OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 '../common.dart'; | 5 import '../common.dart'; |
6 import '../compiler.dart' show Compiler; | 6 import '../compiler.dart' show Compiler; |
7 import '../constants/values.dart'; | 7 import '../constants/values.dart'; |
8 import '../dart_types.dart'; | 8 import '../dart_types.dart'; |
9 import '../elements/elements.dart'; | 9 import '../elements/elements.dart'; |
10 import '../js/js.dart' as js; | 10 import '../js/js.dart' as js; |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 HInstruction convertDartClosure( | 27 HInstruction convertDartClosure( |
28 ParameterElement parameter, FunctionType type) { | 28 ParameterElement parameter, FunctionType type) { |
29 HInstruction local = builder.localsHandler.readLocal(parameter); | 29 HInstruction local = builder.localsHandler.readLocal(parameter); |
30 ConstantValue arityConstant = | 30 ConstantValue arityConstant = |
31 builder.constantSystem.createInt(type.computeArity()); | 31 builder.constantSystem.createInt(type.computeArity()); |
32 HInstruction arity = builder.graph.addConstant(arityConstant, compiler); | 32 HInstruction arity = builder.graph.addConstant(arityConstant, compiler); |
33 // TODO(ngeoffray): For static methods, we could pass a method with a | 33 // TODO(ngeoffray): For static methods, we could pass a method with a |
34 // defined arity. | 34 // defined arity. |
35 Element helper = backend.helpers.closureConverter; | 35 Element helper = backend.helpers.closureConverter; |
36 builder.pushInvokeStatic(nativeBody, helper, [local, arity]); | 36 builder.pushInvokeStatic(helper, [local, arity], location: nativeBody); |
37 HInstruction closure = builder.pop(); | 37 HInstruction closure = builder.pop(); |
38 return closure; | 38 return closure; |
39 } | 39 } |
40 | 40 |
41 // Check which pattern this native method follows: | 41 // Check which pattern this native method follows: |
42 // 1) foo() native; | 42 // 1) foo() native; |
43 // hasBody = false | 43 // hasBody = false |
44 // 2) foo() native "bar"; | 44 // 2) foo() native "bar"; |
45 // No longer supported, this is now done with @JSName('foo') and case 1. | 45 // No longer supported, this is now done with @JSName('foo') and case 1. |
46 // 3) foo() native "return 42"; | 46 // 3) foo() native "return 42"; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 LiteralString jsCode = nativeBody.asLiteralString(); | 118 LiteralString jsCode = nativeBody.asLiteralString(); |
119 builder.push(new HForeignCode.statement( | 119 builder.push(new HForeignCode.statement( |
120 js.js.statementTemplateYielding( | 120 js.js.statementTemplateYielding( |
121 new js.LiteralStatement(jsCode.dartString.slowToString())), | 121 new js.LiteralStatement(jsCode.dartString.slowToString())), |
122 <HInstruction>[], | 122 <HInstruction>[], |
123 new SideEffects(), | 123 new SideEffects(), |
124 null, | 124 null, |
125 backend.dynamicType)); | 125 backend.dynamicType)); |
126 } | 126 } |
127 } | 127 } |
OLD | NEW |