| 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 library native; | 5 library native; |
| 6 | 6 |
| 7 import 'dart:collection' show Queue; | 7 import 'dart:collection' show Queue; |
| 8 import 'dart2jslib.dart' hide SourceString; | 8 import 'dart2jslib.dart' hide SourceString; |
| 9 import 'dart_types.dart'; | 9 import 'dart_types.dart'; |
| 10 import 'elements/elements.dart'; | 10 import 'elements/elements.dart'; |
| (...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 935 | 935 |
| 936 void handleSsaNative(SsaBuilder builder, Expression nativeBody) { | 936 void handleSsaNative(SsaBuilder builder, Expression nativeBody) { |
| 937 Compiler compiler = builder.compiler; | 937 Compiler compiler = builder.compiler; |
| 938 FunctionElement element = builder.work.element; | 938 FunctionElement element = builder.work.element; |
| 939 NativeEmitter nativeEmitter = builder.emitter.nativeEmitter; | 939 NativeEmitter nativeEmitter = builder.emitter.nativeEmitter; |
| 940 | 940 |
| 941 HInstruction convertDartClosure(Element parameter, FunctionType type) { | 941 HInstruction convertDartClosure(Element parameter, FunctionType type) { |
| 942 HInstruction local = builder.localsHandler.readLocal(parameter); | 942 HInstruction local = builder.localsHandler.readLocal(parameter); |
| 943 Constant arityConstant = | 943 Constant arityConstant = |
| 944 builder.constantSystem.createInt(type.computeArity()); | 944 builder.constantSystem.createInt(type.computeArity()); |
| 945 HInstruction arity = builder.graph.addConstant(arityConstant); | 945 HInstruction arity = builder.graph.addConstant(arityConstant, compiler); |
| 946 // TODO(ngeoffray): For static methods, we could pass a method with a | 946 // TODO(ngeoffray): For static methods, we could pass a method with a |
| 947 // defined arity. | 947 // defined arity. |
| 948 Element helper = builder.backend.getClosureConverter(); | 948 Element helper = builder.backend.getClosureConverter(); |
| 949 builder.pushInvokeStatic(nativeBody, helper, [local, arity]); | 949 builder.pushInvokeStatic(nativeBody, helper, [local, arity]); |
| 950 HInstruction closure = builder.pop(); | 950 HInstruction closure = builder.pop(); |
| 951 return closure; | 951 return closure; |
| 952 } | 952 } |
| 953 | 953 |
| 954 // Check which pattern this native method follows: | 954 // Check which pattern this native method follows: |
| 955 // 1) foo() native; | 955 // 1) foo() native; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1018 'native "..." syntax is restricted to functions with zero parameters', | 1018 'native "..." syntax is restricted to functions with zero parameters', |
| 1019 node: nativeBody); | 1019 node: nativeBody); |
| 1020 } | 1020 } |
| 1021 LiteralString jsCode = nativeBody.asLiteralString(); | 1021 LiteralString jsCode = nativeBody.asLiteralString(); |
| 1022 builder.push(new HForeign.statement( | 1022 builder.push(new HForeign.statement( |
| 1023 new js.LiteralStatement(jsCode.dartString.slowToString()), | 1023 new js.LiteralStatement(jsCode.dartString.slowToString()), |
| 1024 <HInstruction>[], | 1024 <HInstruction>[], |
| 1025 new SideEffects())); | 1025 new SideEffects())); |
| 1026 } | 1026 } |
| 1027 } | 1027 } |
| OLD | NEW |