OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'package:kernel/ast.dart' as ir; | 5 import 'package:kernel/ast.dart' as ir; |
6 | 6 |
7 import '../common.dart'; | 7 import '../common.dart'; |
8 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; | 8 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; |
9 import '../common/names.dart'; | 9 import '../common/names.dart'; |
10 import '../common/tasks.dart' show CompilerTask; | 10 import '../common/tasks.dart' show CompilerTask; |
(...skipping 1515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1526 push(new HInvokeDynamicSetter(selector, mask, null, inputs, type)); | 1526 push(new HInvokeDynamicSetter(selector, mask, null, inputs, type)); |
1527 } else { | 1527 } else { |
1528 push(new HInvokeDynamicMethod( | 1528 push(new HInvokeDynamicMethod( |
1529 selector, mask, inputs, type, isIntercepted)); | 1529 selector, mask, inputs, type, isIntercepted)); |
1530 } | 1530 } |
1531 } | 1531 } |
1532 | 1532 |
1533 // TODO(het): Decide when to inline | 1533 // TODO(het): Decide when to inline |
1534 @override | 1534 @override |
1535 void visitMethodInvocation(ir.MethodInvocation invocation) { | 1535 void visitMethodInvocation(ir.MethodInvocation invocation) { |
| 1536 // Handle `x == null` specially. When these come from null-aware operators, |
| 1537 // there is no mapping in the astAdapter. |
| 1538 if (_handleEqualsNull(invocation)) return; |
1536 invocation.receiver.accept(this); | 1539 invocation.receiver.accept(this); |
1537 HInstruction receiver = pop(); | 1540 HInstruction receiver = pop(); |
1538 | 1541 |
1539 _pushDynamicInvocation( | 1542 _pushDynamicInvocation( |
1540 invocation, | 1543 invocation, |
1541 astAdapter.typeOfInvocation(invocation), | 1544 astAdapter.typeOfInvocation(invocation), |
1542 <HInstruction>[receiver] | 1545 <HInstruction>[receiver] |
1543 ..addAll(_visitArguments(invocation.arguments))); | 1546 ..addAll(_visitArguments(invocation.arguments))); |
1544 } | 1547 } |
1545 | 1548 |
| 1549 bool _handleEqualsNull(ir.MethodInvocation invocation) { |
| 1550 if (invocation.name.name == '==') { |
| 1551 ir.Arguments arguments = invocation.arguments; |
| 1552 if (arguments.types.isEmpty && |
| 1553 arguments.positional.length == 1 && |
| 1554 arguments.named.isEmpty) { |
| 1555 bool finish(ir.Expression comparand) { |
| 1556 comparand.accept(this); |
| 1557 pushCheckNull(pop()); |
| 1558 return true; |
| 1559 } |
| 1560 |
| 1561 ir.Expression receiver = invocation.receiver; |
| 1562 ir.Expression argument = arguments.positional.first; |
| 1563 if (argument is ir.NullLiteral) return finish(receiver); |
| 1564 if (receiver is ir.NullLiteral) return finish(argument); |
| 1565 } |
| 1566 } |
| 1567 return false; |
| 1568 } |
| 1569 |
1546 HInterceptor _interceptorFor(HInstruction intercepted) { | 1570 HInterceptor _interceptorFor(HInstruction intercepted) { |
1547 HInterceptor interceptor = | 1571 HInterceptor interceptor = |
1548 new HInterceptor(intercepted, backend.nonNullType); | 1572 new HInterceptor(intercepted, backend.nonNullType); |
1549 add(interceptor); | 1573 add(interceptor); |
1550 return interceptor; | 1574 return interceptor; |
1551 } | 1575 } |
1552 | 1576 |
1553 static ir.Class _containingClass(ir.TreeNode node) { | 1577 static ir.Class _containingClass(ir.TreeNode node) { |
1554 while (node != null) { | 1578 while (node != null) { |
1555 if (node is ir.Class) return node; | 1579 if (node is ir.Class) return node; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1633 push(new HNot(popBoolified(), backend.boolType)); | 1657 push(new HNot(popBoolified(), backend.boolType)); |
1634 } | 1658 } |
1635 | 1659 |
1636 @override | 1660 @override |
1637 void visitStringConcatenation(ir.StringConcatenation stringConcat) { | 1661 void visitStringConcatenation(ir.StringConcatenation stringConcat) { |
1638 KernelStringBuilder stringBuilder = new KernelStringBuilder(this); | 1662 KernelStringBuilder stringBuilder = new KernelStringBuilder(this); |
1639 stringConcat.accept(stringBuilder); | 1663 stringConcat.accept(stringBuilder); |
1640 stack.add(stringBuilder.result); | 1664 stack.add(stringBuilder.result); |
1641 } | 1665 } |
1642 } | 1666 } |
OLD | NEW |