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)
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/>. */
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
;
27 /* literal primitive semantic types! */
31 struct gpy_symbol_table_t
* symbol_table
;
37 struct gpy_symbol_table_t
* symbol_table
;
39 struct gpy_symbol_table_t
*next
;
42 typedef struct gpy_vector_t
{
44 signed long size
, length
;
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
{
58 typedef struct gpy_hash_table_t
{
59 unsigned int size
, length
;
60 gpy_hash_entry_t
* array
;
63 typedef struct gpy_id_t
{
66 typedef gpy_ident_t
* gpy_ident
;
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
;
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; \
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_ */