use of lucee.transformer.expression.var.DataMember in project Lucee by lucee.
the class ASMUtil method hasOnlyDataMembers.
public static boolean hasOnlyDataMembers(Variable var) {
Iterator<Member> it = var.getMembers().iterator();
Member m;
while (it.hasNext()) {
m = it.next();
if (!(m instanceof DataMember))
return false;
}
return true;
}
use of lucee.transformer.expression.var.DataMember in project Lucee by lucee.
the class ExpressionInvoker method _writeOut.
@Override
public Type _writeOut(BytecodeContext bc, int mode) throws TransformerException {
GeneratorAdapter adapter = bc.getAdapter();
Type rtn = Types.OBJECT;
int count = members.size();
for (int i = 0; i < count; i++) {
adapter.loadArg(0);
}
expr.writeOut(bc, Expression.MODE_REF);
for (int i = 0; i < count; i++) {
Member member = members.get(i);
// Data Member
if (member instanceof DataMember) {
((DataMember) member).getName().writeOut(bc, MODE_REF);
adapter.invokeVirtual(Types.PAGE_CONTEXT, ((i + 1) == count) ? GET : GET_COLLECTION);
rtn = Types.OBJECT;
} else // UDF
if (member instanceof UDF) {
UDF udf = (UDF) member;
udf.getName().writeOut(bc, MODE_REF);
ExpressionUtil.writeOutExpressionArray(bc, Types.OBJECT, udf.getArguments());
adapter.invokeVirtual(Types.PAGE_CONTEXT, udf.hasNamedArgs() ? GET_FUNCTION_WITH_NAMED_ARGS : GET_FUNCTION);
rtn = Types.OBJECT;
}
}
return rtn;
}
use of lucee.transformer.expression.var.DataMember in project Lucee by lucee.
the class VT method _writeOutCallerUtil.
private Type _writeOutCallerUtil(BytecodeContext bc, int mode) throws TransformerException {
GeneratorAdapter adapter = bc.getAdapter();
final int count = countFM + countDM;
// count 0
if (count == 0)
return _writeOutEmpty(bc);
// pc
adapter.loadArg(0);
// collection
RefInteger startIndex = new RefIntegerImpl();
_writeOutFirst(bc, (members.get(0)), mode, count == 1, true, defaultValue, startIndex);
// keys
Iterator<Member> it = members.iterator();
ArrayVisitor av = new ArrayVisitor();
av.visitBegin(adapter, Types.COLLECTION_KEY, countDM - startIndex.toInt());
int index = 0, i = 0;
while (it.hasNext()) {
DataMember member = (DataMember) it.next();
if (i++ < startIndex.toInt())
continue;
av.visitBeginItem(adapter, index++);
getFactory().registerKey(bc, member.getName(), false);
av.visitEndItem(bc.getAdapter());
}
av.visitEnd();
// defaultValue
defaultValue.writeOut(bc, MODE_REF);
bc.getAdapter().invokeStatic(Types.CALLER_UTIL, CALLER_UTIL_GET);
return Types.OBJECT;
}
use of lucee.transformer.expression.var.DataMember in project Lucee by lucee.
the class VariableString method variableToStringArray.
public static String[] variableToStringArray(Variable var, boolean rawIfPossible) throws TransformerException {
List<Member> members = var.getMembers();
List<String> arr = new ArrayList<String>();
if (var.getScope() != Scope.SCOPE_UNDEFINED)
arr.add(ScopeFactory.toStringScope(var.getScope(), "undefined"));
Iterator<Member> it = members.iterator();
DataMember dm;
Expression n;
while (it.hasNext()) {
Object o = it.next();
if (!(o instanceof DataMember))
throw new TransformerException("can't translate Variable to a String", var.getStart());
dm = (DataMember) o;
n = dm.getName();
if (n instanceof Literal) {
if (rawIfPossible && n instanceof Identifier) {
arr.add(((Identifier) n).getRaw());
} else {
arr.add(((Literal) n).getString());
}
} else
throw new TransformerException("argument name must be a constant value", var.getStart());
}
return arr.toArray(new String[arr.size()]);
}
Aggregations