private int foreachLoopCounter = 0;
@Override
public void emitForEachLoop(IForLoopNode node)
{
IBinaryOperatorNode bnode = (IBinaryOperatorNode) node
.getConditionalsContainerNode().getChild(0);
IASNode childNode = bnode.getChild(0);
String iterName = "foreachiter"
+ new Integer(foreachLoopCounter).toString();
foreachLoopCounter++;
write(ASEmitterTokens.FOR);
write(ASEmitterTokens.SPACE);
write(ASEmitterTokens.PAREN_OPEN);
write(ASEmitterTokens.VAR);
write(ASEmitterTokens.SPACE);
write(iterName);
write(ASEmitterTokens.SPACE);
write(ASEmitterTokens.IN);
write(ASEmitterTokens.SPACE);
getWalker().walk(bnode.getChild(1));
writeToken(ASEmitterTokens.PAREN_CLOSE);
writeNewline();
write(ASEmitterTokens.BLOCK_OPEN);
writeNewline();
if (childNode instanceof IVariableExpressionNode)
{
write(ASEmitterTokens.VAR);
write(ASEmitterTokens.SPACE);
write(((IVariableNode) childNode.getChild(0)).getName());
}
else
write(((IIdentifierNode) childNode).getName());
write(ASEmitterTokens.SPACE);
write(ASEmitterTokens.EQUAL);
write(ASEmitterTokens.SPACE);
getWalker().walk(bnode.getChild(1));
write(ASEmitterTokens.SQUARE_OPEN);
write(iterName);
write(ASEmitterTokens.SQUARE_CLOSE);
write(ASEmitterTokens.SEMICOLON);
writeNewline();