scf_node_t* n = (scf_node_t*)ast->current_block;
- while (n && (SCF_OP_WHILE != n->type && SCF_OP_FOR != n->type)) {
+ while (n
+ && SCF_OP_WHILE != n->type
+ && SCF_OP_REPEAT != n->type
+ && SCF_OP_FOR != n->type)
n = n->parent;
- }
if (!n) {
scf_loge("\n");
return -1;
}
- assert(SCF_OP_WHILE == n->type || SCF_OP_FOR == n->type);
+ assert(SCF_OP_WHILE == n->type || SCF_OP_FOR == n->type || SCF_OP_REPEAT == n->type);
scf_node_t* parent = n->parent;
assert(parent);
scf_node_t* n = (scf_node_t*)ast->current_block;
- while (n && (SCF_OP_WHILE != n->type && SCF_OP_FOR != n->type)) {
+ while (n
+ && SCF_OP_WHILE != n->type
+ && SCF_OP_REPEAT != n->type
+ && SCF_OP_FOR != n->type)
n = n->parent;
- }
if (!n) {
scf_loge("\n");
return -1;
}
- assert(SCF_OP_WHILE == n->type || SCF_OP_FOR == n->type);
+ assert(SCF_OP_WHILE == n->type || SCF_OP_FOR == n->type || SCF_OP_REPEAT == n->type);
scf_3ac_code_t* branch = scf_branch_ops_code(SCF_OP_GOTO, NULL, NULL);
--- /dev/null
+int printf(const char* fmt, ...);
+
+int main()
+{
+ const int i = 123;
+
+ printf("%d\n", i);
+
+ return 0;
+}
return SCF_LEX_WORD_KEY_END_IF == w->type;
}
+static inline int scf_dfa_is_continue(scf_dfa_t* dfa, void* word)
+{
+ scf_lex_word_t* w = word;
+
+ return SCF_LEX_WORD_KEY_CONTINUE == w->type;
+}
+
+static inline int scf_dfa_is_break(scf_dfa_t* dfa, void* word)
+{
+ scf_lex_word_t* w = word;
+
+ return SCF_LEX_WORD_KEY_BREAK == w->type;
+}
+
+static inline int scf_dfa_is_return(scf_dfa_t* dfa, void* word)
+{
+ scf_lex_word_t* w = word;
+
+ return SCF_LEX_WORD_KEY_RETURN == w->type;
+}
+
+static inline int scf_dfa_is_exit(scf_dfa_t* dfa, void* word)
+{
+ scf_lex_word_t* w = word;
+
+ return SCF_LEX_WORD_KEY_EXIT == w->type;
+}
+
static inline int scf_dfa_is_while(scf_dfa_t* dfa, void* word)
{
scf_lex_word_t* w = word;
d->expr_local_flag--;
- if (d->current_var->global_flag) {
+ if (d->current_var->global_flag
+ || (d->current_var->const_flag && 0 == d->current_var->nb_pointers + d->current_var->nb_dimentions)) {
scf_logw("d->expr: %p, d->current_var: %p, global_flag: %d\n",
d->expr, d->current_var, d->current_var->global_flag);
scf_node_t* n = (scf_node_t*)ast->current_block;
- while (n && (SCF_OP_WHILE != n->type && SCF_OP_FOR != n->type)) {
+ while (n
+ && SCF_OP_WHILE != n->type
+ && SCF_OP_REPEAT != n->type
+ && SCF_OP_FOR != n->type)
n = n->parent;
- }
if (!n) {
scf_loge("\n");
return -1;
}
- assert(SCF_OP_WHILE == n->type || SCF_OP_FOR == n->type);
+
+ assert(SCF_OP_WHILE == n->type || SCF_OP_FOR == n->type || SCF_OP_REPEAT == n->type);
if (!n->parent) {
scf_loge("\n");