StatementListNode result = statementList;
Set<String> states = model.info.getStateNames();
int count = 0;
for (Iterator<String> iter = states.iterator(); iter.hasNext(); )
{
State state = (State) model.stateByName((String)iter.next());
if (state != null)
{
String identifier = state.getId().intern();
IdentifierNode stateIdentifier = nodeFactory.identifier(identifier, false);
IdentifierNode statesIdentifier = nodeFactory.identifier(STATES, false);
LiteralNumberNode numberNode = nodeFactory.literalNumber(count);
ArgumentListNode getIndexArgList = nodeFactory.argumentList(null, numberNode);
GetExpressionNode getIndexExpression = nodeFactory.getExpression(getIndexArgList);
getIndexExpression.setMode(Tokens.LEFTBRACKET_TOKEN);
GetExpressionNode getStatesExpression = nodeFactory.getExpression(statesIdentifier);
MemberExpressionNode base = nodeFactory.memberExpression(null, getStatesExpression);
MemberExpressionNode getExpr = nodeFactory.memberExpression(base, getIndexExpression);
// Declaration initializer
if (state.isDeclared())
{
ArgumentListNode argList = nodeFactory.argumentList(null, getExpr);
SetExpressionNode selector = nodeFactory.setExpression(stateIdentifier, argList, false);
MemberExpressionNode outer = nodeFactory.memberExpression(null, selector);
ListNode list = nodeFactory.list(null, outer);
ExpressionStatementNode expressionStatement = nodeFactory.expressionStatement(list);
result = nodeFactory.statementList(result, expressionStatement);
}
// Event handlers
for (Iterator<Initializer> initializers = state.getEvents(); initializers.hasNext(); )
{
EventInitializer ei = (EventInitializer) initializers.next();
IdentifierNode addEventIdentifier = nodeFactory.identifier(ADDEVENTLISTENER, false);
LiteralStringNode eventName = nodeFactory.literalString(ei.getName());
macromedia.asc.parser.Node valueNode = ei.generateValueExpr(nodeFactory, configNamespaces,