コード例 #1
0
        public static CodegenExpression Codegen(
            ExprCastNodeForge forge,
            CodegenClassScope codegenClassScope)
        {
            if (forge.EvaluationType == null) {
                return ConstantNull();
            }

            var evaluationType = forge.EvaluationType.GetBoxedType();
            var initMethod = codegenClassScope.NamespaceScope.InitMethod.MakeChildWithScope(
                evaluationType,
                typeof(ExprCastNodeForgeConstEval),
                CodegenSymbolProviderEmpty.INSTANCE,
                codegenClassScope);

            var exprSymbol = new ExprForgeCodegenSymbol(true, null);
            var compute = initMethod.MakeChildWithScope(
                    evaluationType,
                    typeof(ExprCastNodeForgeConstEval),
                    exprSymbol,
                    codegenClassScope)
                .AddParam(ExprForgeCodegenNames.PARAMS);
            compute.Block.MethodReturn(
                ExprCastNodeForgeNonConstEval.Codegen(forge, compute, exprSymbol, codegenClassScope));

            initMethod.Block.MethodReturn(LocalMethod(compute, Constant(null), ConstantTrue(), ConstantNull()));

            return codegenClassScope.AddDefaultFieldUnshared(true, evaluationType, LocalMethod(initMethod));
        }
コード例 #2
0
        public CodegenExpression EvaluateCodegenUninstrumented(
            Type requiredType,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            if (IsConstant) {
                if (Constant == null) {
                    return ConstantNull();
                }

                return ExprCastNodeForgeConstEval.Codegen(this, codegenClassScope);
            }

            return ExprCastNodeForgeNonConstEval.Codegen(this, codegenMethodScope, exprSymbol, codegenClassScope);
        }