From 9d985413ce2b60a1a8cf001913ee8dac81c03aac Mon Sep 17 00:00:00 2001 From: Ash Wolf Date: Fri, 13 Jan 2023 01:36:56 +0000 Subject: fix lots more issues, add endian conversions to ObjGenMachO, add 64-bit kludge to Switch.c --- compiler_and_linker/unsorted/Switch.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'compiler_and_linker/unsorted/Switch.c') 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++; } -- cgit v1.2.3