use of lucee.transformer.bytecode.Statement in project Lucee by lucee.
the class TagTry method hasFinally.
private boolean hasFinally() {
List<Statement> statements = getBody().getStatements();
Statement stat;
Tag tag;
Iterator<Statement> it = statements.iterator();
while (it.hasNext()) {
stat = it.next();
if (stat instanceof Tag) {
tag = (Tag) stat;
if (tag.getTagLibTag().getTagClassDefinition().isClassNameEqualTo("lucee.runtime.tag.Finally")) {
return true;
}
}
}
return false;
}
use of lucee.transformer.bytecode.Statement in project Lucee by lucee.
the class ASMUtil method getAncestorFCStatement.
private static FlowControl getAncestorFCStatement(Statement stat, List<FlowControlFinal> finallyLabels, int flowType, String label) {
Statement parent = stat;
FlowControlFinal fcf;
while (true) {
parent = parent.getParent();
if (parent == null)
return null;
if (((flowType == FlowControl.RETRY && parent instanceof FlowControlRetry) || (flowType == FlowControl.CONTINUE && parent instanceof FlowControlContinue) || (flowType == FlowControl.BREAK && parent instanceof FlowControlBreak)) && labelMatch((FlowControl) parent, label)) {
if (parent instanceof ScriptBody) {
List<FlowControlFinal> _finallyLabels = finallyLabels == null ? null : new ArrayList<FlowControlFinal>();
FlowControl scriptBodyParent = getAncestorFCStatement(parent, _finallyLabels, flowType, label);
if (scriptBodyParent != null) {
if (finallyLabels != null) {
Iterator<FlowControlFinal> it = _finallyLabels.iterator();
while (it.hasNext()) {
finallyLabels.add(it.next());
}
}
return scriptBodyParent;
}
return (FlowControl) parent;
}
return (FlowControl) parent;
}
// only if not last
if (finallyLabels != null) {
fcf = parent.getFlowControlFinal();
if (fcf != null) {
finallyLabels.add(fcf);
}
}
}
}
use of lucee.transformer.bytecode.Statement in project Lucee by lucee.
the class ASMUtil method replace.
/**
* replace src with trg
* @param src
* @param trg
*/
public static void replace(Tag src, Tag trg, boolean moveBody) {
trg.setParent(src.getParent());
Body p = (Body) src.getParent();
List<Statement> stats = p.getStatements();
Iterator<Statement> it = stats.iterator();
Statement stat;
int count = 0;
while (it.hasNext()) {
stat = it.next();
if (stat == src) {
if (moveBody && src.getBody() != null)
src.getBody().setParent(trg);
stats.set(count, trg);
break;
}
count++;
}
}
use of lucee.transformer.bytecode.Statement in project Lucee by lucee.
the class ASMUtil method count.
public static int count(List<Statement> statements, boolean recursive) {
if (statements == null)
return 0;
int count = 0;
Iterator<Statement> it = statements.iterator();
while (it.hasNext()) {
count += count(it.next(), recursive);
}
return count;
}
use of lucee.transformer.bytecode.Statement in project Lucee by lucee.
the class ASMUtil method move.
public static void move(Tag src, Body dest) {
// switch children
Body srcBody = (Body) src.getParent();
Iterator<Statement> it = srcBody.getStatements().iterator();
Statement stat;
while (it.hasNext()) {
stat = it.next();
if (stat == src) {
it.remove();
dest.addStatement(stat);
}
}
// switch parent
src.setParent(dest);
}
Aggregations