From 0322624729ad539f1f1bcb2399a523f9a6e9f546 Mon Sep 17 00:00:00 2001 From: Jaime Humberto Macias Bustamante Date: Tue, 21 Apr 2026 11:01:22 -0700 Subject: [PATCH] New Ops fixes --- hscript/Async.hx | 4 ++-- hscript/Bytes.hx | 4 ++-- hscript/Checker.hx | 4 ++-- hscript/Macro.hx | 5 +++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/hscript/Async.hx b/hscript/Async.hx index 313de3e..4e39818 100644 --- a/hscript/Async.hx +++ b/hscript/Async.hx @@ -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 ) { diff --git a/hscript/Bytes.hx b/hscript/Bytes.hx index 27b2ec0..e60e33b 100644 --- a/hscript/Bytes.hx +++ b/hscript/Bytes.hx @@ -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: diff --git a/hscript/Checker.hx b/hscript/Checker.hx index a19425e..1eec60a 100644 --- a/hscript/Checker.hx +++ b/hscript/Checker.hx @@ -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: diff --git a/hscript/Macro.hx b/hscript/Macro.hx index 38e3a9b..0ed684c 100644 --- a/hscript/Macro.hx +++ b/hscript/Macro.hx @@ -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));