]> Chaos Git - console/RCOMage.git/commitdiff
Avoid strict-aliasing issues, use a union to make a variable both a uint32 and a...
authorYouness Alaoui <kakaroto@kakaroto.homelinux.net>
Sun, 9 Jan 2011 01:48:54 +0000 (20:48 -0500)
committerYouness Alaoui <kakaroto@kakaroto.homelinux.net>
Sun, 9 Jan 2011 11:37:49 +0000 (06:37 -0500)
vsmx.c
vsmx.h

diff --git a/vsmx.c b/vsmx.c
index b450ddc30ebf919860227ada45c58c29004f5d5d..69acead2e4557d0e852f1a699f62b369d89a24b7 100644 (file)
--- a/vsmx.c
+++ b/vsmx.c
@@ -459,8 +459,8 @@ void* writeVSMXMem(unsigned int* len, VsmxMem* in) {
 \r
 // macro used in both decode and decompile functions\r
 #define CHECK_INDEX(num,nam) \\r
-       if(in->code[i].val >= num) { \\r
-               error("Invalid " nam " index 0x%x at group %d!", in->code[i].val, i); \\r
+       if(in->code[i].val.u32 >= num) { \\r
+               error("Invalid " nam " index 0x%x at group %d!", in->code[i].val.u32, i); \\r
                return 1; \\r
        }\r
 \r
@@ -479,32 +479,32 @@ int VsmxDecode(VsmxMem* in, FILE* out) {
                switch(in->code[i].id & 0xFF) {\r
                        \r
                        case VID_CONST_BOOL:\r
-                               if(in->code[i].val == 1)\r
+                               if(in->code[i].val.u32 == 1)\r
                                        fputws(L" true", out);\r
-                               else if(in->code[i].val == 0)\r
+                               else if(in->code[i].val.u32 == 0)\r
                                        fputws(L" false", out);\r
                                else {\r
-                                       warning("Unexpected boolean value 0x%x at line %d!", in->code[i].val, i+1);\r
-                                       fwprintf(out, L" 0x%x", in->code[i].val);\r
+                                       warning("Unexpected boolean value 0x%x at line %d!", in->code[i].val.u32, i+1);\r
+                                       fwprintf(out, L" 0x%x", in->code[i].val.u32);\r
                                }\r
                        break;\r
                        case VID_CONST_INT:\r
-                               fwprintf(out, L" %u", in->code[i].val);\r
+                               fwprintf(out, L" %u", in->code[i].val.u32);\r
                        break;\r
                        case VID_CONST_FLOAT:\r
-                               fwprintf(out, L" %#g", *(float*)(&in->code[i].val));\r
+                               fwprintf(out, L" %#g", in->code[i].val.f);\r
                        break;\r
                        case VID_CONST_STRING:\r
                                CHECK_INDEX(in->numText, "text");\r
-                               fwprintf(out, L" \"%ls\"", in->pText[in->code[i].val]);\r
+                               fwprintf(out, L" \"%ls\"", in->pText[in->code[i].val.u32]);\r
                        break;\r
                        case VID_VARIABLE: {\r
                                // for some reason, the %s modifier in fwprintf doesn't work properly... :/ so we need to convert to a wide char string\r
                                wchar *tmp;\r
-                               uint tmpLen = strlen(in->pNames[in->code[i].val]);\r
+                               uint tmpLen = strlen(in->pNames[in->code[i].val.u32]);\r
                                CHECK_INDEX(in->numNames, "name");\r
                                tmp = (wchar*)malloc((tmpLen+1) * sizeof(wchar));\r
-                               strwcpy(tmp, in->pNames[in->code[i].val], tmpLen+1);\r
+                               strwcpy(tmp, in->pNames[in->code[i].val.u32], tmpLen+1);\r
                                fwprintf(out, L" %ls", tmp);\r
                                free(tmp);\r
                        } break;\r
@@ -513,33 +513,33 @@ int VsmxDecode(VsmxMem* in, FILE* out) {
                        case VID_UNK_31:\r
                        case VID_UNSET:\r
                                CHECK_INDEX(in->numProp, "property");\r
-                               fwprintf(out, L" %ls", in->pProp[in->code[i].val]);\r
+                               fwprintf(out, L" %ls", in->pProp[in->code[i].val.u32]);\r
                        break;\r
                        case VID_FUNCTION:\r
                                if(in->code[i].id >> 16 & 0xFF)\r
                                        warning("Unexpected flag value for function at line %d, expected 0, got %d", i+1, in->code[i].id >> 16 & 0xFF);\r
-                               fwprintf(out, L" args=%u, flag=%u, start_line=%u", (in->code[i].id >> 8) & 0xFF, (in->code[i].id >> 24) & 0xFF, in->code[i].val+1);\r
+                               fwprintf(out, L" args=%u, flag=%u, start_line=%u", (in->code[i].id >> 8) & 0xFF, (in->code[i].id >> 24) & 0xFF, in->code[i].val.u32+1);\r
                        break;\r
                        case VID_UNNAMED_VAR:\r
-                               fwprintf(out, L" %u", in->code[i].val);\r
+                               fwprintf(out, L" %u", in->code[i].val.u32);\r
                        break;\r
                        \r
                        // jumps\r
                        case VID_SECT_START:\r
                        case VID_JUMP_TRUE:\r
                        case VID_JUMP_FALSE:\r
-                               fwprintf(out, L" line=%u", in->code[i].val+1);\r
+                               fwprintf(out, L" line=%u", in->code[i].val.u32+1);\r
                        break;\r
                        \r
                        // function calls\r
                        case VID_CALL_FUNC:\r
                        case VID_CALL_METHOD:\r
                        case VID_CALL_INBUILT:\r
-                               fwprintf(out, L" args=%u", in->code[i].val);\r
+                               fwprintf(out, L" args=%u", in->code[i].val.u32);\r
                        break;\r
                        \r
                        case VID_MAKE_FLOAT_ARRAY:\r
-                               fwprintf(out, L" items=%u", in->code[i].val);\r
+                               fwprintf(out, L" items=%u", in->code[i].val.u32);\r
                                break;\r
                        \r
                        // ops w/o arg - check for zero\r
@@ -572,14 +572,14 @@ int VsmxDecode(VsmxMem* in, FILE* out) {
                        case VID_ARRAY_ELEM:\r
                        case VID_RETURN:\r
                        case VID_END:\r
-                               if(in->code[i].val)\r
+                               if(in->code[i].val.u32)\r
                                        warning("Unexpected non-zero value at line %d!", i+1);\r
                                \r
                        break;\r
                        \r
                        default:\r
                                warning("Unknown ID 0x%x at line %d", in->code[i].id, i+1);\r
-                               fwprintf(out, L" 0x%x", in->code[i].id, in->code[i].val);\r
+                               fwprintf(out, L" 0x%x", in->code[i].id, in->code[i].val.u32);\r
                }\r
                fputwc(L'\n', out);\r
        }\r
@@ -602,7 +602,7 @@ unsigned int VsmxAddText(void** text, unsigned int** offs, unsigned int* textLen
                        error("malloc failed");\r
                        exit(1);\r
                }\r
-               while(*ptr = (char)(*newText)) {\r
+               while((*ptr = (char)(*newText))) {\r
                        ptr++;\r
                        newText++;\r
                }\r
@@ -809,7 +809,7 @@ VsmxMem* VsmxEncode(FILE* in) {
                ret->codeGroups++;\r
                ret->code = (VSMXGroup*)realloc(ret->code, ret->codeGroups * sizeof(VSMXGroup));\r
                ret->code[ret->codeGroups-1].id = opNum2;\r
-               ret->code[ret->codeGroups-1].val = argNum;\r
+               ret->code[ret->codeGroups-1].val.u32 = argNum;\r
                \r
                lineCount++;\r
        }\r
@@ -940,7 +940,7 @@ int VsmxDecompile(VsmxMem* in, FILE* out) {
                item.arrayFlag = 0;\r
                \r
                item.item.id = 0;\r
-               item.item.val = 0;\r
+               item.item.val.u32 = 0;\r
                \r
                // TODO: check that in->code[i].val is 0 for various things\r
                \r
@@ -969,7 +969,7 @@ int VsmxDecompile(VsmxMem* in, FILE* out) {
                                        // check for special and operation\r
                                        if(in->code[i].id == VID_JUMP_FALSE) {\r
                                                // this upcomming if acts as an AND - we'll display this as a nested if though\r
-                                               mStack->loc = in->code[i].val;\r
+                                               mStack->loc = in->code[i].val.u32;\r
                                                // duplicate this marker as a copy will get popped later\r
                                                VsmxDecompMarkStackPush(&mStack, mStack);\r
                                                wcscat(item.str, L" /* AND condition shown as nested if */ ");\r
@@ -1069,30 +1069,30 @@ int VsmxDecompile(VsmxMem* in, FILE* out) {
                        \r
                        //case VID_CONST_TIME: break; // TODO:\r
                        case VID_CONST_BOOL:\r
-                               if(in->code[i].val == 0)\r
+                               if(in->code[i].val.u32 == 0)\r
                                        wcscpy(item.str, L"false");\r
                                else {\r
                                        wcscpy(item.str, L"true");\r
-                                       if(in->code[i].val != 1)\r
+                                       if(in->code[i].val.u32 != 1)\r
                                                warning("Boolean value at group #%d is not 0 or 1.", i);\r
                                }\r
                                VsmxDecompileStackPush(&stack, &item);\r
                        break;\r
                        \r
                        case VID_CONST_INT:\r
-                               //swprintf(item.str, MAX_TEXT_LEN, L"%u", in->code[i].val);\r
-                               SWPRINTF_ITEM("%u", in->code[i].val);\r
+                               //swprintf(item.str, MAX_TEXT_LEN, L"%u", in->code[i].val.u32);\r
+                               SWPRINTF_ITEM("%u", in->code[i].val.u32);\r
                                VsmxDecompileStackPush(&stack, &item);\r
                        break;\r
                        case VID_CONST_FLOAT:\r
-                               //swprintf(item.str, MAX_TEXT_LEN, L"%f", *(float*)(&in->code[i].val));\r
-                               SWPRINTF_ITEM("%#g", *(float*)(&in->code[i].val));\r
+                               //swprintf(item.str, MAX_TEXT_LEN, L"%f", *(float*)(&in->code[i].val.u32));\r
+                               SWPRINTF_ITEM("%#g", in->code[i].val.f);\r
                                VsmxDecompileStackPush(&stack, &item);\r
                        break;\r
                        case VID_CONST_STRING: { // TODO: unicode issues... :(\r
                                CHECK_INDEX(in->numText, "text");\r
-                               //swprintf(item.str, MAX_TEXT_LEN, L"\"%s\"", in->pText[in->code[i].val]);\r
-                               SWPRINTF_ITEM("\"%ls\"", in->pText[in->code[i].val]);\r
+                               //swprintf(item.str, MAX_TEXT_LEN, L"\"%s\"", in->pText[in->code[i].val.u32]);\r
+                               SWPRINTF_ITEM("\"%ls\"", in->pText[in->code[i].val.u32]);\r
                                VsmxDecompileStackPush(&stack, &item);\r
                        } break;\r
                        case VID_THIS: {\r
@@ -1100,13 +1100,13 @@ int VsmxDecompile(VsmxMem* in, FILE* out) {
                                VsmxDecompileStackPush(&stack, &item);\r
                        } break;\r
                        case VID_UNNAMED_VAR:\r
-                               //swprintf(item.str, MAX_TEXT_LEN, L"__GLOBALS__[%u]", in->code[i].val);\r
-                               SWPRINTF_ITEM("__var%u", in->code[i].val);\r
+                               //swprintf(item.str, MAX_TEXT_LEN, L"__GLOBALS__[%u]", in->code[i].val.u32);\r
+                               SWPRINTF_ITEM("__var%u", in->code[i].val.u32);\r
                                VsmxDecompileStackPush(&stack, &item);\r
                        break;\r
                        case VID_VARIABLE:\r
                                CHECK_INDEX(in->numNames, "name");\r
-                               strwcpy(item.str, in->pNames[in->code[i].val], MAX_TEXT_LEN);\r
+                               strwcpy(item.str, in->pNames[in->code[i].val.u32], MAX_TEXT_LEN);\r
                                VsmxDecompileStackPush(&stack, &item);\r
                        break;\r
                        \r
@@ -1116,11 +1116,11 @@ int VsmxDecompile(VsmxMem* in, FILE* out) {
                                        VsmxDecompileStack *obj, *val;\r
                                        val = VsmxDecompileStackPop(&stack);\r
                                        obj = VsmxDecompileStackPop(&stack);\r
-                                       SWPRINTF_ITEM("%ls.%ls = %ls", obj->str, in->pProp[in->code[i].val], val->str);\r
+                                       SWPRINTF_ITEM("%ls.%ls = %ls", obj->str, in->pProp[in->code[i].val.u32], val->str);\r
                                        free(obj);\r
                                        free(val);\r
                                } else\r
-                                       wcscpy(item.str, in->pProp[in->code[i].val]);\r
+                                       wcscpy(item.str, in->pProp[in->code[i].val.u32]);\r
                                VsmxDecompileStackPush(&stack, &item);\r
                        break;\r
                        \r
@@ -1131,11 +1131,11 @@ int VsmxDecompile(VsmxMem* in, FILE* out) {
                                VsmxDecompileStack *prev;\r
                                prev = VsmxDecompileStackPop(&stack);\r
                                CHECK_INDEX(in->numProp, "property/method");\r
-                               //swprintf(item.str, MAX_TEXT_LEN, L"%s.%s", prev->str, in->pProp[in->code[i].val]);\r
+                               //swprintf(item.str, MAX_TEXT_LEN, L"%s.%s", prev->str, in->pProp[in->code[i].val.u32]);\r
                                if(in->code[i].id == VID_UNSET)\r
-                                       SWPRINTF_ITEM("delete %ls.%ls", prev->str, in->pProp[in->code[i].val]);\r
+                                       SWPRINTF_ITEM("delete %ls.%ls", prev->str, in->pProp[in->code[i].val.u32]);\r
                                else\r
-                                       SWPRINTF_ITEM("%ls.%ls", prev->str, in->pProp[in->code[i].val]);\r
+                                       SWPRINTF_ITEM("%ls.%ls", prev->str, in->pProp[in->code[i].val.u32]);\r
                                VsmxDecompileStackPush(&stack, &item);\r
                                free(prev);\r
                        } break;\r
@@ -1146,7 +1146,7 @@ int VsmxDecompile(VsmxMem* in, FILE* out) {
                                VsmxDecompileStack *prev;\r
                                uint j;\r
                                \r
-                               for(j=0; j<in->code[i].val; j++) {\r
+                               for(j=0; j<in->code[i].val.u32; j++) {\r
                                        prev = VsmxDecompileStackPop(&stack);\r
                                        if(j)\r
                                                SWPRINTF_ITEM(" %ls,%ls", prev->str, item.str);\r
@@ -1206,7 +1206,7 @@ int VsmxDecompile(VsmxMem* in, FILE* out) {
                        case VID_FUNCTION: {\r
                                // TODO: need to check marker stack for look aheads\r
                                // !!! note look ahead used!\r
-                               Bool funcEndStmtStyle = (i+3 < in->codeGroups && in->code[i+2].id == VID_END_STMT && in->code[i+3].id == VID_SECT_START && in->code[i].val == i+4);\r
+                               Bool funcEndStmtStyle = (i+3 < in->codeGroups && in->code[i+2].id == VID_END_STMT && in->code[i+3].id == VID_SECT_START && in->code[i].val.u32 == i+4);\r
                                \r
                                wchar args[4096] = L""; // large enough for anything\r
                                uint numArgs = (in->code[i].id >> 8) & 0xFF, argI;\r
@@ -1224,11 +1224,11 @@ int VsmxDecompile(VsmxMem* in, FILE* out) {
                                \r
                                if(i+2 < in->codeGroups && in->code[i+1].id == VID_OPERATOR_ASSIGN && (\r
                                        funcEndStmtStyle || \r
-                                       (in->code[i+2].id == VID_SECT_START && in->code[i].val == i+3)\r
+                                       (in->code[i+2].id == VID_SECT_START && in->code[i].val.u32 == i+3)\r
                                )) {\r
                                        // abc = function() style?\r
                                        \r
-                                       if(in->code[i+1].val || (funcEndStmtStyle && in->code[i+2].val)) {\r
+                                       if(in->code[i+1].val.u32 || (funcEndStmtStyle && in->code[i+2].val.u32)) {\r
                                                warning("Unexpected values in function definition style at %d", i);\r
                                        }\r
                                        \r
@@ -1262,7 +1262,7 @@ int VsmxDecompile(VsmxMem* in, FILE* out) {
                                                i += 2;\r
                                        else\r
                                                i++;\r
-                               } else if(i+1 < in->codeGroups && in->code[i+1].id == VID_SECT_START && in->code[i].val == i+2) {\r
+                               } else if(i+1 < in->codeGroups && in->code[i+1].id == VID_SECT_START && in->code[i].val.u32 == i+2) {\r
                                        // function abc() style?\r
                                        VsmxDecompileStack *prev;\r
                                        prev = VsmxDecompileStackPop(&stack);\r
@@ -1273,14 +1273,14 @@ int VsmxDecompile(VsmxMem* in, FILE* out) {
                                }\r
                                else {\r
                                        warning("Unexpected function definition syntax at %d!", i);\r
-                                       SWPRINTF_ITEM("function __%u__(%ls)", in->code[i].val, args);\r
+                                       SWPRINTF_ITEM("function __%u__(%ls)", in->code[i].val.u32, args);\r
                                        VsmxDecompileStackPush(&stack, &item);\r
                                }\r
                        } break;\r
                        \r
                        case VID_ARRAY_INDEX: {\r
                                VsmxDecompileStack *idx, *parent;\r
-                               // TODO: check that the number supplied in in->code[i].val isn't used (always is 0)!\r
+                               // TODO: check that the number supplied in in->code[i].val.u32 isn't used (always is 0)!\r
                                idx = VsmxDecompileStackPop(&stack);\r
                                parent = VsmxDecompileStackPop(&stack);\r
                                SWPRINTF_ITEM("%ls[%ls]", parent->str, idx->str);\r
@@ -1304,19 +1304,19 @@ int VsmxDecompile(VsmxMem* in, FILE* out) {
                        case VID_CALL_METHOD:\r
                        case VID_CALL_INBUILT:\r
                        {\r
-                               if(stack->depth < in->code[i].val) {\r
+                               if(stack->depth < in->code[i].val.u32) {\r
                                        error("Not enough arguments to perform requested function call at group %d.", i);\r
                                        return 1;\r
                                }\r
                                VsmxDecompileStack *prev;\r
-                               if(in->code[i].val > 0) {\r
+                               if(in->code[i].val.u32 > 0) {\r
                                        uint arg;\r
                                        strwcpy(item.str, " )", MAX_TEXT_LEN);\r
-                                       for(arg = 0; arg < in->code[i].val; arg++) {\r
+                                       for(arg = 0; arg < in->code[i].val.u32; arg++) {\r
                                                prev = VsmxDecompileStackPop(&stack);\r
                                                //swprintf(item.str, MAX_TEXT_LEN, L"%s%s", prev->str, item.str);\r
                                                //SWPRINTF_ITEM("%ls%ls", prev->str, item.str);\r
-                                               if(arg+1 < in->code[i].val) {\r
+                                               if(arg+1 < in->code[i].val.u32) {\r
                                                        //swprintf(item.str, MAX_TEXT_LEN, L", %s", item.str);\r
                                                        //SWPRINTF_ITEM(", %ls", item.str);\r
                                                        memmove(prev->str + 2, prev->str, (wcslen(prev->str)+1)*sizeof(wchar));\r
@@ -1358,33 +1358,33 @@ int VsmxDecompile(VsmxMem* in, FILE* out) {
                                        // check that next group is a sect start\r
                                           i+1 < in->codeGroups && in->code[i+1].id == VID_SECT_START\r
                                        // check that end of for stmt is a jump back\r
-                                       && in->code[i].val < in->codeGroups && in->code[in->code[i].val-1].id == VID_SECT_START && in->code[in->code[i].val-1].val == stmtStart\r
+                                       && in->code[i].val.u32 < in->codeGroups && in->code[in->code[i].val.u32-1].id == VID_SECT_START && in->code[in->code[i].val.u32-1].val.u32 == stmtStart\r
                                        // end of for loop should be after end of for stmt\r
-                                       && in->code[i+1].val > in->code[i].val\r
+                                       && in->code[i+1].val.u32 > in->code[i].val.u32\r
                                        // check that end of for loop jumps back to incrementor\r
-                                       && in->code[i+1].val < in->codeGroups && in->code[in->code[i+1].val-1].id == VID_SECT_START && in->code[in->code[i+1].val-1].val == i+2\r
+                                       && in->code[i+1].val.u32 < in->codeGroups && in->code[in->code[i+1].val.u32-1].id == VID_SECT_START && in->code[in->code[i+1].val.u32-1].val.u32 == i+2\r
                                ) {\r
                                        // assume for loop\r
-                                       SWPRINTF_ITEM("for(; %ls /* jump to %d */; ", prev->str, in->code[i].val);\r
+                                       SWPRINTF_ITEM("for(; %ls /* jump to %d */; ", prev->str, in->code[i].val.u32);\r
                                        VsmxDecompileStackPush(&stack, &item);\r
                                        \r
-                                       forStmtEnd = in->code[i].val;\r
+                                       forStmtEnd = in->code[i].val.u32;\r
                                        // push for end marker of loop\r
                                        mItem.src = i+1;\r
-                                       mItem.loc = in->code[i+1].val;\r
+                                       mItem.loc = in->code[i+1].val.u32;\r
                                        VsmxDecompMarkStackPush(&mStack, &mItem);\r
                                        // push for end bracket on for()\r
                                        mItem.src = i;\r
-                                       mItem.loc = in->code[i].val;\r
+                                       mItem.loc = in->code[i].val.u32;\r
                                        VsmxDecompMarkStackPush(&mStack, &mItem);\r
                                        i++;\r
                                } else {\r
                                        // assume OR\r
-                                       SWPRINTF_ITEM("( %ls ) || /* ends at %d */ ( ", prev->str, in->code[i].val);\r
+                                       SWPRINTF_ITEM("( %ls ) || /* ends at %d */ ( ", prev->str, in->code[i].val.u32);\r
                                        VsmxDecompileStackPush(&stack, &item);\r
                                        \r
                                        mItem.src = i;\r
-                                       mItem.loc = in->code[i].val;\r
+                                       mItem.loc = in->code[i].val.u32;\r
                                        VsmxDecompMarkStackPush(&mStack, &mItem);\r
                                }\r
                                free(prev);\r
@@ -1394,11 +1394,11 @@ int VsmxDecompile(VsmxMem* in, FILE* out) {
                        // section markers\r
                        case VID_SECT_START: if(!op[0]) {\r
                                // this is either a function start or "else" section, or end of loop\r
-                               if(mStack && (in->code[mStack->src].id == VID_JUMP_FALSE || (in->code[mStack->src].id == VID_SECT_START && in->code[i].val < i))) {\r
+                               if(mStack && (in->code[mStack->src].id == VID_JUMP_FALSE || (in->code[mStack->src].id == VID_SECT_START && in->code[i].val.u32 < i))) {\r
                                        // check whether else or end of while\r
-                                       if(in->code[i].val < i) {\r
+                                       if(in->code[i].val.u32 < i) {\r
                                                // assume end of loop\r
-                                               SWPRINTF(op, 50, L"} %%ls/* jump back to %d */\n", in->code[i].val);\r
+                                               SWPRINTF(op, 50, L"} %%ls/* jump back to %d */\n", in->code[i].val.u32);\r
                                                // push dummy element\r
                                                VsmxDecompileStackPush(&stack, &item);\r
                                                if(indent > 0) indent--; // this should always be true\r
@@ -1427,20 +1427,20 @@ int VsmxDecompile(VsmxMem* in, FILE* out) {
                                                        // inline else\r
                                                        wcscat(stack->str, L" : ");\r
                                                        mItem.src = i;\r
-                                                       mItem.loc = in->code[i].val;\r
+                                                       mItem.loc = in->code[i].val.u32;\r
                                                        VsmxDecompMarkStackPush(&mStack, &mItem);\r
                                                        break;\r
                                                } else {\r
-                                                       SWPRINTF(op, 50, L"} else %%ls{ /* ends at %d */\n", in->code[i].val);\r
+                                                       SWPRINTF(op, 50, L"} else %%ls{ /* ends at %d */\n", in->code[i].val.u32);\r
                                                        // push dummy element\r
                                                        VsmxDecompileStackPush(&stack, &item);\r
                                                }\r
                                        }\r
-                               } else if(mStack && in->code[mStack->src].id == VID_JUMP_TRUE && in->code[mStack->src].val == i+1) {\r
+                               } else if(mStack && in->code[mStack->src].id == VID_JUMP_TRUE && in->code[mStack->src].val.u32 == i+1) {\r
                                        // for loop end of stmt probably\r
                                        if(stack) warning("Unexpected stack at end of for at %d", i);\r
                                        // TODO: need to fix this so it doesn't go on a new line\r
-                                       SWPRINTF(op, 50, L"%%ls /* return to %d */) {\n", in->code[i].val);\r
+                                       SWPRINTF(op, 50, L"%%ls /* return to %d */) {\n", in->code[i].val.u32);\r
                                        // push dummy element\r
                                        VsmxDecompileStackPush(&stack, &item);\r
                                        indentAdd++;\r
@@ -1451,19 +1451,19 @@ int VsmxDecompile(VsmxMem* in, FILE* out) {
                                        \r
                                } else {\r
                                        // function start\r
-                                       SWPRINTF(op, 50, L"%%ls { /* ends at %d */\n", in->code[i].val); // wcscpy(op, L"%s {\n");\r
+                                       SWPRINTF(op, 50, L"%%ls { /* ends at %d */\n", in->code[i].val.u32); // wcscpy(op, L"%s {\n");\r
                                }\r
                        }\r
                        case VID_JUMP_FALSE: if(!op[0]) {\r
                                // !!! look ahead!\r
-                               if(in->code[i].val-1 >= in->codeGroups) {\r
+                               if(in->code[i].val.u32-1 >= in->codeGroups) {\r
                                        error("Invalid jump reference supplied at %d", i);\r
                                        return 1;\r
                                }\r
                                // check whether this is an "if" or "while"\r
-                               if(in->code[in->code[i].val-1].id == VID_SECT_START && in->code[in->code[i].val-1].val == stmtStart) {\r
+                               if(in->code[in->code[i].val.u32-1].id == VID_SECT_START && in->code[in->code[i].val.u32-1].val.u32 == stmtStart) {\r
                                        // while loop\r
-                                       SWPRINTF(op, 50, L"while( %%s ) { /* ends at %d */\n", in->code[i].val); // wcscpy(op, L"while( %s ) {\n");\r
+                                       SWPRINTF(op, 50, L"while( %%s ) { /* ends at %d */\n", in->code[i].val.u32); // wcscpy(op, L"while( %s ) {\n");\r
                                } else {\r
                                        // if statement\r
                                        if(stack->depth > endStmtConcat-1) {\r
@@ -1478,20 +1478,20 @@ int VsmxDecompile(VsmxMem* in, FILE* out) {
                                                        free(prev);\r
                                                }\r
                                                endStmtConcat = 2;\r
-                                               SWPRINTF_ITEM("( %ls ? /* ends at %d */ ", tmp, in->code[i].val);\r
+                                               SWPRINTF_ITEM("( %ls ? /* ends at %d */ ", tmp, in->code[i].val.u32);\r
                                                VsmxDecompileStackPush(&stack, &item);\r
                                                mItem.src = i;\r
-                                               mItem.loc = in->code[i].val;\r
+                                               mItem.loc = in->code[i].val.u32;\r
                                                VsmxDecompMarkStackPush(&mStack, &mItem);\r
                                                break;\r
                                        } else {\r
-                                               SWPRINTF(op, 50, L"if( %%s ) { /* ends at %d */\n", in->code[i].val); // wcscpy(op, L"if( %s ) {\n");\r
+                                               SWPRINTF(op, 50, L"if( %%s ) { /* ends at %d */\n", in->code[i].val.u32); // wcscpy(op, L"if( %s ) {\n");\r
                                        }\r
                                }\r
                        }\r
                        if(!notSectStart) {\r
                                mItem.src = i;\r
-                               mItem.loc = in->code[i].val;\r
+                               mItem.loc = in->code[i].val.u32;\r
                                VsmxDecompMarkStackPush(&mStack, &mItem);\r
                                indentAdd++;\r
                        } // fall through to end of statement\r
@@ -1544,7 +1544,7 @@ int VsmxDecompile(VsmxMem* in, FILE* out) {
                        \r
                        default:\r
                                warning("Unknown id 0x%x at %d", in->code[i].id, i);\r
-                               SWPRINTF_ITEM("<< UNKNOWN 0x%x 0x%x >>", in->code[i].id, in->code[i].val);\r
+                               SWPRINTF_ITEM("<< UNKNOWN 0x%x 0x%x >>", in->code[i].id, in->code[i].val.u32);\r
                                VsmxDecompileStackPush(&stack, &item);\r
                }\r
                \r
diff --git a/vsmx.h b/vsmx.h
index f355ed7f99789790ffd8aeae7551d54df2adc73b..37f789d9af10ca02c9cb8bfe96bc24df46e10b82 100644 (file)
--- a/vsmx.h
+++ b/vsmx.h
@@ -34,7 +34,10 @@ PACK_STRUCT(VSMXHeader, {
 \r
 PACK_STRUCT(VSMXGroup, {\r
        uint32 id;\r
-       uint32 val;\r
+        union {\r
+          uint32 u32;\r
+          float  f;\r
+        } val;\r
 });\r
 \r
 #ifndef __GNU_C__\r