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

Side by Side Diff: pkg/compiler/lib/src/serialization/modelz.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 /// Implementation of the element model used for deserialiation. 5 /// Implementation of the element model used for deserialiation.
6 /// 6 ///
7 /// These classes are created by [ElementDeserializer] triggered by the 7 /// These classes are created by [ElementDeserializer] triggered by the
8 /// [Deserializer]. 8 /// [Deserializer].
9 9
10 library dart2js.serialization.modelz; 10 library dart2js.serialization.modelz;
(...skipping 1253 matching lines...) Expand 10 before | Expand all | Expand 10 after
1264 List<FunctionElement> get nestedClosures => const <FunctionElement>[]; 1264 List<FunctionElement> get nestedClosures => const <FunctionElement>[];
1265 } 1265 }
1266 1266
1267 abstract class FieldElementZ extends DeserializedElementZ 1267 abstract class FieldElementZ extends DeserializedElementZ
1268 with 1268 with
1269 AnalyzableElementMixin, 1269 AnalyzableElementMixin,
1270 AstElementMixin, 1270 AstElementMixin,
1271 TypedElementMixin, 1271 TypedElementMixin,
1272 MemberElementMixin 1272 MemberElementMixin
1273 implements FieldElement { 1273 implements FieldElement {
1274 bool _isConst;
1274 ConstantExpression _constant; 1275 ConstantExpression _constant;
1275 1276
1276 FieldElementZ(ObjectDecoder decoder) : super(decoder); 1277 FieldElementZ(ObjectDecoder decoder) : super(decoder);
1277 1278
1278 @override 1279 @override
1279 ElementKind get kind => ElementKind.FIELD; 1280 ElementKind get kind => ElementKind.FIELD;
1280 1281
1281 @override 1282 @override
1282 accept(ElementVisitor visitor, arg) { 1283 accept(ElementVisitor visitor, arg) {
1283 return visitor.visitFieldElement(this, arg); 1284 return visitor.visitFieldElement(this, arg);
1284 } 1285 }
1285 1286
1286 @override 1287 @override
1287 bool get isFinal => _decoder.getBool(Key.IS_FINAL); 1288 bool get isFinal => _decoder.getBool(Key.IS_FINAL);
1288 1289
1290 void _ensureConstant() {
1291 if (_isConst == null) {
1292 _isConst = _decoder.getBool(Key.IS_CONST);
1293 _constant = _decoder.getConstant(Key.CONSTANT, isOptional: true);
1294 }
1295 }
1296
1289 @override 1297 @override
1290 bool get isConst => _decoder.getBool(Key.IS_CONST); 1298 bool get isConst {
1299 _ensureConstant();
1300 return _isConst;
1301 }
1291 1302
1292 @override 1303 @override
1293 ConstantExpression get constant { 1304 ConstantExpression get constant {
1294 if (isConst && _constant == null) { 1305 _ensureConstant();
1295 _constant = _decoder.getConstant(Key.CONSTANT);
1296 }
1297 return _constant; 1306 return _constant;
1298 } 1307 }
1299 1308
1300 @override 1309 @override
1301 Expression get initializer => _unsupported('initializer'); 1310 Expression get initializer => _unsupported('initializer');
1302 } 1311 }
1303 1312
1304 class TopLevelFieldElementZ extends FieldElementZ with LibraryMemberMixin { 1313 class TopLevelFieldElementZ extends FieldElementZ with LibraryMemberMixin {
1305 TopLevelFieldElementZ(ObjectDecoder decoder) : super(decoder); 1314 TopLevelFieldElementZ(ObjectDecoder decoder) : super(decoder);
1306 } 1315 }
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
1989 } 1998 }
1990 1999
1991 @override 2000 @override
1992 ElementKind get kind => ElementKind.PREFIX; 2001 ElementKind get kind => ElementKind.PREFIX;
1993 2002
1994 @override 2003 @override
1995 Element lookupLocalMember(String memberName) { 2004 Element lookupLocalMember(String memberName) {
1996 return _unsupported('lookupLocalMember'); 2005 return _unsupported('lookupLocalMember');
1997 } 2006 }
1998 } 2007 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/serialization/element_serialization.dart ('k') | pkg/compiler/lib/src/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698