Skip to content

Commit

Permalink
Added missing unary constants
Browse files Browse the repository at this point in the history
  • Loading branch information
maccasoft committed Oct 23, 2023
1 parent e1fd9e9 commit ef3e426
Showing 1 changed file with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
import com.maccasoft.propeller.expressions.Context;
import com.maccasoft.propeller.expressions.ContextLiteral;
import com.maccasoft.propeller.expressions.DataVariable;
import com.maccasoft.propeller.expressions.Decod;
import com.maccasoft.propeller.expressions.Divide;
import com.maccasoft.propeller.expressions.Encod;
import com.maccasoft.propeller.expressions.Equals;
import com.maccasoft.propeller.expressions.Expression;
import com.maccasoft.propeller.expressions.GreaterOrEquals;
Expand All @@ -43,6 +45,7 @@
import com.maccasoft.propeller.expressions.LessThanUnsigned;
import com.maccasoft.propeller.expressions.LocalVariable;
import com.maccasoft.propeller.expressions.LogicalAnd;
import com.maccasoft.propeller.expressions.LogicalNot;
import com.maccasoft.propeller.expressions.LogicalOr;
import com.maccasoft.propeller.expressions.LogicalXor;
import com.maccasoft.propeller.expressions.MemoryContextLiteral;
Expand Down Expand Up @@ -1282,6 +1285,11 @@ else if (node.getType() == Token.STRING) {
return new Xor(buildConstantExpression(context, node.getChild(0), registerConstant), buildConstantExpression(context, node.getChild(1), registerConstant));
case "|":
return new Or(buildConstantExpression(context, node.getChild(0), registerConstant), buildConstantExpression(context, node.getChild(1), registerConstant));
case "!":
if (node.getChildCount() != 1) {
throw new RuntimeException("misplaced unary operator (" + node.getText() + ")");
}
return new Not(buildConstantExpression(context, node.getChild(0), registerConstant));

case "*":
case "*.":
Expand Down Expand Up @@ -1329,6 +1337,12 @@ else if (node.getType() == Token.STRING) {
case "^^":
case "XOR":
return new LogicalXor(buildConstantExpression(context, node.getChild(0), registerConstant), buildConstantExpression(context, node.getChild(1), registerConstant));
case "!!":
case "NOT":
if (node.getChildCount() != 1) {
throw new RuntimeException("misplaced unary operator (" + node.getText() + ")");
}
return new LogicalNot(buildConstantExpression(context, node.getChild(0), registerConstant));

case "<":
case "<.":
Expand Down Expand Up @@ -1361,12 +1375,6 @@ else if (node.getType() == Token.STRING) {
case "<=>":
return new Compare(buildConstantExpression(context, node.getChild(0), registerConstant), buildConstantExpression(context, node.getChild(1), registerConstant));

case "!":
if (node.getChildCount() == 1) {
return new Not(buildConstantExpression(context, node.getChild(0), registerConstant));
}
throw new RuntimeException("unary operator with " + node.getChildCount() + " arguments");

case "?": {
Expression right = buildConstantExpression(context, node.getChild(1), registerConstant);
if (!(right instanceof IfElse)) {
Expand All @@ -1377,6 +1385,17 @@ else if (node.getType() == Token.STRING) {
case ":":
return new IfElse(null, buildConstantExpression(context, node.getChild(0), registerConstant), buildConstantExpression(context, node.getChild(1), registerConstant));

case "ENCOD":
if (node.getChildCount() != 1) {
throw new RuntimeException("misplaced unary operator (" + node.getText() + ")");
}
return new Encod(buildConstantExpression(context, node.getChild(0), registerConstant));
case "DECOD":
if (node.getChildCount() != 1) {
throw new RuntimeException("misplaced unary operator (" + node.getText() + ")");
}
return new Decod(buildConstantExpression(context, node.getChild(0), registerConstant));

case "TRUNC":
if (node.getChildCount() != 1) {
throw new RuntimeException("misplaced unary operator (" + node.getText() + ")");
Expand Down

0 comments on commit ef3e426

Please sign in to comment.