2 /********************************************
4 copyright 1991, Michael D. Brennan
6 This is a source file for mawk, an implementation of
7 the AWK programming language.
9 Mawk is distributed without warranty under the terms of
10 the GNU General Public License, version 2, 1991.
11 ********************************************/
14 * Revision 1.6 1996/02/01 04:39:43 mike
15 * dynamic array scheme
17 * Revision 1.5 1995/04/21 14:20:23 mike
18 * move_level variable to fix bug in arglist patching of moved code.
20 * Revision 1.4 1994/12/13 00:13:02 mike
21 * delete A statement to delete all of A at once
23 * Revision 1.3 1993/12/01 14:25:25 mike
24 * reentrant array loops
26 * Revision 1.2 1993/07/15 01:55:08 mike
29 * Revision 1.1.1.1 1993/07/03 18:58:21 mike
32 * Revision 5.5 1993/01/09 19:03:44 mike
33 * code_pop checks if the resolve_list needs relocation
35 * Revision 5.4 1993/01/07 02:50:33 mike
36 * relative vs absolute code
38 * Revision 5.3 1992/12/17 02:48:01 mike
39 * 1.1.2d changes for DOS
41 * Revision 5.2 1992/07/08 15:44:44 brennan
42 * patch2: length returns. I am a wimp
44 * Revision 5.1 1991/12/05 07:59:37 brennan
49 /* types related to symbols are defined here */
55 /* struct to hold info about builtins */
58 PF_CP fp ; /* ptr to function that does the builtin */
59 unsigned char min_args, max_args ;
60 /* info for parser to check correct number of arguments */
63 /*---------------------------
64 structures and types for arrays
65 *--------------------------*/
72 /* struct to hold the state of an array loop */
73 typedef struct al_state {
74 struct al_state *link ;
77 int index ; /* A[index] */
81 int PROTO( inc_aloop_state, (ALOOP_STATE*)) ;
84 /* for parsing (i,j) in A */
86 int start ; /* offset to code_base */
90 /*------------------------
91 user defined functions
92 ------------------------*/
94 typedef struct fblock {
97 unsigned short nargs ;
98 char *typev ; /* array of size nargs holding types */
99 } FBLOCK ; /* function block */
101 void PROTO(add_to_fdump_list, (FBLOCK *) ) ;
102 void PROTO( fdump, (void) ) ;
104 /*-------------------------
105 elements of the symbol table
106 -----------------------*/
111 #define ST_BUILTIN 3 /* a pointer to a builtin record */
112 #define ST_ARRAY 4 /* a void * ptr to a hash table */
113 #define ST_FIELD 5 /* a cell ptr to a field */
115 #define ST_NR 7 /* NR is special */
116 #define ST_ENV 8 /* and so is ENVIRON */
117 #define ST_LENGTH 9 /* ditto and bozo */
118 #define ST_LOCAL_NONE 10
119 #define ST_LOCAL_VAR 11
120 #define ST_LOCAL_ARRAY 12
122 #define is_local(stp) ((stp)->type>=ST_LOCAL_NONE)
127 unsigned char offset ; /* offset in stack frame for local vars */
139 /*****************************
140 structures for type checking function calls
141 ******************************/
143 typedef struct ca_rec {
144 struct ca_rec *link ;
146 short arg_num ; /* position in callee's stack */
147 /*--------- this data only set if we'll need to patch -------*/
148 /* happens if argument is an ID or type ST_NONE or ST_LOCAL_NONE */
151 /* where the type is stored */
152 SYMTAB *sym_p ; /* if type is ST_NONE */
153 char *type_p ; /* if type is ST_LOCAL_NONE */
154 } CA_REC ; /* call argument record */
156 /* type field of CA_REC matches with ST_ types */
157 #define CA_EXPR ST_LOCAL_VAR
158 #define CA_ARRAY ST_LOCAL_ARRAY
160 typedef struct fcall {
165 FBLOCK *call ; /* only used if call_scope == SCOPE_FUNCT */
166 INST *call_start ; /* computed later as code may be moved */
168 short arg_cnt_checked ;
169 unsigned line_no ; /* for error messages */
172 extern FCALL_REC *resolve_list ;
174 void PROTO(resolve_fcalls, (void) ) ;
175 void PROTO(check_fcall, (FBLOCK*,int,int,FBLOCK*,CA_REC*,unsigned) ) ;
176 void PROTO(relocate_resolve_list, (int,int,FBLOCK*,int,unsigned,int)) ;
179 unsigned PROTO( hash, (char *) ) ;
180 SYMTAB *PROTO( insert, (char *) ) ;
181 SYMTAB *PROTO( find, (char *) ) ;
182 char *PROTO( reverse_find, (int, PTR)) ;
183 SYMTAB *PROTO( save_id, (char *) ) ;
184 void PROTO( restore_ids, (void) ) ;
187 void PROTO(type_error, (SYMTAB *) ) ;
189 #endif /* SYMTYPE_H */