1 /*  Small compiler
2  *
3  *  Global (cross-module) variables.
4  *
5  *  Copyright (c) ITB CompuPhase, 1997-2003
6  *
7  *  This software is provided "as-is", without any express or implied warranty.
8  *  In no event will the authors be held liable for any damages arising from
9  *  the use of this software.
10  *
11  *  Permission is granted to anyone to use this software for any purpose,
12  *  including commercial applications, and to alter it and redistribute it
13  *  freely, subject to the following restrictions:
14  *
15  *  1.  The origin of this software must not be misrepresented; you must not
16  *      claim that you wrote the original software. If you use this software in
17  *      a product, an acknowledgment in the product documentation would be
18  *      appreciated but is not required.
19  *  2.  Altered source versions must be plainly marked as such, and must not be
20  *      misrepresented as being the original software.
21  *  3.  This notice may not be removed or altered from any source distribution.
22  *
23  *  Version: $Id$
24  */
25 
26 
27 #ifdef HAVE_CONFIG_H
28 # include <config.h>		/* for PATH_MAX */
29 #endif
30 
31 #include "embryo_cc_sc.h"
32 
33 /*  global variables
34  *
35  *  All global variables that are shared amongst the compiler files are
36  *  declared here.
37  */
38 symbol   loctab;	/* local symbol table */
39 symbol   glbtab;	/* global symbol table */
40 cell    *litq;	/* the literal queue */
41 char     pline[sLINEMAX + 1];	/* the line read from the input file */
42 char    *lptr;	/* points to the current position in "pline" */
43 constvalue tagname_tab = { NULL, "", 0, 0 };	/* tagname table */
44 constvalue libname_tab = { NULL, "", 0, 0 };	/* library table (#pragma library "..." syntax) */
45 constvalue *curlibrary = NULL;	/* current library */
46 symbol  *curfunc;	/* pointer to current function */
47 char    *inpfname;	/* pointer to name of the file currently read from */
48 char     sc_ctrlchar = CTRL_CHAR;	/* the control character (or escape character) */
49 int      litidx = 0;	/* index to literal table */
50 int      litmax = sDEF_LITMAX;	/* current size of the literal table */
51 int      stgidx = 0;	/* index to the staging buffer */
52 int      labnum = 0;	/* number of (internal) labels */
53 int      staging = 0;	/* true if staging output */
54 cell     declared = 0;	/* number of local cells declared */
55 cell     glb_declared = 0;	/* number of global cells declared */
56 cell     code_idx = 0;	/* number of bytes with generated code */
57 int      ntv_funcid = 0;	/* incremental number of native function */
58 int      errnum = 0;	/* number of errors */
59 int      warnnum = 0;	/* number of warnings */
60 int      sc_debug = sCHKBOUNDS;	/* by default: bounds checking+assertions */
61 int      charbits = 8;	/* a "char" is 8 bits */
62 int      sc_packstr = FALSE;	/* strings are packed by default? */
63 int      sc_compress = TRUE;	/* compress bytecode? */
64 int      sc_needsemicolon = TRUE;	/* semicolon required to terminate expressions? */
65 int      sc_dataalign = sizeof(cell);	/* data alignment value */
66 int      sc_alignnext = FALSE;	/* must frame of the next function be aligned? */
67 int      curseg = 0;	/* 1 if currently parsing CODE, 2 if parsing DATA */
68 cell     sc_stksize = sDEF_AMXSTACK;	/* default stack size */
69 int      freading = FALSE;	/* Is there an input file ready for reading? */
70 int      fline = 0;	/* the line number in the current file */
71 int      fnumber = 0;	/* the file number in the file table (debugging) */
72 int      fcurrent = 0;	/* current file being processed (debugging) */
73 int      intest = 0;	/* true if inside a test */
74 int      sideeffect = 0;	/* true if an expression causes a side-effect */
75 int      stmtindent = 0;	/* current indent of the statement */
76 int      indent_nowarn = TRUE;	/* skip warning "217 loose indentation" */
77 int      sc_tabsize = 8;	/* number of spaces that a TAB represents */
78 int      sc_allowtags = TRUE;	/* allow/detect tagnames in lex() */
79 int      sc_status;	/* read/write status */
80 int      sc_rationaltag = 0;	/* tag for rational numbers */
81 int      rational_digits = 0;	/* number of fractional digits */
82 
83 FILE    *inpf = NULL;	/* file read from (source or include) */
84 FILE    *inpf_org = NULL;	/* main source file */
85 FILE    *outf = NULL;	/* file written to */
86 
87 jmp_buf  errbuf;
88