Search in sources :

Example 1 with VariableRef

use of lucee.transformer.bytecode.expression.var.VariableRef in project Lucee by lucee.

the class TryCatchFinally method addCatch.

/**
 * @param type
 * @param name
 * @param b
 * @param line
 * @throws TransformerException
 */
public void addCatch(Expression type, Expression name, Body b, Position line) throws TransformerException {
    // type
    if (type == null || type instanceof ExprString)
        ;
    else if (type instanceof Variable) {
        type = VariableString.toExprString(type);
    } else
        throw new TransformerException("type from catch statement is invalid", type.getStart());
    // name
    if (name instanceof LitString) {
        Variable v = getFactory().createVariable(Scope.SCOPE_UNDEFINED, name.getStart(), name.getEnd());
        v.addMember(getFactory().createDataMember(getFactory().toExprString(name)));
        name = new VariableRef(v, true);
    } else if (name instanceof Variable)
        name = new VariableRef((Variable) name, true);
    else
        throw new TransformerException("name from catch statement is invalid", name.getStart());
    addCatch((ExprString) type, (VariableRef) name, b, line);
}
Also used : LitString(lucee.transformer.expression.literal.LitString) VariableRef(lucee.transformer.bytecode.expression.var.VariableRef) Variable(lucee.transformer.expression.var.Variable) ExprString(lucee.transformer.expression.ExprString) TransformerException(lucee.transformer.TransformerException)

Aggregations

TransformerException (lucee.transformer.TransformerException)1 VariableRef (lucee.transformer.bytecode.expression.var.VariableRef)1 ExprString (lucee.transformer.expression.ExprString)1 LitString (lucee.transformer.expression.literal.LitString)1 Variable (lucee.transformer.expression.var.Variable)1