list_free(oldstate->wildcard_imports);
dict_destroy(oldstate->imports);oldstate->imports=0;
}
- if(state->method)
- state->method->initcode =
- code_append(state->method->initcode,
- oldstate->method->initcode);
}
void initialize_state()
{
code_t*defaultvalue(code_t*c, classinfo_t*type)
{
- if(TYPE_IS_INT(type) || TYPE_IS_UINT(type) || TYPE_IS_FLOAT(type)) {
+ if(TYPE_IS_INT(type)) {
c = abc_pushbyte(c, 0);
+ } else if(TYPE_IS_UINT(type)) {
+ c = abc_pushuint(c, 0);
+ } else if(TYPE_IS_FLOAT(type)) {
+ c = abc_pushdouble(c, 0.0);
} else if(TYPE_IS_BOOLEAN(type)) {
c = abc_pushfalse(c);
} else {
//MAYBEELSE: ';' "else" CODEBLOCK {$$=$3;}
IF : "if" '(' {new_state();} EXPRESSION ')' CODEBLOCK MAYBEELSE {
- $$ = state->method->initcode;state->method->initcode=0;
-
+ $$ = code_new();
$$ = code_append($$, $4.c);
code_t*myjmp,*myif = $$ = abc_iffalse($$, 0);
FOR_INIT : VOIDEXPRESSION
FOR : "for" '(' {new_state();} FOR_INIT ';' EXPRESSION ';' VOIDEXPRESSION ')' CODEBLOCK {
- $$ = state->method->initcode;state->method->initcode=0;
-
+ $$ = code_new();
$$ = code_append($$, $4);
code_t*loopstart = $$ = abc_label($$);
$$ = code_append($$, $6.c);
}
WHILE : "while" '(' {new_state();} EXPRESSION ')' CODEBLOCK {
- $$ = state->method->initcode;state->method->initcode=0;
-
+ $$ = code_new();
code_t*myjmp = $$ = abc_jump($$, 0);
code_t*loopstart = $$ = abc_label($$);
$$ = code_append($$, $6);