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; }
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); }
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; }
public override void Visit(ConditionalJumpNode node, string condition) { NextNode = (Boolean.Parse(condition)) ? node.NextOnTrue : node.NextOnFalse; }
public abstract void Visit(ConditionalJumpNode conditionalJump);