popSourceInfo();
return expr.makeStmt();
}
private JsStatement mapForStatement(Node forNode) throws JsParserException {
Node fromInit = forNode.getFirstChild();
Node fromTest = fromInit.getNext();
Node fromIncr = fromTest.getNext();
Node fromBody = fromIncr.getNext();
if (fromBody == null) {
// This could be a "for...in" structure.
// We could based on the different child layout.
//
Node fromIter = forNode.getFirstChild();
Node fromObjExpr = fromIter.getNext();
fromBody = fromObjExpr.getNext();
JsForIn toForIn;
if (fromIter.getType() == TokenStream.VAR) {
// A named iterator var.
//
Node fromIterVarName = fromIter.getFirstChild();
String fromName = fromIterVarName.getString();
JsName toName = getScope().declareName(fromName);
toForIn = new JsForIn(makeSourceInfo(forNode), toName);
Node fromIterInit = fromIterVarName.getFirstChild();
if (fromIterInit != null) {
// That has an initializer expression (useful only for side effects).
//
toForIn.setIterExpr(mapOptionalExpression(fromIterInit));
}