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

Side by Side Diff: pkg/compiler/lib/src/serialization/element_serialization.dart

Issue 1919143002: Store constant variable initializers in elements. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 4 years, 7 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 dart2js.serialization.elements; 5 library dart2js.serialization.elements;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../constants/constructors.dart'; 8 import '../constants/constructors.dart';
9 import '../constants/expressions.dart'; 9 import '../constants/expressions.dart';
10 import '../dart_types.dart'; 10 import '../dart_types.dart';
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 return null; 391 return null;
392 } 392 }
393 393
394 void serialize( 394 void serialize(
395 FieldElement element, ObjectEncoder encoder, SerializedElementKind kind) { 395 FieldElement element, ObjectEncoder encoder, SerializedElementKind kind) {
396 encoder.setString(Key.NAME, element.name); 396 encoder.setString(Key.NAME, element.name);
397 SerializerUtil.serializePosition(element, encoder); 397 SerializerUtil.serializePosition(element, encoder);
398 encoder.setType(Key.TYPE, element.type); 398 encoder.setType(Key.TYPE, element.type);
399 encoder.setBool(Key.IS_FINAL, element.isFinal); 399 encoder.setBool(Key.IS_FINAL, element.isFinal);
400 encoder.setBool(Key.IS_CONST, element.isConst); 400 encoder.setBool(Key.IS_CONST, element.isConst);
401 if (element.isConst) { 401 ConstantExpression constant = element.constant;
402 ConstantExpression constant = element.constant; 402 if (constant != null) {
403 encoder.setConstant(Key.CONSTANT, constant); 403 encoder.setConstant(Key.CONSTANT, constant);
404 } 404 }
405 SerializerUtil.serializeParentRelation(element, encoder); 405 SerializerUtil.serializeParentRelation(element, encoder);
406 if (element is EnumConstantElement) { 406 if (element is EnumConstantElement) {
407 EnumConstantElement enumConstant = element; 407 EnumConstantElement enumConstant = element;
408 encoder.setInt(Key.INDEX, enumConstant.index); 408 encoder.setInt(Key.INDEX, enumConstant.index);
409 } 409 }
410 } 410 }
411 } 411 }
412 412
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 return new LocalVariableElementZ(decoder); 701 return new LocalVariableElementZ(decoder);
702 case SerializedElementKind.EXTERNAL_LIBRARY: 702 case SerializedElementKind.EXTERNAL_LIBRARY:
703 case SerializedElementKind.EXTERNAL_LIBRARY_MEMBER: 703 case SerializedElementKind.EXTERNAL_LIBRARY_MEMBER:
704 case SerializedElementKind.EXTERNAL_STATIC_MEMBER: 704 case SerializedElementKind.EXTERNAL_STATIC_MEMBER:
705 case SerializedElementKind.EXTERNAL_CONSTRUCTOR: 705 case SerializedElementKind.EXTERNAL_CONSTRUCTOR:
706 break; 706 break;
707 } 707 }
708 throw new UnsupportedError("Unexpected element kind '${elementKind}."); 708 throw new UnsupportedError("Unexpected element kind '${elementKind}.");
709 } 709 }
710 } 710 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/resolution/resolution.dart ('k') | pkg/compiler/lib/src/serialization/modelz.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698