public CodegenExpression makeCopyMethodClassScoped(CodegenClassScope classScope) { CodegenExpressionField factory = classScope.addOrGetFieldSharable(EventBeanTypedEventFactoryCodegenField.INSTANCE); return newInstance(WrapperEventBeanUndCopyMethod.class, cast(WrapperEventType.class, EventTypeUtility.resolveTypeCodegen(wrapperEventType, EPStatementInitServices.REF)), factory, underlyingCopyMethod.makeCopyMethodClassScoped(classScope)); }
public CodegenExpression makeCopyMethodClassScoped(CodegenClassScope classScope) { CodegenExpressionField factory = classScope.addOrGetFieldSharable(EventBeanTypedEventFactoryCodegenField.INSTANCE); return newInstance(WrapperEventBeanCopyMethod.class, cast(WrapperEventType.class, EventTypeUtility.resolveTypeCodegen(wrapperEventType, EPStatementInitServices.REF)), factory, underlyingCopyMethod.makeCopyMethodClassScoped(classScope)); }
private static CodegenExpression makeCopyMethods(Map<EventTypeSPI, EventBeanCopyMethodForge> copyMethods, CodegenMethodScope parent, SAIFFInitializeSymbol symbols, CodegenClassScope classScope) { if (copyMethods.isEmpty()) { return staticMethod(Collections.class, "emptyMap"); } CodegenMethod method = parent.makeChild(Map.class, VariableReadWritePackageForge.class, classScope); method.getBlock().declareVar(Map.class, "methods", newInstance(HashMap.class, constant(copyMethods.size()))); for (Map.Entry<EventTypeSPI, EventBeanCopyMethodForge> entry : copyMethods.entrySet()) { CodegenExpression type = EventTypeUtility.resolveTypeCodegen(entry.getKey(), symbols.getAddInitSvc(method)); CodegenExpression copyMethod = entry.getValue().makeCopyMethodClassScoped(classScope); method.getBlock().exprDotMethod(ref("methods"), "put", type, copyMethod); } method.getBlock().methodReturn(ref("methods")); return localMethod(method); }
public CodegenExpression makeWCopy(CodegenMethodScope scope, CodegenClassScope classScope) { CodegenExpressionField copyMethodField = classScope.addFieldUnshared(true, EventBeanCopyMethod.class, copyMethod.makeCopyMethodClassScoped(classScope)); CodegenMethod method = scope.makeChild(EventBeanUpdateHelperWCopy.class, this.getClass(), classScope); CodegenMethod updateInternal = makeUpdateInternal(method, classScope); CodegenExpressionNewAnonymousClass clazz = newAnonymousClass(method.getBlock(), EventBeanUpdateHelperWCopy.class); CodegenMethod updateWCopy = CodegenMethod.makeParentNode(EventBean.class, this.getClass(), classScope) .addParam(EventBean.class, "matchingEvent") .addParam(EventBean[].class, NAME_EPS) .addParam(ExprEvaluatorContext.class, NAME_EXPREVALCONTEXT); clazz.addMethod("updateWCopy", updateWCopy); updateWCopy.getBlock() .apply(instblock(classScope, "qInfraUpdate", ref("matchingEvent"), REF_EPS, constant(updateItems.length), constantTrue())) .declareVar(EventBean.class, "copy", exprDotMethod(copyMethodField, "copy", ref("matchingEvent"))) .assignArrayElement(REF_EPS, constant(0), ref("copy")) .assignArrayElement(REF_EPS, constant(2), ref("matchingEvent")) .localMethod(updateInternal, REF_EPS, REF_EXPREVALCONTEXT, ref("copy")) .apply(instblock(classScope, "aInfraUpdate", ref("copy"))) .methodReturn(ref("copy")); method.getBlock().methodReturn(clazz); return localMethod(method); }