public CodegenExpression codegen(CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope, CodegenExpressionRef left, CodegenExpressionRef right, Class ltype, Class rtype) { return op(codegenAsLong(left, ltype), "+", codegenAsLong(right, rtype)); } }
public CodegenExpression codegen(CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope, CodegenExpressionRef left, CodegenExpressionRef right, Class ltype, Class rtype) { return op(codegenAsDouble(left, ltype), "*", codegenAsDouble(right, rtype)); } }
public CodegenExpression codegen(CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope, CodegenExpressionRef left, CodegenExpressionRef right, Class ltype, Class rtype) { return op(codegenAsFloat(left, ltype), "*", codegenAsFloat(right, rtype)); } }
public CodegenExpression codegen(CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope, CodegenExpressionRef left, CodegenExpressionRef right, Class ltype, Class rtype) { return op(codegenAsLong(left, ltype), "%", codegenAsLong(right, rtype)); } }
private void applyEvalLeaveNonNull(CodegenMethod method, CodegenExpression doubleExpression) { method.getBlock().declareVar(double.class, "p", doubleExpression) .ifCondition(relational(cnt, LE, constant(1))) .apply(getClear()) .ifElse() .decrement(cnt) .declareVar(double.class, "oldmean", mean) .assignCompound(mean, "-", op(op(ref("p"), "-", mean), "/", cnt)) .assignCompound(qn, "-", op(op(ref("p"), "-", ref("oldmean")), "*", op(ref("p"), "-", mean))); }
public void getValueCodegen(CodegenMethod method, CodegenClassScope classScope) { CodegenExpression sizeBuf = constant(factory.getSizeOfBuf()); method.getBlock().ifRefNullReturnNull(circularBuffer) .declareVar(int.class, "index", op(op(currentBufferElementPointer, "+", sizeBuf), "%", sizeBuf)) .methodReturn(arrayAtIndex(circularBuffer, ref("index"))); }
private void applyEvalEnterNonNull(CodegenMethod method, CodegenExpression doubleExpression) { method.getBlock().declareVar(double.class, "p", doubleExpression) .ifCondition(equalsIdentity(cnt, constant(0))) .assignRef(mean, ref("p")) .assignRef(qn, constant(0)) .assignRef(cnt, constant(1)) .ifElse() .increment(cnt) .declareVar(double.class, "oldmean", mean) .assignCompound(mean, "+", op(op(ref("p"), "-", mean), "/", cnt)) .assignCompound(qn, "+", op(op(ref("p"), "-", ref("oldmean")), "*", op(ref("p"), "-", mean))); }
protected void applyEvalLeaveNonNull(CodegenMethod method) { method.getBlock().ifCondition(relational(constant(factory.getSizeOfBuf()), GT, numDataPoints)) .declareVar(int.class, "diff", op(constant(factory.getSizeOfBuf()), "-", cast(int.class, numDataPoints))) .declareVar(int.class, "index", op(op(op(currentBufferElementPointer, "+", ref("diff")), "-", constant(1)), "%", constant(factory.getSizeOfBuf()))) .assignArrayElement(circularBuffer, ref("index"), constantNull()) .blockEnd() .decrement(numDataPoints); }
protected void applyEvalEnterNonNull(CodegenExpressionRef valueExpr, CodegenMethod method) { method.getBlock().increment(numDataPoints) .ifCondition(equalsNull(circularBuffer)) .apply(clearCode()) .blockEnd() .assignArrayElement(circularBuffer, currentBufferElementPointer, valueExpr) .assignRef(currentBufferElementPointer, op(op(currentBufferElementPointer, "+", constant(1)), "%", constant(factory.getSizeOfBuf()))); }
public CodegenExpression calendarSetCodegen(CodegenExpression startLong, CodegenExpression cal, CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { CodegenMethod method = codegenMethodScope.makeChild(long.class, TimeAbacusMicroseconds.class, codegenClassScope).addParam(long.class, "fromTime").addParam(Calendar.class, "cal").getBlock() .declareVar(long.class, "millis", op(ref("fromTime"), "/", constant(1000))) .expression(exprDotMethod(ref("cal"), "setTimeInMillis", ref("millis"))) .methodReturn(op(ref("fromTime"), "-", op(ref("millis"), "*", constant(1000)))); return localMethodBuild(method).pass(startLong).pass(cal).call(); }
public void getValueCodegen(CodegenMethod method, CodegenClassScope classScope) { method.getBlock().ifCondition(not(exprDotMethod(points, "isEmpty"))) .declareVar(long.class, "newest", cast(Long.class, exprDotMethod(points, "getLast"))) .declareVar(boolean.class, "leave", staticMethod(AggregatorRateEver.class, "removeFromHead", points, ref("newest"), constant(factory.getIntervalTime()))) .assignCompound(hasLeave, "|", ref("leave")) .blockEnd() .ifCondition(not(hasLeave)).blockReturn(constantNull()) .ifCondition(exprDotMethod(points, "isEmpty")).blockReturn(constant(0d)) .methodReturn(op(op(op(exprDotMethod(points, "size"), "*", constant(factory.getTimeAbacus().getOneSecond())), "*", constant(1d)), "/", constant(factory.getIntervalTime()))); }
public CodegenExpression getLastNthValueCodegen(CodegenExpressionRef index, CodegenMethod parentMethod, CodegenClassScope classScope, CodegenNamedMethods namedMethods) { CodegenMethod method = parentMethod.makeChildWithScope(EventBean.class, AggregatorAccessLinearNonJoin.class, CodegenSymbolProviderEmpty.INSTANCE, classScope).addParam(int.class, "index"); method.getBlock().ifCondition(relational(ref("index"), LT, constant(0))).blockReturn(constantNull()) .ifCondition(relational(ref("index"), GE, exprDotMethod(events, "size"))).blockReturn(constantNull()) .methodReturn(cast(EventBean.class, exprDotMethod(events, "get", op(op(exprDotMethod(events, "size"), "-", ref("index")), "-", constant(1))))); return localMethod(method, index); }
public CodegenExpression codegen(CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope, CodegenExpressionRef left, CodegenExpressionRef right, Class ltype, Class rtype) { if (!divisionByZeroReturnsNull) { return op(codegenAsDouble(left, ltype), "/", codegenAsDouble(right, rtype)); } CodegenMethod method = codegenMethodScope.makeChild(Double.class, DivideDouble.class, codegenClassScope).addParam(ltype, "d1").addParam(rtype, "d2").getBlock() .declareVar(double.class, "d2Double", codegenAsDouble(ref("d2"), rtype)) .ifCondition(equalsIdentity(ref("d2Double"), constant(0))) .blockReturn(constantNull()) .methodReturn(op(codegenAsDouble(ref("d1"), ltype), "/", ref("d2Double"))); return localMethodBuild(method).pass(left).pass(right).call(); } }
public CodegenExpression getLastValueCodegen(CodegenClassScope classScope, CodegenMethod parentMethod, CodegenNamedMethods namedMethods) { CodegenMethod method = parentMethod.makeChildWithScope(EventBean.class, AggregatorAccessLinearNonJoin.class, CodegenSymbolProviderEmpty.INSTANCE, classScope); method.getBlock().ifCondition(exprDotMethod(events, "isEmpty")).blockReturn(constantNull()) .methodReturn(cast(EventBean.class, exprDotMethod(events, "get", op(exprDotMethod(events, "size"), "-", constant(1))))); return localMethod(method); }
public CodegenExpression getLastNthValueCodegen(CodegenExpressionRef index, CodegenMethod parentMethod, CodegenClassScope classScope, CodegenNamedMethods namedMethods) { CodegenMethod initArray = initArrayCodegen(namedMethods, classScope); CodegenMethod method = parentMethod.makeChildWithScope(EventBean.class, AggregatorAccessLinearJoin.class, CodegenSymbolProviderEmpty.INSTANCE, classScope).addParam(int.class, "index"); method.getBlock().ifCondition(relational(ref("index"), LT, constant(0))).blockReturn(constantNull()) .ifCondition(exprDotMethod(refSet, "isEmpty")).blockReturn(constantNull()) .ifCondition(relational(ref("index"), GE, exprDotMethod(refSet, "size"))).blockReturn(constantNull()) .ifCondition(equalsNull(array)).localMethod(initArray).blockEnd() .methodReturn(arrayAtIndex(array, op(op(arrayLength(array), "-", ref("index")), "-", constant(1)))); return localMethod(method, index); }
public CodegenExpression getLastValueCodegen(CodegenClassScope classScope, CodegenMethod parentMethod, CodegenNamedMethods namedMethods) { CodegenMethod initArray = initArrayCodegen(namedMethods, classScope); CodegenMethod method = parentMethod.makeChildWithScope(EventBean.class, AggregatorAccessLinearJoin.class, CodegenSymbolProviderEmpty.INSTANCE, classScope); method.getBlock().ifCondition(exprDotMethod(refSet, "isEmpty")).blockReturn(constantNull()) .ifCondition(equalsNull(array)).localMethod(initArray).blockEnd() .methodReturn(arrayAtIndex(array, op(arrayLength(array), "-", constant(1)))); return localMethod(method); }
public CodegenExpression codegen(CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope, CodegenExpressionRef left, CodegenExpressionRef right, Class ltype, Class rtype) { CodegenMethod method = codegenMethodScope.makeChild(Integer.class, DivideInt.class, codegenClassScope).addParam(int.class, "i1").addParam(int.class, "i2").getBlock() .ifCondition(equalsIdentity(ref("i2"), constant(0))) .blockReturn(constantNull()) .methodReturn(op(ref("i1"), "/", ref("i2"))); return localMethod(method, codegenAsInt(left, ltype), codegenAsInt(right, rtype)); } }
public static void applyEnterCodegenSweep(CodegenMethod method, CodegenClassScope classScope, AggregationClassNames classNames) { CodegenExpressionField timeAbacus = classScope.addOrGetFieldSharable(TimeAbacusField.INSTANCE); method.getBlock().declareVar(long.class, "currentTime", exprDotMethodChain(REF_EXPREVALCONTEXT).add("getTimeProvider").add("getTime")) .ifCondition(or(equalsNull(REF_NEXTSWEEPTIME), relational(REF_NEXTSWEEPTIME, LE, ref("currentTime")))) .assignRef(REF_CURRENTMAXAGE, staticMethod(AggSvcGroupByReclaimAgedImpl.class, "computeTimeReclaimAgeFreq", REF_CURRENTMAXAGE, REF_EVALUATORFUNCTIONMAXAGE, timeAbacus)) .assignRef(REF_CURRENTRECLAIMFREQUENCY, staticMethod(AggSvcGroupByReclaimAgedImpl.class, "computeTimeReclaimAgeFreq", REF_CURRENTRECLAIMFREQUENCY, REF_EVALUATIONFUNCTIONFREQUENCY, timeAbacus)) .assignRef(REF_NEXTSWEEPTIME, op(ref("currentTime"), "+", REF_CURRENTRECLAIMFREQUENCY)) .localMethod(sweepCodegen(method, classScope, classNames), ref("currentTime"), REF_CURRENTMAXAGE); }
public CodegenExpression codegen(CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope, CodegenExpressionRef left, CodegenExpressionRef right, Class ltype, Class rtype) { CodegenBlock block = codegenMethodScope.makeChild(BigDecimal.class, DivideBigDec.class, codegenClassScope).addParam(BigDecimal.class, "b1").addParam(BigDecimal.class, "b2").getBlock(); CodegenBlock ifBlock = block.ifCondition(equalsIdentity(exprDotMethod(ref("b1"), "doubleValue"), constant(0d))); if (divisionByZeroReturnsNull) { ifBlock.blockReturn(constantNull()); } else { ifBlock.blockReturn(newInstance(BigDecimal.class, op(exprDotMethod(ref("b1"), "doubleValue"), "/", constant(0d)))); } CodegenMethod method = block.methodReturn(exprDotMethod(ref("b1"), "divide", ref("b2"))); return localMethod(method, left, right); } }