@Override public void eval(Interpreter interpreter, Expression... args) { Bag eres = null; if (args.length < 1) { eres = new Bag(); } else { // mamy generyczny bag - args[1] okresla jego typ Expression bagTypeExpr = args[1]; bagTypeExpr.accept(interpreter, null); QueryResult qr = interpreter.getQres().pop(); QueryResult clazz = Utils.collectionToObject(qr); JavaClass<Collection> jc = (JavaClass<Collection>) clazz; try { Collection c = jc.value.newInstance(); eres = new Bag<Collection<QueryResult>>(c); } catch (Exception e) { throw new SBQLException(e); } } QueryResult e1res = interpreter.getQres().pop(); StructSBQL s; if (e1res instanceof StructSBQL) { s = (StructSBQL) e1res; } else { s = new StructSBQL(); if (e1res instanceof Collection) { s.addAll((Collection) e1res); } else { s.add(e1res); } } eres.addAll(s); interpreter.getQres().push(eres); }
@Override public void eval(Interpreter interpreter, Expression... args) { Object rightArg = Utils.toSimpleValue(interpreter.getQres().pop(), interpreter.getStore()); Object leftArg = Utils.toSimpleValue(interpreter.getQres().pop(), interpreter.getStore()); Boolean result; if (leftArg instanceof Number && rightArg instanceof Number) { Number n1 = (Number) leftArg; Number n2 = (Number) rightArg; result = n1.doubleValue() > n2.doubleValue(); } else { Comparable c1 = (Comparable) leftArg; Comparable c2 = (Comparable) rightArg; int cRes = MathUtils.compareSafe(c1, c2); result = cRes > 0; } JavaComplexObject res = JavaObjectAbstractFactory.getJavaObjectFactory().createJavaComplexObject(result); interpreter.getQres().push(res); }