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 '../constants/values.dart' as values show ConstantValue; | 6 import '../constants/values.dart' as values show ConstantValue; |
7 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType; | 7 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType; |
8 import '../elements/elements.dart'; | 8 import '../elements/elements.dart'; |
9 import '../io/source_information.dart' show SourceInformation; | 9 import '../io/source_information.dart' show SourceInformation; |
10 import '../types/types.dart' show TypeMask; | 10 import '../types/types.dart' show TypeMask; |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 List<Primitive> arguments, | 512 List<Primitive> arguments, |
513 this.sourceInformation) | 513 this.sourceInformation) |
514 : this.arguments = _referenceList(arguments); | 514 : this.arguments = _referenceList(arguments); |
515 | 515 |
516 accept(Visitor visitor) => visitor.visitApplyBuiltinOperator(this); | 516 accept(Visitor visitor) => visitor.visitApplyBuiltinOperator(this); |
517 | 517 |
518 bool get isSafeForElimination => true; | 518 bool get isSafeForElimination => true; |
519 bool get isSafeForReordering => true; | 519 bool get isSafeForReordering => true; |
520 } | 520 } |
521 | 521 |
| 522 /// Apply a built-in method. |
| 523 /// |
| 524 /// It must be known that the arguments have the proper types. |
| 525 class ApplyBuiltinMethod extends Primitive { |
| 526 BuiltinMethod method; |
| 527 Reference<Primitive> receiver; |
| 528 List<Reference<Primitive>> arguments; |
| 529 final SourceInformation sourceInformation; |
| 530 |
| 531 bool receiverIsNotNull; |
| 532 |
| 533 ApplyBuiltinMethod(this.method, |
| 534 Primitive receiver, |
| 535 List<Primitive> arguments, |
| 536 this.sourceInformation, |
| 537 {this.receiverIsNotNull: false}) |
| 538 : this.receiver = new Reference<Primitive>(receiver), |
| 539 this.arguments = _referenceList(arguments); |
| 540 |
| 541 accept(Visitor visitor) => visitor.visitApplyBuiltinMethod(this); |
| 542 |
| 543 bool get isSafeForElimination => false; |
| 544 bool get isSafeForReordering => false; |
| 545 } |
| 546 |
522 /// Throw a value. | 547 /// Throw a value. |
523 /// | 548 /// |
524 /// Throw is an expression, i.e., it always occurs in tail position with | 549 /// Throw is an expression, i.e., it always occurs in tail position with |
525 /// respect to a body or expression. | 550 /// respect to a body or expression. |
526 class Throw extends TailExpression { | 551 class Throw extends TailExpression { |
527 Reference<Primitive> value; | 552 Reference<Primitive> value; |
528 | 553 |
529 Throw(Primitive value) : value = new Reference<Primitive>(value); | 554 Throw(Primitive value) : value = new Reference<Primitive>(value); |
530 | 555 |
531 accept(Visitor visitor) => visitor.visitThrow(this); | 556 accept(Visitor visitor) => visitor.visitThrow(this); |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1149 T visitInterceptor(Interceptor node); | 1174 T visitInterceptor(Interceptor node); |
1150 T visitCreateInstance(CreateInstance node); | 1175 T visitCreateInstance(CreateInstance node); |
1151 T visitGetField(GetField node); | 1176 T visitGetField(GetField node); |
1152 T visitCreateBox(CreateBox node); | 1177 T visitCreateBox(CreateBox node); |
1153 T visitReifyRuntimeType(ReifyRuntimeType node); | 1178 T visitReifyRuntimeType(ReifyRuntimeType node); |
1154 T visitReadTypeVariable(ReadTypeVariable node); | 1179 T visitReadTypeVariable(ReadTypeVariable node); |
1155 T visitTypeExpression(TypeExpression node); | 1180 T visitTypeExpression(TypeExpression node); |
1156 T visitCreateInvocationMirror(CreateInvocationMirror node); | 1181 T visitCreateInvocationMirror(CreateInvocationMirror node); |
1157 T visitTypeTest(TypeTest node); | 1182 T visitTypeTest(TypeTest node); |
1158 T visitApplyBuiltinOperator(ApplyBuiltinOperator node); | 1183 T visitApplyBuiltinOperator(ApplyBuiltinOperator node); |
| 1184 T visitApplyBuiltinMethod(ApplyBuiltinMethod node); |
1159 T visitGetLength(GetLength node); | 1185 T visitGetLength(GetLength node); |
1160 T visitGetIndex(GetIndex node); | 1186 T visitGetIndex(GetIndex node); |
1161 T visitSetIndex(SetIndex node); | 1187 T visitSetIndex(SetIndex node); |
1162 | 1188 |
1163 // Conditions. | 1189 // Conditions. |
1164 T visitIsTrue(IsTrue node); | 1190 T visitIsTrue(IsTrue node); |
1165 | 1191 |
1166 // Support for literal foreign code. | 1192 // Support for literal foreign code. |
1167 T visitForeignCode(ForeignCode node); | 1193 T visitForeignCode(ForeignCode node); |
1168 } | 1194 } |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1419 processCreateInvocationMirror(node); | 1445 processCreateInvocationMirror(node); |
1420 node.arguments.forEach(processReference); | 1446 node.arguments.forEach(processReference); |
1421 } | 1447 } |
1422 | 1448 |
1423 processApplyBuiltinOperator(ApplyBuiltinOperator node) {} | 1449 processApplyBuiltinOperator(ApplyBuiltinOperator node) {} |
1424 visitApplyBuiltinOperator(ApplyBuiltinOperator node) { | 1450 visitApplyBuiltinOperator(ApplyBuiltinOperator node) { |
1425 processApplyBuiltinOperator(node); | 1451 processApplyBuiltinOperator(node); |
1426 node.arguments.forEach(processReference); | 1452 node.arguments.forEach(processReference); |
1427 } | 1453 } |
1428 | 1454 |
| 1455 processApplyBuiltinMethod(ApplyBuiltinMethod node) {} |
| 1456 visitApplyBuiltinMethod(ApplyBuiltinMethod node) { |
| 1457 processApplyBuiltinMethod(node); |
| 1458 processReference(node.receiver); |
| 1459 node.arguments.forEach(processReference); |
| 1460 } |
| 1461 |
1429 processForeignCode(ForeignCode node) {} | 1462 processForeignCode(ForeignCode node) {} |
1430 visitForeignCode(ForeignCode node) { | 1463 visitForeignCode(ForeignCode node) { |
1431 processForeignCode(node); | 1464 processForeignCode(node); |
1432 if (node.continuation != null) { | 1465 if (node.continuation != null) { |
1433 processReference(node.continuation); | 1466 processReference(node.continuation); |
1434 } | 1467 } |
1435 node.arguments.forEach(processReference); | 1468 node.arguments.forEach(processReference); |
1436 } | 1469 } |
1437 | 1470 |
1438 processUnreachable(Unreachable node) {} | 1471 processUnreachable(Unreachable node) {} |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1591 /// Visit a just-deleted subterm and unlink all [Reference]s in it. | 1624 /// Visit a just-deleted subterm and unlink all [Reference]s in it. |
1592 class RemovalVisitor extends RecursiveVisitor { | 1625 class RemovalVisitor extends RecursiveVisitor { |
1593 processReference(Reference reference) { | 1626 processReference(Reference reference) { |
1594 reference.unlink(); | 1627 reference.unlink(); |
1595 } | 1628 } |
1596 | 1629 |
1597 static void remove(Node node) { | 1630 static void remove(Node node) { |
1598 (new RemovalVisitor()).visit(node); | 1631 (new RemovalVisitor()).visit(node); |
1599 } | 1632 } |
1600 } | 1633 } |
OLD | NEW |