*/
private StatementListNode genSkinPartsAST(Map<String, Boolean> parts,
NodeFactory nodeFactory,
StatementListNode statements)
{
StatementListNode result = statements;
Iterator<String> iterator = parts.keySet().iterator();
ArgumentListNode partsList = null;
//Loop through list of SkinParts and generate key/value field
while( iterator. hasNext() ){
String key = iterator.next();
LiteralStringNode partName = nodeFactory.literalString(key);
LiteralBooleanNode required = nodeFactory.literalBoolean(parts.get(key));
LiteralFieldNode literalField = nodeFactory.literalField(partName, required);
partsList = nodeFactory.argumentList(partsList, literalField);
}
//Create literalObject with key/value pairs
TypeExpressionNode typeExpression = AbstractSyntaxTreeUtil.generateTypeExpression(nodeFactory, OBJECT, true);
LiteralObjectNode literalObject = nodeFactory.literalObject(partsList);
//And finally our completed _skinPart AST
VariableDefinitionNode skinParts = (VariableDefinitionNode)AbstractSyntaxTreeUtil.generatePrivateStaticVariable(currentContext, typeExpression, _SKINPARTS, literalObject);
//Signature for getter that takes no parameters (of course) and returns an Object
MemberExpressionNode returnTypeExpression = AbstractSyntaxTreeUtil.generateGetterSelector(nodeFactory, OBJECT, true);
TypeExpressionNode returnType = nodeFactory.typeExpression(returnTypeExpression, true, false, -1);
FunctionSignatureNode functionSignature = nodeFactory.functionSignature(null, returnType);
//generate <ClassName>._skinParts
IdentifierNode identifier = AbstractSyntaxTreeUtil.generateIdentifier(nodeFactory, _SKINPARTS, false);
GetExpressionNode selector = nodeFactory.getExpression(identifier);
MemberExpressionNode memberExpression = nodeFactory.memberExpression(null, selector);
ListNode list = nodeFactory.list(null, memberExpression);
//return <ClassName>._skinParts
ReturnStatementNode returnStatement = nodeFactory.returnStatement(list);
StatementListNode rStatementList = nodeFactory.statementList(null, returnStatement);
//Create final expression
FunctionCommonNode propertyGetter = nodeFactory.functionCommon(currentContext, null, functionSignature, rStatementList);
//Create FunctionDefinition that will contain the above expression and set its type to a GETTER