|
ds@1952
|
1 |
/* Pawn compiler |
|
ds@1952
|
2 |
* |
|
ds@1952
|
3 |
* Global (cross-module) variables. |
|
ds@1952
|
4 |
* |
|
ds@1952
|
5 |
* Copyright (c) ITB CompuPhase, 1997-2006 |
|
ds@1952
|
6 |
* |
|
ds@1952
|
7 |
* This software is provided "as-is", without any express or implied warranty. |
|
ds@1952
|
8 |
* In no event will the authors be held liable for any damages arising from |
|
ds@1952
|
9 |
* the use of this software. |
|
ds@1952
|
10 |
* |
|
ds@1952
|
11 |
* Permission is granted to anyone to use this software for any purpose, |
|
ds@1952
|
12 |
* including commercial applications, and to alter it and redistribute it |
|
ds@1952
|
13 |
* freely, subject to the following restrictions: |
|
ds@1952
|
14 |
* |
|
ds@1952
|
15 |
* 1. The origin of this software must not be misrepresented; you must not |
|
ds@1952
|
16 |
* claim that you wrote the original software. If you use this software in |
|
ds@1952
|
17 |
* a product, an acknowledgment in the product documentation would be |
|
ds@1952
|
18 |
* appreciated but is not required. |
|
ds@1952
|
19 |
* 2. Altered source versions must be plainly marked as such, and must not be |
|
ds@1952
|
20 |
* misrepresented as being the original software. |
|
ds@1952
|
21 |
* 3. This notice may not be removed or altered from any source distribution. |
|
ds@1952
|
22 |
* |
|
ds@1952
|
23 |
* Version: $Id$ |
|
ds@1952
|
24 |
*/ |
|
ds@1952
|
25 |
#include <stdio.h> |
|
ds@1952
|
26 |
#include <stdlib.h> /* for _MAX_PATH */ |
|
ds@1952
|
27 |
#include "sc.h" |
|
dvander@3075
|
28 |
#include "sp_symhash.h" |
|
ds@1952
|
29 |
|
|
ds@1952
|
30 |
/* global variables |
|
ds@1952
|
31 |
* |
|
ds@1952
|
32 |
* All global variables that are shared amongst the compiler files are |
|
ds@1952
|
33 |
* declared here. |
|
ds@1952
|
34 |
*/ |
|
ds@1952
|
35 |
SC_VDEFINE symbol loctab; /* local symbol table */ |
|
ds@1952
|
36 |
SC_VDEFINE symbol glbtab; /* global symbol table */ |
|
ds@1952
|
37 |
SC_VDEFINE cell *litq; /* the literal queue */ |
|
ds@1952
|
38 |
SC_VDEFINE unsigned char pline[sLINEMAX+1]; /* the line read from the input file */ |
|
ds@1952
|
39 |
SC_VDEFINE const unsigned char *lptr; /* points to the current position in "pline" */ |
|
ds@1952
|
40 |
SC_VDEFINE constvalue tagname_tab = { NULL, "", 0, 0}; /* tagname table */ |
|
ds@1952
|
41 |
SC_VDEFINE constvalue libname_tab = { NULL, "", 0, 0}; /* library table (#pragma library "..." syntax) */ |
|
ds@1952
|
42 |
SC_VDEFINE constvalue *curlibrary = NULL; /* current library */ |
|
ds@1952
|
43 |
SC_VDEFINE int pc_addlibtable = TRUE; /* is the library table added to the AMX file? */ |
|
ds@1952
|
44 |
SC_VDEFINE symbol *curfunc; /* pointer to current function */ |
|
ds@1952
|
45 |
SC_VDEFINE char *inpfname; /* pointer to name of the file currently read from */ |
|
ds@1952
|
46 |
SC_VDEFINE char outfname[_MAX_PATH]; /* intermediate (assembler) file name */ |
|
ds@1952
|
47 |
SC_VDEFINE char binfname[_MAX_PATH]; /* binary file name */ |
|
ds@1952
|
48 |
SC_VDEFINE char errfname[_MAX_PATH]; /* error file name */ |
|
ds@1952
|
49 |
SC_VDEFINE char sc_ctrlchar = CTRL_CHAR; /* the control character (or escape character)*/ |
|
ds@1952
|
50 |
SC_VDEFINE char sc_ctrlchar_org = CTRL_CHAR;/* the default control character */ |
|
ds@1952
|
51 |
SC_VDEFINE int litidx = 0; /* index to literal table */ |
|
ds@1952
|
52 |
SC_VDEFINE int litmax = sDEF_LITMAX; /* current size of the literal table */ |
|
ds@1952
|
53 |
SC_VDEFINE int stgidx = 0; /* index to the staging buffer */ |
|
ds@1952
|
54 |
SC_VDEFINE int sc_labnum = 0; /* number of (internal) labels */ |
|
ds@1952
|
55 |
SC_VDEFINE int staging = 0; /* true if staging output */ |
|
ds@1952
|
56 |
SC_VDEFINE cell declared = 0; /* number of local cells declared */ |
|
ds@1952
|
57 |
SC_VDEFINE cell glb_declared=0; /* number of global cells declared */ |
|
ds@1952
|
58 |
SC_VDEFINE cell code_idx = 0; /* number of bytes with generated code */ |
|
ds@1952
|
59 |
SC_VDEFINE int ntv_funcid= 0; /* incremental number of native function */ |
|
ds@1952
|
60 |
SC_VDEFINE int errnum = 0; /* number of errors */ |
|
ds@1952
|
61 |
SC_VDEFINE int warnnum = 0; /* number of warnings */ |
|
ds@1952
|
62 |
SC_VDEFINE int sc_debug = sCHKBOUNDS; /* by default: bounds checking+assertions */ |
|
ds@1952
|
63 |
SC_VDEFINE int sc_packstr= FALSE; /* strings are packed by default? */ |
|
ds@1952
|
64 |
SC_VDEFINE int sc_asmfile= FALSE; /* create .ASM file? */ |
|
ds@1952
|
65 |
SC_VDEFINE int sc_listing= FALSE; /* create .LST file? */ |
|
ds@1952
|
66 |
SC_VDEFINE int sc_compress=TRUE; /* compress bytecode? */ |
|
ds@1952
|
67 |
SC_VDEFINE int sc_needsemicolon=TRUE;/* semicolon required to terminate expressions? */ |
|
ds@1952
|
68 |
SC_VDEFINE int sc_dataalign=sizeof(cell);/* data alignment value */ |
|
ds@1952
|
69 |
SC_VDEFINE int sc_alignnext=FALSE; /* must frame of the next function be aligned? */ |
|
ds@1952
|
70 |
SC_VDEFINE int pc_docexpr=FALSE; /* must expression be attached to documentation comment? */ |
|
ds@1952
|
71 |
SC_VDEFINE int curseg = 0; /* 1 if currently parsing CODE, 2 if parsing DATA */ |
|
ds@1952
|
72 |
SC_VDEFINE cell pc_stksize=sDEF_AMXSTACK;/* default stack size */ |
|
ds@1952
|
73 |
SC_VDEFINE cell pc_amxlimit=0; /* default abstract machine size limit = none */ |
|
ds@1952
|
74 |
SC_VDEFINE cell pc_amxram=0; /* default abstract machine data size limit = none */ |
|
ds@1952
|
75 |
SC_VDEFINE int freading = FALSE; /* Is there an input file ready for reading? */ |
|
ds@1952
|
76 |
SC_VDEFINE int fline = 0; /* the line number in the current file */ |
|
ds@1952
|
77 |
SC_VDEFINE short fnumber = 0; /* the file number in the file table (debugging) */ |
|
ds@1952
|
78 |
SC_VDEFINE short fcurrent= 0; /* current file being processed (debugging) */ |
|
ds@1952
|
79 |
SC_VDEFINE short sc_intest=FALSE; /* true if inside a test */ |
|
ds@1952
|
80 |
SC_VDEFINE int sideeffect= 0; /* true if an expression causes a side-effect */ |
|
ds@1952
|
81 |
SC_VDEFINE int stmtindent= 0; /* current indent of the statement */ |
|
ds@1952
|
82 |
SC_VDEFINE int indent_nowarn=FALSE;/* skip warning "217 loose indentation" */ |
|
ds@1952
|
83 |
SC_VDEFINE int sc_tabsize=8; /* number of spaces that a TAB represents */ |
|
ds@1952
|
84 |
SC_VDEFINE short sc_allowtags=TRUE; /* allow/detect tagnames in lex() */ |
|
ds@1952
|
85 |
SC_VDEFINE int sc_status; /* read/write status */ |
|
ds@1952
|
86 |
SC_VDEFINE int sc_rationaltag=0; /* tag for rational numbers */ |
|
ds@1952
|
87 |
SC_VDEFINE int rational_digits=0; /* number of fractional digits */ |
|
ds@1952
|
88 |
SC_VDEFINE int sc_allowproccall=0; /* allow/detect tagnames in lex() */ |
|
ds@1952
|
89 |
SC_VDEFINE short sc_is_utf8=FALSE; /* is this source file in UTF-8 encoding */ |
|
ds@1952
|
90 |
SC_VDEFINE char *pc_deprecate=NULL;/* if non-null, mark next declaration as deprecated */ |
|
ds@1952
|
91 |
SC_VDEFINE int sc_curstates=0; /* ID of the current state list */ |
|
ds@1952
|
92 |
SC_VDEFINE int pc_optimize=sOPTIMIZE_NOMACRO; /* (peephole) optimization level */ |
|
ds@1952
|
93 |
SC_VDEFINE int pc_memflags=0; /* special flags for the stack/heap usage */ |
|
ds@1952
|
94 |
|
|
ds@1952
|
95 |
SC_VDEFINE constvalue sc_automaton_tab = { NULL, "", 0, 0}; /* automaton table */ |
|
ds@1952
|
96 |
SC_VDEFINE constvalue sc_state_tab = { NULL, "", 0, 0}; /* state table */ |
|
ds@1952
|
97 |
|
|
ds@1952
|
98 |
SC_VDEFINE FILE *inpf = NULL; /* file read from (source or include) */ |
|
ds@1952
|
99 |
SC_VDEFINE FILE *inpf_org= NULL; /* main source file */ |
|
ds@1952
|
100 |
SC_VDEFINE FILE *outf = NULL; /* (intermediate) text file written to */ |
|
ds@1952
|
101 |
|
|
ds@1952
|
102 |
SC_VDEFINE jmp_buf errbuf; |
|
ds@1952
|
103 |
|
|
dvander@3075
|
104 |
SC_VDEFINE HashTable *sp_Globals = NULL; |
|
dvander@3075
|
105 |
|
|
ds@1952
|
106 |
#if !defined SC_LIGHT |
|
ds@1952
|
107 |
SC_VDEFINE int sc_makereport=FALSE; /* generate a cross-reference report */ |
|
ds@1952
|
108 |
#endif |
|
ds@1952
|
109 |
|
|
ds@1952
|
110 |
#if defined __WATCOMC__ && !defined NDEBUG |
|
ds@1952
|
111 |
/* Watcom's CVPACK dislikes .OBJ files without functions */ |
|
ds@1952
|
112 |
static int dummyfunc(void) |
|
ds@1952
|
113 |
{ |
|
ds@1952
|
114 |
return 0; |
|
ds@1952
|
115 |
} |
|
ds@1952
|
116 |
#endif |