Remove SC_FUNC and SC_VDEFINE.

This commit is contained in:
David Anderson 2014-08-22 00:53:47 -07:00
parent 6291374b35
commit a09735a4c7
18 changed files with 584 additions and 621 deletions

View File

@ -36,8 +36,8 @@ enum FileSections
FS_Number, FS_Number,
}; };
extern "C" int pc_printf(const char *message,...); int pc_printf(const char *message,...);
extern "C" int pc_compile(int argc, char **argv); int pc_compile(int argc, char **argv);
void sfwrite(const void *buf, size_t size, size_t count, sp_file_t *spf); void sfwrite(const void *buf, size_t size, size_t count, sp_file_t *spf);
memfile_t *bin_file = NULL; memfile_t *bin_file = NULL;
@ -518,7 +518,7 @@ void sfwrite(const void *buf, size_t size, size_t count, sp_file_t *spf)
longjmp(brkout, 1); longjmp(brkout, 1);
} }
extern "C" void sp_fdbg_ntv_start(int num_natives) void sp_fdbg_ntv_start(int num_natives)
{ {
if (num_natives == 0) if (num_natives == 0)
return; return;
@ -528,8 +528,7 @@ extern "C" void sp_fdbg_ntv_start(int num_natives)
} }
#include "sc.h" #include "sc.h"
void sp_fdbg_ntv_hook(int index, symbol *sym)
extern "C" void sp_fdbg_ntv_hook(int index, symbol *sym)
{ {
int i, j; int i, j;
t_native *native; t_native *native;

View File

@ -537,11 +537,6 @@ typedef enum s_optmark {
#define CELL_MAX (((ucell)1 << (sizeof(cell)*8-1)) - 1) #define CELL_MAX (((ucell)1 << (sizeof(cell)*8-1)) - 1)
/* interface functions */
#if defined __cplusplus
extern "C" {
#endif
/* /*
* Functions you call from the "driver" program * Functions you call from the "driver" program
*/ */
@ -590,166 +585,144 @@ void pc_resetbin(void *handle,long offset);
int pc_writebin(void *handle,void *buffer,int size); int pc_writebin(void *handle,void *buffer,int size);
long pc_lengthbin(void *handle); /* return the length of the file */ long pc_lengthbin(void *handle); /* return the length of the file */
#if defined __cplusplus void sp_fdbg_ntv_start(int num_natives);
} void sp_fdbg_ntv_hook(int index, symbol *sym);
#endif
/* by default, functions and variables used in throughout the compiler
* files are "external"
*/
#if !defined SC_FUNC
# if defined(__cplusplus)
# define SC_FUNC extern "C"
# else
# define SC_FUNC
# endif
#endif
#if !defined SC_VDECL
#define SC_VDECL extern
#endif
#if !defined SC_VDEFINE
#define SC_VDEFINE
#endif
SC_FUNC void sp_fdbg_ntv_start(int num_natives);
SC_FUNC void sp_fdbg_ntv_hook(int index, symbol *sym);
/* function prototypes in SC1.C */ /* function prototypes in SC1.C */
SC_FUNC void set_extension(char *filename,const char *extension,int force); void set_extension(char *filename,const char *extension,int force);
SC_FUNC symbol *fetchfunc(char *name); symbol *fetchfunc(char *name);
SC_FUNC char *operator_symname(char *symname,const char *opername,int tag1,int tag2,int numtags,int resulttag); char *operator_symname(char *symname,const char *opername,int tag1,int tag2,int numtags,int resulttag);
SC_FUNC char *funcdisplayname(char *dest,char *funcname); char *funcdisplayname(char *dest,char *funcname);
SC_FUNC int exprconst(cell *val,int *tag,symbol **symptr); int exprconst(cell *val,int *tag,symbol **symptr);
SC_FUNC constvalue *append_constval(constvalue *table,const char *name,cell val,int index); constvalue *append_constval(constvalue *table,const char *name,cell val,int index);
SC_FUNC constvalue *find_constval(constvalue *table,char *name,int index); constvalue *find_constval(constvalue *table,char *name,int index);
SC_FUNC void delete_consttable(constvalue *table); void delete_consttable(constvalue *table);
SC_FUNC symbol *add_constant(const char *name,cell val,int vclass,int tag); symbol *add_constant(const char *name,cell val,int vclass,int tag);
SC_FUNC void exporttag(int tag); void exporttag(int tag);
SC_FUNC void sc_attachdocumentation(symbol *sym); void sc_attachdocumentation(symbol *sym);
SC_FUNC constvalue *find_tag_byval(int tag); constvalue *find_tag_byval(int tag);
SC_FUNC int get_actual_compound(symbol *sym); int get_actual_compound(symbol *sym);
/* function prototypes in SC2.C */ /* function prototypes in SC2.C */
#define PUSHSTK_P(v) { stkitem s_; s_.pv=(v); pushstk(s_); } #define PUSHSTK_P(v) { stkitem s_; s_.pv=(v); pushstk(s_); }
#define PUSHSTK_I(v) { stkitem s_; s_.i=(v); pushstk(s_); } #define PUSHSTK_I(v) { stkitem s_; s_.i=(v); pushstk(s_); }
#define POPSTK_P() (popstk().pv) #define POPSTK_P() (popstk().pv)
#define POPSTK_I() (popstk().i) #define POPSTK_I() (popstk().i)
SC_FUNC void pushstk(stkitem val); void pushstk(stkitem val);
SC_FUNC stkitem popstk(void); stkitem popstk(void);
SC_FUNC void clearstk(void); void clearstk(void);
SC_FUNC int plungequalifiedfile(char *name); /* explicit path included */ int plungequalifiedfile(char *name); /* explicit path included */
SC_FUNC int plungefile(char *name,int try_currentpath,int try_includepaths); /* search through "include" paths */ int plungefile(char *name,int try_currentpath,int try_includepaths); /* search through "include" paths */
SC_FUNC void preprocess(void); void preprocess(void);
SC_FUNC void lexinit(void); void lexinit(void);
SC_FUNC int lex(cell *lexvalue,char **lexsym); int lex(cell *lexvalue,char **lexsym);
SC_FUNC int lextok(token_t *tok); int lextok(token_t *tok);
SC_FUNC int lexpeek(int id); int lexpeek(int id);
SC_FUNC void lexpush(void); void lexpush(void);
SC_FUNC void lexclr(int clreol); void lexclr(int clreol);
SC_FUNC int matchtoken(int token); int matchtoken(int token);
SC_FUNC int tokeninfo(cell *val,char **str); int tokeninfo(cell *val,char **str);
SC_FUNC int needtoken(int token); int needtoken(int token);
SC_FUNC int matchtoken2(int id, token_t *tok); int matchtoken2(int id, token_t *tok);
SC_FUNC int expecttoken(int id, token_t *tok); int expecttoken(int id, token_t *tok);
SC_FUNC int matchsymbol(token_ident_t *ident); int matchsymbol(token_ident_t *ident);
SC_FUNC int needsymbol(token_ident_t *ident); int needsymbol(token_ident_t *ident);
SC_FUNC int peek_same_line(); int peek_same_line();
SC_FUNC int require_newline(int allow_semi); int require_newline(int allow_semi);
SC_FUNC void litadd(cell value); void litadd(cell value);
SC_FUNC void litinsert(cell value,int pos); void litinsert(cell value,int pos);
SC_FUNC int alphanum(char c); int alphanum(char c);
SC_FUNC int ishex(char c); int ishex(char c);
SC_FUNC void delete_symbol(symbol *root,symbol *sym); void delete_symbol(symbol *root,symbol *sym);
SC_FUNC void delete_symbols(symbol *root,int level,int del_labels,int delete_functions); void delete_symbols(symbol *root,int level,int del_labels,int delete_functions);
SC_FUNC int refer_symbol(symbol *entry,symbol *bywhom); int refer_symbol(symbol *entry,symbol *bywhom);
SC_FUNC void markusage(symbol *sym,int usage); void markusage(symbol *sym,int usage);
SC_FUNC symbol *findglb(const char *name,int filter); symbol *findglb(const char *name,int filter);
SC_FUNC symbol *findloc(const char *name); symbol *findloc(const char *name);
SC_FUNC symbol *findconst(const char *name,int *matchtag); symbol *findconst(const char *name,int *matchtag);
SC_FUNC symbol *finddepend(const symbol *parent); symbol *finddepend(const symbol *parent);
SC_FUNC symbol *addsym(const char *name,cell addr,int ident,int vclass,int tag, int usage); symbol *addsym(const char *name,cell addr,int ident,int vclass,int tag, int usage);
SC_FUNC symbol *addvariable(const char *name,cell addr,int ident,int vclass,int tag, symbol *addvariable(const char *name,cell addr,int ident,int vclass,int tag,
int dim[],int numdim,int idxtag[]); int dim[],int numdim,int idxtag[]);
SC_FUNC symbol *addvariable2(const char *name,cell addr,int ident,int vclass,int tag, symbol *addvariable2(const char *name,cell addr,int ident,int vclass,int tag,
int dim[],int numdim,int idxtag[],int slength); int dim[],int numdim,int idxtag[],int slength);
SC_FUNC symbol *addvariable3(declinfo_t *decl,cell addr,int vclass,int slength); symbol *addvariable3(declinfo_t *decl,cell addr,int vclass,int slength);
SC_FUNC int getlabel(void); int getlabel(void);
SC_FUNC char *itoh(ucell val); char *itoh(ucell val);
#define MATCHTAG_COERCE 0x1 // allow coercion #define MATCHTAG_COERCE 0x1 // allow coercion
#define MATCHTAG_SILENT 0x2 // silence the error(213) warning #define MATCHTAG_SILENT 0x2 // silence the error(213) warning
#define MATCHTAG_COMMUTATIVE 0x4 // order does not matter #define MATCHTAG_COMMUTATIVE 0x4 // order does not matter
/* function prototypes in SC3.C */ /* function prototypes in SC3.C */
SC_FUNC int check_userop(void (*oper)(void),int tag1,int tag2,int numparam, int check_userop(void (*oper)(void),int tag1,int tag2,int numparam,
value *lval,int *resulttag); value *lval,int *resulttag);
SC_FUNC int matchtag(int formaltag,int actualtag,int allowcoerce); int matchtag(int formaltag,int actualtag,int allowcoerce);
SC_FUNC int checktag(int tags[],int numtags,int exprtag); int checktag(int tags[],int numtags,int exprtag);
SC_FUNC int expression(cell *val,int *tag,symbol **symptr,int chkfuncresult,value *_lval); int expression(cell *val,int *tag,symbol **symptr,int chkfuncresult,value *_lval);
SC_FUNC int sc_getstateid(constvalue **automaton,constvalue **state); int sc_getstateid(constvalue **automaton,constvalue **state);
SC_FUNC cell array_totalsize(symbol *sym); cell array_totalsize(symbol *sym);
SC_FUNC int matchtag_string(int ident, int tag); int matchtag_string(int ident, int tag);
SC_FUNC int checktag_string(value *sym1, value *sym2); int checktag_string(value *sym1, value *sym2);
SC_FUNC int checktags_string(int tags[], int numtags, value *sym1); int checktags_string(int tags[], int numtags, value *sym1);
SC_FUNC int lvalexpr(svalue *sval); int lvalexpr(svalue *sval);
/* function prototypes in SC4.C */ /* function prototypes in SC4.C */
SC_FUNC void writeleader(symbol *root); void writeleader(symbol *root);
SC_FUNC void writetrailer(void); void writetrailer(void);
SC_FUNC void begcseg(void); void begcseg(void);
SC_FUNC void begdseg(void); void begdseg(void);
SC_FUNC void setline(int chkbounds); void setline(int chkbounds);
SC_FUNC void setfiledirect(char *name); void setfiledirect(char *name);
SC_FUNC void setlinedirect(int line); void setlinedirect(int line);
SC_FUNC void setlabel(int index); void setlabel(int index);
SC_FUNC void markexpr(optmark type,const char *name,cell offset); void markexpr(optmark type,const char *name,cell offset);
SC_FUNC void startfunc(char *fname); void startfunc(char *fname);
SC_FUNC void endfunc(void); void endfunc(void);
SC_FUNC void alignframe(int numbytes); void alignframe(int numbytes);
SC_FUNC void rvalue(value *lval); void rvalue(value *lval);
SC_FUNC void address(symbol *ptr,regid reg); void address(symbol *ptr,regid reg);
SC_FUNC void store(value *lval); void store(value *lval);
SC_FUNC void loadreg(cell address,regid reg); void loadreg(cell address,regid reg);
SC_FUNC void storereg(cell address,regid reg); void storereg(cell address,regid reg);
SC_FUNC void memcopy(cell size); void memcopy(cell size);
SC_FUNC void copyarray(symbol *sym,cell size); void copyarray(symbol *sym,cell size);
SC_FUNC void fillarray(symbol *sym,cell size,cell value); void fillarray(symbol *sym,cell size,cell value);
SC_FUNC void ldconst(cell val,regid reg); void ldconst(cell val,regid reg);
SC_FUNC void moveto1(void); void moveto1(void);
SC_FUNC void move_alt(void); void move_alt(void);
SC_FUNC void pushreg(regid reg); void pushreg(regid reg);
SC_FUNC void pushval(cell val); void pushval(cell val);
SC_FUNC void popreg(regid reg); void popreg(regid reg);
SC_FUNC void genarray(int dims, int _autozero); void genarray(int dims, int _autozero);
SC_FUNC void swap1(void); void swap1(void);
SC_FUNC void ffswitch(int label); void ffswitch(int label);
SC_FUNC void ffcase(cell value,char *labelname,int newtable); void ffcase(cell value,char *labelname,int newtable);
SC_FUNC void ffcall(symbol *sym,const char *label,int numargs); void ffcall(symbol *sym,const char *label,int numargs);
SC_FUNC void ffret(int remparams); void ffret(int remparams);
SC_FUNC void ffabort(int reason); void ffabort(int reason);
SC_FUNC void ffbounds(cell size); void ffbounds(cell size);
SC_FUNC void jumplabel(int number); void jumplabel(int number);
SC_FUNC void defstorage(void); void defstorage(void);
SC_FUNC void modstk(int delta); void modstk(int delta);
SC_FUNC void setstk(cell value); void setstk(cell value);
SC_FUNC void modheap(int delta); void modheap(int delta);
SC_FUNC void modheap_i(); void modheap_i();
SC_FUNC void setheap_pri(void); void setheap_pri(void);
SC_FUNC void setheap(cell value); void setheap(cell value);
SC_FUNC void cell2addr(void); void cell2addr(void);
SC_FUNC void cell2addr_alt(void); void cell2addr_alt(void);
SC_FUNC void addr2cell(void); void addr2cell(void);
SC_FUNC void char2addr(void); void char2addr(void);
SC_FUNC void charalign(void); void charalign(void);
SC_FUNC void addconst(cell value); void addconst(cell value);
SC_FUNC void setheap_save(cell value); void setheap_save(cell value);
SC_FUNC void stradjust(regid reg); void stradjust(regid reg);
SC_FUNC void invoke_getter(struct methodmap_method_s *method); void invoke_getter(struct methodmap_method_s *method);
SC_FUNC void invoke_setter(struct methodmap_method_s *method, int save); void invoke_setter(struct methodmap_method_s *method, int save);
SC_FUNC void inc_pri(); void inc_pri();
SC_FUNC void dec_pri(); void dec_pri();
SC_FUNC void load_hidden_arg(); void load_hidden_arg();
/* Code generation functions for arithmetic operators. /* Code generation functions for arithmetic operators.
* *
@ -759,197 +732,197 @@ SC_FUNC void load_hidden_arg();
* | +--------- "u"nsigned operator, "s"igned operator or "b"oth * | +--------- "u"nsigned operator, "s"igned operator or "b"oth
* +------------- "o"perator * +------------- "o"perator
*/ */
SC_FUNC void os_mult(void); /* multiplication (signed) */ void os_mult(void); /* multiplication (signed) */
SC_FUNC void os_div(void); /* division (signed) */ void os_div(void); /* division (signed) */
SC_FUNC void os_mod(void); /* modulus (signed) */ void os_mod(void); /* modulus (signed) */
SC_FUNC void ob_add(void); /* addition */ void ob_add(void); /* addition */
SC_FUNC void ob_sub(void); /* subtraction */ void ob_sub(void); /* subtraction */
SC_FUNC void ob_sal(void); /* shift left (arithmetic) */ void ob_sal(void); /* shift left (arithmetic) */
SC_FUNC void os_sar(void); /* shift right (arithmetic, signed) */ void os_sar(void); /* shift right (arithmetic, signed) */
SC_FUNC void ou_sar(void); /* shift right (logical, unsigned) */ void ou_sar(void); /* shift right (logical, unsigned) */
SC_FUNC void ob_or(void); /* bitwise or */ void ob_or(void); /* bitwise or */
SC_FUNC void ob_xor(void); /* bitwise xor */ void ob_xor(void); /* bitwise xor */
SC_FUNC void ob_and(void); /* bitwise and */ void ob_and(void); /* bitwise and */
SC_FUNC void ob_eq(void); /* equality */ void ob_eq(void); /* equality */
SC_FUNC void ob_ne(void); /* inequality */ void ob_ne(void); /* inequality */
SC_FUNC void relop_prefix(void); void relop_prefix(void);
SC_FUNC void relop_suffix(void); void relop_suffix(void);
SC_FUNC void os_le(void); /* less or equal (signed) */ void os_le(void); /* less or equal (signed) */
SC_FUNC void os_ge(void); /* greater or equal (signed) */ void os_ge(void); /* greater or equal (signed) */
SC_FUNC void os_lt(void); /* less (signed) */ void os_lt(void); /* less (signed) */
SC_FUNC void os_gt(void); /* greater (signed) */ void os_gt(void); /* greater (signed) */
SC_FUNC void lneg(void); void lneg(void);
SC_FUNC void neg(void); void neg(void);
SC_FUNC void invert(void); void invert(void);
SC_FUNC void nooperation(void); void nooperation(void);
SC_FUNC void inc(value *lval); void inc(value *lval);
SC_FUNC void dec(value *lval); void dec(value *lval);
SC_FUNC void jmp_ne0(int number); void jmp_ne0(int number);
SC_FUNC void jmp_eq0(int number); void jmp_eq0(int number);
SC_FUNC void outval(cell val,int newline); void outval(cell val,int newline);
/* function prototypes in SC5.C */ /* function prototypes in SC5.C */
SC_FUNC int error(int number,...); int error(int number,...);
SC_FUNC void errorset(int code,int line); void errorset(int code,int line);
/* function prototypes in SC6.C */ /* function prototypes in SC6.C */
SC_FUNC int assemble(void *fout,void *fin); int assemble(void *fout,void *fin);
/* function prototypes in SC7.C */ /* function prototypes in SC7.C */
SC_FUNC void stgbuffer_cleanup(void); void stgbuffer_cleanup(void);
SC_FUNC void stgmark(char mark); void stgmark(char mark);
SC_FUNC void stgwrite(const char *st); void stgwrite(const char *st);
SC_FUNC void stgout(int index); void stgout(int index);
SC_FUNC void stgdel(int index,cell code_index); void stgdel(int index,cell code_index);
SC_FUNC int stgget(int *index,cell *code_index); int stgget(int *index,cell *code_index);
SC_FUNC void stgset(int onoff); void stgset(int onoff);
SC_FUNC int phopt_init(void); int phopt_init(void);
SC_FUNC int phopt_cleanup(void); int phopt_cleanup(void);
/* function prototypes in SCLIST.C */ /* function prototypes in SCLIST.C */
SC_FUNC char* duplicatestring(const char* sourcestring); char* duplicatestring(const char* sourcestring);
SC_FUNC stringpair *insert_alias(char *name,char *alias); stringpair *insert_alias(char *name,char *alias);
SC_FUNC stringpair *find_alias(char *name); stringpair *find_alias(char *name);
SC_FUNC int lookup_alias(char *target,char *name); int lookup_alias(char *target,char *name);
SC_FUNC void delete_aliastable(void); void delete_aliastable(void);
SC_FUNC stringlist *insert_path(char *path); stringlist *insert_path(char *path);
SC_FUNC char *get_path(int index); char *get_path(int index);
SC_FUNC void delete_pathtable(void); void delete_pathtable(void);
SC_FUNC stringpair *insert_subst(const char *pattern,const char *substitution,int prefixlen); stringpair *insert_subst(const char *pattern,const char *substitution,int prefixlen);
SC_FUNC int get_subst(int index,char **pattern,char **substitution); int get_subst(int index,char **pattern,char **substitution);
SC_FUNC stringpair *find_subst(char *name,int length); stringpair *find_subst(char *name,int length);
SC_FUNC int delete_subst(char *name,int length); int delete_subst(char *name,int length);
SC_FUNC void delete_substtable(void); void delete_substtable(void);
SC_FUNC stringlist *insert_sourcefile(char *string); stringlist *insert_sourcefile(char *string);
SC_FUNC char *get_sourcefile(int index); char *get_sourcefile(int index);
SC_FUNC void delete_sourcefiletable(void); void delete_sourcefiletable(void);
SC_FUNC stringlist *insert_docstring(char *string); stringlist *insert_docstring(char *string);
SC_FUNC char *get_docstring(int index); char *get_docstring(int index);
SC_FUNC void delete_docstring(int index); void delete_docstring(int index);
SC_FUNC void delete_docstringtable(void); void delete_docstringtable(void);
SC_FUNC stringlist *insert_autolist(const char *string); stringlist *insert_autolist(const char *string);
SC_FUNC char *get_autolist(int index); char *get_autolist(int index);
SC_FUNC void delete_autolisttable(void); void delete_autolisttable(void);
SC_FUNC stringlist *insert_dbgfile(const char *filename); stringlist *insert_dbgfile(const char *filename);
SC_FUNC stringlist *insert_dbgline(int linenr); stringlist *insert_dbgline(int linenr);
SC_FUNC stringlist *insert_dbgsymbol(symbol *sym); stringlist *insert_dbgsymbol(symbol *sym);
SC_FUNC char *get_dbgstring(int index); char *get_dbgstring(int index);
SC_FUNC void delete_dbgstringtable(void); void delete_dbgstringtable(void);
SC_FUNC stringlist *get_dbgstrings(); stringlist *get_dbgstrings();
/* function prototypes in SCI18N.C */ /* function prototypes in SCI18N.C */
#define MAXCODEPAGE 12 #define MAXCODEPAGE 12
SC_FUNC int cp_path(const char *root,const char *directory); int cp_path(const char *root,const char *directory);
SC_FUNC int cp_set(const char *name); int cp_set(const char *name);
SC_FUNC cell cp_translate(const unsigned char *string,const unsigned char **endptr); cell cp_translate(const unsigned char *string,const unsigned char **endptr);
SC_FUNC cell get_utf8_char(const unsigned char *string,const unsigned char **endptr); cell get_utf8_char(const unsigned char *string,const unsigned char **endptr);
SC_FUNC int scan_utf8(void *fp,const char *filename); int scan_utf8(void *fp,const char *filename);
/* function prototypes in SCSTATE.C */ /* function prototypes in SCSTATE.C */
SC_FUNC constvalue *automaton_add(const char *name); constvalue *automaton_add(const char *name);
SC_FUNC constvalue *automaton_find(const char *name); constvalue *automaton_find(const char *name);
SC_FUNC constvalue *automaton_findid(int id); constvalue *automaton_findid(int id);
SC_FUNC constvalue *state_add(const char *name,int fsa_id); constvalue *state_add(const char *name,int fsa_id);
SC_FUNC constvalue *state_find(const char *name,int fsa_id); constvalue *state_find(const char *name,int fsa_id);
SC_FUNC constvalue *state_findid(int id); constvalue *state_findid(int id);
SC_FUNC void state_buildlist(int **list,int *listsize,int *count,int stateid); void state_buildlist(int **list,int *listsize,int *count,int stateid);
SC_FUNC int state_addlist(int *list,int count,int fsa_id); int state_addlist(int *list,int count,int fsa_id);
SC_FUNC void state_deletetable(void); void state_deletetable(void);
SC_FUNC int state_getfsa(int listid); int state_getfsa(int listid);
SC_FUNC int state_count(int listid); int state_count(int listid);
SC_FUNC int state_inlist(int listid,int state); int state_inlist(int listid,int state);
SC_FUNC int state_listitem(int listid,int index); int state_listitem(int listid,int index);
SC_FUNC void state_conflict(symbol *root); void state_conflict(symbol *root);
SC_FUNC int state_conflict_id(int listid1,int listid2); int state_conflict_id(int listid1,int listid2);
/* external variables (defined in scvars.c) */ /* external variables (defined in scvars.c) */
#if !defined SC_SKIP_VDECL #if !defined SC_SKIP_VDECL
typedef struct HashTable HashTable; typedef struct HashTable HashTable;
SC_VDECL struct HashTable *sp_Globals; extern struct HashTable *sp_Globals;
SC_VDECL symbol loctab; /* local symbol table */ extern symbol loctab; /* local symbol table */
SC_VDECL symbol glbtab; /* global symbol table */ extern symbol glbtab; /* global symbol table */
SC_VDECL cell *litq; /* the literal queue */ extern cell *litq; /* the literal queue */
SC_VDECL unsigned char pline[]; /* the line read from the input file */ extern unsigned char pline[]; /* the line read from the input file */
SC_VDECL const unsigned char *lptr;/* points to the current position in "pline" */ extern const unsigned char *lptr;/* points to the current position in "pline" */
SC_VDECL constvalue tagname_tab;/* tagname table */ extern constvalue tagname_tab;/* tagname table */
SC_VDECL constvalue libname_tab;/* library table (#pragma library "..." syntax) */ extern constvalue libname_tab;/* library table (#pragma library "..." syntax) */
SC_VDECL constvalue *curlibrary;/* current library */ extern constvalue *curlibrary;/* current library */
SC_VDECL int pc_addlibtable; /* is the library table added to the AMX file? */ extern int pc_addlibtable; /* is the library table added to the AMX file? */
SC_VDECL symbol *curfunc; /* pointer to current function */ extern symbol *curfunc; /* pointer to current function */
SC_VDECL char *inpfname; /* name of the file currently read from */ extern char *inpfname; /* name of the file currently read from */
SC_VDECL char outfname[]; /* intermediate (assembler) file name */ extern char outfname[]; /* intermediate (assembler) file name */
SC_VDECL char binfname[]; /* binary file name */ extern char binfname[]; /* binary file name */
SC_VDECL char errfname[]; /* error file name */ extern char errfname[]; /* error file name */
SC_VDECL char sc_ctrlchar; /* the control character (or escape character) */ extern char sc_ctrlchar; /* the control character (or escape character) */
SC_VDECL char sc_ctrlchar_org;/* the default control character */ extern char sc_ctrlchar_org;/* the default control character */
SC_VDECL int litidx; /* index to literal table */ extern int litidx; /* index to literal table */
SC_VDECL int litmax; /* current size of the literal table */ extern int litmax; /* current size of the literal table */
SC_VDECL int stgidx; /* index to the staging buffer */ extern int stgidx; /* index to the staging buffer */
SC_VDECL int sc_labnum; /* number of (internal) labels */ extern int sc_labnum; /* number of (internal) labels */
SC_VDECL int staging; /* true if staging output */ extern int staging; /* true if staging output */
SC_VDECL cell declared; /* number of local cells declared */ extern cell declared; /* number of local cells declared */
SC_VDECL cell glb_declared; /* number of global cells declared */ extern cell glb_declared; /* number of global cells declared */
SC_VDECL cell code_idx; /* number of bytes with generated code */ extern cell code_idx; /* number of bytes with generated code */
SC_VDECL int ntv_funcid; /* incremental number of native function */ extern int ntv_funcid; /* incremental number of native function */
SC_VDECL int errnum; /* number of errors */ extern int errnum; /* number of errors */
SC_VDECL int warnnum; /* number of warnings */ extern int warnnum; /* number of warnings */
SC_VDECL int sc_debug; /* debug/optimization options (bit field) */ extern int sc_debug; /* debug/optimization options (bit field) */
SC_VDECL int sc_packstr; /* strings are packed by default? */ extern int sc_packstr; /* strings are packed by default? */
SC_VDECL int sc_asmfile; /* create .ASM file? */ extern int sc_asmfile; /* create .ASM file? */
SC_VDECL int sc_listing; /* create .LST file? */ extern int sc_listing; /* create .LST file? */
SC_VDECL int sc_compress; /* compress bytecode? */ extern int sc_compress; /* compress bytecode? */
SC_VDECL int sc_needsemicolon;/* semicolon required to terminate expressions? */ extern int sc_needsemicolon;/* semicolon required to terminate expressions? */
SC_VDECL int sc_dataalign; /* data alignment value */ extern int sc_dataalign; /* data alignment value */
SC_VDECL int sc_alignnext; /* must frame of the next function be aligned? */ extern int sc_alignnext; /* must frame of the next function be aligned? */
SC_VDECL int pc_docexpr; /* must expression be attached to documentation comment? */ extern int pc_docexpr; /* must expression be attached to documentation comment? */
SC_VDECL int sc_showincludes; /* show include files? */ extern int sc_showincludes; /* show include files? */
SC_VDECL int curseg; /* 1 if currently parsing CODE, 2 if parsing DATA */ extern int curseg; /* 1 if currently parsing CODE, 2 if parsing DATA */
SC_VDECL cell pc_stksize; /* stack size */ extern cell pc_stksize; /* stack size */
SC_VDECL cell pc_amxlimit; /* abstract machine size limit (code + data, or only code) */ extern cell pc_amxlimit; /* abstract machine size limit (code + data, or only code) */
SC_VDECL cell pc_amxram; /* abstract machine data size limit */ extern cell pc_amxram; /* abstract machine data size limit */
SC_VDECL int freading; /* is there an input file ready for reading? */ extern int freading; /* is there an input file ready for reading? */
SC_VDECL int fline; /* the line number in the current file */ extern int fline; /* the line number in the current file */
SC_VDECL short fnumber; /* number of files in the file table (debugging) */ extern short fnumber; /* number of files in the file table (debugging) */
SC_VDECL short fcurrent; /* current file being processed (debugging) */ extern short fcurrent; /* current file being processed (debugging) */
SC_VDECL short sc_intest; /* true if inside a test */ extern short sc_intest; /* true if inside a test */
SC_VDECL int sideeffect; /* true if an expression causes a side-effect */ extern int sideeffect; /* true if an expression causes a side-effect */
SC_VDECL int stmtindent; /* current indent of the statement */ extern int stmtindent; /* current indent of the statement */
SC_VDECL int indent_nowarn; /* skip warning "217 loose indentation" */ extern int indent_nowarn; /* skip warning "217 loose indentation" */
SC_VDECL int sc_tabsize; /* number of spaces that a TAB represents */ extern int sc_tabsize; /* number of spaces that a TAB represents */
SC_VDECL short sc_allowtags; /* allow/detect tagnames in lex() */ extern short sc_allowtags; /* allow/detect tagnames in lex() */
SC_VDECL int sc_status; /* read/write status */ extern int sc_status; /* read/write status */
SC_VDECL int sc_err_status; /* TRUE if errors should be generated even if sc_status = SKIP */ extern int sc_err_status; /* TRUE if errors should be generated even if sc_status = SKIP */
SC_VDECL int sc_rationaltag; /* tag for rational numbers */ extern int sc_rationaltag; /* tag for rational numbers */
SC_VDECL int rational_digits; /* number of fractional digits */ extern int rational_digits; /* number of fractional digits */
SC_VDECL int sc_allowproccall;/* allow/detect tagnames in lex() */ extern int sc_allowproccall;/* allow/detect tagnames in lex() */
SC_VDECL short sc_is_utf8; /* is this source file in UTF-8 encoding */ extern short sc_is_utf8; /* is this source file in UTF-8 encoding */
SC_VDECL char *pc_deprecate; /* if non-NULL, mark next declaration as deprecated */ extern char *pc_deprecate; /* if non-NULL, mark next declaration as deprecated */
SC_VDECL int sc_curstates; /* ID of the current state list */ extern int sc_curstates; /* ID of the current state list */
SC_VDECL int pc_optimize; /* (peephole) optimization level */ extern int pc_optimize; /* (peephole) optimization level */
SC_VDECL int pc_memflags; /* special flags for the stack/heap usage */ extern int pc_memflags; /* special flags for the stack/heap usage */
SC_VDECL int pc_functag; /* global function tag */ extern int pc_functag; /* global function tag */
SC_VDECL int pc_tag_string; /* global String tag */ extern int pc_tag_string; /* global String tag */
SC_VDECL int pc_tag_void; /* global void tag */ extern int pc_tag_void; /* global void tag */
SC_VDECL int pc_tag_object; /* root object tag */ extern int pc_tag_object; /* root object tag */
SC_VDECL int pc_tag_bool; /* global bool tag */ extern int pc_tag_bool; /* global bool tag */
SC_VDECL int pc_tag_null_t; /* the null type */ extern int pc_tag_null_t; /* the null type */
SC_VDECL int pc_tag_nullfunc_t; /* the null function type */ extern int pc_tag_nullfunc_t; /* the null function type */
SC_VDECL int pc_anytag; /* global any tag */ extern int pc_anytag; /* global any tag */
SC_VDECL int glbstringread; /* last global string read */ extern int glbstringread; /* last global string read */
SC_VDECL int sc_require_newdecls; /* only newdecls are allowed */ extern int sc_require_newdecls; /* only newdecls are allowed */
SC_VDECL constvalue sc_automaton_tab; /* automaton table */ extern constvalue sc_automaton_tab; /* automaton table */
SC_VDECL constvalue sc_state_tab; /* state table */ extern constvalue sc_state_tab; /* state table */
SC_VDECL void *inpf; /* file read from (source or include) */ extern void *inpf; /* file read from (source or include) */
SC_VDECL void *inpf_org; /* main source file */ extern void *inpf_org; /* main source file */
SC_VDECL void *outf; /* file written to */ extern void *outf; /* file written to */
SC_VDECL jmp_buf errbuf; /* target of longjmp() on a fatal error */ extern jmp_buf errbuf; /* target of longjmp() on a fatal error */
#if !defined SC_LIGHT #if !defined SC_LIGHT
SC_VDECL int sc_makereport; /* generate a cross-reference report */ extern int sc_makereport; /* generate a cross-reference report */
#endif #endif
#if defined WIN32 #if defined WIN32

View File

@ -193,9 +193,6 @@ char g_tmpfile[_MAX_PATH] = {0};
/* "main" of the compiler /* "main" of the compiler
*/ */
#if defined __cplusplus
extern "C"
#endif
int pc_compile(int argc, char *argv[]) int pc_compile(int argc, char *argv[])
{ {
int entry,i,jmpcode; int entry,i,jmpcode;
@ -582,9 +579,6 @@ cleanup:
return retcode; return retcode;
} }
#if defined __cplusplus
extern "C"
#endif
int pc_addconstant(const char *name,cell value,int tag) int pc_addconstant(const char *name,cell value,int tag)
{ {
errorset(sFORCESET,0); /* make sure error engine is silenced */ errorset(sFORCESET,0); /* make sure error engine is silenced */
@ -678,9 +672,6 @@ int pc_findtag(const char *name)
return -1; return -1;
} }
#if defined __cplusplus
extern "C"
#endif
int pc_addtag(const char *name) int pc_addtag(const char *name)
{ {
int val; int val;
@ -833,7 +824,7 @@ static char *get_extension(char *filename)
* Set the default extension, or force an extension. To erase the * Set the default extension, or force an extension. To erase the
* extension of a filename, set "extension" to an empty string. * extension of a filename, set "extension" to an empty string.
*/ */
SC_FUNC void set_extension(char *filename,const char *extension,int force) void set_extension(char *filename,const char *extension,int force)
{ {
char *ptr; char *ptr;
@ -4726,7 +4717,7 @@ static int compare_tag(int tag1, int tag2)
* Finds a function in the global symbol table or creates a new entry. * Finds a function in the global symbol table or creates a new entry.
* It does some basic processing and error checking. * It does some basic processing and error checking.
*/ */
SC_FUNC symbol *fetchfunc(char *name) symbol *fetchfunc(char *name)
{ {
symbol *sym; symbol *sym;
@ -4955,7 +4946,7 @@ static char *tag2str(char *dest,int tag)
return isdigit(dest[1]) ? &dest[1] : dest; return isdigit(dest[1]) ? &dest[1] : dest;
} }
SC_FUNC char *operator_symname(char *symname,const char *opername,int tag1,int tag2,int numtags,int resulttag) char *operator_symname(char *symname,const char *opername,int tag1,int tag2,int numtags,int resulttag)
{ {
char tagstr1[10], tagstr2[10]; char tagstr1[10], tagstr2[10];
int opertok; int opertok;
@ -5005,7 +4996,7 @@ constvalue *find_tag_byval(int tag)
return tagsym; return tagsym;
} }
SC_FUNC char *funcdisplayname(char *dest,char *funcname) char *funcdisplayname(char *dest,char *funcname)
{ {
int tags[2]; int tags[2];
char opname[10]; char opname[10];
@ -6493,7 +6484,7 @@ static constvalue *insert_constval(constvalue *prev,constvalue *next,const char
return cur; return cur;
} }
SC_FUNC constvalue *append_constval(constvalue *table,const char *name,cell val,int index) constvalue *append_constval(constvalue *table,const char *name,cell val,int index)
{ {
constvalue *cur,*prev; constvalue *cur,*prev;
@ -6503,7 +6494,7 @@ SC_FUNC constvalue *append_constval(constvalue *table,const char *name,cell val,
return insert_constval(prev,NULL,name,val,index); return insert_constval(prev,NULL,name,val,index);
} }
SC_FUNC constvalue *find_constval(constvalue *table,char *name,int index) constvalue *find_constval(constvalue *table,char *name,int index)
{ {
constvalue *ptr = table->next; constvalue *ptr = table->next;
@ -6546,7 +6537,7 @@ static int delete_constval(constvalue *table,char *name)
} }
#endif #endif
SC_FUNC void delete_consttable(constvalue *table) void delete_consttable(constvalue *table)
{ {
constvalue *cur=table->next, *next; constvalue *cur=table->next, *next;
@ -6562,7 +6553,7 @@ SC_FUNC void delete_consttable(constvalue *table)
* *
* Adds a symbol to the symbol table. Returns NULL on failure. * Adds a symbol to the symbol table. Returns NULL on failure.
*/ */
SC_FUNC symbol *add_constant(const char *name,cell val,int vclass,int tag) symbol *add_constant(const char *name,cell val,int vclass,int tag)
{ {
symbol *sym; symbol *sym;
@ -6896,7 +6887,7 @@ static int doexpr2(int comma,int chkeffect,int allowarray,int mark_endexpr,
/* exprconst /* exprconst
*/ */
SC_FUNC int exprconst(cell *val,int *tag,symbol **symptr) int exprconst(cell *val,int *tag,symbol **symptr)
{ {
int ident,index; int ident,index;
cell cidx; cell cidx;
@ -7633,7 +7624,7 @@ static void docont(void)
jumplabel(ptr[wqLOOP]); jumplabel(ptr[wqLOOP]);
} }
SC_FUNC void exporttag(int tag) void exporttag(int tag)
{ {
/* find the tag by value in the table, then set the top bit to mark it /* find the tag by value in the table, then set the top bit to mark it
* "public" * "public"

View File

@ -86,7 +86,7 @@ static double pow10(double d)
static stkitem *stack=NULL; static stkitem *stack=NULL;
static int stkidx=0,stktop=0; static int stkidx=0,stktop=0;
SC_FUNC void pushstk(stkitem val) void pushstk(stkitem val)
{ {
assert(stkidx<=stktop); assert(stkidx<=stktop);
if (stkidx==stktop) { if (stkidx==stktop) {
@ -109,7 +109,7 @@ SC_FUNC void pushstk(stkitem val)
stkidx+=1; stkidx+=1;
} }
SC_FUNC stkitem popstk(void) stkitem popstk(void)
{ {
if (stkidx==0) { if (stkidx==0) {
stkitem s; stkitem s;
@ -121,7 +121,7 @@ SC_FUNC stkitem popstk(void)
return stack[stkidx]; return stack[stkidx];
} }
SC_FUNC void clearstk(void) void clearstk(void)
{ {
assert(stack!=NULL || stktop==0); assert(stack!=NULL || stktop==0);
if (stack!=NULL) { if (stack!=NULL) {
@ -132,7 +132,7 @@ SC_FUNC void clearstk(void)
assert(stktop==0); assert(stktop==0);
} }
SC_FUNC int plungequalifiedfile(char *name) int plungequalifiedfile(char *name)
{ {
static const char *extensions[] = { ".inc", ".p", ".pawn" }; static const char *extensions[] = { ".inc", ".p", ".pawn" };
@ -185,7 +185,7 @@ SC_FUNC int plungequalifiedfile(char *name)
return TRUE; return TRUE;
} }
SC_FUNC int plungefile(char *name,int try_currentpath,int try_includepaths) int plungefile(char *name,int try_currentpath,int try_includepaths)
{ {
int result=FALSE; int result=FALSE;
@ -1793,7 +1793,7 @@ static int scanellipsis(const unsigned char *lptr)
* pline (altered) * pline (altered)
* freading (referred to only) * freading (referred to only)
*/ */
SC_FUNC void preprocess(void) void preprocess(void)
{ {
int iscommand; int iscommand;
@ -1932,7 +1932,7 @@ static full_token_t *next_token()
return &sTokenBuffer->tokens[cursor]; return &sTokenBuffer->tokens[cursor];
} }
SC_FUNC void lexinit(void) void lexinit(void)
{ {
stkidx=0; /* index for pushstk() and popstk() */ stkidx=0; /* index for pushstk() and popstk() */
iflevel=0; /* preprocessor: nesting of "#if" is currently 0 */ iflevel=0; /* preprocessor: nesting of "#if" is currently 0 */
@ -2001,7 +2001,7 @@ static void lexpop()
sTokenBuffer->cursor = 0; sTokenBuffer->cursor = 0;
} }
SC_FUNC int lex(cell *lexvalue,char **lexsym) int lex(cell *lexvalue,char **lexsym)
{ {
int i,toolong,newline; int i,toolong,newline;
const unsigned char *starttoken; const unsigned char *starttoken;
@ -2259,7 +2259,7 @@ SC_FUNC int lex(cell *lexvalue,char **lexsym)
* to read and return the information from these variables, rather than * to read and return the information from these variables, rather than
* to read in a new token from the input file. * to read in a new token from the input file.
*/ */
SC_FUNC void lexpush(void) void lexpush(void)
{ {
assert(sTokenBuffer->depth < MAX_TOKEN_DEPTH); assert(sTokenBuffer->depth < MAX_TOKEN_DEPTH);
sTokenBuffer->depth++; sTokenBuffer->depth++;
@ -2276,7 +2276,7 @@ SC_FUNC void lexpush(void)
* symbol (a not continue with some old one). This is required upon return * symbol (a not continue with some old one). This is required upon return
* from Assembler mode, and in a few cases after detecting an syntax error. * from Assembler mode, and in a few cases after detecting an syntax error.
*/ */
SC_FUNC void lexclr(int clreol) void lexclr(int clreol)
{ {
sTokenBuffer->depth = 0; sTokenBuffer->depth = 0;
if (clreol) { if (clreol) {
@ -2286,7 +2286,7 @@ SC_FUNC void lexclr(int clreol)
} }
// Return true if the symbol is ahead, false otherwise. // Return true if the symbol is ahead, false otherwise.
SC_FUNC int lexpeek(int id) int lexpeek(int id)
{ {
if (matchtoken(id)) { if (matchtoken(id)) {
lexpush(); lexpush();
@ -2305,7 +2305,7 @@ SC_FUNC int lexpeek(int id)
* (i.e. not present in the source code) should not be pushed back, which is * (i.e. not present in the source code) should not be pushed back, which is
* why it is sometimes important to distinguish the two. * why it is sometimes important to distinguish the two.
*/ */
SC_FUNC int matchtoken(int token) int matchtoken(int token)
{ {
cell val; cell val;
char *str; char *str;
@ -2338,7 +2338,7 @@ SC_FUNC int matchtoken(int token)
* *
* The token itself is the return value. Normally, this one is already known. * The token itself is the return value. Normally, this one is already known.
*/ */
SC_FUNC int tokeninfo(cell *val,char **str) int tokeninfo(cell *val,char **str)
{ {
*val = current_token()->value; *val = current_token()->value;
*str = current_token()->str; *str = current_token()->str;
@ -2352,7 +2352,7 @@ SC_FUNC int tokeninfo(cell *val,char **str)
* this function returns 1 for "token found" and 2 for "statement termination * this function returns 1 for "token found" and 2 for "statement termination
* token" found; see function matchtoken() for details. * token" found; see function matchtoken() for details.
*/ */
SC_FUNC int needtoken(int token) int needtoken(int token)
{ {
char s1[20],s2[20]; char s1[20],s2[20];
int t; int t;
@ -2379,7 +2379,7 @@ SC_FUNC int needtoken(int token)
// If the next token is on the current line, return that token. Otherwise, // If the next token is on the current line, return that token. Otherwise,
// return tNEWLINE. // return tNEWLINE.
SC_FUNC int peek_same_line() int peek_same_line()
{ {
// We should not call this without having parsed at least one token. // We should not call this without having parsed at least one token.
assert(sTokenBuffer->num_tokens > 0); assert(sTokenBuffer->num_tokens > 0);
@ -2407,7 +2407,7 @@ SC_FUNC int peek_same_line()
return tEOL; return tEOL;
} }
SC_FUNC int require_newline(int allow_semi) int require_newline(int allow_semi)
{ {
if (allow_semi) { if (allow_semi) {
// Semicolon must be on the same line. // Semicolon must be on the same line.
@ -2482,7 +2482,7 @@ static void chk_grow_litq(void)
* Global references: litidx (altered) * Global references: litidx (altered)
* litq (altered) * litq (altered)
*/ */
SC_FUNC void litadd(cell value) void litadd(cell value)
{ {
chk_grow_litq(); chk_grow_litq();
assert(litidx<litmax); assert(litidx<litmax);
@ -2497,7 +2497,7 @@ SC_FUNC void litadd(cell value)
* Global references: litidx (altered) * Global references: litidx (altered)
* litq (altered) * litq (altered)
*/ */
SC_FUNC void litinsert(cell value,int pos) void litinsert(cell value,int pos)
{ {
chk_grow_litq(); chk_grow_litq();
assert(litidx<litmax); assert(litidx<litmax);
@ -2632,7 +2632,7 @@ static int alpha(char c)
* *
* Test if character "c" is alphanumeric ("a".."z", "0".."9", "_" or "@") * Test if character "c" is alphanumeric ("a".."z", "0".."9", "_" or "@")
*/ */
SC_FUNC int alphanum(char c) int alphanum(char c)
{ {
return (alpha(c) || isdigit(c)); return (alpha(c) || isdigit(c));
} }
@ -2641,7 +2641,7 @@ SC_FUNC int alphanum(char c)
* *
* Test if character "c" is a hexadecimal digit ("0".."9" or "a".."f"). * Test if character "c" is a hexadecimal digit ("0".."9" or "a".."f").
*/ */
SC_FUNC int ishex(char c) int ishex(char c)
{ {
return (c>='0' && c<='9') || (c>='a' && c<='f') || (c>='A' && c<='F'); return (c>='0' && c<='9') || (c>='a' && c<='f') || (c>='A' && c<='F');
} }
@ -2717,7 +2717,7 @@ static void free_symbol(symbol *sym)
free(sym); free(sym);
} }
SC_FUNC void delete_symbol(symbol *root,symbol *sym) void delete_symbol(symbol *root,symbol *sym)
{ {
symbol *origRoot=root; symbol *origRoot=root;
/* find the symbol and its predecessor /* find the symbol and its predecessor
@ -2738,7 +2738,7 @@ SC_FUNC void delete_symbol(symbol *root,symbol *sym)
free_symbol(sym); free_symbol(sym);
} }
SC_FUNC int get_actual_compound(symbol *sym) int get_actual_compound(symbol *sym)
{ {
if (sym->ident == iARRAY || sym->ident == iREFARRAY) { if (sym->ident == iARRAY || sym->ident == iREFARRAY) {
while (sym->parent) while (sym->parent)
@ -2748,7 +2748,7 @@ SC_FUNC int get_actual_compound(symbol *sym)
return sym->compound; return sym->compound;
} }
SC_FUNC void delete_symbols(symbol *root,int level,int delete_labels,int delete_functions) void delete_symbols(symbol *root,int level,int delete_labels,int delete_functions)
{ {
symbol *origRoot=root; symbol *origRoot=root;
symbol *sym,*parent_sym; symbol *sym,*parent_sym;
@ -2908,7 +2908,7 @@ static symbol *find_symbol_child(const symbol *root,const symbol *sym)
* bywhom will be the function that uses a variable or that calls * bywhom will be the function that uses a variable or that calls
* the function. * the function.
*/ */
SC_FUNC int refer_symbol(symbol *entry,symbol *bywhom) int refer_symbol(symbol *entry,symbol *bywhom)
{ {
int count; int count;
@ -2950,7 +2950,7 @@ SC_FUNC int refer_symbol(symbol *entry,symbol *bywhom)
return TRUE; return TRUE;
} }
SC_FUNC void markusage(symbol *sym,int usage) void markusage(symbol *sym,int usage)
{ {
assert(sym!=NULL); assert(sym!=NULL);
sym->usage |= (char)usage; sym->usage |= (char)usage;
@ -2974,7 +2974,7 @@ SC_FUNC void markusage(symbol *sym,int usage)
* *
* Returns a pointer to the global symbol (if found) or NULL (if not found) * Returns a pointer to the global symbol (if found) or NULL (if not found)
*/ */
SC_FUNC symbol *findglb(const char *name,int filter) symbol *findglb(const char *name,int filter)
{ {
/* find a symbol with a matching automaton first */ /* find a symbol with a matching automaton first */
symbol *sym=NULL; symbol *sym=NULL;
@ -3010,12 +3010,12 @@ SC_FUNC symbol *findglb(const char *name,int filter)
* Returns a pointer to the local symbol (if found) or NULL (if not found). * Returns a pointer to the local symbol (if found) or NULL (if not found).
* See add_symbol() how the deepest nesting level is searched first. * See add_symbol() how the deepest nesting level is searched first.
*/ */
SC_FUNC symbol *findloc(const char *name) symbol *findloc(const char *name)
{ {
return find_symbol(&loctab,name,-1,-1,NULL); return find_symbol(&loctab,name,-1,-1,NULL);
} }
SC_FUNC symbol *findconst(const char *name,int *cmptag) symbol *findconst(const char *name,int *cmptag)
{ {
symbol *sym; symbol *sym;
@ -3033,7 +3033,7 @@ SC_FUNC symbol *findconst(const char *name,int *cmptag)
return sym; return sym;
} }
SC_FUNC symbol *finddepend(const symbol *parent) symbol *finddepend(const symbol *parent)
{ {
symbol *sym; symbol *sym;
@ -3048,7 +3048,7 @@ SC_FUNC symbol *finddepend(const symbol *parent)
* Adds a symbol to the symbol table (either global or local variables, * Adds a symbol to the symbol table (either global or local variables,
* or global and local constants). * or global and local constants).
*/ */
SC_FUNC symbol *addsym(const char *name,cell addr,int ident,int vclass,int tag,int usage) symbol *addsym(const char *name,cell addr,int ident,int vclass,int tag,int usage)
{ {
symbol entry, **refer; symbol entry, **refer;
@ -3083,13 +3083,13 @@ SC_FUNC symbol *addsym(const char *name,cell addr,int ident,int vclass,int tag,i
return add_symbol(&loctab,&entry,FALSE); return add_symbol(&loctab,&entry,FALSE);
} }
SC_FUNC symbol *addvariable(const char *name,cell addr,int ident,int vclass,int tag, symbol *addvariable(const char *name,cell addr,int ident,int vclass,int tag,
int dim[],int numdim,int idxtag[]) int dim[],int numdim,int idxtag[])
{ {
return addvariable2(name,addr,ident,vclass,tag,dim,numdim,idxtag,0); return addvariable2(name,addr,ident,vclass,tag,dim,numdim,idxtag,0);
} }
SC_FUNC symbol *addvariable3(declinfo_t *decl,cell addr,int vclass,int slength) symbol *addvariable3(declinfo_t *decl,cell addr,int vclass,int slength)
{ {
typeinfo_t *type = &decl->type; typeinfo_t *type = &decl->type;
return addvariable2( return addvariable2(
@ -3105,7 +3105,7 @@ SC_FUNC symbol *addvariable3(declinfo_t *decl,cell addr,int vclass,int slength)
); );
} }
SC_FUNC symbol *addvariable2(const char *name,cell addr,int ident,int vclass,int tag, symbol *addvariable2(const char *name,cell addr,int ident,int vclass,int tag,
int dim[],int numdim,int idxtag[],int slength) int dim[],int numdim,int idxtag[],int slength)
{ {
symbol *sym; symbol *sym;
@ -3154,7 +3154,7 @@ SC_FUNC symbol *addvariable2(const char *name,cell addr,int ident,int vclass,int
* Returns te next internal label number. The global variable sc_labnum is * Returns te next internal label number. The global variable sc_labnum is
* initialized to zero. * initialized to zero.
*/ */
SC_FUNC int getlabel(void) int getlabel(void)
{ {
return sc_labnum++; return sc_labnum++;
} }
@ -3164,7 +3164,7 @@ SC_FUNC int getlabel(void)
* Converts a number to a hexadecimal string and returns a pointer to that * Converts a number to a hexadecimal string and returns a pointer to that
* string. This function is NOT re-entrant. * string. This function is NOT re-entrant.
*/ */
SC_FUNC char *itoh(ucell val) char *itoh(ucell val)
{ {
static char itohstr[30]; static char itohstr[30];
char *ptr; char *ptr;
@ -3199,13 +3199,13 @@ static char itohstr[30];
return itohstr; return itohstr;
} }
SC_FUNC int lextok(token_t *tok) int lextok(token_t *tok)
{ {
tok->id = lex(&tok->val, &tok->str); tok->id = lex(&tok->val, &tok->str);
return tok->id; return tok->id;
} }
SC_FUNC int expecttoken(int id, token_t *tok) int expecttoken(int id, token_t *tok)
{ {
int rval = needtoken(id); int rval = needtoken(id);
if (rval) { if (rval) {
@ -3217,7 +3217,7 @@ SC_FUNC int expecttoken(int id, token_t *tok)
return FALSE; return FALSE;
} }
SC_FUNC int matchtoken2(int id, token_t *tok) int matchtoken2(int id, token_t *tok)
{ {
if (matchtoken(id)) { if (matchtoken(id)) {
tok->id = tokeninfo(&tok->val, &tok->str); tok->id = tokeninfo(&tok->val, &tok->str);
@ -3226,7 +3226,7 @@ SC_FUNC int matchtoken2(int id, token_t *tok)
return FALSE; return FALSE;
} }
SC_FUNC int matchsymbol(token_ident_t *ident) int matchsymbol(token_ident_t *ident)
{ {
if (lextok(&ident->tok) != tSYMBOL) { if (lextok(&ident->tok) != tSYMBOL) {
lexpush(); lexpush();
@ -3237,7 +3237,7 @@ SC_FUNC int matchsymbol(token_ident_t *ident)
return TRUE; return TRUE;
} }
SC_FUNC int needsymbol(token_ident_t *ident) int needsymbol(token_ident_t *ident)
{ {
if (!expecttoken(tSYMBOL, &ident->tok)) if (!expecttoken(tSYMBOL, &ident->tok))
return FALSE; return FALSE;

View File

@ -113,7 +113,7 @@ static int nextop(int *opidx,int *list)
return FALSE; /* entire list scanned, nothing found */ return FALSE; /* entire list scanned, nothing found */
} }
SC_FUNC int check_userop(void (*oper)(void),int tag1,int tag2,int numparam, int check_userop(void (*oper)(void),int tag1,int tag2,int numparam,
value *lval,int *resulttag) value *lval,int *resulttag)
{ {
static const char *binoperstr[] = { static const char *binoperstr[] = {
@ -290,7 +290,7 @@ SC_FUNC int check_userop(void (*oper)(void),int tag1,int tag2,int numparam,
return TRUE; return TRUE;
} }
SC_FUNC int checktags_string(int tags[], int numtags, value *sym1) int checktags_string(int tags[], int numtags, value *sym1)
{ {
int i; int i;
if (sym1->ident == iARRAY || sym1->ident == iREFARRAY) if (sym1->ident == iARRAY || sym1->ident == iREFARRAY)
@ -305,7 +305,7 @@ SC_FUNC int checktags_string(int tags[], int numtags, value *sym1)
return FALSE; return FALSE;
} }
SC_FUNC int checktag_string(value *sym1, value *sym2) int checktag_string(value *sym1, value *sym2)
{ {
if (sym1->ident == iARRAY || sym2->ident == iARRAY || if (sym1->ident == iARRAY || sym2->ident == iARRAY ||
sym1->ident == iREFARRAY || sym2->ident == iREFARRAY) sym1->ident == iREFARRAY || sym2->ident == iREFARRAY)
@ -321,7 +321,7 @@ SC_FUNC int checktag_string(value *sym1, value *sym2)
return FALSE; return FALSE;
} }
SC_FUNC const char *type_to_name(int tag) const char *type_to_name(int tag)
{ {
if (tag == 0) if (tag == 0)
return "int"; return "int";
@ -339,7 +339,7 @@ SC_FUNC const char *type_to_name(int tag)
return "unknown"; return "unknown";
} }
SC_FUNC int matchtag_string(int ident, int tag) int matchtag_string(int ident, int tag)
{ {
if (ident == iARRAY || ident == iREFARRAY) if (ident == iARRAY || ident == iREFARRAY)
return FALSE; return FALSE;
@ -519,7 +519,7 @@ static int matchfunctags(int formaltag, int actualtag)
return FALSE; return FALSE;
} }
SC_FUNC int matchtag(int formaltag, int actualtag, int flags) int matchtag(int formaltag, int actualtag, int flags)
{ {
if (formaltag == actualtag) if (formaltag == actualtag)
return TRUE; return TRUE;
@ -958,7 +958,7 @@ static cell calc(cell left,void (*oper)(),cell right,char *boolresult)
return 0; return 0;
} }
SC_FUNC int lvalexpr(svalue *sval) int lvalexpr(svalue *sval)
{ {
memset(sval, 0, sizeof(*sval)); memset(sval, 0, sizeof(*sval));
@ -971,7 +971,7 @@ SC_FUNC int lvalexpr(svalue *sval)
return sval->val.ident; return sval->val.ident;
} }
SC_FUNC int expression(cell *val,int *tag,symbol **symptr,int chkfuncresult,value *_lval) int expression(cell *val,int *tag,symbol **symptr,int chkfuncresult,value *_lval)
{ {
value lval={0}; value lval={0};
pushheaplist(); pushheaplist();
@ -994,7 +994,7 @@ SC_FUNC int expression(cell *val,int *tag,symbol **symptr,int chkfuncresult,valu
return lval.ident; return lval.ident;
} }
SC_FUNC int sc_getstateid(constvalue **automaton,constvalue **state) int sc_getstateid(constvalue **automaton,constvalue **state)
{ {
char name[sNAMEMAX+1]; char name[sNAMEMAX+1];
cell val; cell val;
@ -1047,7 +1047,7 @@ SC_FUNC int sc_getstateid(constvalue **automaton,constvalue **state)
return 1; return 1;
} }
SC_FUNC cell array_totalsize(symbol *sym) cell array_totalsize(symbol *sym)
{ {
cell length; cell length;

View File

@ -34,14 +34,14 @@
static int fcurseg; /* the file number (fcurrent) for the active segment */ static int fcurseg; /* the file number (fcurrent) for the active segment */
SC_FUNC void load_i(); void load_i();
/* When a subroutine returns to address 0, the AMX must halt. In earlier /* When a subroutine returns to address 0, the AMX must halt. In earlier
* releases, the RET and RETN opcodes checked for the special case 0 address. * releases, the RET and RETN opcodes checked for the special case 0 address.
* Today, the compiler simply generates a HALT instruction at address 0. So * Today, the compiler simply generates a HALT instruction at address 0. So
* a subroutine can savely return to 0, and then encounter a HALT. * a subroutine can savely return to 0, and then encounter a HALT.
*/ */
SC_FUNC void writeleader(symbol *root) void writeleader(symbol *root)
{ {
int lbl_nostate,lbl_table; int lbl_nostate,lbl_table;
int statecount; int statecount;
@ -175,7 +175,7 @@ SC_FUNC void writeleader(symbol *root)
* code_idx (altered) * code_idx (altered)
* glb_declared (altered) * glb_declared (altered)
*/ */
SC_FUNC void writetrailer(void) void writetrailer(void)
{ {
assert(sc_dataalign % opcodes(1) == 0); /* alignment must be a multiple of assert(sc_dataalign % opcodes(1) == 0); /* alignment must be a multiple of
* the opcode size */ * the opcode size */
@ -215,7 +215,7 @@ SC_FUNC void writetrailer(void)
* Global references: curseg * Global references: curseg
* fcurrent * fcurrent
*/ */
SC_FUNC void begcseg(void) void begcseg(void)
{ {
if (sc_status!=statSKIP && (curseg!=sIN_CSEG || fcurrent!=fcurseg)) { if (sc_status!=statSKIP && (curseg!=sIN_CSEG || fcurrent!=fcurseg)) {
stgwrite("\n"); stgwrite("\n");
@ -233,7 +233,7 @@ SC_FUNC void begcseg(void)
* *
* Global references: curseg * Global references: curseg
*/ */
SC_FUNC void begdseg(void) void begdseg(void)
{ {
if (sc_status!=statSKIP && (curseg!=sIN_DSEG || fcurrent!=fcurseg)) { if (sc_status!=statSKIP && (curseg!=sIN_DSEG || fcurrent!=fcurseg)) {
stgwrite("\n"); stgwrite("\n");
@ -246,7 +246,7 @@ SC_FUNC void begdseg(void)
} /* if */ } /* if */
} }
SC_FUNC void setline(int chkbounds) void setline(int chkbounds)
{ {
if (sc_asmfile) { if (sc_asmfile) {
stgwrite("\t; line "); stgwrite("\t; line ");
@ -263,7 +263,7 @@ SC_FUNC void setline(int chkbounds)
} /* if */ } /* if */
} }
SC_FUNC void setfiledirect(char *name) void setfiledirect(char *name)
{ {
if (sc_status==statFIRST && sc_listing) { if (sc_status==statFIRST && sc_listing) {
assert(name!=NULL); assert(name!=NULL);
@ -273,7 +273,7 @@ SC_FUNC void setfiledirect(char *name)
} /* if */ } /* if */
} }
SC_FUNC void setlinedirect(int line) void setlinedirect(int line)
{ {
if (sc_status==statFIRST && sc_listing) { if (sc_status==statFIRST && sc_listing) {
char string[40]; char string[40];
@ -286,7 +286,7 @@ SC_FUNC void setlinedirect(int line)
* *
* Post a code label (specified as a number), on a new line. * Post a code label (specified as a number), on a new line.
*/ */
SC_FUNC void setlabel(int number) void setlabel(int number)
{ {
assert(number>=0); assert(number>=0);
stgwrite("l."); stgwrite("l.");
@ -307,7 +307,7 @@ SC_FUNC void setlabel(int number)
* statement. This allows several simple optimizations by the peephole * statement. This allows several simple optimizations by the peephole
* optimizer. * optimizer.
*/ */
SC_FUNC void markexpr(optmark type,const char *name,cell offset) void markexpr(optmark type,const char *name,cell offset)
{ {
switch (type) { switch (type) {
case sEXPR: case sEXPR:
@ -332,7 +332,7 @@ SC_FUNC void markexpr(optmark type,const char *name,cell offset)
* *
* Global references: funcstatus (referred to only) * Global references: funcstatus (referred to only)
*/ */
SC_FUNC void startfunc(char *fname) void startfunc(char *fname)
{ {
stgwrite("\tproc"); stgwrite("\tproc");
if (sc_asmfile) { if (sc_asmfile) {
@ -349,7 +349,7 @@ SC_FUNC void startfunc(char *fname)
* *
* Declare a CODE ending point (function end) * Declare a CODE ending point (function end)
*/ */
SC_FUNC void endfunc(void) void endfunc(void)
{ {
stgwrite("\n"); /* skip a line */ stgwrite("\n"); /* skip a line */
} }
@ -361,7 +361,7 @@ SC_FUNC void endfunc(void)
* be a power of 2, and this alignment must be done right after the frame * be a power of 2, and this alignment must be done right after the frame
* is set up (before the first variable is declared) * is set up (before the first variable is declared)
*/ */
SC_FUNC void alignframe(int numbytes) void alignframe(int numbytes)
{ {
#if !defined NDEBUG #if !defined NDEBUG
/* "numbytes" should be a power of 2 for this code to work */ /* "numbytes" should be a power of 2 for this code to work */
@ -385,7 +385,7 @@ SC_FUNC void alignframe(int numbytes)
* *
* Generate code to get the value of a symbol into "primary". * Generate code to get the value of a symbol into "primary".
*/ */
SC_FUNC void rvalue(value *lval) void rvalue(value *lval)
{ {
symbol *sym; symbol *sym;
@ -429,7 +429,7 @@ SC_FUNC void rvalue(value *lval)
/* Get the address of a symbol into the primary or alternate register (used /* Get the address of a symbol into the primary or alternate register (used
* for arrays, and for passing arguments by reference). * for arrays, and for passing arguments by reference).
*/ */
SC_FUNC void address(symbol *sym,regid reg) void address(symbol *sym,regid reg)
{ {
assert(sym!=NULL); assert(sym!=NULL);
assert(reg==sPRI || reg==sALT); assert(reg==sPRI || reg==sALT);
@ -495,20 +495,20 @@ static void load_argcount(regid reg)
} }
// PRI = ALT + (PRI * cellsize) // PRI = ALT + (PRI * cellsize)
SC_FUNC void idxaddr() void idxaddr()
{ {
stgwrite("\tidxaddr\n"); stgwrite("\tidxaddr\n");
code_idx += opcodes(1); code_idx += opcodes(1);
} }
SC_FUNC void load_i() void load_i()
{ {
stgwrite("\tload.i\n"); stgwrite("\tload.i\n");
code_idx+=opcodes(1); code_idx+=opcodes(1);
} }
// Load the hidden array argument into ALT. // Load the hidden array argument into ALT.
SC_FUNC void load_hidden_arg() void load_hidden_arg()
{ {
pushreg(sPRI); pushreg(sPRI);
@ -533,7 +533,7 @@ SC_FUNC void load_hidden_arg()
* Saves the contents of "primary" into a memory cell, either directly * Saves the contents of "primary" into a memory cell, either directly
* or indirectly (at the address given in the alternate register). * or indirectly (at the address given in the alternate register).
*/ */
SC_FUNC void store(value *lval) void store(value *lval)
{ {
symbol *sym; symbol *sym;
@ -570,7 +570,7 @@ SC_FUNC void store(value *lval)
} }
/* Get a cell from a fixed address in memory */ /* Get a cell from a fixed address in memory */
SC_FUNC void loadreg(cell address,regid reg) void loadreg(cell address,regid reg)
{ {
assert(reg==sPRI || reg==sALT); assert(reg==sPRI || reg==sALT);
if (reg==sPRI) if (reg==sPRI)
@ -582,7 +582,7 @@ SC_FUNC void loadreg(cell address,regid reg)
} }
/* Store a cell into a fixed address in memory */ /* Store a cell into a fixed address in memory */
SC_FUNC void storereg(cell address,regid reg) void storereg(cell address,regid reg)
{ {
assert(reg==sPRI || reg==sALT); assert(reg==sPRI || reg==sALT);
if (reg==sPRI) if (reg==sPRI)
@ -596,7 +596,7 @@ SC_FUNC void storereg(cell address,regid reg)
/* source must in PRI, destination address in ALT. The "size" /* source must in PRI, destination address in ALT. The "size"
* parameter is in bytes, not cells. * parameter is in bytes, not cells.
*/ */
SC_FUNC void memcopy(cell size) void memcopy(cell size)
{ {
stgwrite("\tmovs "); stgwrite("\tmovs ");
outval(size,TRUE); outval(size,TRUE);
@ -607,7 +607,7 @@ SC_FUNC void memcopy(cell size)
/* Address of the source must already have been loaded in PRI /* Address of the source must already have been loaded in PRI
* "size" is the size in bytes (not cells). * "size" is the size in bytes (not cells).
*/ */
SC_FUNC void copyarray(symbol *sym,cell size) void copyarray(symbol *sym,cell size)
{ {
assert(sym!=NULL); assert(sym!=NULL);
/* the symbol can be a local array, a global array, or an array /* the symbol can be a local array, a global array, or an array
@ -631,7 +631,7 @@ SC_FUNC void copyarray(symbol *sym,cell size)
memcopy(size); memcopy(size);
} }
SC_FUNC void fillarray(symbol *sym,cell size,cell value) void fillarray(symbol *sym,cell size,cell value)
{ {
ldconst(value,sPRI); /* load value in PRI */ ldconst(value,sPRI); /* load value in PRI */
@ -660,7 +660,7 @@ SC_FUNC void fillarray(symbol *sym,cell size,cell value)
code_idx+=opcodes(2)+opargs(2); code_idx+=opcodes(2)+opargs(2);
} }
SC_FUNC void stradjust(regid reg) void stradjust(regid reg)
{ {
assert(reg==sPRI); assert(reg==sPRI);
stgwrite("\tstradjust.pri\n"); stgwrite("\tstradjust.pri\n");
@ -670,7 +670,7 @@ SC_FUNC void stradjust(regid reg)
/* Instruction to get an immediate value into the primary or the alternate /* Instruction to get an immediate value into the primary or the alternate
* register * register
*/ */
SC_FUNC void ldconst(cell val,regid reg) void ldconst(cell val,regid reg)
{ {
assert(reg==sPRI || reg==sALT); assert(reg==sPRI || reg==sALT);
switch (reg) { switch (reg) {
@ -698,13 +698,13 @@ SC_FUNC void ldconst(cell val,regid reg)
} }
/* Copy value in alternate register to the primary register */ /* Copy value in alternate register to the primary register */
SC_FUNC void moveto1(void) void moveto1(void)
{ {
stgwrite("\tmove.pri\n"); stgwrite("\tmove.pri\n");
code_idx+=opcodes(1)+opargs(0); code_idx+=opcodes(1)+opargs(0);
} }
SC_FUNC void move_alt(void) void move_alt(void)
{ {
stgwrite("\tmove.alt\n"); stgwrite("\tmove.alt\n");
code_idx+=opcodes(1)+opargs(0); code_idx+=opcodes(1)+opargs(0);
@ -712,7 +712,7 @@ SC_FUNC void move_alt(void)
/* Push primary or the alternate register onto the stack /* Push primary or the alternate register onto the stack
*/ */
SC_FUNC void pushreg(regid reg) void pushreg(regid reg)
{ {
assert(reg==sPRI || reg==sALT); assert(reg==sPRI || reg==sALT);
switch (reg) { switch (reg) {
@ -729,7 +729,7 @@ SC_FUNC void pushreg(regid reg)
/* /*
* Push a constant value onto the stack * Push a constant value onto the stack
*/ */
SC_FUNC void pushval(cell val) void pushval(cell val)
{ {
stgwrite("\tpush.c "); stgwrite("\tpush.c ");
outval(val, TRUE); outval(val, TRUE);
@ -738,7 +738,7 @@ SC_FUNC void pushval(cell val)
/* Pop stack into the primary or the alternate register /* Pop stack into the primary or the alternate register
*/ */
SC_FUNC void popreg(regid reg) void popreg(regid reg)
{ {
assert(reg==sPRI || reg==sALT); assert(reg==sPRI || reg==sALT);
switch (reg) { switch (reg) {
@ -755,7 +755,7 @@ SC_FUNC void popreg(regid reg)
/* /*
* Generate an array * Generate an array
*/ */
SC_FUNC void genarray(int dims, int _autozero) void genarray(int dims, int _autozero)
{ {
if (_autozero) { if (_autozero) {
stgwrite("\tgenarray.z "); stgwrite("\tgenarray.z ");
@ -769,7 +769,7 @@ SC_FUNC void genarray(int dims, int _autozero)
/* /*
* swap the top-of-stack with the value in primary register * swap the top-of-stack with the value in primary register
*/ */
SC_FUNC void swap1(void) void swap1(void)
{ {
stgwrite("\tswap.pri\n"); stgwrite("\tswap.pri\n");
code_idx+=opcodes(1); code_idx+=opcodes(1);
@ -784,14 +784,14 @@ SC_FUNC void swap1(void)
* The case table is sorted on the comparison value. This allows more advanced * The case table is sorted on the comparison value. This allows more advanced
* abstract machines to sift the case table with a binary search. * abstract machines to sift the case table with a binary search.
*/ */
SC_FUNC void ffswitch(int label) void ffswitch(int label)
{ {
stgwrite("\tswitch "); stgwrite("\tswitch ");
outval(label,TRUE); /* the label is the address of the case table */ outval(label,TRUE); /* the label is the address of the case table */
code_idx+=opcodes(1)+opargs(1); code_idx+=opcodes(1)+opargs(1);
} }
SC_FUNC void ffcase(cell value,char *labelname,int newtable) void ffcase(cell value,char *labelname,int newtable)
{ {
if (newtable) { if (newtable) {
stgwrite("\tcasetbl\n"); stgwrite("\tcasetbl\n");
@ -808,7 +808,7 @@ SC_FUNC void ffcase(cell value,char *labelname,int newtable)
/* /*
* Call specified function * Call specified function
*/ */
SC_FUNC void ffcall(symbol *sym,const char *label,int numargs) void ffcall(symbol *sym,const char *label,int numargs)
{ {
char symname[2*sNAMEMAX+16]; char symname[2*sNAMEMAX+16];
char aliasname[sNAMEMAX+1]; char aliasname[sNAMEMAX+1];
@ -868,7 +868,7 @@ SC_FUNC void ffcall(symbol *sym,const char *label,int numargs)
* *
* Global references: funcstatus (referred to only) * Global references: funcstatus (referred to only)
*/ */
SC_FUNC void ffret(int remparams) void ffret(int remparams)
{ {
if (remparams) if (remparams)
stgwrite("\tretn\n"); stgwrite("\tretn\n");
@ -877,14 +877,14 @@ SC_FUNC void ffret(int remparams)
code_idx+=opcodes(1); code_idx+=opcodes(1);
} }
SC_FUNC void ffabort(int reason) void ffabort(int reason)
{ {
stgwrite("\thalt "); stgwrite("\thalt ");
outval(reason,TRUE); outval(reason,TRUE);
code_idx+=opcodes(1)+opargs(1); code_idx+=opcodes(1)+opargs(1);
} }
SC_FUNC void ffbounds(cell size) void ffbounds(cell size)
{ {
if ((sc_debug & sCHKBOUNDS)!=0) { if ((sc_debug & sCHKBOUNDS)!=0) {
stgwrite("\tbounds "); stgwrite("\tbounds ");
@ -896,7 +896,7 @@ SC_FUNC void ffbounds(cell size)
/* /*
* Jump to local label number (the number is converted to a name) * Jump to local label number (the number is converted to a name)
*/ */
SC_FUNC void jumplabel(int number) void jumplabel(int number)
{ {
stgwrite("\tjump "); stgwrite("\tjump ");
outval(number,TRUE); outval(number,TRUE);
@ -906,7 +906,7 @@ SC_FUNC void jumplabel(int number)
/* /*
* Define storage (global and static variables) * Define storage (global and static variables)
*/ */
SC_FUNC void defstorage(void) void defstorage(void)
{ {
stgwrite("dump "); stgwrite("dump ");
} }
@ -915,7 +915,7 @@ SC_FUNC void defstorage(void)
* Inclrement/decrement stack pointer. Note that this routine does * Inclrement/decrement stack pointer. Note that this routine does
* nothing if the delta is zero. * nothing if the delta is zero.
*/ */
SC_FUNC void modstk(int delta) void modstk(int delta)
{ {
if (delta) { if (delta) {
stgwrite("\tstack "); stgwrite("\tstack ");
@ -925,7 +925,7 @@ SC_FUNC void modstk(int delta)
} }
/* set the stack to a hard offset from the frame */ /* set the stack to a hard offset from the frame */
SC_FUNC void setstk(cell value) void setstk(cell value)
{ {
stgwrite("\tstackadjust "); stgwrite("\tstackadjust ");
assert(value<=0); /* STK should always become <= FRM */ assert(value<=0); /* STK should always become <= FRM */
@ -933,7 +933,7 @@ SC_FUNC void setstk(cell value)
code_idx+=opcodes(1)+opargs(1); code_idx+=opcodes(1)+opargs(1);
} }
SC_FUNC void modheap(int delta) void modheap(int delta)
{ {
if (delta) { if (delta) {
stgwrite("\theap "); stgwrite("\theap ");
@ -942,13 +942,13 @@ SC_FUNC void modheap(int delta)
} /* if */ } /* if */
} }
SC_FUNC void modheap_i() void modheap_i()
{ {
stgwrite("\ttracker.pop.setheap\n"); stgwrite("\ttracker.pop.setheap\n");
code_idx+=opcodes(1); code_idx+=opcodes(1);
} }
SC_FUNC void setheap_save(cell value) void setheap_save(cell value)
{ {
assert(value); assert(value);
stgwrite("\ttracker.push.c "); stgwrite("\ttracker.push.c ");
@ -956,7 +956,7 @@ SC_FUNC void setheap_save(cell value)
code_idx+=opcodes(1)+opargs(1); code_idx+=opcodes(1)+opargs(1);
} }
SC_FUNC void setheap_pri(void) void setheap_pri(void)
{ {
stgwrite("\theap "); /* ALT = HEA++ */ stgwrite("\theap "); /* ALT = HEA++ */
outval(sizeof(cell), TRUE); outval(sizeof(cell), TRUE);
@ -965,7 +965,7 @@ SC_FUNC void setheap_pri(void)
code_idx+=opcodes(3)+opargs(1); code_idx+=opcodes(3)+opargs(1);
} }
SC_FUNC void setheap(cell value) void setheap(cell value)
{ {
stgwrite("\tconst.pri "); /* load default value in PRI */ stgwrite("\tconst.pri "); /* load default value in PRI */
outval(value, TRUE); outval(value, TRUE);
@ -977,7 +977,7 @@ SC_FUNC void setheap(cell value)
* Convert a cell number to a "byte" address; i.e. double or quadruple * Convert a cell number to a "byte" address; i.e. double or quadruple
* the primary register. * the primary register.
*/ */
SC_FUNC void cell2addr(void) void cell2addr(void)
{ {
#if PAWN_CELL_SIZE==16 #if PAWN_CELL_SIZE==16
stgwrite("\tshl.c.pri 1\n"); stgwrite("\tshl.c.pri 1\n");
@ -994,7 +994,7 @@ SC_FUNC void cell2addr(void)
/* /*
* Double or quadruple the alternate register. * Double or quadruple the alternate register.
*/ */
SC_FUNC void cell2addr_alt(void) void cell2addr_alt(void)
{ {
#if PAWN_CELL_SIZE==16 #if PAWN_CELL_SIZE==16
stgwrite("\tshl.c.alt 1\n"); stgwrite("\tshl.c.alt 1\n");
@ -1013,7 +1013,7 @@ SC_FUNC void cell2addr_alt(void)
* Or convert a number of packed characters to the number of cells (with * Or convert a number of packed characters to the number of cells (with
* truncation). * truncation).
*/ */
SC_FUNC void addr2cell(void) void addr2cell(void)
{ {
#if PAWN_CELL_SIZE==16 #if PAWN_CELL_SIZE==16
stgwrite("\tshr.c.pri 1\n"); stgwrite("\tshr.c.pri 1\n");
@ -1030,7 +1030,7 @@ SC_FUNC void addr2cell(void)
/* Convert from character index to byte address. This routine does /* Convert from character index to byte address. This routine does
* nothing if a character has the size of a byte. * nothing if a character has the size of a byte.
*/ */
SC_FUNC void char2addr(void) void char2addr(void)
{ {
#if sCHARBITS==16 #if sCHARBITS==16
stgwrite("\tshl.c.pri 1\n"); stgwrite("\tshl.c.pri 1\n");
@ -1048,7 +1048,7 @@ SC_FUNC void char2addr(void)
* *
* NOTE: For Source Pawn, this is fliped. It will do nothing on Little-Endian. * NOTE: For Source Pawn, this is fliped. It will do nothing on Little-Endian.
*/ */
SC_FUNC void charalign(void) void charalign(void)
{ {
#if 0 /* TEMPORARILY DISABLED BECAUSE WE DON'T USE BIG ENDIAN */ #if 0 /* TEMPORARILY DISABLED BECAUSE WE DON'T USE BIG ENDIAN */
stgwrite("\talign.pri "); stgwrite("\talign.pri ");
@ -1060,7 +1060,7 @@ SC_FUNC void charalign(void)
/* /*
* Add a constant to the primary register. * Add a constant to the primary register.
*/ */
SC_FUNC void addconst(cell value) void addconst(cell value)
{ {
if (value!=0) { if (value!=0) {
stgwrite("\tadd.c "); stgwrite("\tadd.c ");
@ -1072,7 +1072,7 @@ SC_FUNC void addconst(cell value)
/* /*
* signed multiply of primary and secundairy registers (result in primary) * signed multiply of primary and secundairy registers (result in primary)
*/ */
SC_FUNC void os_mult(void) void os_mult(void)
{ {
stgwrite("\tsmul\n"); stgwrite("\tsmul\n");
code_idx+=opcodes(1); code_idx+=opcodes(1);
@ -1082,7 +1082,7 @@ SC_FUNC void os_mult(void)
* signed divide of alternate register by primary register (quotient in * signed divide of alternate register by primary register (quotient in
* primary; remainder in alternate) * primary; remainder in alternate)
*/ */
SC_FUNC void os_div(void) void os_div(void)
{ {
stgwrite("\tsdiv.alt\n"); stgwrite("\tsdiv.alt\n");
code_idx+=opcodes(1); code_idx+=opcodes(1);
@ -1091,7 +1091,7 @@ SC_FUNC void os_div(void)
/* /*
* modulus of (alternate % primary), result in primary (signed) * modulus of (alternate % primary), result in primary (signed)
*/ */
SC_FUNC void os_mod(void) void os_mod(void)
{ {
stgwrite("\tsdiv.alt\n"); stgwrite("\tsdiv.alt\n");
stgwrite("\tmove.pri\n"); /* move ALT to PRI */ stgwrite("\tmove.pri\n"); /* move ALT to PRI */
@ -1101,7 +1101,7 @@ SC_FUNC void os_mod(void)
/* /*
* Add primary and alternate registers (result in primary). * Add primary and alternate registers (result in primary).
*/ */
SC_FUNC void ob_add(void) void ob_add(void)
{ {
stgwrite("\tadd\n"); stgwrite("\tadd\n");
code_idx+=opcodes(1); code_idx+=opcodes(1);
@ -1110,7 +1110,7 @@ SC_FUNC void ob_add(void)
/* /*
* subtract primary register from alternate register (result in primary) * subtract primary register from alternate register (result in primary)
*/ */
SC_FUNC void ob_sub(void) void ob_sub(void)
{ {
stgwrite("\tsub.alt\n"); stgwrite("\tsub.alt\n");
code_idx+=opcodes(1); code_idx+=opcodes(1);
@ -1122,7 +1122,7 @@ SC_FUNC void ob_sub(void)
* There is no need for a "logical shift left" routine, since * There is no need for a "logical shift left" routine, since
* logical shift left is identical to arithmic shift left. * logical shift left is identical to arithmic shift left.
*/ */
SC_FUNC void ob_sal(void) void ob_sal(void)
{ {
stgwrite("\txchg\n"); stgwrite("\txchg\n");
stgwrite("\tshl\n"); stgwrite("\tshl\n");
@ -1133,7 +1133,7 @@ SC_FUNC void ob_sal(void)
* arithmic shift right alternate register the number of bits * arithmic shift right alternate register the number of bits
* given in the primary register (result in primary). * given in the primary register (result in primary).
*/ */
SC_FUNC void os_sar(void) void os_sar(void)
{ {
stgwrite("\txchg\n"); stgwrite("\txchg\n");
stgwrite("\tsshr\n"); stgwrite("\tsshr\n");
@ -1144,7 +1144,7 @@ SC_FUNC void os_sar(void)
* logical (unsigned) shift right of the alternate register by the * logical (unsigned) shift right of the alternate register by the
* number of bits given in the primary register (result in primary). * number of bits given in the primary register (result in primary).
*/ */
SC_FUNC void ou_sar(void) void ou_sar(void)
{ {
stgwrite("\txchg\n"); stgwrite("\txchg\n");
stgwrite("\tshr\n"); stgwrite("\tshr\n");
@ -1154,7 +1154,7 @@ SC_FUNC void ou_sar(void)
/* /*
* inclusive "or" of primary and alternate registers (result in primary) * inclusive "or" of primary and alternate registers (result in primary)
*/ */
SC_FUNC void ob_or(void) void ob_or(void)
{ {
stgwrite("\tor\n"); stgwrite("\tor\n");
code_idx+=opcodes(1); code_idx+=opcodes(1);
@ -1163,7 +1163,7 @@ SC_FUNC void ob_or(void)
/* /*
* "exclusive or" of primary and alternate registers (result in primary) * "exclusive or" of primary and alternate registers (result in primary)
*/ */
SC_FUNC void ob_xor(void) void ob_xor(void)
{ {
stgwrite("\txor\n"); stgwrite("\txor\n");
code_idx+=opcodes(1); code_idx+=opcodes(1);
@ -1172,7 +1172,7 @@ SC_FUNC void ob_xor(void)
/* /*
* "and" of primary and secundairy registers (result in primary) * "and" of primary and secundairy registers (result in primary)
*/ */
SC_FUNC void ob_and(void) void ob_and(void)
{ {
stgwrite("\tand\n"); stgwrite("\tand\n");
code_idx+=opcodes(1); code_idx+=opcodes(1);
@ -1181,7 +1181,7 @@ SC_FUNC void ob_and(void)
/* /*
* test ALT==PRI; result in primary register (1 or 0). * test ALT==PRI; result in primary register (1 or 0).
*/ */
SC_FUNC void ob_eq(void) void ob_eq(void)
{ {
stgwrite("\teq\n"); stgwrite("\teq\n");
code_idx+=opcodes(1); code_idx+=opcodes(1);
@ -1190,7 +1190,7 @@ SC_FUNC void ob_eq(void)
/* /*
* test ALT!=PRI * test ALT!=PRI
*/ */
SC_FUNC void ob_ne(void) void ob_ne(void)
{ {
stgwrite("\tneq\n"); stgwrite("\tneq\n");
code_idx+=opcodes(1); code_idx+=opcodes(1);
@ -1216,14 +1216,14 @@ SC_FUNC void ob_ne(void)
* stack and moves the value of ALT into PRI. If there is a next comparison, * stack and moves the value of ALT into PRI. If there is a next comparison,
* PRI can now serve as the "left" operand of the relational operator. * PRI can now serve as the "left" operand of the relational operator.
*/ */
SC_FUNC void relop_prefix(void) void relop_prefix(void)
{ {
stgwrite("\tpush.pri\n"); stgwrite("\tpush.pri\n");
stgwrite("\tmove.pri\n"); stgwrite("\tmove.pri\n");
code_idx+=opcodes(2); code_idx+=opcodes(2);
} }
SC_FUNC void relop_suffix(void) void relop_suffix(void)
{ {
stgwrite("\tswap.alt\n"); stgwrite("\tswap.alt\n");
stgwrite("\tand\n"); stgwrite("\tand\n");
@ -1234,7 +1234,7 @@ SC_FUNC void relop_suffix(void)
/* /*
* test ALT<PRI (signed) * test ALT<PRI (signed)
*/ */
SC_FUNC void os_lt(void) void os_lt(void)
{ {
stgwrite("\txchg\n"); stgwrite("\txchg\n");
stgwrite("\tsless\n"); stgwrite("\tsless\n");
@ -1244,7 +1244,7 @@ SC_FUNC void os_lt(void)
/* /*
* test ALT<=PRI (signed) * test ALT<=PRI (signed)
*/ */
SC_FUNC void os_le(void) void os_le(void)
{ {
stgwrite("\txchg\n"); stgwrite("\txchg\n");
stgwrite("\tsleq\n"); stgwrite("\tsleq\n");
@ -1254,7 +1254,7 @@ SC_FUNC void os_le(void)
/* /*
* test ALT>PRI (signed) * test ALT>PRI (signed)
*/ */
SC_FUNC void os_gt(void) void os_gt(void)
{ {
stgwrite("\txchg\n"); stgwrite("\txchg\n");
stgwrite("\tsgrtr\n"); stgwrite("\tsgrtr\n");
@ -1264,7 +1264,7 @@ SC_FUNC void os_gt(void)
/* /*
* test ALT>=PRI (signed) * test ALT>=PRI (signed)
*/ */
SC_FUNC void os_ge(void) void os_ge(void)
{ {
stgwrite("\txchg\n"); stgwrite("\txchg\n");
stgwrite("\tsgeq\n"); stgwrite("\tsgeq\n");
@ -1274,7 +1274,7 @@ SC_FUNC void os_ge(void)
/* /*
* logical negation of primary register * logical negation of primary register
*/ */
SC_FUNC void lneg(void) void lneg(void)
{ {
stgwrite("\tnot\n"); stgwrite("\tnot\n");
code_idx+=opcodes(1); code_idx+=opcodes(1);
@ -1283,7 +1283,7 @@ SC_FUNC void lneg(void)
/* /*
* two's complement primary register * two's complement primary register
*/ */
SC_FUNC void neg(void) void neg(void)
{ {
stgwrite("\tneg\n"); stgwrite("\tneg\n");
code_idx+=opcodes(1); code_idx+=opcodes(1);
@ -1292,7 +1292,7 @@ SC_FUNC void neg(void)
/* /*
* one's complement of primary register * one's complement of primary register
*/ */
SC_FUNC void invert(void) void invert(void)
{ {
stgwrite("\tinvert\n"); stgwrite("\tinvert\n");
code_idx+=opcodes(1); code_idx+=opcodes(1);
@ -1301,19 +1301,19 @@ SC_FUNC void invert(void)
/* /*
* nop * nop
*/ */
SC_FUNC void nooperation(void) void nooperation(void)
{ {
stgwrite("\tnop\n"); stgwrite("\tnop\n");
code_idx+=opcodes(1); code_idx+=opcodes(1);
} }
SC_FUNC void inc_pri() void inc_pri()
{ {
stgwrite("\tinc.pri\n"); stgwrite("\tinc.pri\n");
code_idx+=opcodes(1); code_idx+=opcodes(1);
} }
SC_FUNC void dec_pri() void dec_pri()
{ {
stgwrite("\tdec.pri\n"); stgwrite("\tdec.pri\n");
code_idx+=opcodes(1); code_idx+=opcodes(1);
@ -1321,7 +1321,7 @@ SC_FUNC void dec_pri()
/* increment symbol /* increment symbol
*/ */
SC_FUNC void inc(value *lval) void inc(value *lval)
{ {
symbol *sym; symbol *sym;
@ -1379,7 +1379,7 @@ SC_FUNC void inc(value *lval)
* *
* in case of an integer pointer, the symbol must be incremented by 2. * in case of an integer pointer, the symbol must be incremented by 2.
*/ */
SC_FUNC void dec(value *lval) void dec(value *lval)
{ {
symbol *sym; symbol *sym;
@ -1436,7 +1436,7 @@ SC_FUNC void dec(value *lval)
/* /*
* Jumps to "label" if PRI != 0 * Jumps to "label" if PRI != 0
*/ */
SC_FUNC void jmp_ne0(int number) void jmp_ne0(int number)
{ {
stgwrite("\tjnz "); stgwrite("\tjnz ");
outval(number,TRUE); outval(number,TRUE);
@ -1446,7 +1446,7 @@ SC_FUNC void jmp_ne0(int number)
/* /*
* Jumps to "label" if PRI == 0 * Jumps to "label" if PRI == 0
*/ */
SC_FUNC void jmp_eq0(int number) void jmp_eq0(int number)
{ {
stgwrite("\tjzer "); stgwrite("\tjzer ");
outval(number,TRUE); outval(number,TRUE);
@ -1454,14 +1454,14 @@ SC_FUNC void jmp_eq0(int number)
} }
/* write a value in hexadecimal; optionally adds a newline */ /* write a value in hexadecimal; optionally adds a newline */
SC_FUNC void outval(cell val,int newline) void outval(cell val,int newline)
{ {
stgwrite(itoh(val)); stgwrite(itoh(val));
if (newline) if (newline)
stgwrite("\n"); stgwrite("\n");
} }
SC_FUNC void invoke_getter(methodmap_method_t *method) void invoke_getter(methodmap_method_t *method)
{ {
if (!method->getter) { if (!method->getter) {
error(149, method->name); error(149, method->name);
@ -1479,7 +1479,7 @@ SC_FUNC void invoke_getter(methodmap_method_t *method)
markusage(method->getter, uREAD); markusage(method->getter, uREAD);
} }
SC_FUNC void invoke_setter(methodmap_method_t *method, int save) void invoke_setter(methodmap_method_t *method, int save)
{ {
if (!method->setter) { if (!method->setter) {
error(152, method->name); error(152, method->name);

View File

@ -21,7 +21,7 @@
* Version: $Id$ * Version: $Id$
*/ */
SC_FUNC int strexpand(char *dest, unsigned char *source, int maxlen, unsigned char pairtable[128][2]); int strexpand(char *dest, unsigned char *source, int maxlen, unsigned char pairtable[128][2]);
#ifndef SCPACK #ifndef SCPACK
# define SCPACK # define SCPACK

View File

@ -67,7 +67,7 @@ static int sErrLine; /* forced line number for the error message */
* fcurrent (reffered to only) * fcurrent (reffered to only)
* errflag (altered) * errflag (altered)
*/ */
SC_FUNC int error(int number,...) int error(int number,...)
{ {
static const char *prefix[3]={ "error", "fatal error", "warning" }; static const char *prefix[3]={ "error", "fatal error", "warning" };
static int lastline,errorcount; static int lastline,errorcount;
@ -172,7 +172,7 @@ static short lastfile;
return 0; return 0;
} }
SC_FUNC void errorset(int code,int line) void errorset(int code,int line)
{ {
switch (code) { switch (code) {
case sRESET: case sRESET:

View File

@ -659,7 +659,7 @@ static int findopcode(char *instr,int maxlen)
return 0; /* not found, return special index */ return 0; /* not found, return special index */
} }
SC_FUNC int assemble(void *fout, void *fin) int assemble(void *fout, void *fin)
{ {
AMX_HEADER hdr; AMX_HEADER hdr;
AMX_FUNCSTUBNT func; AMX_FUNCSTUBNT func;

View File

@ -22,7 +22,7 @@
* Version: $Id$ * Version: $Id$
*/ */
SC_FUNC int strexpand(char *dest, unsigned char *source, int maxlen, unsigned char pairtable[128][2]); int strexpand(char *dest, unsigned char *source, int maxlen, unsigned char pairtable[128][2]);
#define SCPACK_TERMINATOR , /* end each section with a comma */ #define SCPACK_TERMINATOR , /* end each section with a comma */

View File

@ -108,7 +108,7 @@ static void grow_stgbuffer(char **buffer, int *curmax, int requiredsize)
**buffer='\0'; **buffer='\0';
} }
SC_FUNC void stgbuffer_cleanup(void) void stgbuffer_cleanup(void)
{ {
if (stgbuf!=NULL) { if (stgbuf!=NULL) {
free(stgbuf); free(stgbuf);
@ -141,7 +141,7 @@ SC_FUNC void stgbuffer_cleanup(void)
* stgbuf (altered) * stgbuf (altered)
* staging (referred to only) * staging (referred to only)
*/ */
SC_FUNC void stgmark(char mark) void stgmark(char mark)
{ {
if (staging) { if (staging) {
CHECK_STGBUFFER(stgidx); CHECK_STGBUFFER(stgidx);
@ -188,7 +188,7 @@ static int filewrite(char *str)
* stgbuf (altered) * stgbuf (altered)
* staging (referred to only) * staging (referred to only)
*/ */
SC_FUNC void stgwrite(const char *st) void stgwrite(const char *st)
{ {
int len; int len;
@ -224,7 +224,7 @@ SC_FUNC void stgwrite(const char *st)
* stgbuf (referred to only) * stgbuf (referred to only)
* staging (referred to only) * staging (referred to only)
*/ */
SC_FUNC void stgout(int index) void stgout(int index)
{ {
int reordered=0; int reordered=0;
int idx; int idx;
@ -348,7 +348,7 @@ static int stgstring(char *start,char *end)
* Global references: stgidx (altered) * Global references: stgidx (altered)
* staging (reffered to only) * staging (reffered to only)
*/ */
SC_FUNC void stgdel(int index,cell code_index) void stgdel(int index,cell code_index)
{ {
if (staging) { if (staging) {
stgidx=index; stgidx=index;
@ -356,7 +356,7 @@ SC_FUNC void stgdel(int index,cell code_index)
} /* if */ } /* if */
} }
SC_FUNC int stgget(int *index,cell *code_index) int stgget(int *index,cell *code_index)
{ {
if (staging) { if (staging) {
*index=stgidx; *index=stgidx;
@ -375,7 +375,7 @@ SC_FUNC int stgget(int *index,cell *code_index)
* stgidx (altered) * stgidx (altered)
* stgbuf (contents altered) * stgbuf (contents altered)
*/ */
SC_FUNC void stgset(int onoff) void stgset(int onoff)
{ {
staging=onoff; staging=onoff;
if (staging){ if (staging){
@ -398,7 +398,7 @@ SC_FUNC void stgset(int onoff)
*/ */
static SEQUENCE *sequences; static SEQUENCE *sequences;
SC_FUNC int phopt_init(void) int phopt_init(void)
{ {
int number, i, len; int number, i, len;
char str[160]; char str[160];
@ -440,7 +440,7 @@ SC_FUNC int phopt_init(void)
return TRUE; return TRUE;
} }
SC_FUNC int phopt_cleanup(void) int phopt_cleanup(void)
{ {
int i; int i;
if (sequences!=NULL) { if (sequences!=NULL) {

View File

@ -16,7 +16,7 @@
#define STACKSIZE 16 #define STACKSIZE 16
SC_FUNC int strexpand(char *dest, unsigned char *source, int maxlen, unsigned char pairtable[128][2]) int strexpand(char *dest, unsigned char *source, int maxlen, unsigned char pairtable[128][2])
{ {
unsigned char stack[STACKSIZE]; unsigned char stack[STACKSIZE];
short c, top = 0; short c, top = 0;

View File

@ -113,7 +113,7 @@ static int cp_readline(FILE *fp,char *string,size_t size)
* codepages are most conveniently stored in a subdirectory of this home * codepages are most conveniently stored in a subdirectory of this home
* directory. * directory.
*/ */
SC_FUNC int cp_path(const char *root, const char *directory) int cp_path(const char *root, const char *directory)
{ {
size_t len1,len2; size_t len1,len2;
int add_slash1,add_slash2; int add_slash1,add_slash2;
@ -154,7 +154,7 @@ SC_FUNC int cp_path(const char *root, const char *directory)
* <cprootpath>/cp<name> * <cprootpath>/cp<name>
* <cprootpath>/cp<name>.txt * <cprootpath>/cp<name>.txt
*/ */
SC_FUNC int cp_set(const char *name) int cp_set(const char *name)
{ {
char filename[_MAX_PATH]; char filename[_MAX_PATH];
FILE *fp=NULL; FILE *fp=NULL;
@ -277,7 +277,7 @@ SC_FUNC int cp_set(const char *name)
return TRUE; return TRUE;
} }
SC_FUNC cell cp_translate(const unsigned char *string,const unsigned char **endptr) cell cp_translate(const unsigned char *string,const unsigned char **endptr)
{ {
wchar_t result; wchar_t result;
@ -312,7 +312,7 @@ SC_FUNC cell cp_translate(const unsigned char *string,const unsigned char **endp
#endif /* NO_CODEPAGE */ #endif /* NO_CODEPAGE */
#if !defined NO_UTF8 #if !defined NO_UTF8
SC_FUNC cell get_utf8_char(const unsigned char *string,const unsigned char **endptr) cell get_utf8_char(const unsigned char *string,const unsigned char **endptr)
{ {
int follow=0; int follow=0;
long lowmark=0; long lowmark=0;
@ -391,7 +391,7 @@ SC_FUNC cell get_utf8_char(const unsigned char *string,const unsigned char **end
} }
#endif #endif
SC_FUNC int scan_utf8(void *fp,const char *filename) int scan_utf8(void *fp,const char *filename)
{ {
#if defined NO_UTF8 #if defined NO_UTF8
return 0; return 0;

View File

@ -41,7 +41,7 @@
* to other memory allocators becomes easier. * to other memory allocators becomes easier.
* By Søren Hannibal. * By Søren Hannibal.
*/ */
SC_FUNC char* duplicatestring(const char* sourcestring) char* duplicatestring(const char* sourcestring)
{ {
char* result=(char*)malloc(strlen(sourcestring)+1); char* result=(char*)malloc(strlen(sourcestring)+1);
strcpy(result,sourcestring); strcpy(result,sourcestring);
@ -190,7 +190,7 @@ static int delete_string(stringlist *root,int index)
return FALSE; return FALSE;
} }
SC_FUNC void delete_stringtable(stringlist *root) void delete_stringtable(stringlist *root)
{ {
stringlist *cur,*next; stringlist *cur,*next;
@ -210,7 +210,7 @@ SC_FUNC void delete_stringtable(stringlist *root)
/* ----- alias table --------------------------------------------- */ /* ----- alias table --------------------------------------------- */
static stringpair alias_tab = {NULL, NULL, NULL}; /* alias table */ static stringpair alias_tab = {NULL, NULL, NULL}; /* alias table */
SC_FUNC stringpair *insert_alias(char *name,char *alias) stringpair *insert_alias(char *name,char *alias)
{ {
stringpair *cur; stringpair *cur;
@ -223,7 +223,7 @@ SC_FUNC stringpair *insert_alias(char *name,char *alias)
return cur; return cur;
} }
SC_FUNC int lookup_alias(char *target,char *name) int lookup_alias(char *target,char *name)
{ {
stringpair *cur=find_stringpair(alias_tab.next,name,strlen(name)); stringpair *cur=find_stringpair(alias_tab.next,name,strlen(name));
if (cur!=NULL) { if (cur!=NULL) {
@ -233,7 +233,7 @@ SC_FUNC int lookup_alias(char *target,char *name)
return cur!=NULL; return cur!=NULL;
} }
SC_FUNC void delete_aliastable(void) void delete_aliastable(void)
{ {
delete_stringpairtable(&alias_tab); delete_stringpairtable(&alias_tab);
} }
@ -241,17 +241,17 @@ SC_FUNC void delete_aliastable(void)
/* ----- include paths list -------------------------------------- */ /* ----- include paths list -------------------------------------- */
static stringlist includepaths; /* directory list for include files */ static stringlist includepaths; /* directory list for include files */
SC_FUNC stringlist *insert_path(char *path) stringlist *insert_path(char *path)
{ {
return insert_string(&includepaths,path); return insert_string(&includepaths,path);
} }
SC_FUNC char *get_path(int index) char *get_path(int index)
{ {
return get_string(&includepaths,index); return get_string(&includepaths,index);
} }
SC_FUNC void delete_pathtable(void) void delete_pathtable(void)
{ {
delete_stringtable(&includepaths); delete_stringtable(&includepaths);
assert(includepaths.next==NULL); assert(includepaths.next==NULL);
@ -275,7 +275,7 @@ static void adjustindex(char c)
substindex[(int)c-PUBLIC_CHAR]=cur; substindex[(int)c-PUBLIC_CHAR]=cur;
} }
SC_FUNC stringpair *insert_subst(const char *pattern,const char *substitution,int prefixlen) stringpair *insert_subst(const char *pattern,const char *substitution,int prefixlen)
{ {
stringpair *cur; stringpair *cur;
@ -306,7 +306,7 @@ SC_FUNC stringpair *insert_subst(const char *pattern,const char *substitution,in
return cur; return cur;
} }
SC_FUNC stringpair *find_subst(char *name,int length) stringpair *find_subst(char *name,int length)
{ {
stringpair *item; stringpair *item;
assert(name!=NULL); assert(name!=NULL);
@ -336,7 +336,7 @@ SC_FUNC stringpair *find_subst(char *name,int length)
return item; return item;
} }
SC_FUNC int delete_subst(char *name,int length) int delete_subst(char *name,int length)
{ {
stringpair *item; stringpair *item;
assert(name!=NULL); assert(name!=NULL);
@ -357,7 +357,7 @@ SC_FUNC int delete_subst(char *name,int length)
return TRUE; return TRUE;
} }
SC_FUNC void delete_substtable(void) void delete_substtable(void)
{ {
int i; int i;
delete_stringpairtable(&substpair); delete_stringpairtable(&substpair);
@ -371,17 +371,17 @@ SC_FUNC void delete_substtable(void)
/* ----- input file list ----------------------------------------- */ /* ----- input file list ----------------------------------------- */
static stringlist sourcefiles; static stringlist sourcefiles;
SC_FUNC stringlist *insert_sourcefile(char *string) stringlist *insert_sourcefile(char *string)
{ {
return insert_string(&sourcefiles,string); return insert_string(&sourcefiles,string);
} }
SC_FUNC char *get_sourcefile(int index) char *get_sourcefile(int index)
{ {
return get_string(&sourcefiles,index); return get_string(&sourcefiles,index);
} }
SC_FUNC void delete_sourcefiletable(void) void delete_sourcefiletable(void)
{ {
delete_stringtable(&sourcefiles); delete_stringtable(&sourcefiles);
assert(sourcefiles.next==NULL); assert(sourcefiles.next==NULL);
@ -392,22 +392,22 @@ SC_FUNC void delete_sourcefiletable(void)
#if !defined SC_LIGHT #if !defined SC_LIGHT
static stringlist docstrings; static stringlist docstrings;
SC_FUNC stringlist *insert_docstring(char *string) stringlist *insert_docstring(char *string)
{ {
return insert_string(&docstrings,string); return insert_string(&docstrings,string);
} }
SC_FUNC char *get_docstring(int index) char *get_docstring(int index)
{ {
return get_string(&docstrings,index); return get_string(&docstrings,index);
} }
SC_FUNC void delete_docstring(int index) void delete_docstring(int index)
{ {
delete_string(&docstrings,index); delete_string(&docstrings,index);
} }
SC_FUNC void delete_docstringtable(void) void delete_docstringtable(void)
{ {
delete_stringtable(&docstrings); delete_stringtable(&docstrings);
assert(docstrings.next==NULL); assert(docstrings.next==NULL);
@ -418,17 +418,17 @@ SC_FUNC void delete_docstringtable(void)
/* ----- autolisting --------------------------------------------- */ /* ----- autolisting --------------------------------------------- */
static stringlist autolist; static stringlist autolist;
SC_FUNC stringlist *insert_autolist(const char *string) stringlist *insert_autolist(const char *string)
{ {
return insert_string(&autolist,string); return insert_string(&autolist,string);
} }
SC_FUNC char *get_autolist(int index) char *get_autolist(int index)
{ {
return get_string(&autolist,index); return get_string(&autolist,index);
} }
SC_FUNC void delete_autolisttable(void) void delete_autolisttable(void)
{ {
delete_stringtable(&autolist); delete_stringtable(&autolist);
assert(autolist.next==NULL); assert(autolist.next==NULL);
@ -464,7 +464,7 @@ SC_FUNC void delete_autolisttable(void)
static stringlist dbgstrings; static stringlist dbgstrings;
SC_FUNC stringlist *insert_dbgfile(const char *filename) stringlist *insert_dbgfile(const char *filename)
{ {
if (sc_status==statWRITE && (sc_debug & sSYMBOLIC)!=0) { if (sc_status==statWRITE && (sc_debug & sSYMBOLIC)!=0) {
@ -477,7 +477,7 @@ SC_FUNC stringlist *insert_dbgfile(const char *filename)
return NULL; return NULL;
} }
SC_FUNC stringlist *insert_dbgline(int linenr) stringlist *insert_dbgline(int linenr)
{ {
if (sc_status==statWRITE && (sc_debug & sSYMBOLIC)!=0) { if (sc_status==statWRITE && (sc_debug & sSYMBOLIC)!=0) {
char string[40]; char string[40];
@ -489,7 +489,7 @@ SC_FUNC stringlist *insert_dbgline(int linenr)
return NULL; return NULL;
} }
SC_FUNC stringlist *insert_dbgsymbol(symbol *sym) stringlist *insert_dbgsymbol(symbol *sym)
{ {
if (sc_status==statWRITE && (sc_debug & sSYMBOLIC)!=0) { if (sc_status==statWRITE && (sc_debug & sSYMBOLIC)!=0) {
char string[2*sNAMEMAX+128]; char string[2*sNAMEMAX+128];
@ -522,17 +522,17 @@ SC_FUNC stringlist *insert_dbgsymbol(symbol *sym)
return NULL; return NULL;
} }
SC_FUNC stringlist *get_dbgstrings() stringlist *get_dbgstrings()
{ {
return &dbgstrings; return &dbgstrings;
} }
SC_FUNC char *get_dbgstring(int index) char *get_dbgstring(int index)
{ {
return get_string(&dbgstrings,index); return get_string(&dbgstrings,index);
} }
SC_FUNC void delete_dbgstringtable(void) void delete_dbgstringtable(void)
{ {
delete_stringtable(&dbgstrings); delete_stringtable(&dbgstrings);
assert(dbgstrings.next==NULL); assert(dbgstrings.next==NULL);

View File

@ -87,7 +87,7 @@ static constvalue *find_automaton(const char *name,int *last)
return NULL; return NULL;
} }
SC_FUNC constvalue *automaton_add(const char *name) constvalue *automaton_add(const char *name)
{ {
constvalue *ptr; constvalue *ptr;
int last; int last;
@ -101,13 +101,13 @@ SC_FUNC constvalue *automaton_add(const char *name)
return ptr; return ptr;
} }
SC_FUNC constvalue *automaton_find(const char *name) constvalue *automaton_find(const char *name)
{ {
int last; int last;
return find_automaton(name,&last); return find_automaton(name,&last);
} }
SC_FUNC constvalue *automaton_findid(int id) constvalue *automaton_findid(int id)
{ {
constvalue *ptr; constvalue *ptr;
for (ptr=sc_automaton_tab.next; ptr!=NULL && ptr->index!=id; ptr=ptr->next) for (ptr=sc_automaton_tab.next; ptr!=NULL && ptr->index!=id; ptr=ptr->next)
@ -135,7 +135,7 @@ static constvalue *find_state(const char *name,int fsa,int *last)
return NULL; return NULL;
} }
SC_FUNC constvalue *state_add(const char *name,int fsa) constvalue *state_add(const char *name,int fsa)
{ {
constvalue *ptr; constvalue *ptr;
int last; int last;
@ -149,13 +149,13 @@ SC_FUNC constvalue *state_add(const char *name,int fsa)
return ptr; return ptr;
} }
SC_FUNC constvalue *state_find(const char *name,int fsa_id) constvalue *state_find(const char *name,int fsa_id)
{ {
int last; /* dummy */ int last; /* dummy */
return find_state(name,fsa_id,&last); return find_state(name,fsa_id,&last);
} }
SC_FUNC constvalue *state_findid(int id) constvalue *state_findid(int id)
{ {
constvalue *ptr; constvalue *ptr;
for (ptr=sc_state_tab.next; ptr!=NULL && ptr->value!=id; ptr=ptr->next) for (ptr=sc_state_tab.next; ptr!=NULL && ptr->value!=id; ptr=ptr->next)
@ -163,7 +163,7 @@ SC_FUNC constvalue *state_findid(int id)
return ptr; return ptr;
} }
SC_FUNC void state_buildlist(int **list,int *listsize,int *count,int stateid) void state_buildlist(int **list,int *listsize,int *count,int stateid)
{ {
int idx; int idx;
@ -227,7 +227,7 @@ static statelist *state_getlist_ptr(int listid)
return ptr; return ptr;
} }
SC_FUNC int state_addlist(int *list,int count,int fsa) int state_addlist(int *list,int count,int fsa)
{ {
statelist *ptr; statelist *ptr;
int last; int last;
@ -253,7 +253,7 @@ SC_FUNC int state_addlist(int *list,int count,int fsa)
return ptr->listid; return ptr->listid;
} }
SC_FUNC void state_deletetable(void) void state_deletetable(void)
{ {
statelist *ptr; statelist *ptr;
@ -268,7 +268,7 @@ SC_FUNC void state_deletetable(void)
} /* while */ } /* while */
} }
SC_FUNC int state_getfsa(int listid) int state_getfsa(int listid)
{ {
statelist *ptr; statelist *ptr;
@ -280,7 +280,7 @@ SC_FUNC int state_getfsa(int listid)
return (ptr!=NULL) ? ptr->fsa : -1; /* fsa 0 exists */ return (ptr!=NULL) ? ptr->fsa : -1; /* fsa 0 exists */
} }
SC_FUNC int state_count(int listid) int state_count(int listid)
{ {
statelist *ptr=state_getlist_ptr(listid); statelist *ptr=state_getlist_ptr(listid);
if (ptr==NULL) if (ptr==NULL)
@ -288,7 +288,7 @@ SC_FUNC int state_count(int listid)
return ptr->numstates; return ptr->numstates;
} }
SC_FUNC int state_inlist(int listid,int state) int state_inlist(int listid,int state)
{ {
statelist *ptr; statelist *ptr;
int i; int i;
@ -302,7 +302,7 @@ SC_FUNC int state_inlist(int listid,int state)
return FALSE; return FALSE;
} }
SC_FUNC int state_listitem(int listid,int index) int state_listitem(int listid,int index)
{ {
statelist *ptr; statelist *ptr;
@ -329,7 +329,7 @@ static int checkconflict(statelist *psrc,statelist *ptgt)
* of a symbol exists in any other statelist id's of the same function; it also * of a symbol exists in any other statelist id's of the same function; it also
* verifies that all definitions of the symbol are in the same automaton. * verifies that all definitions of the symbol are in the same automaton.
*/ */
SC_FUNC void state_conflict(symbol *root) void state_conflict(symbol *root)
{ {
statelist *psrc,*ptgt; statelist *psrc,*ptgt;
constvalue *srcptr,*tgtptr; constvalue *srcptr,*tgtptr;
@ -363,7 +363,7 @@ SC_FUNC void state_conflict(symbol *root)
/* check whether the two state lists (whose ids are passed in) share any /* check whether the two state lists (whose ids are passed in) share any
* states * states
*/ */
SC_FUNC int state_conflict_id(int listid1,int listid2) int state_conflict_id(int listid1,int listid2)
{ {
statelist *psrc,*ptgt; statelist *psrc,*ptgt;

View File

@ -32,82 +32,82 @@
* All global variables that are shared amongst the compiler files are * All global variables that are shared amongst the compiler files are
* declared here. * declared here.
*/ */
SC_VDEFINE symbol loctab; /* local symbol table */ symbol loctab; /* local symbol table */
SC_VDEFINE symbol glbtab; /* global symbol table */ symbol glbtab; /* global symbol table */
SC_VDEFINE cell *litq; /* the literal queue */ cell *litq; /* the literal queue */
SC_VDEFINE unsigned char pline[sLINEMAX+1]; /* the line read from the input file */ unsigned char pline[sLINEMAX+1]; /* the line read from the input file */
SC_VDEFINE const unsigned char *lptr; /* points to the current position in "pline" */ const unsigned char *lptr; /* points to the current position in "pline" */
SC_VDEFINE constvalue tagname_tab = { NULL, "", 0, 0}; /* tagname table */ constvalue tagname_tab = { NULL, "", 0, 0}; /* tagname table */
SC_VDEFINE constvalue libname_tab = { NULL, "", 0, 0}; /* library table (#pragma library "..." syntax) */ constvalue libname_tab = { NULL, "", 0, 0}; /* library table (#pragma library "..." syntax) */
SC_VDEFINE constvalue *curlibrary = NULL; /* current library */ constvalue *curlibrary = NULL; /* current library */
SC_VDEFINE int pc_addlibtable = TRUE; /* is the library table added to the AMX file? */ int pc_addlibtable = TRUE; /* is the library table added to the AMX file? */
SC_VDEFINE symbol *curfunc; /* pointer to current function */ symbol *curfunc; /* pointer to current function */
SC_VDEFINE char *inpfname; /* pointer to name of the file currently read from */ char *inpfname; /* pointer to name of the file currently read from */
SC_VDEFINE char outfname[_MAX_PATH]; /* intermediate (assembler) file name */ char outfname[_MAX_PATH]; /* intermediate (assembler) file name */
SC_VDEFINE char binfname[_MAX_PATH]; /* binary file name */ char binfname[_MAX_PATH]; /* binary file name */
SC_VDEFINE char errfname[_MAX_PATH]; /* error file name */ char errfname[_MAX_PATH]; /* error file name */
SC_VDEFINE char sc_ctrlchar = CTRL_CHAR; /* the control character (or escape character)*/ char sc_ctrlchar = CTRL_CHAR; /* the control character (or escape character)*/
SC_VDEFINE char sc_ctrlchar_org = CTRL_CHAR;/* the default control character */ char sc_ctrlchar_org = CTRL_CHAR;/* the default control character */
SC_VDEFINE int litidx = 0; /* index to literal table */ int litidx = 0; /* index to literal table */
SC_VDEFINE int litmax = sDEF_LITMAX; /* current size of the literal table */ int litmax = sDEF_LITMAX; /* current size of the literal table */
SC_VDEFINE int stgidx = 0; /* index to the staging buffer */ int stgidx = 0; /* index to the staging buffer */
SC_VDEFINE int sc_labnum = 0; /* number of (internal) labels */ int sc_labnum = 0; /* number of (internal) labels */
SC_VDEFINE int staging = 0; /* true if staging output */ int staging = 0; /* true if staging output */
SC_VDEFINE cell declared = 0; /* number of local cells declared */ cell declared = 0; /* number of local cells declared */
SC_VDEFINE cell glb_declared=0; /* number of global cells declared */ cell glb_declared=0; /* number of global cells declared */
SC_VDEFINE cell code_idx = 0; /* number of bytes with generated code */ cell code_idx = 0; /* number of bytes with generated code */
SC_VDEFINE int ntv_funcid= 0; /* incremental number of native function */ int ntv_funcid= 0; /* incremental number of native function */
SC_VDEFINE int errnum = 0; /* number of errors */ int errnum = 0; /* number of errors */
SC_VDEFINE int warnnum = 0; /* number of warnings */ int warnnum = 0; /* number of warnings */
SC_VDEFINE int sc_debug = sCHKBOUNDS; /* by default: bounds checking+assertions */ int sc_debug = sCHKBOUNDS; /* by default: bounds checking+assertions */
SC_VDEFINE int sc_packstr= FALSE; /* strings are packed by default? */ int sc_packstr= FALSE; /* strings are packed by default? */
SC_VDEFINE int sc_asmfile= FALSE; /* create .ASM file? */ int sc_asmfile= FALSE; /* create .ASM file? */
SC_VDEFINE int sc_listing= FALSE; /* create .LST file? */ int sc_listing= FALSE; /* create .LST file? */
SC_VDEFINE int sc_compress=TRUE; /* compress bytecode? */ int sc_compress=TRUE; /* compress bytecode? */
SC_VDEFINE int sc_needsemicolon=TRUE;/* semicolon required to terminate expressions? */ int sc_needsemicolon=TRUE;/* semicolon required to terminate expressions? */
SC_VDEFINE int sc_dataalign=sizeof(cell);/* data alignment value */ int sc_dataalign=sizeof(cell);/* data alignment value */
SC_VDEFINE int sc_alignnext=FALSE; /* must frame of the next function be aligned? */ int sc_alignnext=FALSE; /* must frame of the next function be aligned? */
SC_VDEFINE int pc_docexpr=FALSE; /* must expression be attached to documentation comment? */ int pc_docexpr=FALSE; /* must expression be attached to documentation comment? */
SC_VDEFINE int curseg = 0; /* 1 if currently parsing CODE, 2 if parsing DATA */ int curseg = 0; /* 1 if currently parsing CODE, 2 if parsing DATA */
SC_VDEFINE cell pc_stksize=sDEF_AMXSTACK;/* default stack size */ cell pc_stksize=sDEF_AMXSTACK;/* default stack size */
SC_VDEFINE cell pc_amxlimit=0; /* default abstract machine size limit = none */ cell pc_amxlimit=0; /* default abstract machine size limit = none */
SC_VDEFINE cell pc_amxram=0; /* default abstract machine data size limit = none */ cell pc_amxram=0; /* default abstract machine data size limit = none */
SC_VDEFINE int freading = FALSE; /* Is there an input file ready for reading? */ int freading = FALSE; /* Is there an input file ready for reading? */
SC_VDEFINE int fline = 0; /* the line number in the current file */ int fline = 0; /* the line number in the current file */
SC_VDEFINE short fnumber = 0; /* the file number in the file table (debugging) */ short fnumber = 0; /* the file number in the file table (debugging) */
SC_VDEFINE short fcurrent= 0; /* current file being processed (debugging) */ short fcurrent= 0; /* current file being processed (debugging) */
SC_VDEFINE short sc_intest=FALSE; /* true if inside a test */ short sc_intest=FALSE; /* true if inside a test */
SC_VDEFINE int sideeffect= 0; /* true if an expression causes a side-effect */ int sideeffect= 0; /* true if an expression causes a side-effect */
SC_VDEFINE int stmtindent= 0; /* current indent of the statement */ int stmtindent= 0; /* current indent of the statement */
SC_VDEFINE int indent_nowarn=FALSE;/* skip warning "217 loose indentation" */ int indent_nowarn=FALSE;/* skip warning "217 loose indentation" */
SC_VDEFINE int sc_tabsize=8; /* number of spaces that a TAB represents */ int sc_tabsize=8; /* number of spaces that a TAB represents */
SC_VDEFINE short sc_allowtags=TRUE; /* allow/detect tagnames in lex() */ short sc_allowtags=TRUE; /* allow/detect tagnames in lex() */
SC_VDEFINE int sc_status; /* read/write status */ int sc_status; /* read/write status */
SC_VDEFINE int sc_err_status; int sc_err_status;
SC_VDEFINE int sc_rationaltag=0; /* tag for rational numbers */ int sc_rationaltag=0; /* tag for rational numbers */
SC_VDEFINE int rational_digits=0; /* number of fractional digits */ int rational_digits=0; /* number of fractional digits */
SC_VDEFINE int sc_allowproccall=0; /* allow/detect tagnames in lex() */ int sc_allowproccall=0; /* allow/detect tagnames in lex() */
SC_VDEFINE short sc_is_utf8=FALSE; /* is this source file in UTF-8 encoding */ short sc_is_utf8=FALSE; /* is this source file in UTF-8 encoding */
SC_VDEFINE char *pc_deprecate=NULL;/* if non-null, mark next declaration as deprecated */ char *pc_deprecate=NULL;/* if non-null, mark next declaration as deprecated */
SC_VDEFINE int sc_curstates=0; /* ID of the current state list */ int sc_curstates=0; /* ID of the current state list */
SC_VDEFINE int pc_optimize=sOPTIMIZE_NOMACRO; /* (peephole) optimization level */ int pc_optimize=sOPTIMIZE_NOMACRO; /* (peephole) optimization level */
SC_VDEFINE int pc_memflags=0; /* special flags for the stack/heap usage */ int pc_memflags=0; /* special flags for the stack/heap usage */
SC_VDEFINE int sc_showincludes=0; /* show include files */ int sc_showincludes=0; /* show include files */
SC_VDEFINE int sc_require_newdecls=0; /* Require new-style declarations */ int sc_require_newdecls=0; /* Require new-style declarations */
SC_VDEFINE constvalue sc_automaton_tab = { NULL, "", 0, 0}; /* automaton table */ constvalue sc_automaton_tab = { NULL, "", 0, 0}; /* automaton table */
SC_VDEFINE constvalue sc_state_tab = { NULL, "", 0, 0}; /* state table */ constvalue sc_state_tab = { NULL, "", 0, 0}; /* state table */
SC_VDEFINE void *inpf = NULL; /* file read from (source or include) */ void *inpf = NULL; /* file read from (source or include) */
SC_VDEFINE void *inpf_org= NULL; /* main source file */ void *inpf_org= NULL; /* main source file */
SC_VDEFINE void *outf = NULL; /* (intermediate) text file written to */ void *outf = NULL; /* (intermediate) text file written to */
SC_VDEFINE jmp_buf errbuf; jmp_buf errbuf;
SC_VDEFINE HashTable *sp_Globals = NULL; HashTable *sp_Globals = NULL;
#if !defined SC_LIGHT #if !defined SC_LIGHT
SC_VDEFINE int sc_makereport=FALSE; /* generate a cross-reference report */ int sc_makereport=FALSE; /* generate a cross-reference report */
#endif #endif
#if defined __WATCOMC__ && !defined NDEBUG #if defined __WATCOMC__ && !defined NDEBUG

View File

@ -64,13 +64,13 @@ struct HashTable : public ke::HashTable<SymbolHashPolicy>
{ {
}; };
SC_FUNC uint32_t uint32_t
NameHash(const char *str) NameHash(const char *str)
{ {
return ke::HashCharSequence(str, strlen(str)); return ke::HashCharSequence(str, strlen(str));
} }
SC_FUNC HashTable *NewHashTable() HashTable *NewHashTable()
{ {
HashTable *ht = new HashTable(); HashTable *ht = new HashTable();
if (!ht->init()) { if (!ht->init()) {
@ -80,13 +80,13 @@ SC_FUNC HashTable *NewHashTable()
return ht; return ht;
} }
SC_FUNC void void
DestroyHashTable(HashTable *ht) DestroyHashTable(HashTable *ht)
{ {
delete ht; delete ht;
} }
SC_FUNC symbol * symbol *
FindTaggedInHashTable(HashTable *ht, const char *name, int fnumber, int *cmptag) FindTaggedInHashTable(HashTable *ht, const char *name, int fnumber, int *cmptag)
{ {
NameAndScope nas(name, fnumber, cmptag); NameAndScope nas(name, fnumber, cmptag);
@ -103,7 +103,7 @@ FindTaggedInHashTable(HashTable *ht, const char *name, int fnumber, int *cmptag)
return *r; return *r;
} }
SC_FUNC symbol * symbol *
FindInHashTable(HashTable *ht, const char *name, int fnumber) FindInHashTable(HashTable *ht, const char *name, int fnumber)
{ {
NameAndScope nas(name, fnumber, nullptr); NameAndScope nas(name, fnumber, nullptr);
@ -113,7 +113,7 @@ FindInHashTable(HashTable *ht, const char *name, int fnumber)
return *r; return *r;
} }
SC_FUNC void void
AddToHashTable(HashTable *ht, symbol *sym) AddToHashTable(HashTable *ht, symbol *sym)
{ {
HashTable::Insert i = ht->findForAdd(sym); HashTable::Insert i = ht->findForAdd(sym);
@ -121,7 +121,7 @@ AddToHashTable(HashTable *ht, symbol *sym)
ht->add(i, sym); ht->add(i, sym);
} }
SC_FUNC void void
RemoveFromHashTable(HashTable *ht, symbol *sym) RemoveFromHashTable(HashTable *ht, symbol *sym)
{ {
HashTable::Result r = ht->find(sym); HashTable::Result r = ht->find(sym);

View File

@ -2,16 +2,16 @@
#ifndef _INCLUDE_SPCOMP_SYMHASH_H_ #ifndef _INCLUDE_SPCOMP_SYMHASH_H_
#define _INCLUDE_SPCOMP_SYMHASH_H_ #define _INCLUDE_SPCOMP_SYMHASH_H_
SC_FUNC uint32_t NameHash(const char *str); uint32_t NameHash(const char *str);
struct HashTable; struct HashTable;
SC_FUNC HashTable *NewHashTable(); HashTable *NewHashTable();
SC_FUNC void DestroyHashTable(HashTable *ht); void DestroyHashTable(HashTable *ht);
SC_FUNC void AddToHashTable(HashTable *ht, symbol *sym); void AddToHashTable(HashTable *ht, symbol *sym);
SC_FUNC void RemoveFromHashTable(HashTable *ht, symbol *sym); void RemoveFromHashTable(HashTable *ht, symbol *sym);
SC_FUNC symbol *FindInHashTable(HashTable *ht, const char *name, int fnumber); symbol *FindInHashTable(HashTable *ht, const char *name, int fnumber);
SC_FUNC symbol *FindTaggedInHashTable(HashTable *ht, const char *name, int fnumber, symbol *FindTaggedInHashTable(HashTable *ht, const char *name, int fnumber,
int *cmptag); int *cmptag);
#endif /* _INCLUDE_SPCOMP_SYMHASH_H_ */ #endif /* _INCLUDE_SPCOMP_SYMHASH_H_ */