1 31 package org.jruby.ast; 32 33 import java.util.List ; 34 35 import org.jruby.ast.visitor.NodeVisitor; 36 import org.jruby.evaluator.Instruction; 37 import org.jruby.lexer.yacc.ISourcePosition; 38 39 51 public class WhileNode extends Node { 52 static final long serialVersionUID = -5355364190446060873L; 53 54 private final Node conditionNode; 55 private final Node bodyNode; 56 private final boolean evaluateAtStart; 57 58 public WhileNode(ISourcePosition position, Node conditionNode, Node bodyNode) { 59 this(position, conditionNode, bodyNode, true); 60 } 61 62 public WhileNode(ISourcePosition position, Node conditionNode, Node bodyNode, 63 boolean evalAtStart) { 64 super(position, NodeTypes.WHILENODE); 65 this.conditionNode = conditionNode; 66 this.bodyNode = bodyNode; 67 this.evaluateAtStart = evalAtStart; 68 } 69 70 74 public Instruction accept(NodeVisitor iVisitor) { 75 return iVisitor.visitWhileNode(this); 76 } 77 81 public Node getBodyNode() { 82 return bodyNode; 83 } 84 85 89 public Node getConditionNode() { 90 return conditionNode; 91 } 92 93 97 public boolean evaluateAtStart() { 98 return evaluateAtStart; 99 } 100 101 public List childNodes() { 102 return Node.createList(conditionNode, bodyNode); 103 } 104 105 } 106 | Popular Tags |