Exemple #1
0
        public static CodegenMethod Codegen(
            ExprLikeNodeForgeConst forge,
            ExprNode lhs,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var mLikeUtil = codegenClassScope.AddDefaultFieldUnshared(
                true,
                typeof(LikeUtil),
                forge.LikeUtilInit);


            var methodNode = codegenMethodScope.MakeChild(
                typeof(bool?),
                typeof(ExprLikeNodeForgeConstEval),
                codegenClassScope);
            if (!forge.IsNumericValue) {
                methodNode.Block
                    .DeclareVar<string>(
                        "value",
                        lhs.Forge.EvaluateCodegen(typeof(string), methodNode, exprSymbol, codegenClassScope))
                    .IfRefNullReturnNull("value")
                    .MethodReturn(GetLikeCode(forge, mLikeUtil, Ref("value")));
            }
            else {
                methodNode.Block.DeclareVar<object>(
                        "value",
                        lhs.Forge.EvaluateCodegen(typeof(object), methodNode, exprSymbol, codegenClassScope))
                    .IfRefNullReturnNull("value")
                    .MethodReturn(GetLikeCode(forge, mLikeUtil, ExprDotMethod(Ref("value"), "ToString")));
            }

            return methodNode;
        }
Exemple #2
0
 internal ExprLikeNodeForgeConstEval(
     ExprLikeNodeForgeConst forge,
     ExprEvaluator lhsEval)
 {
     this.forge = forge;
     this.lhsEval = lhsEval;
 }