public void projection() { // find an id or null on the stack, then an expr CompiledValue // push an Object[2] on the stack. First element is id, second is CompiledValue CompiledID id = (CompiledID) pop(); CompiledValue expr = (CompiledValue) pop(); push(new Object[] {id == null ? null : id.getId(), expr}); }
public void combine(int num) { List list = new ArrayList(); for (int i = 0; i < num; i++) { list.add(0, pop()); } push(list); }
public void function(int function, int numOfChildren) { CompiledValue[] cvArr = new CompiledValue[numOfChildren]; for (int i = numOfChildren - 1; i >= 0; i--) { cvArr[i] = (CompiledValue) pop(); } push(new CompiledFunction(cvArr, function)); }
public void methodInvocation() { // find on stack: // argList, methodName, receiver (which may be null if receiver is implicit) List argList = (List) TypeUtils.checkCast(pop(), List.class); CompiledID methodName = (CompiledID) TypeUtils.checkCast(pop(), CompiledID.class); CompiledValue rcvr = (CompiledValue) TypeUtils.checkCast(pop(), CompiledValue.class); push(new CompiledOperation(rcvr, methodName.getId(), argList)); }
public void appendPathComponent(String id) { CompiledValue rcvr = (CompiledValue) pop(); push(new CompiledPath(rcvr, id)); }
public void undefinedExpr(boolean is_defined) { CompiledValue value = (CompiledValue) pop(); push(new CompiledUndefined(value, is_defined)); }
public void unaryMinus() { Object obj = this.stack.peek(); Assert.assertTrue(obj instanceof CompiledValue); push(new CompiledUnaryMinus((CompiledValue) pop())); }
public void not() { Object obj = this.stack.peek(); Assert.assertTrue(obj instanceof CompiledValue); if (obj instanceof Negatable) ((Negatable) obj).negate(); else push(new CompiledNegation((CompiledValue) pop())); }
public void iteratorDef() { // find type id and colln on the stack ObjectType type = assembleType(); // can be null CompiledID id = (CompiledID) TypeUtils.checkCast(pop(), CompiledID.class); // can be null CompiledValue colln = (CompiledValue) TypeUtils.checkCast(pop(), CompiledValue.class); if (type == null) { type = TypeUtils.OBJECT_TYPE; } push(new CompiledIteratorDef(id == null ? null : id.getId(), type, colln)); }
public void typecast() { // pop expr and type, apply type, then push result AbstractCompiledValue cmpVal = (AbstractCompiledValue) TypeUtils.checkCast(pop(), AbstractCompiledValue.class); ObjectType objType = assembleType(); cmpVal.setTypecast(objType); push(cmpVal); }
public void constructObject(Class clazz) { // find argList on stack // only support SET for now Assert.assertTrue(clazz == ResultsSet.class); List argList = (List) TypeUtils.checkCast(pop(), List.class); push(new CompiledConstruction(clazz, argList)); }
public ObjectType assembleType() { ObjectType objType = (ObjectType) TypeUtils.checkCast(pop(), ObjectType.class); if (objType instanceof CollectionType) { // pop the elementType ObjectType elementType = assembleType(); if (objType instanceof MapType) { // pop the key type ObjectType keyType = assembleType(); return new MapTypeImpl(objType.resolveClass(), keyType, elementType); } return new CollectionTypeImpl(objType.resolveClass(), elementType); } return objType; }