private CodegenExpression codegenEvaluateInternal(CodegenExpression event, CodegenClassScope codegenClassScope, CodegenMethodScope codegenMethodScope) { CodegenMethod method = codegenMethodScope.makeChild(Collection.class, PropertyDotScalarCollection.class, codegenClassScope).addParam(EventBean.class, "event").getBlock() .methodReturn(CodegenLegoCast.castSafeFromObjectType(Collection.class, getter.eventBeanGetCodegen(ref("event"), codegenMethodScope, codegenClassScope))); return localMethodBuild(method).pass(event).call(); } }
protected static CodegenExpression codegenWidenArrayAsListMayNull(CodegenExpression expression, Class arrayType, CodegenMethodScope codegenMethodScope, Class generator, CodegenClassScope codegenClassScope) { CodegenMethod method = codegenMethodScope.makeChild(Collection.class, generator, codegenClassScope).addParam(Object.class, "input").getBlock() .ifRefNullReturnNull("input") .methodReturn(staticMethod(Arrays.class, "asList", cast(arrayType, ref("input")))); return localMethodBuild(method).pass(expression).call(); } }
public CodegenExpression widenCodegen(CodegenExpression expression, CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { CodegenMethod method = codegenMethodScope.makeChild(ByteBuffer.class, TypeWidenerByteArrayToByteBufferCoercer.class, codegenClassScope).addParam(Object.class, "input").getBlock() .ifRefNullReturnNull("input") .methodReturn(staticMethod(ByteBuffer.class, "wrap", cast(byte[].class, ref("input")))); return localMethodBuild(method).pass(expression).call(); } }
public CodegenExpression codegenDate(CodegenExpression inner, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { CodegenExpressionField formatField = codegenFormatFieldInit(codegenClassScope); CodegenBlock blockMethod = codegenMethodScope.makeChild(String.class, ReformatFormatForge.class, codegenClassScope).addParam(Date.class, "d").getBlock() .synchronizedOn(formatField) .blockReturn(exprDotMethod(formatField, "format", ref("d"))); return localMethodBuild(blockMethod.methodEnd()).pass(inner).call(); }
public CodegenExpression codegenCal(CodegenExpression inner, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { CodegenExpressionField formatField = codegenFormatFieldInit(codegenClassScope); CodegenBlock blockMethod = codegenMethodScope.makeChild(String.class, ReformatFormatForge.class, codegenClassScope).addParam(Calendar.class, "cal").getBlock() .synchronizedOn(formatField) .blockReturn(exprDotMethod(formatField, "format", exprDotMethod(ref("cal"), "getTime"))); return localMethodBuild(blockMethod.methodEnd()).pass(inner).call(); }
public CodegenExpression calendarSetCodegen(CodegenExpression startLong, CodegenExpression cal, CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { return localMethodBuild(codegenMethodScope.makeChild(long.class, TimeAbacusMilliseconds.class, codegenClassScope).addParam(long.class, "fromTime").addParam(Calendar.class, "cal").getBlock() .expression(exprDotMethod(ref("cal"), "setTimeInMillis", ref("fromTime"))) .methodReturn(constant(0))).pass(startLong).pass(cal).call(); }
public CodegenExpression widenCodegen(CodegenExpression expression, CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { CodegenMethod method = codegenMethodScope.makeChild(Object.class, TypeWidenerSPI.class, codegenClassScope).addParam(Object.class, "input").getBlock() .ifCondition(instanceOf(ref("input"), EventBean.class)) .blockReturn(exprDotMethod(cast(EventBean.class, ref("input")), "getUnderlying")) .methodReturn(ref("input")); return localMethodBuild(method).pass(expression).call(); } };
protected CodegenExpression processFirstColCodegen(Class evaluationType, CodegenExpression expression, CodegenExpression resultEventType, CodegenExpression eventBeanFactory, CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { CodegenExpressionField type = VariantEventTypeUtil.getField(variantEventType, codegenClassScope); CodegenMethod method = codegenMethodScope.makeChild(EventBean.class, this.getClass(), codegenClassScope).addParam(evaluationType, "result").getBlock() .declareVar(EventType.class, "beanEventType", exprDotMethod(type, "eventTypeForNativeObject", ref("result"))) .declareVar(EventBean.class, "wrappedEvent", exprDotMethod(eventBeanFactory, "adapterForTypedBean", ref("result"), ref("beanEventType"))) .declareVar(EventBean.class, "variant", exprDotMethod(type, "getValueAddEventBean", ref("wrappedEvent"))) .methodReturn(exprDotMethod(eventBeanFactory, "adapterForTypedWrapper", ref("variant"), staticMethod(Collections.class, "emptyMap"), resultEventType)); return localMethodBuild(method).pass(expression).call(); } }
public CodegenExpression codegenZDT(CodegenExpression inner, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { CodegenExpression timeZoneField = codegenClassScope.addOrGetFieldSharable(RuntimeSettingsTimeZoneField.INSTANCE); CodegenMethod method = codegenMethodScope.makeChild(Calendar.class, ReformatToCalendarForge.class, codegenClassScope).addParam(ZonedDateTime.class, "zdt").getBlock() .declareVar(Calendar.class, "cal", staticMethod(Calendar.class, "getInstance", timeZoneField)) .exprDotMethod(ref("cal"), "setTimeInMillis", staticMethod(DatetimeLongCoercerZonedDateTime.class, "coerceZDTToMillis", ref("zdt"))) .methodReturn(ref("cal")); return localMethodBuild(method).pass(inner).call(); }
protected CodegenExpression codegenEventsPerStreamRewritten(CodegenExpression eventsPerStream, CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { CodegenBlock block = codegenMethodScope.makeChild(EventBean[].class, ExprDeclaredForgeRewrite.class, codegenClassScope).addParam(EventBean[].class, "eps").getBlock() .declareVar(EventBean[].class, "events", newArrayByLength(EventBean.class, constant(streamAssignments.length))); for (int i = 0; i < streamAssignments.length; i++) { block.assignArrayElement("events", constant(i), arrayAtIndex(ref("eps"), constant(streamAssignments[i]))); } return localMethodBuild(block.methodReturn(ref("events"))).pass(eventsPerStream).call(); } }
public CodegenExpression codegenLong(CodegenExpression inner, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { CodegenExpression timeZoneField = codegenClassScope.addOrGetFieldSharable(RuntimeSettingsTimeZoneField.INSTANCE); CodegenMethod method = codegenMethodScope.makeChild(int.class, ReformatEvalForge.class, codegenClassScope).addParam(long.class, "ts"); method.getBlock() .declareVar(Calendar.class, "cal", staticMethod(Calendar.class, "getInstance", timeZoneField)) .expression(timeAbacus.calendarSetCodegen(ref("ts"), ref("cal"), method, codegenClassScope)) .methodReturn(calendarEval.codegen(ref("cal"))); return localMethodBuild(method).pass(inner).call(); }
private CodegenExpression codegenEvaluateInternal(CodegenExpression event, CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { if (JavaClassHelper.isImplementsInterface(getterReturnType, Collection.class)) { return getter.eventBeanGetCodegen(event, codegenMethodScope, codegenClassScope); } CodegenMethod method = codegenMethodScope.makeChild(Collection.class, PropertyDotScalarIterable.class, codegenClassScope).addParam(EventBean.class, "event").getBlock() .declareVar(getterReturnType, "result", CodegenLegoCast.castSafeFromObjectType(Iterable.class, getter.eventBeanGetCodegen(ref("event"), codegenMethodScope, codegenClassScope))) .ifRefNullReturnNull("result") .methodReturn(staticMethod(CollectionUtil.class, "iterableToCollection", ref("result"))); return localMethodBuild(method).pass(event).call(); }
public CodegenExpression codegenLong(CodegenExpression inner, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope classScope) { CodegenExpressionField formatField = codegenFormatFieldInit(classScope); CodegenBlock blockMethod = codegenMethodScope.makeChild(String.class, ReformatFormatForge.class, classScope).addParam(long.class, "ts").getBlock(); CodegenBlock syncBlock = blockMethod.synchronizedOn(formatField); if (timeAbacus.getOneSecond() == 1000L) { syncBlock.blockReturn(exprDotMethod(formatField, "format", ref("ts"))); } else { syncBlock.blockReturn(exprDotMethod(formatField, "format", timeAbacus.toDateCodegen(ref("ts")))); } return localMethodBuild(blockMethod.methodEnd()).pass(inner).call(); }
public CodegenExpression codegen(CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope, CodegenExpressionRef left, CodegenExpressionRef right, Class ltype, Class rtype) { CodegenMethod method = codegenMethodScope.makeChild(BigDecimal.class, SubtractBigDecConvComputer.class, codegenClassScope).addParam(ltype, "d1").addParam(rtype, "d2").getBlock() .declareVar(BigDecimal.class, "s1", convOne.coerceBoxedBigDecCodegen(ref("d1"), ltype)) .declareVar(BigDecimal.class, "s2", convTwo.coerceBoxedBigDecCodegen(ref("d2"), rtype)) .methodReturn(exprDotMethod(ref("s1"), "subtract", ref("s2"))); return localMethodBuild(method).pass(left).pass(right).call(); } }
public CodegenExpression eventBeanGetMappedCodegen(CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope, CodegenExpression beanExpression, CodegenExpression key) { CodegenMethod method = codegenMethodScope.makeChild(Object.class, WrapperGetterMapped.class, codegenClassScope).addParam(EventBean.class, "event").addParam(String.class, "key").getBlock() .declareVar(DecoratingEventBean.class, "wrapper", cast(DecoratingEventBean.class, ref("event"))) .declareVar(EventBean.class, "wrapped", exprDotMethod(ref("wrapper"), "getUnderlyingEvent")) .ifRefNullReturnNull("wrapped") .methodReturn(undMapped.eventBeanGetMappedCodegen(codegenMethodScope, codegenClassScope, ref("wrapped"), ref("key"))); return localMethodBuild(method).pass(beanExpression).pass(key).call(); } };
public CodegenExpression eventBeanGetIndexedCodegen(CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope, CodegenExpression beanExpression, CodegenExpression key) { CodegenMethod method = codegenMethodScope.makeChild(Object.class, WrapperGetterIndexed.class, codegenClassScope).addParam(EventBean.class, "event").addParam(int.class, "index").getBlock() .declareVar(DecoratingEventBean.class, "wrapper", cast(DecoratingEventBean.class, ref("event"))) .declareVar(EventBean.class, "wrapped", exprDotMethod(ref("wrapper"), "getUnderlyingEvent")) .ifRefNullReturnNull("wrapped") .methodReturn(undIndexed.eventBeanGetIndexedCodegen(codegenMethodScope, codegenClassScope, ref("wrapped"), ref("index"))); return localMethodBuild(method).pass(beanExpression).pass(key).call(); } }
public CodegenExpression eventBeanGetMappedCodegen(CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope, CodegenExpression beanExpression, CodegenExpression key) { CodegenMethod method = codegenMethodScope.makeChild(Object.class, AvroEventBeanGetterMappedRuntimeKeyed.class, codegenClassScope).addParam(EventBean.class, "event").addParam(String.class, "key").getBlock() .declareVar(GenericData.Record.class, "record", castUnderlying(GenericData.Record.class, ref("event"))) .declareVar(Map.class, "values", cast(Map.class, exprDotMethod(ref("record"), "get", constant(pos)))) .methodReturn(staticMethod(AvroEventBeanGetterMapped.class, "getAvroMappedValueWNullCheck", ref("values"), ref("key"))); return localMethodBuild(method).pass(beanExpression).pass(key).call(); } }
public CodegenExpression codegen(CodegenExpression input, Class inputType, CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { CodegenMethod method = codegenMethodScope.makeChild(Character.class, CharacterCaster.class, codegenClassScope).addParam(Object.class, "object").getBlock() .declareVar(String.class, "value", exprDotMethod(ref("object"), "toString")) .ifCondition(equalsIdentity(exprDotMethod(ref("value"), "length"), constant(0))) .blockReturn(constantNull()) .methodReturn(exprDotMethod(ref("value"), "charAt", constant(0))); return localMethodBuild(method).pass(input).call(); } }
public CodegenExpression eventBeanGetMappedCodegen(CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope, CodegenExpression beanExpression, CodegenExpression key) { CodegenExpressionField factory = codegenClassScope.addOrGetFieldSharable(EventBeanTypedEventFactoryCodegenField.INSTANCE); CodegenExpressionField eventType = codegenClassScope.addFieldUnshared(true, EventType.class, EventTypeUtility.resolveTypeCodegen(underlyingEventType, EPStatementInitServices.REF)); CodegenMethod method = codegenMethodScope.makeChild(Object.class, WrapperEventType.class, codegenClassScope).addParam(EventBean.class, "theEvent").addParam(String.class, "mapKey").getBlock() .declareVar(DecoratingEventBean.class, "wrapperEvent", cast(DecoratingEventBean.class, ref("theEvent"))) .declareVar(Map.class, "map", exprDotMethod(ref("wrapperEvent"), "getDecoratingProperties")) .declareVar(EventBean.class, "wrapped", exprDotMethod(factory, "adapterForTypedMap", ref("map"), eventType)) .methodReturn(decoMapped.eventBeanGetMappedCodegen(codegenMethodScope, codegenClassScope, ref("wrapped"), ref("mapKey"))); return localMethodBuild(method).pass(beanExpression).pass(key).call(); } };
public CodegenExpression codegen(CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope, CodegenExpressionRef left, CodegenExpressionRef right, Class ltype, Class rtype) { CodegenMethod method = codegenMethodScope.makeChild(BigInteger.class, DivideBigIntConvComputer.class, codegenClassScope).addParam(ltype, "d1").addParam(rtype, "d2").getBlock() .declareVar(BigInteger.class, "s1", convOne.coerceBoxedBigIntCodegen(ref("d1"), ltype)) .declareVar(BigInteger.class, "s2", convTwo.coerceBoxedBigIntCodegen(ref("d2"), rtype)) .ifCondition(equalsIdentity(exprDotMethod(ref("s2"), "doubleValue"), constant(0))) .blockReturn(constantNull()) .methodReturn(exprDotMethod(ref("s1"), "divide", ref("s2"))); return localMethodBuild(method).pass(left).pass(right).call(); } }