private CodegenExpression makeInstrumentationProvider(CodegenMethod method, CodegenClassScope classScope) { if (!instrumented) { return constantNull(); } CodegenExpressionNewAnonymousClass anonymousClass = newAnonymousClass(method.getBlock(), InstrumentationCommon.class); CodegenMethod activated = CodegenMethod.makeParentNode(boolean.class, this.getClass(), classScope); anonymousClass.addMethod("activated", activated); activated.getBlock().methodReturn(constantTrue()); for (Method forwarded : InstrumentationCommon.class.getMethods()) { if (forwarded.getDeclaringClass() == Object.class) { continue; } if (forwarded.getName().equals("activated")) { continue; } List<CodegenNamedParam> params = new ArrayList<>(); CodegenExpression[] expressions = new CodegenExpression[forwarded.getParameterCount()]; int num = 0; for (Parameter param : forwarded.getParameters()) { params.add(new CodegenNamedParam(param.getType(), param.getName())); expressions[num] = ref(param.getName()); num++; } CodegenMethod m = CodegenMethod.makeParentNode(void.class, this.getClass(), classScope).addParam(params); anonymousClass.addMethod(forwarded.getName(), m); m.getBlock().apply(InstrumentationCode.instblock(classScope, forwarded.getName(), expressions)); } return anonymousClass; }
public static CodegenExpressionNewAnonymousClass newAnonymousClass(CodegenBlock parentBlock, Class interfaceOrSuperClass, List<CodegenExpression> ctorParams) { return new CodegenExpressionNewAnonymousClass(parentBlock, interfaceOrSuperClass, ctorParams); }
public void render(StringBuilder builder, Map<Class, String> imports, boolean isInnerClass) { render(builder, imports, isInnerClass, 4, new CodegenIndent(true)); }
public CodegenExpression makeAnonymous(CodegenMethod method, CodegenClassScope classScope) { CodegenExpressionNewAnonymousClass clazz = newAnonymousClass(method.getBlock(), MatchedEventConvertor.class); CodegenMethod convert = CodegenMethod.makeParentNode(EventBean[].class, this.getClass(), classScope).addParam(MatchedEventMap.class, "events"); clazz.addMethod("convert", convert); convert.getBlock().methodReturn(localMethod(make(convert, classScope), ref("events"))); return clazz; } }
public static CodegenExpressionNewAnonymousClass newAnonymousClass(CodegenBlock parentBlock, Class interfaceOrSuperClass) { return new CodegenExpressionNewAnonymousClass(parentBlock, interfaceOrSuperClass, Collections.emptyList()); }
public CodegenExpression initCtorScoped() { CodegenExpressionNewAnonymousClass anonymousClass = newAnonymousClass(classScope.getPackageScope().getInitMethod().getBlock(), SimpleTypeParser.class); CodegenMethod parse = CodegenMethod.makeParentNode(Object.class, this.getClass(), classScope).addParam(String.class, "text"); anonymousClass.addMethod("parse", parse); parse.getBlock().methodReturn(parser.codegen(ref("text"))); return anonymousClass; }
public static void makeSubstitutionSetter(CodegenPackageScope packageScope, CodegenMethod method, CodegenClassScope classScope) { CodegenExpressionNewAnonymousClass assignerSetterClass = newAnonymousClass(method.getBlock(), FAFQueryMethodAssignerSetter.class); method.getBlock().methodReturn(assignerSetterClass); CodegenMethod assignMethod = CodegenMethod.makeParentNode(void.class, StmtClassForgableStmtFields.class, classScope).addParam(StatementAIFactoryAssignments.class, "assignments"); assignerSetterClass.addMethod("assign", assignMethod); assignMethod.getBlock().staticMethod(packageScope.getFieldsClassNameOptional(), "assign", ref("assignments")); CodegenMethod setValueMethod = CodegenMethod.makeParentNode(void.class, StmtClassForgableStmtFields.class, classScope).addParam(int.class, "index").addParam(Object.class, "value"); assignerSetterClass.addMethod("setValue", setValueMethod); CodegenSubstitutionParamEntry.codegenSetterMethod(classScope, setValueMethod); }
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); } }
static CodegenExpression makeAnonymous(FilterSpecParamFilterForEvalDoubleForge eval, Class originator, CodegenClassScope classScope, CodegenMethod method) { CodegenExpressionNewAnonymousClass anonymousClass = newAnonymousClass(method.getBlock(), FilterSpecParamFilterForEvalDouble.class); CodegenMethod getFilterValueDouble = CodegenMethod.makeParentNode(Double.class, originator, classScope).addParam(GET_FILTER_VALUE_FP); anonymousClass.addMethod("getFilterValueDouble", getFilterValueDouble); getFilterValueDouble.getBlock().methodReturn(cast(Double.class, eval.makeCodegen(classScope, getFilterValueDouble))); CodegenMethod getFilterValue = CodegenMethod.makeParentNode(Object.class, originator, classScope).addParam(GET_FILTER_VALUE_FP); anonymousClass.addMethod("getFilterValue", getFilterValue); getFilterValue.getBlock().methodReturn(exprDotMethod(ref("this"), "getFilterValueDouble", REF_MATCHEDEVENTMAP, REF_EXPREVALCONTEXT, REF_STMTCTXFILTEREVALENV)); return anonymousClass; } }
public CodegenExpression make(CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { CodegenMethod init = codegenClassScope.getPackageScope().getInitMethod(); CodegenExpressionField factory = codegenClassScope.addOrGetFieldSharable(EventBeanTypedEventFactoryCodegenField.INSTANCE); CodegenExpressionField beanType = codegenClassScope.addFieldUnshared(true, EventType.class, EventTypeUtility.resolveTypeCodegen(eventType, EPStatementInitServices.REF)); CodegenExpressionNewAnonymousClass manufacturer = newAnonymousClass(init.getBlock(), EventBeanManufacturer.class); CodegenMethod makeUndMethod = CodegenMethod.makeParentNode(GenericData.Record.class, this.getClass(), codegenClassScope).addParam(Object[].class, "properties"); manufacturer.addMethod("makeUnderlying", makeUndMethod); makeUnderlyingCodegen(makeUndMethod, codegenClassScope); CodegenMethod makeMethod = CodegenMethod.makeParentNode(EventBean.class, this.getClass(), codegenClassScope).addParam(Object[].class, "properties"); manufacturer.addMethod("make", makeMethod); makeMethod.getBlock() .declareVar(GenericData.Record.class, "und", localMethod(makeUndMethod, ref("properties"))) .methodReturn(exprDotMethod(factory, "adapterForTypedAvro", ref("und"), beanType)); return codegenClassScope.addFieldUnshared(true, EventBeanManufacturer.class, manufacturer); }
public CodegenExpression make(CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { CodegenMethod init = codegenClassScope.getPackageScope().getInitMethod(); CodegenExpressionField factory = codegenClassScope.addOrGetFieldSharable(EventBeanTypedEventFactoryCodegenField.INSTANCE); CodegenExpressionField beanType = codegenClassScope.addFieldUnshared(true, EventType.class, EventTypeUtility.resolveTypeCodegen(beanEventType, EPStatementInitServices.REF)); CodegenExpressionNewAnonymousClass manufacturer = newAnonymousClass(init.getBlock(), EventBeanManufacturer.class); CodegenMethod makeUndMethod = CodegenMethod.makeParentNode(Object.class, this.getClass(), codegenClassScope).addParam(Object[].class, "properties"); manufacturer.addMethod("makeUnderlying", makeUndMethod); makeUnderlyingCodegen(makeUndMethod, codegenClassScope); CodegenMethod makeMethod = CodegenMethod.makeParentNode(EventBean.class, this.getClass(), codegenClassScope).addParam(Object[].class, "properties"); manufacturer.addMethod("make", makeMethod); makeMethod.getBlock() .declareVar(Object.class, "und", localMethod(makeUndMethod, ref("properties"))) .methodReturn(exprDotMethod(factory, "adapterForTypedBean", ref("und"), beanType)); return codegenClassScope.addFieldUnshared(true, EventBeanManufacturer.class, manufacturer); }
public CodegenExpression make(CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { CodegenMethod init = codegenClassScope.getPackageScope().getInitMethod(); CodegenExpressionField factory = codegenClassScope.addOrGetFieldSharable(EventBeanTypedEventFactoryCodegenField.INSTANCE); CodegenExpressionField eventType = codegenClassScope.addFieldUnshared(true, EventType.class, EventTypeUtility.resolveTypeCodegen(this.eventType, EPStatementInitServices.REF)); CodegenExpressionNewAnonymousClass manufacturer = newAnonymousClass(init.getBlock(), EventBeanManufacturer.class); CodegenMethod makeUndMethod = CodegenMethod.makeParentNode(Object[].class, this.getClass(), codegenClassScope).addParam(Object[].class, "properties"); manufacturer.addMethod("makeUnderlying", makeUndMethod); makeUnderlyingCodegen(makeUndMethod, codegenClassScope); CodegenMethod makeMethod = CodegenMethod.makeParentNode(EventBean.class, this.getClass(), codegenClassScope).addParam(Object[].class, "properties"); manufacturer.addMethod("make", makeMethod); makeMethod.getBlock() .declareVar(Object[].class, "und", localMethod(makeUndMethod, ref("properties"))) .methodReturn(exprDotMethod(factory, "adapterForTypedObjectArray", ref("und"), eventType)); return codegenClassScope.addFieldUnshared(true, EventBeanManufacturer.class, manufacturer); }
public static CodegenExpression codegenExprEnumEval(ExprEnumerationGivenEventForge enumEval, CodegenMethod method, SAIFFInitializeSymbol symbols, CodegenClassScope classScope, Class generator) { CodegenExpressionNewAnonymousClass evaluator = newAnonymousClass(method.getBlock(), ExprEnumerationGivenEvent.class); ExprEnumerationGivenEventSymbol enumSymbols = new ExprEnumerationGivenEventSymbol(); CodegenMethod evaluateEventGetROCollectionEvents = CodegenMethod.makeParentNode(Collection.class, generator, enumSymbols, classScope).addParam(EventBean.class, "event").addParam(ExprEvaluatorContext.class, NAME_EXPREVALCONTEXT); evaluator.addMethod("evaluateEventGetROCollectionEvents", evaluateEventGetROCollectionEvents); evaluateEventGetROCollectionEvents.getBlock().methodReturn(enumEval.evaluateEventGetROCollectionEventsCodegen(evaluateEventGetROCollectionEvents, enumSymbols, classScope)); CodegenMethod evaluateEventGetROCollectionScalar = CodegenMethod.makeParentNode(Collection.class, generator, enumSymbols, classScope).addParam(EventBean.class, "event").addParam(ExprEvaluatorContext.class, NAME_EXPREVALCONTEXT); evaluator.addMethod("evaluateEventGetROCollectionScalar", evaluateEventGetROCollectionScalar); evaluateEventGetROCollectionScalar.getBlock().methodReturn(enumEval.evaluateEventGetROCollectionScalarCodegen(evaluateEventGetROCollectionScalar, enumSymbols, classScope)); CodegenMethod evaluateEventGetEventBean = CodegenMethod.makeParentNode(EventBean.class, generator, enumSymbols, classScope).addParam(EventBean.class, "event").addParam(ExprEvaluatorContext.class, NAME_EXPREVALCONTEXT); evaluator.addMethod("evaluateEventGetEventBean", evaluateEventGetEventBean); evaluateEventGetEventBean.getBlock().methodReturn(enumEval.evaluateEventGetEventBeanCodegen(evaluateEventGetEventBean, enumSymbols, classScope)); return evaluator; } }
public CodegenExpression make(CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { CodegenMethod init = codegenClassScope.getPackageScope().getInitMethod(); CodegenExpressionField factory = codegenClassScope.addOrGetFieldSharable(EventBeanTypedEventFactoryCodegenField.INSTANCE); CodegenExpressionField eventType = codegenClassScope.addFieldUnshared(true, EventType.class, EventTypeUtility.resolveTypeCodegen(mapEventType, EPStatementInitServices.REF)); CodegenExpressionNewAnonymousClass manufacturer = newAnonymousClass(init.getBlock(), EventBeanManufacturer.class); CodegenMethod makeUndMethod = CodegenMethod.makeParentNode(Map.class, this.getClass(), codegenClassScope).addParam(Object[].class, "properties"); manufacturer.addMethod("makeUnderlying", makeUndMethod); makeUnderlyingCodegen(makeUndMethod, codegenClassScope); CodegenMethod makeMethod = CodegenMethod.makeParentNode(EventBean.class, this.getClass(), codegenClassScope).addParam(Object[].class, "properties"); manufacturer.addMethod("make", makeMethod); makeMethod.getBlock() .declareVar(Map.class, "und", localMethod(makeUndMethod, ref("properties"))) .methodReturn(exprDotMethod(factory, "adapterForTypedMap", ref("und"), eventType)); return codegenClassScope.addFieldUnshared(true, EventBeanManufacturer.class, manufacturer); }
public static CodegenExpression codegenWidener(TypeWidenerSPI widener, CodegenMethod method, Class originator, CodegenClassScope classScope) { CodegenExpressionNewAnonymousClass anonymousClass = newAnonymousClass(method.getBlock(), TypeWidener.class); CodegenMethod widen = CodegenMethod.makeParentNode(Object.class, originator, classScope).addParam(Object.class, "input"); anonymousClass.addMethod("widen", widen); CodegenExpression widenResult = widener.widenCodegen(ref("input"), method, classScope); widen.getBlock().methodReturn(widenResult); return anonymousClass; }
public static CodegenExpression codegenSimpleParser(SimpleTypeParserSPI parser, CodegenMethod method, Class originator, CodegenClassScope classScope) { CodegenExpressionNewAnonymousClass anonymousClass = newAnonymousClass(method.getBlock(), SimpleTypeParser.class); CodegenMethod parse = CodegenMethod.makeParentNode(Object.class, originator, classScope).addParam(String.class, "value"); anonymousClass.addMethod("parse", parse); parse.getBlock().methodReturn(parser.codegen(ref("value"))); return anonymousClass; } }
public CodegenExpression makeTimePeriodAnonymous(CodegenMethod method, CodegenClassScope classScope) { CodegenExpressionNewAnonymousClass timeClass = newAnonymousClass(method.getBlock(), TimePeriodEval.class); CodegenMethod evalMethod = CodegenMethod.makeParentNode(TimePeriod.class, this.getClass(), classScope).addParam(ExprForgeCodegenNames.PARAMS); timeClass.addMethod("timePeriodEval", evalMethod); ExprForgeCodegenSymbol exprSymbol = new ExprForgeCodegenSymbol(true, true); CodegenMethod exprMethod = evalMethod.makeChildWithScope(TimePeriod.class, this.getClass(), exprSymbol, classScope).addParam(ExprForgeCodegenNames.PARAMS); CodegenExpression expression = forge.evaluateGetTimePeriodCodegen(exprMethod, exprSymbol, classScope); exprSymbol.derivedSymbolsCodegen(evalMethod, exprMethod.getBlock(), classScope); exprMethod.getBlock().methodReturn(expression); evalMethod.getBlock().methodReturn(localMethod(exprMethod, REF_EPS, REF_ISNEWDATA, REF_EXPREVALCONTEXT)); return timeClass; }
public CodegenExpression makeNoCopy(CodegenMethodScope scope, CodegenClassScope classScope) { CodegenMethod method = scope.makeChild(EventBeanUpdateHelperNoCopy.class, this.getClass(), classScope); CodegenMethod updateInternal = makeUpdateInternal(method, classScope); CodegenExpressionNewAnonymousClass clazz = newAnonymousClass(method.getBlock(), EventBeanUpdateHelperNoCopy.class); CodegenMethod updateNoCopy = CodegenMethod.makeParentNode(void.class, this.getClass(), classScope) .addParam(EventBean.class, "matchingEvent") .addParam(EventBean[].class, NAME_EPS) .addParam(ExprEvaluatorContext.class, NAME_EXPREVALCONTEXT); clazz.addMethod("updateNoCopy", updateNoCopy); updateNoCopy.getBlock() .apply(instblock(classScope, "qInfraUpdate", ref("matchingEvent"), REF_EPS, constant(updateItems.length), constantFalse())) .localMethod(updateInternal, REF_EPS, REF_EXPREVALCONTEXT, ref("matchingEvent")) .apply(instblock(classScope, "aInfraUpdate", ref("matchingEvent"))); CodegenMethod getUpdatedProperties = CodegenMethod.makeParentNode(String[].class, this.getClass(), classScope); clazz.addMethod("getUpdatedProperties", getUpdatedProperties); getUpdatedProperties.getBlock().methodReturn(constant(getUpdateItemsPropertyNames())); CodegenMethod isRequiresStream2InitialValueEvent = CodegenMethod.makeParentNode(boolean.class, this.getClass(), classScope); clazz.addMethod("isRequiresStream2InitialValueEvent", isRequiresStream2InitialValueEvent); isRequiresStream2InitialValueEvent.getBlock().methodReturn(constant(isRequiresStream2InitialValueEvent())); method.getBlock().methodReturn(clazz); return localMethod(method); }
public CodegenMethod makeCodegen(CodegenClassScope classScope, CodegenMethodScope parent, SAIFFInitializeSymbolWEventType symbols) { CodegenMethod method = parent.makeChild(FilterSpecParam.class, FilterSpecParamConstantForge.class, classScope); method.getBlock() .declareVar(ExprFilterSpecLookupable.class, "lookupable", localMethod(lookupable.makeCodegen(method, symbols, classScope))) .declareVar(FilterOperator.class, "op", enumValue(FilterOperator.class, filterOperator.name())); CodegenExpressionNewAnonymousClass inner = newAnonymousClass(method.getBlock(), FilterSpecParam.class, Arrays.asList(ref("lookupable"), ref("op"))); CodegenMethod getFilterValue = CodegenMethod.makeParentNode(Object.class, this.getClass(), classScope).addParam(FilterSpecParam.GET_FILTER_VALUE_FP); inner.addMethod("getFilterValue", getFilterValue); getFilterValue.getBlock().methodReturn(constant(filterConstant)); method.getBlock().methodReturn(inner); return method; }