mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-10 14:52:01 +00:00
Adds the following keywords from M32script into CON: shiftvarvarl, shiftvarvarr, ifvarvarle, ifvarvarge, ifvarvarboth, whilevarl, and whilevarvarl.
This also adds the shorthand versions of some commands, like "set" for "setvarvar", "add" for "addvarvar", "ife" for "ifvarvare", etc. There are about 30 of these. Because some of these names may already be used in some projects as variable names, this revision also includes a somewhat large change in variable naming rules: gamevars may now have the same names as CON keywords, with the caveat that the masked keyword is no longer accessible. This results in a warning at compile time but should ensure nobody's project ever stops compiling due to the introduction of new keywords. git-svn-id: https://svn.eduke32.com/eduke32@5499 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
0871e56b92
commit
7c976018be
3 changed files with 140 additions and 10 deletions
|
@ -37,6 +37,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#endif
|
||||
|
||||
#define NUMKEYWORDS (int32_t)ARRAY_SIZE(keyw)
|
||||
#define NUMALTKEYWORDS (int32_t)ARRAY_SIZE(altkeyw)
|
||||
|
||||
int32_t g_scriptVersion = 13; // 13 = 1.3D-style CON files, 14 = 1.4/1.5 style CON files
|
||||
uint32_t g_scriptDateVersion = 99999999; // YYYYMMDD
|
||||
|
@ -181,6 +182,43 @@ static const char *C_GetLabelType(int32_t type)
|
|||
return Xstrdup(x);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
const char* token;
|
||||
int32_t val;
|
||||
} tokenmap_t;
|
||||
|
||||
const tokenmap_t altkeyw [] =
|
||||
{
|
||||
{ "#define", CON_DEFINE },
|
||||
{ "al", CON_ADDLOGVAR },
|
||||
{ "var", CON_GAMEVAR },
|
||||
{ "array", CON_GAMEARRAY },
|
||||
{ "shiftl", CON_SHIFTVARVARL },
|
||||
{ "shiftr", CON_SHIFTVARVARR },
|
||||
{ "rand", CON_RANDVARVAR },
|
||||
{ "set", CON_SETVARVAR },
|
||||
{ "add", CON_ADDVARVAR },
|
||||
{ "sub", CON_SUBVARVAR },
|
||||
{ "mul", CON_MULVARVAR },
|
||||
{ "div", CON_DIVVARVAR },
|
||||
{ "mod", CON_MODVARVAR },
|
||||
{ "and", CON_ANDVARVAR },
|
||||
{ "or", CON_ORVARVAR },
|
||||
{ "xor", CON_XORVARVAR },
|
||||
{ "ifl", CON_IFVARVARL },
|
||||
{ "ifle", CON_IFVARVARLE },
|
||||
{ "ifg", CON_IFVARVARG },
|
||||
{ "ifge", CON_IFVARVARGE },
|
||||
{ "ife", CON_IFVARVARE },
|
||||
{ "ifn", CON_IFVARVARN },
|
||||
{ "ifand", CON_IFVARVARAND },
|
||||
{ "ifor", CON_IFVARVAROR },
|
||||
{ "ifxor", CON_IFVARVARXOR },
|
||||
{ "ifeither", CON_IFVARVAREITHER },
|
||||
{ "ifboth", CON_IFVARVARBOTH },
|
||||
{ "whilen", CON_WHILEVARVARN },
|
||||
{ "whilel", CON_WHILEVARVARL },
|
||||
};
|
||||
|
||||
const char *keyw[] =
|
||||
{
|
||||
|
@ -568,6 +606,13 @@ const char *keyw[] =
|
|||
"resetplayerflags", // 381
|
||||
"appendevent", // 382
|
||||
"defstate", // 383
|
||||
"shiftvarvarl", // 384
|
||||
"shiftvarvarr", // 385
|
||||
"ifvarvarle", // 386
|
||||
"ifvarvarge", // 387
|
||||
"ifvarvarboth", // 388
|
||||
"whilevarl", // 389
|
||||
"whilevarvarl", // 390
|
||||
"<null>"
|
||||
};
|
||||
#endif
|
||||
|
@ -1277,6 +1322,7 @@ void C_InitHashes()
|
|||
}
|
||||
|
||||
for (i=g_scriptLastKeyword; i>=0; i--) hash_add(&h_keywords,keyw[i],i,0);
|
||||
for (i=0; i<NUMALTKEYWORDS; i++) hash_add(&h_keywords, altkeyw[i].token, altkeyw[i].val, 0);
|
||||
for (i=0; SectorLabels[i].lId >= 0; i++) hash_add(§orH,SectorLabels[i].name,i,0);
|
||||
for (i=0; WallLabels[i].lId >= 0; i++) hash_add(&wallH,WallLabels[i].name,i,0);
|
||||
for (i=0; UserdefsLabels[i].lId >= 0; i++) hash_add(&userdefH,UserdefsLabels[i].name,i,0);
|
||||
|
@ -2992,9 +3038,9 @@ DO_DEFSTATE:
|
|||
|
||||
if (EDUKE32_PREDICT_FALSE(hash_find(&h_keywords,label+(g_numLabels<<6))>=0))
|
||||
{
|
||||
g_numCompilerErrors++;
|
||||
C_ReportError(ERROR_ISAKEYWORD);
|
||||
continue;
|
||||
g_numCompilerWarnings++;
|
||||
C_ReportError(WARNING_VARMASKSKEYWORD);
|
||||
hash_delete(&h_keywords, label+(g_numLabels<<6));
|
||||
}
|
||||
|
||||
//printf("Translating number '%.20s'\n",textptr);
|
||||
|
@ -3037,9 +3083,9 @@ DO_DEFSTATE:
|
|||
|
||||
if (EDUKE32_PREDICT_FALSE(hash_find(&h_keywords,label+(g_numLabels<<6))>=0))
|
||||
{
|
||||
g_numCompilerErrors++;
|
||||
C_ReportError(ERROR_ISAKEYWORD);
|
||||
continue;
|
||||
g_numCompilerWarnings++;
|
||||
C_ReportError(WARNING_ARRAYMASKSKEYWORD);
|
||||
hash_delete(&h_keywords, label+(g_numLabels<<6));
|
||||
}
|
||||
|
||||
i = hash_find(&h_gamevars,label+(g_numLabels<<6));
|
||||
|
@ -4353,6 +4399,8 @@ DO_DEFSTATE:
|
|||
case CON_ANDVARVAR:
|
||||
case CON_ORVARVAR:
|
||||
case CON_XORVARVAR:
|
||||
case CON_SHIFTVARVARL:
|
||||
case CON_SHIFTVARVARR:
|
||||
case CON_DISPLAYRANDVARVAR:
|
||||
case CON_SIN:
|
||||
case CON_COS:
|
||||
|
@ -4840,12 +4888,16 @@ DO_DEFSTATE:
|
|||
case CON_IFVARVARG:
|
||||
case CON_IFVARVARL:
|
||||
case CON_IFVARVARE:
|
||||
case CON_IFVARVARLE:
|
||||
case CON_IFVARVARGE:
|
||||
case CON_IFVARVARBOTH:
|
||||
case CON_IFVARVARN:
|
||||
case CON_IFVARVARAND:
|
||||
case CON_IFVARVAROR:
|
||||
case CON_IFVARVARXOR:
|
||||
case CON_IFVARVAREITHER:
|
||||
case CON_WHILEVARVARN:
|
||||
case CON_WHILEVARVARL:
|
||||
{
|
||||
intptr_t offset;
|
||||
intptr_t lastScriptPtr = g_scriptPtr - &script[0] - 1;
|
||||
|
@ -4894,6 +4946,7 @@ DO_DEFSTATE:
|
|||
case CON_IFVARXOR:
|
||||
case CON_IFVAREITHER:
|
||||
case CON_WHILEVARN:
|
||||
case CON_WHILEVARL:
|
||||
{
|
||||
intptr_t offset;
|
||||
intptr_t lastScriptPtr = (g_scriptPtr-script-1);
|
||||
|
@ -4919,7 +4972,7 @@ DO_DEFSTATE:
|
|||
*tempscrptr = (intptr_t) g_scriptPtr;
|
||||
bitptr[(tempscrptr-script)>>3] |= (BITPTR_POINTER<<((tempscrptr-script)&7));
|
||||
|
||||
if (tw != CON_WHILEVARN)
|
||||
if (tw != CON_WHILEVARN && tw != CON_WHILEVARL)
|
||||
{
|
||||
j = C_GetKeyword();
|
||||
|
||||
|
@ -6647,8 +6700,8 @@ void C_Compile(const char *filenam)
|
|||
|
||||
DO_FREE_AND_NULL(mptr);
|
||||
|
||||
if (g_numCompilerWarnings|g_numCompilerErrors)
|
||||
initprintf("Found %d warning(s), %d error(s).\n",g_numCompilerWarnings,g_numCompilerErrors);
|
||||
if (g_numCompilerWarnings || g_numCompilerErrors)
|
||||
initprintf("Found %d warning(s), %d error(s).\n", g_numCompilerWarnings, g_numCompilerErrors);
|
||||
|
||||
if (g_numCompilerErrors)
|
||||
{
|
||||
|
@ -6839,6 +6892,12 @@ void C_ReportError(int32_t iError)
|
|||
case WARNING_NAMEMATCHESVAR:
|
||||
initprintf("%s:%d: warning: symbol `%s' already used for game variable.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6));
|
||||
break;
|
||||
case WARNING_VARMASKSKEYWORD:
|
||||
initprintf("%s:%d: warning: game variable `%s' masks keyword.\n", g_szScriptFileName, g_lineNumber, label+(g_numLabels<<6));
|
||||
break;
|
||||
case WARNING_ARRAYMASKSKEYWORD:
|
||||
initprintf("%s:%d: warning: game array `%s' masks keyword.\n", g_szScriptFileName, g_lineNumber, label+(g_numLabels<<6));
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -205,7 +205,9 @@ enum ScriptError_t
|
|||
WARNING_DUPLICATEDEFINITION,
|
||||
WARNING_EVENTSYNC,
|
||||
WARNING_LABELSONLY,
|
||||
WARNING_NAMEMATCHESVAR
|
||||
WARNING_NAMEMATCHESVAR,
|
||||
WARNING_VARMASKSKEYWORD,
|
||||
WARNING_ARRAYMASKSKEYWORD
|
||||
};
|
||||
|
||||
enum PlayerLabel_t
|
||||
|
@ -1049,6 +1051,13 @@ enum ScriptKeywords_t
|
|||
CON_RESETPLAYERFLAGS, // 381
|
||||
CON_APPENDEVENT, // 382
|
||||
CON_DEFSTATE, // 383
|
||||
CON_SHIFTVARVARL, // 384
|
||||
CON_SHIFTVARVARR, // 385
|
||||
CON_IFVARVARLE, // 386
|
||||
CON_IFVARVARGE, // 387
|
||||
CON_IFVARVARBOTH, // 388
|
||||
CON_WHILEVARL, // 389
|
||||
CON_WHILEVARVARL, // 390
|
||||
CON_END
|
||||
};
|
||||
// KEEPINSYNC with the keyword list in lunatic/con_lang.lua
|
||||
|
|
|
@ -4978,6 +4978,18 @@ finish_qsprintf:
|
|||
insptr += 2;
|
||||
continue;
|
||||
|
||||
case CON_SHIFTVARVARL:
|
||||
insptr++;
|
||||
tw = *insptr++;
|
||||
Gv_SetVarX(tw, Gv_GetVarX(tw) << Gv_GetVarX(*insptr++));
|
||||
continue;
|
||||
|
||||
case CON_SHIFTVARVARR:
|
||||
insptr++;
|
||||
tw = *insptr++;
|
||||
Gv_SetVarX(tw, Gv_GetVarX(tw) >> Gv_GetVarX(*insptr++));
|
||||
continue;
|
||||
|
||||
case CON_SIN:
|
||||
insptr++;
|
||||
tw = *insptr++;
|
||||
|
@ -5097,6 +5109,14 @@ finish_qsprintf:
|
|||
VM_CONDITIONAL(tw);
|
||||
continue;
|
||||
|
||||
case CON_IFVARVARBOTH:
|
||||
insptr++;
|
||||
tw = Gv_GetVarX(*insptr++);
|
||||
tw = (Gv_GetVarX(*insptr++) && tw);
|
||||
insptr--;
|
||||
VM_CONDITIONAL(tw);
|
||||
continue;
|
||||
|
||||
case CON_IFVARVARN:
|
||||
insptr++;
|
||||
tw = Gv_GetVarX(*insptr++);
|
||||
|
@ -5121,6 +5141,14 @@ finish_qsprintf:
|
|||
VM_CONDITIONAL(tw);
|
||||
continue;
|
||||
|
||||
case CON_IFVARVARGE:
|
||||
insptr++;
|
||||
tw = Gv_GetVarX(*insptr++);
|
||||
tw = (tw >= Gv_GetVarX(*insptr++));
|
||||
insptr--;
|
||||
VM_CONDITIONAL(tw);
|
||||
continue;
|
||||
|
||||
case CON_IFVARVARL:
|
||||
insptr++;
|
||||
tw = Gv_GetVarX(*insptr++);
|
||||
|
@ -5129,6 +5157,14 @@ finish_qsprintf:
|
|||
VM_CONDITIONAL(tw);
|
||||
continue;
|
||||
|
||||
case CON_IFVARVARLE:
|
||||
insptr++;
|
||||
tw = Gv_GetVarX(*insptr++);
|
||||
tw = (tw <= Gv_GetVarX(*insptr++));
|
||||
insptr--;
|
||||
VM_CONDITIONAL(tw);
|
||||
continue;
|
||||
|
||||
case CON_IFVARN:
|
||||
insptr++;
|
||||
tw = Gv_GetVarX(*insptr++);
|
||||
|
@ -5148,6 +5184,18 @@ finish_qsprintf:
|
|||
continue;
|
||||
}
|
||||
|
||||
case CON_WHILEVARL:
|
||||
{
|
||||
intptr_t const *const savedinsptr = insptr + 2;
|
||||
do
|
||||
{
|
||||
insptr = savedinsptr;
|
||||
tw = (Gv_GetVarX(*(insptr - 1)) < *insptr);
|
||||
VM_CONDITIONAL(tw);
|
||||
} while (tw);
|
||||
continue;
|
||||
}
|
||||
|
||||
case CON_WHILEVARVARN:
|
||||
{
|
||||
intptr_t const *const savedinsptr = insptr + 2;
|
||||
|
@ -5163,6 +5211,20 @@ finish_qsprintf:
|
|||
continue;
|
||||
}
|
||||
|
||||
case CON_WHILEVARVARL:
|
||||
{
|
||||
intptr_t const *const savedinsptr = insptr + 2;
|
||||
do
|
||||
{
|
||||
insptr = savedinsptr;
|
||||
tw = Gv_GetVarX(*(insptr - 1));
|
||||
tw = (tw < Gv_GetVarX(*insptr++));
|
||||
insptr--;
|
||||
VM_CONDITIONAL(tw);
|
||||
} while (tw);
|
||||
continue;
|
||||
}
|
||||
|
||||
case CON_IFVARAND:
|
||||
insptr++;
|
||||
tw = Gv_GetVarX(*insptr++);
|
||||
|
|
Loading…
Reference in a new issue