|
@ -1,6 +1,6 @@ |
|
|
# main.leg -- C parser + interpreter |
|
|
# 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; |
|
|
if (a == b) return 0; |
|
|
type_t ta = getType(a), tb = getType(b); |
|
|
type_t ta = getType(a), tb = getType(b); |
|
|
if (ta == tb) { |
|
|
if (ta == tb) { |
|
|
switch (getType(a)) { |
|
|
|
|
|
|
|
|
switch (ta) { |
|
|
case Integer: return CMP(_integerValue(a), _integerValue(b)); |
|
|
case Integer: return CMP(_integerValue(a), _integerValue(b)); |
|
|
case Float: return CMP( _floatValue(a), _floatValue(b)); |
|
|
case Float: return CMP( _floatValue(a), _floatValue(b)); |
|
|
case Pointer: { |
|
|
case Pointer: { |
|
|
oop ba = get(a, Pointer,base), bb = get(b, Pointer,base); |
|
|
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); |
|
|
int oa = get(a, Pointer,offset), ob = get(b, Pointer,offset); |
|
|
return CMP(oa, ob); |
|
|
return CMP(oa, ob); |
|
|
} |
|
|
} |
|
|