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

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

Issue 11967010: Internal libraries supported. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased Created 7 years, 11 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
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 6
7 import 'dart:collection' show Queue; 7 import 'dart:collection' show Queue;
8 import 'dart:uri'; 8 import 'dart:uri';
9 import 'dart2jslib.dart' hide SourceString; 9 import 'dart2jslib.dart' hide SourceString;
10 import 'elements/elements.dart'; 10 import 'elements/elements.dart';
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 // Also parse the node to know all its methods because otherwise it will 217 // Also parse the node to know all its methods because otherwise it will
218 // only be parsed if there is a call to one of its constructors. 218 // only be parsed if there is a call to one of its constructors.
219 classElement.parseNode(compiler); 219 classElement.parseNode(compiler);
220 220
221 if (firstTime) { 221 if (firstTime) {
222 queue.add(onFirstNativeClass); 222 queue.add(onFirstNativeClass);
223 } 223 }
224 } 224 }
225 225
226 registerElement(Element element) { 226 registerElement(Element element) {
227 if (element.isFunction() || element.isGetter() || element.isSetter()) { 227 compiler.withCurrentElement(element, () {
228 handleMethodAnnotations(element); 228 if (element.isFunction() || element.isGetter() || element.isSetter()) {
229 if (element.isNative()) { 229 handleMethodAnnotations(element);
230 registerMethodUsed(element); 230 if (element.isNative()) {
231 registerMethodUsed(element);
232 }
233 } else if (element.isField()) {
234 handleFieldAnnotations(element);
235 if (element.isNative()) {
236 registerFieldLoad(element);
237 registerFieldStore(element);
238 }
231 } 239 }
232 } else if (element.isField()) { 240 });
233 handleFieldAnnotations(element);
234 if (element.isNative()) {
235 registerFieldLoad(element);
236 registerFieldStore(element);
237 }
238 }
239 } 241 }
240 242
241 handleFieldAnnotations(Element element) { 243 handleFieldAnnotations(Element element) {
242 if (element.enclosingElement.isNative()) { 244 if (element.enclosingElement.isNative()) {
243 // Exclude non-instance (static) fields - they not really native and are 245 // Exclude non-instance (static) fields - they not really native and are
244 // compiled as isolate globals. Access of a property of a constructor 246 // compiled as isolate globals. Access of a property of a constructor
245 // function or a non-method property in the prototype chain, must be coded 247 // function or a non-method property in the prototype chain, must be coded
246 // using a JS-call. 248 // using a JS-call.
247 if (element.isInstanceMember()) { 249 if (element.isInstanceMember()) {
248 setNativeName(element); 250 setNativeName(element);
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 directSubtypes.add(cls); 445 directSubtypes.add(cls);
444 } 446 }
445 447
446 void logSummary(log(message)) { 448 void logSummary(log(message)) {
447 log('Compiled ${registeredClasses.length} native classes, ' 449 log('Compiled ${registeredClasses.length} native classes, '
448 '${unusedClasses.length} native classes omitted.'); 450 '${unusedClasses.length} native classes omitted.');
449 } 451 }
450 } 452 }
451 453
452 void maybeEnableNative(Compiler compiler, 454 void maybeEnableNative(Compiler compiler,
453 LibraryElement library, 455 LibraryElement library) {
454 Uri uri) { 456 String libraryName = library.canonicalUri.toString();
455 String libraryName = uri.toString();
456 if (library.entryCompilationUnit.script.name.contains( 457 if (library.entryCompilationUnit.script.name.contains(
457 'dart/tests/compiler/dart2js_native') 458 'dart/tests/compiler/dart2js_native')
458 || libraryName == 'dart:async' 459 || libraryName == 'dart:async'
459 || libraryName == 'dart:html' 460 || libraryName == 'dart:html'
460 || libraryName == 'dart:html_common' 461 || libraryName == 'dart:html_common'
461 || libraryName == 'dart:indexed_db' 462 || libraryName == 'dart:indexed_db'
462 || libraryName == 'dart:svg' 463 || libraryName == 'dart:svg'
463 || libraryName == 'dart:web_audio') { 464 || libraryName == 'dart:web_audio') {
464 library.canUseNative = true; 465 library.canUseNative = true;
465 } 466 }
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 } else { 877 } else {
877 if (parameters.parameterCount != 0) { 878 if (parameters.parameterCount != 0) {
878 compiler.cancel( 879 compiler.cancel(
879 'native "..." syntax is restricted to functions with zero parameters', 880 'native "..." syntax is restricted to functions with zero parameters',
880 node: nativeBody); 881 node: nativeBody);
881 } 882 }
882 LiteralString jsCode = nativeBody.asLiteralString(); 883 LiteralString jsCode = nativeBody.asLiteralString();
883 builder.push(new HForeign.statement(jsCode.dartString, <HInstruction>[])); 884 builder.push(new HForeign.statement(jsCode.dartString, <HInstruction>[]));
884 } 885 }
885 } 886 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698