| 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 String nativeMethodName = element.name.slowToString(); | 234 String nativeMethodName = element.name.slowToString(); |
| 235 if (!node.arguments.isEmpty()) { | 235 if (!node.arguments.isEmpty()) { |
| 236 if (!node.arguments.tail.isEmpty()) { | 236 if (!node.arguments.tail.isEmpty()) { |
| 237 builder.compiler.cancel('More than one argument to native'); | 237 builder.compiler.cancel('More than one argument to native'); |
| 238 } | 238 } |
| 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 nativeEmitter.addRedirectingMethod(element, nativeMethodName); |
| 244 } else { | 245 } else { |
| 245 hasBody = true; | 246 hasBody = true; |
| 246 } | 247 } |
| 247 } | 248 } |
| 248 | 249 |
| 249 if (!hasBody) { | 250 if (!hasBody) { |
| 250 nativeEmitter.nativeMethods.add(element); | 251 nativeEmitter.nativeMethods.add(element); |
| 251 } | 252 } |
| 252 | 253 |
| 253 FunctionSignature parameters = element.computeSignature(builder.compiler); | 254 FunctionSignature parameters = element.computeSignature(builder.compiler); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 String parameters) { | 347 String parameters) { |
| 347 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty"); | 348 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty"); |
| 348 buffer.add("('$methodName')) {\n"); | 349 buffer.add("('$methodName')) {\n"); |
| 349 buffer.add(" $code"); | 350 buffer.add(" $code"); |
| 350 buffer.add(" } else {\n"); | 351 buffer.add(" } else {\n"); |
| 351 buffer.add(" return Object.prototype.$methodName.call(this"); | 352 buffer.add(" return Object.prototype.$methodName.call(this"); |
| 352 buffer.add(parameters == '' ? '' : ', $parameters'); | 353 buffer.add(parameters == '' ? '' : ', $parameters'); |
| 353 buffer.add(");\n"); | 354 buffer.add(");\n"); |
| 354 buffer.add(" }\n"); | 355 buffer.add(" }\n"); |
| 355 } | 356 } |
| OLD | NEW |