Search in sources :

Example 1 with TagComponent

use of lucee.transformer.bytecode.statement.tag.TagComponent in project Lucee by lucee.

the class Static method evaluate.

@Override
public void evaluate(Tag tag, TagLibTag libTag) throws EvaluatorException {
    // check parent
    Body body = null;
    String compName = Property.getComponentName(tag);
    boolean isCompChild = false;
    Tag p = ASMUtil.getParentTag(tag);
    if (p != null && (p instanceof TagComponent || getFullname(p, "").equalsIgnoreCase(compName))) {
        isCompChild = true;
        body = p.getBody();
    }
    Tag pp = p != null ? ASMUtil.getParentTag(p) : null;
    if (!isCompChild && pp != null && (p instanceof TagComponent || getFullname(pp, "").equalsIgnoreCase(compName))) {
        isCompChild = true;
        body = pp.getBody();
    }
    if (!isCompChild) {
        throw new EvaluatorException("Wrong Context for the the static constructor, " + "a static constructor must inside a component body.");
    }
    // Body body=(Body) tag.getParent();
    List<Statement> children = tag.getBody().getStatements();
    // remove that tag from parent
    ASMUtil.remove(tag);
    StaticBody sb = getStaticBody(body);
    ASMUtil.addStatements(sb, children);
}
Also used : EvaluatorException(lucee.transformer.cfml.evaluator.EvaluatorException) Statement(lucee.transformer.bytecode.Statement) StaticBody(lucee.transformer.bytecode.StaticBody) Tag(lucee.transformer.bytecode.statement.tag.Tag) TagLibTag(lucee.transformer.library.tag.TagLibTag) TagComponent(lucee.transformer.bytecode.statement.tag.TagComponent) Body(lucee.transformer.bytecode.Body) StaticBody(lucee.transformer.bytecode.StaticBody)

Example 2 with TagComponent

use of lucee.transformer.bytecode.statement.tag.TagComponent in project Lucee by lucee.

the class AbstrCFMLScriptTransformer method componentStatement.

private final TagComponent componentStatement(ExprData data, Body parent) throws TemplateException {
    int pos = data.srcCode.getPos();
    // get the idendifier in front of
    String id = identifier(data, false);
    if (id == null) {
        data.srcCode.setPos(pos);
        return null;
    }
    int mod = ComponentUtil.toModifier(id, Component.MODIFIER_NONE, Component.MODIFIER_NONE);
    if (mod == Component.MODIFIER_NONE) {
        data.srcCode.setPos(pos);
    }
    comments(data);
    // do we have a starting component?
    if (!data.srcCode.isCurrent(getComponentName(data.srcCode.getDialect())) && (data.srcCode.getDialect() == CFMLEngine.DIALECT_CFML || !data.srcCode.isCurrent(Constants.CFML_COMPONENT_TAG_NAME))) {
        data.srcCode.setPos(pos);
        return null;
    }
    // parse the component
    TagLibTag tlt = CFMLTransformer.getTLT(data.srcCode, getComponentName(data.srcCode.getDialect()), data.config.getIdentification());
    TagComponent comp = (TagComponent) _multiAttrStatement(parent, data, tlt);
    if (mod != Component.MODIFIER_NONE)
        comp.addAttribute(new Attribute(false, "modifier", data.factory.createLitString(id), "string"));
    return comp;
}
Also used : TagLibTag(lucee.transformer.library.tag.TagLibTag) Attribute(lucee.transformer.bytecode.statement.tag.Attribute) TagComponent(lucee.transformer.bytecode.statement.tag.TagComponent)

Aggregations

TagComponent (lucee.transformer.bytecode.statement.tag.TagComponent)2 TagLibTag (lucee.transformer.library.tag.TagLibTag)2 Body (lucee.transformer.bytecode.Body)1 Statement (lucee.transformer.bytecode.Statement)1 StaticBody (lucee.transformer.bytecode.StaticBody)1 Attribute (lucee.transformer.bytecode.statement.tag.Attribute)1 Tag (lucee.transformer.bytecode.statement.tag.Tag)1 EvaluatorException (lucee.transformer.cfml.evaluator.EvaluatorException)1