public CodegenExpression EvaluateEventGetROCollectionScalarCodegen( CodegenMethodScope methodScope, ExprEnumerationGivenEventSymbol symbols, CodegenClassScope codegenClassScope) { if (getterReturnType.IsGenericCollection()) { return getter.EventBeanGetCodegen( symbols.GetAddEvent(methodScope), methodScope, codegenClassScope); } CodegenMethod method = methodScope.MakeChild( typeof(ICollection<object>), typeof(PropertyDotScalarIterable), codegenClassScope); method.Block.DeclareVar( getterReturnType, "result", CodegenLegoCast.CastSafeFromObjectType( typeof(IEnumerable), getter.EventBeanGetCodegen(symbols.GetAddEvent(method), methodScope, codegenClassScope))) .IfRefNullReturnNull("result") .MethodReturn(StaticMethod(typeof(CollectionUtil), "IterableToCollection", Ref("result"))); return LocalMethod(method); }
public CodegenExpression Codegen(CodegenExpression inner, Type innerType, CodegenMethodScope parent, ExprForgeCodegenSymbol symbols, CodegenClassScope classScope) { Type type = EPTypeHelper.GetCodegenReturnType(_returnType); CodegenMethod method = parent .MakeChild(type, typeof(ExprDotForgeProperty), classScope) .AddParam(innerType, "target").AddParam(typeof(int?), "index"); var arrayExpr = CastSafeFromObjectType(_arrayType, _getter.EventBeanGetCodegen(Cast(typeof(EventBean), Ref("target")), method, classScope)); method.Block .IfNotInstanceOf("target", typeof(EventBean)) .BlockReturn(ConstantNull()) .DeclareVar(_arrayType, "array", arrayExpr) .IfRefNullReturnNull("index") .IfCondition(Relational(Ref("index"), CodegenExpressionRelational.CodegenRelational.GE, ArrayLength(Ref("array")))) .BlockThrow( NewInstance <EPException>( Concat( Constant("Array length "), ArrayLength(Ref("array")), Constant(" less than index "), Ref("index"), Constant(" for property '" + _propertyName + "'")))) .MethodReturn(CastSafeFromObjectType(type, ArrayAtIndex(Ref("array"), ExprDotMethod(Ref("index"), "AsInt32")))); return(LocalMethod(method, inner, _indexExpression.Forge.EvaluateCodegen(typeof(int?), method, symbols, classScope))); }
private CodegenExpression CodegenEvaluateGetInternal( CodegenExpression @event, CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { var block = codegenMethodScope .MakeChild(typeof(FlexCollection), typeof(PropertyDotScalarArrayForge), codegenClassScope) .AddParam(typeof(EventBean), "@event") .Block .DeclareVar( getterReturnType, "value", CodegenLegoCast.CastSafeFromObjectType( getterReturnType, getter.EventBeanGetCodegen(Ref("@event"), codegenMethodScope, codegenClassScope))) .IfRefNullReturnNull("value"); CodegenMethod method; if (ComponentTypeCollection.CanNotBeNull() || ComponentTypeCollection.GetUnboxedType().CanNotBeNull()) { method = block.MethodReturn( FlexWrap( NewInstance<ArrayWrappingCollection>( Ref("value")))); } else { method = block.MethodReturn(Ref("value")); } return LocalMethodBuild(method).Pass(@event).Call(); }
public CodegenExpression EvaluateCodegen( Type requiredType, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { CodegenMethod methodNode = codegenMethodScope.MakeChild( typeof(ICollection<object>), GetType(), codegenClassScope); CodegenExpressionRef refEPS = exprSymbol.GetAddEPS(methodNode); methodNode.Block .DeclareVar<EventBean>( "@event", CodegenExpressionBuilder.ArrayAtIndex(refEPS, CodegenExpressionBuilder.Constant(_streamNum))) .IfRefNullReturnNull("@event") .DeclareVar<object[]>( "result", CodegenExpressionBuilder.Cast( typeof(object[]), _getter.EventBeanGetCodegen( CodegenExpressionBuilder.Ref("@event"), methodNode, codegenClassScope))) .IfRefNullReturnNull("result") .MethodReturn( CodegenExpressionBuilder.StaticMethod( typeof(CompatExtensions), "AsList", CodegenExpressionBuilder.Ref("result"))); return CodegenExpressionBuilder.LocalMethod(methodNode); }
private CodegenExpression CodegenEvaluateGetInternal( CodegenExpression @event, CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { var block = codegenMethodScope .MakeChild(typeof(FlexCollection), typeof(PropertyDotScalarArrayForge), codegenClassScope) .AddParam(typeof(EventBean), "@event") .Block .DeclareVar( _getterReturnType, "value", CodegenLegoCast.CastSafeFromObjectType( _getterReturnType, _getter.EventBeanGetCodegen(Ref("@event"), codegenMethodScope, codegenClassScope))); var method = block.MethodReturn( StaticMethod( typeof(PropertyDotScalarStringForge), "ConvertToCollection", Constant(_propertyName), Ref("value"))); return LocalMethodBuild(method).Pass(@event).Call(); }
public CodegenExpression MakeCodegen( CodegenClassScope classScope, CodegenMethodScope parent) { var method = parent.MakeChild(typeof(object), GetType(), classScope) .AddParam(GET_FILTER_VALUE_FP); method.Block .DeclareVar<EventBean>("props", ExprDotName(REF_EXPREVALCONTEXT, "ContextProperties")) .IfNullReturnNull(Ref("props")) .DeclareVar<object>("result", _getter.EventBeanGetCodegen(Ref("props"), method, classScope)); if (_numberCoercer != null) { method.Block.AssignRef( "result", _numberCoercer.CoerceCodegenMayNullBoxed( Cast(typeof(object), Ref("result")), typeof(object), method, classScope)); } method.Block.MethodReturn(Ref("result")); return LocalMethod(method, GET_FILTER_VALUE_REFS); }
public CodegenExpression EvaluateCodegenUninstrumented( Type requiredType, CodegenMethodScope parent, ExprForgeCodegenSymbol symbols, CodegenClassScope classScope) { var methodNode = parent.MakeChild(EvaluationType, typeof(ExprVariableNodeImpl), classScope); var readerExpression = GetReaderExpression(VariableMetadata, methodNode, symbols, classScope); var block = methodNode.Block .DeclareVar<VariableReader>("reader", readerExpression); if (VariableMetadata.EventType == null) { block.DeclareVar( EvaluationType, "value", Cast(EvaluationType, ExprDotName(Ref("reader"), "Value"))) .MethodReturn(Ref("value")); } else { block.DeclareVar<object>("value", ExprDotName(Ref("reader"), "Value")) .IfRefNullReturnNull("value") .DeclareVar<EventBean>("theEvent", Cast(typeof(EventBean), Ref("value"))); if (optSubPropName == null) { block.MethodReturn(Cast(EvaluationType, ExprDotUnderlying(Ref("theEvent")))); } else { block.MethodReturn( CodegenLegoCast.CastSafeFromObjectType( EvaluationType, optSubPropGetter.EventBeanGetCodegen(Ref("theEvent"), methodNode, classScope))); } } return LocalMethod(methodNode); }
public CodegenExpression EvaluateCodegen( Type requiredType, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { var methodNode = codegenMethodScope.MakeChild( typeof(object), typeof(ExprForgeStreamWithGetter), codegenClassScope); var refEPS = exprSymbol.GetAddEPS(methodNode); methodNode.Block .DeclareVar <EventBean>( "theEvent", CodegenExpressionBuilder.ArrayAtIndex(refEPS, CodegenExpressionBuilder.Constant(0))) .IfRefNotNull("theEvent") .BlockReturn( getter.EventBeanGetCodegen( CodegenExpressionBuilder.Ref("theEvent"), methodNode, codegenClassScope)) .MethodReturn(CodegenExpressionBuilder.ConstantNull()); return(CodegenExpressionBuilder.LocalMethod(methodNode)); }
public CodegenExpression EvaluateCodegen( Type requiredType, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { var methodNode = codegenMethodScope.MakeChild( typeof(long?), typeof(ExprEvaluatorStreamDTPropFragment), codegenClassScope); var refEPS = exprSymbol.GetAddEPS(methodNode); methodNode.Block .DeclareVar<EventBean>("theEvent", ArrayAtIndex(refEPS, Constant(streamId))) .IfRefNullReturnNull("theEvent") .DeclareVar<object>( "@event", getterFragment.EventBeanFragmentCodegen(Ref("theEvent"), methodNode, codegenClassScope)) .IfCondition(Not(InstanceOf(Ref("@event"), typeof(EventBean)))) .BlockReturn(ConstantNull()) .MethodReturn( CodegenLegoCast.CastSafeFromObjectType( typeof(long), getterTimestamp.EventBeanGetCodegen( Cast(typeof(EventBean), Ref("@event")), methodNode, codegenClassScope))); return LocalMethod(methodNode); }
public CodegenExpression EvaluateEventGetROCollectionScalarCodegen( CodegenMethodScope methodScope, ExprEnumerationGivenEventSymbol symbols, CodegenClassScope codegenClassScope) { var methodNode = methodScope.MakeChild( typeof(ICollection<object>), typeof(PropertyDotScalarCollection), codegenClassScope); methodNode.Block.MethodReturn( CodegenLegoCast.CastSafeFromObjectType( typeof(ICollection<object>), getter.EventBeanGetCodegen( symbols.GetAddEvent(methodNode), methodScope, codegenClassScope))); return LocalMethod(methodNode); }
private CodegenMethod GetObjectArrayCodegen( CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { return codegenMethodScope.MakeChild(typeof(object), GetType(), codegenClassScope) .AddParam(typeof(object[]), "array") .Block .DeclareVar<object>("value", ArrayAtIndex(Ref("array"), Constant(propertyIndex))) .IfRefNullReturnNull("value") .DeclareVarWCast(typeof(EventBean), "theEvent", "value") .MethodReturn( eventBeanEntryGetter.EventBeanGetCodegen(Ref("theEvent"), codegenMethodScope, codegenClassScope)); }
private CodegenMethod GetMapCodegen( CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { var block = codegenMethodScope.MakeChild(typeof(object), GetType(), codegenClassScope) .AddParam(typeof(IDictionary<string, object>), "map") .Block .DeclareVar<object>("value", ExprDotMethod(Ref("map"), "Get", Constant(propertyMap))) .IfRefNullReturnNull("value"); return block.DeclareVar<EventBean>("theEvent", Cast(typeof(EventBean), Ref("value"))) .MethodReturn( eventBeanEntryGetter.EventBeanGetCodegen(Ref("theEvent"), codegenMethodScope, codegenClassScope)); }
private CodegenMethod GetCodegen( CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { return codegenMethodScope.MakeChild(typeof(object), GetType(), codegenClassScope) .AddParam(typeof(EventBean), "theEvent") .Block .DeclareVarWCast(typeof(DecoratingEventBean), "wrapperEvent", "theEvent") .DeclareVar<EventBean>("wrappedEvent", ExprDotName(Ref("wrapperEvent"), "UnderlyingEvent")) .IfRefNullReturnNull("wrappedEvent") .MethodReturn( underlyingGetter.EventBeanGetCodegen(Ref("wrappedEvent"), codegenMethodScope, codegenClassScope)); }
public override CodegenMethod MakeCodegen( CodegenClassScope classScope, CodegenMethodScope parent, SAIFFInitializeSymbolWEventType symbols) { var method = parent.MakeChild(typeof(FilterSpecParam), GetType(), classScope); var lookupableExpr = LocalMethod(lookupable.MakeCodegen(method, symbols, classScope)); method.Block .DeclareVar<ExprFilterSpecLookupable>("lookupable", lookupableExpr) .DeclareVar<FilterOperator>("filterOperator", EnumValue(filterOperator)); //var param = NewAnonymousClass( // method.Block, // typeof(FilterSpecParam), // Arrays.AsList<CodegenExpression>(Ref("lookupable"), Ref("filterOperator"))); var getFilterValue = new CodegenExpressionLambda(method.Block) .WithParams(FilterSpecParam.GET_FILTER_VALUE_FP); var param = NewInstance<ProxyFilterSpecParam>( Ref("lookupable"), Ref("filterOperator"), getFilterValue); //var getFilterValue = CodegenMethod // .MakeParentNode(typeof(object), GetType(), classScope) // .AddParam(FilterSpecParam.GET_FILTER_VALUE_FP); //param.AddMethod("GetFilterValue", getFilterValue); getFilterValue.Block .DeclareVar<EventBean>("props", ExprDotName(REF_EXPREVALCONTEXT, "ContextProperties")) .IfNullReturnNull(Ref("props")) .DeclareVar<object>("result", _getter.EventBeanGetCodegen(Ref("props"), method, classScope)); if (_numberCoercer != null) { getFilterValue.Block.AssignRef( "result", _numberCoercer.CoerceCodegenMayNullBoxed( Cast(typeof(object), Ref("result")), typeof(object), method, classScope)); } var returnExpr = FilterValueSetParamImpl.CodegenNew(Ref("result")); getFilterValue.Block.BlockReturn(returnExpr); method.Block.MethodReturn(param); return method; }
public static CodegenMethod GetArrayPropertyValueCodegen( CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope, int index, EventPropertyGetterSPI nestedGetter) { return codegenMethodScope.MakeChild(typeof(object), typeof(BaseNestableEventUtil), codegenClassScope) .AddParam(typeof(EventBean[]), "wrapper") .Block .IfRefNullReturnNull("wrapper") .IfConditionReturnConst(Relational(ArrayLength(Ref("wrapper")), LE, Constant(index)), null) .DeclareVar<EventBean>("inner", ArrayAtIndex(Ref("wrapper"), Constant(index))) .MethodReturn(nestedGetter.EventBeanGetCodegen(Ref("inner"), codegenMethodScope, codegenClassScope)); }
public CodegenExpression MakeCodegen( CodegenClassScope classScope, CodegenMethodScope parent) { var method = parent.MakeChild(typeof(object), GetType(), classScope) .AddParam(GET_FILTER_VALUE_FP); method.Block .DeclareVar<EventBean>("props", ExprDotName(REF_EXPREVALCONTEXT, "ContextProperties")) .IfNullReturnNull(Ref("props")) .MethodReturn(_getter.EventBeanGetCodegen(Ref("props"), method, classScope)); return LocalMethod(method, GET_FILTER_VALUE_REFS); }
public CodegenExpression EvaluateCodegenUninstrumented( Type requiredType, CodegenMethodScope parent, ExprForgeCodegenSymbol symbols, CodegenClassScope classScope) { var methodNode = parent.MakeChild(EvaluationType, typeof(ExprVariableNodeImpl), classScope); CodegenExpression readerExpression; if (VariableMetadata.OptionalContextName == null) { readerExpression = classScope.AddOrGetDefaultFieldSharable(new VariableReaderCodegenFieldSharable(VariableMetadata)); } else { var field = classScope.AddOrGetDefaultFieldSharable( new VariableReaderPerCPCodegenFieldSharable(VariableMetadata)); var cpid = ExprDotName(symbols.GetAddExprEvalCtx(methodNode), "AgentInstanceId"); readerExpression = Cast(typeof(VariableReader), ExprDotMethod(field, "Get", cpid)); } var block = methodNode.Block .DeclareVar<VariableReader>("reader", readerExpression); if (VariableMetadata.EventType == null) { block.DeclareVar( EvaluationType, "value", Cast(EvaluationType, ExprDotName(Ref("reader"), "Value"))) .MethodReturn(Ref("value")); } else { block.DeclareVar<object>("value", ExprDotName(Ref("reader"), "Value")) .IfRefNullReturnNull("value") .DeclareVar<EventBean>("theEvent", Cast(typeof(EventBean), Ref("value"))); if (optSubPropName == null) { block.MethodReturn(Cast(EvaluationType, ExprDotUnderlying(Ref("theEvent")))); } else { block.MethodReturn( CodegenLegoCast.CastSafeFromObjectType( EvaluationType, optSubPropGetter.EventBeanGetCodegen(Ref("theEvent"), methodNode, classScope))); } } return LocalMethod(methodNode); }
public CodegenExpression EvaluateCodegen( Type requiredType, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { var methodNode = codegenMethodScope.MakeChild(EvaluationType, typeof(ExprEvalByGetter), codegenClassScope); var refEPS = exprSymbol.GetAddEPS(methodNode); methodNode.Block .DeclareVar<EventBean>("@event", ArrayAtIndex(refEPS, Constant(_streamNum))) .IfRefNullReturnNull("@event") .MethodReturn( CodegenLegoCast.CastSafeFromObjectType( EvaluationType, _getter.EventBeanGetCodegen(Ref("@event"), methodNode, codegenClassScope))); return LocalMethod(methodNode); }
public CodegenExpression EvaluateCodegenUninstrumented( Type requiredType, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { var methodNode = codegenMethodScope.MakeChild( EvaluationType, typeof(ExprContextPropertyNodeImpl), codegenClassScope); var refExprEvalCtx = exprSymbol.GetAddExprEvalCtx(methodNode); var block = methodNode.Block .DeclareVar<EventBean>("props", ExprDotName(refExprEvalCtx, "ContextProperties")) .IfRefNullReturnNull("props"); block.MethodReturn( CodegenLegoCast.CastSafeFromObjectType( Type, getter.EventBeanGetCodegen(Ref("props"), methodNode, codegenClassScope))); return LocalMethod(methodNode); }
public CodegenExpression EvaluateCodegen( Type requiredType, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { CodegenMethod methodNode = codegenMethodScope.MakeChild(_returnType, GetType(), codegenClassScope); CodegenExpressionRef refEPS = exprSymbol.GetAddEPS(methodNode); methodNode.Block .DeclareVar<EventBean>( "streamEvent", CodegenExpressionBuilder.ArrayAtIndex(refEPS, CodegenExpressionBuilder.Constant(_streamNum))) .IfRefNullReturnNull("streamEvent") .MethodReturn( CodegenLegoCast.CastSafeFromObjectType( _returnType, _getter.EventBeanGetCodegen( CodegenExpressionBuilder.Ref("streamEvent"), methodNode, codegenClassScope))); return CodegenExpressionBuilder.LocalMethod(methodNode); }
protected override CodegenExpression ProcessSpecificCodegen( CodegenExpression resultEventType, CodegenExpression eventBeanFactory, CodegenExpression props, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { var methodNode = codegenMethodScope .MakeChild(typeof(EventBean), typeof(SelectEvalStreamWUnderlying), codegenClassScope) .AddParam(typeof(IDictionary<string, object>), "props"); var wrapperUndType = codegenClassScope.AddDefaultFieldUnshared( true, typeof(EventType), EventTypeUtility.ResolveTypeCodegen( wrapperEventType.UnderlyingEventType, EPStatementInitServicesConstants.REF)); var refEPS = exprSymbol.GetAddEPS(methodNode); var refIsNewData = exprSymbol.GetAddIsNewData(methodNode); var refExprEvalCtx = exprSymbol.GetAddExprEvalCtx(methodNode); var block = methodNode.Block; if (singleStreamWrapper) { block.DeclareVar<DecoratingEventBean>( "wrapper", Cast(typeof(DecoratingEventBean), ArrayAtIndex(refEPS, Constant(0)))) .IfRefNotNull("wrapper") .ExprDotMethod(props, "PutAll", ExprDotName(Ref("wrapper"), "DecoratingProperties")) .BlockEnd(); } if (underlyingIsFragmentEvent) { var fragment = ((EventTypeSPI) eventTypes[underlyingStreamNumber]) .GetGetterSPI(unnamedStreams[0].StreamSelected.StreamName) .EventBeanFragmentCodegen( Ref("eventBean"), methodNode, codegenClassScope); block.DeclareVar<EventBean>("eventBean", ArrayAtIndex(refEPS, Constant(underlyingStreamNumber))) .DeclareVar<EventBean>("theEvent", Cast(typeof(EventBean), fragment)); } else if (underlyingPropertyEventGetter != null) { block.DeclareVar<EventBean>("theEvent", ConstantNull()) .DeclareVar<object>( "value", underlyingPropertyEventGetter.EventBeanGetCodegen( ArrayAtIndex(refEPS, Constant(underlyingStreamNumber)), methodNode, codegenClassScope)) .IfRefNotNull("value") .AssignRef( "theEvent", ExprDotMethod(eventBeanFactory, "AdapterForTypedObject", Ref("value"), wrapperUndType)) .BlockEnd(); } else if (underlyingExprForge != null) { block.DeclareVar<EventBean>("theEvent", ConstantNull()) .DeclareVar<object>( "value", underlyingExprForge.EvaluateCodegen(typeof(object), methodNode, exprSymbol, codegenClassScope)) .IfRefNotNull("value") .AssignRef( "theEvent", ExprDotMethod(eventBeanFactory, "AdapterForTypedObject", Ref("value"), wrapperUndType)) .BlockEnd(); } else { block.DeclareVar<EventBean>("theEvent", ArrayAtIndex(refEPS, Constant(underlyingStreamNumber))); if (tableMetadata != null) { var eventToPublic = TableDeployTimeResolver.MakeTableEventToPublicField( tableMetadata, codegenClassScope, GetType()); block.IfRefNotNull("theEvent") .AssignRef( "theEvent", ExprDotMethod( eventToPublic, "Convert", Ref("theEvent"), refEPS, refIsNewData, refExprEvalCtx)) .BlockEnd(); } } block.MethodReturn( ExprDotMethod( eventBeanFactory, "AdapterForTypedWrapper", Ref("theEvent"), Ref("props"), resultEventType)); return LocalMethod(methodNode, props); }
public static CodegenMethod From( CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope, Type expectedUnderlyingType, EventPropertyGetterSPI innerGetter, AccessType accessType, Type generator) { var methodNode = codegenMethodScope.MakeChild( accessType == AccessType.EXISTS ? typeof(bool) : typeof(object), generator, codegenClassScope) .AddParam(typeof(object), "value"); var block = methodNode.Block .IfInstanceOf("value", typeof(EventBean)) .DeclareVarWCast(typeof(EventBean), "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 .IfNotInstanceOf("value", expectedUnderlyingType) .BlockReturn( accessType == AccessType.EXISTS ? Constant(false) : ConstantNull()); 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); }
private CodegenExpression CodegenGet( Type requiredType, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { if (returnType == null) { return ConstantNull(); } var castTargetType = GetCodegenReturnType(requiredType); var useUnderlying = exprSymbol.IsAllowUnderlyingReferences && !identNode.ResolvedPropertyName.Contains("?") && !(eventType is WrapperEventType) && !(eventType is VariantEventType); if (useUnderlying && !optionalEvent) { var underlying = exprSymbol.GetAddRequiredUnderlying( codegenMethodScope, streamNum, eventType, false); var property = propertyGetter.UnderlyingGetCodegen(underlying, codegenMethodScope, codegenClassScope); return CodegenLegoCast.CastSafeFromObjectType(castTargetType, property); } var method = codegenMethodScope.MakeChild( castTargetType, this.GetType(), codegenClassScope); var block = method.Block; if (useUnderlying) { var underlying = exprSymbol.GetAddRequiredUnderlying( method, streamNum, eventType, true); if (castTargetType.CanNotBeNull()) { #if THROW_VALUE_ON_NULL block.IfRefNullThrowException(underlying); #else block .IfRefNull(underlying) .BlockReturn(new CodegenExpressionDefault(castTargetType)); #endif } else { block.IfRefNullReturnNull(underlying); } block.MethodReturn( CodegenLegoCast.CastSafeFromObjectType( castTargetType, propertyGetter.UnderlyingGetCodegen(underlying, method, codegenClassScope))); } else { var refEPS = exprSymbol.GetAddEPS(method); method.Block.DeclareVar<EventBean>("@event", ArrayAtIndex(refEPS, Constant(streamNum))); if (optionalEvent) { if (castTargetType.CanNotBeNull()) { #if THROW_VALUE_ON_NULL block.IfRefNullThrowException(Ref("@event")); #else block .IfRefNull(Ref("@event")) .BlockReturn(new CodegenExpressionDefault(castTargetType)); #endif } else { block.IfRefNullReturnNull(Ref("@event")); } } block.MethodReturn( CodegenLegoCast.CastSafeFromObjectType( castTargetType, propertyGetter.EventBeanGetCodegen(Ref("@event"), method, codegenClassScope))); } return LocalMethod(method); }