delete some un-used member vars and code for them.
authoryu.dongliang <18588496441@163.com>
Wed, 17 Jun 2026 14:55:05 +0000 (22:55 +0800)
committeryu.dongliang <18588496441@163.com>
Wed, 17 Jun 2026 14:55:05 +0000 (22:55 +0800)
25 files changed:
core/scf_3ac.c
core/scf_3ac.h
core/scf_ast.c
core/scf_ast.h
core/scf_basic_block.c
core/scf_label.c
core/scf_node.c
core/scf_node.h
core/scf_operator_handler_3ac.c
core/scf_scope.c
core/scf_scope.h
core/scf_type.c
core/scf_type.h
core/scf_variable.c
parse/scf_dfa_class.c
parse/scf_dfa_container.c
parse/scf_dfa_function.c
parse/scf_dfa_goto.c
parse/scf_dfa_label.c
parse/scf_dfa_type.c
parse/scf_dfa_va_arg.c
parse/scf_dfa_var.c
parse/scf_operator_handler_semantic.c
parse/scf_parse.c
parse/scf_parse.h

index 0e28716b56d28eec98fe9e640439eeb1e0f856bb..07401bb2ecee415f176f56ed80ed5e19e429805d 100644 (file)
@@ -384,7 +384,7 @@ scf_3ac_code_t* scf_3ac_alloc_by_dst(int op_type, scf_dag_node_t* dst)
        return c;
 }
 
-scf_3ac_code_t* scf_3ac_jmp_code(int type, scf_label_t* l, scf_node_t* err)
+scf_3ac_code_t* scf_3ac_jmp_code(int type, scf_lex_word_t* label)
 {
        scf_3ac_operand_t* dst;
        scf_3ac_code_t*    c;
@@ -394,9 +394,9 @@ scf_3ac_code_t* scf_3ac_jmp_code(int type, scf_label_t* l, scf_node_t* err)
                return NULL;
 
        c->op    = scf_3ac_find_operator(type);
-       c->label = l;
+       c->label = label;
 
-       c->dsts  = scf_vector_alloc();
+       c->dsts = scf_vector_alloc();
        if (!c->dsts) {
                scf_3ac_code_free(c);
                return NULL;
index 947bff2878729112ba5ded2ba159c5b09311a85f..7f45cb67c46a2e56547773a3681f44e663f02873 100644 (file)
@@ -32,7 +32,7 @@ struct scf_3ac_code_s {
        scf_vector_t*           dsts; // dst operands, maybe only used for function return value
        scf_vector_t*           srcs; // src operands, usually 2
 
-       scf_label_t*            label; // only for 'goto' to find the destination to go
+       scf_lex_word_t*     label; // only for 'goto' to find the destination
 
        scf_3ac_code_t*     origin;
 
@@ -60,7 +60,7 @@ void                          scf_3ac_code_print(scf_3ac_code_t* c, scf_list_t* sentinel);
 
 void                scf_3ac_list_print(scf_list_t* h);
 
-scf_3ac_code_t*     scf_3ac_jmp_code(int type, scf_label_t* l, scf_node_t* err);
+scf_3ac_code_t*     scf_3ac_jmp_code(int type, scf_lex_word_t* label);
 
 scf_3ac_operator_t*    scf_3ac_find_operator(const int type);
 
index d7a827cd9ae2bc74402391c8470440b144aee079..50eafa220c705f6d09c78dfce27dc734952bfc0d 100644 (file)
@@ -158,7 +158,7 @@ static int _find_type_by_type(scf_node_t* node, void* arg, scf_vector_t* vec)
 
                scf_type_t* t = (scf_type_t*)node;
 
-               if (t->type == (intptr_t)arg) {
+               if (t->node.type == (intptr_t)arg) {
 
                        int ret = scf_vector_add(vec, t);
                        if (ret < 0)
index 0cc4cc024c93bff5f59b120f100741830b204aeb..55da0d1ae32257cae601b3aefc9cb8f47117ca95 100644 (file)
@@ -56,32 +56,6 @@ int scf_expr_calculate_internal(scf_ast_t* ast, scf_node_t* node, void* data);
 
 scf_string_t* scf_variable_type_name(scf_ast_t* ast, scf_variable_t* v);
 
-static inline void scf_ast_push_block(scf_ast_t* ast, scf_block_t* b)
-{
-       scf_node_add_child((scf_node_t*)ast->current_block, (scf_node_t*)b);
-       ast->current_block = b;
-}
-
-static inline void scf_ast_pop_block(scf_ast_t* ast)
-{
-       ast->current_block = (scf_block_t*)(ast->current_block->node.parent);
-}
-
-static inline scf_block_t* scf_ast_parent_block(scf_ast_t* ast)
-{
-       scf_node_t* parent = ast->current_block->node.parent;
-
-       while (parent && parent->type != SCF_OP_BLOCK && parent->type != SCF_FUNCTION)
-               parent = parent->parent;
-
-       return (scf_block_t*)parent;
-}
-
-static inline scf_scope_t* scf_ast_current_scope(scf_ast_t* ast)
-{
-       return ast->current_block->scope;
-}
-
 int scf_ast_find_proper_function (scf_function_t** pf, scf_ast_t* ast, scf_vector_t* fvec, scf_vector_t* argv);
 int scf_ast_find_global_function (scf_function_t** pf, scf_ast_t* ast, char* name);
 int scf_ast_find_global_variable (scf_variable_t** pv, scf_ast_t* ast, char* name);
index 55a642619edc8e1b1fb22205ff72943da1c32345..0fc2e60ef295c69f846496c1efb712e163862802 100644 (file)
@@ -143,7 +143,7 @@ scf_basic_block_t* scf_basic_block_jcc(scf_basic_block_t* to, scf_function_t* f,
        if (!bb)
                return NULL;
 
-       c = scf_3ac_jmp_code(jcc, NULL, NULL);
+       c = scf_3ac_jmp_code(jcc, NULL);
        if (!c) {
                scf_basic_block_free(bb);
                return NULL;
index 63bdb9e33bbe74d18a05480fdd60c4ebc2daf996..7bb478b7ca1c12db5db6d006fbfb68c3a33a6109 100644 (file)
@@ -12,7 +12,6 @@ scf_label_t* scf_label_alloc(scf_lex_word_t* w)
                return NULL;
        }
 
-       l->refs = 1;
        l->type = SCF_LABEL;
        return l;
 }
@@ -20,9 +19,6 @@ scf_label_t* scf_label_alloc(scf_lex_word_t* w)
 void scf_label_free(scf_label_t* l)
 {
        if (l) {
-               if (--l->refs > 0)
-                       return;
-
                if (l->w) {
                        scf_lex_word_free(l->w);
                        l->w = NULL;
index 89d68ad11d18027c388a8aed617bfd8f2c34840e..deaf7be6b26eaa29a7a787450886a072ffa4b32a 100644 (file)
@@ -76,9 +76,7 @@ scf_node_t* scf_node_clone(scf_node_t* node)
                if (!dst->var)
                        goto failed;
 
-       } else if (SCF_LABEL == node->type)
-               dst->label = node->label;
-       else {
+       } else {
                if (node->w) {
                        dst->w = scf_lex_word_clone(node->w);
                        if (!dst->w)
@@ -110,19 +108,6 @@ failed:
        return NULL;
 }
 
-scf_node_t*    scf_node_alloc_label(scf_label_t* l)
-{
-       scf_node_t* node = calloc(1, sizeof(scf_node_t));
-       if (!node) {
-               scf_loge("node alloc failed\n");
-               return NULL;
-       }
-
-       node->type  = SCF_LABEL;
-       node->label = l;
-       return node;
-}
-
 int scf_node_add_child(scf_node_t* parent, scf_node_t* child)
 {
        if (!parent)
@@ -168,11 +153,6 @@ void scf_node_free_data(scf_node_t* node)
                        scf_variable_free(node->var);
                        node->var = NULL;
                }
-       } else if (SCF_LABEL == node->type) {
-               if (node->label) {
-                       scf_label_free(node->label);
-                       node->label = NULL;
-               }
        } else {
                if (node->w) {
                        scf_lex_word_free(node->w);
@@ -277,11 +257,7 @@ void scf_node_print(scf_node_t* node)
        if (node) {
                scf_logw("node: %p, type: %d", node, node->type); 
 
-               if (SCF_LABEL == node->type) {
-                       if (node->label && node->label->w)
-                               printf(", w: %s, line: %d", node->label->w->text->data, node->label->w->line);
-
-               } else if (scf_type_is_var(node->type)) {
+               if (scf_type_is_var(node->type)) {
                        if (node->var && node->var->w)
                                printf(", w: %s, line: %d", node->var->w->text->data, node->var->w->line);
 
index 7023d1e77944f6f0919a4da8ecb9ad20d0db0e62..523e324a2b7751042207c84babde32126ff6f8aa 100644 (file)
@@ -20,9 +20,8 @@ struct scf_node_s {
        scf_node_t**            nodes;          // children nodes
 
        union {
-               scf_variable_t*         var;
-               scf_lex_word_t*         w;
-               scf_label_t*            label;
+               scf_variable_t* var;
+               scf_lex_word_t* w;
        };
 
        scf_lex_word_t*         debug_w;
@@ -60,9 +59,6 @@ struct scf_label_s {
 };
 
 scf_node_t*            scf_node_alloc(scf_lex_word_t* w, int type, scf_variable_t* var);
-scf_node_t*            scf_node_alloc_label(scf_label_t* l);
-
-scf_node_t*            scf_node_clone(scf_node_t* node);
 
 int             scf_node_add_child(scf_node_t* parent, scf_node_t* child);
 void            scf_node_del_child(scf_node_t* parent, scf_node_t* child);
@@ -71,6 +67,7 @@ void                  scf_node_free(scf_node_t* node);
 void                   scf_node_free_data(scf_node_t* node);
 void                   scf_node_move_data(scf_node_t* dst, scf_node_t* src);
 
+scf_node_t*            scf_node_clone(scf_node_t* node);
 void            scf_node_print(scf_node_t* node);
 
 scf_variable_t* _scf_operand_get(const scf_node_t* node);
index 33d276cc52003225a2509d4ec050c49750aecd6f..cb81514cb7ae58069722a04842f02dac1fd1ebea 100644 (file)
@@ -385,9 +385,7 @@ static int _scf_op_block(scf_ast_t* ast, scf_node_t** nodes, int nb_nodes, void*
 
        int i;
        int j;
-
        for (i = 0; i < nb_nodes; i++) {
-
                node = nodes[i];
                op   = node->op;
 
@@ -413,7 +411,6 @@ static int _scf_op_block(scf_ast_t* ast, scf_node_t** nodes, int nb_nodes, void*
                // for goto
                if (SCF_LABEL == node->type) {
 
-                       scf_label_t*       l    = node->label;
                        scf_list_t*        tail = scf_list_tail(d->_3ac_list_head);
                        scf_3ac_code_t*    end  = scf_list_data(tail, scf_3ac_code_t, list);
                        scf_3ac_code_t*    c;
@@ -423,7 +420,7 @@ static int _scf_op_block(scf_ast_t* ast, scf_node_t** nodes, int nb_nodes, void*
                                scf_loge("\n");
                                return -1;
                        }
-                       end->label = l;
+                       end->label = node->w;
 
                        int j;
                        for (j = 0; j < d->branch_ops->_gotos->size; j++) {
@@ -432,10 +429,9 @@ static int _scf_op_block(scf_ast_t* ast, scf_node_t** nodes, int nb_nodes, void*
                                if (!c)
                                        continue;
 
-                               assert(l->w);
-                               assert(c->label->w);
+                               assert(c->label);
 
-                               if (!strcmp(l->w->text->data, c->label->w->text->data)) {
+                               if (!strcmp(node->w->text->data, c->label->text->data)) {
                                        dst       = c->dsts->data[0];
                                        dst->code = end;
                                }
@@ -486,7 +482,7 @@ static int _scf_op_return(scf_ast_t* ast, scf_node_t** nodes, int nb_nodes, void
                        return -1;
        }
 
-       scf_3ac_code_t* end = scf_3ac_jmp_code(SCF_OP_GOTO, NULL, NULL);
+       scf_3ac_code_t* end = scf_3ac_jmp_code(SCF_OP_GOTO, NULL);
 
        scf_list_add_tail(d->_3ac_list_head, &end->list);
 
@@ -510,7 +506,7 @@ static int _scf_op_break(scf_ast_t* ast, scf_node_t** nodes, int nb_nodes, void*
                return -1;
        }
 
-       scf_3ac_code_t* jmp = scf_3ac_jmp_code(SCF_OP_GOTO, NULL, NULL);
+       scf_3ac_code_t* jmp = scf_3ac_jmp_code(SCF_OP_GOTO, NULL);
 
        scf_list_add_tail(d->_3ac_list_head, &jmp->list);
 
@@ -534,7 +530,7 @@ static int _scf_op_continue(scf_ast_t* ast, scf_node_t** nodes, int nb_nodes, vo
                return -1;
        }
 
-       scf_3ac_code_t* jmp = scf_3ac_jmp_code(SCF_OP_GOTO, NULL, NULL);
+       scf_3ac_code_t* jmp = scf_3ac_jmp_code(SCF_OP_GOTO, NULL);
 
        scf_list_add_tail(d->_3ac_list_head, &jmp->list);
 
@@ -553,14 +549,12 @@ static int _scf_op_goto(scf_ast_t* ast, scf_node_t** nodes, int nb_nodes, void*
 
        scf_handler_data_t* d  = data;
        scf_node_t*         nl = nodes[0];
-       scf_label_t*        l  = nl->label;
 
        assert(SCF_LABEL == nl->type);
-       assert(l->w);
 
        scf_3ac_operand_t* dst;
        scf_3ac_code_t*    c;
-       scf_3ac_code_t*    jmp = scf_3ac_jmp_code(SCF_OP_GOTO, l, NULL);
+       scf_3ac_code_t*    jmp = scf_3ac_jmp_code(SCF_OP_GOTO, nl->w);
 
        scf_list_add_tail(d->_3ac_list_head, &jmp->list);
 
@@ -568,7 +562,9 @@ static int _scf_op_goto(scf_ast_t* ast, scf_node_t** nodes, int nb_nodes, void*
        for (i = 0; i < d->branch_ops->_labels->size; i++) {
                c  =        d->branch_ops->_labels->data[i];
 
-               if (!strcmp(l->w->text->data, c->label->w->text->data)) {
+               assert(c->label);
+
+               if (!strcmp(nl->w->text->data, c->label->text->data)) {
                        dst = jmp->dsts->data[0];
                        dst->code = c;
                        break;
@@ -734,7 +730,7 @@ static int _scf_op_if(scf_ast_t* ast, scf_node_t** nodes, int nb_nodes, void* da
        }
 
        scf_3ac_operand_t* dst;
-       scf_3ac_code_t*    jmp_else  = scf_3ac_jmp_code(jmp_op, NULL, NULL);
+       scf_3ac_code_t*    jmp_else  = scf_3ac_jmp_code(jmp_op, NULL);
        scf_3ac_code_t*    jmp_endif = NULL;
        scf_list_t*        l;
 
@@ -751,7 +747,7 @@ static int _scf_op_if(scf_ast_t* ast, scf_node_t** nodes, int nb_nodes, void* da
 
                if (1 == i) {
                        if (3 == nb_nodes) {
-                               jmp_endif = scf_3ac_jmp_code(SCF_OP_GOTO, NULL, NULL);
+                               jmp_endif = scf_3ac_jmp_code(SCF_OP_GOTO, NULL);
                                scf_list_add_tail(d->_3ac_list_head, &jmp_endif->list);
                        }
 
@@ -877,13 +873,13 @@ static int _scf_op_end_loop(scf_list_t* start_prev, scf_list_t* continue_prev, s
 
        if (jmp_end) {
                // add loop when true
-               loop = scf_3ac_jmp_code(jmp_op, NULL, NULL);
+               loop = scf_3ac_jmp_code(jmp_op, NULL);
                scf_list_add_tail(d->_3ac_list_head, &loop->list);
 
                // should get the real start here,
                start = scf_list_data(scf_list_next(&jmp_end->list), scf_3ac_code_t, list);
        } else {
-               loop = scf_3ac_jmp_code(SCF_OP_GOTO, NULL, NULL);
+               loop = scf_3ac_jmp_code(SCF_OP_GOTO, NULL);
                scf_list_add_tail(d->_3ac_list_head, &loop->list);
 
                start = scf_list_data(scf_list_next(start_prev), scf_3ac_code_t, list);
@@ -990,7 +986,7 @@ static int _scf_op_do(scf_ast_t* ast, scf_node_t** nodes, int nb_nodes, void* da
 
        scf_list_t*     l;
        scf_3ac_code_t* c;
-       scf_3ac_code_t* jmp_end = scf_3ac_jmp_code(jmp_op, NULL, NULL);
+       scf_3ac_code_t* jmp_end = scf_3ac_jmp_code(jmp_op, NULL);
 
        scf_list_add_tail(d->_3ac_list_head, &jmp_end->list);
 
@@ -1050,7 +1046,7 @@ static int _scf_op_while(scf_ast_t* ast, scf_node_t** nodes, int nb_nodes, void*
                return -1;
        }
 
-       scf_3ac_code_t* jmp_end = scf_3ac_jmp_code(jmp_op, NULL, NULL);
+       scf_3ac_code_t* jmp_end = scf_3ac_jmp_code(jmp_op, NULL);
        scf_list_add_tail(d->_3ac_list_head, &jmp_end->list);
 
        scf_branch_ops_t* local_branch_ops = scf_branch_ops_alloc();
@@ -1115,7 +1111,7 @@ static int _scf_op_vla_alloc(scf_ast_t* ast, scf_node_t** nodes, int nb_nodes, v
        if (!cmp)
                return -ENOMEM;
 
-       jgt = scf_3ac_jmp_code(SCF_OP_3AC_JGT, NULL, NULL);
+       jgt = scf_3ac_jmp_code(SCF_OP_3AC_JGT, NULL);
        if (!jgt) {
                scf_3ac_code_free(cmp);
                return -ENOMEM;
@@ -1194,7 +1190,7 @@ static int _scf_op_switch(scf_ast_t* ast, scf_node_t** nodes, int nb_nodes, void
                if (SCF_OP_CASE == child->type || SCF_OP_DEFAULT == child->type) {
 
                        if (jnot) {
-                               jnext = scf_3ac_jmp_code(SCF_OP_GOTO, NULL, NULL);
+                               jnext = scf_3ac_jmp_code(SCF_OP_GOTO, NULL);
 
                                scf_list_add_tail(d->_3ac_list_head, &jnext->list);
                                scf_vector_add(up_branch_ops->_breaks, jnext);
@@ -1229,7 +1225,7 @@ static int _scf_op_switch(scf_ast_t* ast, scf_node_t** nodes, int nb_nodes, void
                                else
                                        cmp = scf_3ac_code_NN(SCF_OP_3AC_TEQ, NULL, 0, &e2, 1);
 
-                               jnot = scf_3ac_jmp_code(SCF_OP_3AC_JNZ, NULL, NULL);
+                               jnot = scf_3ac_jmp_code(SCF_OP_3AC_JNZ, NULL);
 
                                scf_list_add_tail(d->_3ac_list_head, &cmp->list);
                                scf_list_add_tail(d->_3ac_list_head, &jnot->list);
@@ -1316,7 +1312,7 @@ static int _scf_op_for(scf_ast_t* ast, scf_node_t** nodes, int nb_nodes, void* d
                                return -1;
                        }
 
-                       jmp_end = scf_3ac_jmp_code(jmp_op, NULL, NULL);
+                       jmp_end = scf_3ac_jmp_code(jmp_op, NULL);
                        scf_list_add_tail(d->_3ac_list_head, &jmp_end->list);
                }
        }
@@ -1509,7 +1505,7 @@ static int _scf_op_new(scf_ast_t* ast, scf_node_t** nodes, int nb_nodes, void* d
                return ret;
        }
 
-       jz  = scf_3ac_jmp_code(SCF_OP_3AC_JZ, NULL, NULL);
+       jz  = scf_3ac_jmp_code(SCF_OP_3AC_JZ, NULL);
        scf_list_add_tail(d->_3ac_list_head, &jz->list);
 
        for (i = 3; i < nb_nodes; i++) {
@@ -1533,7 +1529,7 @@ static int _scf_op_new(scf_ast_t* ast, scf_node_t** nodes, int nb_nodes, void* d
                return ret;
        }
 
-       jmp = scf_3ac_jmp_code(SCF_OP_GOTO,   NULL, NULL);
+       jmp = scf_3ac_jmp_code(SCF_OP_GOTO,   NULL);
        scf_list_add_tail(d->_3ac_list_head, &jmp->list);
 
        scf_vector_add(d->branch_ops->_breaks, jz);
@@ -2378,7 +2374,7 @@ static int _scf_op_logic_##name(scf_ast_t* ast, scf_node_t** nodes, int nb_nodes
        if (jmp_op < 0) \
                return -1; \
        \
-       scf_3ac_code_t* jmp = scf_3ac_jmp_code(jmp_op, NULL, NULL); \
+       scf_3ac_code_t* jmp = scf_3ac_jmp_code(jmp_op, NULL); \
        if (!jmp) \
                return -ENOMEM; \
        \
index 7a06609f51d5e76f6a2697abf8af14f6a02d39de..732b59efc6e8f22247d5bd7368306309d3601da1 100644 (file)
@@ -1,93 +1,58 @@
 #include"scf_ast.h"
 
-scf_scope_t* scf_scope_alloc(scf_lex_word_t* w, const char* name)
+scf_scope_t* scf_scope_alloc()
 {
        scf_scope_t* scope = calloc(1, sizeof(scf_scope_t));
        if (!scope)
                return NULL;
 
-       scope->name = scf_string_cstr(name);
-       if (!scope->name) {
-               free(scope);
-               return NULL;
-       }
-
        scope->vars = scf_vector_alloc();
        if (!scope->vars) {
-               scf_string_free(scope->name);
                free(scope);
                return NULL;
        }
 
-       if (w) {
-               scope->w = scf_lex_word_clone(w);
-
-               if (!scope->w) {
-                       scf_vector_free(scope->vars);
-                       scf_string_free(scope->name);
-                       free(scope);
-                       return NULL;
-               }
-       }
-
        scf_list_init(&scope->list);
-       scf_list_init(&scope->type_list_head);
-       scf_list_init(&scope->operator_list_head);
-       scf_list_init(&scope->function_list_head);
-       scf_list_init(&scope->label_list_head);
+       scf_list_init(&scope->types);
+       scf_list_init(&scope->operators);
+       scf_list_init(&scope->functions);
+       scf_list_init(&scope->labels);
        return scope;
 }
 
 void scf_scope_push_var(scf_scope_t* scope, scf_variable_t* var)
 {
-       assert(scope);
-       assert(var);
        scf_vector_add(scope->vars, var);
 }
 
 void scf_scope_push_type(scf_scope_t* scope, scf_type_t* t)
 {
-       assert(scope);
-       assert(t);
-       scf_list_add_front(&scope->type_list_head, &t->list);
+       scf_list_add_front(&scope->types, &t->list);
 }
 
 void scf_scope_push_operator(scf_scope_t* scope, scf_function_t* op)
 {
-       assert(scope);
-       assert(op);
-       scf_list_add_front(&scope->operator_list_head, &op->list);
+       scf_list_add_front(&scope->operators, &op->list);
 }
 
 void scf_scope_push_function(scf_scope_t* scope, scf_function_t* f)
 {
-       assert(scope);
-       assert(f);
-       scf_list_add_front(&scope->function_list_head, &f->list);
+       scf_list_add_front(&scope->functions, &f->list);
 }
 
 void scf_scope_push_label(scf_scope_t* scope, scf_label_t* l)
 {
-       assert(scope);
-       assert(l);
-       scf_list_add_front(&scope->label_list_head, &l->list);
+       scf_list_add_front(&scope->labels, &l->list);
 }
 
 void scf_scope_free(scf_scope_t* scope)
 {
        if (scope) {
-               scf_string_free(scope->name);
-               scope->name = NULL;
-
-               if (scope->w)
-                       scf_lex_word_free(scope->w);
-
                scf_vector_clear(scope->vars, (void (*)(void*))scf_variable_free);
                scf_vector_free(scope->vars);
                scope->vars = NULL;
 
-               scf_list_clear(&scope->type_list_head, scf_type_t, list, scf_type_free);
-               scf_list_clear(&scope->function_list_head, scf_function_t, list, scf_function_free);
+               scf_list_clear(&scope->labels, scf_label_t, list, scf_label_free);
 
                free(scope);
        }
@@ -98,7 +63,7 @@ scf_type_t*   scf_scope_find_type(scf_scope_t* scope, const char* name)
        scf_type_t* t;
        scf_list_t* l;
 
-       for (l = scf_list_head(&scope->type_list_head); l != scf_list_sentinel(&scope->type_list_head); l = scf_list_next(l)) {
+       for (l = scf_list_head(&scope->types); l != scf_list_sentinel(&scope->types); l = scf_list_next(l)) {
                t  = scf_list_data(l, scf_type_t, list);
 
                if (!strcmp(name, t->name->data)) {
@@ -113,10 +78,10 @@ scf_type_t*        scf_scope_find_type_type(scf_scope_t* scope, const int type)
        scf_type_t* t;
        scf_list_t* l;
 
-       for (l = scf_list_head(&scope->type_list_head); l != scf_list_sentinel(&scope->type_list_head); l = scf_list_next(l)) {
+       for (l = scf_list_head(&scope->types); l != scf_list_sentinel(&scope->types); l = scf_list_next(l)) {
                t  = scf_list_data(l, scf_type_t, list);
 
-               if (type == t->type)
+               if (type == t->node.type)
                        return t;
        }
        return NULL;
@@ -141,7 +106,7 @@ scf_label_t* scf_scope_find_label(scf_scope_t* scope, const char* name)
        scf_label_t* label;
        scf_list_t*  l;
 
-       for (l    = scf_list_head(&scope->label_list_head); l != scf_list_sentinel(&scope->label_list_head); l = scf_list_next(l)) {
+       for (l    = scf_list_head(&scope->labels); l != scf_list_sentinel(&scope->labels); l = scf_list_next(l)) {
                label = scf_list_data(l, scf_label_t, list);
 
                if (!strcmp(name, label->w->text->data))
@@ -155,7 +120,7 @@ scf_function_t*     scf_scope_find_function(scf_scope_t* scope, const char* name)
        scf_function_t* f;
        scf_list_t*     l;
 
-       for (l = scf_list_head(&scope->function_list_head); l != scf_list_sentinel(&scope->function_list_head); l = scf_list_next(l)) {
+       for (l = scf_list_head(&scope->functions); l != scf_list_sentinel(&scope->functions); l = scf_list_next(l)) {
                f  = scf_list_data(l, scf_function_t, list);
 
                if (!strcmp(name, f->node.w->text->data))
@@ -169,7 +134,7 @@ scf_function_t*     scf_scope_find_same_function(scf_scope_t* scope, scf_function_t*
        scf_function_t* f1;
        scf_list_t*     l;
 
-       for (l = scf_list_head(&scope->function_list_head); l != scf_list_sentinel(&scope->function_list_head); l = scf_list_next(l)) {
+       for (l = scf_list_head(&scope->functions); l != scf_list_sentinel(&scope->functions); l = scf_list_next(l)) {
                f1 = scf_list_data(l, scf_function_t, list);
 
                if (scf_function_same(f0, f1))
@@ -188,7 +153,7 @@ int scf_scope_find_like_functions(scf_vector_t** pfunctions, scf_scope_t* scope,
        if (!vec)
                return -ENOMEM;
 
-       for (l = scf_list_head(&scope->function_list_head); l != scf_list_sentinel(&scope->function_list_head); l = scf_list_next(l)) {
+       for (l = scf_list_head(&scope->functions); l != scf_list_sentinel(&scope->functions); l = scf_list_next(l)) {
                f  = scf_list_data(l, scf_function_t, list);
 
                if (strcmp(f->node.w->text->data, name))
@@ -223,7 +188,7 @@ int scf_scope_find_overloaded_functions(scf_vector_t** pfunctions, scf_scope_t*
        if (!vec)
                return -ENOMEM;
 
-       for (l = scf_list_head(&scope->operator_list_head); l != scf_list_sentinel(&scope->operator_list_head); l = scf_list_next(l)) {
+       for (l = scf_list_head(&scope->operators); l != scf_list_sentinel(&scope->operators); l = scf_list_next(l)) {
                f  = scf_list_data(l, scf_function_t, list);
 
                if (op_type != f->op_type)
index 53ef96ad5a3902223a572ca87c2c6f6d874f0fb6..ac823f19b2db20c1c63259ec80b5063d2b2df3d4 100644 (file)
@@ -6,37 +6,30 @@
 #include"scf_lex_word.h"
 #include"scf_core_types.h"
 
-struct scf_scope_s {
-       scf_list_t                      list; // scope list
-       scf_string_t*           name; // scope name
-
-       scf_lex_word_t*         w; // scope name
-
-       scf_vector_t*       vars;               // vars in this scope, should not have the same name
-       scf_list_t                      type_list_head; // type list in this scope, not define the same type
-       scf_list_t                      operator_list_head; // operator list in this scope
-       scf_list_t                      function_list_head; // function list in this scope
-       scf_list_t                      label_list_head; // label list in this scope
+struct scf_scope_s
+{
+       scf_list_t          list; // scope list
+
+       scf_vector_t*       vars;          // vars in this scope, should not have the same name
+       scf_list_t          types;     // type list in this scope, not define the same type
+       scf_list_t          operators; // operator list in this scope
+       scf_list_t          functions; // function list in this scope
+       scf_list_t          labels;    // label list in this scope
 };
 
-scf_scope_t*    scf_scope_alloc(scf_lex_word_t* w, const char* name);
-void            scf_scope_free( scf_scope_t*    scope);
+scf_scope_t*    scf_scope_alloc();
+void            scf_scope_free(scf_scope_t* scope);
 
-void            scf_scope_push_var(scf_scope_t* scope, scf_variable_t* var);
-
-void            scf_scope_push_type(scf_scope_t* scope, scf_type_t* t);
+void            scf_scope_push_var (scf_scope_t* scope, scf_variable_t* var);
+void            scf_scope_push_type(scf_scope_t* scope, scf_type_t*     t);
 
 void            scf_scope_push_operator(scf_scope_t* scope, scf_function_t* op);
-
 void            scf_scope_push_function(scf_scope_t* scope, scf_function_t* f);
 
-scf_type_t*     scf_scope_find_type(scf_scope_t* scope, const char* name);
-
-scf_type_t*     scf_scope_find_type_type(scf_scope_t* scope, const int type);
-
-scf_variable_t* scf_scope_find_variable(scf_scope_t* scope, const char* name);
-
-scf_function_t* scf_scope_find_function(scf_scope_t* scope, const char* name);
+scf_type_t*     scf_scope_find_type     (scf_scope_t* scope, const char* name);
+scf_type_t*     scf_scope_find_type_type(scf_scope_t* scope, const int   type);
+scf_variable_t* scf_scope_find_variable (scf_scope_t* scope, const char* name);
+scf_function_t* scf_scope_find_function (scf_scope_t* scope, const char* name);
 
 scf_function_t*        scf_scope_find_same_function(scf_scope_t* scope, scf_function_t* f0);
 
index 5a13a3aa093110b540717c0f015ea2cb32b4e457..94455a5a29f8824d69634c5b7492f495439386dd 100644 (file)
@@ -7,7 +7,6 @@ scf_type_t* scf_type_alloc(scf_lex_word_t* w, const char* name, int type, int si
        if (!t)
                return NULL;
 
-       t->type      = type;
        t->node.type = type;
 
        t->name = scf_string_cstr(name);
@@ -17,8 +16,8 @@ scf_type_t* scf_type_alloc(scf_lex_word_t* w, const char* name, int type, int si
        }
 
        if (w) {
-               t->w = scf_lex_word_clone(w);
-               if (!t->w) {
+               t->node.w = scf_lex_word_clone(w);
+               if (!t->node.w) {
                        scf_string_free(t->name);
                        free(t);
                        return NULL;
@@ -35,18 +34,12 @@ void scf_type_free(scf_type_t* t)
                scf_string_free(t->name);
                t->name = NULL;
 
-               if (t->w) {
-                       scf_lex_word_free(t->w);
-                       t->w = NULL;
-               }
-
                if (t->scope) {
                        scf_scope_free(t->scope);
                        t->scope = NULL;
                }
 
-               free(t);
-               t = NULL;
+               scf_node_free((scf_node_t*)t);
        }
 }
 
@@ -54,6 +47,7 @@ static scf_type_abbrev_t  type_abbrevs[] =
 {
        {"int",       "i"},
        {"void",      "v"},
+       {"bool",      "B"},
 
        {"char",      "c"},
        {"float",     "f"},
index efb3a1592a4cc645f38666c55c9ea3bd538477d7..3ece46b06df740767f10f0fe32d66eb4c7a00878 100644 (file)
@@ -4,8 +4,8 @@
 #include"scf_node.h"
 
 typedef struct {
-       int                                     type;
        const char*                     name;
+       int                                     type;
        int                                     size;
 } scf_base_type_t;
 
@@ -14,20 +14,16 @@ typedef struct {
        const char*         abbrev;
 } scf_type_abbrev_t;
 
-struct scf_type_s {
+struct scf_type_s
+{
        // same as block, only used for class type
        scf_node_t          node;
-
        scf_scope_t*        scope;
-
        scf_string_t*       name;
 
        // list for scope's type_list_head
        scf_list_t                      list;
 
-       int                                     type;
-       scf_lex_word_t*         w;
-
        int                                     nb_pointers;
 //     int                                     array_capacity;
 
@@ -45,4 +41,3 @@ void                  scf_type_free(scf_type_t* t);
 const char*     scf_type_find_abbrev(const char* name);
 
 #endif
-
index 96197d20ae567ef7952ae62fd43e235ade2f0902..bcd9cdb1539fc5c8a456865ba4d166d162f5d563 100644 (file)
@@ -98,7 +98,7 @@ scf_variable_t*       scf_variable_alloc(scf_lex_word_t* w, scf_type_t* t)
                return NULL;
 
        v->refs = 1;
-       v->type = t->type;
+       v->type = t->node.type;
 
        v->const_flag  = t->node.const_flag;
        v->nb_pointers = t->nb_pointers;
index 2e8794470281593f6ec2cde9a1d26dca39d99067..be6d60438b3e021210a1f3d760df6a99f6631c55 100644 (file)
@@ -54,7 +54,7 @@ static int _class_action_identity(scf_dfa_t* dfa, scf_vector_t* words, void* dat
        md->parent_block     = parse->ast->current_block;
        SCF_DFA_PUSH_HOOK(scf_dfa_find_node(dfa, "class_end"), SCF_DFA_HOOK_END);
 
-       scf_logi("\033[31m t: %p, t->type: %d\033[0m\n", t, t->type);
+       scf_logi("\033[31m t: %p, t->type: %d\033[0m\n", t, t->node.type);
 
        return SCF_DFA_NEXT_WORD;
 }
index 5a2ac2b7ba69a21f245488acc5fb2409fc28062b..03d1bbbd5bba19e2f915eeb610dc54a4a5fb852d 100644 (file)
@@ -120,7 +120,7 @@ static int _container_action_comma(scf_dfa_t* dfa, scf_vector_t* words, void* da
                                return SCF_DFA_ERROR;
                        }
 
-                       if (id->type->type < SCF_STRUCT) {
+                       if (id->type->node.type < SCF_STRUCT) {
                                scf_loge("'%s' is not a class or struct\n", w->text->data);
                                free(id);
                                return SCF_DFA_ERROR;
index 2e7fe3299978ac16d9804d28ec0ca09e5258c2e3..14f4394d86002e0229f9b347dd1ee1b8adfc180c 100644 (file)
@@ -59,7 +59,7 @@ int _function_add_function(scf_dfa_t* dfa, dfa_data_t* d)
                        return SCF_DFA_ERROR;
                }
 
-               if (SCF_VAR_VOID == id->type->type && 0 == id->nb_pointers)
+               if (SCF_VAR_VOID == id->type->node.type && 0 == id->nb_pointers)
                        void_flag = 1;
 
                f->extern_flag |= id->extern_flag;
@@ -152,7 +152,7 @@ int _function_add_arg(scf_dfa_t* dfa, dfa_data_t* d)
                if (v && v->identity)
                        w = v->identity;
 
-               if (SCF_VAR_VOID == t->type->type && 0 == t->nb_pointers) {
+               if (SCF_VAR_VOID == t->type->node.type && 0 == t->nb_pointers) {
                        scf_loge("\n");
                        return SCF_DFA_ERROR;
                }
index b3ea503d033040e30bfb5c99946e0e99d62319f7..2c035d5f65de93027138b4b85b3cf550148b1ac3 100644 (file)
@@ -31,11 +31,9 @@ static int _goto_action_identity(scf_dfa_t* dfa, scf_vector_t* words, void* data
        scf_parse_t*      parse  = dfa->priv;
        dfa_data_t*       d      = data;
        scf_lex_word_t*   w      = words->data[words->size - 1];
+       scf_node_t*       node   = scf_node_alloc(w, SCF_LABEL, NULL);
 
-       scf_label_t*      l      = scf_label_alloc(w);
-       scf_node_t*       n      = scf_node_alloc_label(l);
-
-       scf_node_add_child(d->current_goto, n);
+       scf_node_add_child(d->current_goto, node);
 
        return SCF_DFA_NEXT_WORD;
 }
index a017cf7a961016ba770939914c09a22921c4f692..f8679fa453fff4bbfb9403b655a7705edc84120c 100644 (file)
@@ -16,7 +16,7 @@ static int _label_action_colon(scf_dfa_t* dfa, scf_vector_t* words, void* data)
        }
 
        scf_label_t* l = scf_label_alloc(id->identity);
-       scf_node_t*  n = scf_node_alloc_label(l);
+       scf_node_t*  n = scf_node_alloc(l->w, SCF_LABEL, NULL);
 
        scf_stack_pop(d->current_identities);
        free(id);
@@ -24,6 +24,7 @@ static int _label_action_colon(scf_dfa_t* dfa, scf_vector_t* words, void* data)
 
        scf_node_add_child((scf_node_t*)parse->ast->current_block, n);
 
+       l->node = n;
        scf_scope_push_label(parse->ast->current_block->scope, l);
 
        return SCF_DFA_OK;
index 5ef9055a4eefdcf09eab8cab3c25c3df5eaeab7e..7e72383bd701c3d5dc59d0b974571003d93bba14 100644 (file)
@@ -132,7 +132,7 @@ int _type_find_type(scf_dfa_t* dfa, dfa_identity_t* id)
                        }
                }
 
-               if (SCF_FUNCTION_PTR == id->type->type) {
+               if (SCF_FUNCTION_PTR == id->type->node.type) {
 
                        id->func_ptr = _type_find_function(parse->ast->current_block, id->identity->text->data);
 
index 0a4dc98a2279dfb654300499a3009b84c552ac9c..918690cb96637129b2667adcc66a1991dea0aa69 100644 (file)
@@ -120,7 +120,7 @@ static int _va_arg_action_ap(scf_dfa_t* dfa, scf_vector_t* words, void* data)
        }
        assert(t);
 
-       if (t->type != ap->type || 0 != ap->nb_dimentions) {
+       if (t->node.type != ap->type || 0 != ap->nb_dimentions) {
                scf_loge("variable %s is not va_list type\n", w->text->data);
                return SCF_DFA_ERROR;
        }
index b911d12492d4f0158804e1fdbaecec9be0d2dab3..c626f5615548bb9b9057b2ecf7bbbda0ea153cbb 100644 (file)
@@ -8,8 +8,8 @@ int _expr_multi_rets(scf_expr_t* e);
 
 int _check_recursive(scf_type_t* parent, scf_type_t* child, scf_lex_word_t* w)
 {
-       if (child->type == parent->type) {
-       
+       if (child->node.type == parent->node.type) {
+
                scf_loge("recursive define '%s' type member var '%s' in type '%s', line: %d\n",
                                child->name->data, w->text->data, parent->name->data, w->line);
 
@@ -17,7 +17,7 @@ int _check_recursive(scf_type_t* parent, scf_type_t* child, scf_lex_word_t* w)
        }
 
        if (child->scope) {
-               assert(child->type >= SCF_STRUCT);
+               assert(child->node.type >= SCF_STRUCT);
 
                scf_variable_t* v      = NULL;
                scf_type_t*     type_v = NULL;
@@ -84,7 +84,7 @@ static int _var_add_var(scf_dfa_t* dfa, dfa_data_t* d)
                        global_flag = 0;
                        member_flag = 1;
 
-                       if (0 == id0->nb_pointers && id0->type->type >= SCF_STRUCT) {
+                       if (0 == id0->nb_pointers && id0->type->node.type >= SCF_STRUCT) {
                                // if not pointer var, check if define recursive struct/union/class var
 
                                if (_check_recursive((scf_type_t*)b, id0->type, id->identity) < 0) {
@@ -96,7 +96,7 @@ static int _var_add_var(scf_dfa_t* dfa, dfa_data_t* d)
                        }
                }
 
-               if (SCF_FUNCTION_PTR == id0->type->type
+               if (SCF_FUNCTION_PTR == id0->type->node.type
                                && (!id0->func_ptr || 0 == id0->nb_pointers)) {
                        scf_loge("invalid func ptr\n");
                        return SCF_DFA_ERROR;
@@ -115,7 +115,7 @@ static int _var_add_var(scf_dfa_t* dfa, dfa_data_t* d)
                        }
                }
 
-               if (SCF_VAR_VOID == id0->type->type && 0 == id0->nb_pointers) {
+               if (SCF_VAR_VOID == id0->type->node.type && 0 == id0->nb_pointers) {
                        scf_loge("void var must be a pointer, like void*\n");
                        return SCF_DFA_ERROR;
                }
index 5655a3b10b02bb942b86ef5e1b0102d053ae87e6..6ba2ae3fb0bad0826d3179efdd483507acf07c22 100644 (file)
@@ -150,7 +150,7 @@ static int _semantic_do_type_cast(scf_ast_t* ast, scf_node_t** nodes, int nb_nod
        if (!v_std)
                return -ENOMEM;
 
-       if (t->type != v0->type) {
+       if (t->node.type != v0->type) {
                ret = _semantic_add_type_cast(ast, &nodes[0], v_std, nodes[0]);
                if (ret < 0) {
                        scf_loge("add type cast failed\n");
@@ -158,7 +158,7 @@ static int _semantic_do_type_cast(scf_ast_t* ast, scf_node_t** nodes, int nb_nod
                }
        }
 
-       if (t->type != v1->type) {
+       if (t->node.type != v1->type) {
                ret = _semantic_add_type_cast(ast, &nodes[1], v_std, nodes[1]);
                if (ret < 0) {
                        scf_loge("add type cast failed\n");
@@ -467,12 +467,12 @@ static int _semantic_do_new(scf_ast_t* ast, scf_node_t** nodes, int nb_nodes, sc
        if (!new)
                return -ENOMEM;
 
-       v_pf = SCF_VAR_ALLOC_BY_TYPE(t->w, pt, 1, 1, NULL);
+       v_pf = SCF_VAR_ALLOC_BY_TYPE(t->node.w, pt, 1, 1, NULL);
        if (!v_pf)
                return -ENOMEM;
        v_pf->const_literal_flag = 1;
 
-       node_pf = scf_node_alloc(t->w, v_pf->type, v_pf);
+       node_pf = scf_node_alloc(t->node.w, v_pf->type, v_pf);
        if (!node_pf)
                return -ENOMEM;
 
@@ -727,7 +727,7 @@ static int _scf_op_semantic_new(scf_ast_t* ast, scf_node_t** nodes, int nb_nodes
        if (!argv)
                return -ENOMEM;
 
-       ret = _semantic_add_var(&nthis, ast, NULL, v0->w, class->type, 0, 1, NULL);
+       ret = _semantic_add_var(&nthis, ast, NULL, v0->w, class->node.type, 0, 1, NULL);
        if (ret < 0) {
                scf_vector_free(argv);
                return ret;
@@ -1149,11 +1149,8 @@ static int _scf_op_semantic_goto(scf_ast_t* ast, scf_node_t** nodes, int nb_node
        scf_node_t* nl = nodes[0];
        assert(SCF_LABEL == nl->type);
 
-       scf_label_t* l = nl->label;
-       assert(l->w);
-
-       scf_label_t* l2 = scf_block_find_label(ast->current_block, l->w->text->data);
-       if (!l2) {
+       scf_label_t* l = scf_block_find_label(ast->current_block, nl->w->text->data);
+       if (!l) {
                scf_loge("label '%s' not found\n", l->w->text->data);
                return -1;
        }
@@ -2425,7 +2422,7 @@ static int _scf_op_semantic_binary(scf_ast_t* ast, scf_node_t** nodes, int nb_no
                                if (ret < 0)
                                        return ret;
 
-                               if (t->type != v0->type)
+                               if (t->node.type != v0->type)
                                        ret = _semantic_add_type_cast(ast, &nodes[0], v1, nodes[0]);
                                else
                                        ret = _semantic_add_type_cast(ast, &nodes[1], v0, nodes[1]);
index fc05258f36a5c89d456301605d5e8d2745db0fd0..6e1151951339ad96515dbcdb8a096d7c0fea2e8b 100644 (file)
 #include"scf_leb128.h"
 #include"scf_eda.h"
 
-scf_base_type_t        base_types[] =
+scf_base_type_t  base_types[] =
 {
-       {SCF_VAR_CHAR,          "char",           1},
-
-       {SCF_VAR_VOID,      "void",       1},
-       {SCF_VAR_BIT,       "bit",        1},
-       {SCF_VAR_U2,        "bit2_t",     1},
-       {SCF_VAR_U3,        "bit3_t",     1},
-       {SCF_VAR_U4,        "bit4_t",     1},
-
-       {SCF_VAR_I1,        "int1_t",     1},
-       {SCF_VAR_I2,        "int2_t",     1},
-       {SCF_VAR_I3,        "int3_t",     1},
-       {SCF_VAR_I4,        "int4_t",     1},
-
-       {SCF_VAR_INT,           "int",            4},
-       {SCF_VAR_FLOAT,     "float",      4},
-       {SCF_VAR_DOUBLE,        "double",         8},
-
-       {SCF_VAR_I8,        "int8_t",     1},
-       {SCF_VAR_I16,       "int16_t",    2},
-       {SCF_VAR_I32,       "int32_t",    4},
-       {SCF_VAR_I64,       "int64_t",    8},
-
-       {SCF_VAR_U8,        "uint8_t",    1},
-       {SCF_VAR_U16,       "uint16_t",   2},
-       {SCF_VAR_U32,       "uint32_t",   4},
-       {SCF_VAR_U64,       "uint64_t",   8},
-
-       {SCF_VAR_INTPTR,    "intptr_t",   sizeof(void*)},
-       {SCF_VAR_UINTPTR,   "uintptr_t",  sizeof(void*)},
-       {SCF_FUNCTION_PTR,  "funcptr",    sizeof(void*)},
+       {"char",      SCF_VAR_CHAR,   1},
+       {"void",      SCF_VAR_VOID,   1},
+
+       {"bit",       SCF_VAR_BIT,    1},
+       {"bit2_t",    SCF_VAR_U2,     1},
+       {"bit3_t",    SCF_VAR_U3,     1},
+       {"bit4_t",    SCF_VAR_U4,     1},
+
+       {"int1_t",    SCF_VAR_I1,     1},
+       {"int2_t",    SCF_VAR_I2,     1},
+       {"int3_t",    SCF_VAR_I3,     1},
+       {"int4_t",    SCF_VAR_I4,     1},
+
+       {"int",       SCF_VAR_INT,    4},
+       {"float",     SCF_VAR_FLOAT,  4},
+       {"double",    SCF_VAR_DOUBLE, 8},
+
+       {"int8_t",    SCF_VAR_I8,     1},
+       {"int16_t",   SCF_VAR_I16,    2},
+       {"int32_t",   SCF_VAR_I32,    4},
+       {"int64_t",   SCF_VAR_I64,    8},
+
+       {"uint8_t",   SCF_VAR_U8,     1},
+       {"uint16_t",  SCF_VAR_U16,    2},
+       {"uint32_t",  SCF_VAR_U32,    4},
+       {"uint64_t",  SCF_VAR_U64,    8},
+
+       {"intptr_t",  SCF_VAR_INTPTR,   sizeof(void*)},
+       {"uintptr_t", SCF_VAR_UINTPTR,  sizeof(void*)},
+       {"funcptr",   SCF_FUNCTION_PTR, sizeof(void*)},
 };
 
 int    scf_parse_open(scf_parse_t** pparse)
@@ -193,7 +193,7 @@ static scf_dwarf_info_entry_t* _debug_find_type(scf_parse_t* parse, scf_type_t*
                tag   = DW_TAG_pointer_type;
                types = parse->debug->base_types;
 
-       } else if (t->type < SCF_STRUCT) {
+       } else if (t->node.type < SCF_STRUCT) {
 
                tag   = DW_TAG_base_type;
                types = parse->debug->base_types;
@@ -217,7 +217,7 @@ static scf_dwarf_info_entry_t* _debug_find_type(scf_parse_t* parse, scf_type_t*
 
                assert(ie->attributes->size == d->attributes->size);
 
-               if (ie->type == t->type && ie->nb_pointers == nb_pointers)
+               if (ie->type == t->node.type && ie->nb_pointers == nb_pointers)
                        return ie;
 #if 0
                for (j = 0; j < d ->attributes->size; j++) {
@@ -264,7 +264,7 @@ static int __debug_add_type(scf_dwarf_info_entry_t** pie, scf_dwarf_abbrev_decla
 
                types = parse->debug->base_types;
 
-       } else if (t->type < SCF_STRUCT) {
+       } else if (t->node.type < SCF_STRUCT) {
 
                d = scf_vector_find_cmp(parse->debug->abbrevs, (void*)DW_TAG_base_type, _debug_abbrev_find_by_tag);
                if (!d) {
@@ -302,7 +302,7 @@ static int __debug_add_type(scf_dwarf_info_entry_t** pie, scf_dwarf_abbrev_decla
                return -ENOMEM;
        ie->code = d->code;
 
-       ie->type = t->type;
+       ie->type = t->node.type;
        ie->nb_pointers = nb_pointers;
 
        ret = scf_vector_add(types, ie);
@@ -345,19 +345,19 @@ static int __debug_add_type(scf_dwarf_info_entry_t** pie, scf_dwarf_abbrev_decla
 
                        uint8_t ate;
 
-                       if (SCF_VAR_CHAR == t->type || SCF_VAR_I8 == t->type)
+                       if (SCF_VAR_CHAR == t->node.type || SCF_VAR_I8 == t->node.type)
                                ate = DW_ATE_signed_char;
 
-                       else if (scf_type_is_signed(t->type))
+                       else if (scf_type_is_signed(t->node.type))
                                ate = DW_ATE_signed;
 
-                       else if (SCF_VAR_U8 == t->type)
+                       else if (SCF_VAR_U8 == t->node.type)
                                ate = DW_ATE_unsigned_char;
 
-                       else if (scf_type_is_unsigned(t->type))
+                       else if (scf_type_is_unsigned(t->node.type))
                                ate = DW_ATE_unsigned;
 
-                       else if (scf_type_is_float(t->type))
+                       else if (scf_type_is_float(t->node.type))
                                ate = DW_ATE_float;
                        else {
                                scf_loge("\n");
@@ -384,7 +384,7 @@ static int __debug_add_type(scf_dwarf_info_entry_t** pie, scf_dwarf_abbrev_decla
 
                } else if (DW_AT_decl_line == iattr->name) {
 
-                       ret = scf_dwarf_info_fill_attr(iattr, (uint8_t*)&t->w->line, sizeof(t->w->line));
+                       ret = scf_dwarf_info_fill_attr(iattr, (uint8_t*)&t->node.w->line, sizeof(t->node.w->line));
                        if (ret < 0)
                                return ret;
 
@@ -634,7 +634,7 @@ static int _debug_add_struct_type(scf_dwarf_info_entry_t** pie, scf_dwarf_abbrev
 
                                v_member  = t->scope->vars->data[i];
 
-                               if (v_member->type != t->type)
+                               if (v_member->type != t->node.type)
                                        continue;
 
                                if (v_member->nb_pointers != j)
@@ -677,7 +677,7 @@ static int _debug_add_type(scf_dwarf_info_entry_t** pie, scf_parse_t* parse, scf
        ie = _debug_find_type(parse, t, 0);
        if (!ie) {
 
-               if (t->type < SCF_STRUCT) {
+               if (t->node.type < SCF_STRUCT) {
 
                        ret = __debug_add_type(&ie, &d, parse, t, 0, NULL);
                        if (ret < 0)
index 216b91513cfed7508d0556dbc341c5753d000d8d..32ac1818268257e56bab5a07fc27025a3a2d78b4 100644 (file)
@@ -87,11 +87,6 @@ struct dfa_data_s {
 
        scf_node_t*          current_node;
 
-       scf_node_t*          current_while;
-
-       scf_node_t*          current_for;
-       scf_vector_t*        for_exprs;
-
        scf_node_t*          current_return;
        scf_node_t*          current_goto;