private CodegenMethod getFragmentCodegen(CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { return codegenMethodScope.makeChild(Object.class, this.getClass(), codegenClassScope).addParam(EventBean.class, "theEvent").getBlock() .declareVarWCast(DecoratingEventBean.class, "wrapperEvent", "theEvent") .declareVar(EventBean.class, "wrappedEvent", exprDotMethod(ref("wrapperEvent"), "getUnderlyingEvent")) .ifRefNullReturnNull("wrappedEvent") .methodReturn(underlyingGetter.eventBeanFragmentCodegen(ref("wrappedEvent"), codegenMethodScope, codegenClassScope)); }
public CodegenExpression make(CodegenMethodScope parent, SAIFFInitializeSymbol symbols, CodegenClassScope classScope) { CodegenMethod method = parent.makeChild(ContainedEventEvalGetter.class, this.getClass(), classScope); CodegenExpressionNewAnonymousClass anonymousClass = newAnonymousClass(method.getBlock(), EventPropertyFragmentGetter.class); CodegenMethod getFragment = CodegenMethod.makeParentNode(Object.class, this.getClass(), classScope).addParam(EventBean.class, "event"); anonymousClass.addMethod("getFragment", getFragment); getFragment.getBlock().methodReturn(getter.eventBeanFragmentCodegen(ref("event"), getFragment, classScope)); method.getBlock().methodReturn(newInstance(ContainedEventEvalGetter.class, anonymousClass)); return localMethod(method); } }
public CodegenExpression evaluateEventGetEventBeanCodegen(CodegenMethodScope parent, ExprEnumerationGivenEventSymbol symbols, CodegenClassScope codegenClassScope) { CodegenMethod methodNode = parent.makeChild(EventBean.class, PropertyDotEventSingleForge.class, codegenClassScope); methodNode.getBlock() .ifRefNullReturnNull(symbols.getAddEvent(methodNode)) .methodReturn(cast(EventBean.class, getter.eventBeanFragmentCodegen(symbols.getAddEvent(methodNode), methodNode, codegenClassScope))); return localMethod(methodNode); }
private CodegenMethod getFragmentCodegen(CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { return codegenMethodScope.makeChild(Object.class, this.getClass(), codegenClassScope).addParam(Object[].class, "array").getBlock() .declareVar(Object.class, "value", arrayAtIndex(ref("array"), constant(propertyIndex))) .ifRefNullReturnNull("value") .declareVarWCast(EventBean.class, "theEvent", "value") .methodReturn(eventBeanEntryGetter.eventBeanFragmentCodegen(ref("theEvent"), codegenMethodScope, codegenClassScope)); }
private CodegenMethod getFragmentCodegen(CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { return codegenMethodScope.makeChild(Object.class, this.getClass(), codegenClassScope).addParam(Map.class, "map").getBlock() .declareVar(Object.class, "value", exprDotMethod(ref("map"), "get", constant(propertyMap))) .ifRefNullReturnNull("value") .declareVar(EventBean.class, "theEvent", cast(EventBean.class, ref("value"))) .methodReturn(eventBeanEntryGetter.eventBeanFragmentCodegen(ref("theEvent"), codegenMethodScope, codegenClassScope)); }
public CodegenExpression evaluateGetEventBeanCodegen(CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { CodegenMethod methodNode = codegenMethodScope.makeChild(EventBean.class, PropertyDotEventSingleForge.class, codegenClassScope); CodegenExpressionRef refEPS = exprSymbol.getAddEPS(methodNode); methodNode.getBlock() .declareVar(EventBean.class, "event", arrayAtIndex(refEPS, constant(streamId))) .ifRefNullReturnNull("event") .methodReturn(cast(EventBean.class, getter.eventBeanFragmentCodegen(ref("event"), methodNode, codegenClassScope))); return localMethod(methodNode); }
public CodegenExpression evaluateCodegen(Class requiredType, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { CodegenMethod methodNode = codegenMethodScope.makeChild(EventBean.class, PropertyDotNonLambdaFragmentForge.class, codegenClassScope); CodegenExpressionRef refEPS = exprSymbol.getAddEPS(methodNode); methodNode.getBlock() .declareVar(EventBean.class, "event", arrayAtIndex(refEPS, constant(streamId))) .ifRefNullReturnNull("event") .methodReturn(cast(EventBean.class, getter.eventBeanFragmentCodegen(ref("event"), methodNode, codegenClassScope))); return localMethod(methodNode); }
public CodegenExpression evaluateCodegen(Class requiredType, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { Class result = fragmentType.isIndexed() ? EventBean[].class : EventBean.class; CodegenMethod methodNode = codegenMethodScope.makeChild(result, ExprEvalByGetterFragment.class, codegenClassScope); CodegenExpressionRef refEPS = exprSymbol.getAddEPS(methodNode); methodNode.getBlock() .declareVar(EventBean.class, "event", arrayAtIndex(refEPS, constant(streamNum))) .ifRefNullReturnNull("event") .methodReturn(cast(result, getter.eventBeanFragmentCodegen(ref("event"), methodNode, codegenClassScope))); return localMethod(methodNode); }
public static CodegenMethod getArrayPropertyFragmentCodegen(CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope, int index, EventPropertyGetterSPI nestedGetter) { return codegenMethodScope.makeChild(Object.class, BaseNestableEventUtil.class, codegenClassScope).addParam(EventBean[].class, "wrapper").getBlock() .ifRefNullReturnNull("wrapper") .ifConditionReturnConst(relational(arrayLength(ref("wrapper")), LE, constant(index)), null) .declareVar(EventBean.class, "inner", arrayAtIndex(ref("wrapper"), constant(index))) .methodReturn(nestedGetter.eventBeanFragmentCodegen(ref("inner"), codegenMethodScope, codegenClassScope)); }
public static CodegenMethod from(CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope, Class expectedUnderlyingType, EventPropertyGetterSPI innerGetter, AccessType accessType, Class generator) { CodegenMethod methodNode = codegenMethodScope.makeChild(accessType == AccessType.EXISTS ? boolean.class : Object.class, generator, codegenClassScope).addParam(Object.class, "value"); CodegenBlock block = methodNode.getBlock() .ifNotInstanceOf("value", expectedUnderlyingType) .ifInstanceOf("value", EventBean.class) .declareVarWCast(EventBean.class, "bean", "value"); if (accessType == AccessType.GET) { block = block.blockReturn(innerGetter.eventBeanGetCodegen(ref("bean"), codegenMethodScope, codegenClassScope)); } else if (accessType == AccessType.EXISTS) { block = block.blockReturn(innerGetter.eventBeanExistsCodegen(ref("bean"), codegenMethodScope, codegenClassScope)); } else if (accessType == AccessType.FRAGMENT) { block = block.blockReturn(innerGetter.eventBeanFragmentCodegen(ref("bean"), codegenMethodScope, codegenClassScope)); } else { throw new UnsupportedOperationException("Invalid access type " + accessType); } block = block.blockReturn(constant(accessType == AccessType.EXISTS ? false : null)); CodegenExpression expression; if (accessType == AccessType.GET) { expression = innerGetter.underlyingGetCodegen(cast(expectedUnderlyingType, ref("value")), codegenMethodScope, codegenClassScope); } else if (accessType == AccessType.EXISTS) { expression = innerGetter.underlyingExistsCodegen(cast(expectedUnderlyingType, ref("value")), codegenMethodScope, codegenClassScope); } else if (accessType == AccessType.FRAGMENT) { expression = innerGetter.underlyingFragmentCodegen(cast(expectedUnderlyingType, ref("value")), codegenMethodScope, codegenClassScope); } else { throw new UnsupportedOperationException("Invalid access type " + accessType); } block.methodReturn(expression); return methodNode; }
public CodegenExpression evaluateCodegen(Class requiredType, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { CodegenMethod methodNode = codegenMethodScope.makeChild(Long.class, ExprEvaluatorStreamDTPropFragment.class, codegenClassScope); CodegenExpressionRef refEPS = exprSymbol.getAddEPS(methodNode); methodNode.getBlock() .declareVar(EventBean.class, "theEvent", arrayAtIndex(refEPS, constant(streamId))) .ifRefNullReturnNull("theEvent") .declareVar(Object.class, "event", getterFragment.eventBeanFragmentCodegen(ref("theEvent"), methodNode, codegenClassScope)) .ifCondition(not(instanceOf(ref("event"), EventBean.class))) .blockReturn(constantNull()) .methodReturn(CodegenLegoCast.castSafeFromObjectType(Long.class, getterTimestamp.eventBeanGetCodegen(cast(EventBean.class, ref("event")), methodNode, codegenClassScope))); return localMethod(methodNode); }
private CodegenExpression codegenEvaluateInternal(CodegenExpressionRef event, Function<CodegenMethod, CodegenExpressionRef> refExprEvalCtxFunc, CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { if (disablePropertyExpressionEventCollCache) { CodegenMethod methodNode = codegenMethodScope.makeChild(Collection.class, PropertyDotEventCollectionForge.class, codegenClassScope).addParam(EventBean.class, "event"); methodNode.getBlock() .declareVar(EventBean[].class, "events", cast(EventBean[].class, getter.eventBeanFragmentCodegen(ref("event"), methodNode, codegenClassScope))) .ifRefNullReturnNull("events") .methodReturn(staticMethod(Arrays.class, "asList", ref("events"))); return localMethod(methodNode, event); } CodegenMethod methodNode = codegenMethodScope.makeChild(Collection.class, PropertyDotEventCollectionForge.class, codegenClassScope).addParam(EventBean.class, "event"); CodegenExpressionRef refExprEvalCtx = refExprEvalCtxFunc.apply(methodNode); methodNode.getBlock() .declareVar(ExpressionResultCacheForPropUnwrap.class, "cache", exprDotMethodChain(refExprEvalCtx).add("getExpressionResultCacheService").add("getAllocateUnwrapProp")) .declareVar(ExpressionResultCacheEntryBeanAndCollBean.class, "cacheEntry", exprDotMethod(ref("cache"), "getPropertyColl", constant(propertyNameCache), ref("event"))) .ifCondition(notEqualsNull(ref("cacheEntry"))) .blockReturn(exprDotMethod(ref("cacheEntry"), "getResult")) .declareVar(EventBean[].class, "events", cast(EventBean[].class, getter.eventBeanFragmentCodegen(ref("event"), methodNode, codegenClassScope))) .declareVarNoInit(Collection.class, "coll") .ifRefNull("events") .assignRef("coll", constantNull()) .ifElse() .assignRef("coll", staticMethod(Arrays.class, "asList", ref("events"))) .blockEnd() .expression(exprDotMethod(ref("cache"), "savePropertyColl", constant(propertyNameCache), ref("event"), ref("coll"))) .methodReturn(ref("coll")); return localMethod(methodNode, event); }
public CodegenExpression evaluateCodegenUninstrumented(Class requiredType, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { CodegenMethod methodNode = codegenMethodScope.makeChild(String.class, ExprTypeofNodeForgeFragmentType.class, codegenClassScope); CodegenExpressionRef refEPS = exprSymbol.getAddEPS(methodNode); methodNode.getBlock() .declareVar(EventBean.class, "event", arrayAtIndex(refEPS, constant(streamId))) .ifRefNullReturnNull("event") .declareVar(Object.class, "fragment", getter.eventBeanFragmentCodegen(ref("event"), methodNode, codegenClassScope)) .ifRefNullReturnNull("fragment") .ifInstanceOf("fragment", EventBean.class) .blockReturn(exprDotMethodChain(cast(EventBean.class, ref("fragment"))).add("getEventType").add("getName")) .ifCondition(exprDotMethodChain(ref("fragment")).add("getClass").add("isArray")) .blockReturn(constant(fragmentType + "[]")) .methodReturn(constantNull()); return localMethod(methodNode); }
CodegenExpression fragment = ((EventTypeSPI) eventTypes[underlyingStreamNumber]).getGetterSPI(unnamedStreams.get(0).getStreamSelected().getStreamName()).eventBeanFragmentCodegen(ref("eventBean"), methodNode, codegenClassScope); block.declareVar(EventBean.class, "eventBean", arrayAtIndex(refEPS, constant(underlyingStreamNumber))) .declareVar(EventBean.class, "theEvent", cast(EventBean.class, fragment));
CodegenBlock foreach = method.getBlock().forEach(EventBean.class, "event", symbols.getAddMatchingEvents(method)); foreach.declareVar(Object.class, "fragment", eval.getGetter().eventBeanFragmentCodegen(ref("event"), method, classScope)) .ifRefNull("fragment").blockContinue() .exprDotMethod(ref("events"), "add", ref("fragment"));