public override Node Visit(IfNode n) { if (TryMutate(n, out Node newNode)) { return(newNode); } return(base.Visit(n)); }
public virtual void Visit(IfNode n) { VisitNode(n.Condition); VisitNode(n.WhenTrue); if (n.WhenFalse != null) { VisitNode(n.WhenFalse); } }
public virtual Node Visit(IfNode n) { var cV = VisitNode(n.Condition); var tV = VisitNode(n.WhenTrue); var fV = n.WhenFalse != null?VisitNode(n.WhenFalse) : null; return(cV == n.Condition && tV == n.WhenTrue && fV == n.WhenFalse ? n : new IfNode(cV, tV, fV)); }
public override void Visit(IfNode n) { VisitNode(n.Condition); if (_result > 0) { VisitNode(n.WhenTrue); } else { VisitNode(n.WhenFalse); } }
public override void Visit(IfNode n) { NodeCount++; _buffer.Append(" ("); VisitNode(n.Condition); _buffer.Append(" ? "); VisitNode(n.WhenTrue); _buffer.Append(" : "); VisitNode(n.WhenFalse); _buffer.Append(") "); }
public override Node Visit(IfNode n) { var cV = VisitNode(n.Condition); var tV = VisitNode(n.WhenTrue); var fV = n.WhenFalse != null?VisitNode(n.WhenFalse) : null; if (cV is ConstantNode cVC) { return(cVC.Value > 0 ? tV : fV); } return(cV == n.Condition && tV == n.WhenTrue && fV == n.WhenFalse ? n : new IfNode(cV, tV, fV)); }
Node ParseCondExpression(StringTokenizer t) { var condition = ParseExpression(t); if (t.Match(TokenType.QuestionMark)) { var then = ParseCondExpression(t); if (!t.Match(TokenType.Colon)) { return(new ErrorNode("Expected : of ternary operator.")); } var @else = ParseCondExpression(t); condition = new IfNode(condition, then, @else); } return(condition); }
public override Node Visit(IfNode n) { return(base.Visit(n)); }