Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
MXPDS6688 committed Sep 5, 2023
1 parent 1e7039d commit bfc8869
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 72 deletions.
63 changes: 27 additions & 36 deletions GaiaXAnalyze/GXAnalyzeCore/GXAnalyze.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -716,8 +716,7 @@ GXATSNode GXAnalyze::doubleCalculate(GXATSNode left, GXATSNode right, string op)
} else {
result.name = "false";
}
}
else if (op == "?") {
} else if (op == "?") {
if (left.name == "true" || ((left.name != "false" && left.token != "null"))) {
result.name = right.name;
result.token = right.token;
Expand All @@ -728,33 +727,30 @@ GXATSNode GXAnalyze::doubleCalculate(GXATSNode left, GXATSNode right, string op)
result.token = "right";
result.name = "right";
}
}
else if (op == "?:") {
} else if (op == "?:") {
if (left.name == "true" || (left.name != "false" && left.token != "null")) {
result.name = left.name;
result.token = left.token;
} else {
result.name = right.name;
result.token = right.token;
}
}
else if (op == ":") {
} else if (op == ":") {
if (left.token == "right" && left.name == "right") {
result.token = right.token;
result.name = right.name;
} else {
result.token = left.token;
result.name = left.name;
}
}
else if (op == "+") {
} else if (op == "+") {
if ((left.token == "num" || left.token == "long") &&
(right.token == "num" || right.token == "long")) {
if (left.token == "num" || right.token == "num") {
float temp = stof(left.name) + stof(right.name);
result.name = to_string(temp);
result.token = "num";
}else{
} else {
long temp = stol(left.name) + stol(right.name);
result.name = to_string(temp);
result.token = "long";
Expand Down Expand Up @@ -787,16 +783,15 @@ GXATSNode GXAnalyze::doubleCalculate(GXATSNode left, GXATSNode right, string op)
}
}
}
}
else if (op == "-") {
} else if (op == "-") {
if ((left.token == "num" || left.token == "long") &&
(right.token == "num" || right.token == "long")) {

if (left.token == "num" || right.token == "num") {
float temp = stof(left.name) - stof(right.name);
result.name = to_string(temp);
result.token = "num";
}else{
} else {
long temp = stol(left.name) - stol(right.name);
result.name = to_string(temp);
result.token = "long";
Expand All @@ -823,15 +818,14 @@ GXATSNode GXAnalyze::doubleCalculate(GXATSNode left, GXATSNode right, string op)
left.token;
}
}
}
else if (op == "*") {
} else if (op == "*") {
if ((left.token == "num" || left.token == "long") &&
(right.token == "num" || right.token == "long")) {
if (left.token == "num" || right.token == "num") {
float temp = stof(left.name) * stof(right.name);
result.name = to_string(temp);
result.token = "num";
}else{
} else {
long temp = stol(left.name) * stol(right.name);
result.name = to_string(temp);
result.token = "long";
Expand All @@ -858,8 +852,7 @@ GXATSNode GXAnalyze::doubleCalculate(GXATSNode left, GXATSNode right, string op)
left.token;
}
}
}
else if (op == "/") {
} else if (op == "/") {
if ((left.token == "num" || left.token == "long") &&
(right.token == "num" || right.token == "long")) {
if (stof(right.name) == 0) {
Expand All @@ -870,13 +863,13 @@ GXATSNode GXAnalyze::doubleCalculate(GXATSNode left, GXATSNode right, string op)
float temp = stof(left.name) / stof(right.name);
result.name = to_string(temp);
result.token = "num";
}else{
} else {
long temp = stol(left.name) / stol(right.name);
long double tempF = stold(left.name) / stold(right.name);
if(temp != tempF && (left.token == "num" || right.token == "num")){
if (temp != tempF && (left.token == "num" || right.token == "num")) {
result.name = to_string(tempF);
result.token = "num";
}else{
} else {
result.name = to_string(temp);
result.token = "long";
}
Expand Down Expand Up @@ -904,8 +897,7 @@ GXATSNode GXAnalyze::doubleCalculate(GXATSNode left, GXATSNode right, string op)
left.token;
}
}
}
else if (op == "%") {
} else if (op == "%") {
if ((left.token == "num" || left.token == "long") &&
(right.token == "num" || right.token == "long")) {
if (stof(right.name) == 0) {
Expand Down Expand Up @@ -938,8 +930,7 @@ GXATSNode GXAnalyze::doubleCalculate(GXATSNode left, GXATSNode right, string op)
left.token;
}
}
}
else{
} else {
result.token = "error";
result.name = "expressionError: wrong expression";
}
Expand Down Expand Up @@ -1063,7 +1054,7 @@ long GXAnalyze::getValue(string expression, void *source) {
} else if (gxv->tag == GX_TAG_NULL) {
tokenNum.name = "null";
tokenNum.token = "null";
}else{
} else {
tokenNum.name = "null";
tokenNum.token = "null";
}
Expand Down Expand Up @@ -1111,7 +1102,7 @@ long GXAnalyze::getValue(string expression, void *source) {
} else if (gxv->tag == GX_TAG_NULL) {
tokenNum.name = "null";
tokenNum.token = "null";
}else{
} else {
tokenNum.name = "null";
tokenNum.token = "null";
}
Expand Down Expand Up @@ -1162,7 +1153,7 @@ long GXAnalyze::getValue(string expression, void *source) {
pointer = new GXValue(GX_TAG_ARRAY, (void *) atol(res.name.c_str()));
} else if (res.token == "null") {
pointer = new GXValue(GX_TAG_NULL, 1);
}else{
} else {
pointer = new GXValue(GX_TAG_NULL, 1);
}
Res = (long) pointer;
Expand Down Expand Up @@ -1268,7 +1259,7 @@ GXAnalyze::calculateCache(string cacheString, vector<GXATSNode> array, void *p_a
} else if (node.token == "null") {
GXValue *par = new GXValue(GX_TAG_NULL, 1);
paramsTempArray.push_back((long) par);
}else{
} else {
GXValue *par = new GXValue(GX_TAG_NULL, 1);
paramsTempArray.push_back((long) par);
}
Expand Down Expand Up @@ -1313,7 +1304,7 @@ GXAnalyze::calculateCache(string cacheString, vector<GXATSNode> array, void *p_a
} else if (node.token == "null") {
GXValue *par = new GXValue(GX_TAG_NULL, 1);
paramsTempArray.push_back((long) par);
}else{
} else {
GXValue *par = new GXValue(GX_TAG_NULL, 1);
paramsTempArray.push_back((long) par);
}
Expand Down Expand Up @@ -1383,7 +1374,7 @@ GXAnalyze::calculateCache(string cacheString, vector<GXATSNode> array, void *p_a
} else if (fun->tag == GX_TAG_NULL) {
node.name = "null";
node.token = "null";
}else{
} else {
node.name = "null";
node.token = "null";
}
Expand Down Expand Up @@ -1432,7 +1423,7 @@ GXAnalyze::calculateCache(string cacheString, vector<GXATSNode> array, void *p_a
pointer = new GXValue(GX_TAG_ARRAY, (void *) atol(res.name.c_str()));
} else if (res.token == "null") {
pointer = new GXValue(GX_TAG_NULL, 1);
}else{
} else {
pointer = new GXValue(GX_TAG_NULL, 1);
}

Expand Down Expand Up @@ -1497,7 +1488,7 @@ long GXAnalyze::check(string s, vector<GXATSNode> array, void *p_analyze, void *
pointer = new GXValue(GX_TAG_ARRAY, (void *) atol(valueStack[0].name.c_str()));
} else if (valueStack[0].token == "null") {
pointer = new GXValue(GX_TAG_NULL, 1);
}else{
} else {
pointer = new GXValue(GX_TAG_NULL, 1);
}
delete[] statusStack;
Expand Down Expand Up @@ -1576,7 +1567,7 @@ long GXAnalyze::check(string s, vector<GXATSNode> array, void *p_analyze, void *
} else if (gxv->tag == GX_TAG_NULL) {
t1.name = "null";
t1.token = "null";
}else{
} else {
t1.name = "null";
t1.token = "null";
}
Expand Down Expand Up @@ -1630,7 +1621,7 @@ long GXAnalyze::check(string s, vector<GXATSNode> array, void *p_analyze, void *
} else if (gxv->tag == GX_TAG_NULL) {
t1.name = "null";
t1.token = "null";
}else{
} else {
t1.name = "null";
t1.token = "null";
}
Expand Down Expand Up @@ -1788,7 +1779,7 @@ long GXAnalyze::check(string s, vector<GXATSNode> array, void *p_analyze, void *
} else if (fun->tag == GX_TAG_NULL) {
tempR.name = "null";
tempR.token = "null";
}else{
} else {
tempR.name = "null";
tempR.token = "null";
}
Expand Down Expand Up @@ -1840,7 +1831,7 @@ long GXAnalyze::check(string s, vector<GXATSNode> array, void *p_analyze, void *
} else if (valueStack[i].token == "null") {
GXValue *par = new GXValue(GX_TAG_NULL, 1);
paramsTempArray.push_back((long) par);
}else{
} else {
GXValue *par = new GXValue(GX_TAG_NULL, 1);
paramsTempArray.push_back((long) par);
}
Expand Down
Loading

0 comments on commit bfc8869

Please sign in to comment.