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);
}
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;
}
Aggregations