New Ops fixes

This commit is contained in:
Jaime Humberto Macias Bustamante
2026-04-21 11:01:22 -07:00
parent 68358bb084
commit 0322624729
4 changed files with 9 additions and 8 deletions
+2 -2
View File
@@ -294,7 +294,7 @@ class Async {
var efor = block([
mk(EVar("_i" + id, call(ident("makeIterator",eit),[eit],eit)),eit),
fun("_", block([
mk(EIf(mk(EUnop("!", true, call( field(it, "hasNext", it), [], it)),it), currentBreak(it)),it),
mk(EIf(mk(EUnop(Unop.OpNot, true, call( field(it, "hasNext", it), [], it)),it), currentBreak(it)),it),
mk(EVar(v, call(field(it, "next",it), [], it)), it),
toCps(eloop, loop, exit),
], it),"_loop" + id),
@@ -303,7 +303,7 @@ class Async {
currentLoop = oldLoop;
currentBreak = oldBreak;
return efor;
case EUnop(op = "!", prefix, eop):
case EUnop(op = Unop.OpNot, prefix, eop):
return toCps(eop, fun("_r",call(rest, [mk(EUnop(op, prefix, ident("_r",e)),e)], e)), exit);
case EBinop(op, e1, e2):
switch( op ) {
+2 -2
View File
@@ -160,7 +160,7 @@ class Bytes {
doEncode(e1);
doEncode(e2);
case EUnop(op,prefix,e):
doEncodeString(op);
doEncodeString(op.toString()); // maybe doEncodeInt
bout.addByte(prefix?1:0);
doEncode(e);
case ECall(e,el):
@@ -282,7 +282,7 @@ class Bytes {
var e1 = doDecode();
EBinop(op,e1,doDecode());
case 7:
var op = doDecodeString();
var op = Unop.fromString(doDecodeString());
var prefix = bin.get(pin++) != 0;
EUnop(op,prefix,doDecode());
case 8:
+2 -2
View File
@@ -1073,10 +1073,10 @@ class Checker {
case EUnop(op, _, e):
var et = typeExpr(e, Value);
switch( op ) {
case "++", "--", "-":
case OpIncrement | OpDecrement | OpNeg:
unify(et,TInt,e);
return et;
case "!":
case OpNot:
unify(et,TBool,e);
return et;
default:
+3 -2
View File
@@ -155,8 +155,9 @@ class Macro {
if( b == null ) throw EInvalidOp(op.toString());
EBinop(b, convert(e1), convert(e2));
case EUnop(op, prefix, e):
var u = unops.get(op);
if( u == null ) throw EInvalidOp(op);
var opStr = op.toString();
var u = unops.get(opStr);
if( u == null ) throw EInvalidOp(opStr);
EUnop(u, !prefix, convert(e));
case ECall(e, params):
ECall(convert(e), map(params, convert));