Search in sources :

Example 1 with ScriptBody

use of lucee.transformer.bytecode.ScriptBody 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);
            }
        }
    }
}
Also used : FlowControlContinue(lucee.transformer.bytecode.statement.FlowControlContinue) FlowControl(lucee.transformer.bytecode.statement.FlowControl) Statement(lucee.transformer.bytecode.Statement) ScriptBody(lucee.transformer.bytecode.ScriptBody) FlowControlFinal(lucee.transformer.bytecode.statement.FlowControlFinal) FlowControlBreak(lucee.transformer.bytecode.statement.FlowControlBreak) FlowControlRetry(lucee.transformer.bytecode.statement.FlowControlRetry)

Example 2 with ScriptBody

use of lucee.transformer.bytecode.ScriptBody in project Lucee by lucee.

the class AbstrCFMLScriptTransformer method statements.

/**
 * Liest saemtliche Statements des CFScriptString ein.
 * <br />
 * EBNF:<br />
 * <code>{statement spaces};</code>
 * @return a statement
 * @throws TemplateException
 */
protected final Body statements(ExprData data) throws TemplateException {
    ScriptBody body = new ScriptBody(data.factory);
    statements(data, body, true);
    return body;
}
Also used : ScriptBody(lucee.transformer.bytecode.ScriptBody)

Example 3 with ScriptBody

use of lucee.transformer.bytecode.ScriptBody in project Lucee by lucee.

the class JavaScriptTransformer method transform.

@Override
public Body transform(Factory factory, Root root, EvaluatorPool ep, TagLib[][] tlibs, FunctionLib[] flibs, String surroundingTagName, TagLibTag[] scriptTags, SourceCode cfml, TransfomerSettings settings) throws TemplateException {
    StringBuilder sb = new StringBuilder();
    // MUST add again int startline=cfml.getLine();
    while (!cfml.isAfterLast() && !cfml.isCurrent("</", surroundingTagName)) {
        sb.append(cfml.getCurrent());
        cfml.next();
    }
    // int endline=cfml.getLine();
    if (cfml.isAfterLast())
        // TODO better error message
        throw new TemplateException(cfml, "missing end tag");
    if (true)
        throw new RuntimeException("not implemented");
    try {
        // MUST add again CompilationUnit cu = JavaParser.parse(bais);
        // MUST add again DataBag db = new DataBag();
        ScriptBody body = new ScriptBody(factory);
        return body;
    // MUST add again new JavaParserVisitor(body,start,end).visit(cu, db);
    } catch (Exception e) {
        throw new TemplateException(cfml, e);
    }
}
Also used : TemplateException(lucee.runtime.exp.TemplateException) ScriptBody(lucee.transformer.bytecode.ScriptBody) TemplateException(lucee.runtime.exp.TemplateException)

Aggregations

ScriptBody (lucee.transformer.bytecode.ScriptBody)3 TemplateException (lucee.runtime.exp.TemplateException)1 Statement (lucee.transformer.bytecode.Statement)1 FlowControl (lucee.transformer.bytecode.statement.FlowControl)1 FlowControlBreak (lucee.transformer.bytecode.statement.FlowControlBreak)1 FlowControlContinue (lucee.transformer.bytecode.statement.FlowControlContinue)1 FlowControlFinal (lucee.transformer.bytecode.statement.FlowControlFinal)1 FlowControlRetry (lucee.transformer.bytecode.statement.FlowControlRetry)1