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

Side by Side Diff: pkg/compiler/lib/src/elements/elements.dart

Issue 1318043005: Support user generated custom native JS classes. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: about to land Created 5 years, 2 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
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 import '../common.dart'; 7 import '../common.dart';
8 import '../common/resolution.dart' show 8 import '../common/resolution.dart' show
9 Resolution; 9 Resolution;
10 import '../compiler.dart' show 10 import '../compiler.dart' show
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 299
300 /// Returns true if this [Element] is a top level element. 300 /// Returns true if this [Element] is a top level element.
301 /// That is, if it is not defined within the scope of a class. 301 /// That is, if it is not defined within the scope of a class.
302 /// 302 ///
303 /// This means whether the enclosing element is a compilation unit. 303 /// This means whether the enclosing element is a compilation unit.
304 /// With the exception of [ClosureClassElement] that is considered top level 304 /// With the exception of [ClosureClassElement] that is considered top level
305 /// as all other classes. 305 /// as all other classes.
306 bool get isTopLevel; 306 bool get isTopLevel;
307 bool get isAssignable; 307 bool get isAssignable;
308 bool get isNative; 308 bool get isNative;
309 bool get isJsInterop;
310
309 bool get isDeferredLoaderGetter; 311 bool get isDeferredLoaderGetter;
310 312
311 /// True if the element is declared in a patch library but has no 313 /// True if the element is declared in a patch library but has no
312 /// corresponding declaration in the origin library. 314 /// corresponding declaration in the origin library.
313 bool get isInjected; 315 bool get isInjected;
314 316
315 /// `true` if this element is a constructor, top level or local variable, 317 /// `true` if this element is a constructor, top level or local variable,
316 /// or static field that is declared `const`. 318 /// or static field that is declared `const`.
317 bool get isConst; 319 bool get isConst;
318 320
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 /// 397 ///
396 /// See [:patch_parser.dart:] for a description of the terminology. 398 /// See [:patch_parser.dart:] for a description of the terminology.
397 Element get origin; 399 Element get origin;
398 400
399 bool get isSynthesized; 401 bool get isSynthesized;
400 bool get isMixinApplication; 402 bool get isMixinApplication;
401 403
402 bool get hasFixedBackendName; 404 bool get hasFixedBackendName;
403 String get fixedBackendName; 405 String get fixedBackendName;
404 406
407 String get jsInteropName;
408
405 bool get isAbstract; 409 bool get isAbstract;
406 410
407 Scope buildScope(); 411 Scope buildScope();
408 412
409 // TODO(johnniwinther): Move this to [AstElement]. 413 // TODO(johnniwinther): Move this to [AstElement].
410 /// Returns the [Element] that holds the [TreeElements] for this element. 414 /// Returns the [Element] that holds the [TreeElements] for this element.
411 AnalyzableElement get analyzableElement; 415 AnalyzableElement get analyzableElement;
412 416
413 accept(ElementVisitor visitor, arg); 417 accept(ElementVisitor visitor, arg);
418
419 void setJsInteropName(String name);
420 void markAsJsInterop();
414 } 421 }
415 422
416 class Elements { 423 class Elements {
417 static bool isUnresolved(Element e) { 424 static bool isUnresolved(Element e) {
418 return e == null || e.isErroneous; 425 return e == null || e.isErroneous;
419 } 426 }
420 static bool isErroneous(Element e) => e != null && e.isErroneous; 427 static bool isErroneous(Element e) => e != null && e.isErroneous;
421 428
422 /// Unwraps [element] reporting any warnings attached to it, if any. 429 /// Unwraps [element] reporting any warnings attached to it, if any.
423 static Element unwrap(Element element, 430 static Element unwrap(Element element,
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 // it specially. 515 // it specially.
509 if (element.isGenerativeConstructorBody) return true; 516 if (element.isGenerativeConstructorBody) return true;
510 return !Elements.isUnresolved(element) && 517 return !Elements.isUnresolved(element) &&
511 !element.isAbstract && 518 !element.isAbstract &&
512 element.isInstanceMember && 519 element.isInstanceMember &&
513 (element.isFunction || element.isAccessor); 520 (element.isFunction || element.isAccessor);
514 } 521 }
515 522
516 static bool isNativeOrExtendsNative(ClassElement element) { 523 static bool isNativeOrExtendsNative(ClassElement element) {
517 if (element == null) return false; 524 if (element == null) return false;
518 if (element.isNative) return true; 525 if (element.isNative || element.isJsInterop) return true;
519 assert(element.isResolved); 526 assert(element.isResolved);
520 return isNativeOrExtendsNative(element.superclass); 527 return isNativeOrExtendsNative(element.superclass);
521 } 528 }
522 529
523 static bool isInstanceSend(Send send, TreeElements elements) { 530 static bool isInstanceSend(Send send, TreeElements elements) {
524 Element element = elements[send]; 531 Element element = elements[send];
525 if (element == null) return !isClosureSend(send, element); 532 if (element == null) return !isClosureSend(send, element);
526 return isInstanceMethod(element) || 533 return isInstanceMethod(element) ||
527 isInstanceField(element) || 534 isInstanceField(element) ||
528 (send.isConditional && !element.isStatic); 535 (send.isConditional && !element.isStatic);
(...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1703 bool get isDeclaredByField; 1710 bool get isDeclaredByField;
1704 1711
1705 /// Returns `true` if this member is abstract. 1712 /// Returns `true` if this member is abstract.
1706 bool get isAbstract; 1713 bool get isAbstract;
1707 1714
1708 /// If abstract, [implementation] points to the overridden concrete member, 1715 /// If abstract, [implementation] points to the overridden concrete member,
1709 /// if any. Otherwise [implementation] points to the member itself. 1716 /// if any. Otherwise [implementation] points to the member itself.
1710 Member get implementation; 1717 Member get implementation;
1711 } 1718 }
1712 1719
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/diagnostics/messages.dart ('k') | pkg/compiler/lib/src/elements/modelx.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698