예제 #1
0
        public void Combine()
        {
            var conditionalJumpNode = new ConditionalJumpNode();

            _compiledStatement.AddLast(new DoNothingNode());
            LinkedListExtensions.AppendRange(_compiledStatement, _condition.AsEnumerable<ActionNode>());
            _compiledStatement.AddLast(conditionalJumpNode);
            LinkedListExtensions.AppendRange(_compiledStatement, _body.AsEnumerable<ActionNode>());
            _compiledStatement.AddLast(new DoNothingNode());

            conditionalJumpNode.NextOnTrue = _body.First;
            conditionalJumpNode.NextOnFalse = _compiledStatement.Last;
        }
예제 #2
0
        public override void Compile()
        {
            DoNothingNode firstDN = new DoNothingNode();
            DoNothingNode middleDN = new DoNothingNode();
            DoNothingNode lastDN = new DoNothingNode();

            Compiled.Add(firstDN);

            CompiledCondition condition = new CompiledCondition();

            while(CurrentToken.Value.TokenType != TokenType.ELLIPSISOPEN)
            {
                CurrentToken = CurrentToken.Next;
            }

            condition.CurrentToken = CurrentToken.Next.Next;
            condition.Compile();
            CurrentToken = condition.CurrentToken;

            Compiled.InsertAfter(condition.Compiled);

            ConditionalJumpNode jump = new ConditionalJumpNode();
            jump.NextOnTrue = middleDN;
            jump.NextOnFalse = lastDN;

            Compiled.Add(jump);
            Compiled.Add(middleDN);

            while (CurrentToken.Value.TokenType != TokenType.BRACKETOPEN)
            {
                CurrentToken = CurrentToken.Next;
            }

            CurrentToken = CurrentToken.Next;

            while (CurrentToken.Value.TokenType != TokenType.BRACKETCLOSE)
            {
                AbstractCompiled compiled = CompilerFactory.getInstance().GetCompiled(CurrentToken);
                compiled.CurrentToken = CurrentToken;
                compiled.Compile();
                Compiled.InsertAfter(compiled.Compiled);
                CurrentToken = CurrentToken.Next;
            }

            Compiled.Add(new JumpNode(firstDN));

            Compiled.Add(lastDN);
        }
예제 #3
0
        public void Combine()
        {
            var conditionalJumpNode = new ConditionalJumpNode();
            var jumpBackNode = new JumpNode();

            _compiledStatement.AddLast(new DoNothingNode());
            LinkedListExtensions.AppendRange(_compiledStatement, _condition.AsEnumerable<ActionNode>());
            _compiledStatement.AddLast(conditionalJumpNode); // De body komt dus rechtstreeks na de conditionalJumpNode (dus op de .Next property)
            LinkedListExtensions.AppendRange(_compiledStatement, _body.AsEnumerable<ActionNode>());
            _compiledStatement.AddLast(jumpBackNode);
            _compiledStatement.AddLast(new DoNothingNode());

            jumpBackNode.JumpToNode = _compiledStatement.First; // JumpToNode is een extra property ten opzichte van andere nodes.
            conditionalJumpNode.NextOnTrue = _body.First; // NextOnTrue en NextOnFalse zijn extra properties ten opzichte van andere nodes.
            conditionalJumpNode.NextOnFalse = _compiledStatement.Last;
        }
예제 #4
0
 public override void Visit(ConditionalJumpNode node, string condition)
 {
     NextNode = (Boolean.Parse(condition)) ? node.NextOnTrue : node.NextOnFalse;
 }
예제 #5
0
 public abstract void Visit(ConditionalJumpNode conditionalJump);