public override void Visit(LoopStatementNode node)
        {
            // AddCommand(new PushState());

            // LoopIteratorInitialization
            node.LoopIteratorInitialization.Accept(this);

            int conditionAddress = CurrentFunctionSize;

            // LoopCondition //
            string loopIteratorName = node.LoopIteratorName.Value;
            AddCommand(new Push(loopIteratorName,ValueAccessModes.LocalVariable));

            // LoopLimitExpression
            node.LoopLimitExpression.Accept(this);

            AddCommand(new Compare(Compare.ComparisonModes.LessThanOrEqual));
            // LoopCondition //

            RelativeJumpIfFalse rj = new RelativeJumpIfFalse(0);
            AddCommand(rj);
            jumpStack.Push(rj);

            // LoopCore
            node.LoopCore.Accept(this);

            // LoopUpdate
            AddCommand(new Push(loopIteratorName, ValueAccessModes.LocalVariableReference));
            AddCommand(new Push(loopIteratorName, ValueAccessModes.LocalVariable));
            AddCommand(new Push(new Integer(1)));
            AddCommand(new BinaryOperation(BinaryOperation.Operations.Addition));
            AddCommand(new Assign(false));

            AddCommand(new RelativeJump(conditionAddress - CurrentFunctionSize));

            // Pop all Break from the jumpStack and set up it's PC to the end of the block
            while (jumpStack.Peek().GetType() == (new Break()).GetType())
                SetUpTopJumpInJumpStack(0);

            SetUpTopJumpInJumpStack(0);

            // AddCommand(new PopState());
        }
        public override void Visit(ForEachStatementNode node)
        {
            // AddCommand(new PushState());

            RegisterIntervalChange(node.ForEachInitialization);

            // ForEachRunningVariableType
            node.ForEachRunningVariableType.Accept(this);

            // If this is UserDefined, then use lastCompiledUserDefinedDataTypeName
            TypeEnum forEachRunningVariableType = lastCompiledDataType;
            string forEachRunningVariableTypeName = lastCompiledDataTypeName;

            // IteratorVariableName
            string forEachRunningVariableName = node.ForEachRunningVariableName.Value;

            // Check variable name
            //CheckAndAddLocalVariableName(forEachRunningVariableName, node.NodeValueInfo);

            // IteratorVariableDeclaration
            AddCommand(new Declare(forEachRunningVariableName, forEachRunningVariableType));

            // ForEachCollectionExpression, IteratorInitialization
            node.ForEachCollectionExpression.Accept(this);
            AddCommand(new CallMethod("GetIterator"));
            string iteratorName = GenerateIteratorName();
            AddCommand(new Initialize(iteratorName, TypeEnum.Iterator));

            int conditionAddress = CurrentFunctionSize;

            // ForEachCondition
            AddCommand(new Push(iteratorName, ValueAccessModes.LocalVariableReference));
            AddCommand(new CallMethod("MoveNext"));

            RelativeJumpIfFalse rj = new RelativeJumpIfFalse(0);
            AddCommand(rj);
            jumpStack.Push(rj);

            // ForEachUpdate
            AddCommand(new Push(forEachRunningVariableName, ValueAccessModes.LocalVariableReference));
            AddCommand(new Push(iteratorName, ValueAccessModes.LocalVariable));
            AddCommand(new CallMethod("Current"));
            AddCommand(new Assign(false));

            // ForEachCore
            node.ForEachCore.Accept(this);

            AddCommand(new RelativeJump( conditionAddress - CurrentFunctionSize));

            // Pop all Break from the jumpStack and set up it's PC to the end of the block
            while (jumpStack.Peek().GetType() == (new Break()).GetType())
                SetUpTopJumpInJumpStack(0);

            SetUpTopJumpInJumpStack(0);

            // AddCommand(new PopState());
        }
        public override void Visit(ForStatementNode node)
        {
            AddCommand(new PushScope());

            // ForInitialization
            node.ForInitialization.Accept(this);

            int conditionAddress = CurrentFunctionSize;

            // ForCondition
            node.ForCondition.Accept(this);

            // Jump To The end of the ForStatement if the ForCondition is false
            RelativeJumpIfFalse rj = new RelativeJumpIfFalse(0);
            AddCommand(rj);
            jumpStack.Push(rj);

            // ForCore
            AddCommand(new PushScope());
            node.ForCore.Accept(this);
            AddCommand(new PopScope());

            // ForUpdate
            node.ForUpdate.Accept(this);

            // Jump To The ForCondition
            AddCommand(new RelativeJump(conditionAddress - CurrentFunctionSize));

            // Pop all Break from the jumpStack and set up it's PC to the end of the block
            while (jumpStack.Peek().GetType() == (typeof(Break)))
            {
                AddCommandBefore(new PopScope(), jumpStack.Peek());
                SetUpTopJumpInJumpStack(0);
            }

            SetUpTopJumpInJumpStack(0);

            AddCommand(new PopScope());
        }
        public override void Visit(WhileStatementNode node)
        {
            // AddCommand(new PushState());

            int conditionAddress = CurrentFunctionSize;

            // WhileCondition
            node.WhileCondition.Accept(this);

            // Jump To The end of the WhileStatement if the WhileCondition if false
            RelativeJumpIfFalse rj = new RelativeJumpIfFalse(0);
            AddCommand(rj);
            jumpStack.Push(rj);

            // WhileCore
            node.WhileCore.Accept(this);

            // Jump to the while condition
            AddCommand(new RelativeJump(conditionAddress - CurrentFunctionSize));

            // Pop all Break from the jumpStack and set up it's PC to the end of the block
            while (jumpStack.Peek().GetType() == (new Break()).GetType())
                SetUpTopJumpInJumpStack(0);

            SetUpTopJumpInJumpStack(0);

            // AddCommand(new PopState());
        }
        public override void Visit(ConditionalBranchNode node)
        {
            // AddCommand( new PushState() );

            node.ConditionalBranchCondition.Accept(this);

            RelativeJumpIfFalse falseConditionJump = new RelativeJumpIfFalse(0);
            AddCommand(falseConditionJump);
            jumpStack.Push(falseConditionJump);

            // IfCore
            node.ConditionalBranchCore.Accept(this);

            // This will jump to the end of the IfStatement
            RelativeJump toEndJump = new RelativeJump(0);
            AddCommand(toEndJump);

            // Pop all Break command from the jumpStack
            System.Collections.Generic.Stack<Jump> tempBreakStack = new System.Collections.Generic.Stack<Jump>();

            while (jumpStack.Count != 0 && jumpStack.Peek().GetType() == (new Break()).GetType() )
                tempBreakStack.Push(jumpStack.Pop());

            SetUpTopJumpInJumpStack(0);

            // Push all Break back to the jumpStack
            while (tempBreakStack.Count != 0) jumpStack.Push(tempBreakStack.Pop());

            // Push the falseConditionJump to set up PC later
            jumpStack.Push(toEndJump);
            conditionCount++;

            // AddCommand( new PopState() );
        }