Search in sources :

Example 16 with EvaluatorException

use of lucee.transformer.cfml.evaluator.EvaluatorException in project Lucee by lucee.

the class ReThrow method evaluate.

@Override
public void evaluate(Tag tag, TagLibTag libTag) throws EvaluatorException {
    String ns = libTag.getTagLib().getNameSpaceAndSeparator();
    String queryName = ns + "catch";
    if (!ASMUtil.hasAncestorTryStatement(tag)) {
        if (tag.isScriptBase())
            throw new EvaluatorException("Wrong Context, statement " + libTag.getName() + " must be inside a " + queryName + " tag or catch statement");
        throw new EvaluatorException("Wrong Context, tag " + libTag.getFullName() + " must be inside a " + queryName + " tag");
    }
// ASMUtil.replace(tag,new TagReThrow(tag));
}
Also used : EvaluatorException(lucee.transformer.cfml.evaluator.EvaluatorException)

Example 17 with EvaluatorException

use of lucee.transformer.cfml.evaluator.EvaluatorException in project Lucee by lucee.

the class Retry method evaluate.

@Override
public void evaluate(Tag tag, TagLibTag libTag) throws EvaluatorException {
    String ns = libTag.getTagLib().getNameSpaceAndSeparator();
    String name = ns + "catch";
    if (getAncestorCatch(libTag.getTagLib(), tag) == null)
        throw new EvaluatorException("Wrong Context, tag " + libTag.getFullName() + " must be inside a " + name + " tag");
}
Also used : EvaluatorException(lucee.transformer.cfml.evaluator.EvaluatorException)

Example 18 with EvaluatorException

use of lucee.transformer.cfml.evaluator.EvaluatorException in project Lucee by lucee.

the class TreeItem method evaluate.

/**
 * @see lucee.transformer.cfml.evaluator.EvaluatorSupport#evaluate(org.w3c.dom.Element, lucee.transformer.library.tag.TagLibTag)
 */
@Override
public void evaluate(Tag tag, TagLibTag libTag) throws EvaluatorException {
    String ns = libTag.getTagLib().getNameSpaceAndSeparator();
    String name = ns + "tree";
    // check if tag is direct inside if
    if (!ASMUtil.hasAncestorTag(tag, name))
        throw new EvaluatorException("Wrong Context, tag " + libTag.getFullName() + " must be inside a " + name + " tag");
}
Also used : EvaluatorException(lucee.transformer.cfml.evaluator.EvaluatorException)

Example 19 with EvaluatorException

use of lucee.transformer.cfml.evaluator.EvaluatorException in project Lucee by lucee.

the class Function method addAttribute.

public final void addAttribute(Attribute attr) throws TemplateException {
    String name = attr.getName().toLowerCase();
    // name
    if ("name".equals(name)) {
        throw new TransformerException("name cannot be defined twice", getStart());
    } else if ("returntype".equals(name)) {
        this.returnType = toLitString(name, attr.getValue());
    } else if ("access".equals(name)) {
        LitString ls = toLitString(name, attr.getValue());
        String strAccess = ls.getString();
        int acc = ComponentUtil.toIntAccess(strAccess, -1);
        if (acc == -1)
            throw new TransformerException("invalid access type [" + strAccess + "], access types are remote, public, package, private", getStart());
        access = acc;
    } else if ("output".equals(name))
        this.output = toLitBoolean(name, attr.getValue());
    else if ("bufferoutput".equals(name))
        this.bufferOutput = toLitBoolean(name, attr.getValue());
    else if ("displayname".equals(name))
        this.displayName = toLitString(name, attr.getValue());
    else if ("hint".equals(name))
        this.hint = toLitString(name, attr.getValue());
    else if ("description".equals(name))
        this.description = toLitString(name, attr.getValue());
    else if ("returnformat".equals(name))
        this.returnFormat = toLitString(name, attr.getValue());
    else if ("securejson".equals(name))
        this.secureJson = toLitBoolean(name, attr.getValue());
    else if ("verifyclient".equals(name))
        this.verifyClient = toLitBoolean(name, attr.getValue());
    else if ("localmode".equals(name)) {
        Expression v = attr.getValue();
        if (v != null) {
            String str = ASMUtil.toString(v, null);
            if (!StringUtil.isEmpty(str)) {
                int mode = AppListenerUtil.toLocalMode(str, -1);
                if (mode != -1)
                    this.localMode = v.getFactory().createLitInteger(mode);
                else
                    throw new TransformerException("Attribute localMode of the Tag Function, must be a literal value (modern, classic, true or false)", getStart());
            }
        }
    } else if ("cachedwithin".equals(name)) {
        try {
            // ASMUtil.timeSpanToLong(attr.getValue());
            this.cachedWithin = ASMUtil.cachedWithinValue(attr.getValue());
        } catch (EvaluatorException e) {
            throw new TemplateException(e.getMessage());
        }
    } else if ("modifier".equals(name)) {
        Expression val = attr.getValue();
        if (val instanceof Literal) {
            Literal l = (Literal) val;
            String str = StringUtil.emptyIfNull(l.getString()).trim();
            if ("abstract".equalsIgnoreCase(str))
                modifier = Component.MODIFIER_ABSTRACT;
            else if ("final".equalsIgnoreCase(str))
                modifier = Component.MODIFIER_FINAL;
        }
    } else {
        // needed for testing
        toLitString(name, attr.getValue());
        if (metadata == null)
            metadata = new HashMap<String, Attribute>();
        metadata.put(attr.getName(), attr);
    }
}
Also used : LitString(lucee.transformer.expression.literal.LitString) Expression(lucee.transformer.expression.Expression) EvaluatorException(lucee.transformer.cfml.evaluator.EvaluatorException) TemplateException(lucee.runtime.exp.TemplateException) Attribute(lucee.transformer.bytecode.statement.tag.Attribute) Literal(lucee.transformer.expression.literal.Literal) LitString(lucee.transformer.expression.literal.LitString) ExprString(lucee.transformer.expression.ExprString) TransformerException(lucee.transformer.TransformerException)

Example 20 with EvaluatorException

use of lucee.transformer.cfml.evaluator.EvaluatorException in project Lucee by lucee.

the class CFMLTransformer method executeEvaluator.

private boolean executeEvaluator(TagData data, TagLibTag tagLibTag, Tag tag) throws TemplateException {
    if (tagLibTag.hasTTE()) {
        try {
            TagLib lib = tagLibTag.getEvaluator().execute(data.config, tag, tagLibTag, data.flibs, data);
            if (lib != null) {
                // set
                for (int i = 0; i < data.tlibs[TAG_LIB_PAGE].length; i++) {
                    if (data.tlibs[TAG_LIB_PAGE][i].getNameSpaceAndSeparator().equalsIgnoreCase(lib.getNameSpaceAndSeparator())) {
                        boolean extIsCustom = data.tlibs[TAG_LIB_PAGE][i] instanceof CustomTagLib;
                        boolean newIsCustom = lib instanceof CustomTagLib;
                        // TagLib + CustomTagLib (visa/versa)
                        if (extIsCustom) {
                            ((CustomTagLib) data.tlibs[TAG_LIB_PAGE][i]).append(lib);
                            return true;
                        } else if (newIsCustom) {
                            ((CustomTagLib) lib).append(data.tlibs[TAG_LIB_PAGE][i]);
                            data.tlibs[TAG_LIB_PAGE][i] = lib;
                            return true;
                        }
                    }
                }
                // TODO make sure longer namespace ar checked firts to support subsets, same for core libs
                // insert
                TagLib[] newTlibs = new TagLib[data.tlibs[TAG_LIB_PAGE].length + 1];
                for (int i = 0; i < data.tlibs[TAG_LIB_PAGE].length; i++) {
                    newTlibs[i] = data.tlibs[TAG_LIB_PAGE][i];
                }
                newTlibs[data.tlibs[TAG_LIB_PAGE].length] = lib;
                data.tlibs[TAG_LIB_PAGE] = newTlibs;
            }
        } catch (EvaluatorException e) {
            throw new TemplateException(data.srcCode, e);
        }
    }
    return true;
}
Also used : EvaluatorException(lucee.transformer.cfml.evaluator.EvaluatorException) AttributeEvaluatorException(lucee.transformer.cfml.attributes.AttributeEvaluatorException) ComponentTemplateException(lucee.transformer.cfml.script.AbstrCFMLScriptTransformer.ComponentTemplateException) TemplateException(lucee.runtime.exp.TemplateException) TagLib(lucee.transformer.library.tag.TagLib) CustomTagLib(lucee.transformer.library.tag.CustomTagLib) CustomTagLib(lucee.transformer.library.tag.CustomTagLib)

Aggregations

EvaluatorException (lucee.transformer.cfml.evaluator.EvaluatorException)28 LitString (lucee.transformer.expression.literal.LitString)10 Attribute (lucee.transformer.bytecode.statement.tag.Attribute)9 Tag (lucee.transformer.bytecode.statement.tag.Tag)6 Body (lucee.transformer.bytecode.Body)5 Statement (lucee.transformer.bytecode.Statement)5 ExprString (lucee.transformer.expression.ExprString)5 Expression (lucee.transformer.expression.Expression)5 TagLibTag (lucee.transformer.library.tag.TagLibTag)5 TemplateException (lucee.runtime.exp.TemplateException)4 Page (lucee.transformer.bytecode.Page)4 TransformerException (lucee.transformer.TransformerException)3 StaticBody (lucee.transformer.bytecode.StaticBody)3 Literal (lucee.transformer.expression.literal.Literal)3 TagIf (lucee.transformer.bytecode.statement.tag.TagIf)2 TagLoop (lucee.transformer.bytecode.statement.tag.TagLoop)2 LitBoolean (lucee.transformer.expression.literal.LitBoolean)2 TagLib (lucee.transformer.library.tag.TagLib)2 SourceCode (lucee.transformer.util.SourceCode)2 Iterator (java.util.Iterator)1