public void setHint(int numOfChildren) { ArrayList list = new ArrayList(); for (int i = 0; i < numOfChildren; i++) { String hi = (String) this.stack.pop(); list.add(0, hi); } push(list); // setHints(list); }
/** * Yogesh: compiles order by clause and push into the stack * */ public void compileOrederByClause(int numOfChildren) { List list = new ArrayList(); for (int i = 0; i < numOfChildren; i++) { CompiledSortCriterion csc = (CompiledSortCriterion) this.stack.pop(); list.add(0, csc); } push(list); }
public void compileGroupByClause(int numOfChildren) { List list = new ArrayList(); for (int i = 0; i < numOfChildren; i++) { Object csc = this.stack.pop(); list.add(0, csc); } push(list); }
/** * Yogesh: compiles sort criteria present in order by clause and push into the stack * */ public void compileSortCriteria(String sortCriterion) { CompiledValue obj = (CompiledValue) this.stack.pop(); boolean criterion = false; if (sortCriterion.equals("desc")) criterion = true; CompiledSortCriterion csc = new CompiledSortCriterion(criterion, obj); push(csc); }
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)); }
@Override public void compile(QCompiler compiler) { super.compile(compiler); compiler.push(this.getText()); }
public void unaryMinus() { Object obj = this.stack.peek(); Assert.assertTrue(obj instanceof CompiledValue); push(new CompiledUnaryMinus((CompiledValue) pop())); }
public void compare(int opKind) { CompiledValue v2 = (CompiledValue) pop(); CompiledValue v1 = (CompiledValue) pop(); push(new CompiledComparison(v1, v2, opKind)); }
public void mod(int opKind) { CompiledValue v2 = (CompiledValue) pop(); CompiledValue v1 = (CompiledValue) pop(); push(new CompiledMod(v1, v2, opKind)); }
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}); }
private void addition(int opKind) { CompiledValue v2 = (CompiledValue) pop(); CompiledValue v1 = (CompiledValue) pop(); push(new CompiledAddition(v1, v2, opKind)); }
private void division(int opKind) { CompiledValue v2 = (CompiledValue) pop(); CompiledValue v1 = (CompiledValue) pop(); push(new CompiledDivision(v1, v2, opKind)); }
@Override public void compile(QCompiler compiler) { // resolve children type nodes if any, pushing on stack first // collections are pushed as CollectionTypes, but elementTypes are not yet resolved (set to // OBJECT_TYPE) super.compile(compiler); Assert.assertTrue(this.javaType != null ^ this.typeName != null); if (this.typeName != null) { this.javaType = compiler.resolveType(this.typeName); } compiler.push(this.javaType); }
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 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 void inExpr() { CompiledValue collnExpr = (CompiledValue) TypeUtils.checkCast(pop(), CompiledValue.class); CompiledValue elm = (CompiledValue) TypeUtils.checkCast(pop(), CompiledValue.class); push(new CompiledIn(elm, collnExpr)); }
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 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)); }