OLD | NEW |
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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 case ConstantExpressionKind.IDENTICAL: | 225 case ConstantExpressionKind.IDENTICAL: |
226 return new IdenticalConstantExpression( | 226 return new IdenticalConstantExpression( |
227 decoder.getConstant(Key.LEFT), decoder.getConstant(Key.RIGHT)); | 227 decoder.getConstant(Key.LEFT), decoder.getConstant(Key.RIGHT)); |
228 case ConstantExpressionKind.INT: | 228 case ConstantExpressionKind.INT: |
229 return new IntConstantExpression(decoder.getInt(Key.VALUE)); | 229 return new IntConstantExpression(decoder.getInt(Key.VALUE)); |
230 case ConstantExpressionKind.INT_FROM_ENVIRONMENT: | 230 case ConstantExpressionKind.INT_FROM_ENVIRONMENT: |
231 return new IntFromEnvironmentConstantExpression( | 231 return new IntFromEnvironmentConstantExpression( |
232 decoder.getConstant(Key.NAME), | 232 decoder.getConstant(Key.NAME), |
233 decoder.getConstant(Key.DEFAULT, isOptional: true)); | 233 decoder.getConstant(Key.DEFAULT, isOptional: true)); |
234 case ConstantExpressionKind.LIST: | 234 case ConstantExpressionKind.LIST: |
235 return new ListConstantExpression( | 235 return new ListConstantExpression(decoder.getType(Key.TYPE), |
236 decoder.getType(Key.TYPE), decoder.getConstants(Key.VALUES)); | 236 decoder.getConstants(Key.VALUES, isOptional: true)); |
237 case ConstantExpressionKind.MAP: | 237 case ConstantExpressionKind.MAP: |
238 return new MapConstantExpression(decoder.getType(Key.TYPE), | 238 return new MapConstantExpression( |
239 decoder.getConstants(Key.KEYS), decoder.getConstants(Key.VALUES)); | 239 decoder.getType(Key.TYPE), |
| 240 decoder.getConstants(Key.KEYS, isOptional: true), |
| 241 decoder.getConstants(Key.VALUES, isOptional: true)); |
240 case ConstantExpressionKind.NULL: | 242 case ConstantExpressionKind.NULL: |
241 return new NullConstantExpression(); | 243 return new NullConstantExpression(); |
242 case ConstantExpressionKind.STRING: | 244 case ConstantExpressionKind.STRING: |
243 return new StringConstantExpression(decoder.getString(Key.VALUE)); | 245 return new StringConstantExpression(decoder.getString(Key.VALUE)); |
244 case ConstantExpressionKind.STRING_FROM_ENVIRONMENT: | 246 case ConstantExpressionKind.STRING_FROM_ENVIRONMENT: |
245 return new StringFromEnvironmentConstantExpression( | 247 return new StringFromEnvironmentConstantExpression( |
246 decoder.getConstant(Key.NAME), | 248 decoder.getConstant(Key.NAME), |
247 decoder.getConstant(Key.DEFAULT, isOptional: true)); | 249 decoder.getConstant(Key.DEFAULT, isOptional: true)); |
248 case ConstantExpressionKind.STRING_LENGTH: | 250 case ConstantExpressionKind.STRING_LENGTH: |
249 return new StringLengthConstantExpression( | 251 return new StringLengthConstantExpression( |
250 decoder.getConstant(Key.EXPRESSION)); | 252 decoder.getConstant(Key.EXPRESSION)); |
251 case ConstantExpressionKind.SYMBOL: | 253 case ConstantExpressionKind.SYMBOL: |
252 break; | 254 return new SymbolConstantExpression(decoder.getString(Key.NAME)); |
253 case ConstantExpressionKind.TYPE: | 255 case ConstantExpressionKind.TYPE: |
254 return new TypeConstantExpression(decoder.getType(Key.TYPE)); | 256 return new TypeConstantExpression(decoder.getType(Key.TYPE)); |
255 case ConstantExpressionKind.UNARY: | 257 case ConstantExpressionKind.UNARY: |
256 UnaryOperator operator = UnaryOperator | 258 UnaryOperator operator = UnaryOperator |
257 .fromKind(decoder.getEnum(Key.OPERATOR, UnaryOperatorKind.values)); | 259 .fromKind(decoder.getEnum(Key.OPERATOR, UnaryOperatorKind.values)); |
258 return new UnaryConstantExpression( | 260 return new UnaryConstantExpression( |
259 operator, decoder.getConstant(Key.EXPRESSION)); | 261 operator, decoder.getConstant(Key.EXPRESSION)); |
260 case ConstantExpressionKind.VARIABLE: | 262 case ConstantExpressionKind.VARIABLE: |
261 return new VariableConstantExpression(decoder.getElement(Key.ELEMENT)); | 263 return new VariableConstantExpression(decoder.getElement(Key.ELEMENT)); |
262 | 264 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 readFields(), readConstructorInvocation()); | 390 readFields(), readConstructorInvocation()); |
389 case ConstantConstructorKind.REDIRECTING_GENERATIVE: | 391 case ConstantConstructorKind.REDIRECTING_GENERATIVE: |
390 return new RedirectingGenerativeConstantConstructor( | 392 return new RedirectingGenerativeConstantConstructor( |
391 readDefaults(), readConstructorInvocation()); | 393 readDefaults(), readConstructorInvocation()); |
392 case ConstantConstructorKind.REDIRECTING_FACTORY: | 394 case ConstantConstructorKind.REDIRECTING_FACTORY: |
393 return new RedirectingFactoryConstantConstructor( | 395 return new RedirectingFactoryConstantConstructor( |
394 readConstructorInvocation()); | 396 readConstructorInvocation()); |
395 } | 397 } |
396 } | 398 } |
397 } | 399 } |
OLD | NEW |