コード例 #1
0
        public static CodegenExpression Codegen(
            ExprAndNodeImpl parent,
            CodegenMethodScope codegenMethodScope,
            ExprForgeCodegenSymbol exprSymbol,
            CodegenClassScope codegenClassScope)
        {
            var methodNode = codegenMethodScope.MakeChild(typeof(bool?), typeof(ExprAndNodeEval), codegenClassScope);
            var block = methodNode.Block
                .DeclareVar<bool?>("result", ConstantTrue());

            var count = -1;
            foreach (ExprNode child in parent.ChildNodes) {
                count++;
                var childType = child.Forge.EvaluationType;
                if (childType.CanNotBeNull()) {
                    block.IfCondition(
                            Not(child.Forge.EvaluateCodegen(typeof(bool?), methodNode, exprSymbol, codegenClassScope)))
                        .BlockReturn(ConstantFalse());
                }
                else {
                    var refname = "r" + count;
                    block.DeclareVar<bool?>(
                            refname,
                            child.Forge.EvaluateCodegen(typeof(bool?), methodNode, exprSymbol, codegenClassScope))
                        .IfCondition(EqualsNull(Ref(refname)))
                        .AssignRef("result", ConstantNull())
                        .IfElse()
                        .IfCondition(Not(ExprDotName(Ref(refname), "Value")))
                        .BlockReturn(ConstantFalse());
                }
            }

            block.MethodReturn(Ref("result"));
            return LocalMethod(methodNode);
        }
コード例 #2
0
 public ExprAndNodeEval(
     ExprAndNodeImpl parent,
     ExprEvaluator[] evaluators)
 {
     this._parent = parent;
     this._evaluators = evaluators;
 }