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

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

Issue 177963002: Use List instead of Link in the type system. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase and some algorithmic bugs fixed. Created 6 years, 9 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 part of dart2js; 5 part of dart2js;
6 6
7 /** 7 /**
8 * The [ConstantHandler] keeps track of compile-time constants, 8 * The [ConstantHandler] keeps track of compile-time constants,
9 * initializations of global and static fields, and default values of 9 * initializations of global and static fields, and default values of
10 * optional parameters. 10 * optional parameters.
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 } 324 }
325 } 325 }
326 326
327 bool hasProtoKey = (protoValue != null); 327 bool hasProtoKey = (protoValue != null);
328 List<Constant> values = map.values.toList(); 328 List<Constant> values = map.values.toList();
329 InterfaceType sourceType = elements.getType(node); 329 InterfaceType sourceType = elements.getType(node);
330 DartType keysType; 330 DartType keysType;
331 if (sourceType.treatAsRaw) { 331 if (sourceType.treatAsRaw) {
332 keysType = compiler.listClass.rawType; 332 keysType = compiler.listClass.rawType;
333 } else { 333 } else {
334 Link<DartType> arguments = 334 List<DartType> arguments = <DartType>[sourceType.typeArguments.first];
335 new Link<DartType>.fromList([sourceType.typeArguments.head]);
336 keysType = new InterfaceType(compiler.listClass, arguments); 335 keysType = new InterfaceType(compiler.listClass, arguments);
337 } 336 }
338 ListConstant keysList = new ListConstant(keysType, keys); 337 ListConstant keysList = new ListConstant(keysType, keys);
339 String className = onlyStringKeys 338 String className = onlyStringKeys
340 ? (hasProtoKey ? MapConstant.DART_PROTO_CLASS 339 ? (hasProtoKey ? MapConstant.DART_PROTO_CLASS
341 : MapConstant.DART_STRING_CLASS) 340 : MapConstant.DART_STRING_CLASS)
342 : MapConstant.DART_GENERAL_CLASS; 341 : MapConstant.DART_GENERAL_CLASS;
343 ClassElement classElement = compiler.jsHelperLibrary.find(className); 342 ClassElement classElement = compiler.jsHelperLibrary.find(className);
344 classElement.ensureResolved(compiler); 343 classElement.ensureResolved(compiler);
345 Link<DartType> typeArgument = sourceType.typeArguments; 344 List<DartType> typeArgument = sourceType.typeArguments;
346 InterfaceType type; 345 InterfaceType type;
347 if (sourceType.treatAsRaw) { 346 if (sourceType.treatAsRaw) {
348 type = classElement.rawType; 347 type = classElement.rawType;
349 } else { 348 } else {
350 type = new InterfaceType(classElement, typeArgument); 349 type = new InterfaceType(classElement, typeArgument);
351 } 350 }
352 return new MapConstant(type, keysList, values, protoValue, onlyStringKeys); 351 return new MapConstant(type, keysList, values, protoValue, onlyStringKeys);
353 } 352 }
354 353
355 Constant visitLiteralNull(LiteralNull node) { 354 Constant visitLiteralNull(LiteralNull node) {
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 if (fieldValue == null) { 1001 if (fieldValue == null) {
1003 // Use the default value. 1002 // Use the default value.
1004 fieldValue = handler.compileConstant(field); 1003 fieldValue = handler.compileConstant(field);
1005 } 1004 }
1006 jsNewArguments.add(fieldValue); 1005 jsNewArguments.add(fieldValue);
1007 }, 1006 },
1008 includeSuperAndInjectedMembers: true); 1007 includeSuperAndInjectedMembers: true);
1009 return jsNewArguments; 1008 return jsNewArguments;
1010 } 1009 }
1011 } 1010 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698