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 #import('dart:uri'); | 6 #import('dart:uri'); |
7 #import('leg.dart'); | 7 #import('leg.dart'); |
8 #import('elements/elements.dart'); | 8 #import('elements/elements.dart'); |
9 #import('js_backend/js_backend.dart'); | 9 #import('js_backend/js_backend.dart'); |
10 #import('scanner/scannerlib.dart'); | 10 #import('scanner/scannerlib.dart'); |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 && element.isGetter() | 188 && element.isGetter() |
189 && nativeEmitter.toNativeName(element.getEnclosingClass()) == 'DOMType') { | 189 && nativeEmitter.toNativeName(element.getEnclosingClass()) == 'DOMType') { |
190 Element helper = | 190 Element helper = |
191 compiler.findHelper(const SourceString('getTypeNameOf')); | 191 compiler.findHelper(const SourceString('getTypeNameOf')); |
192 builder.pushInvokeHelper1(helper, builder.localsHandler.readThis()); | 192 builder.pushInvokeHelper1(helper, builder.localsHandler.readThis()); |
193 builder.close(new HReturn(builder.pop())).addSuccessor(builder.graph.exit); | 193 builder.close(new HReturn(builder.pop())).addSuccessor(builder.graph.exit); |
194 } | 194 } |
195 | 195 |
196 HInstruction convertDartClosure(Element parameter, FunctionType type) { | 196 HInstruction convertDartClosure(Element parameter, FunctionType type) { |
197 HInstruction local = builder.localsHandler.readLocal(parameter); | 197 HInstruction local = builder.localsHandler.readLocal(parameter); |
198 HInstruction arity = builder.graph.addConstantInt(type.computeArity()); | 198 Constant arityConstant = |
| 199 builder.constantSystem.createInt(type.computeArity()); |
| 200 HInstruction arity = builder.graph.addConstant(arityConstant); |
199 // TODO(ngeoffray): For static methods, we could pass a method with a | 201 // TODO(ngeoffray): For static methods, we could pass a method with a |
200 // defined arity. | 202 // defined arity. |
201 Element helper = builder.interceptors.getClosureConverter(); | 203 Element helper = builder.interceptors.getClosureConverter(); |
202 builder.pushInvokeHelper2(helper, local, arity); | 204 builder.pushInvokeHelper2(helper, local, arity); |
203 HInstruction closure = builder.pop(); | 205 HInstruction closure = builder.pop(); |
204 return closure; | 206 return closure; |
205 } | 207 } |
206 | 208 |
207 // Check which pattern this native method follows: | 209 // Check which pattern this native method follows: |
208 // 1) foo() native; hasBody = false, isRedirecting = false | 210 // 1) foo() native; hasBody = false, isRedirecting = false |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 String parameters) { | 331 String parameters) { |
330 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty"); | 332 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty"); |
331 buffer.add("('$methodName')) {\n"); | 333 buffer.add("('$methodName')) {\n"); |
332 buffer.add(" $code"); | 334 buffer.add(" $code"); |
333 buffer.add(" } else {\n"); | 335 buffer.add(" } else {\n"); |
334 buffer.add(" return Object.prototype.$methodName.call(this"); | 336 buffer.add(" return Object.prototype.$methodName.call(this"); |
335 buffer.add(parameters == '' ? '' : ', $parameters'); | 337 buffer.add(parameters == '' ? '' : ', $parameters'); |
336 buffer.add(");\n"); | 338 buffer.add(");\n"); |
337 buffer.add(" }\n"); | 339 buffer.add(" }\n"); |
338 } | 340 } |
OLD | NEW |