Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library dart2js.ir_nodes; | 4 library dart2js.ir_nodes; |
| 5 | 5 |
| 6 import 'dart:collection'; | 6 import 'dart:collection'; |
| 7 import '../constants/values.dart' as values; | 7 import '../constants/values.dart' as values; |
| 8 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType; | 8 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType; |
| 9 import '../elements/elements.dart'; | 9 import '../elements/elements.dart'; |
| 10 import '../io/source_information.dart' show SourceInformation; | 10 import '../io/source_information.dart' show SourceInformation; |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 580 | 580 |
| 581 /// An "is" type test. | 581 /// An "is" type test. |
| 582 /// | 582 /// |
| 583 /// Returns `true` if [value] is an instance of [type]. | 583 /// Returns `true` if [value] is an instance of [type]. |
| 584 /// | 584 /// |
| 585 /// [type] must not be the [Object], `dynamic` or [Null] types (though it might | 585 /// [type] must not be the [Object], `dynamic` or [Null] types (though it might |
| 586 /// be a type variable containing one of these types). This design is chosen | 586 /// be a type variable containing one of these types). This design is chosen |
| 587 /// to simplify code generation for type tests. | 587 /// to simplify code generation for type tests. |
| 588 class TypeTest extends Primitive { | 588 class TypeTest extends Primitive { |
| 589 Reference<Primitive> value; | 589 Reference<Primitive> value; |
| 590 | |
|
Kevin Millikin (Google)
2015/10/07 14:10:49
Not sure why there's a space here (there isn't one
sra1
2015/10/07 17:45:57
Done.
| |
| 590 final DartType dartType; | 591 final DartType dartType; |
| 591 | 592 |
| 592 /// If [type] is an [InterfaceType], this holds the internal representation of | 593 /// If [type] is an [InterfaceType], this holds the internal representation of |
|
Kevin Millikin (Google)
2015/10/07 14:10:49
Hmm, [type] in the doc comment didn't get renamed
sra1
2015/10/07 17:45:58
Done.
| |
| 593 /// the type arguments to [type]. Since these may reference type variables | 594 /// the type arguments to [type]. Since these may reference type variables |
| 594 /// from the enclosing class, they are not constant. | 595 /// from the enclosing class, they are not constant. |
| 595 /// | 596 /// |
| 596 /// If [type] is a [TypeVariableType], this is a singleton list with | 597 /// If [type] is a [TypeVariableType], this is a singleton list with |
| 597 /// the internal representation of the type held in that type variable. | 598 /// the internal representation of the type held in that type variable. |
| 598 /// | 599 /// |
| 599 /// If [type] is a [FunctionType], this is a singleton list with the | 600 /// If [type] is a [FunctionType], this is a singleton list with the |
| 600 /// internal representation of that type, | 601 /// internal representation of that type, |
| 601 /// | 602 /// |
| 602 /// Otherwise the list is empty. | 603 /// Otherwise the list is empty. |
| 603 final List<Reference<Primitive>> typeArguments; | 604 final List<Reference<Primitive>> typeArguments; |
| 604 | 605 |
| 606 Reference<Primitive> interceptor; | |
|
Kevin Millikin (Google)
2015/10/07 14:10:49
Needs some documentation: how do I interpret a non
sra1
2015/10/07 17:45:58
Done.
| |
| 607 | |
| 605 TypeTest(Primitive value, | 608 TypeTest(Primitive value, |
| 606 this.dartType, | 609 this.dartType, |
| 607 List<Primitive> typeArguments) | 610 List<Primitive> typeArguments) |
| 608 : this.value = new Reference<Primitive>(value), | 611 : this.value = new Reference<Primitive>(value), |
| 609 this.typeArguments = _referenceList(typeArguments); | 612 this.typeArguments = _referenceList(typeArguments); |
| 610 | 613 |
| 611 accept(Visitor visitor) => visitor.visitTypeTest(this); | 614 accept(Visitor visitor) => visitor.visitTypeTest(this); |
| 612 | 615 |
| 613 bool get isSafeForElimination => true; | 616 bool get isSafeForElimination => true; |
| 614 bool get isSafeForReordering => true; | 617 bool get isSafeForReordering => true; |
| 615 } | 618 } |
| 616 | 619 |
| 620 /// An "is" type test for a raw type, performed by testing a flag property. | |
| 621 /// | |
| 622 /// Returns `true` if [interceptor] is for [dartType]. | |
| 623 class TypeTestViaFlag extends Primitive { | |
| 624 Reference<Primitive> interceptor; | |
| 625 final DartType dartType; | |
| 626 | |
| 627 TypeTestViaFlag(Primitive interceptor, this.dartType) | |
| 628 : this.interceptor = new Reference<Primitive>(interceptor); | |
| 629 | |
| 630 accept(Visitor visitor) => visitor.visitTypeTestViaFlag(this); | |
| 631 | |
| 632 bool get isSafeForElimination => true; | |
| 633 bool get isSafeForReordering => true; | |
| 634 } | |
| 635 | |
| 617 /// An "as" type cast. | 636 /// An "as" type cast. |
| 618 /// | 637 /// |
| 619 /// If [value] is `null` or is an instance of [type], [continuation] is invoked | 638 /// If [value] is `null` or is an instance of [type], [continuation] is invoked |
| 620 /// with [value] as argument. Otherwise, a [CastError] is thrown. | 639 /// with [value] as argument. Otherwise, a [CastError] is thrown. |
| 621 /// | 640 /// |
| 622 /// Discussion: | 641 /// Discussion: |
| 623 /// The parameter to [continuation] is redundant since it will always equal | 642 /// The parameter to [continuation] is redundant since it will always equal |
| 624 /// [value], which is typically in scope in the continuation. However, it might | 643 /// [value], which is typically in scope in the continuation. However, it might |
| 625 /// simplify type propagation, since a better type can be computed for the | 644 /// simplify type propagation, since a better type can be computed for the |
| 626 /// continuation parameter without needing flow-sensitive analysis. | 645 /// continuation parameter without needing flow-sensitive analysis. |
| (...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1364 T visitGetStatic(GetStatic node); | 1383 T visitGetStatic(GetStatic node); |
| 1365 T visitInterceptor(Interceptor node); | 1384 T visitInterceptor(Interceptor node); |
| 1366 T visitCreateInstance(CreateInstance node); | 1385 T visitCreateInstance(CreateInstance node); |
| 1367 T visitGetField(GetField node); | 1386 T visitGetField(GetField node); |
| 1368 T visitCreateBox(CreateBox node); | 1387 T visitCreateBox(CreateBox node); |
| 1369 T visitReifyRuntimeType(ReifyRuntimeType node); | 1388 T visitReifyRuntimeType(ReifyRuntimeType node); |
| 1370 T visitReadTypeVariable(ReadTypeVariable node); | 1389 T visitReadTypeVariable(ReadTypeVariable node); |
| 1371 T visitTypeExpression(TypeExpression node); | 1390 T visitTypeExpression(TypeExpression node); |
| 1372 T visitCreateInvocationMirror(CreateInvocationMirror node); | 1391 T visitCreateInvocationMirror(CreateInvocationMirror node); |
| 1373 T visitTypeTest(TypeTest node); | 1392 T visitTypeTest(TypeTest node); |
| 1393 T visitTypeTestViaFlag(TypeTestViaFlag node); | |
| 1374 T visitApplyBuiltinOperator(ApplyBuiltinOperator node); | 1394 T visitApplyBuiltinOperator(ApplyBuiltinOperator node); |
| 1375 T visitApplyBuiltinMethod(ApplyBuiltinMethod node); | 1395 T visitApplyBuiltinMethod(ApplyBuiltinMethod node); |
| 1376 T visitGetLength(GetLength node); | 1396 T visitGetLength(GetLength node); |
| 1377 T visitGetIndex(GetIndex node); | 1397 T visitGetIndex(GetIndex node); |
| 1378 T visitSetIndex(SetIndex node); | 1398 T visitSetIndex(SetIndex node); |
| 1379 T visitRefinement(Refinement node); | 1399 T visitRefinement(Refinement node); |
| 1380 | 1400 |
| 1381 // Support for literal foreign code. | 1401 // Support for literal foreign code. |
| 1382 T visitForeignCode(ForeignCode node); | 1402 T visitForeignCode(ForeignCode node); |
| 1383 } | 1403 } |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1489 processTypeCast(node); | 1509 processTypeCast(node); |
| 1490 processReference(node.continuation); | 1510 processReference(node.continuation); |
| 1491 processReference(node.value); | 1511 processReference(node.value); |
| 1492 node.typeArguments.forEach(processReference); | 1512 node.typeArguments.forEach(processReference); |
| 1493 } | 1513 } |
| 1494 | 1514 |
| 1495 processTypeTest(TypeTest node) {} | 1515 processTypeTest(TypeTest node) {} |
| 1496 visitTypeTest(TypeTest node) { | 1516 visitTypeTest(TypeTest node) { |
| 1497 processTypeTest(node); | 1517 processTypeTest(node); |
| 1498 processReference(node.value); | 1518 processReference(node.value); |
| 1519 if (node.interceptor != null) processReference(node.interceptor); | |
| 1499 node.typeArguments.forEach(processReference); | 1520 node.typeArguments.forEach(processReference); |
| 1500 } | 1521 } |
| 1501 | 1522 |
| 1523 processTypeTestViaFlag(TypeTestViaFlag node) {} | |
| 1524 visitTypeTestViaFlag(TypeTestViaFlag node) { | |
| 1525 processTypeTestViaFlag(node); | |
| 1526 processReference(node.interceptor); | |
| 1527 } | |
| 1528 | |
| 1502 processSetMutable(SetMutable node) {} | 1529 processSetMutable(SetMutable node) {} |
| 1503 visitSetMutable(SetMutable node) { | 1530 visitSetMutable(SetMutable node) { |
| 1504 processSetMutable(node); | 1531 processSetMutable(node); |
| 1505 processReference(node.variable); | 1532 processReference(node.variable); |
| 1506 processReference(node.value); | 1533 processReference(node.value); |
| 1507 } | 1534 } |
| 1508 | 1535 |
| 1509 processGetLazyStatic(GetLazyStatic node) {} | 1536 processGetLazyStatic(GetLazyStatic node) {} |
| 1510 visitGetLazyStatic(GetLazyStatic node) { | 1537 visitGetLazyStatic(GetLazyStatic node) { |
| 1511 processGetLazyStatic(node); | 1538 processGetLazyStatic(node); |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1817 /// Visit a just-deleted subterm and unlink all [Reference]s in it. | 1844 /// Visit a just-deleted subterm and unlink all [Reference]s in it. |
| 1818 class RemovalVisitor extends RecursiveVisitor { | 1845 class RemovalVisitor extends RecursiveVisitor { |
| 1819 processReference(Reference reference) { | 1846 processReference(Reference reference) { |
| 1820 reference.unlink(); | 1847 reference.unlink(); |
| 1821 } | 1848 } |
| 1822 | 1849 |
| 1823 static void remove(Node node) { | 1850 static void remove(Node node) { |
| 1824 (new RemovalVisitor()).visit(node); | 1851 (new RemovalVisitor()).visit(node); |
| 1825 } | 1852 } |
| 1826 } | 1853 } |
| OLD | NEW |