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

Side by Side Diff: pkg/compiler/lib/src/native/enqueue.dart

Issue 1132783002: Add Accessor, Getter, and Setter elements. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased Created 5 years, 7 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 | « pkg/compiler/lib/src/library_loader.dart ('k') | pkg/compiler/lib/src/native/native.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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 part of native; 5 part of native;
6 6
7 /** 7 /**
8 * This could be an abstract class but we use it as a stub for the dart_backend. 8 * This could be an abstract class but we use it as a stub for the dart_backend.
9 */ 9 */
10 class NativeEnqueuer { 10 class NativeEnqueuer {
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 nativeClasses.forEach(walkPotentialSubclasses); 218 nativeClasses.forEach(walkPotentialSubclasses);
219 219
220 nativeClasses.addAll(nativeClassesAndSubclasses); 220 nativeClasses.addAll(nativeClassesAndSubclasses);
221 unusedClasses.addAll(nativeClassesAndSubclasses); 221 unusedClasses.addAll(nativeClassesAndSubclasses);
222 } 222 }
223 223
224 /** 224 /**
225 * Returns the source string of the class named in the extends clause, or 225 * Returns the source string of the class named in the extends clause, or
226 * `null` if there is no extends clause. 226 * `null` if there is no extends clause.
227 */ 227 */
228 String findExtendsNameOfClass(ClassElement classElement) { 228 String findExtendsNameOfClass(BaseClassElementX classElement) {
229 // "class B extends A ... {}" --> "A" 229 // "class B extends A ... {}" --> "A"
230 // "class B extends foo.A ... {}" --> "A" 230 // "class B extends foo.A ... {}" --> "A"
231 // "class B<T> extends foo.A<T,T> with M1, M2 ... {}" --> "A" 231 // "class B<T> extends foo.A<T,T> with M1, M2 ... {}" --> "A"
232 232
233 // We want to avoid calling classElement.parseNode on every class. Doing so 233 // We want to avoid calling classElement.parseNode on every class. Doing so
234 // will slightly increase parse time and size and cause compiler errors and 234 // will slightly increase parse time and size and cause compiler errors and
235 // warnings to me emitted in more unused code. 235 // warnings to me emitted in more unused code.
236 236
237 // An alternative to this code is to extend the API of ClassElement to 237 // An alternative to this code is to extend the API of ClassElement to
238 // expose the name of the extended element. 238 // expose the name of the extended element.
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 353
354 void flushQueue() { 354 void flushQueue() {
355 if (flushing) return; 355 if (flushing) return;
356 flushing = true; 356 flushing = true;
357 while (!queue.isEmpty) { 357 while (!queue.isEmpty) {
358 (queue.removeFirst())(); 358 (queue.removeFirst())();
359 } 359 }
360 flushing = false; 360 flushing = false;
361 } 361 }
362 362
363 processClass(ClassElementX classElement, cause) { 363 processClass(BaseClassElementX classElement, cause) {
364 // TODO(ahe): Fix this assertion to work in incremental compilation. 364 // TODO(ahe): Fix this assertion to work in incremental compilation.
365 assert(compiler.hasIncrementalSupport || 365 assert(compiler.hasIncrementalSupport ||
366 !registeredClasses.contains(classElement)); 366 !registeredClasses.contains(classElement));
367 367
368 bool firstTime = registeredClasses.isEmpty; 368 bool firstTime = registeredClasses.isEmpty;
369 pendingClasses.remove(classElement); 369 pendingClasses.remove(classElement);
370 registeredClasses.add(classElement); 370 registeredClasses.add(classElement);
371 371
372 // TODO(ahe): Is this really a global dependency? 372 // TODO(ahe): Is this really a global dependency?
373 world.registerInstantiatedClass(classElement, compiler.globalDependencies); 373 world.registerInstantiatedClass(classElement, compiler.globalDependencies);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 if (method.isStatic) { 415 if (method.isStatic) {
416 setNativeNameForStaticMethod(method); 416 setNativeNameForStaticMethod(method);
417 } else { 417 } else {
418 setNativeName(method); 418 setNativeName(method);
419 } 419 }
420 } 420 }
421 } 421 }
422 422
423 /// Sets the native name of [element], either from an annotation, or 423 /// Sets the native name of [element], either from an annotation, or
424 /// defaulting to the Dart name. 424 /// defaulting to the Dart name.
425 void setNativeName(Element element) { 425 void setNativeName(ElementX element) {
426 String name = findJsNameFromAnnotation(element); 426 String name = findJsNameFromAnnotation(element);
427 if (name == null) name = element.name; 427 if (name == null) name = element.name;
428 element.setNative(name); 428 element.setNative(name);
429 } 429 }
430 430
431 /// Sets the native name of the static native method [element], using the 431 /// Sets the native name of the static native method [element], using the
432 /// following rules: 432 /// following rules:
433 /// 1. If [element] has a @JSName annotation that is an identifier, qualify 433 /// 1. If [element] has a @JSName annotation that is an identifier, qualify
434 /// that identifier to the @Native name of the enclosing class 434 /// that identifier to the @Native name of the enclosing class
435 /// 2. If [element] has a @JSName annotation that is not an identifier, 435 /// 2. If [element] has a @JSName annotation that is not an identifier,
436 /// use the declared @JSName as the expression 436 /// use the declared @JSName as the expression
437 /// 3. If [element] does not have a @JSName annotation, qualify the name of 437 /// 3. If [element] does not have a @JSName annotation, qualify the name of
438 /// the method with the @Native name of the enclosing class. 438 /// the method with the @Native name of the enclosing class.
439 void setNativeNameForStaticMethod(Element element) { 439 void setNativeNameForStaticMethod(ElementX element) {
440 String name = findJsNameFromAnnotation(element); 440 String name = findJsNameFromAnnotation(element);
441 if (name == null) name = element.name; 441 if (name == null) name = element.name;
442 if (isIdentifier(name)) { 442 if (isIdentifier(name)) {
443 List<String> nativeNames = nativeTagsOfClassRaw(element.enclosingClass); 443 List<String> nativeNames = nativeTagsOfClassRaw(element.enclosingClass);
444 if (nativeNames.length != 1) { 444 if (nativeNames.length != 1) {
445 compiler.internalError(element, 445 compiler.internalError(element,
446 'Unable to determine a native name for the enclosing class, ' 446 'Unable to determine a native name for the enclosing class, '
447 'options: $nativeNames'); 447 'options: $nativeNames');
448 } 448 }
449 element.setNative('${nativeNames[0]}.$name'); 449 element.setNative('${nativeNames[0]}.$name');
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 superclass, 683 superclass,
684 () => <ClassElement>[]); 684 () => <ClassElement>[]);
685 directSubtypes.add(cls); 685 directSubtypes.add(cls);
686 } 686 }
687 687
688 void logSummary(log(message)) { 688 void logSummary(log(message)) {
689 log('Compiled ${registeredClasses.length} native classes, ' 689 log('Compiled ${registeredClasses.length} native classes, '
690 '${unusedClasses.length} native classes omitted.'); 690 '${unusedClasses.length} native classes omitted.');
691 } 691 }
692 } 692 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/library_loader.dart ('k') | pkg/compiler/lib/src/native/native.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698