use of lucee.transformer.bytecode.expression.FunctionAsExpression in project Lucee by lucee.
the class AbstrCFMLScriptTransformer method expressionStatement.
/**
* List mithilfe des data.CFMLExprTransformer einen Ausruck ein.
* <br />
* EBNF:<br />
* <code>expression ";";</code>
* @param parent
* @return Ausdruck
* @throws TemplateException
*/
private Statement expressionStatement(ExprData data, Body parent) throws TemplateException {
// first we check if we have a access modifier
int pos = data.srcCode.getPos();
int access = -1;
boolean _final = false;
if (data.context == CTX_CFC || data.context == CTX_STATIC) {
if (data.srcCode.forwardIfCurrent("final ")) {
_final = true;
comments(data);
}
if (data.srcCode.forwardIfCurrent("private ")) {
access = Component.ACCESS_PRIVATE;
comments(data);
} else if (data.srcCode.forwardIfCurrent("package ")) {
access = Component.ACCESS_PACKAGE;
comments(data);
} else if (data.srcCode.forwardIfCurrent("public ")) {
access = Component.ACCESS_PUBLIC;
comments(data);
} else if (data.srcCode.forwardIfCurrent("remote ")) {
access = Component.ACCESS_REMOTE;
// comments(data);
throw new TemplateException(data.srcCode, "access modifier [remote] not supported in this context");
}
if (!_final && data.srcCode.forwardIfCurrent("final ")) {
_final = true;
comments(data);
}
}
Expression expr = expression(data);
checkSemiColonLineFeed(data, true, true, false);
// variable declaration (variable in body)
if (expr instanceof Variable) {
Variable v = (Variable) expr;
if (ASMUtil.isOnlyDataMember(v)) {
expr = new Assign(v, data.srcCode.getDialect() == CFMLEngine.DIALECT_LUCEE || data.config.getFullNullSupport() ? data.factory.createNull() : data.factory.EMPTY(), data.srcCode.getPosition());
}
}
// if a specific access was defined
if (access > -1 || _final) {
if (!(expr instanceof Assign)) {
data.srcCode.setPos(pos);
throw new TemplateException(data.srcCode, "invalid syntax, access modifier cannot be used in this context");
}
if (access > -1) {
// this is only supported with the Lucee dialect
// if(data.srcCode.getDialect()==CFMLEngine.DIALECT_CFML)
// throw new TemplateException(data.srcCode,
// "invalid syntax, access modifier cannot be used in this context");
((Assign) expr).setAccess(access);
}
if (_final)
((Assign) expr).setModifier(Member.MODIFIER_FINAL);
}
if (expr instanceof FunctionAsExpression)
return ((FunctionAsExpression) expr).getFunction();
return new ExpressionAsStatement(expr);
}
Aggregations