Binop
This commit is contained in:
+536
-536
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -156,7 +156,7 @@ class Bytes {
|
||||
doEncode(e);
|
||||
doEncodeString(f);
|
||||
case EBinop(op,e1,e2):
|
||||
doEncodeString(op);
|
||||
doEncodeString(op.toString());
|
||||
doEncode(e1);
|
||||
doEncode(e2);
|
||||
case EUnop(op,prefix,e):
|
||||
@@ -278,7 +278,7 @@ class Bytes {
|
||||
var e = doDecode();
|
||||
EField(e,doDecodeString());
|
||||
case 6:
|
||||
var op = doDecodeString();
|
||||
var op = Binop.fromString(doDecodeString());
|
||||
var e1 = doDecode();
|
||||
EBinop(op,e1,doDecode());
|
||||
case 7:
|
||||
|
||||
+28
-14
@@ -1113,11 +1113,11 @@ class Checker {
|
||||
return TVoid;
|
||||
case EBinop(op, e1, e2):
|
||||
switch( op ) {
|
||||
case "&", "|", "^", ">>", ">>>", "<<":
|
||||
case OpAnd, OpOr, OpXor, OpShr, OpUshr, OpShl:
|
||||
typeExprWith(e1,TInt);
|
||||
typeExprWith(e2,TInt);
|
||||
return TInt;
|
||||
case "=":
|
||||
case OpAssign:
|
||||
if( allowDefine ) {
|
||||
switch( edef(e1) ) {
|
||||
case EIdent(i) if( !locals.exists(i) && !globals.exists(i) ):
|
||||
@@ -1133,7 +1133,7 @@ class Checker {
|
||||
}
|
||||
typeExprWith(e2,vt);
|
||||
return vt;
|
||||
case "+":
|
||||
case OpAdd:
|
||||
var t1 = typeExpr(e1,WithType(TInt));
|
||||
var t2 = typeExpr(e2,WithType(t1));
|
||||
tryUnify(t1,t2);
|
||||
@@ -1150,14 +1150,14 @@ class Checker {
|
||||
unify(t1, TFloat, e1);
|
||||
unify(t2, TFloat, e2);
|
||||
}
|
||||
case "-", "*", "/", "%":
|
||||
case OpSub, OpMult, OpDiv, OpMod:
|
||||
var t1 = typeExpr(e1,WithType(TInt));
|
||||
var t2 = typeExpr(e2,WithType(t1));
|
||||
if( !tryUnify(t1,t2) )
|
||||
unify(t2,t1,e2);
|
||||
switch( [follow(t1), follow(t2)]) {
|
||||
case [TInt, TInt]:
|
||||
if( op == "/" ) return TFloat;
|
||||
if( op == OpDiv ) return TFloat;
|
||||
return TInt;
|
||||
case [TFloat|TDynamic, TInt|TDynamic], [TInt|TDynamic, TFloat|TDynamic], [TFloat, TFloat]:
|
||||
return TFloat;
|
||||
@@ -1165,21 +1165,21 @@ class Checker {
|
||||
unify(t1, TFloat, e1);
|
||||
unify(t2, TFloat, e2);
|
||||
}
|
||||
case "&&", "||":
|
||||
case OpBoolAnd, OpBoolOr:
|
||||
typeExprWith(e1,TBool);
|
||||
typeExprWith(e2,TBool);
|
||||
return TBool;
|
||||
case "...":
|
||||
case OpInterval:
|
||||
typeExprWith(e1,TInt);
|
||||
typeExprWith(e2,TInt);
|
||||
return makeIterator(TInt);
|
||||
case "==", "!=":
|
||||
case OpEq, OpNeq:
|
||||
var t1 = typeExpr(e1,Value);
|
||||
var t2 = typeExpr(e2,WithType(t1));
|
||||
if( !tryUnify(t1,t2) )
|
||||
unify(t2,t1,e2);
|
||||
return TBool;
|
||||
case ">", "<", ">=", "<=":
|
||||
case OpGt, OpLt, OpGte, OpLte:
|
||||
var t1 = typeExpr(e1,Value);
|
||||
var t2 = typeExpr(e2,WithType(t1));
|
||||
if( !tryUnify(t1,t2) )
|
||||
@@ -1190,12 +1190,26 @@ class Checker {
|
||||
error("Cannot compare "+typeStr(t1), expr);
|
||||
}
|
||||
return TBool;
|
||||
case OpAddAssign, OpSubAssign, OpMultAssign, OpDivAssign, OpModAssign, OpAndAssign, OpOrAssign, OpXorAssign, OpShlAssign, OpShrAssign, OpUshrAssign, OpNcoalAssign:
|
||||
var baseOp = switch(op) {
|
||||
case OpAddAssign: OpAdd;
|
||||
case OpSubAssign: OpSub;
|
||||
case OpMultAssign: OpMult;
|
||||
case OpDivAssign: OpDiv;
|
||||
case OpModAssign: OpMod;
|
||||
case OpAndAssign: OpAnd;
|
||||
case OpOrAssign: OpOr;
|
||||
case OpXorAssign: OpXor;
|
||||
case OpShlAssign: OpShl;
|
||||
case OpShrAssign: OpShr;
|
||||
case OpUshrAssign: OpUshr;
|
||||
case OpNcoalAssign: OpNcoal;
|
||||
default: op;
|
||||
};
|
||||
var t = typeExpr(mk(EBinop(baseOp,e1,e2),expr),withType);
|
||||
return typeExpr(mk(EBinop(OpAssign,e1,e2),expr), withType);
|
||||
default:
|
||||
if( op.charCodeAt(op.length-1) == "=".code ) {
|
||||
var t = typeExpr(mk(EBinop(op.substr(0,op.length-1),e1,e2),expr),withType);
|
||||
return typeExpr(mk(EBinop("=",e1,e2),expr), withType);
|
||||
}
|
||||
error("Unsupported operation "+op, expr);
|
||||
error("Unsupported operation "+op.toString(), expr);
|
||||
}
|
||||
case ETry(etry, v, et, ecatch):
|
||||
var vt = typeExpr(etry, withType);
|
||||
|
||||
+127
-1
@@ -28,6 +28,132 @@ typedef Int64 = #if cpp cpp.Int64 #elseif java java.Int64 #elseif cs cs.Int64 #e
|
||||
|
||||
typedef UInt8 = #if cpp cpp.UInt8 #elseif cs cs.UInt8 #else Int #end;
|
||||
typedef UInt16 = #if cpp cpp.UInt16 #elseif cs cs.UInt16 #else Int #end;
|
||||
|
||||
enum abstract Binop(Int) from Int to Int {
|
||||
var OpAdd = 0;
|
||||
var OpSub = 1;
|
||||
var OpMult = 2;
|
||||
var OpDiv = 3;
|
||||
var OpMod = 4;
|
||||
var OpAnd = 5;
|
||||
var OpOr = 6;
|
||||
var OpXor = 7;
|
||||
var OpShl = 8;
|
||||
var OpShr = 9;
|
||||
var OpUshr = 10;
|
||||
var OpEq = 11;
|
||||
var OpNeq = 12;
|
||||
var OpGte = 13;
|
||||
var OpLte = 14;
|
||||
var OpGt = 15;
|
||||
var OpLt = 16;
|
||||
var OpBoolOr = 17;
|
||||
var OpBoolAnd = 18;
|
||||
var OpIs = 19;
|
||||
var OpAssign = 20;
|
||||
var OpNcoal = 21;
|
||||
var OpInterval = 22;
|
||||
var OpArrow = 23;
|
||||
var OpAddAssign = 24;
|
||||
var OpSubAssign = 25;
|
||||
var OpMultAssign = 26;
|
||||
var OpDivAssign = 27;
|
||||
var OpModAssign = 28;
|
||||
var OpAndAssign = 29;
|
||||
var OpOrAssign = 30;
|
||||
var OpXorAssign = 31;
|
||||
var OpShlAssign = 32;
|
||||
var OpShrAssign = 33;
|
||||
var OpUshrAssign = 34;
|
||||
var OpNcoalAssign = 35;
|
||||
var OpArrowFn = 36;
|
||||
|
||||
public static inline function fromString(s:String):Binop {
|
||||
return switch(s) {
|
||||
case "+": OpAdd;
|
||||
case "-": OpSub;
|
||||
case "*": OpMult;
|
||||
case "/": OpDiv;
|
||||
case "%": OpMod;
|
||||
case "&": OpAnd;
|
||||
case "|": OpOr;
|
||||
case "^": OpXor;
|
||||
case "<<": OpShl;
|
||||
case ">>": OpShr;
|
||||
case ">>>": OpUshr;
|
||||
case "==": OpEq;
|
||||
case "!=": OpNeq;
|
||||
case ">=": OpGte;
|
||||
case "<=": OpLte;
|
||||
case ">": OpGt;
|
||||
case "<": OpLt;
|
||||
case "||": OpBoolOr;
|
||||
case "&&": OpBoolAnd;
|
||||
case "is": OpIs;
|
||||
case "=": OpAssign;
|
||||
case "??": OpNcoal;
|
||||
case "...": OpInterval;
|
||||
case "->": OpArrow;
|
||||
case "=>": OpArrowFn;
|
||||
case "+=": OpAddAssign;
|
||||
case "-=": OpSubAssign;
|
||||
case "*=": OpMultAssign;
|
||||
case "/=": OpDivAssign;
|
||||
case "%=": OpModAssign;
|
||||
case "&=": OpAndAssign;
|
||||
case "|=": OpOrAssign;
|
||||
case "^=": OpXorAssign;
|
||||
case "<<=": OpShlAssign;
|
||||
case ">>=": OpShrAssign;
|
||||
case ">>>=": OpUshrAssign;
|
||||
case "??=": OpNcoalAssign;
|
||||
default: -1;
|
||||
}
|
||||
}
|
||||
|
||||
public inline function toString():String {
|
||||
return switch(this) {
|
||||
case OpAdd: "+";
|
||||
case OpSub: "-";
|
||||
case OpMult: "*";
|
||||
case OpDiv: "/";
|
||||
case OpMod: "%";
|
||||
case OpAnd: "&";
|
||||
case OpOr: "|";
|
||||
case OpXor: "^";
|
||||
case OpShl: "<<";
|
||||
case OpShr: ">>";
|
||||
case OpUshr: ">>>";
|
||||
case OpEq: "==";
|
||||
case OpNeq: "!=";
|
||||
case OpGte: ">=";
|
||||
case OpLte: "<=";
|
||||
case OpGt: ">";
|
||||
case OpLt: "<";
|
||||
case OpBoolOr: "||";
|
||||
case OpBoolAnd: "&&";
|
||||
case OpIs: "is";
|
||||
case OpAssign: "=";
|
||||
case OpNcoal: "??";
|
||||
case OpInterval: "...";
|
||||
case OpArrow: "->";
|
||||
case OpArrowFn: "=>";
|
||||
case OpAddAssign: "+=";
|
||||
case OpSubAssign: "-=";
|
||||
case OpMultAssign: "*=";
|
||||
case OpDivAssign: "/=";
|
||||
case OpModAssign: "%=";
|
||||
case OpAndAssign: "&=";
|
||||
case OpOrAssign: "|=";
|
||||
case OpXorAssign: "^=";
|
||||
case OpShlAssign: "<<=";
|
||||
case OpShrAssign: ">>=";
|
||||
case OpUshrAssign: ">>>=";
|
||||
case OpNcoalAssign: "??=";
|
||||
default: "?";
|
||||
}
|
||||
}
|
||||
}
|
||||
typedef UInt32 = #if cpp cpp.UInt32 #else Int #end;
|
||||
typedef UInt64 = #if cpp cpp.UInt64 #else Int #end;
|
||||
|
||||
@@ -57,7 +183,7 @@ enum Expr {
|
||||
EParent( e : Expr );
|
||||
EBlock( e : Array<Expr> );
|
||||
EField( e : Expr, f : String , ?safe : Bool );
|
||||
EBinop( op : String, e1 : Expr, e2 : Expr );
|
||||
EBinop( op : Binop, e1 : Expr, e2 : Expr );
|
||||
EUnop( op : String, prefix : Bool, e : Expr );
|
||||
ECall( e : Expr, params : Array<Expr> );
|
||||
EIf( cond : Expr, e1 : Expr, ?e2 : Expr );
|
||||
|
||||
+45
-58
@@ -144,7 +144,6 @@ class Interp {
|
||||
|
||||
// warning can be null
|
||||
public var locals:Map<String, DeclaredVar>;
|
||||
var binops:StringMap<Expr->Expr->Dynamic>;
|
||||
|
||||
var depth:Int = 0;
|
||||
var inTry:Bool;
|
||||
@@ -179,7 +178,6 @@ class Interp {
|
||||
locals = new Map();
|
||||
declared = [];
|
||||
resetVariables();
|
||||
initOps();
|
||||
}
|
||||
|
||||
private function resetVariables():Void {
|
||||
@@ -210,49 +208,6 @@ class Interp {
|
||||
return cast {fileName: "hscript", lineNumber: 0};
|
||||
}
|
||||
|
||||
function initOps():Void {
|
||||
var me = this;
|
||||
binops = new StringMap<Expr -> Expr -> Dynamic>();
|
||||
binops.set("+", function(e1, e2) return me.expr(e1) + me.expr(e2));
|
||||
binops.set("-", function(e1, e2) return me.expr(e1) - me.expr(e2));
|
||||
binops.set("*", function(e1, e2) return me.expr(e1) * me.expr(e2));
|
||||
binops.set("/", function(e1, e2) return me.expr(e1) / me.expr(e2));
|
||||
binops.set("%", function(e1, e2) return me.expr(e1) % me.expr(e2));
|
||||
binops.set("&", function(e1, e2) return me.expr(e1) & me.expr(e2));
|
||||
binops.set("|", function(e1, e2) return me.expr(e1) | me.expr(e2));
|
||||
binops.set("^", function(e1, e2) return me.expr(e1) ^ me.expr(e2));
|
||||
binops.set("<<", function(e1, e2) return me.expr(e1) << me.expr(e2));
|
||||
binops.set(">>", function(e1, e2) return me.expr(e1) >> me.expr(e2));
|
||||
binops.set(">>>", function(e1, e2) return me.expr(e1) >>> me.expr(e2));
|
||||
binops.set("==", function(e1, e2) return me.expr(e1) == me.expr(e2));
|
||||
binops.set("!=", function(e1, e2) return me.expr(e1) != me.expr(e2));
|
||||
binops.set(">=", function(e1, e2) return me.expr(e1) >= me.expr(e2));
|
||||
binops.set("<=", function(e1, e2) return me.expr(e1) <= me.expr(e2));
|
||||
binops.set(">", function(e1, e2) return me.expr(e1) > me.expr(e2));
|
||||
binops.set("<", function(e1, e2) return me.expr(e1) < me.expr(e2));
|
||||
binops.set("||", function(e1, e2) return me.expr(e1) == true || me.expr(e2) == true);
|
||||
binops.set("&&", function(e1, e2) return me.expr(e1) == true && me.expr(e2) == true);
|
||||
binops.set("is", checkIsType);
|
||||
binops.set("=", assign);
|
||||
binops.set("??", function(e1, e2) {
|
||||
var expr1:Dynamic = me.expr(e1);
|
||||
return expr1 == null ? me.expr(e2) : expr1;
|
||||
});
|
||||
binops.set("...", function(e1, e2) return new IntIterator(me.expr(e1), me.expr(e2)));
|
||||
assignOp("+=", function(v1:Dynamic, v2:Dynamic) return v1 + v2);
|
||||
assignOp("-=", function(v1:Float, v2:Float) return v1 - v2);
|
||||
assignOp("*=", function(v1:Float, v2:Float) return v1 * v2);
|
||||
assignOp("/=", function(v1:Float, v2:Float) return v1 / v2);
|
||||
assignOp("%=", function(v1:Float, v2:Float) return v1 % v2);
|
||||
assignOp("&=", function(v1, v2) return v1 & v2);
|
||||
assignOp("|=", function(v1, v2) return v1 | v2);
|
||||
assignOp("^=", function(v1, v2) return v1 ^ v2);
|
||||
assignOp("<<=", function(v1, v2) return v1 << v2);
|
||||
assignOp(">>=", function(v1, v2) return v1 >> v2);
|
||||
assignOp(">>>=", function(v1, v2) return v1 >>> v2);
|
||||
assignOp("??" + "=", function(v1, v2) return v1 == null ? v2 : v1);
|
||||
}
|
||||
|
||||
function checkIsType(e1:Expr,e2:Expr): Bool {
|
||||
var expr1:Dynamic = expr(e1);
|
||||
|
||||
@@ -371,12 +326,7 @@ class Interp {
|
||||
return v;
|
||||
}
|
||||
|
||||
function assignOp(op:String, fop:Dynamic->Dynamic->Dynamic):Void {
|
||||
var me = this;
|
||||
binops.set(op, function(e1, e2) return me.evalAssignOp(op, fop, e1, e2));
|
||||
}
|
||||
|
||||
function evalAssignOp(op:String, fop:Dynamic->Dynamic->Dynamic, e1:Expr, e2:Expr):Dynamic {
|
||||
function evalAssignOp(op:Binop, fop:Dynamic->Dynamic->Dynamic, e1:Expr, e2:Expr):Dynamic {
|
||||
var v;
|
||||
switch (Tools.expr(e1)) {
|
||||
case EIdent(id):
|
||||
@@ -458,7 +408,7 @@ class Interp {
|
||||
arr[index] = v;
|
||||
}
|
||||
default:
|
||||
return error(EInvalidOp(op));
|
||||
return error(EInvalidOp(op.toString()));
|
||||
}
|
||||
return v;
|
||||
}
|
||||
@@ -1117,10 +1067,47 @@ class Interp {
|
||||
}
|
||||
return get(field, f);
|
||||
case EBinop(op, e1, e2):
|
||||
var fop = binops.get(op);
|
||||
if (fop == null)
|
||||
error(EInvalidOp(op));
|
||||
return fop(e1, e2);
|
||||
return switch(op) {
|
||||
case OpAdd: expr(e1) + expr(e2);
|
||||
case OpSub: expr(e1) - expr(e2);
|
||||
case OpMult: expr(e1) * expr(e2);
|
||||
case OpDiv: expr(e1) / expr(e2);
|
||||
case OpMod: expr(e1) % expr(e2);
|
||||
case OpAnd: expr(e1) & expr(e2);
|
||||
case OpOr: expr(e1) | expr(e2);
|
||||
case OpXor: expr(e1) ^ expr(e2);
|
||||
case OpShl: expr(e1) << expr(e2);
|
||||
case OpShr: expr(e1) >> expr(e2);
|
||||
case OpUshr: expr(e1) >>> expr(e2);
|
||||
case OpEq: expr(e1) == expr(e2);
|
||||
case OpNeq: expr(e1) != expr(e2);
|
||||
case OpGte: expr(e1) >= expr(e2);
|
||||
case OpLte: expr(e1) <= expr(e2);
|
||||
case OpGt: expr(e1) > expr(e2);
|
||||
case OpLt: expr(e1) < expr(e2);
|
||||
case OpBoolOr: expr(e1) == true || expr(e2) == true;
|
||||
case OpBoolAnd: expr(e1) == true && expr(e2) == true;
|
||||
case OpIs: checkIsType(e1, e2);
|
||||
case OpAssign: assign(e1, e2);
|
||||
case OpNcoal:
|
||||
var expr1:Dynamic = expr(e1);
|
||||
expr1 == null ? expr(e2) : expr1;
|
||||
case OpInterval: new IntIterator(expr(e1), expr(e2));
|
||||
case OpArrow: null;
|
||||
case OpAddAssign: evalAssignOp(OpAddAssign, function(v1:Dynamic, v2:Dynamic) return v1 + v2, e1, e2);
|
||||
case OpSubAssign: evalAssignOp(OpSubAssign, function(v1:Float, v2:Float) return v1 - v2, e1, e2);
|
||||
case OpMultAssign: evalAssignOp(OpMultAssign, function(v1:Float, v2:Float) return v1 * v2, e1, e2);
|
||||
case OpDivAssign: evalAssignOp(OpDivAssign, function(v1:Float, v2:Float) return v1 / v2, e1, e2);
|
||||
case OpModAssign: evalAssignOp(OpModAssign, function(v1:Float, v2:Float) return v1 % v2, e1, e2);
|
||||
case OpAndAssign: evalAssignOp(OpAndAssign, function(v1, v2) return v1 & v2, e1, e2);
|
||||
case OpOrAssign: evalAssignOp(OpOrAssign, function(v1, v2) return v1 | v2, e1, e2);
|
||||
case OpXorAssign: evalAssignOp(OpXorAssign, function(v1, v2) return v1 ^ v2, e1, e2);
|
||||
case OpShlAssign: evalAssignOp(OpShlAssign, function(v1, v2) return v1 << v2, e1, e2);
|
||||
case OpShrAssign: evalAssignOp(OpShrAssign, function(v1, v2) return v1 >> v2, e1, e2);
|
||||
case OpUshrAssign: evalAssignOp(OpUshrAssign, function(v1, v2) return v1 >>> v2, e1, e2);
|
||||
case OpNcoalAssign: evalAssignOp(OpNcoalAssign, function(v1, v2) return v1 == null ? v2 : v1, e1, e2);
|
||||
default: error(EInvalidOp(op.toString()));
|
||||
}
|
||||
case EUnop(op, prefix, e):
|
||||
switch (op) {
|
||||
case "!":
|
||||
@@ -1275,7 +1262,7 @@ class Interp {
|
||||
}
|
||||
|
||||
if (!isMap && arr.length > 0) {
|
||||
isMap = Tools.expr(arr[0]).match(EBinop("=>", _));
|
||||
isMap = Tools.expr(arr[0]).match(EBinop(OpArrowFn, _));
|
||||
}
|
||||
|
||||
// TODO: separate this into a function
|
||||
@@ -1289,7 +1276,7 @@ class Interp {
|
||||
|
||||
for (e in arr) {
|
||||
switch (Tools.expr(e)) {
|
||||
case EBinop("=>", eKey, eValue):
|
||||
case EBinop(OpArrowFn, eKey, eValue):
|
||||
var key:Dynamic = expr(eKey);
|
||||
var value:Dynamic = expr(eValue);
|
||||
isAllString = isAllString && (key is String);
|
||||
|
||||
+2
-2
@@ -151,8 +151,8 @@ class Macro {
|
||||
case EField(e, f):
|
||||
EField(convert(e), f);
|
||||
case EBinop(op, e1, e2):
|
||||
var b = binops.get(op);
|
||||
if( b == null ) throw EInvalidOp(op);
|
||||
var b = binops.get(op.toString());
|
||||
if( b == null ) throw EInvalidOp(op.toString());
|
||||
EBinop(b, convert(e1), convert(e2));
|
||||
case EUnop(op, prefix, e):
|
||||
var u = unops.get(op);
|
||||
|
||||
+9
-8
@@ -609,22 +609,23 @@ class Parser {
|
||||
}
|
||||
|
||||
@:analyzer(fusion) inline function makeBinop( op:String, e1:Expr, e:Expr ):Expr {
|
||||
var binop = Binop.fromString(op);
|
||||
if( e == null && resumeErrors )
|
||||
return mk(EBinop(op,e1,e),pmin(e1),pmax(e1));
|
||||
return mk(EBinop(binop,e1,e),pmin(e1),pmax(e1));
|
||||
return switch( expr(e) ) {
|
||||
case EBinop(op2,e2,e3):
|
||||
var delta = opPriority.get(op) - opPriority.get(op2);
|
||||
var delta = opPriority.get(op) - opPriority.get(op2.toString());
|
||||
if( delta < 0 || (delta == 0 && !opRightAssoc.exists(op)) )
|
||||
mk(EBinop(op2,makeBinop(op,e1,e2),e3),pmin(e1),pmax(e3));
|
||||
else
|
||||
mk(EBinop(op, e1, e), pmin(e1), pmax(e));
|
||||
mk(EBinop(binop, e1, e), pmin(e1), pmax(e));
|
||||
case ETernary(e2,e3,e4):
|
||||
if( opRightAssoc.exists(op) )
|
||||
mk(EBinop(op,e1,e),pmin(e1),pmax(e));
|
||||
mk(EBinop(binop,e1,e),pmin(e1),pmax(e));
|
||||
else
|
||||
mk(ETernary(makeBinop(op, e1, e2), e3, e4), pmin(e1), pmax(e));
|
||||
default:
|
||||
mk(EBinop(op,e1,e),pmin(e1),pmax(e));
|
||||
mk(EBinop(binop,e1,e),pmin(e1),pmax(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1737,7 +1738,7 @@ class Parser {
|
||||
var expr:Null<Expr> = exprs.shift();
|
||||
while(true) {
|
||||
if(exprs.length == 0) break;
|
||||
expr = mk(EBinop('+', expr, exprs.shift()));
|
||||
expr = mk(EBinop(OpAdd, expr, exprs.shift()));
|
||||
}
|
||||
return expr;
|
||||
}
|
||||
@@ -2443,9 +2444,9 @@ class Parser {
|
||||
return !evalPreproCond(e);
|
||||
case EParent(e):
|
||||
return evalPreproCond(e);
|
||||
case EBinop("&&", e1, e2):
|
||||
case EBinop(OpBoolAnd, e1, e2):
|
||||
return evalPreproCond(e1) && evalPreproCond(e2);
|
||||
case EBinop("||", e1, e2):
|
||||
case EBinop(OpBoolOr, e1, e2):
|
||||
return evalPreproCond(e1) || evalPreproCond(e2);
|
||||
default:
|
||||
error(EInvalidPreprocessor("Can't eval " + expr(e).getName()), readPos, readPos);
|
||||
|
||||
+1
-1
@@ -276,7 +276,7 @@ class Printer {
|
||||
add((s == true ? "?." : ".") + f);
|
||||
case EBinop(op, e1, e2):
|
||||
expr(e1);
|
||||
add(" " + op + " ");
|
||||
add(" " + op.toString() + " ");
|
||||
expr(e2);
|
||||
case EUnop(op, pre, e):
|
||||
if( pre ) {
|
||||
|
||||
Reference in New Issue
Block a user