Clean up a couple instances of direct usage of a magic number in the CON compiler. DONT_BUILD.

git-svn-id: https://svn.eduke32.com/eduke32@5534 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2016-01-11 05:05:10 +00:00
parent e1124f9d12
commit 31e89f12b2
3 changed files with 7 additions and 7 deletions

View file

@ -2123,7 +2123,7 @@ static int32_t C_CheckMalformedBranch(intptr_t lastScriptPtr)
C_ReportError(-1); C_ReportError(-1);
g_numCompilerWarnings++; g_numCompilerWarnings++;
initprintf("%s:%d: warning: malformed `%s' branch\n",g_szScriptFileName,g_lineNumber, initprintf("%s:%d: warning: malformed `%s' branch\n",g_szScriptFileName,g_lineNumber,
keyw[*(g_scriptPtr) & 0xFFF]); keyw[*(g_scriptPtr) & VM_INSTMASK]);
return 1; return 1;
} }
return 0; return 0;
@ -2140,7 +2140,7 @@ static int32_t C_CheckEmptyBranch(int32_t tw, intptr_t lastScriptPtr)
return 0; return 0;
} }
if ((*(g_scriptPtr) & 0xFFF) != CON_NULLOP || *(g_scriptPtr)>>12 != IFELSE_MAGIC) if ((*(g_scriptPtr) & VM_INSTMASK) != CON_NULLOP || *(g_scriptPtr)>>12 != IFELSE_MAGIC)
g_ifElseAborted = 0; g_ifElseAborted = 0;
if (EDUKE32_PREDICT_FALSE(g_ifElseAborted)) if (EDUKE32_PREDICT_FALSE(g_ifElseAborted))
@ -2149,7 +2149,7 @@ static int32_t C_CheckEmptyBranch(int32_t tw, intptr_t lastScriptPtr)
g_numCompilerWarnings++; g_numCompilerWarnings++;
g_scriptPtr = lastScriptPtr + &script[0]; g_scriptPtr = lastScriptPtr + &script[0];
initprintf("%s:%d: warning: empty `%s' branch\n",g_szScriptFileName,g_lineNumber, initprintf("%s:%d: warning: empty `%s' branch\n",g_szScriptFileName,g_lineNumber,
keyw[*(g_scriptPtr) & 0xFFF]); keyw[*(g_scriptPtr) & VM_INSTMASK]);
*(g_scriptPtr) = (CON_NULLOP + (IFELSE_MAGIC<<12)); *(g_scriptPtr) = (CON_NULLOP + (IFELSE_MAGIC<<12));
return 1; return 1;
} }
@ -5106,13 +5106,13 @@ repeatcase:
g_numBraces--; g_numBraces--;
if ((*(g_scriptPtr-2)>>12) == (IFELSE_MAGIC) && if ((*(g_scriptPtr-2)>>12) == (IFELSE_MAGIC) &&
((*(g_scriptPtr-2) & 0xFFF) == CON_LEFTBRACE)) // rewrite "{ }" into "nullop" ((*(g_scriptPtr-2) & VM_INSTMASK) == CON_LEFTBRACE)) // rewrite "{ }" into "nullop"
{ {
// initprintf("%s:%d: rewriting empty braces '{ }' as 'nullop' from right\n",g_szScriptFileName,g_lineNumber); // initprintf("%s:%d: rewriting empty braces '{ }' as 'nullop' from right\n",g_szScriptFileName,g_lineNumber);
*(g_scriptPtr-2) = CON_NULLOP + (IFELSE_MAGIC<<12); *(g_scriptPtr-2) = CON_NULLOP + (IFELSE_MAGIC<<12);
g_scriptPtr -= 2; g_scriptPtr -= 2;
if (C_GetKeyword() != CON_ELSE && (*(g_scriptPtr-2)&0xFFF) != CON_ELSE) if (C_GetKeyword() != CON_ELSE && (*(g_scriptPtr-2) & VM_INSTMASK) != CON_ELSE)
g_ifElseAborted = 1; g_ifElseAborted = 1;
else g_ifElseAborted = 0; else g_ifElseAborted = 0;

View file

@ -38,6 +38,8 @@ extern "C" {
#define MAXCHEATLEN 20 #define MAXCHEATLEN 20
#define NUMCHEATCODES (int32_t)ARRAY_SIZE(CheatStrings) #define NUMCHEATCODES (int32_t)ARRAY_SIZE(CheatStrings)
#define VM_INSTMASK 0xfff
extern intptr_t const * insptr; extern intptr_t const * insptr;
extern void VM_ScriptInfo(intptr_t const *ptr, int32_t range); extern void VM_ScriptInfo(intptr_t const *ptr, int32_t range);

View file

@ -83,8 +83,6 @@ GAMEEXEC_STATIC void VM_Execute(int32_t loop);
# include "gamestructures.c" # include "gamestructures.c"
#endif #endif
#define VM_INSTMASK 0xfff
#define VM_CONDITIONAL(xxx) \ #define VM_CONDITIONAL(xxx) \
{ \ { \
if ((xxx) || ((insptr = (intptr_t *)*(insptr + 1)) && (((*insptr) & VM_INSTMASK) == CON_ELSE))) \ if ((xxx) || ((insptr = (intptr_t *)*(insptr + 1)) && (((*insptr) & VM_INSTMASK) == CON_ELSE))) \