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

Side by Side Diff: frog/type.dart

Issue 9107067: Work in progress: changes to interpretation (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: work in progress Created 8 years, 11 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 | « frog/member.dart ('k') | frog/utils.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
None
OLDNEW
1 // Copyright (c) 2011, 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 class Type extends Element { 5 class Type extends Element {
6 bool isTested = false; 6 bool isTested = false;
7 bool isChecked = false; 7 bool isChecked = false;
8 bool isWritten = false; 8 bool isWritten = false;
9 9
10 /** 10 /**
11 * For core types (int, String, etc) this is the generated type assertion 11 * For core types (int, String, etc) this is the generated type assertion
12 * function (uses JS "typeof"). This field is null for all other types. 12 * function (uses JS "typeof"). This field is null for all other types.
13 */ 13 */
14 String typeCheckCode; 14 String typeCheckCode;
15 15
16 Member _typeMember; 16 Member _typeMember;
17 17
18 /** Stubs used to call into this method dynamically. */ 18 /** Stubs used to call into this method dynamically. */
19 Map<String, VarMember> varStubs; 19 Map<String, VarMember> varStubs;
20 20
21 /** Cache of [Member]s that have been found. */ 21 /** Cache of [Member]s that have been found. */
22 Map<String, Member> _foundMembers; 22 Map<String, Member> _foundMembers;
23 23
24 Type(String name): _foundMembers = {}, varStubs = {}, super(name, null); 24 Type(String name): _foundMembers = {}, varStubs = {}, super(name, null);
25 25
26 void markUsed() {} 26 void markUsed() {}
27 abstract void genMethod(Member method); 27 abstract void markUsedMethod(Member method);
28 28
29 TypeMember get typeMember() { 29 TypeMember get typeMember() {
30 if (_typeMember == null) { 30 if (_typeMember == null) {
31 _typeMember = new TypeMember(this); 31 _typeMember = new TypeMember(this);
32 } 32 }
33 return _typeMember; 33 return _typeMember;
34 } 34 }
35 35
36 abstract Type resolveTypeParams(ConcreteType inType); 36 abstract Type resolveTypeParams(ConcreteType inType);
37 37
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 assert(isObject); 164 assert(isObject);
165 // Add a != method just like the == one. 165 // Add a != method just like the == one.
166 MethodMember eq = members[':eq']; 166 MethodMember eq = members[':eq'];
167 if (eq == null) { 167 if (eq == null) {
168 // TODO(jmesserly): should this be an error? 168 // TODO(jmesserly): should this be an error?
169 // Frog is being hosted by "utils/css" such that it doesn't have its 169 // Frog is being hosted by "utils/css" such that it doesn't have its
170 // standard lib initialized properly. 170 // standard lib initialized properly.
171 return; 171 return;
172 } 172 }
173 final ne = new MethodMember(':ne', this, eq.definition); 173 final ne = new MethodMember(':ne', this, eq.definition);
174 ne.isGenerated = true;
175 ne.returnType = eq.returnType; 174 ne.returnType = eq.returnType;
176 ne.parameters = eq.parameters; 175 ne.parameters = eq.parameters;
177 ne.isStatic = eq.isStatic; 176 ne.isStatic = eq.isStatic;
178 ne.isAbstract = eq.isAbstract; 177 ne.isAbstract = eq.isAbstract;
179 // TODO - What else to fill in? 178 // TODO - What else to fill in?
180 members[':ne'] = ne; 179 members[':ne'] = ne;
181 } 180 }
182 181
183 Member _getMemberInParents(String memberName) { 182 Member _getMemberInParents(String memberName) {
184 // print('getting $memberName in parents of $name, $isClass'); 183 // print('getting $memberName in parents of $name, $isClass');
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 // similar enough, which is probably true quite often in practice. 232 // similar enough, which is probably true quite often in practice.
234 if (args.length != call.parameters.length || !call.namesInOrder(args)) { 233 if (args.length != call.parameters.length || !call.namesInOrder(args)) {
235 return true; 234 return true;
236 } 235 }
237 } 236 }
238 237
239 // Use a normal JS call, or not a function type. 238 // Use a normal JS call, or not a function type.
240 return false; 239 return false;
241 } 240 }
242 241
242 // TODO(jmesserly): does this function stick around once we have UnionValue?
243 static Type union(Type x, Type y) { 243 static Type union(Type x, Type y) {
244 if (x == y) return x; 244 if (x == y) return x;
245
245 if (x.isNum && y.isNum) return world.numType; 246 if (x.isNum && y.isNum) return world.numType;
246 if (x.isString && y.isString) return world.stringType; 247 if (x.isString && y.isString) return world.stringType;
247 248
248 // TODO(jmesserly): make this more precise when we can. Or add UnionValue 249 // TODO(jmesserly): make this more precise when we can. Or add UnionValue
249 // and have Value do the heavy lifting of tracking sets of types. 250 // and have Value do the heavy lifting of tracking sets of types.
250 return world.varType; 251 return world.varType;
251 } 252 }
252 253
253 // This is from the "Interface Types" section of the language spec: 254 // This is from the "Interface Types" section of the language spec:
254 255
(...skipping 12 matching lines...) Expand all
267 * if I is listed in the extends clause of J. 268 * if I is listed in the extends clause of J.
268 */ 269 */
269 bool _isDirectSupertypeOf(Type other) { 270 bool _isDirectSupertypeOf(Type other) {
270 if (other.isClass) { 271 if (other.isClass) {
271 return other.parent == this || isObject && other.parent == null; 272 return other.parent == this || isObject && other.parent == null;
272 } else { 273 } else {
273 if (other.interfaces == null || other.interfaces.isEmpty()) { 274 if (other.interfaces == null || other.interfaces.isEmpty()) {
274 return isObject; 275 return isObject;
275 } else { 276 } else {
276 return other.interfaces.some((i) => i == this); 277 return other.interfaces.some((i) => i == this);

error: old chunk mismatch

OLDNEW
« no previous file with comments | « frog/member.dart ('k') | frog/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698