OLD | NEW |
1 // This code was auto-generated, is not intended to be edited, and is subject to | 1 // This code was auto-generated, is not intended to be edited, and is subject to |
2 // significant change. Please see the README file for more information. | 2 // significant change. Please see the README file for more information. |
3 | 3 |
4 library engine.ast; | 4 library engine.ast; |
5 | 5 |
6 import 'dart:collection'; | 6 import 'dart:collection'; |
7 import 'java_core.dart'; | 7 import 'java_core.dart'; |
8 import 'java_engine.dart'; | 8 import 'java_engine.dart'; |
9 import 'source.dart' show LineInfo; | 9 import 'source.dart' show LineInfo; |
10 import 'scanner.dart'; | 10 import 'scanner.dart'; |
(...skipping 17289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17300 * @param owner the node that is the parent of each of the elements in the lis
t | 17300 * @param owner the node that is the parent of each of the elements in the lis
t |
17301 */ | 17301 */ |
17302 NodeList(this.owner); | 17302 NodeList(this.owner); |
17303 | 17303 |
17304 /** | 17304 /** |
17305 * Use the given visitor to visit each of the nodes in this list. | 17305 * Use the given visitor to visit each of the nodes in this list. |
17306 * | 17306 * |
17307 * @param visitor the visitor to be used to visit the elements of this list | 17307 * @param visitor the visitor to be used to visit the elements of this list |
17308 */ | 17308 */ |
17309 accept(ASTVisitor visitor) { | 17309 accept(ASTVisitor visitor) { |
17310 for (E element in _elements) { | 17310 var length = _elements.length; |
17311 element.accept(visitor); | 17311 for (var i = 0; i < length; i++) { |
| 17312 _elements[i].accept(visitor); |
17312 } | 17313 } |
17313 } | 17314 } |
17314 void add(E node) { | 17315 void add(E node) { |
17315 insert(length, node); | 17316 insert(length, node); |
17316 } | 17317 } |
17317 void insert(int index, E node) { | 17318 void insert(int index, E node) { |
17318 int length = _elements.length; | 17319 int length = _elements.length; |
17319 if (index < 0 || index > length) { | 17320 if (index < 0 || index > length) { |
17320 throw new RangeError("Index: ${index}, Size: ${_elements.length}"); | 17321 throw new RangeError("Index: ${index}, Size: ${_elements.length}"); |
17321 } | 17322 } |
17322 owner.becomeParentOf(node); | 17323 owner.becomeParentOf(node); |
17323 if (length == 0) { | 17324 if (length == 0) { |
17324 _elements = <E> [node]; | 17325 _elements = <E> [node]; |
17325 } else { | 17326 } else { |
17326 List<E> newElements = new List<E>(length + 1); | 17327 _elements.insert(index, node); |
17327 JavaSystem.arraycopy(_elements, 0, newElements, 0, index); | |
17328 newElements[index] = node; | |
17329 JavaSystem.arraycopy(_elements, index, newElements, index + 1, length - in
dex); | |
17330 _elements = newElements; | |
17331 } | 17328 } |
17332 } | 17329 } |
17333 bool addAll(Iterable<E> nodes) { | 17330 bool addAll(Iterable<E> nodes) { |
17334 if (nodes != null && !nodes.isEmpty) { | 17331 if (nodes != null && !nodes.isEmpty) { |
17335 int oldCount = _elements.length; | 17332 _elements.addAll(nodes); |
17336 int newCount = nodes.length; | |
17337 List<E> newElements = new List<E>(oldCount + newCount); | |
17338 JavaSystem.arraycopy(_elements, 0, newElements, 0, oldCount); | |
17339 int index = oldCount; | |
17340 for (E node in nodes) { | 17333 for (E node in nodes) { |
17341 owner.becomeParentOf(node); | 17334 owner.becomeParentOf(node); |
17342 newElements[index++] = node; | |
17343 } | 17335 } |
17344 _elements = newElements; | |
17345 return true; | 17336 return true; |
17346 } | 17337 } |
17347 return false; | 17338 return false; |
17348 } | 17339 } |
17349 E operator[](int index) { | 17340 E operator[](int index) { |
17350 if (index < 0 || index >= _elements.length) { | 17341 if (index < 0 || index >= _elements.length) { |
17351 throw new RangeError("Index: ${index}, Size: ${_elements.length}"); | 17342 throw new RangeError("Index: ${index}, Size: ${_elements.length}"); |
17352 } | 17343 } |
17353 return _elements[index] as E; | 17344 return _elements[index] as E; |
17354 } | 17345 } |
(...skipping 24 matching lines...) Expand all Loading... |
17379 E removeAt(int index) { | 17370 E removeAt(int index) { |
17380 if (index < 0 || index >= _elements.length) { | 17371 if (index < 0 || index >= _elements.length) { |
17381 throw new RangeError("Index: ${index}, Size: ${_elements.length}"); | 17372 throw new RangeError("Index: ${index}, Size: ${_elements.length}"); |
17382 } | 17373 } |
17383 E removedNode = _elements[index] as E; | 17374 E removedNode = _elements[index] as E; |
17384 int length = _elements.length; | 17375 int length = _elements.length; |
17385 if (length == 1) { | 17376 if (length == 1) { |
17386 _elements = ASTNode.EMPTY_ARRAY; | 17377 _elements = ASTNode.EMPTY_ARRAY; |
17387 return removedNode; | 17378 return removedNode; |
17388 } | 17379 } |
17389 List<E> newElements = new List<E>(length - 1); | 17380 _elements.removeAt(index); |
17390 JavaSystem.arraycopy(_elements, 0, newElements, 0, index); | |
17391 JavaSystem.arraycopy(_elements, index + 1, newElements, index, length - inde
x - 1); | |
17392 _elements = newElements; | |
17393 return removedNode; | 17381 return removedNode; |
17394 } | 17382 } |
17395 void operator[]=(int index, E node) { | 17383 void operator[]=(int index, E node) { |
17396 if (index < 0 || index >= _elements.length) { | 17384 if (index < 0 || index >= _elements.length) { |
17397 throw new RangeError("Index: ${index}, Size: ${_elements.length}"); | 17385 throw new RangeError("Index: ${index}, Size: ${_elements.length}"); |
17398 } | 17386 } |
17399 _elements[index] as E; | |
17400 owner.becomeParentOf(node); | 17387 owner.becomeParentOf(node); |
17401 _elements[index] = node; | 17388 _elements[index] = node; |
17402 } | 17389 } |
17403 int get length => _elements.length; | 17390 int get length => _elements.length; |
17404 } | 17391 } |
OLD | NEW |