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

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

Issue 13467021: Register type for literal list/map. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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) 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 elements.modelx; 5 library elements.modelx;
6 6
7 import 'dart:uri'; 7 import 'dart:uri';
8 import 'dart:collection' show LinkedHashMap; 8 import 'dart:collection' show LinkedHashMap;
9 9
10 import 'elements.dart'; 10 import 'elements.dart';
(...skipping 1346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1357 * The [rawType] field is a canonicalization of the raw type and should be 1357 * The [rawType] field is a canonicalization of the raw type and should be
1358 * used to distinguish explicit and implicit uses of the [dynamic] 1358 * used to distinguish explicit and implicit uses of the [dynamic]
1359 * type arguments. For instance should [:List:] be the [rawType] of the 1359 * type arguments. For instance should [:List:] be the [rawType] of the
1360 * [:List:] class element whereas [:List<dynamic>:] should be its own 1360 * [:List:] class element whereas [:List<dynamic>:] should be its own
1361 * instantiation of [InterfaceType] with [:dynamic:] as type argument. Using 1361 * instantiation of [InterfaceType] with [:dynamic:] as type argument. Using
1362 * this distinction, we can print the raw type with type arguments only when 1362 * this distinction, we can print the raw type with type arguments only when
1363 * the input source has used explicit type arguments. 1363 * the input source has used explicit type arguments.
1364 * 1364 *
1365 * This type is computed together with [thisType] in [computeType]. 1365 * This type is computed together with [thisType] in [computeType].
1366 */ 1366 */
1367 InterfaceType rawType; 1367 InterfaceType rawTypeCache;
1368 DartType supertype; 1368 DartType supertype;
1369 DartType defaultClass; 1369 DartType defaultClass;
1370 Link<DartType> interfaces; 1370 Link<DartType> interfaces;
1371 SourceString nativeTagInfo; 1371 SourceString nativeTagInfo;
1372 int supertypeLoadState; 1372 int supertypeLoadState;
1373 int resolutionState; 1373 int resolutionState;
1374 1374
1375 // backendMembers are members that have been added by the backend to simplify 1375 // backendMembers are members that have been added by the backend to simplify
1376 // compilation. They don't have any user-side counter-part. 1376 // compilation. They don't have any user-side counter-part.
1377 Link<Element> backendMembers = const Link<Element>(); 1377 Link<Element> backendMembers = const Link<Element>();
(...skipping 15 matching lines...) Expand all
1393 ClassElement get implementation => super.implementation; 1393 ClassElement get implementation => super.implementation;
1394 1394
1395 bool get hasBackendMembers => !backendMembers.isEmpty; 1395 bool get hasBackendMembers => !backendMembers.isEmpty;
1396 1396
1397 InterfaceType computeType(Compiler compiler) { 1397 InterfaceType computeType(Compiler compiler) {
1398 if (thisType == null) { 1398 if (thisType == null) {
1399 if (origin == null) { 1399 if (origin == null) {
1400 Link<DartType> parameters = computeTypeParameters(compiler); 1400 Link<DartType> parameters = computeTypeParameters(compiler);
1401 thisType = new InterfaceType(this, parameters); 1401 thisType = new InterfaceType(this, parameters);
1402 if (parameters.isEmpty) { 1402 if (parameters.isEmpty) {
1403 rawType = thisType; 1403 rawTypeCache = thisType;
1404 } else { 1404 } else {
1405 var dynamicParameters = const Link<DartType>(); 1405 var dynamicParameters = const Link<DartType>();
1406 parameters.forEach((_) { 1406 parameters.forEach((_) {
1407 dynamicParameters = 1407 dynamicParameters =
1408 dynamicParameters.prepend(compiler.types.dynamicType); 1408 dynamicParameters.prepend(compiler.types.dynamicType);
1409 }); 1409 });
1410 rawType = new InterfaceType(this, dynamicParameters); 1410 rawTypeCache = new InterfaceType(this, dynamicParameters);
1411 } 1411 }
1412 } else { 1412 } else {
1413 thisType = origin.computeType(compiler); 1413 thisType = origin.computeType(compiler);
1414 rawType = origin.rawType; 1414 rawTypeCache = origin.rawType;
1415 } 1415 }
1416 } 1416 }
1417 return thisType; 1417 return thisType;
1418 } 1418 }
1419 1419
1420 InterfaceType get rawType {
1421 assert(invariant(this, rawTypeCache != null,
1422 message: 'Raw type has not been computed for $this'));
1423 return rawTypeCache;
1424 }
1425
1420 Link<DartType> computeTypeParameters(Compiler compiler); 1426 Link<DartType> computeTypeParameters(Compiler compiler);
1421 1427
1422 /** 1428 /**
1423 * Return [:true:] if this element is the [:Object:] class for the [compiler]. 1429 * Return [:true:] if this element is the [:Object:] class for the [compiler].
1424 */ 1430 */
1425 bool isObject(Compiler compiler) => 1431 bool isObject(Compiler compiler) =>
1426 identical(declaration, compiler.objectClass); 1432 identical(declaration, compiler.objectClass);
1427 1433
1428 Link<DartType> get typeVariables => thisType.typeArguments; 1434 Link<DartType> get typeVariables => thisType.typeArguments;
1429 1435
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
2019 2025
2020 MetadataAnnotation ensureResolved(Compiler compiler) { 2026 MetadataAnnotation ensureResolved(Compiler compiler) {
2021 if (resolutionState == STATE_NOT_STARTED) { 2027 if (resolutionState == STATE_NOT_STARTED) {
2022 compiler.resolver.resolveMetadataAnnotation(this); 2028 compiler.resolver.resolveMetadataAnnotation(this);
2023 } 2029 }
2024 return this; 2030 return this;
2025 } 2031 }
2026 2032
2027 String toString() => 'MetadataAnnotation($value, $resolutionState)'; 2033 String toString() => 'MetadataAnnotation($value, $resolutionState)';
2028 } 2034 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698