Revert "Add built-in __file constant"
This reverts commit d15fc2224be20eac391062d1c1898b027a168713.
This commit is contained in:
parent
a05033be20
commit
0cd10a73d6
@ -527,7 +527,6 @@ SC_FUNC constvalue *append_constval(constvalue *table,const char *name,cell val,
|
|||||||
SC_FUNC constvalue *find_constval(constvalue *table,char *name,int index);
|
SC_FUNC constvalue *find_constval(constvalue *table,char *name,int index);
|
||||||
SC_FUNC void delete_consttable(constvalue *table);
|
SC_FUNC void delete_consttable(constvalue *table);
|
||||||
SC_FUNC symbol *add_constant(char *name,cell val,int vclass,int tag);
|
SC_FUNC symbol *add_constant(char *name,cell val,int vclass,int tag);
|
||||||
SC_FUNC symbol *add_string_constant(char *name,const char *val,int vclass);
|
|
||||||
SC_FUNC void exporttag(int tag);
|
SC_FUNC void exporttag(int tag);
|
||||||
SC_FUNC void sc_attachdocumentation(symbol *sym);
|
SC_FUNC void sc_attachdocumentation(symbol *sym);
|
||||||
|
|
||||||
@ -584,9 +583,7 @@ SC_FUNC void begcseg(void);
|
|||||||
SC_FUNC void begdseg(void);
|
SC_FUNC void begdseg(void);
|
||||||
SC_FUNC void setline(int chkbounds);
|
SC_FUNC void setline(int chkbounds);
|
||||||
SC_FUNC void setfiledirect(char *name);
|
SC_FUNC void setfiledirect(char *name);
|
||||||
SC_FUNC void setfileconst(char *name);
|
|
||||||
SC_FUNC void setlinedirect(int line);
|
SC_FUNC void setlinedirect(int line);
|
||||||
SC_FUNC void setlineconst(int line);
|
|
||||||
SC_FUNC void setlabel(int index);
|
SC_FUNC void setlabel(int index);
|
||||||
SC_FUNC void markexpr(optmark type,const char *name,cell offset);
|
SC_FUNC void markexpr(optmark type,const char *name,cell offset);
|
||||||
SC_FUNC void startfunc(char *fname);
|
SC_FUNC void startfunc(char *fname);
|
||||||
|
@ -570,8 +570,8 @@ int pc_compile(int argc, char *argv[])
|
|||||||
sc_needsemicolon ? "true" : "false",
|
sc_needsemicolon ? "true" : "false",
|
||||||
sc_tabsize);
|
sc_tabsize);
|
||||||
pc_writeasm(outf,string);
|
pc_writeasm(outf,string);
|
||||||
} /* if */
|
|
||||||
setfiledirect(inpfname);
|
setfiledirect(inpfname);
|
||||||
|
} /* if */
|
||||||
/* do the first pass through the file (or possibly two or more "first passes") */
|
/* do the first pass through the file (or possibly two or more "first passes") */
|
||||||
sc_parsenum=0;
|
sc_parsenum=0;
|
||||||
inpfmark=pc_getpossrc(inpf_org);
|
inpfmark=pc_getpossrc(inpf_org);
|
||||||
@ -596,7 +596,7 @@ int pc_compile(int argc, char *argv[])
|
|||||||
fline=skipinput; /* reset line number */
|
fline=skipinput; /* reset line number */
|
||||||
sc_reparse=FALSE; /* assume no extra passes */
|
sc_reparse=FALSE; /* assume no extra passes */
|
||||||
sc_status=statFIRST; /* resetglobals() resets it to IDLE */
|
sc_status=statFIRST; /* resetglobals() resets it to IDLE */
|
||||||
setfileconst(inpfname);
|
|
||||||
if (strlen(incfname)>0) {
|
if (strlen(incfname)>0) {
|
||||||
if (strcmp(incfname,sDEF_PREFIX)==0) {
|
if (strcmp(incfname,sDEF_PREFIX)==0) {
|
||||||
plungefile(incfname,FALSE,TRUE); /* parse "default.inc" */
|
plungefile(incfname,FALSE,TRUE); /* parse "default.inc" */
|
||||||
@ -661,7 +661,6 @@ int pc_compile(int argc, char *argv[])
|
|||||||
lexinit(); /* clear internal flags of lex() */
|
lexinit(); /* clear internal flags of lex() */
|
||||||
sc_status=statWRITE; /* allow to write --this variable was reset by resetglobals() */
|
sc_status=statWRITE; /* allow to write --this variable was reset by resetglobals() */
|
||||||
writeleader(&glbtab);
|
writeleader(&glbtab);
|
||||||
setfileconst(inpfname);
|
|
||||||
insert_dbgfile(inpfname);
|
insert_dbgfile(inpfname);
|
||||||
if (strlen(incfname)>0) {
|
if (strlen(incfname)>0) {
|
||||||
if (strcmp(incfname,sDEF_PREFIX)==0)
|
if (strcmp(incfname,sDEF_PREFIX)==0)
|
||||||
@ -4899,9 +4898,9 @@ SC_FUNC symbol *add_constant(char *name,cell val,int vclass,int tag)
|
|||||||
* constants are stored in the symbols table, this also finds previously
|
* constants are stored in the symbols table, this also finds previously
|
||||||
* defind constants. */
|
* defind constants. */
|
||||||
sym=findglb(name,sSTATEVAR);
|
sym=findglb(name,sSTATEVAR);
|
||||||
if (sym==NULL)
|
if (!sym)
|
||||||
sym=findloc(name);
|
sym=findloc(name);
|
||||||
if (sym!=NULL) {
|
if (sym) {
|
||||||
int redef=0;
|
int redef=0;
|
||||||
if (sym->ident!=iCONSTEXPR)
|
if (sym->ident!=iCONSTEXPR)
|
||||||
redef=1; /* redefinition a function/variable to a constant is not allowed */
|
redef=1; /* redefinition a function/variable to a constant is not allowed */
|
||||||
@ -4948,48 +4947,6 @@ redef_enumfield:
|
|||||||
return sym;
|
return sym;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add_string_constant
|
|
||||||
*
|
|
||||||
* Adds a string constant to the symbol table.
|
|
||||||
*/
|
|
||||||
SC_FUNC symbol *add_string_constant(char *name,const char *val,int vclass)
|
|
||||||
{
|
|
||||||
symbol *sym;
|
|
||||||
|
|
||||||
/* Test whether a global or local symbol with the same name exists. Since
|
|
||||||
* constants are stored in the symbols table, this also finds previously
|
|
||||||
* defind constants. */
|
|
||||||
sym=findglb(name,sSTATEVAR);
|
|
||||||
if (sym==NULL)
|
|
||||||
sym=findloc(name);
|
|
||||||
if (sym!=NULL) {
|
|
||||||
int redef=0;
|
|
||||||
if (sym->ident!=iARRAY) {
|
|
||||||
error(21,name); /* symbol already defined */
|
|
||||||
return NULL;
|
|
||||||
} /* if */
|
|
||||||
} else {
|
|
||||||
sym=addsym(name,0,iARRAY,vclass,0,uDEFINE);
|
|
||||||
sym->fnumber=fcurrent;
|
|
||||||
sym->usage|=uSTOCK;
|
|
||||||
} /* if */
|
|
||||||
sym->addr=(litidx+glb_declared)*sizeof(cell);
|
|
||||||
sym->usage|=(uDEFINE | uPREDEF);
|
|
||||||
/* Store this constant only if it's used somewhere. This can be detected
|
|
||||||
* in the second stage. */
|
|
||||||
if (sc_status==statWRITE && (sym->usage & uREAD)!=0) {
|
|
||||||
assert(litidx==0);
|
|
||||||
begdseg();
|
|
||||||
while (*val!='\0')
|
|
||||||
litadd(*val++);
|
|
||||||
litadd(0);
|
|
||||||
glb_declared+=litidx;
|
|
||||||
dumplits();
|
|
||||||
litidx=0;
|
|
||||||
}
|
|
||||||
return sym;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* statement - The Statement Parser
|
/* statement - The Statement Parser
|
||||||
*
|
*
|
||||||
* This routine is called whenever the parser needs to know what statement
|
* This routine is called whenever the parser needs to know what statement
|
||||||
|
@ -198,7 +198,6 @@ static char extensions[][6] = { "", ".inc", ".p", ".pawn" };
|
|||||||
icomment=0; /* not in a comment */
|
icomment=0; /* not in a comment */
|
||||||
insert_dbgfile(inpfname);
|
insert_dbgfile(inpfname);
|
||||||
setfiledirect(inpfname);
|
setfiledirect(inpfname);
|
||||||
setfileconst(inpfname);
|
|
||||||
listline=-1; /* force a #line directive when changing the file */
|
listline=-1; /* force a #line directive when changing the file */
|
||||||
sc_is_utf8=(short)scan_utf8(inpf,real_path);
|
sc_is_utf8=(short)scan_utf8(inpf,real_path);
|
||||||
free(real_path);
|
free(real_path);
|
||||||
@ -351,6 +350,7 @@ static void readline(unsigned char *line)
|
|||||||
{
|
{
|
||||||
int i,num,cont;
|
int i,num,cont;
|
||||||
unsigned char *ptr;
|
unsigned char *ptr;
|
||||||
|
symbol *sym;
|
||||||
|
|
||||||
if (lptr==term_expr)
|
if (lptr==term_expr)
|
||||||
return;
|
return;
|
||||||
@ -429,7 +429,9 @@ static void readline(unsigned char *line)
|
|||||||
line+=strlen((char*)line);
|
line+=strlen((char*)line);
|
||||||
} /* if */
|
} /* if */
|
||||||
fline+=1;
|
fline+=1;
|
||||||
setlineconst(fline);
|
sym=findconst("__line",NULL);
|
||||||
|
assert(sym!=NULL);
|
||||||
|
sym->addr=fline;
|
||||||
} while (num>=0 && cont);
|
} while (num>=0 && cont);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2709,7 +2711,7 @@ SC_FUNC void delete_symbols(symbol *root,int level,int delete_labels,int delete_
|
|||||||
case iVARIABLE:
|
case iVARIABLE:
|
||||||
case iARRAY:
|
case iARRAY:
|
||||||
/* do not delete global variables if functions are preserved */
|
/* do not delete global variables if functions are preserved */
|
||||||
mustdelete=delete_functions || (sym->usage & uPREDEF)==0;
|
mustdelete=delete_functions;
|
||||||
break;
|
break;
|
||||||
case iREFERENCE:
|
case iREFERENCE:
|
||||||
/* always delete references (only exist as function parameters) */
|
/* always delete references (only exist as function parameters) */
|
||||||
|
@ -270,11 +270,6 @@ SC_FUNC void setfiledirect(char *name)
|
|||||||
} /* if */
|
} /* if */
|
||||||
}
|
}
|
||||||
|
|
||||||
SC_FUNC void setfileconst(char *name)
|
|
||||||
{
|
|
||||||
add_string_constant("__file",name,sGLOBAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
SC_FUNC void setlinedirect(int line)
|
SC_FUNC void setlinedirect(int line)
|
||||||
{
|
{
|
||||||
if (sc_status==statFIRST && sc_listing) {
|
if (sc_status==statFIRST && sc_listing) {
|
||||||
@ -284,15 +279,6 @@ SC_FUNC void setlinedirect(int line)
|
|||||||
} /* if */
|
} /* if */
|
||||||
}
|
}
|
||||||
|
|
||||||
SC_FUNC void setlineconst(int line)
|
|
||||||
{
|
|
||||||
symbol *sym;
|
|
||||||
|
|
||||||
sym=findconst("__line",NULL);
|
|
||||||
assert(sym!=NULL);
|
|
||||||
sym->addr=fline;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* setlabel
|
/* setlabel
|
||||||
*
|
*
|
||||||
* Post a code label (specified as a number), on a new line.
|
* Post a code label (specified as a number), on a new line.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user