Beispiel #1
0
 private CodegenMethod IsExistsPropertyCodegen(
     CodegenMethodScope codegenMethodScope,
     CodegenClassScope codegenClassScope)
 {
     return codegenMethodScope.MakeChild(typeof(bool), GetType(), codegenClassScope)
         .AddParam(typeof(GenericRecord), "record")
         .Block
         .DeclareVar<Field>(
             "field",
             CodegenExpressionBuilder.ExprDotMethodChain(CodegenExpressionBuilder.Ref("record"))
                 .Get("Schema")
                 .Add("GetField", CodegenExpressionBuilder.Constant(_fieldTop)))
         .IfRefNullReturnFalse("field")
         .DeclareVar<object>(
             "inner",
             CodegenExpressionBuilder.StaticMethod(
                 typeof(GenericRecordExtensions),
                 "Get",
                 CodegenExpressionBuilder.Ref("record"),
                 CodegenExpressionBuilder.Constant(_fieldTop)))
         .IfRefNotTypeReturnConst("inner", typeof(GenericRecord), false)
         .MethodReturn(
             _getter.UnderlyingExistsCodegen(
                 CodegenExpressionBuilder.Cast(typeof(GenericRecord), CodegenExpressionBuilder.Ref("inner")),
                 codegenMethodScope,
                 codegenClassScope));
 }
Beispiel #2
0
 private CodegenMethod ExistsCodegen(CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope)
 {
     return codegenMethodScope
         .MakeChild(typeof(bool), GetType(), codegenClassScope)
         .AddParam(typeof(GenericRecord), "record")
         .Block
         .DeclareVar<GenericRecord>(
             "inner",
             StaticMethod(
                 GetType(),
                 "GetAtIndex",
                 Ref("record"),
                 Constant(_posTop.Name),
                 Constant(_index)))
         .IfRefNullReturnFalse("inner")
         .MethodReturn(
             _nested.UnderlyingExistsCodegen(
                 Ref("inner"),
                 codegenMethodScope,
                 codegenClassScope));
 }
Beispiel #3
0
 private CodegenMethod ExistsCodegen(CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope)
 {
     return codegenMethodScope
         .MakeChild(typeof(bool), GetType(), codegenClassScope)
         .AddParam(typeof(GenericRecord), "record")
         .Block
         .DeclareVar<GenericRecord>(
             "inner",
             Cast(
                 typeof(GenericRecord),
                 StaticMethod(
                     typeof(GenericRecordExtensions),
                     "Get",
                     Ref("record"),
                     Constant(_fieldTop))))
         .MethodReturn(
             Conditional(
                 EqualsNull(Ref("inner")),
                 ConstantFalse(),
                 _getter.UnderlyingExistsCodegen(
                     Ref("inner"),
                     codegenMethodScope,
                     codegenClassScope)));
 }