瀏覽代碼

be more relaxed about pointer comparisons

master
Ian Piumarta 3 月之前
父節點
當前提交
f411e2d569
共有 1 個檔案被更改,包括 3 行新增3 行删除
  1. +3
    -3
      main.leg

+ 3
- 3
main.leg 查看文件

@ -1,6 +1,6 @@
# main.leg -- C parser + interpreter
#
# Last edited: 2025-02-01 10:02:43 by piumarta on xubuntu
# Last edited: 2025-02-01 10:15:19 by piumarta on xubuntu
%{
;
@ -3319,12 +3319,12 @@ int compare(oop a, oop b)
if (a == b) return 0;
type_t ta = getType(a), tb = getType(b);
if (ta == tb) {
switch (getType(a)) {
switch (ta) {
case Integer: return CMP(_integerValue(a), _integerValue(b));
case Float: return CMP( _floatValue(a), _floatValue(b));
case Pointer: {
oop ba = get(a, Pointer,base), bb = get(b, Pointer,base);
if (ba != bb) fatal("comparing pointers to different objects");
if (ba != bb) return CMP((intptr_t)ba, (intptr_t)bb);
int oa = get(a, Pointer,offset), ob = get(b, Pointer,offset);
return CMP(oa, ob);
}

Loading…
取消
儲存