diff options
author | Ash Wolf <ninji@wuffs.org> | 2023-01-13 01:38:15 +0000 |
---|---|---|
committer | Ash Wolf <ninji@wuffs.org> | 2023-01-13 01:38:15 +0000 |
commit | 08d21a052b9afc37292ec3fad390502610e2cb32 (patch) | |
tree | 270737c790f5d1bb05f68498f8233640ada6a0c5 /compiler_and_linker/unsorted/Switch.c | |
parent | 54628993e0038c7bea9c064491974985b6699502 (diff) | |
parent | 9d985413ce2b60a1a8cf001913ee8dac81c03aac (diff) | |
download | MWCC-08d21a052b9afc37292ec3fad390502610e2cb32.tar.gz MWCC-08d21a052b9afc37292ec3fad390502610e2cb32.zip |
Merge remote-tracking branch 'origin/main'
Diffstat (limited to 'compiler_and_linker/unsorted/Switch.c')
-rw-r--r-- | compiler_and_linker/unsorted/Switch.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/compiler_and_linker/unsorted/Switch.c b/compiler_and_linker/unsorted/Switch.c index 8fd45b8..3b9d246 100644 --- a/compiler_and_linker/unsorted/Switch.c +++ b/compiler_and_linker/unsorted/Switch.c @@ -366,8 +366,7 @@ static Object *create_switch_table(void) { while (CInt64_LessEqual(value, range)) { while (CInt64_Greater(CInt64_Add(first, value), CInt64_Add(currange->min, currange->range))) currange++; - // HACK - this will not work properly on 64-bit systems - *outptr = (UInt32) currange->label; + *outptr = CTool_CreateIndexFromPointer(currange->label); value = CInt64_Add(value, cint64_one); outptr++; } @@ -420,7 +419,7 @@ static void generate_table(ENode *expr, SwitchInfo *info) { } } - if (FITS_IN_SHORT(CInt64_GetULong(&range))) { + if (!FITS_IN_SHORT(CInt64_GetULong(&range))) { short tmp = ALLOC_GPR(); load_immediate(tmp, CInt64_GetULong(&range)); emitpcode(PC_CMPL, 0, reg, tmp); @@ -511,7 +510,7 @@ void dumpswitchtables(Object *funcobj) { size = table->u.data.u.switchtable.size; array = (UInt32 *) table->u.data.u.switchtable.data; while (size--) { - *array = CTool_EndianConvertWord32(((PCodeLabel *) *array)->block->codeOffset); + *array = CTool_EndianConvertWord32(((PCodeLabel *) CTool_ResolveIndexToPointer(*array))->block->codeOffset); array++; } |