コード例 #1
0
        public CodegenExpression Codegen(
            CodegenExpression inner,
            Type innerType,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            if (type == DuckType.WRAPARRAY) {
                return ExprDotMethodForgeNoDuckEvalWrapArray.CodegenWrapArray(
                    this,
                    inner,
                    innerType,
                    codegenMethodScope,
                    exprSymbol,
                    codegenClassScope);
            }

            if (type == DuckType.PLAIN) {
                return ExprDotMethodForgeNoDuckEvalPlain.CodegenPlain(
                    this,
                    inner,
                    innerType,
                    codegenMethodScope,
                    exprSymbol,
                    codegenClassScope);
            }

            return ExprDotMethodForgeNoDuckEvalUnderlying.CodegenUnderlying(
                this,
                inner,
                innerType,
                codegenMethodScope,
                exprSymbol,
                codegenClassScope);
        }
コード例 #2
0
        public static CodegenExpression CodegenUnderlying(
            ExprDotMethodForgeNoDuck forge,
            CodegenExpression inner,
            Type innerType,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var underlyingType = forge.Method.DeclaringType;
            var returnType     = forge.Method.ReturnType;
            var methodNode     = codegenMethodScope
                                 .MakeChild(returnType.GetBoxedType(), typeof(ExprDotMethodForgeNoDuckEvalUnderlying), codegenClassScope)
                                 .AddParam(typeof(EventBean), "target");

            var eval = ExprDotMethodForgeNoDuckEvalPlain.CodegenPlain(
                forge,
                Ref("underlying"),
                underlyingType,
                methodNode,
                exprSymbol,
                codegenClassScope);

            if (returnType != typeof(void))
            {
                methodNode.Block
                .IfRefNullReturnNull("target")
                .DeclareVar(underlyingType, "underlying", Cast(underlyingType, ExprDotName(Ref("target"), "Underlying")))
                .MethodReturn(eval);
            }
            else
            {
                methodNode.Block
                .IfRefNotNull("target")
                .DeclareVar(underlyingType, "underlying", Cast(underlyingType, ExprDotName(Ref("target"), "Underlying")))
                .Expression(eval);
            }

            return(LocalMethod(methodNode, inner));
        }