}
// now, process all the state dependent nodes
int instanceNodeCounter = 0;
IASNode anInstanceNode = null;
for (IMXMLNode node : stateDependentNodes)
{
// here we only care about instance nodes
if (node instanceof IMXMLInstanceNode)
{
anInstanceNode = node;
// Generate a map that tell for each state dependent instance node, what slot
// it corresponds to in the array of
// deferredInstanceFromFunction's
if (nodeToIndexMap==null)
nodeToIndexMap = new HashMap<IMXMLNode, Integer>();
nodeToIndexMap.put(node, instanceNodeCounter);
++instanceNodeCounter;
InstructionList il;
if (getProject().getTargetSettings().getMxmlChildrenAsData())
{
if (nodeToInstanceDescriptorMap==null)
nodeToInstanceDescriptorMap = new HashMap<IMXMLNode, InstructionList>();
il = new InstructionList();
nodeToInstanceDescriptorMap.put(node, il);
// build the initializer function by processing the node
Context stateContext = new Context((IMXMLInstanceNode)node, il);
stateContext.isContentFactory = true;
processNode(node, stateContext);
stateContext.transfer(IL.MXML_CONTENT_FACTORY);
stateContext.addInstruction(OP_newarray, stateContext.getCounter(IL.MXML_CONTENT_FACTORY));
}
else
{
context.addInstruction(OP_findpropstrict, deferredInstanceFromFunctionName);
// stack: ..., DeferredInstaceFromFunction class
// build the initializer function by processing the node
processNode(node, context);
// stack: ..., DeferredInstaceFromFunction class, initializerFunc
context.addInstruction(OP_constructprop, new Object[] { deferredInstanceFromFunctionName, 1});
// stack: ..., DeferredInstaceFromFunction object
}
}
}
if (getProject().getTargetSettings().getMxmlChildrenAsData())
return;
// if we didn't find any state dependent instance nodes, then leave
if (instanceNodeCounter==0)
return;
// stack: ..., arg[0], arg[1],.., arg[n-1]
context.addInstruction(OP_newarray, instanceNodeCounter);
context.addInstruction(OP_setlocal3);
// now local3= array of deferredInstanceFromFunctionName
// make a dependency on the sdk class DeferredInstanceFromFunction
IWorkspace workspace = project.getWorkspace();
IResolvedQualifiersReference ref = ReferenceFactory.packageQualifiedReference(workspace, deferredInstanceFromFunctionClass);
IScopedNode scopedNode = anInstanceNode.getContainingScope();
IASScope iscope = scopedNode.getScope();
ASScope scope = (ASScope)iscope;
if (ref == null)
assert false;