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('scanner/scannerlib.dart'); | 9 #import('scanner/scannerlib.dart'); |
10 #import('ssa/ssa.dart'); | 10 #import('ssa/ssa.dart'); |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 LiteralString jsCode = node.arguments.head; | 239 LiteralString jsCode = node.arguments.head; |
240 String str = jsCode.dartString.slowToString(); | 240 String str = jsCode.dartString.slowToString(); |
241 if (nativeRedirectionRegExp.hasMatch(str)) { | 241 if (nativeRedirectionRegExp.hasMatch(str)) { |
242 nativeMethodName = str; | 242 nativeMethodName = str; |
243 isRedirecting = true; | 243 isRedirecting = true; |
244 } else { | 244 } else { |
245 hasBody = true; | 245 hasBody = true; |
246 } | 246 } |
247 } | 247 } |
248 | 248 |
| 249 if (!hasBody) { |
| 250 compiler.emitter.nativeEmitter.nativeMethods.add(element); |
| 251 } |
| 252 |
249 FunctionParameters parameters = element.computeParameters(builder.compiler); | 253 FunctionParameters parameters = element.computeParameters(builder.compiler); |
250 if (!hasBody) { | 254 if (!hasBody) { |
251 List<String> arguments = <String>[]; | 255 List<String> arguments = <String>[]; |
252 List<HInstruction> inputs = <HInstruction>[]; | 256 List<HInstruction> inputs = <HInstruction>[]; |
253 String receiver = ''; | 257 String receiver = ''; |
254 if (element.isInstanceMember()) { | 258 if (element.isInstanceMember()) { |
255 receiver = '#.'; | 259 receiver = '#.'; |
256 inputs.add(builder.localsHandler.readThis()); | 260 inputs.add(builder.localsHandler.readThis()); |
257 } | 261 } |
258 parameters.forEachParameter((Element parameter) { | 262 parameters.forEachParameter((Element parameter) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 String parameters) { | 347 String parameters) { |
344 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty"); | 348 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty"); |
345 buffer.add("('$methodName')) {\n"); | 349 buffer.add("('$methodName')) {\n"); |
346 buffer.add(" $code"); | 350 buffer.add(" $code"); |
347 buffer.add(" } else {\n"); | 351 buffer.add(" } else {\n"); |
348 buffer.add(" return Object.prototype.$methodName.call(this"); | 352 buffer.add(" return Object.prototype.$methodName.call(this"); |
349 buffer.add(parameters == '' ? '' : ', $parameters'); | 353 buffer.add(parameters == '' ? '' : ', $parameters'); |
350 buffer.add(");\n"); | 354 buffer.add(");\n"); |
351 buffer.add(" }\n"); | 355 buffer.add(" }\n"); |
352 } | 356 } |
OLD | NEW |