Package org.jruby.ast
Class ListNode
java.lang.Object
org.jruby.ast.Node
org.jruby.ast.ListNode
- Direct Known Subclasses:
ArrayNode,BlockNode,DNode,ZArrayNode
All Nodes which have a list representation inherit this. This is also used
as generic container for additional information that is not directly evaluated.
In particular, f_arg production rule uses this to capture arg information for
the editor projects who want position info saved.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Node[]private static final intprivate Node[]private NodeThis is used to reduce the need to allocate an array for the many single-element ListNode instances in a typical Ruby app.private intFields inherited from class org.jruby.ast.Node
containsVariableAssignment, EMPTY_LIST, newline -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> Taccept(NodeVisitor<T> visitor) Add all elements in other list to this list node.Add other element to this listprotected voidaddAllInternal(ListNode other) protected voidaddInternal(Node node) private voidaddToSingle(Node single, Node node) private Node[]arrayifySingle(Node single) Deprecated.Node[]children()get(int idx) getLast()private Node[]growList(int mustBeDelta) booleanisEmpty()iterator()intsize()Methods inherited from class org.jruby.ast.Node
containsVariableAssignment, createList, createList, createList, createList, executesOnce, findFirstChild, getFile, getLine, getNodeName, isNewline, isNil, needsDefinitionCheck, setLine, setNewline, toString, toString, toStringExtraInfo, toStringInternal, unsetNewlineMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
EMPTY
-
INITIAL_SIZE
private static final int INITIAL_SIZE- See Also:
-
list
-
size
private int size -
single
This is used to reduce the need to allocate an array for the many single-element ListNode instances in a typical Ruby app. The methods below detect if single has been set and act accordingly, expanding it to an array lazily only when needed.
-
-
Constructor Details
-
ListNode
Create a new ListNode.- Parameters:
line- where list isfirstNode- first element of the list
-
ListNode
public ListNode(int line)
-
-
Method Details
-
getNodeType
- Specified by:
getNodeTypein classNode- Returns:
- the nodeId
-
growList
-
addInternal
-
addAllInternal
-
addToSingle
-
arrayifySingle
-
add
-
size
public int size() -
addAll
Add all elements in other list to this list node.- Parameters:
other- list which has elements- Returns:
- this instance for method chaining
-
addAll
-
addAll
Add other element to this list- Parameters:
other- list which has elements- Returns:
- this instance for method chaining
-
getLast
-
isEmpty
public boolean isEmpty() -
children
-
childNodes
Deprecated.- Specified by:
childNodesin classNode
-
accept
-
get
-
iterator
-