コード例 #1
0
        public CodegenExpression Codegen(
            CodegenExpression inner,
            Type innerType,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var returnType = ((ClassEPType) TypeInfo).Clazz.GetBoxedType();
            var methodNode = codegenMethodScope
                .MakeChild(returnType, typeof(ExprDotDTForge), codegenClassScope)
                .AddParam(innerType, "target");

            CodegenExpression targetValue = Unbox(Ref("target"), innerType);

            var block = methodNode.Block;

            block.Debug("Codegen: target = {0}", Ref("target"));
            
            if (innerType.CanBeNull()) {
                block.IfRefNullReturnNull("target");
            }

            block.MethodReturn(
                forge.Codegen(
                    targetValue,
                    innerType,
                    methodNode,
                    exprSymbol,
                    codegenClassScope));

            return LocalMethod(methodNode, inner);
        }
コード例 #2
0
        public CodegenExpression Codegen(
            CodegenExpression inner,
            Type innerType,
            CodegenMethodScope parent,
            ExprForgeCodegenSymbol symbols,
            CodegenClassScope classScope)
        {
            Type methodReturnType;
            if (_returnType is ClassEPType classEPType) {
                methodReturnType = classEPType.Clazz.GetBoxedType();
            }
            else {
                methodReturnType = ((ClassMultiValuedEPType) _returnType).Container;
            }

            var methodNode = parent
                .MakeChild(methodReturnType, typeof(ExprDotDTForge), classScope)
                .AddParam(innerType, "target");
            
            var targetValue = Unbox(Ref("target"), innerType);

            var block = methodNode.Block;

            if (innerType.CanBeNull()) {
                block.IfRefNullReturnNull("target");
            }

            block.MethodReturn(
                forge.Codegen(
                    targetValue,
                    innerType,
                    methodNode,
                    symbols,
                    classScope));

            return LocalMethod(methodNode, inner);
        }