mirror of
https://github.com/nzp-team/fteqw.git
synced 2024-11-26 05:41:52 +00:00
prevent generation of statements outside functions (inlining to constants is okay).
insert .qc files into tree view in .src order instead of alphabetically. make sure extra .src files appear at the root. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4837 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
8cb0834782
commit
052cba731d
7 changed files with 67 additions and 33 deletions
|
@ -6,7 +6,7 @@ void GUI_SetDefaultOpts(void);
|
||||||
int GUI_BuildParms(char *args, char **argv, pbool quick);
|
int GUI_BuildParms(char *args, char **argv, pbool quick);
|
||||||
|
|
||||||
unsigned char *PDECL QCC_ReadFile (const char *fname, void *buffer, int len, size_t *sz);
|
unsigned char *PDECL QCC_ReadFile (const char *fname, void *buffer, int len, size_t *sz);
|
||||||
int QCC_FileSize (const char *fname);
|
int QCC_RawFileSize (const char *fname);
|
||||||
pbool QCC_WriteFile (const char *name, void *data, int len);
|
pbool QCC_WriteFile (const char *name, void *data, int len);
|
||||||
void GUI_DialogPrint(char *title, char *text);
|
void GUI_DialogPrint(char *title, char *text);
|
||||||
|
|
||||||
|
|
|
@ -941,6 +941,8 @@ extern int max_temps;
|
||||||
extern int tempsstart;
|
extern int tempsstart;
|
||||||
extern int numtemps;
|
extern int numtemps;
|
||||||
|
|
||||||
|
extern char compilingrootfile[]; //.src file currently being compiled
|
||||||
|
|
||||||
typedef char PATHSTRING[MAX_DATA_PATH];
|
typedef char PATHSTRING[MAX_DATA_PATH];
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
|
|
@ -174,7 +174,7 @@ enum
|
||||||
QCC_def_t *QCC_PR_StatementFlags ( QCC_opcode_t *op, QCC_def_t *var_a, QCC_def_t *var_b, QCC_statement_t **outstatement, unsigned int flags);
|
QCC_def_t *QCC_PR_StatementFlags ( QCC_opcode_t *op, QCC_def_t *var_a, QCC_def_t *var_b, QCC_statement_t **outstatement, unsigned int flags);
|
||||||
|
|
||||||
void QCC_PR_ParseState (void);
|
void QCC_PR_ParseState (void);
|
||||||
pbool expandedemptymacro;
|
pbool expandedemptymacro; //just inhibits warnings about hanging semicolons
|
||||||
|
|
||||||
QCC_pr_info_t pr;
|
QCC_pr_info_t pr;
|
||||||
//QCC_def_t **pr_global_defs/*[MAX_REGS]*/; // to find def for a global variable
|
//QCC_def_t **pr_global_defs/*[MAX_REGS]*/; // to find def for a global variable
|
||||||
|
@ -1693,7 +1693,7 @@ static void QCC_fprintfLocals(FILE *f, gofs_t paramstart, gofs_t paramend)
|
||||||
{
|
{
|
||||||
if (t->lastfunc == pr_scope)
|
if (t->lastfunc == pr_scope)
|
||||||
{
|
{
|
||||||
fprintf(f, "local %s temp_%i;\n", (t->size == 1)?"float":"vector", t->ofs);
|
fprintf(f, "local %s temp_%i;\n", (t->size == 1)?"float":"vector", t->ofs-FIRST_TEMP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3381,6 +3381,9 @@ QCC_def_t *QCC_PR_StatementFlags (QCC_opcode_t *op, QCC_def_t *var_a, QCC_def_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!pr_scope)
|
||||||
|
QCC_PR_ParseError(ERR_BADEXTENSION, "Unable to generate statements at global scope.\n");
|
||||||
|
|
||||||
if (outstatement)
|
if (outstatement)
|
||||||
*outstatement = statement;
|
*outstatement = statement;
|
||||||
|
|
||||||
|
@ -6324,7 +6327,7 @@ QCC_ref_t *QCC_PR_ParseRefValue (QCC_ref_t *refbuf, QCC_type_t *assumeclass, pbo
|
||||||
}
|
}
|
||||||
else if (pr_assumetermtype)
|
else if (pr_assumetermtype)
|
||||||
{
|
{
|
||||||
d = QCC_PR_GetDef (pr_assumetermtype, name, pr_scope, true, 0, false);
|
d = QCC_PR_GetDef (pr_assumetermtype, name, NULL, true, 0, false);
|
||||||
if (!d)
|
if (!d)
|
||||||
QCC_PR_ParseError (ERR_UNKNOWNVALUE, "Unknown value \"%s\"", name);
|
QCC_PR_ParseError (ERR_UNKNOWNVALUE, "Unknown value \"%s\"", name);
|
||||||
}
|
}
|
||||||
|
@ -7692,18 +7695,31 @@ QCC_ref_t *QCC_PR_RefExpression (QCC_ref_t *retbuf, int priority, int exprflags)
|
||||||
|
|
||||||
QCC_def_t *val, *r;
|
QCC_def_t *val, *r;
|
||||||
QCC_statement_t *fromj, *elsej;
|
QCC_statement_t *fromj, *elsej;
|
||||||
//FIXME: use the correct conditional
|
if (QCC_PR_CheckToken(":"))
|
||||||
QCC_FreeTemp(QCC_PR_Statement(&pr_opcodes[OP_IFNOT_I], QCC_RefToDef(lhsr, true), NULL, &fromj));
|
{
|
||||||
|
val = QCC_RefToDef(lhsr, true);
|
||||||
|
//FIXME: use the correct conditional
|
||||||
|
QCC_FreeTemp(QCC_PR_Statement(&pr_opcodes[OP_IFNOT_I], val, NULL, &fromj));
|
||||||
|
QCC_UnFreeTemp(val);
|
||||||
|
r = QCC_GetTemp(val->type);
|
||||||
|
QCC_FreeTemp(QCC_PR_StatementFlags(&pr_opcodes[(r->type->size>=3)?OP_STORE_V:OP_STORE_F], val, r, NULL, 0));
|
||||||
|
QCC_UnFreeTemp(r);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//FIXME: use the correct conditional
|
||||||
|
QCC_FreeTemp(QCC_PR_Statement(&pr_opcodes[OP_IFNOT_I], QCC_RefToDef(lhsr, true), NULL, &fromj));
|
||||||
|
|
||||||
val = QCC_PR_Expression(TOP_PRIORITY, EXPR_DISALLOW_COMMA);
|
val = QCC_PR_Expression(TOP_PRIORITY, EXPR_DISALLOW_COMMA);
|
||||||
if (val->type->type == ev_integer && !QCC_OPCodeValid(&pr_opcodes[OP_STORE_I]))
|
if (val->type->type == ev_integer && !QCC_OPCodeValid(&pr_opcodes[OP_STORE_I]))
|
||||||
val = QCC_SupplyConversion(val, ev_float, true);
|
val = QCC_SupplyConversion(val, ev_float, true);
|
||||||
r = QCC_GetTemp(val->type);
|
r = QCC_GetTemp(val->type);
|
||||||
QCC_FreeTemp(QCC_PR_StatementFlags(&pr_opcodes[(r->type->size>=3)?OP_STORE_V:OP_STORE_F], val, r, NULL, 0));
|
QCC_FreeTemp(QCC_PR_StatementFlags(&pr_opcodes[(r->type->size>=3)?OP_STORE_V:OP_STORE_F], val, r, NULL, 0));
|
||||||
//r can be stomped upon until its reused anyway
|
//r can be stomped upon until its reused anyway
|
||||||
QCC_UnFreeTemp(r);
|
QCC_UnFreeTemp(r);
|
||||||
|
|
||||||
QCC_PR_Expect(":");
|
QCC_PR_Expect(":");
|
||||||
|
}
|
||||||
QCC_PR_Statement(&pr_opcodes[OP_GOTO], NULL, NULL, &elsej);
|
QCC_PR_Statement(&pr_opcodes[OP_GOTO], NULL, NULL, &elsej);
|
||||||
fromj->b = &statements[numstatements] - fromj;
|
fromj->b = &statements[numstatements] - fromj;
|
||||||
val = QCC_PR_Expression(TOP_PRIORITY, EXPR_DISALLOW_COMMA);
|
val = QCC_PR_Expression(TOP_PRIORITY, EXPR_DISALLOW_COMMA);
|
||||||
|
@ -9139,7 +9155,7 @@ void QCC_PR_ParseState (void)
|
||||||
|
|
||||||
QCC_PR_Expect (",");
|
QCC_PR_Expect (",");
|
||||||
|
|
||||||
pr_scope = NULL;
|
// pr_scope = NULL;
|
||||||
pr_assumetermtype = type_function;
|
pr_assumetermtype = type_function;
|
||||||
def = QCC_PR_Expression (TOP_PRIORITY, EXPR_DISALLOW_COMMA);
|
def = QCC_PR_Expression (TOP_PRIORITY, EXPR_DISALLOW_COMMA);
|
||||||
if (typecmp(def->type, type_function))
|
if (typecmp(def->type, type_function))
|
||||||
|
@ -9156,7 +9172,7 @@ void QCC_PR_ParseState (void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pr_assumetermtype = NULL;
|
pr_assumetermtype = NULL;
|
||||||
pr_scope = sc;
|
// pr_scope = sc;
|
||||||
|
|
||||||
QCC_PR_Expect ("]");
|
QCC_PR_Expect ("]");
|
||||||
|
|
||||||
|
|
|
@ -2983,6 +2983,7 @@ int QCC_PR_CheckCompConst(void)
|
||||||
QCC_PR_ExpandStrCat(&buffer, &bufferlen, &buffermax, "\0", 1);
|
QCC_PR_ExpandStrCat(&buffer, &bufferlen, &buffermax, "\0", 1);
|
||||||
QCC_PR_IncludeChunkEx(buffer, true, NULL, c);
|
QCC_PR_IncludeChunkEx(buffer, true, NULL, c);
|
||||||
}
|
}
|
||||||
|
expandedemptymacro = true;
|
||||||
free(buffer);
|
free(buffer);
|
||||||
|
|
||||||
if (flag_debugmacros)
|
if (flag_debugmacros)
|
||||||
|
@ -2998,9 +2999,9 @@ int QCC_PR_CheckCompConst(void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!*c->value)
|
if (*c->value)
|
||||||
expandedemptymacro = true;
|
QCC_PR_IncludeChunkEx(c->value, false, NULL, c);
|
||||||
QCC_PR_IncludeChunkEx(c->value, false, NULL, c);
|
expandedemptymacro = true;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -260,7 +260,7 @@ unsigned char *PDECL QCC_ReadFile (const char *fname, void *buffer, int len, siz
|
||||||
*sz = length;
|
*sz = length;
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
int PDECL QCC_FileSize (const char *fname)
|
int PDECL QCC_RawFileSize (const char *fname)
|
||||||
{
|
{
|
||||||
long length;
|
long length;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
@ -270,12 +270,21 @@ int PDECL QCC_FileSize (const char *fname)
|
||||||
fseek(f, 0, SEEK_END);
|
fseek(f, 0, SEEK_END);
|
||||||
length = ftell(f);
|
length = ftell(f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
if (strcmp(progssrcname, fname))
|
|
||||||
AddSourceFile("%s/%s", progssrcname, fname);
|
|
||||||
|
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
int PDECL QCC_PopFileSize (const char *fname)
|
||||||
|
{
|
||||||
|
extern int qcc_compileactive;
|
||||||
|
int len = QCC_RawFileSize(fname);
|
||||||
|
if (len >= 0 && qcc_compileactive)
|
||||||
|
{
|
||||||
|
if (strcmp(compilingrootfile, fname))
|
||||||
|
AddSourceFile("%s/%s", compilingrootfile, fname);
|
||||||
|
else
|
||||||
|
AddSourceFile("%s", fname);
|
||||||
|
}
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef AVAIL_ZLIB
|
#ifdef AVAIL_ZLIB
|
||||||
#include "../libs/zlib.h"
|
#include "../libs/zlib.h"
|
||||||
|
@ -1598,7 +1607,7 @@ static void EditorReload(editor_t *editor)
|
||||||
int flen;
|
int flen;
|
||||||
char *file;
|
char *file;
|
||||||
|
|
||||||
flen = QCC_FileSize(editor->filename);
|
flen = QCC_RawFileSize(editor->filename);
|
||||||
if (flen >= 0)
|
if (flen >= 0)
|
||||||
{
|
{
|
||||||
file = malloc(flen+1);
|
file = malloc(flen+1);
|
||||||
|
@ -1675,7 +1684,7 @@ void EditFile(char *name, int line)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QCC_FileSize(name) == -1)
|
if (QCC_RawFileSize(name) == -1)
|
||||||
{
|
{
|
||||||
QC_snprintfz(title, sizeof(title), "File not found.\n%s", name);
|
QC_snprintfz(title, sizeof(title), "File not found.\n%s", name);
|
||||||
MessageBox(NULL, title, "Error", 0);
|
MessageBox(NULL, title, "Error", 0);
|
||||||
|
@ -1890,7 +1899,7 @@ int GUIFileSize(const char *fname)
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return QCC_FileSize(fname);
|
return QCC_PopFileSize(fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*checks if the file has been modified externally*/
|
/*checks if the file has been modified externally*/
|
||||||
|
@ -3335,12 +3344,15 @@ static LRESULT CALLBACK MainWndProc(HWND hWnd,UINT message,
|
||||||
{
|
{
|
||||||
case NM_DBLCLK:
|
case NM_DBLCLK:
|
||||||
item = TreeView_GetSelection(projecttree);
|
item = TreeView_GetSelection(projecttree);
|
||||||
|
memset(&i, 0, sizeof(i));
|
||||||
i.hItem = item;
|
i.hItem = item;
|
||||||
i.mask = TVIF_TEXT;
|
i.mask = TVIF_TEXT|TVIF_PARAM;
|
||||||
i.pszText = itemtext;
|
i.pszText = itemtext;
|
||||||
i.cchTextMax = sizeof(itemtext)-1;
|
i.cchTextMax = sizeof(itemtext)-1;
|
||||||
if (!TreeView_GetItem(projecttree, &i))
|
if (!TreeView_GetItem(projecttree, &i))
|
||||||
return 0;
|
return 0;
|
||||||
|
if (!i.lParam)
|
||||||
|
return 0;
|
||||||
strcpy(filename, i.pszText);
|
strcpy(filename, i.pszText);
|
||||||
while(item)
|
while(item)
|
||||||
{
|
{
|
||||||
|
@ -3836,11 +3848,11 @@ void AddSourceFile(char *format, ...)
|
||||||
memset(&parent, 0, sizeof(parent));
|
memset(&parent, 0, sizeof(parent));
|
||||||
|
|
||||||
pi = item.hParent = TVI_ROOT;
|
pi = item.hParent = TVI_ROOT;
|
||||||
item.hInsertAfter = TVI_SORT;
|
item.hInsertAfter = TVI_LAST;//TVI_SORT;
|
||||||
item.item.pszText = string;
|
item.item.pszText = string;
|
||||||
item.item.state = TVIS_EXPANDED;
|
item.item.state = TVIS_EXPANDED;
|
||||||
item.item.stateMask = TVIS_EXPANDED;
|
item.item.stateMask = TVIS_EXPANDED;
|
||||||
item.item.mask = TVIF_TEXT|TVIF_STATE;
|
item.item.mask = TVIF_TEXT|TVIF_STATE|TVIF_PARAM;
|
||||||
while(item.item.pszText)
|
while(item.item.pszText)
|
||||||
{
|
{
|
||||||
slash = strchr(item.item.pszText, '/');
|
slash = strchr(item.item.pszText, '/');
|
||||||
|
@ -3862,6 +3874,7 @@ void AddSourceFile(char *format, ...)
|
||||||
if (!item.hParent)
|
if (!item.hParent)
|
||||||
{ //add a directory.
|
{ //add a directory.
|
||||||
item.hParent = pi;
|
item.hParent = pi;
|
||||||
|
item.item.lParam = !slash;
|
||||||
pi = (HANDLE)SendMessage(projecttree,TVM_INSERTITEM,0,(LPARAM)&item);
|
pi = (HANDLE)SendMessage(projecttree,TVM_INSERTITEM,0,(LPARAM)&item);
|
||||||
item.hParent = pi;
|
item.hParent = pi;
|
||||||
}
|
}
|
||||||
|
@ -4003,9 +4016,9 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin
|
||||||
if (!fl_acc && !*progssrcname)
|
if (!fl_acc && !*progssrcname)
|
||||||
{
|
{
|
||||||
strcpy(progssrcname, "preprogs.src");
|
strcpy(progssrcname, "preprogs.src");
|
||||||
if (QCC_FileSize(progssrcname)==-1)
|
if (QCC_RawFileSize(progssrcname)==-1)
|
||||||
strcpy(progssrcname, "progs.src");
|
strcpy(progssrcname, "progs.src");
|
||||||
if (QCC_FileSize(progssrcname)==-1)
|
if (QCC_RawFileSize(progssrcname)==-1)
|
||||||
{
|
{
|
||||||
char *s, *s2;
|
char *s, *s2;
|
||||||
char filename[MAX_PATH];
|
char filename[MAX_PATH];
|
||||||
|
|
|
@ -27,7 +27,7 @@ int Grep(char *filename, char *string)
|
||||||
char *buf;
|
char *buf;
|
||||||
if (!filename)
|
if (!filename)
|
||||||
return foundcount;
|
return foundcount;
|
||||||
sz = QCC_FileSize(filename);
|
sz = QCC_RawFileSize(filename);
|
||||||
if (sz <= 0)
|
if (sz <= 0)
|
||||||
return foundcount;
|
return foundcount;
|
||||||
buf = malloc(sz+1);
|
buf = malloc(sz+1);
|
||||||
|
|
|
@ -52,6 +52,7 @@ int sourcefilesnumdefs;
|
||||||
int currentsourcefile;
|
int currentsourcefile;
|
||||||
int numsourcefiles;
|
int numsourcefiles;
|
||||||
extern char *compilingfile;
|
extern char *compilingfile;
|
||||||
|
char compilingrootfile[1024];
|
||||||
|
|
||||||
void QCC_PR_ResetErrorScope(void);
|
void QCC_PR_ResetErrorScope(void);
|
||||||
|
|
||||||
|
@ -3410,6 +3411,7 @@ memset(pr_immediate_string, 0, sizeof(pr_immediate_string));
|
||||||
sprintf (qccmprogsdat, "%s%s", qccmsourcedir, sourcefileslist[currentsourcefile++]);
|
sprintf (qccmprogsdat, "%s%s", qccmsourcedir, sourcefileslist[currentsourcefile++]);
|
||||||
printf ("Source file: %s\n", qccmprogsdat);
|
printf ("Source file: %s\n", qccmprogsdat);
|
||||||
|
|
||||||
|
QC_strlcpy(compilingrootfile, qccmprogsdat, sizeof(compilingrootfile));
|
||||||
if (QCC_LoadFile (qccmprogsdat, (void *)&qccmsrc) == -1)
|
if (QCC_LoadFile (qccmprogsdat, (void *)&qccmsrc) == -1)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue