Fixes compilation for now. Now if my executable would start...

git-svn-id: https://svn.eduke32.com/eduke32@1692 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2010-08-12 13:38:37 +00:00
parent 71e59a5502
commit 6185aedded
7 changed files with 53 additions and 20 deletions

View file

@ -51,7 +51,6 @@ extern void VM_OnEvent(register int32_t iEventID, register int32_t iActor);
extern void VM_ScriptInfo(void); extern void VM_ScriptInfo(void);
extern void VM_Disasm(ofstype beg, int32_t size); extern void VM_Disasm(ofstype beg, int32_t size);
extern void C_ReportError(int32_t iError);
extern int32_t Gv_NewVar(const char *pszLabel, intptr_t lValue, uint32_t dwFlags); extern int32_t Gv_NewVar(const char *pszLabel, intptr_t lValue, uint32_t dwFlags);
extern int32_t Gv_NewArray(const char *pszLabel, void *arrayptr, intptr_t asize, uint32_t dwFlags); extern int32_t Gv_NewArray(const char *pszLabel, void *arrayptr, intptr_t asize, uint32_t dwFlags);
@ -275,4 +274,23 @@ extern int32_t halfxdim16, midydim16;
#define M32_PRINTERROR(Text, ...) OSD_Printf(OSD_ERROR "Line %d, %s: " Text "\n", g_errorLineNum, keyw[g_tw], ## __VA_ARGS__) #define M32_PRINTERROR(Text, ...) OSD_Printf(OSD_ERROR "Line %d, %s: " Text "\n", g_errorLineNum, keyw[g_tw], ## __VA_ARGS__)
// how local gamevars are allocated:
// uncomment if variable-length arrays are available
//#define M32_LOCALS_VARARRAY
// uncomment if alloca() is available
//#define M32_LOCALS_ALLOCA
// if neither is there, use a constant number of them
#define M32_LOCALS_FIXEDNUM 64
#if defined M32_LOCALS_VARARRAY || defined M32_LOCALS_ALLOCA
# define M32_MAX_LOCALS MAXGAMEVARS
#else
# define M32_MAX_LOCALS M32_LOCALS_FIXEDNUM
#endif
#endif #endif

View file

@ -33,7 +33,7 @@ static char g_szCurrentBlockName[BMAX_PATH] = "(none)", g_szLastBlockName[BMAX_P
////// compiler state vvv ////// compiler state vvv
static const char *textptr, *start_textptr, *g_curkwptr; static const char *textptr, *start_textptr, *g_curkwptr;
static int32_t g_tw; static int32_t def_tw;
int32_t g_totalLines, g_lineNumber; int32_t g_totalLines, g_lineNumber;
int32_t g_numCompilerErrors, g_numCompilerWarnings; int32_t g_numCompilerErrors, g_numCompilerWarnings;
@ -102,9 +102,6 @@ int32_t g_gameArrayCount=0, g_systemArrayCount=0;
#define IFELSE_MAGIC 31337 #define IFELSE_MAGIC 31337
void C_ReportError(int32_t iError);
static void PrintErrorPosition();
enum ScriptLabel_t enum ScriptLabel_t
{ {
LABEL_ANY = -1, LABEL_ANY = -1,
@ -1545,7 +1542,7 @@ static int32_t C_ParseCommand(void)
/// Bsprintf(g_szBuf,"PC(): '%.25s'",textptr); AddLog(g_szBuf); /// Bsprintf(g_szBuf,"PC(): '%.25s'",textptr); AddLog(g_szBuf);
tw = C_GetNextKeyword(); tw = C_GetNextKeyword();
g_tw = tw; def_tw = tw;
// Bsprintf(tempbuf,"%s",keyw[tw]); AddLog(tempbuf); // Bsprintf(tempbuf,"%s",keyw[tw]); AddLog(tempbuf);
if (C_SkipComments()) if (C_SkipComments())
@ -2487,8 +2484,8 @@ repeatcase:
uint16_t *numlocals = (cs.currentStateIdx >= 0) ? uint16_t *numlocals = (cs.currentStateIdx >= 0) ?
&statesinfo[cs.currentStateIdx].numlocals : &aEventNumLocals[cs.currentEvent]; &statesinfo[cs.currentStateIdx].numlocals : &aEventNumLocals[cs.currentEvent];
if (((int32_t)(*numlocals))+1 > MAXGAMEVARS) if (((int32_t)(*numlocals))+1 > M32_MAX_LOCALS)
C_CUSTOMERROR("too much local storage required (max: %d gamevar equivalents).", MAXGAMEVARS); C_CUSTOMERROR("too much local storage required (max: %d gamevar equivalents).", M32_MAX_LOCALS);
else else
{ {
hash_add(&h_localvars, tlabel, (int32_t)(*numlocals), 0); hash_add(&h_localvars, tlabel, (int32_t)(*numlocals), 0);
@ -2523,8 +2520,8 @@ repeatcase:
uint16_t *numlocals = (cs.currentStateIdx >= 0) ? uint16_t *numlocals = (cs.currentStateIdx >= 0) ?
&statesinfo[cs.currentStateIdx].numlocals : &aEventNumLocals[cs.currentEvent]; &statesinfo[cs.currentStateIdx].numlocals : &aEventNumLocals[cs.currentEvent];
if (((int32_t)(*numlocals))+asize > MAXGAMEVARS) if (((int32_t)(*numlocals))+asize > M32_MAX_LOCALS)
C_CUSTOMERROR("too much local storage required (max: %d gamevar equivalents).", MAXGAMEVARS); C_CUSTOMERROR("too much local storage required (max: %d gamevar equivalents).", M32_MAX_LOCALS);
else else
{ {
hash_add(&h_localvars, tlabel, ((int32_t)(*numlocals))|(asize<<16), 0); hash_add(&h_localvars, tlabel, ((int32_t)(*numlocals))|(asize<<16), 0);
@ -3809,7 +3806,7 @@ void C_ReportError(int32_t iError)
break; break;
case ERROR_LABELINUSE: case ERROR_LABELINUSE:
initprintf("%s:%d: error: label `%s' is already in use by a %s.\n", initprintf("%s:%d: error: label `%s' is already in use by a %s.\n",
g_szScriptFileName, g_lineNumber, tlabel, g_tw==CON_DEFSTATE?"define":"state"); g_szScriptFileName, g_lineNumber, tlabel, def_tw==CON_DEFSTATE?"define":"state");
break; break;
case WARNING_DUPLICATECASE: case WARNING_DUPLICATECASE:
initprintf("%s:%ld: warning: duplicate case ignored.\n", initprintf("%s:%ld: warning: duplicate case ignored.\n",
@ -3833,10 +3830,10 @@ void C_ReportError(int32_t iError)
} }
if (iError!=-1) if (iError!=-1)
PrintErrorPosition(); C_PrintErrorPosition();
} }
static void PrintErrorPosition() void C_PrintErrorPosition()
{ {
const char *b = g_curkwptr, *e=textptr; const char *b = g_curkwptr, *e=textptr;
int32_t i, nchars; int32_t i, nchars;

View file

@ -32,16 +32,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define C_CUSTOMERROR(Text, ...) do { \ #define C_CUSTOMERROR(Text, ...) do { \
C_ReportError(-1); \ C_ReportError(-1); \
initprintf("%s:%d: error: " Text "\n", g_szScriptFileName, g_lineNumber, ## __VA_ARGS__); \ initprintf("%s:%d: error: " Text "\n", g_szScriptFileName, g_lineNumber, ## __VA_ARGS__); \
PrintErrorPosition(); \ C_PrintErrorPosition(); \
g_numCompilerErrors++; \ g_numCompilerErrors++; \
} while (0) } while (0)
#define C_CUSTOMWARNING(Text, ...) do { \ #define C_CUSTOMWARNING(Text, ...) do { \
C_ReportError(-1); \ C_ReportError(-1); \
initprintf("%s:%d: warning: " Text "\n", g_szScriptFileName, g_lineNumber, ## __VA_ARGS__); \ initprintf("%s:%d: warning: " Text "\n", g_szScriptFileName, g_lineNumber, ## __VA_ARGS__); \
PrintErrorPosition(); \ C_PrintErrorPosition(); \
g_numCompilerWarnings++; \ g_numCompilerWarnings++; \
} while (0) } while (0)
extern void C_PrintErrorPosition();
extern void C_ReportError(int32_t iError);
extern char g_szScriptFileName[BMAX_PATH]; extern char g_szScriptFileName[BMAX_PATH];
extern int32_t g_totalLines, g_lineNumber; extern int32_t g_totalLines, g_lineNumber;
extern int32_t g_numCompilerErrors, g_numCompilerWarnings; extern int32_t g_numCompilerErrors, g_numCompilerWarnings;
@ -103,6 +106,7 @@ extern vmstate_t vm_default;
extern int32_t g_errorLineNum; extern int32_t g_errorLineNum;
extern int32_t g_tw;
extern const char *keyw[]; extern const char *keyw[];
enum SystemString_t { enum SystemString_t {

View file

@ -48,6 +48,7 @@ int32_t g_errorLineNum, g_tw;
uint8_t aEventEnabled[MAXEVENTS]; uint8_t aEventEnabled[MAXEVENTS];
uint32_t m32_drawlinepat=0xffffffff; uint32_t m32_drawlinepat=0xffffffff;
int32_t m32_script_expertmode = 0;
instype *insptr; instype *insptr;
int32_t VM_Execute(int32_t once); int32_t VM_Execute(int32_t once);
@ -152,7 +153,13 @@ void VM_OnEvent(register int32_t iEventID, register int32_t iActor)
instype *oinsptr=insptr; instype *oinsptr=insptr;
vmstate_t vm_backup; vmstate_t vm_backup;
void *olocalvars = aGameArrays[M32_LOCAL_ARRAY_ID].vals; void *olocalvars = aGameArrays[M32_LOCAL_ARRAY_ID].vals;
void *localvars = alloca(aEventNumLocals[iEventID] * sizeof(int32_t)); #ifdef M32_LOCALS_VARARRAY
int32_t localvars[aEventNumLocals[iEventID]];
#elif defined M32_LOCALS_ALLOCA
int32_t *localvars = alloca(aEventNumLocals[iEventID] * sizeof(int32_t));
#else
int32_t localvars[M32_LOCALS_FIXEDNUM];
#endif
// needed since any read access before initialization would cause undefined behaviour // needed since any read access before initialization would cause undefined behaviour
if (aEventNumLocals[iEventID] > 0) if (aEventNumLocals[iEventID] > 0)
@ -341,7 +348,13 @@ skip_check:
instype *tempscrptr = insptr+2; instype *tempscrptr = insptr+2;
int32_t stateidx = *(insptr+1), o_g_st = vm.g_st, oret=vm.flags&VMFLAG_RETURN; int32_t stateidx = *(insptr+1), o_g_st = vm.g_st, oret=vm.flags&VMFLAG_RETURN;
void *olocalvars = aGameArrays[M32_LOCAL_ARRAY_ID].vals; void *olocalvars = aGameArrays[M32_LOCAL_ARRAY_ID].vals;
void *localvars = alloca(statesinfo[stateidx].numlocals * sizeof(int32_t)); #ifdef M32_LOCALS_VARARRAY
int32_t localvars[statesinfo[stateidx].numlocals];
#elif defined M32_LOCALS_ALLOCA
int32_t *localvars = alloca(statesinfo[stateidx].numlocals * sizeof(int32_t));
#else
int32_t localvars[M32_LOCALS_FIXEDNUM];
#endif
// needed since any read access before initialization would cause undefined behaviour // needed since any read access before initialization would cause undefined behaviour
if (statesinfo[stateidx].numlocals > 0) if (statesinfo[stateidx].numlocals > 0)

View file

@ -33,7 +33,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define ACCESS_USEVARS 2 #define ACCESS_USEVARS 2
#define ACCESS_SPRITEEXT 4 #define ACCESS_SPRITEEXT 4
int32_t m32_script_expertmode = 0;
/// This file is #included into other files, so don't define variables here!
static int32_t __fastcall VM_AccessWall(int32_t how, int32_t lVar1, int32_t lLabelID, int32_t lVar2) static int32_t __fastcall VM_AccessWall(int32_t how, int32_t lVar1, int32_t lLabelID, int32_t lVar2)