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('js_backend/js_backend.dart'); | 9 #import('js_backend/js_backend.dart'); |
10 #import('scanner/scannerlib.dart'); | 10 #import('scanner/scannerlib.dart'); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 const SourceString('toStringForNativeObject'))); | 72 const SourceString('toStringForNativeObject'))); |
73 } | 73 } |
74 } | 74 } |
75 | 75 |
76 void maybeEnableNative(Compiler compiler, | 76 void maybeEnableNative(Compiler compiler, |
77 LibraryElement library, | 77 LibraryElement library, |
78 Uri uri) { | 78 Uri uri) { |
79 String libraryName = uri.toString(); | 79 String libraryName = uri.toString(); |
80 if (library.entryCompilationUnit.script.name.contains( | 80 if (library.entryCompilationUnit.script.name.contains( |
81 'dart/tests/compiler/dart2js_native') | 81 'dart/tests/compiler/dart2js_native') |
82 || libraryName == 'dart:dom_deprecated' | |
83 || libraryName == 'dart:isolate' | 82 || libraryName == 'dart:isolate' |
84 || libraryName == 'dart:html') { | 83 || libraryName == 'dart:html') { |
85 library.canUseNative = true; | 84 library.canUseNative = true; |
86 } | 85 } |
87 } | 86 } |
88 | 87 |
89 void checkAllowedLibrary(ElementListener listener, Token token) { | 88 void checkAllowedLibrary(ElementListener listener, Token token) { |
90 LibraryElement currentLibrary = listener.compilationUnitElement.getLibrary(); | 89 LibraryElement currentLibrary = listener.compilationUnitElement.getLibrary(); |
91 if (!currentLibrary.canUseNative) { | 90 if (!currentLibrary.canUseNative) { |
92 listener.recoverableError("Unexpected token", token: token); | 91 listener.recoverableError("Unexpected token", token: token); |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 String parameters) { | 330 String parameters) { |
332 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty"); | 331 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty"); |
333 buffer.add("('$methodName')) {\n"); | 332 buffer.add("('$methodName')) {\n"); |
334 buffer.add(" $code"); | 333 buffer.add(" $code"); |
335 buffer.add(" } else {\n"); | 334 buffer.add(" } else {\n"); |
336 buffer.add(" return Object.prototype.$methodName.call(this"); | 335 buffer.add(" return Object.prototype.$methodName.call(this"); |
337 buffer.add(parameters == '' ? '' : ', $parameters'); | 336 buffer.add(parameters == '' ? '' : ', $parameters'); |
338 buffer.add(");\n"); | 337 buffer.add(");\n"); |
339 buffer.add(" }\n"); | 338 buffer.add(" }\n"); |
340 } | 339 } |
OLD | NEW |