parser cleanups
[official-gcc.git] / gcc / python / symbols.h
blobb83e911f40a445d4161462b1b1383049876b2d87
1 /* This file is part of GCC.
3 GCC is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 3, or (at your option)
6 any later version.
8 GCC is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with GCC; see the file COPYING3. If not see
15 <http://www.gnu.org/licenses/>. */
17 #ifndef __SYMBOLS_H_
18 #define __SYMBOLS_H__
20 typedef unsigned short gpy_opcode_t;
22 typedef struct GTY(()) gpy_symbol_table_t {
23 char * identifier; gpy_opcode_t exp;
24 gpy_opcode_t type, op_a_t, op_b_t;
25 location_t loc;
26 union {
27 /* literal primitive semantic types! */
28 int integer;
29 char * string;
30 bool boolean;
31 struct gpy_symbol_table_t * symbol_table;
32 } op_a;
33 union {
34 int integer;
35 char * string;
36 bool boolean;
37 struct gpy_symbol_table_t * symbol_table;
38 } op_b;
39 struct gpy_symbol_table_t *next;
40 } gpy_symbol_obj ;
42 typedef struct gpy_vector_t {
43 void ** vector;
44 signed long size, length;
45 } gpy_ident_vector_t;
47 enum OPERATOR_T {
48 LESS_OP, GREATER_OP, EQ_EQ_OP,
49 GREATER_EQ_OP, LESS_EQ_OP
52 typedef unsigned long gpy_hashval_t;
53 typedef struct gpy_hash_entry {
54 gpy_hashval_t hash;
55 void * data;
56 } gpy_hash_entry_t ;
58 typedef struct gpy_hash_table_t {
59 unsigned int size, length;
60 gpy_hash_entry_t * array;
61 } gpy_hash_tab_t ;
63 typedef struct gpy_id_t {
64 char * ident;
65 } gpy_ident_t;
66 typedef gpy_ident_t * gpy_ident;
68 typedef int gpy_int;
69 DEF_VEC_I( gpy_int );
70 DEF_VEC_ALLOC_I( gpy_int,gc );
72 DEF_VEC_P( gpy_ident );
73 DEF_VEC_ALLOC_P( gpy_ident,gc );
75 typedef struct GTY(()) gpy_context_branch_t {
76 gpy_hash_tab_t * var_decls;
77 VEC(gpy_ident,gc) *var_decl_t;
78 gpy_hash_tab_t * fnc_decls;
79 VEC(gpy_ident,gc) *fnc_decl_t;
80 VEC(tree,gc) * ctx_init;
81 } gpy_context_branch ;
83 enum DECL_T { VAR, FUNC };
85 typedef gpy_symbol_obj *gpy_sym;
86 typedef gpy_context_branch *gpy_ctx_t;
88 DEF_VEC_P( gpy_sym );
89 DEF_VEC_ALLOC_P( gpy_sym,gc );
91 DEF_VEC_P( gpy_ctx_t );
92 DEF_VEC_ALLOC_P( gpy_ctx_t,gc );
94 extern VEC(gpy_ctx_t,gc) * gpy_ctx_table;
95 extern VEC(gpy_sym,gc) * gpy_garbage_decls;
96 extern VEC(tree,gc) * global_decls;
98 #define Gpy_Symbol_Init_Ctx( x ) \
99 x->identifier = NULL; \
100 x->exp = TYPE_SYMBOL_NIL; \
101 x->type = SYMBOL_PRIMARY; \
102 x->loc = UNKNOWN_LOCATION; \
103 x->op_a_t = TYPE_SYMBOL_NIL; \
104 x->op_b_t = TYPE_SYMBOL_NIL; \
105 x->op_a.symbol_table = NULL; \
106 x->op_b.symbol_table = NULL; \
107 x->next = NULL;
109 #define Gpy_Symbol_Init( x ) \
110 x = (gpy_symbol_obj*) \
111 xmalloc( sizeof(gpy_symbol_obj) ); \
112 debug("object created at <%p>!\n", (void*)x ); \
113 Gpy_Symbol_Init_Ctx( x );
115 #define Gpy_Mark_Garbage_obj( x ) \
116 debug("marking object <%p> as garbage!\n", x ); \
117 VEC_safe_push( gpy_sym,gc, gpy_garbage_decls, x );
119 #endif /* __SYMBOLS_H_ */