File tree Expand file tree Collapse file tree 3 files changed +20
-5
lines changed
Expand file tree Collapse file tree 3 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -276,8 +276,12 @@ typedef struct use_chain_node {
276276 struct use_chain_node * prev ;
277277} use_chain_t ;
278278
279+ typedef struct var var_t ;
280+ typedef struct type type_t ;
281+
279282struct var {
280283 char type_name [MAX_TYPE_LEN ];
284+ type_t * type ;
281285 char var_name [MAX_VAR_LEN ];
282286 int is_ptr ;
283287 bool is_func ;
@@ -302,8 +306,6 @@ struct var {
302306 bool is_const ; /* whether a constant representaion or not */
303307};
304308
305- typedef struct var var_t ;
306-
307309typedef struct {
308310 char name [MAX_VAR_LEN ];
309311 bool is_variadic ;
@@ -324,7 +326,6 @@ struct block {
324326 struct block * parent ;
325327 func_t * func ;
326328 macro_t * macro ;
327- int locals_size ;
328329 struct block * next ;
329330};
330331
@@ -374,8 +375,6 @@ struct type {
374375 int num_fields ;
375376};
376377
377- typedef struct type type_t ;
378-
379378/* lvalue details */
380379typedef struct {
381380 int size ;
Original file line number Diff line number Diff line change @@ -996,6 +996,7 @@ void global_release()
996996{
997997 while (BLOCKS .head ) {
998998 block_t * next = BLOCKS .head -> next ;
999+ printf ("%d\n" , BLOCKS .head -> next_local );
9991000 free (BLOCKS .head );
10001001 BLOCKS .head = next ;
10011002 }
Original file line number Diff line number Diff line change @@ -47,6 +47,21 @@ var_t *require_var(block_t *blk)
4747 return var ;
4848}
4949
50+ var_t * require_var_t (block_t * blk , type_t * type )
51+ {
52+ if (blk -> next_local >= MAX_LOCALS )
53+ error ("Too many locals" );
54+
55+ if (!type )
56+ error ("Type must not be NULL" );
57+
58+ var_t * var = & blk -> locals [blk -> next_local ++ ];
59+ var -> consumed = -1 ;
60+ var -> base = var ;
61+ var -> type = type ;
62+ return var ;
63+ }
64+
5065void opstack_push (var_t * var )
5166{
5267 operand_stack [operand_stack_idx ++ ] = var ;
You can’t perform that action at this time.
0 commit comments