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

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

Issue 10542073: RFC: Resolution based tree-shaking. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 6 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 #import('../tree/tree.dart'); 7 #import('../tree/tree.dart');
8 #import('../scanner/scannerlib.dart'); 8 #import('../scanner/scannerlib.dart');
9 #import('../leg.dart'); // TODO(karlklose): we only need type. 9 #import('../leg.dart'); // TODO(karlklose): we only need type.
10 #import('../util/util.dart'); 10 #import('../util/util.dart');
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 } 124 }
125 bool isClass() => kind === ElementKind.CLASS; 125 bool isClass() => kind === ElementKind.CLASS;
126 bool isVariable() => kind === ElementKind.VARIABLE; 126 bool isVariable() => kind === ElementKind.VARIABLE;
127 bool isParameter() => kind === ElementKind.PARAMETER; 127 bool isParameter() => kind === ElementKind.PARAMETER;
128 bool isStatement() => kind === ElementKind.STATEMENT; 128 bool isStatement() => kind === ElementKind.STATEMENT;
129 bool isTypedef() => kind === ElementKind.TYPEDEF; 129 bool isTypedef() => kind === ElementKind.TYPEDEF;
130 bool isTypeVariable() => kind === ElementKind.TYPE_VARIABLE; 130 bool isTypeVariable() => kind === ElementKind.TYPE_VARIABLE;
131 bool isField() => kind === ElementKind.FIELD; 131 bool isField() => kind === ElementKind.FIELD;
132 bool isGetter() => kind === ElementKind.GETTER; 132 bool isGetter() => kind === ElementKind.GETTER;
133 bool isSetter() => kind === ElementKind.SETTER; 133 bool isSetter() => kind === ElementKind.SETTER;
134 bool isAccessor() => isGetter() || isSetter();
135 bool isForeign() => kind === ElementKind.FOREIGN;
134 bool impliesType() => (kind.category & ElementCategory.IMPLIES_TYPE) != 0; 136 bool impliesType() => (kind.category & ElementCategory.IMPLIES_TYPE) != 0;
135 bool isExtendable() => (kind.category & ElementCategory.IS_EXTENDABLE) != 0; 137 bool isExtendable() => (kind.category & ElementCategory.IS_EXTENDABLE) != 0;
136 138
139 bool isTopLevel() => enclosingElement.isCompilationUnit();
140
137 bool isAssignable() { 141 bool isAssignable() {
138 if (modifiers != null && modifiers.isFinal()) return false; 142 if (modifiers != null && modifiers.isFinal()) return false;
139 if (isFunction() || isGenerativeConstructor()) return false; 143 if (isFunction() || isGenerativeConstructor()) return false;
140 return true; 144 return true;
141 } 145 }
142 146
143 Token position() => null; 147 Token position() => null;
144 148
145 Token findMyName(Token token) { 149 Token findMyName(Token token) {
146 for (Token t = token; t.kind !== EOF_TOKEN; t = t.next) { 150 for (Token t = token; t.kind !== EOF_TOKEN; t = t.next) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 return null; 185 return null;
182 } 186 }
183 187
184 Element getEnclosingMember() { 188 Element getEnclosingMember() {
185 for (Element e = this; e !== null; e = e.enclosingElement) { 189 for (Element e = this; e !== null; e = e.enclosingElement) {
186 if (e.isMember()) return e; 190 if (e.isMember()) return e;
187 } 191 }
188 return null; 192 return null;
189 } 193 }
190 194
191 toString() => '$kind(${name.slowToString()})'; 195 Element getOutermostEnclosingMemberOrTopLevel() {
196 for (Element e = this; e !== null; e = e.enclosingElement) {
197 if (e.isMember() || e.isTopLevel()) {
198 return e;
199 }
200 }
201 return null;
202 }
203
204 toString() {
205 if (isMember()) {
206 String holderName = enclosingElement.name.slowToString();
207 return '$kind($holderName#${name.slowToString()})';
208 } else {
209 return '$kind(${name.slowToString()})';
210 }
211 }
192 212
193 bool _isNative = false; 213 bool _isNative = false;
194 void setNative() { _isNative = true; } 214 void setNative() { _isNative = true; }
195 bool isNative() => _isNative; 215 bool isNative() => _isNative;
196 } 216 }
197 217
198 class ContainerElement extends Element { 218 class ContainerElement extends Element {
199 ContainerElement(name, kind, enclosingElement) : 219 ContainerElement(name, kind, enclosingElement) :
200 super(name, kind, enclosingElement); 220 super(name, kind, enclosingElement);
201 221
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 final Node node; 1055 final Node node;
1036 Type bound; 1056 Type bound;
1037 Type type; 1057 Type type;
1038 TypeVariableElement(name, Element enclosing, this.node, this.type, 1058 TypeVariableElement(name, Element enclosing, this.node, this.type,
1039 [this.bound]) 1059 [this.bound])
1040 : super(name, ElementKind.TYPE_VARIABLE, enclosing); 1060 : super(name, ElementKind.TYPE_VARIABLE, enclosing);
1041 Type computeType(compiler) => type; 1061 Type computeType(compiler) => type;
1042 Node parseNode(compiler) => node; 1062 Node parseNode(compiler) => node;
1043 toString() => "${enclosingElement.toString()}.${name.slowToString()}"; 1063 toString() => "${enclosingElement.toString()}.${name.slowToString()}";
1044 } 1064 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698