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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 | 74 |
| 75 void maybeEnableNative(Compiler compiler, | 75 void maybeEnableNative(Compiler compiler, |
| 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/tests/compiler/dart2js_native') | 79 if (library.script.name.contains('dart/tests/compiler/dart2js_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.canUseNative = true; | 83 library.canUseNative = true; |
| 84 library.define(compiler.findHelper(const SourceString('JS')), compiler); | |
|
Lasse Reichstein Nielsen
2012/07/04 13:49:44
Maybe we should extend the map in library_map.dart
| |
| 84 if (compiler.jsIndexingBehaviorInterface !== null) { | 85 if (compiler.jsIndexingBehaviorInterface !== null) { |
| 85 library.define(compiler.jsIndexingBehaviorInterface, compiler); | 86 library.define(compiler.jsIndexingBehaviorInterface, compiler); |
| 86 } | 87 } |
| 87 } | 88 } |
| 88 | |
| 89 // Additionaly, if this is a test, we allow access to foreign functions. | |
| 90 if (library.script.name.contains('dart/tests/compiler/dart2js_native')) { | |
| 91 library.define(compiler.findHelper(const SourceString('JS')), compiler); | |
| 92 } | |
| 93 } | 89 } |
| 94 | 90 |
| 95 void checkAllowedLibrary(ElementListener listener, Token token) { | 91 void checkAllowedLibrary(ElementListener listener, Token token) { |
| 96 LibraryElement currentLibrary = listener.compilationUnitElement.getLibrary(); | 92 LibraryElement currentLibrary = listener.compilationUnitElement.getLibrary(); |
| 97 if (!currentLibrary.canUseNative) { | 93 if (!currentLibrary.canUseNative) { |
| 98 listener.recoverableError("Unexpected token", token: token); | 94 listener.recoverableError("Unexpected token", token: token); |
| 99 } | 95 } |
| 100 } | 96 } |
| 101 | 97 |
| 102 Token handleNativeBlockToSkip(Listener listener, Token token) { | 98 Token handleNativeBlockToSkip(Listener listener, Token token) { |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 333 String parameters) { | 329 String parameters) { |
| 334 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty"); | 330 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty"); |
| 335 buffer.add("('$methodName')) {\n"); | 331 buffer.add("('$methodName')) {\n"); |
| 336 buffer.add(" $code"); | 332 buffer.add(" $code"); |
| 337 buffer.add(" } else {\n"); | 333 buffer.add(" } else {\n"); |
| 338 buffer.add(" return Object.prototype.$methodName.call(this"); | 334 buffer.add(" return Object.prototype.$methodName.call(this"); |
| 339 buffer.add(parameters == '' ? '' : ', $parameters'); | 335 buffer.add(parameters == '' ? '' : ', $parameters'); |
| 340 buffer.add(");\n"); | 336 buffer.add(");\n"); |
| 341 buffer.add(" }\n"); | 337 buffer.add(" }\n"); |
| 342 } | 338 } |
| OLD | NEW |