Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Side by Side Diff: lib/compiler/implementation/native_handler.dart

Issue 10828413: Only add JS once, and not to very single patched library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « lib/compiler/implementation/compiler.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
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' 82 || libraryName == 'dart:dom_deprecated'
83 || libraryName == 'dart:isolate' 83 || libraryName == 'dart:isolate'
84 || libraryName == 'dart:html') { 84 || libraryName == 'dart:html') {
85 library.canUseNative = true; 85 library.canUseNative = true;
86 library.addToScope(compiler.findHelper(const SourceString('JS')), compiler); 86 compiler.addForeignFunctions(library);
ahe 2012/08/21 11:28:31 I'm not sure about this. What do you need?
Anders Johnsen 2012/08/21 11:40:23 The problem is not here, but in the other file. We
ahe 2012/08/21 12:01:16 I don't think the patch libraries need all the for
Anders Johnsen 2012/08/21 14:31:11 Thank you for explaining, I've reverted this parti
87 if (compiler.jsIndexingBehaviorInterface !== null) { 87 if (compiler.jsIndexingBehaviorInterface !== null) {
88 library.addToScope(compiler.jsIndexingBehaviorInterface, compiler); 88 library.addToScope(compiler.jsIndexingBehaviorInterface, compiler);
89 } 89 }
90 } 90 }
91 } 91 }
92 92
93 void checkAllowedLibrary(ElementListener listener, Token token) { 93 void checkAllowedLibrary(ElementListener listener, Token token) {
94 LibraryElement currentLibrary = listener.compilationUnitElement.getLibrary(); 94 LibraryElement currentLibrary = listener.compilationUnitElement.getLibrary();
95 if (!currentLibrary.canUseNative) { 95 if (!currentLibrary.canUseNative) {
96 listener.recoverableError("Unexpected token", token: token); 96 listener.recoverableError("Unexpected token", token: token);
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 String parameters) { 333 String parameters) {
334 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty"); 334 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty");
335 buffer.add("('$methodName')) {\n"); 335 buffer.add("('$methodName')) {\n");
336 buffer.add(" $code"); 336 buffer.add(" $code");
337 buffer.add(" } else {\n"); 337 buffer.add(" } else {\n");
338 buffer.add(" return Object.prototype.$methodName.call(this"); 338 buffer.add(" return Object.prototype.$methodName.call(this");
339 buffer.add(parameters == '' ? '' : ', $parameters'); 339 buffer.add(parameters == '' ? '' : ', $parameters');
340 buffer.add(");\n"); 340 buffer.add(");\n");
341 buffer.add(" }\n"); 341 buffer.add(" }\n");
342 } 342 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/compiler.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698