Beispiel #1
0
        public static CodegenMethod Codegen(
            ExprRegexpNodeForgeConst forge,
            ExprNode lhs,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            CodegenExpression mPattern = codegenClassScope.AddDefaultFieldUnshared<Regex>(true, forge.PatternInit);
            var methodNode = codegenMethodScope.MakeChild(
                typeof(bool?),
                typeof(ExprRegexpNodeForgeConstEval),
                codegenClassScope);

            if (!forge.IsNumericValue) {
                methodNode.Block
                    .DeclareVar<string>(
                        "value",
                        lhs.Forge.EvaluateCodegen(typeof(string), methodNode, exprSymbol, codegenClassScope))
                    .IfRefNullReturnNull("value")
                    .MethodReturn(GetRegexpCode(forge, mPattern, Ref("value")));
            }
            else {
                var valueRender = StaticMethod(typeof(CompatExtensions), "RenderAny", Ref("value"));
                methodNode.Block
                    .DeclareVar<object>(
                        "value",
                        lhs.Forge.EvaluateCodegen(typeof(object), methodNode, exprSymbol, codegenClassScope))
                    .IfRefNullReturnNull("value")
                    .MethodReturn(GetRegexpCode(forge, mPattern, valueRender));
            }

            return methodNode;
        }
Beispiel #2
0
 internal ExprRegexpNodeForgeConstEval(
     ExprRegexpNodeForgeConst forge,
     ExprEvaluator lhsEval)
 {
     this.forge = forge;
     this.lhsEval = lhsEval;
 }