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 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 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 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 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; }
public CodegenExpression make(CodegenMethod parent, ModuleExpressionDeclaredInitializeSymbol symbols, CodegenClassScope classScope) { CodegenMethod method = parent.makeChild(ExpressionDeclItem.class, this.getClass(), classScope); CodegenExpressionNewAnonymousClass supplierSodaBytes = newAnonymousClass(method.getBlock(), Supplier.class); CodegenMethod get = CodegenMethod.makeParentNode(Object.class, this.getClass(), classScope); supplierSodaBytes.addMethod("get", get); get.getBlock().methodReturn(constant(optionalSodaBytes.get())); method.getBlock() .declareVar(ExpressionDeclItem.class, "item", newInstance(ExpressionDeclItem.class, constant(name), constant(parametersNames), constant(alias))) .exprDotMethod(ref("item"), "setOptionalSodaBytes", supplierSodaBytes) .exprDotMethod(ref("item"), "setModuleName", constant(moduleName)) .exprDotMethod(ref("item"), "setVisibility", constant(visibility)) .methodReturn(ref("item")); return localMethod(method); } }
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 static CodegenExpressionNewAnonymousClass codegenEvaluator(ExprForge forge, CodegenMethod method, Class originator, CodegenClassScope classScope) { CodegenExpressionNewAnonymousClass anonymousClass = newAnonymousClass(method.getBlock(), ExprEvaluator.class); CodegenMethod evaluate = CodegenMethod.makeParentNode(Object.class, originator, classScope).addParam(ExprForgeCodegenNames.PARAMS); anonymousClass.addMethod("evaluate", evaluate); if (forge.getEvaluationType() == null) { evaluate.getBlock().methodReturn(constantNull()); } else { CodegenMethod evalMethod = CodegenLegoMethodExpression.codegenExpression(forge, method, classScope); evaluate.getBlock().methodReturn(localMethod(evalMethod, REF_EPS, REF_ISNEWDATA, REF_EXPREVALCONTEXT)); } return anonymousClass; }
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 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); }
private CodegenExpression makeAggAssignables(CodegenMethodScope parent, CodegenClassScope classScope) { CodegenMethod method = parent.makeChild(AggregationResultFutureAssignable[].class, this.getClass(), classScope); method.getBlock() .declareVar(AggregationResultFutureAssignable[].class, "assignables", newArrayByLength(AggregationResultFutureAssignable.class, constant(aggregationServices.length))); for (int i = 0; i < aggregationServices.length; i++) { if (aggregationServices[i] != null) { CodegenExpressionNewAnonymousClass anonymousClass = newAnonymousClass(method.getBlock(), AggregationResultFutureAssignable.class); CodegenMethod assign = CodegenMethod.makeParentNode(void.class, this.getClass(), classScope).addParam(AggregationResultFuture.class, "future"); anonymousClass.addMethod("assign", assign); CodegenExpression field = classScope.getPackageScope().addOrGetFieldWellKnown(new CodegenFieldNameMatchRecognizeAgg(i), AggregationResultFuture.class); assign.getBlock().assignRef(field, ref("future")); method.getBlock().assignArrayElement(ref("assignables"), constant(i), anonymousClass); } } method.getBlock().methodReturn(ref("assignables")); return localMethod(method); }
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); }
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 static CodegenExpression codegenGetterWCoerce(EventPropertyGetterSPI getter, Class getterType, Class optionalCoercionType, CodegenMethod method, Class generator, CodegenClassScope classScope) { getterType = JavaClassHelper.getBoxedType(getterType); CodegenExpressionNewAnonymousClass anonymous = newAnonymousClass(method.getBlock(), EventPropertyValueGetter.class); CodegenMethod get = CodegenMethod.makeParentNode(Object.class, generator, classScope).addParam(CodegenNamedParam.from(EventBean.class, "bean")); anonymous.addMethod("get", get); CodegenExpression result = getter.eventBeanGetCodegen(ref("bean"), method, classScope); if (optionalCoercionType != null && getterType != optionalCoercionType && JavaClassHelper.isNumeric(getterType)) { SimpleNumberCoercer coercer = SimpleNumberCoercerFactory.getCoercer(getterType, JavaClassHelper.getBoxedType(optionalCoercionType)); get.getBlock().declareVar(getterType, "prop", cast(getterType, result)); result = coercer.coerceCodegen(ref("prop"), getterType); } get.getBlock().methodReturn(result); return anonymous; }
public static CodegenExpression codegenWriter(EventType eventType, Class targetType, Class evaluationType, EventPropertyWriterSPI writer, CodegenMethod method, Class generator, CodegenClassScope classScope) { CodegenExpressionNewAnonymousClass anonymous = newAnonymousClass(method.getBlock(), EventPropertyWriter.class); CodegenMethod write = CodegenMethod.makeParentNode(void.class, generator, classScope).addParam(CodegenNamedParam.from(Object.class, "value", EventBean.class, "bean")); anonymous.addMethod("write", write); evaluationType = JavaClassHelper.getBoxedType(evaluationType); write.getBlock() .declareVar(eventType.getUnderlyingType(), "und", cast(eventType.getUnderlyingType(), exprDotUnderlying(ref("bean")))) .declareVar(evaluationType, "eval", cast(evaluationType, ref("value"))) .expression(writer.writeCodegen(ref("eval"), ref("und"), ref("bean"), write, classScope)); return anonymous; }
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 static CodegenExpressionNewAnonymousClass codegenEvaluatorWCoerce(ExprForge forge, Class optCoercionType, CodegenMethod method, Class generator, CodegenClassScope classScope) { CodegenExpressionNewAnonymousClass evaluator = newAnonymousClass(method.getBlock(), ExprEvaluator.class); CodegenMethod evaluate = CodegenMethod.makeParentNode(Object.class, generator, classScope).addParam(ExprForgeCodegenNames.PARAMS); evaluator.addMethod("evaluate", evaluate); CodegenExpression result = constantNull(); if (forge.getEvaluationType() != null) { CodegenMethod evalMethod = CodegenLegoMethodExpression.codegenExpression(forge, method, classScope); result = localMethod(evalMethod, REF_EPS, REF_ISNEWDATA, REF_EXPREVALCONTEXT); if (optCoercionType != null && JavaClassHelper.getBoxedType(forge.getEvaluationType()) != JavaClassHelper.getBoxedType(optCoercionType)) { SimpleNumberCoercer coercer = SimpleNumberCoercerFactory.getCoercer(forge.getEvaluationType(), JavaClassHelper.getBoxedType(optCoercionType)); evaluate.getBlock().declareVar(forge.getEvaluationType(), "result", result); result = coercer.coerceCodegen(ref("result"), forge.getEvaluationType()); } } evaluate.getBlock().methodReturn(result); return evaluator; }