Sfoglia il codice sorgente

be more relaxed about pointer comparisons

master
Ian Piumarta 3 mesi fa
parent
commit
f411e2d569
1 ha cambiato i file con 3 aggiunte e 3 eliminazioni
  1. +3
    -3
      main.leg

+ 3
- 3
main.leg Vedi File

@ -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);
}

Caricamento…
Annulla
Salva