use of lucee.runtime.type.ref.VariableReference in project Lucee by lucee.
the class ValueList method toColumn.
protected static QueryColumn toColumn(PageContext pc, String strQueryColumn) throws PageException {
// if(strQueryColumn.indexOf('.')<1)
// throw new ExpressionException("invalid query column definition ["+strQueryColumn+"]");
VariableReference ref = ((PageContextImpl) pc).getVariableReference(strQueryColumn);
if (ref.getParent() instanceof Scope)
throw new ExpressionException("invalid query column definition [" + strQueryColumn + "]");
Query query = Caster.toQuery(ref.getParent());
return query.getColumn(ref.getKey());
}
use of lucee.runtime.type.ref.VariableReference in project Lucee by lucee.
the class VariableInterpreter method getVariableReference.
/**
* return a variable reference by string syntax ("scopename.key.key" -> "url.name")
* a variable reference, references to variable, to modifed it, with global effect.
* @param pc
* @param var variable name to get
* @return variable as Reference
* @throws PageException
*/
public static VariableReference getVariableReference(PageContext pc, String var) throws PageException {
StringList list = parse(pc, new ParserString(var), false);
if (list == null)
throw new InterpreterException("invalid variable declaration [" + var + "]");
if (list.size() == 1) {
return new VariableReference(pc.undefinedScope(), list.next());
}
int scope = scopeString2Int(pc.ignoreScopes(), list.next());
Object coll;
if (scope == Scope.SCOPE_UNDEFINED) {
coll = pc.touch(pc.undefinedScope(), KeyImpl.init(list.current()));
} else {
coll = VariableInterpreter.scope(pc, scope, list.hasNext());
// coll=pc.scope(scope);
}
while (list.hasNextNext()) {
coll = pc.touch(coll, KeyImpl.init(list.next()));
}
if (!(coll instanceof Collection))
throw new InterpreterException("invalid variable [" + var + "]");
return new VariableReference((Collection) coll, list.next());
}
use of lucee.runtime.type.ref.VariableReference in project Lucee by lucee.
the class VariableInterpreter method getVariableReference.
public static VariableReference getVariableReference(PageContext pc, Collection.Key[] keys, boolean keepScope) throws PageException {
if (keys.length == 1) {
if (keepScope) {
Collection coll = ((UndefinedImpl) pc.undefinedScope()).getScopeFor(keys[0], null);
if (coll != null)
return new VariableReference(coll, keys[0]);
}
return new VariableReference(pc.undefinedScope(), keys[0]);
}
int scope = scopeKey2Int(keys[0]);
Object coll;
if (scope == Scope.SCOPE_UNDEFINED) {
coll = pc.touch(pc.undefinedScope(), keys[0]);
} else {
coll = VariableInterpreter.scope(pc, scope, keys.length > 1);
}
for (int i = 1; i < (keys.length - 1); i++) {
coll = pc.touch(coll, keys[i]);
}
if (!(coll instanceof Collection))
throw new InterpreterException("invalid variable [" + ListUtil.arrayToList(keys, ".") + "]");
return new VariableReference((Collection) coll, keys[keys.length - 1]);
}
use of lucee.runtime.type.ref.VariableReference in project Lucee by lucee.
the class Operator method unaryPreMultiply.
// pre multiply
public static Double unaryPreMultiply(PageContext pc, Collection.Key[] keys, double value) throws PageException {
VariableReference ref = VariableInterpreter.getVariableReference(pc, keys, true);
double rtn = Caster.toDoubleValue(ref.get(pc)) * value;
ref.set(rtn);
return rtn;
}
use of lucee.runtime.type.ref.VariableReference in project Lucee by lucee.
the class Operator method unaryPrMi.
public static double unaryPrMi(PageContext pc, Collection.Key[] keys, double value) throws PageException {
VariableReference ref = VariableInterpreter.getVariableReference(pc, keys, true);
double rtn = Caster.toDoubleValue(ref.get(pc)) - value;
ref.set(rtn);
return rtn;
}
Aggregations