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

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

Issue 2110323003: Support serialization of loadLibrary (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: dartfmt Created 4 years, 5 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.constants; 5 library dart2js.serialization.constants;
6 6
7 import '../constants/constructors.dart'; 7 import '../constants/constructors.dart';
8 import '../constants/expressions.dart'; 8 import '../constants/expressions.dart';
9 import '../dart_types.dart'; 9 import '../dart_types.dart';
10 import '../elements/elements.dart' show FieldElement; 10 import '../elements/elements.dart' show FieldElement;
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 } 162 }
163 163
164 @override 164 @override
165 void visitStringLength( 165 void visitStringLength(
166 StringLengthConstantExpression exp, ObjectEncoder encoder) { 166 StringLengthConstantExpression exp, ObjectEncoder encoder) {
167 encoder.setConstant(Key.EXPRESSION, exp.expression); 167 encoder.setConstant(Key.EXPRESSION, exp.expression);
168 } 168 }
169 169
170 @override 170 @override
171 void visitDeferred(DeferredConstantExpression exp, ObjectEncoder encoder) { 171 void visitDeferred(DeferredConstantExpression exp, ObjectEncoder encoder) {
172 throw new UnsupportedError( 172 encoder.setElement(Key.PREFIX, exp.prefix);
173 "ConstantSerializer.visitDeferred: ${exp.toDartText()}"); 173 encoder.setConstant(Key.EXPRESSION, exp.expression);
174 } 174 }
175 } 175 }
176 176
177 /// Utility class for deserializing [ConstantExpression]s. 177 /// Utility class for deserializing [ConstantExpression]s.
178 /// 178 ///
179 /// This is used by the [Deserializer]. 179 /// This is used by the [Deserializer].
180 class ConstantDeserializer { 180 class ConstantDeserializer {
181 /// Deserializes a [ConstantExpression] from an [ObjectDecoder]. 181 /// Deserializes a [ConstantExpression] from an [ObjectDecoder].
182 /// 182 ///
183 /// The class is called from the [Deserializer] when a [ConstantExpression] 183 /// The class is called from the [Deserializer] when a [ConstantExpression]
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 return new UnaryConstantExpression( 260 return new UnaryConstantExpression(
261 operator, decoder.getConstant(Key.EXPRESSION)); 261 operator, decoder.getConstant(Key.EXPRESSION));
262 case ConstantExpressionKind.VARIABLE: 262 case ConstantExpressionKind.VARIABLE:
263 return new VariableConstantExpression(decoder.getElement(Key.ELEMENT)); 263 return new VariableConstantExpression(decoder.getElement(Key.ELEMENT));
264 264
265 case ConstantExpressionKind.POSITIONAL_REFERENCE: 265 case ConstantExpressionKind.POSITIONAL_REFERENCE:
266 return new PositionalArgumentReference(decoder.getInt(Key.INDEX)); 266 return new PositionalArgumentReference(decoder.getInt(Key.INDEX));
267 case ConstantExpressionKind.NAMED_REFERENCE: 267 case ConstantExpressionKind.NAMED_REFERENCE:
268 return new NamedArgumentReference(decoder.getString(Key.NAME)); 268 return new NamedArgumentReference(decoder.getString(Key.NAME));
269 case ConstantExpressionKind.DEFERRED: 269 case ConstantExpressionKind.DEFERRED:
270 return new DeferredConstantExpression(
271 decoder.getConstant(Key.EXPRESSION),
272 decoder.getElement(Key.PREFIX));
270 case ConstantExpressionKind.SYNTHETIC: 273 case ConstantExpressionKind.SYNTHETIC:
271 } 274 }
272 throw new UnsupportedError("Unexpected constant kind: ${kind} in $decoder"); 275 throw new UnsupportedError("Unexpected constant kind: ${kind} in $decoder");
273 } 276 }
274 } 277 }
275 278
276 /// Visitor that serializes a [ConstantConstructor] by encoding it into an 279 /// Visitor that serializes a [ConstantConstructor] by encoding it into an
277 /// [ObjectEncoder]. 280 /// [ObjectEncoder].
278 /// 281 ///
279 /// This class is called from the [ConstructorSerializer] when the [Serializer] 282 /// This class is called from the [ConstructorSerializer] when the [Serializer]
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 readFields(), readConstructorInvocation()); 393 readFields(), readConstructorInvocation());
391 case ConstantConstructorKind.REDIRECTING_GENERATIVE: 394 case ConstantConstructorKind.REDIRECTING_GENERATIVE:
392 return new RedirectingGenerativeConstantConstructor( 395 return new RedirectingGenerativeConstantConstructor(
393 readDefaults(), readConstructorInvocation()); 396 readDefaults(), readConstructorInvocation());
394 case ConstantConstructorKind.REDIRECTING_FACTORY: 397 case ConstantConstructorKind.REDIRECTING_FACTORY:
395 return new RedirectingFactoryConstantConstructor( 398 return new RedirectingFactoryConstantConstructor(
396 readConstructorInvocation()); 399 readConstructorInvocation());
397 } 400 }
398 } 401 }
399 } 402 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698