// that started code generation here.
classScope.callVisitEnds();
{
// Synthesize a constructor.
iinfo.iInit = new MethodInfo();
MethodBodyInfo iinit = new MethodBodyInfo();
iinit.setMethodInfo(iinfo.iInit);
IMethodVisitor mv = emitter.visitMethod(iinfo.iInit);
mv.visit();
IMethodBodyVisitor mbv = mv.visitBody(iinit);
InstructionList ctor_insns = new InstructionList();
// Don't even think of removing these instructions!
// there is lots of code we are generating that assumes that the
// scopes and such are set up like this!!
// In particular the data binding code may create anonymous function objects
// in the constructor that assume "this" is already on the scope stack.
ctor_insns.addInstruction(OP_getlocal0);
ctor_insns.addInstruction(OP_pushscope);
// iinitInsns go before the constructsuper opcode.
ctor_insns.addAll(iinitInsns);
// Call the superclass' constructor after the instance
// init instructions; this doesn't seem like an abstractly
// correct sequence, but it's what ASC does.
ctor_insns.addInstruction(OP_getlocal0);
ctor_insns.addInstruction(OP_constructsuper, 0);
// initialize currentState to first state
// this has to go before other iinit because
// otherwise setCurrentState will fire off transitions
setCurrentState(ctor_insns);
if (!getProject().getTargetSettings().getMxmlChildrenAsData())
{
// iinitAfterSuperInsns go after the constructsuper opcode.
ctor_insns.addAll(iinitAfterSuperInsns);
}
else
{
if (!iinitForNonPublicProperties.isEmpty())
ctor_insns.addAll(iinitForNonPublicProperties);
}
// call the Binding helper to get all the data binding setup code
addBindingCodeForCtor(ctor_insns);
// add call to MXMLAttributes
if (getProject().getTargetSettings().getMxmlChildrenAsData() && numElements > 0)
{
// generateMXMLAttributes(attributes);
FunctionDefinition funcDef = (FunctionDefinition)SemanticUtils.findProperty(classDefinition.getContainedScope(),
"generateMXMLAttributes",
getProject(), false);
if (funcDef != null)
{
Name funcName = ((FunctionDefinition)funcDef).getMName(getProject());
ctor_insns.addInstruction(OP_getlocal0);
ctor_insns.addAll(mxmlPropertiesInsns);
ctor_insns.addInstruction(OP_callpropvoid, new Object[] {funcName, 1 });
}
}
ctor_insns.addInstruction(OP_returnvoid);
mbv.visit();
mbv.visitInstructionList(ctor_insns);
mbv.visitEnd();
mv.visitEnd();
}
// If the class has static variables with
// initialization instructions, emit a class
// init routine.
if (!cinitInsns.isEmpty())
{
cinfo.cInit = new MethodInfo();
MethodBodyInfo cinit_info = new MethodBodyInfo();
cinit_info.setMethodInfo(cinfo.cInit);
IMethodVisitor mv = emitter.visitMethod(cinfo.cInit);
mv.visit();