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

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

Issue 10867011: Deal with the JS helper separately from the 'native' keyword. (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/leg.dart ('k') | lib/compiler/implementation/patch_parser.dart » ('j') | 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
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' 82 || libraryName == 'dart:dom_deprecated'
83 || libraryName == 'dart:isolate' 83 || libraryName == 'dart:isolate'
84 || libraryName == 'dart:math'
85 || libraryName == 'dart:html') { 84 || libraryName == 'dart:html') {
86 library.canUseNative = true; 85 library.canUseNative = true;
87 library.addToScope(compiler.findHelper(const SourceString('JS')), compiler);
88 if (compiler.jsIndexingBehaviorInterface !== null) {
89 library.addToScope(compiler.jsIndexingBehaviorInterface, compiler);
90 }
91 } 86 }
92 } 87 }
93 88
94 void checkAllowedLibrary(ElementListener listener, Token token) { 89 void checkAllowedLibrary(ElementListener listener, Token token) {
95 LibraryElement currentLibrary = listener.compilationUnitElement.getLibrary(); 90 LibraryElement currentLibrary = listener.compilationUnitElement.getLibrary();
96 if (!currentLibrary.canUseNative) { 91 if (!currentLibrary.canUseNative) {
97 listener.recoverableError("Unexpected token", token: token); 92 listener.recoverableError("Unexpected token", token: token);
98 } 93 }
99 } 94 }
100 95
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 String parameters) { 329 String parameters) {
335 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty"); 330 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty");
336 buffer.add("('$methodName')) {\n"); 331 buffer.add("('$methodName')) {\n");
337 buffer.add(" $code"); 332 buffer.add(" $code");
338 buffer.add(" } else {\n"); 333 buffer.add(" } else {\n");
339 buffer.add(" return Object.prototype.$methodName.call(this"); 334 buffer.add(" return Object.prototype.$methodName.call(this");
340 buffer.add(parameters == '' ? '' : ', $parameters'); 335 buffer.add(parameters == '' ? '' : ', $parameters');
341 buffer.add(");\n"); 336 buffer.add(");\n");
342 buffer.add(" }\n"); 337 buffer.add(" }\n");
343 } 338 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/leg.dart ('k') | lib/compiler/implementation/patch_parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698