| 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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 HInstruction jsClosure = convertDartClosure(parameter, type); | 285 HInstruction jsClosure = convertDartClosure(parameter, type); |
| 286 // Because the JS code references the argument name directly, | 286 // Because the JS code references the argument name directly, |
| 287 // we must keep the name and assign the JS closure to it. | 287 // we must keep the name and assign the JS closure to it. |
| 288 builder.add(new HForeign( | 288 builder.add(new HForeign( |
| 289 new DartString.literal('${parameter.name.slowToString()} = #'), | 289 new DartString.literal('${parameter.name.slowToString()} = #'), |
| 290 const LiteralDartString('void'), | 290 const LiteralDartString('void'), |
| 291 <HInstruction>[jsClosure])); | 291 <HInstruction>[jsClosure])); |
| 292 } | 292 } |
| 293 }); | 293 }); |
| 294 LiteralString jsCode = nativeBody.asLiteralString(); | 294 LiteralString jsCode = nativeBody.asLiteralString(); |
| 295 builder.push(new HForeign(jsCode.dartString, | 295 builder.push(new HForeign.statement(jsCode.dartString, <HInstruction>[])); |
| 296 const LiteralDartString('Object'), | |
| 297 <HInstruction>[])); | |
| 298 } | 296 } |
| 299 } | 297 } |
| 300 | 298 |
| 301 void generateMethodWithPrototypeCheckForElement(Compiler compiler, | 299 void generateMethodWithPrototypeCheckForElement(Compiler compiler, |
| 302 StringBuffer buffer, | 300 StringBuffer buffer, |
| 303 FunctionElement element, | 301 FunctionElement element, |
| 304 String code, | 302 String code, |
| 305 String parameters) { | 303 String parameters) { |
| 306 String methodName; | 304 String methodName; |
| 307 Namer namer = compiler.namer; | 305 Namer namer = compiler.namer; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 335 String parameters) { | 333 String parameters) { |
| 336 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty"); | 334 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty"); |
| 337 buffer.add("('$methodName')) {\n"); | 335 buffer.add("('$methodName')) {\n"); |
| 338 buffer.add(" $code"); | 336 buffer.add(" $code"); |
| 339 buffer.add(" } else {\n"); | 337 buffer.add(" } else {\n"); |
| 340 buffer.add(" return Object.prototype.$methodName.call(this"); | 338 buffer.add(" return Object.prototype.$methodName.call(this"); |
| 341 buffer.add(parameters == '' ? '' : ', $parameters'); | 339 buffer.add(parameters == '' ? '' : ', $parameters'); |
| 342 buffer.add(");\n"); | 340 buffer.add(");\n"); |
| 343 buffer.add(" }\n"); | 341 buffer.add(" }\n"); |
| 344 } | 342 } |
| OLD | NEW |