Skip to content

Commit

Permalink
Add compare VPointer
Browse files Browse the repository at this point in the history
  • Loading branch information
yuxiaomao committed May 22, 2024
1 parent ffcddbb commit 3913067
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion hld/Eval.hx
Original file line number Diff line number Diff line change
Expand Up @@ -496,11 +496,15 @@ class Eval {

function compare(a:Value,b:Value) : Int {
switch [a.v, b.v] {
case [VPointer(aptr), VPointer(bptr)]:
return aptr.sub(bptr);
case [VString(as,_), VString(bs,_)]:
return Reflect.compare(as, bs);
default:
case [VInt(_) | VFloat(_), VInt(_) | VFloat(_)]:
var d = getNum(a) - getNum(b);
return d == 0 ? 0 : d > 0 ? 1 : -1;
default:
throw "Don't know how to compare " + a.v.getName() + " and " + b.v.getName();
}
}

Expand Down

0 comments on commit 3913067

Please sign in to comment.