public override void visit(NodeConditionalJump node)
 {
     if (VirtualMachine.getInstance().returnValue == true.ToString())
     {
         this.nextNode = node.nextOntrue;
     }
     else
     {
         this.nextNode = node.nextOnFalse;
     }
 }
Example #2
0
        private bool openedBracket; // check if compiling statement

        public CompileIfStatement() : base()
        {
            firstNodeDoNothing = new NodeDoNothing();
            conditionalJump    = new NodeConditionalJump();
            trueNodeDoNothing  = new NodeDoNothing();
            falseNodeDoNothing = new NodeDoNothing();

            compiledNodes.addLast(new NodeDoNothing());
            compiledNodes.addLast(new NodeConditionalJump());
            compiledNodes.addLast(new NodeDoNothing());
            compiledNodes.addLast(new NodeDoNothing());

            compiledNodes.addLast(firstNodeDoNothing);
            compiledNodes.addLast(conditionalJump);
            compiledNodes.addLast(trueNodeDoNothing);
            compiledNodes.addLast(falseNodeDoNothing);
        }
        private bool openedBracket; // check if compiling statement

        public CompileWhile() : base()
        {
            firstDoNothingNode = new NodeDoNothing();
            conditionalJump    = new NodeConditionalJump();
            jumpBackNode       = new NodeJump();

            compiledNodes.addLast(firstDoNothingNode);
            compiledNodes.addLast(conditionalJump);
            compiledNodes.addLast(new NodeDoNothing());
            compiledNodes.addLast(jumpBackNode);
            compiledNodes.addLast(new NodeDoNothing());

            jumpBackNode.jumpNode       = compiledNodes.getFirst();
            conditionalJump.nextOntrue  = compiledNodes.get(2);
            conditionalJump.nextOnFalse = compiledNodes.getLast();

            // Settings
            openedBracket = false;
        }
        private bool openedBracket; // check if compiling statement

        public CompileIfElseStatement() : base()
        {
            firstNodeDoNothing = new NodeDoNothing();
            trueNodeDoNothing  = new NodeDoNothing();
            falseNodeDoNothing = new NodeDoNothing();
            conditionalJump    = new NodeConditionalJump();
            nodeJump           = new NodeJump();
            nodeDoNothing      = new NodeDoNothing();

            conditionalJump.nextOntrue  = trueNodeDoNothing;
            conditionalJump.nextOnFalse = falseNodeDoNothing;

            compiledNodes.addLast(firstNodeDoNothing);
            compiledNodes.addLast(conditionalJump);
            compiledNodes.addLast(trueNodeDoNothing);
            compiledNodes.addLast(falseNodeDoNothing);

            nodeJump.jumpNode = nodeDoNothing;

            compiledNodes.insertBefore(falseNodeDoNothing, nodeJump);
            compiledNodes.addLast(nodeDoNothing);
        }
 public abstract void visit(NodeConditionalJump node);