| 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 '../constants/values.dart'; | 6 import '../constants/values.dart'; |
| 7 import '../elements/resolution_types.dart'; | 7 import '../elements/resolution_types.dart'; |
| 8 import '../elements/elements.dart'; | 8 import '../elements/elements.dart'; |
| 9 import '../js/js.dart' as js; | 9 import '../js/js.dart' as js; |
| 10 import '../js_emitter/js_emitter.dart' show NativeEmitter; | 10 import '../js_emitter/js_emitter.dart' show NativeEmitter; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 HInstruction convertDartClosure( | 22 HInstruction convertDartClosure( |
| 23 ParameterElement parameter, ResolutionFunctionType type) { | 23 ParameterElement parameter, ResolutionFunctionType type) { |
| 24 HInstruction local = builder.localsHandler.readLocal(parameter); | 24 HInstruction local = builder.localsHandler.readLocal(parameter); |
| 25 ConstantValue arityConstant = | 25 ConstantValue arityConstant = |
| 26 builder.constantSystem.createInt(type.parameterTypes.length); | 26 builder.constantSystem.createInt(type.parameterTypes.length); |
| 27 HInstruction arity = | 27 HInstruction arity = |
| 28 builder.graph.addConstant(arityConstant, builder.closedWorld); | 28 builder.graph.addConstant(arityConstant, builder.closedWorld); |
| 29 // TODO(ngeoffray): For static methods, we could pass a method with a | 29 // TODO(ngeoffray): For static methods, we could pass a method with a |
| 30 // defined arity. | 30 // defined arity. |
| 31 MethodElement helper = builder.helpers.closureConverter; | 31 MethodElement helper = builder.commonElements.closureConverter; |
| 32 builder.pushInvokeStatic(nativeBody, helper, [local, arity]); | 32 builder.pushInvokeStatic(nativeBody, helper, [local, arity]); |
| 33 HInstruction closure = builder.pop(); | 33 HInstruction closure = builder.pop(); |
| 34 return closure; | 34 return closure; |
| 35 } | 35 } |
| 36 | 36 |
| 37 // Check which pattern this native method follows: | 37 // Check which pattern this native method follows: |
| 38 // 1) foo() native; | 38 // 1) foo() native; |
| 39 // hasBody = false | 39 // hasBody = false |
| 40 // 2) foo() native "bar"; | 40 // 2) foo() native "bar"; |
| 41 // No longer supported, this is now done with @JSName('foo') and case 1. | 41 // 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... |
| 114 LiteralString jsCode = nativeBody.asLiteralString(); | 114 LiteralString jsCode = nativeBody.asLiteralString(); |
| 115 builder.push(new HForeignCode.statement( | 115 builder.push(new HForeignCode.statement( |
| 116 js.js.statementTemplateYielding( | 116 js.js.statementTemplateYielding( |
| 117 new js.LiteralStatement(jsCode.dartString.slowToString())), | 117 new js.LiteralStatement(jsCode.dartString.slowToString())), |
| 118 <HInstruction>[], | 118 <HInstruction>[], |
| 119 new SideEffects(), | 119 new SideEffects(), |
| 120 null, | 120 null, |
| 121 builder.commonMasks.dynamicType)); | 121 builder.commonMasks.dynamicType)); |
| 122 } | 122 } |
| 123 } | 123 } |
| OLD | NEW |