use of lucee.transformer.expression.var.Variable in project Lucee by lucee.
the class ArrayToList method execute.
@Override
public void execute(BIF bif, FunctionLibFunction flf) throws TemplateException {
Argument[] args = bif.getArguments();
Argument arg = args[0];
Expression value = arg.getValue();
if (value instanceof Cast) {
value = ((Cast) value).getExpr();
}
if (value instanceof Variable) {
((Variable) value).setAsCollection(Boolean.TRUE);
}
}
use of lucee.transformer.expression.var.Variable in project Lucee by lucee.
the class IsNull method execute.
@Override
public void execute(BIF bif, FunctionLibFunction flf) throws TemplateException {
Argument arg = bif.getArguments()[0];
Expression value = arg.getValue();
// set all member to safe navigated
if (value instanceof Variable) {
Variable var = ((Variable) value);
/* LDEV-1201 List<Member> members = var.getMembers();
for(Member m:members) {
m.setSafeNavigated(true);
}*/
var.setDefaultValue(value.getFactory().createNull());
}
}
use of lucee.transformer.expression.var.Variable in project Lucee by lucee.
the class Output method addEncodeToChildren.
private void addEncodeToChildren(Iterator it, Expression encodeForValue, FunctionLibFunction encodeForBIF) {
Statement stat;
while (it.hasNext()) {
stat = (Statement) it.next();
if (stat instanceof PrintOut) {
PrintOut printOut = ((PrintOut) stat);
Expression e = removeCastString(printOut.getExpr());
if (!(e instanceof Literal)) {
if (e instanceof Variable) {
Member member = ((Variable) e).getFirstMember();
if (member instanceof BIF) {
BIF bif = (BIF) member;
String cn = bif.getClassDefinition().getClassName();
if (cn.startsWith(ENCODE_FOR) || cn.equals(ESAPIEncode.class.getName())) {
continue;
}
}
}
printOut.setEncodeFor(encodeForValue);
}
} else if (stat instanceof Tag) {
Body b = ((Tag) stat).getBody();
if (b != null)
addEncodeToChildren(b.getStatements().iterator(), encodeForValue, encodeForBIF);
} else if (stat instanceof Body) {
addEncodeToChildren(((Body) stat).getStatements().iterator(), encodeForValue, encodeForBIF);
}
}
}
use of lucee.transformer.expression.var.Variable 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.expression.var.Variable in project Lucee by lucee.
the class AbstrCFMLExprTransformer method dynamic.
/**
* Liest den folgenden idetifier ein und prueft ob dieser ein boolscher Wert ist.
* Im Gegensatz zu CFMX wird auch "yes" und "no" als bolscher <wert akzeptiert,
* was bei CFMX nur beim Umwandeln einer Zeichenkette zu einem boolschen Wert der Fall ist.<br />
* Wenn es sich um keinen bolschen Wert handelt wird der folgende Wert eingelesen mit seiner ganzen Hirarchie.
* <br />
* EBNF:<br />
* <code>"true" | "false" | "yes" | "no" | startElement {("." identifier | "[" structElement "]" )[function] };</code>
* @return CFXD Element
* @throws TemplateException
*/
private Expression dynamic(ExprData data) throws TemplateException {
// Die Implementation weicht ein wenig von der Grammatik ab,
// aber nicht in der Logik sondern rein wie es umgesetzt wurde.
// get First Element of the Variable
Position line = data.srcCode.getPosition();
Identifier id = identifier(data, false, true);
if (id == null) {
if (!data.srcCode.forwardIfCurrent('('))
return null;
comments(data);
Expression expr = assignOp(data);
if (!data.srcCode.forwardIfCurrent(')'))
throw new TemplateException(data.srcCode, "Invalid Syntax Closing [)] not found");
comments(data);
// subDynamic(expr);
return expr;
}
Variable var;
comments(data);
// Boolean constant
if (id.getString().equalsIgnoreCase("TRUE")) {
// || name.equals("YES")) {
comments(data);
return id.getFactory().createLitBoolean(true, line, data.srcCode.getPosition());
} else if (id.getString().equalsIgnoreCase("FALSE")) {
// || name.equals("NO")) {
comments(data);
return id.getFactory().createLitBoolean(false, line, data.srcCode.getPosition());
} else if ((data.srcCode.getDialect() != CFMLEngine.DIALECT_CFML || data.config.getFullNullSupport()) && id.getString().equalsIgnoreCase("NULL")) {
comments(data);
return id.getFactory().createNull(line, data.srcCode.getPosition());
}
// Extract Scope from the Variable
var = startElement(data, id, line);
var.setStart(line);
var.setEnd(data.srcCode.getPosition());
return var;
}
Aggregations