From c7c587d258ae768c3796b0ffd7d4b6951a1daab0 Mon Sep 17 00:00:00 2001 From: kramm Date: Fri, 2 Jan 2009 19:49:57 +0000 Subject: [PATCH] construct superclass in default constructor --- lib/as3/parser.y | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/as3/parser.y b/lib/as3/parser.y index 5aeee28..7023420 100644 --- a/lib/as3/parser.y +++ b/lib/as3/parser.y @@ -250,6 +250,7 @@ typedef struct _classstate { abc_class_t*abc; code_t*init; code_t*static_init; + char has_constructor; } classstate_t; typedef struct _methodstate { @@ -609,6 +610,13 @@ static code_t* wrap_function(code_t*c,code_t*initcode, code_t*body) static void endclass() { + if(!state->cls->has_constructor) { + code_t*c = 0; + c = abc_getlocal_0(c); + c = abc_constructsuper(c, 0); + state->cls->init = code_append(state->cls->init, c); + } + if(state->cls->init) { abc_method_t*m = abc_class_getconstructor(state->cls->abc, 0); m->body->code = wrap_function(0, state->cls->init, m->body->code); @@ -789,6 +797,8 @@ static void startfunction(token_t*ns, int flags, enum yytokentype getset, char*n state->method->initcode = 0; state->method->is_constructor = !strcmp(state->cls->info->name,name); state->method->has_super = 0; + + state->cls->has_constructor |= state->method->is_constructor; global->variable_count = 0; -- 1.7.10.4