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 '../elements/resolution_types.dart'; | 8 import '../elements/resolution_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, ResolutionFunctionType type) { | 28 ParameterElement parameter, ResolutionFunctionType 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.parameterTypes.length); | 31 builder.constantSystem.createInt(type.parameterTypes.length); |
32 HInstruction arity = | 32 HInstruction arity = |
33 builder.graph.addConstant(arityConstant, builder.closedWorld); | 33 builder.graph.addConstant(arityConstant, builder.closedWorld); |
34 // TODO(ngeoffray): For static methods, we could pass a method with a | 34 // TODO(ngeoffray): For static methods, we could pass a method with a |
35 // defined arity. | 35 // defined arity. |
36 MethodElement helper = backend.helpers.closureConverter; | 36 MethodElement helper = backend.commonElements.closureConverter; |
37 builder.pushInvokeStatic(nativeBody, helper, [local, arity]); | 37 builder.pushInvokeStatic(nativeBody, helper, [local, arity]); |
38 HInstruction closure = builder.pop(); | 38 HInstruction closure = builder.pop(); |
39 return closure; | 39 return closure; |
40 } | 40 } |
41 | 41 |
42 // Check which pattern this native method follows: | 42 // Check which pattern this native method follows: |
43 // 1) foo() native; | 43 // 1) foo() native; |
44 // hasBody = false | 44 // hasBody = false |
45 // 2) foo() native "bar"; | 45 // 2) foo() native "bar"; |
46 // No longer supported, this is now done with @JSName('foo') and case 1. | 46 // No longer supported, this is now done with @JSName('foo') and case 1. |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 LiteralString jsCode = nativeBody.asLiteralString(); | 119 LiteralString jsCode = nativeBody.asLiteralString(); |
120 builder.push(new HForeignCode.statement( | 120 builder.push(new HForeignCode.statement( |
121 js.js.statementTemplateYielding( | 121 js.js.statementTemplateYielding( |
122 new js.LiteralStatement(jsCode.dartString.slowToString())), | 122 new js.LiteralStatement(jsCode.dartString.slowToString())), |
123 <HInstruction>[], | 123 <HInstruction>[], |
124 new SideEffects(), | 124 new SideEffects(), |
125 null, | 125 null, |
126 builder.commonMasks.dynamicType)); | 126 builder.commonMasks.dynamicType)); |
127 } | 127 } |
128 } | 128 } |
OLD | NEW |