| OLD | NEW |
| 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 | 5 |
| 6 interface CallingContext { | 6 interface CallingContext { |
| 7 MemberSet findMembers(String name); | 7 MemberSet findMembers(String name); |
| 8 CounterLog get counters(); | 8 CounterLog get counters(); |
| 9 Library get library(); | 9 Library get library(); |
| 10 bool get isStatic(); | 10 bool get isStatic(); |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 int arity = callMethod.parameters.length; | 644 int arity = callMethod.parameters.length; |
| 645 var myCall = type.getCallMethod(); | 645 var myCall = type.getCallMethod(); |
| 646 | 646 |
| 647 Value result = this; | 647 Value result = this; |
| 648 if (myCall == null || myCall.parameters.length != arity) { | 648 if (myCall == null || myCall.parameters.length != arity) { |
| 649 final stub = world.functionType.getCallStub(new Arguments.bare(arity)); | 649 final stub = world.functionType.getCallStub(new Arguments.bare(arity)); |
| 650 result = new Value(toType, 'to\$${stub.name}($code)', span); | 650 result = new Value(toType, 'to\$${stub.name}($code)', span); |
| 651 } | 651 } |
| 652 | 652 |
| 653 // TODO(jmesserly): handle when type or toType are type parameters. | 653 // TODO(jmesserly): handle when type or toType are type parameters. |
| 654 if (toType.library == world.dom && type.library != world.dom) { | 654 if (toType.library.isDomOrHtml && !type.library.isDomOrHtml) { |
| 655 // TODO(jmesserly): either remove this or make it a more first class | 655 // TODO(jmesserly): either remove this or make it a more first class |
| 656 // feature of our native interop. We shouldn't be checking for the DOM | 656 // feature of our native interop. We shouldn't be checking for the DOM |
| 657 // library--any host environment (like node.js) might need this feature | 657 // library--any host environment (like node.js) might need this feature |
| 658 // for isolates too. But we don't want to wrap every function we send to | 658 // for isolates too. But we don't want to wrap every function we send to |
| 659 // native code--many callbacks like List.filter are perfectly safe. | 659 // native code--many callbacks like List.filter are perfectly safe. |
| 660 if (arity == 0) { | 660 if (arity == 0) { |
| 661 world.gen.corejs.useWrap0 = true; | 661 world.gen.corejs.useWrap0 = true; |
| 662 } else { | 662 } else if (arity == 1) { |
| 663 world.gen.corejs.useWrap1 = true; | 663 world.gen.corejs.useWrap1 = true; |
| 664 } else if (arity == 2) { |
| 665 world.gen.corejs.useWrap2 = true; |
| 664 } | 666 } |
| 665 | 667 |
| 666 result = new Value(toType, '\$wrap_call\$$arity(${result.code})', span); | 668 result = new Value(toType, '\$wrap_call\$$arity(${result.code})', span); |
| 667 } | 669 } |
| 668 | 670 |
| 669 return result._changeStaticType(toType); | 671 return result._changeStaticType(toType); |
| 670 } | 672 } |
| 671 | 673 |
| 672 /** | 674 /** |
| 673 * Generates a run time type assertion for the given value. This works like | 675 * Generates a run time type assertion for the given value. This works like |
| (...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1654 } | 1656 } |
| 1655 return super.unop(kind, context, node); | 1657 return super.unop(kind, context, node); |
| 1656 } | 1658 } |
| 1657 Value binop(int kind, var other, CallingContext context, var node) { | 1659 Value binop(int kind, var other, CallingContext context, var node) { |
| 1658 if (value != null) { | 1660 if (value != null) { |
| 1659 return replaceValue(value.binop(kind, _unwrap(other), context, node)); | 1661 return replaceValue(value.binop(kind, _unwrap(other), context, node)); |
| 1660 } | 1662 } |
| 1661 return super.binop(kind, other, context, node); | 1663 return super.binop(kind, other, context, node); |
| 1662 } | 1664 } |
| 1663 } | 1665 } |
| OLD | NEW |