Chromium Code Reviews| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 LibraryElement library, | 76 LibraryElement library, |
| 77 Uri uri) { | 77 Uri uri) { |
| 78 String libraryName = uri.toString(); | 78 String libraryName = uri.toString(); |
| 79 if (library.script.name.contains('dart/frog/tests/frog_native') | 79 if (library.script.name.contains('dart/frog/tests/frog_native') |
| 80 || libraryName == 'dart:dom_deprecated' | 80 || libraryName == 'dart:dom_deprecated' |
| 81 || libraryName == 'dart:isolate' | 81 || libraryName == 'dart:isolate' |
| 82 || libraryName == 'dart:html') { | 82 || libraryName == 'dart:html') { |
| 83 library.define(new ForeignElement( | 83 library.define(new ForeignElement( |
| 84 const SourceString('native'), library), compiler); | 84 const SourceString('native'), library), compiler); |
| 85 library.canUseNative = true; | 85 library.canUseNative = true; |
| 86 library.define(compiler.javaScriptIndexingBehaviorInterface, compiler); | |
|
ahe
2012/06/12 18:30:04
For the unit tests, it may make sense to test for
ngeoffray
2012/06/13 13:02:42
Done.
| |
| 86 } | 87 } |
| 87 | 88 |
| 88 // Additionaly, if this is a test, we allow access to foreign functions. | 89 // Additionaly, if this is a test, we allow access to foreign functions. |
| 89 if (library.script.name.contains('dart/frog/tests/frog_native')) { | 90 if (library.script.name.contains('dart/frog/tests/frog_native')) { |
| 90 library.define(compiler.findHelper(const SourceString('JS')), compiler); | 91 library.define(compiler.findHelper(const SourceString('JS')), compiler); |
| 91 } | 92 } |
| 92 } | 93 } |
| 93 | 94 |
| 94 void checkAllowedLibrary(ElementListener listener, Token token) { | 95 void checkAllowedLibrary(ElementListener listener, Token token) { |
| 95 LibraryElement currentLibrary = listener.compilationUnitElement.getLibrary(); | 96 LibraryElement currentLibrary = listener.compilationUnitElement.getLibrary(); |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 350 String parameters) { | 351 String parameters) { |
| 351 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty"); | 352 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty"); |
| 352 buffer.add("('$methodName')) {\n"); | 353 buffer.add("('$methodName')) {\n"); |
| 353 buffer.add(" $code"); | 354 buffer.add(" $code"); |
| 354 buffer.add(" } else {\n"); | 355 buffer.add(" } else {\n"); |
| 355 buffer.add(" return Object.prototype.$methodName.call(this"); | 356 buffer.add(" return Object.prototype.$methodName.call(this"); |
| 356 buffer.add(parameters == '' ? '' : ', $parameters'); | 357 buffer.add(parameters == '' ? '' : ', $parameters'); |
| 357 buffer.add(");\n"); | 358 buffer.add(");\n"); |
| 358 buffer.add(" }\n"); | 359 buffer.add(" }\n"); |
| 359 } | 360 } |
| OLD | NEW |