IMetaTag[] skinParts = classDefinition.findSkinParts(classScope.getProject(), null);
if (skinParts.length > 0)
{
Name var_name = new Name(CONSTANT_Qname, new Nsset(skinPartPrivateNamespace), "skinParts");
classStaticScope.declareVariableName(var_name);
ITraitVisitor tv = classStaticScope.traitsVisitor.visitSlotTrait(TRAIT_Var, var_name,
ITraitsVisitor.RUNTIME_SLOT, NAME_OBJECT, LexicalScope.noInitializer);
tv.visitEnd();
cinitInsns.addInstruction(OP_findproperty, var_name);
for (IMetaTag skinPart : skinParts)
{
cinitInsns.addInstruction(OP_pushstring, skinPart.getDecoratedDefinition().getBaseName());
cinitInsns.addInstruction(OP_convert_s);
IMetaTagAttribute attr = skinPart.getAttribute("required");
if (attr == null || attr.getValue().equals("true"))
cinitInsns.addInstruction(OP_pushtrue);
else
cinitInsns.addInstruction(OP_pushfalse);
}
cinitInsns.addInstruction(OP_newobject, skinParts.length);
cinitInsns.addInstruction(OP_setproperty, var_name);
// Equivalent AS:
//
// protected function get skinParts():Object
// {
// return ClassName._skinParts;
// }
//
MethodInfo mi = new MethodInfo();
mi.setMethodName("skinParts");
mi.setReturnType(NAME_OBJECT);
InstructionList insns = new InstructionList(3);
insns.addInstruction(OP_getlocal0);
insns.addInstruction(OP_findpropstrict, var_name);
insns.addInstruction(OP_getproperty, var_name);
insns.addInstruction(OP_returnvalue);
FunctionGeneratorHelper.generateFunction(classScope.getEmitter(), mi, insns);
NamespaceDefinition nd = (NamespaceDefinition)classDefinition.getProtectedNamespaceReference();
Name func_name = new Name(nd.getAETNamespace(), "skinParts");
tv = classScope.traitsVisitor.visitMethodTrait(TRAIT_Getter, func_name, 0, mi);
tv.visitAttribute(Trait.TRAIT_OVERRIDE, Boolean.TRUE);
tv.visitEnd();
}
// the generation of instructions for variable initialization is delayed
// until now, so we can add that initialization to the front of
// the cinit instruction list.
if (!staticVariableInitializers.isEmpty())
{
InstructionList exisitingCinitInsns = null;
if (!this.cinitInsns.isEmpty())
{
exisitingCinitInsns = new InstructionList();
exisitingCinitInsns.addAll(this.cinitInsns);
this.cinitInsns = new InstructionList();
}
for (VariableNode var : staticVariableInitializers)
generateInstructions(var, true);
if (exisitingCinitInsns != null)
this.cinitInsns.addAll(exisitingCinitInsns);
}
// add "goto_definition_help" metadata to user defined metadata.
ITraitVisitor tv = classScope.getGlobalScope().traitsVisitor.visitClassTrait(
TRAIT_Class, className, 0, cinfo);
IMetaInfo[] metaTags = getAllMetaTags(classDefinition);
// Add "goto definition help" metadata for the constructor.
if (this.ctorFunction != null)
{
FunctionDefinition ctorDef = this.ctorFunction.getDefinition();
MetaTag metaTag = MetaTag.createGotoDefinitionHelp(classDefinition,
classDefinition.getContainingFilePath(),
Integer.toString(ctorDef.getNameStart()), true);
if (metaTag != null)
metaTags = MetaTag.addMetaTag(metaTags, metaTag);
}
this.classScope.processMetadata(tv, metaTags);
tv.visitEnd();
// Need to do this before generating the CTOR as the generated code may result in insns that
// need to be added to the ctor.
generateBindableImpl();