{
transferWebServiceOperationsOrRemoteObjectMethods((IMXMLInstanceNode)node, childContext, parentContext);
}
IMXMLInstanceNode instanceNode = (IMXMLInstanceNode)childContext.node;
Name instanceClassName = childContext.instanceClassName;
if (!getProject().getTargetSettings().getMxmlChildrenAsData() && generateNonDescriptorCode)
{
callInitialized(instanceNode, childContext);
setDocument(instanceNode, true, childContext);
setDocumentDescriptorForInstance(instanceNode, childContext);
}
String id = instanceNode.getEffectiveID();
if (id != null)
{
Name idName = new Name(id);
// Create a reference variable in the class whose name is the id.
// For example, for <s:Button id="b1"/>, create
// public var b1:spark.components.Button;
if( instanceNode.getID() != null )
{
IDefinition d = instanceNode.resolveID();
// Only create reference var if it isn't already declared on base class
// Look for a property with the same name as this function in the base class
// the lookup will search up the inheritance chain, so we don't have to worry about
// walking up the inheritance chain here.
ClassDefinition base = (ClassDefinition)classDefinition.resolveBaseClass(getProject());
if (base != null)
{
IDefinition baseDef = base.getContainedScope().getQualifiedPropertyFromDef(
getProject(), base, d.getBaseName(), NamespaceDefinition.getPublicNamespaceDefinition(), false);
if (baseDef == null)
addBindableVariableTrait(idName, instanceClassName, d);
//else
// System.out.println("not adding bindable variable trait for " + d.getBaseName() + " in " + instanceClassName);
}
else
addBindableVariableTrait(idName, instanceClassName, d);
}
else
{
// No ID specified, can just make a var that isn't bindable
addVariableTrait(idName, instanceClassName);
}
if (!getProject().getTargetSettings().getMxmlChildrenAsData())
{
if (generateNonDescriptorCode || isStateDependentInstance(instanceNode))
{
// Set the reference variable to the new instance.
setIDReferenceVariable(idName, childContext);
if (instanceAffectsBindings(instanceNode))
{
// Call executeBindings() on the new instance.
executeBindingsForInstance(instanceNode, childContext);
}
}
}
}
if (getProject().getTargetSettings().getMxmlChildrenAsData())
{
return;
}
Name initializerName = null;
if (isInitializer)
{
initializerName = getInstanceInitializerName(instanceNode);
MethodInfo methodInfo = createInstanceInitializerMethodInfo(
initializerName.getBaseName(), instanceClassName);
addMethodTrait(initializerName, methodInfo, false);
childContext.addInstruction(OP_returnvalue);
generateMethodBody(methodInfo, classScope, childContext.currentInstructionList);
}