* @param scope
* 语句子节点生存域
*/
public LoopStatement(Node node, ScriptOrFnNode root, Scope scope) {
super(node);
Node childNode = node.getFirstChild();
switch (childNode.getType()) {
case Token.EXPR_VOID:
tokenType = Token.FOR;
startNode = addExpression(childNode.getFirstChild(), root, scope);
childNode = childNode.getNext();
break;
case Token.VAR:
tokenType = Token.FOR;
startNode = addStatement(childNode, root, scope);
childNode = childNode.getNext();
break;
}
if (childNode.getType() == Token.TARGET) {
bodyStatement = addStatement(childNode.getNext(), root, scope);
childNode = bodyStatement.getNext().getNext();
checkExpression = addExpression(childNode.getFirstChild(), root, scope);
if (tokenType == 0) {
tokenType = Token.DO;
}
} else if (childNode.getType() == Token.GOTO) {
bodyStatement = addStatement(childNode.getNext().getNext(), root, scope);
childNode = bodyStatement.getNext().getNext();
if (childNode.getType() == Token.EXPR_VOID) {
tokenType = Token.FOR;
endExpression = addExpression(childNode.getFirstChild(), root, scope);
childNode = childNode.getNext().getNext();
}
childNode = childNode.getNext();
if (childNode.getType() == Token.TARGET) {
checkExpression = addExpression(childNode.getNext().getFirstChild(),
root, scope);
tokenType = Token.FOR;
} else {
checkExpression = addExpression(childNode.getFirstChild(), root, scope);
if (tokenType == 0) {
tokenType = Token.WHILE;
}
}
}