webit.script.core.ast.statements.Block Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of webit-script Show documentation
Show all versions of webit-script Show documentation
a template-like script and engine, all writen with Java.
The newest version!
// Copyright (c) 2013-2014, Webit Team. All Rights Reserved.
package webit.script.core.ast.statements;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import webit.script.Context;
import webit.script.core.LoopInfo;
import webit.script.core.ast.Loopable;
import webit.script.core.ast.Statement;
import webit.script.util.StatementUtil;
/**
*
* @author Zqq
*/
public final class Block extends IBlock implements Loopable {
public final int indexer;
public final Statement[] statements;
public final LoopInfo[] possibleLoopsInfo;
public Block(int indexer, Statement[] statements, LoopInfo[] possibleLoopsInfo, int line, int column) {
super(line, column);
this.indexer = indexer;
this.statements = statements;
this.possibleLoopsInfo = possibleLoopsInfo;
}
public Object execute(final Context context) {
final int preIndex = context.indexer;
context.indexer = indexer;
StatementUtil.executeInvertedAndCheckLoops(statements, context);
context.indexer = preIndex;
return null;
}
public List collectPossibleLoopsInfo() {
return new LinkedList(Arrays.asList(possibleLoopsInfo));
}
public boolean hasLoops() {
return true;
}
public int getVarIndexer() {
return indexer;
}
public Statement[] getStatements() {
return statements;
}
}