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

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

Issue 24952003: Change TypeMask.base to be a ClassElement. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Moar declaration. Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/inferrer/simple_types_inferrer.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 inferrer_visitor; 5 library inferrer_visitor;
6 6
7 import '../dart2jslib.dart' hide Selector, TypedSelector; 7 import '../dart2jslib.dart' hide Selector, TypedSelector;
8 import '../dart_types.dart'; 8 import '../dart_types.dart';
9 import '../elements/elements.dart'; 9 import '../elements/elements.dart';
10 import '../tree/tree.dart'; 10 import '../tree/tree.dart';
(...skipping 13 matching lines...) Expand all
24 T get functionType; 24 T get functionType;
25 T get listType; 25 T get listType;
26 T get constListType; 26 T get constListType;
27 T get fixedListType; 27 T get fixedListType;
28 T get growableListType; 28 T get growableListType;
29 T get mapType; 29 T get mapType;
30 T get constMapType; 30 T get constMapType;
31 T get stringType; 31 T get stringType;
32 T get typeType; 32 T get typeType;
33 33
34 T nonNullSubtype(DartType type); 34 T nonNullSubtype(ClassElement type);
35 T nonNullSubclass(DartType type); 35 T nonNullSubclass(ClassElement type);
36 T nonNullExact(DartType type); 36 T nonNullExact(ClassElement type);
37 T nonNullEmpty(); 37 T nonNullEmpty();
38 Selector newTypedSelector(T receiver, Selector selector); 38 Selector newTypedSelector(T receiver, Selector selector);
39 39
40 T allocateContainer(T type, 40 T allocateContainer(T type,
41 Node node, 41 Node node,
42 Element enclosing, 42 Element enclosing,
43 [T elementType, int length]); 43 [T elementType, int length]);
44 44
45 /** 45 /**
46 * Returns the least upper bound between [firstType] and 46 * Returns the least upper bound between [firstType] and
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 } 673 }
674 674
675 T visitLiteralNull(LiteralNull node) { 675 T visitLiteralNull(LiteralNull node) {
676 return types.nullType; 676 return types.nullType;
677 } 677 }
678 678
679 T visitLiteralSymbol(LiteralSymbol node) { 679 T visitLiteralSymbol(LiteralSymbol node) {
680 // TODO(kasperl): We should be able to tell that the type of a literal 680 // TODO(kasperl): We should be able to tell that the type of a literal
681 // symbol is always a non-null exact symbol implementation -- not just 681 // symbol is always a non-null exact symbol implementation -- not just
682 // any non-null subtype of the symbol interface. 682 // any non-null subtype of the symbol interface.
683 return types.nonNullSubtype(compiler.symbolClass.rawType); 683 return types.nonNullSubtype(compiler.symbolClass);
684 } 684 }
685 685
686 T visitTypeReferenceSend(Send node) { 686 T visitTypeReferenceSend(Send node) {
687 // If [node] is not a type literal is the class name of a static access, 687 // If [node] is not a type literal is the class name of a static access,
688 // in which case we don't use the type mask. 688 // in which case we don't use the type mask.
689 return elements.isTypeLiteral(node) ? types.typeType : null; 689 return elements.isTypeLiteral(node) ? types.typeType : null;
690 } 690 }
691 691
692 bool isThisOrSuper(Node node) => node.isThis() || node.isSuper(); 692 bool isThisOrSuper(Node node) => node.isThis() || node.isSuper();
693 693
694 Element get outermostElement { 694 Element get outermostElement {
695 return 695 return
696 analyzedElement.getOutermostEnclosingMemberOrTopLevel().implementation; 696 analyzedElement.getOutermostEnclosingMemberOrTopLevel().implementation;
697 } 697 }
698 698
699 T _thisType; 699 T _thisType;
700 T get thisType { 700 T get thisType {
701 if (_thisType != null) return _thisType; 701 if (_thisType != null) return _thisType;
702 ClassElement cls = outermostElement.getEnclosingClass(); 702 ClassElement cls = outermostElement.getEnclosingClass();
703 if (compiler.world.isUsedAsMixin(cls)) { 703 if (compiler.world.isUsedAsMixin(cls)) {
704 return _thisType = types.nonNullSubtype(cls.rawType); 704 return _thisType = types.nonNullSubtype(cls);
705 } else if (compiler.world.hasAnySubclass(cls)) { 705 } else if (compiler.world.hasAnySubclass(cls)) {
706 return _thisType = types.nonNullSubclass(cls.rawType); 706 return _thisType = types.nonNullSubclass(cls);
707 } else { 707 } else {
708 return _thisType = types.nonNullExact(cls.rawType); 708 return _thisType = types.nonNullExact(cls);
709 } 709 }
710 } 710 }
711 711
712 T _superType; 712 T _superType;
713 T get superType { 713 T get superType {
714 if (_superType != null) return _superType; 714 if (_superType != null) return _superType;
715 return _superType = types.nonNullExact( 715 return _superType = types.nonNullExact(
716 outermostElement.getEnclosingClass().superclass.rawType); 716 outermostElement.getEnclosingClass().superclass);
717 } 717 }
718 718
719 T visitIdentifier(Identifier node) { 719 T visitIdentifier(Identifier node) {
720 if (node.isThis()) { 720 if (node.isThis()) {
721 return thisType; 721 return thisType;
722 } else if (node.isSuper()) { 722 } else if (node.isSuper()) {
723 return superType; 723 return superType;
724 } 724 }
725 } 725 }
726 726
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 locals.seenReturnOrThrow = true; 972 locals.seenReturnOrThrow = true;
973 return types.nonNullEmpty(); 973 return types.nonNullEmpty();
974 } 974 }
975 975
976 T visitCatchBlock(CatchBlock node) { 976 T visitCatchBlock(CatchBlock node) {
977 Node exception = node.exception; 977 Node exception = node.exception;
978 if (exception != null) { 978 if (exception != null) {
979 DartType type = elements.getType(node.type); 979 DartType type = elements.getType(node.type);
980 T mask = type == null || type.treatAsDynamic 980 T mask = type == null || type.treatAsDynamic
981 ? types.dynamicType 981 ? types.dynamicType
982 : types.nonNullSubtype(type.asRaw()); 982 : types.nonNullSubtype(type.element);
983 locals.update(elements[exception], mask, node); 983 locals.update(elements[exception], mask, node);
984 } 984 }
985 Node trace = node.trace; 985 Node trace = node.trace;
986 if (trace != null) { 986 if (trace != null) {
987 locals.update(elements[trace], types.dynamicType, node); 987 locals.update(elements[trace], types.dynamicType, node);
988 } 988 }
989 visit(node.block); 989 visit(node.block);
990 } 990 }
991 991
992 T visitParenthesizedExpression(ParenthesizedExpression node) { 992 T visitParenthesizedExpression(ParenthesizedExpression node) {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1104 return type; 1104 return type;
1105 } 1105 }
1106 1106
1107 T visitCascade(Cascade node) { 1107 T visitCascade(Cascade node) {
1108 // Ignore the result of the cascade send and return the type of the cascade 1108 // Ignore the result of the cascade send and return the type of the cascade
1109 // receiver. 1109 // receiver.
1110 visit(node.expression); 1110 visit(node.expression);
1111 return cascadeReceiverStack.removeLast(); 1111 return cascadeReceiverStack.removeLast();
1112 } 1112 }
1113 } 1113 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/inferrer/simple_types_inferrer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698