| 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 part of native; | 5 part of native; |
| 6 | 6 |
| 7 final RegExp nativeRedirectionRegExp = new RegExp(r'^[a-zA-Z][a-zA-Z_$0-9]*$'); | 7 final RegExp nativeRedirectionRegExp = new RegExp(r'^[a-zA-Z][a-zA-Z_$0-9]*$'); |
| 8 | 8 |
| 9 void handleSsaNative(SsaBuilder builder, Expression nativeBody) { | 9 void handleSsaNative(SsaBuilder builder, Expression nativeBody) { |
| 10 Compiler compiler = builder.compiler; | 10 Compiler compiler = builder.compiler; |
| 11 FunctionElement element = builder.work.element; | 11 FunctionElement element = builder.work.element; |
| 12 NativeEmitter nativeEmitter = builder.nativeEmitter; | 12 NativeEmitter nativeEmitter = builder.nativeEmitter; |
| 13 JavaScriptBackend backend = builder.backend; | 13 JavaScriptBackend backend = builder.backend; |
| 14 | 14 |
| 15 HInstruction convertDartClosure(ParameterElement parameter, | 15 HInstruction convertDartClosure(ParameterElement parameter, |
| 16 FunctionType type) { | 16 FunctionType type) { |
| 17 HInstruction local = builder.localsHandler.readLocal(parameter); | 17 HInstruction local = builder.localsHandler.readLocal(parameter); |
| 18 Constant arityConstant = | 18 ConstantValue arityConstant = |
| 19 builder.constantSystem.createInt(type.computeArity()); | 19 builder.constantSystem.createInt(type.computeArity()); |
| 20 HInstruction arity = builder.graph.addConstant(arityConstant, compiler); | 20 HInstruction arity = builder.graph.addConstant(arityConstant, compiler); |
| 21 // TODO(ngeoffray): For static methods, we could pass a method with a | 21 // TODO(ngeoffray): For static methods, we could pass a method with a |
| 22 // defined arity. | 22 // defined arity. |
| 23 Element helper = backend.getClosureConverter(); | 23 Element helper = backend.getClosureConverter(); |
| 24 builder.pushInvokeStatic(nativeBody, helper, [local, arity]); | 24 builder.pushInvokeStatic(nativeBody, helper, [local, arity]); |
| 25 HInstruction closure = builder.pop(); | 25 HInstruction closure = builder.pop(); |
| 26 return closure; | 26 return closure; |
| 27 } | 27 } |
| 28 | 28 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 LiteralString jsCode = nativeBody.asLiteralString(); | 102 LiteralString jsCode = nativeBody.asLiteralString(); |
| 103 builder.push(new HForeign.statement( | 103 builder.push(new HForeign.statement( |
| 104 js.js.statementTemplateYielding( | 104 js.js.statementTemplateYielding( |
| 105 new js.LiteralStatement(jsCode.dartString.slowToString())), | 105 new js.LiteralStatement(jsCode.dartString.slowToString())), |
| 106 <HInstruction>[], | 106 <HInstruction>[], |
| 107 new SideEffects(), | 107 new SideEffects(), |
| 108 null, | 108 null, |
| 109 backend.dynamicType)); | 109 backend.dynamicType)); |
| 110 } | 110 } |
| 111 } | 111 } |
| OLD | NEW |