예제 #1
0
        public PrinterNode Visit(IfNode node)
        {
            var pNode = new PrinterNode("If");

            pNode.AddChild(node.Condition.Accept(this));

            if (node.TrueBranch != null)
            {
                pNode.AddChild(node.TrueBranch.Accept(this));
            }

            if (node.FalseBranch != null)
            {
                pNode.AddChild(node.FalseBranch.Accept(this));
            }

            return(pNode);
        }
예제 #2
0
        public void VisitIfNode(IfNode node)
        {
            ExpressionNode condition  = node.Condition;
            StatementNode  ifBranch   = node.IfBranch;
            StatementNode  elseBranch = node.ElseBranch;

            condition.Accept(this);
            ifBranch.Accept(this);

            if (condition.EvaluationType != TokenType.BOOLEAN_VAL)
            {
                analyzer.notifyError(new IllegalTypeError(condition));
            }

            if (elseBranch != null)
            {
                elseBranch.Accept(this);

                if (ifBranch.Returns && elseBranch.Returns)
                {
                    node.Returns = true;
                }
            }
        }
예제 #3
0
 public bool Visit(IfNode node)
 {
     node.Condition.Accept(this);
     _typeChecker.RequireCast(_stack.SymBool, ref node.Condition);
     return(true);
 }
예제 #4
0
 public void VisitIfNode(IfNode node)
 {
 }