2 * symbol - global and local symbol routines
4 * Copyright (C) 1999 David I. Bell
6 * Calc is open software; you can redistribute it and/or modify it under
7 * the terms of the version 2.1 of the GNU Lesser General Public License
8 * as published by the Free Software Foundation.
10 * Calc is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
13 * Public License for more details.
15 * A copy of version 2.1 of the GNU Lesser General Public License is
16 * distributed with calc under the filename COPYING-LGPL. You should have
17 * received a copy with calc; if not, write to Free Software Foundation, Inc.
18 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
24 * Under source code control: 1990/02/15 01:48:37
25 * File existed as early as: before 1990
27 * Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
31 #if !defined(__SYMBOL_H__)
35 #if defined(CALC_SRC) /* if we are building from the calc source tree */
36 # include "calc/zmath.h"
38 # include <calc/zmath.h>
43 * Symbol Declarations.
45 #define SYM_UNDEFINED 0 /* undefined symbol */
46 #define SYM_PARAM 1 /* parameter symbol */
47 #define SYM_LOCAL 2 /* local symbol */
48 #define SYM_GLOBAL 3 /* global symbol */
49 #define SYM_STATIC 4 /* static symbol */
51 #define SCOPE_GLOBAL 0 /* file scope level for global variables */
52 #define SCOPE_STATIC 1 /* lowest file scope for static variables */
55 typedef struct global GLOBAL;
57 int g_len; /* length of symbol name */
58 short g_filescope; /* file scope level of symbol (0 if global) */
59 short g_funcscope; /* function scope level of symbol */
60 char *g_name; /* global symbol name */
61 VALUE g_value; /* global symbol value */
62 GLOBAL *g_next; /* next symbol in hash chain */
67 * Routines to search for global symbols.
69 extern GLOBAL *addglobal(char *name, BOOL isstatic);
70 extern GLOBAL *findglobal(char *name);
74 * Routines to return names of variables.
76 extern char *localname(long n);
77 extern char *paramname(long n);
78 extern char *globalname(GLOBAL *sp);
82 * Routines to handle entering and leaving of scope levels.
84 extern void resetscopes(void);
85 extern void enterfilescope(void);
86 extern void exitfilescope(void);
87 extern void enterfuncscope(void);
88 extern void exitfuncscope(void);
89 extern void endscope (char *name, BOOL isglobal);
95 extern long addlocal(char *name);
96 extern long findlocal(char *name);
97 extern long addparam(char *name);
98 extern long findparam(char *name);
99 extern void initlocals(void);
100 extern void initglobals(void);
101 extern int writeglobals(char *name);
102 extern int symboltype(char *name);
103 extern void showglobals(void);
104 extern void showallglobals(void);
105 extern void freeglobals(void);
106 extern void showstatics(void);
107 extern void freestatics(void);
110 #endif /* !__SYMBOL_H__ */