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

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

Issue 15026006: Support for extending native classes (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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
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 elements; 5 library elements;
6 6
7 7
8 import '../tree/tree.dart'; 8 import '../tree/tree.dart';
9 import '../util/util.dart'; 9 import '../util/util.dart';
10 import '../resolution/resolution.dart'; 10 import '../resolution/resolution.dart';
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 return isStaticOrTopLevel(element) 325 return isStaticOrTopLevel(element)
326 && (identical(element.kind, ElementKind.FUNCTION)); 326 && (identical(element.kind, ElementKind.FUNCTION));
327 } 327 }
328 328
329 static bool isInstanceMethod(Element element) { 329 static bool isInstanceMethod(Element element) {
330 return !Elements.isUnresolved(element) 330 return !Elements.isUnresolved(element)
331 && element.isInstanceMember() 331 && element.isInstanceMember()
332 && (identical(element.kind, ElementKind.FUNCTION)); 332 && (identical(element.kind, ElementKind.FUNCTION));
333 } 333 }
334 334
335 static bool isNativeOrExtendsNative(ClassElement element) {
336 if (element == null) return false;
337 if (element.isNative()) return true;
338 return isNativeOrExtendsNative(element.superclass);
339 }
340
335 static bool isInstanceSend(Send send, TreeElements elements) { 341 static bool isInstanceSend(Send send, TreeElements elements) {
336 Element element = elements[send]; 342 Element element = elements[send];
337 if (element == null) return !isClosureSend(send, element); 343 if (element == null) return !isClosureSend(send, element);
338 return isInstanceMethod(element) || isInstanceField(element); 344 return isInstanceMethod(element) || isInstanceField(element);
339 } 345 }
340 346
341 static bool isClosureSend(Send send, Element element) { 347 static bool isClosureSend(Send send, Element element) {
342 if (send.isPropertyAccess) return false; 348 if (send.isPropertyAccess) return false;
343 if (send.receiver != null) return false; 349 if (send.receiver != null) return false;
344 Node selector = send.selector; 350 Node selector = send.selector;
345 // this(). 351 // this().
346 if (selector.isThis()) return true; 352 if (selector.isThis()) return true;
347 // (o)() or foo()(). 353 // (o)() or foo()().
348 if (element == null && selector.asIdentifier() == null) return true; 354 if (element == null && selector.asIdentifier() == null) return true;
349 if (element == null) return false; 355 if (element == null) return false;
350 // foo() with foo a local or a parameter. 356 // foo() with foo a local or a parameter.
351 return isLocal(element); 357 return isLocal(element);
352 } 358 }
353 359
354 static SourceString reconstructConstructorNameSourceString(Element element) { 360 static SourceString reconstructConstructorNameSourceString(Element element) {
355 if (element.name == const SourceString('')) { 361 if (element.name == const SourceString('')) {
356 return element.getEnclosingClass().name; 362 return element.getEnclosingClass().name;
357 } else { 363 } else {
358 return new SourceString(reconstructConstructorName(element)); 364 return new SourceString(reconstructConstructorName(element));
359 } 365 }
360 } 366 }
361 367
362 // TODO(johnniwinther): Remove this method. 368 // TODO(johnniwinther): Remove this method.
363 static String reconstructConstructorName(Element element) { 369 static String reconstructConstructorName(Element element) {
364 String className = element.getEnclosingClass().name.slowToString(); 370 String className = element.getEnclosingClass().name.slowToString();
365 if (element.name == const SourceString('')) { 371 if (element.name == const SourceString('')) {
366 return className; 372 return className;
367 } else { 373 } else {
368 return '$className\$${element.name.slowToString()}'; 374 return '$className\$${element.name.slowToString()}';
369 } 375 }
370 } 376 }
371 377
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 int get resolutionState; 941 int get resolutionState;
936 Token get beginToken; 942 Token get beginToken;
937 Token get endToken; 943 Token get endToken;
938 944
939 // TODO(kasperl): Try to get rid of these. 945 // TODO(kasperl): Try to get rid of these.
940 void set annotatedElement(Element value); 946 void set annotatedElement(Element value);
941 void set resolutionState(int value); 947 void set resolutionState(int value);
942 948
943 MetadataAnnotation ensureResolved(Compiler compiler); 949 MetadataAnnotation ensureResolved(Compiler compiler);
944 } 950 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698