use of lucee.transformer.bytecode.expression.var.Assign in project Lucee by lucee.
the class AbstrCFMLExprTransformer method assignOp.
/**
* Transfomiert Zuweisungs Operation.
* <br />
* EBNF:<br />
* <code>eqvOp ["=" spaces assignOp];</code>
* @return CFXD Element
* @throws TemplateException
*/
protected Expression assignOp(ExprData data) throws TemplateException {
Expression expr = conditionalOp(data);
if (data.srcCode.forwardIfCurrent('=')) {
comments(data);
if (data.mode == STATIC)
expr = new DynAssign(expr, assignOp(data));
else {
if (expr instanceof Variable) {
Expression value = assignOp(data);
expr = new Assign((Variable) expr, value, data.srcCode.getPosition());
} else if (expr instanceof Null) {
Variable var = ((Null) expr).toVariable();
Expression value = assignOp(data);
expr = new Assign(var, value, data.srcCode.getPosition());
} else
throw new TemplateException(data.srcCode, "invalid assignment left-hand side (" + expr.getClass().getName() + ")");
}
}
// patch for test()(); only works at the end of an expression!
comments(data);
while (data.srcCode.isCurrent('(')) {
comments(data);
Call call = new Call(expr);
getFunctionMemberAttrs(data, null, false, call, null);
call.setEnd(data.srcCode.getPosition());
comments(data);
expr = call;
}
return expr;
}
use of lucee.transformer.bytecode.expression.var.Assign in project Lucee by lucee.
the class QueryExecute method evaluate.
@Override
public void evaluate(BIF bif, FunctionLibFunction flf) throws EvaluatorException {
Variable var = bif.getParent();
if (var != null) {
Assign ass = var.assign();
if (ass != null) {
try {
String str = VariableString.variableToString(ass.getVariable(), false);
addArgument(bif, str);
} catch (TransformerException e) {
SystemOut.printDate(e);
}
}
}
}
use of lucee.transformer.bytecode.expression.var.Assign 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