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

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: ptal 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/resolution.dart' show 7 import '../common/resolution.dart' show
8 Resolution; 8 Resolution;
9 import '../compiler.dart' show 9 import '../compiler.dart' show
10 Compiler; 10 Compiler;
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 305
306 /// Returns true if this [Element] is a top level element. 306 /// Returns true if this [Element] is a top level element.
307 /// That is, if it is not defined within the scope of a class. 307 /// That is, if it is not defined within the scope of a class.
308 /// 308 ///
309 /// This means whether the enclosing element is a compilation unit. 309 /// This means whether the enclosing element is a compilation unit.
310 /// With the exception of [ClosureClassElement] that is considered top level 310 /// With the exception of [ClosureClassElement] that is considered top level
311 /// as all other classes. 311 /// as all other classes.
312 bool get isTopLevel; 312 bool get isTopLevel;
313 bool get isAssignable; 313 bool get isAssignable;
314 bool get isNative; 314 bool get isNative;
315 bool get isJsInterop;
316
315 bool get isDeferredLoaderGetter; 317 bool get isDeferredLoaderGetter;
316 318
317 /// True if the element is declared in a patch library but has no 319 /// True if the element is declared in a patch library but has no
318 /// corresponding declaration in the origin library. 320 /// corresponding declaration in the origin library.
319 bool get isInjected; 321 bool get isInjected;
320 322
321 /// `true` if this element is a constructor, top level or local variable, 323 /// `true` if this element is a constructor, top level or local variable,
322 /// or static field that is declared `const`. 324 /// or static field that is declared `const`.
323 bool get isConst; 325 bool get isConst;
324 326
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 /// 403 ///
402 /// See [:patch_parser.dart:] for a description of the terminology. 404 /// See [:patch_parser.dart:] for a description of the terminology.
403 Element get origin; 405 Element get origin;
404 406
405 bool get isSynthesized; 407 bool get isSynthesized;
406 bool get isMixinApplication; 408 bool get isMixinApplication;
407 409
408 bool get hasFixedBackendName; 410 bool get hasFixedBackendName;
409 String get fixedBackendName; 411 String get fixedBackendName;
410 412
413 String get jsInteropName;
414
411 bool get isAbstract; 415 bool get isAbstract;
412 416
413 Scope buildScope(); 417 Scope buildScope();
414 418
415 // TODO(johnniwinther): Move this to [AstElement]. 419 // TODO(johnniwinther): Move this to [AstElement].
416 /// Returns the [Element] that holds the [TreeElements] for this element. 420 /// Returns the [Element] that holds the [TreeElements] for this element.
417 AnalyzableElement get analyzableElement; 421 AnalyzableElement get analyzableElement;
418 422
419 accept(ElementVisitor visitor, arg); 423 accept(ElementVisitor visitor, arg);
424
425 void setJsInteropName(String name);
426 void markAsJsInterop();
420 } 427 }
421 428
422 class Elements { 429 class Elements {
423 static bool isUnresolved(Element e) { 430 static bool isUnresolved(Element e) {
424 return e == null || e.isErroneous; 431 return e == null || e.isErroneous;
425 } 432 }
426 static bool isErroneous(Element e) => e != null && e.isErroneous; 433 static bool isErroneous(Element e) => e != null && e.isErroneous;
427 434
428 /// Unwraps [element] reporting any warnings attached to it, if any. 435 /// Unwraps [element] reporting any warnings attached to it, if any.
429 static Element unwrap(Element element, 436 static Element unwrap(Element element,
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 // it specially. 521 // it specially.
515 if (element.isGenerativeConstructorBody) return true; 522 if (element.isGenerativeConstructorBody) return true;
516 return !Elements.isUnresolved(element) && 523 return !Elements.isUnresolved(element) &&
517 !element.isAbstract && 524 !element.isAbstract &&
518 element.isInstanceMember && 525 element.isInstanceMember &&
519 (element.isFunction || element.isAccessor); 526 (element.isFunction || element.isAccessor);
520 } 527 }
521 528
522 static bool isNativeOrExtendsNative(ClassElement element) { 529 static bool isNativeOrExtendsNative(ClassElement element) {
523 if (element == null) return false; 530 if (element == null) return false;
524 if (element.isNative) return true; 531 if (element.isNative || element.isJsInterop) return true;
525 assert(element.isResolved); 532 assert(element.isResolved);
526 return isNativeOrExtendsNative(element.superclass); 533 return isNativeOrExtendsNative(element.superclass);
527 } 534 }
528 535
529 static bool isInstanceSend(Send send, TreeElements elements) { 536 static bool isInstanceSend(Send send, TreeElements elements) {
530 Element element = elements[send]; 537 Element element = elements[send];
531 if (element == null) return !isClosureSend(send, element); 538 if (element == null) return !isClosureSend(send, element);
532 return isInstanceMethod(element) || 539 return isInstanceMethod(element) ||
533 isInstanceField(element) || 540 isInstanceField(element) ||
534 (send.isConditional && !element.isStatic); 541 (send.isConditional && !element.isStatic);
(...skipping 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1708 bool get isDeclaredByField; 1715 bool get isDeclaredByField;
1709 1716
1710 /// Returns `true` if this member is abstract. 1717 /// Returns `true` if this member is abstract.
1711 bool get isAbstract; 1718 bool get isAbstract;
1712 1719
1713 /// If abstract, [implementation] points to the overridden concrete member, 1720 /// If abstract, [implementation] points to the overridden concrete member,
1714 /// if any. Otherwise [implementation] points to the member itself. 1721 /// if any. Otherwise [implementation] points to the member itself.
1715 Member get implementation; 1722 Member get implementation;
1716 } 1723 }
1717 1724
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698