Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(469)

Side by Side Diff: dart/sdk/lib/_internal/compiler/implementation/tree/nodes.dart

Issue 11788016: Update dart2js unit tests to new library API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of tree; 5 part of tree;
6 6
7 abstract class Visitor<R> { 7 abstract class Visitor<R> {
8 const Visitor(); 8 const Visitor();
9 9
10 R visitNode(Node node); 10 R visitNode(Node node);
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 Send asSend() => this; 281 Send asSend() => this;
282 282
283 accept(Visitor visitor) => visitor.visitSend(this); 283 accept(Visitor visitor) => visitor.visitSend(this);
284 284
285 visitChildren(Visitor visitor) { 285 visitChildren(Visitor visitor) {
286 if (receiver != null) receiver.accept(visitor); 286 if (receiver != null) receiver.accept(visitor);
287 if (selector != null) selector.accept(visitor); 287 if (selector != null) selector.accept(visitor);
288 if (argumentsNode != null) argumentsNode.accept(visitor); 288 if (argumentsNode != null) argumentsNode.accept(visitor);
289 } 289 }
290 290
291 int argumentCount() => (argumentsNode == null) ? -1 : argumentsNode.length; 291 int argumentCount() {
292 return (argumentsNode == null) ? -1 : argumentsNode.slowLength();
293 }
292 294
293 bool get isSuperCall { 295 bool get isSuperCall {
294 return receiver != null && 296 return receiver != null &&
295 receiver.asIdentifier() != null && 297 receiver.asIdentifier() != null &&
296 receiver.asIdentifier().isSuper(); 298 receiver.asIdentifier().isSuper();
297 } 299 }
298 bool get isOperator => selector is Operator; 300 bool get isOperator => selector is Operator;
299 bool get isPropertyAccess => argumentsNode == null; 301 bool get isPropertyAccess => argumentsNode == null;
300 bool get isFunctionObjectInvocation => selector == null; 302 bool get isFunctionObjectInvocation => selector == null;
301 bool get isPrefix => argumentsNode is Prefix; 303 bool get isPrefix => argumentsNode is Prefix;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 421
420 NodeList([this.beginToken, this.nodes, this.endToken, this.delimiter]); 422 NodeList([this.beginToken, this.nodes, this.endToken, this.delimiter]);
421 423
422 Iterator<Node> get iterator => nodes.iterator; 424 Iterator<Node> get iterator => nodes.iterator;
423 425
424 NodeList.singleton(Node node) : this(null, const Link<Node>().prepend(node)); 426 NodeList.singleton(Node node) : this(null, const Link<Node>().prepend(node));
425 NodeList.empty() : this(null, const Link<Node>()); 427 NodeList.empty() : this(null, const Link<Node>());
426 428
427 NodeList asNodeList() => this; 429 NodeList asNodeList() => this;
428 430
429 int get length { 431 int slowLength() {
430 int result = 0; 432 int result = 0;
431 for (Link<Node> cursor = nodes; !cursor.isEmpty; cursor = cursor.tail) { 433 for (Link<Node> cursor = nodes; !cursor.isEmpty; cursor = cursor.tail) {
432 result++; 434 result++;
433 } 435 }
434 return result; 436 return result;
435 } 437 }
436 438
437 accept(Visitor visitor) => visitor.visitNodeList(this); 439 accept(Visitor visitor) => visitor.visitNodeList(this);
438 440
439 visitChildren(Visitor visitor) { 441 visitChildren(Visitor visitor) {
(...skipping 23 matching lines...) Expand all
463 if (nodes != null) { 465 if (nodes != null) {
464 Link<Node> link = nodes; 466 Link<Node> link = nodes;
465 if (link.isEmpty) return beginToken; 467 if (link.isEmpty) return beginToken;
466 while (!link.tail.isEmpty) link = link.tail; 468 while (!link.tail.isEmpty) link = link.tail;
467 if (link.head.getEndToken() != null) return link.head.getEndToken(); 469 if (link.head.getEndToken() != null) return link.head.getEndToken();
468 if (link.head.getBeginToken() != null) return link.head.getBeginToken(); 470 if (link.head.getBeginToken() != null) return link.head.getBeginToken();
469 } 471 }
470 return beginToken; 472 return beginToken;
471 } 473 }
472 474
473 // ------------------- Iterable methods ------------------------------------- 475 // TODO(ahe): The method does not belong in the Iterable interface.
474 // 476 get length {
475 // TODO(floitsch): these functions should be pulled in through a mixin 477 throw new UnsupportedError('get:length');
476 // mechanism.
477 Iterable mappedBy(f(Node element)) => new MappedIterable(this, f);
478
479 Iterable<Node> where(bool f(Node element))
480 => new WhereIterable<Node>(this, f);
481
482 bool contains(Node element) {
483 for (Node e in this) {
484 if (e == element) return true;
485 }
486 return false;
487 } 478 }
488 479
489 void forEach(void f(Node element)) { 480 // TODO(ahe): The method does not belong in the Iterable interface.
490 for (Node element in this) f(element); 481 mappedBy(f) {
482 throw new UnsupportedError('mappedBy');
491 } 483 }
492 484
493 String join([String separator]) => Collections.join(this, separator); 485 // TODO(ahe): The method does not belong in the Iterable interface.
494 486 where(f) {
495 dynamic reduce(var initialValue, 487 throw new UnsupportedError('where');
496 dynamic combine(var previousValue, Node element)) {
497 var value = initialValue;
498 for (Node element in this) value = combine(value, element);
499 return value;
500 } 488 }
501 489
502 bool every(bool f(Node element)) { 490 // TODO(ahe): The method does not belong in the Iterable interface.
503 for (Node element in this) { 491 contains(element) {
504 if (!f(element)) return false; 492 throw new UnsupportedError('contains');
505 }
506 return true;
507 } 493 }
508 494
509 bool any(bool f(Node element)) { 495 // TODO(ahe): The method does not belong in the Iterable interface.
510 for (Node element in this) { 496 forEach(f) {
511 if (f(element)) return true; 497 throw new UnsupportedError('forEach');
512 }
513 return false;
514 } 498 }
515 499
516 List<Node> toList() => new List<Node>.from(this); 500 // TODO(ahe): The method does not belong in the Iterable interface.
517 501 join([separator]) {
518 Set<Node> toSet() => new Set<Node>.from(this); 502 throw new UnsupportedError('join');
519
520 Iterable<Node> take(int n) => new TakeIterable<Node>(this, n);
521
522 Iterable<Node> takeWhile(bool test(Node value)) {
523 return new TakeWhileIterable<Node>(this, test);
524 } 503 }
525 504
526 Iterable<Node> skip(int n) => new SkipIterable<Node>(this, n); 505 // TODO(ahe): The method does not belong in the Iterable interface.
527 506 reduce(initialValue, combine) {
528 Iterable<Node> skipWhile(bool test(Node value)) { 507 throw new UnsupportedError('reduce');
529 return new SkipWhileIterable<Node>(this, test);
530 } 508 }
531 509
532 Node get first { 510 // TODO(ahe): The method does not belong in the Iterable interface.
533 return Collections.first(this); 511 every(f) {
512 throw new UnsupportedError('every');
534 } 513 }
535 514
536 Node get last { 515 // TODO(ahe): The method does not belong in the Iterable interface.
537 return Collections.last(this); 516 any(f) {
517 throw new UnsupportedError('any');
538 } 518 }
539 519
540 Node get single { 520 // TODO(ahe): The method does not belong in the Iterable interface.
541 return Collections.single(this); 521 toList() {
522 throw new UnsupportedError('toList');
542 } 523 }
543 524
544 Node min([int compare(Node a, Node b)]) => Collections.min(this, compare); 525 // TODO(ahe): The method does not belong in the Iterable interface.
545 526 toSet() {
546 Node max([int compare(Node a, Node b)]) => Collections.max(this, compare); 527 throw new UnsupportedError('toSet');
547
548 Node firstMatching(bool test(Node value), {Node orElse()}) {
549 return Collections.firstMatching(this, test, orElse);
550 } 528 }
551 529
552 Node lastMatching(bool test(Node value), {Node orElse()}) { 530 // TODO(ahe): The method does not belong in the Iterable interface.
553 return Collections.lastMatching(this, test, orElse); 531 take(n) {
532 throw new UnsupportedError('take');
554 } 533 }
555 534
556 Node singleMatching(bool test(Node value)) { 535 // TODO(ahe): The method does not belong in the Iterable interface.
557 return Collections.singleMatching(this, test); 536 takeWhile(test) {
537 throw new UnsupportedError('takeWhile');
558 } 538 }
559 539
560 Node elementAt(int index) { 540 // TODO(ahe): The method does not belong in the Iterable interface.
561 return Collections.elementAt(this, index); 541 skip(n) {
542 throw new UnsupportedError('skip');
543 }
544
545 // TODO(ahe): The method does not belong in the Iterable interface.
546 skipWhile(test) {
547 throw new UnsupportedError('skipWhile');
548 }
549
550 // TODO(ahe): The method does not belong in the Iterable interface.
551 get first {
552 throw new UnsupportedError('get:first');
553 }
554
555 // TODO(ahe): The method does not belong in the Iterable interface.
556 get last {
557 throw new UnsupportedError('get:first');
558 }
559
560 // TODO(ahe): The method does not belong in the Iterable interface.
561 get single {
562 throw new UnsupportedError('get:single');
563 }
564
565 // TODO(ahe): The method does not belong in the Iterable interface.
566 min([compare]) {
567 throw new UnsupportedError('min');
568 }
569
570 // TODO(ahe): The method does not belong in the Iterable interface.
571 max([compare]) {
572 throw new UnsupportedError('max');
573 }
574
575 // TODO(ahe): The method does not belong in the Iterable interface.
576 firstMatching(test, {orElse}) {
577 throw new UnsupportedError('firstMatching');
578 }
579
580 // TODO(ahe): The method does not belong in the Iterable interface.
581 lastMatching(test, {orElse}) {
582 throw new UnsupportedError('lastMatching');
583 }
584
585 singleMatching(test) {
586 throw new UnsupportedError('singleMatching');
587 }
588
589 elementAt(index) {
590 throw new UnsupportedError('elementAt');
562 } 591 }
563 } 592 }
564 593
565 class Block extends Statement { 594 class Block extends Statement {
566 final NodeList statements; 595 final NodeList statements;
567 596
568 Block(this.statements); 597 Block(this.statements);
569 598
570 Block asBlock() => this; 599 Block asBlock() => this;
571 600
(...skipping 1517 matching lines...) Expand 10 before | Expand all | Expand 10 after
2089 * argument). 2118 * argument).
2090 * 2119 *
2091 * TODO(ahe): This method is controversial, the team needs to discuss 2120 * TODO(ahe): This method is controversial, the team needs to discuss
2092 * if top-level methods are acceptable and what naming conventions to 2121 * if top-level methods are acceptable and what naming conventions to
2093 * use. 2122 * use.
2094 */ 2123 */
2095 initializerDo(Node node, f(Node node)) { 2124 initializerDo(Node node, f(Node node)) {
2096 SendSet send = node.asSendSet(); 2125 SendSet send = node.asSendSet();
2097 if (send != null) return f(send.arguments.head); 2126 if (send != null) return f(send.arguments.head);
2098 } 2127 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698