| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.util; | 5 library dart2js.serialization.util; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../constants/expressions.dart'; | 8 import '../constants/expressions.dart'; |
| 9 import '../elements/resolution_types.dart'; | 9 import '../elements/resolution_types.dart'; |
| 10 import '../diagnostics/messages.dart'; | 10 import '../diagnostics/messages.dart'; |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 case SendStructureKind.DEFERRED_PREFIX: | 184 case SendStructureKind.DEFERRED_PREFIX: |
| 185 DeferredPrefixStructure structure = sendStructure; | 185 DeferredPrefixStructure structure = sendStructure; |
| 186 encoder.setElement(Key.PREFIX, structure.prefix); | 186 encoder.setElement(Key.PREFIX, structure.prefix); |
| 187 serializeSendStructure( | 187 serializeSendStructure( |
| 188 structure.sendStructure, encoder.createObject(Key.SEND_STRUCTURE)); | 188 structure.sendStructure, encoder.createObject(Key.SEND_STRUCTURE)); |
| 189 break; | 189 break; |
| 190 } | 190 } |
| 191 } | 191 } |
| 192 | 192 |
| 193 /// Deserialize a [SendStructure] from [decoder]. | 193 /// Deserialize a [SendStructure] from [decoder]. |
| 194 // ignore: MISSING_RETURN |
| 194 SendStructure deserializeSendStructure(ObjectDecoder decoder) { | 195 SendStructure deserializeSendStructure(ObjectDecoder decoder) { |
| 195 SendStructureKind kind = decoder.getEnum(Key.KIND, SendStructureKind.values); | 196 SendStructureKind kind = decoder.getEnum(Key.KIND, SendStructureKind.values); |
| 196 switch (kind) { | 197 switch (kind) { |
| 197 case SendStructureKind.IF_NULL: | 198 case SendStructureKind.IF_NULL: |
| 198 return const IfNullStructure(); | 199 return const IfNullStructure(); |
| 199 case SendStructureKind.LOGICAL_AND: | 200 case SendStructureKind.LOGICAL_AND: |
| 200 return const LogicalAndStructure(); | 201 return const LogicalAndStructure(); |
| 201 case SendStructureKind.LOGICAL_OR: | 202 case SendStructureKind.LOGICAL_OR: |
| 202 return const LogicalOrStructure(); | 203 return const LogicalOrStructure(); |
| 203 case SendStructureKind.IS: | 204 case SendStructureKind.IS: |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 encoder.setEnum(Key.SUB_KIND, structure.constantInvokeKind); | 335 encoder.setEnum(Key.SUB_KIND, structure.constantInvokeKind); |
| 335 encoder.setConstant(Key.CONSTANT, structure.constant); | 336 encoder.setConstant(Key.CONSTANT, structure.constant); |
| 336 break; | 337 break; |
| 337 case NewStructureKind.LATE_CONST: | 338 case NewStructureKind.LATE_CONST: |
| 338 throw new UnsupportedError( | 339 throw new UnsupportedError( |
| 339 'Unsupported NewStructure kind ${newStructure.kind}.'); | 340 'Unsupported NewStructure kind ${newStructure.kind}.'); |
| 340 } | 341 } |
| 341 } | 342 } |
| 342 | 343 |
| 343 /// Deserialize a [NewStructure] from [decoder]. | 344 /// Deserialize a [NewStructure] from [decoder]. |
| 345 // ignore: MISSING_RETURN |
| 344 NewStructure deserializeNewStructure(ObjectDecoder decoder) { | 346 NewStructure deserializeNewStructure(ObjectDecoder decoder) { |
| 345 NewStructureKind kind = decoder.getEnum(Key.KIND, NewStructureKind.values); | 347 NewStructureKind kind = decoder.getEnum(Key.KIND, NewStructureKind.values); |
| 346 switch (kind) { | 348 switch (kind) { |
| 347 case NewStructureKind.NEW_INVOKE: | 349 case NewStructureKind.NEW_INVOKE: |
| 348 ConstructorAccessKind constructorAccessKind = | 350 ConstructorAccessKind constructorAccessKind = |
| 349 decoder.getEnum(Key.SUB_KIND, ConstructorAccessKind.values); | 351 decoder.getEnum(Key.SUB_KIND, ConstructorAccessKind.values); |
| 350 Element element = decoder.getElement(Key.ELEMENT); | 352 Element element = decoder.getElement(Key.ELEMENT); |
| 351 ResolutionDartType type = decoder.getType(Key.TYPE); | 353 ResolutionDartType type = decoder.getType(Key.TYPE); |
| 352 ConstructorAccessSemantics semantics = | 354 ConstructorAccessSemantics semantics = |
| 353 new ConstructorAccessSemantics(constructorAccessKind, element, type); | 355 new ConstructorAccessSemantics(constructorAccessKind, element, type); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 encoder.setEnum(Key.SUB_KIND, compoundAccess.compoundAccessKind); | 416 encoder.setEnum(Key.SUB_KIND, compoundAccess.compoundAccessKind); |
| 415 encoder.setElement(Key.GETTER, semantics.getter); | 417 encoder.setElement(Key.GETTER, semantics.getter); |
| 416 encoder.setElement(Key.SETTER, semantics.setter); | 418 encoder.setElement(Key.SETTER, semantics.setter); |
| 417 break; | 419 break; |
| 418 case AccessKind.CONSTANT: | 420 case AccessKind.CONSTANT: |
| 419 throw new UnsupportedError('Unsupported access kind: ${semantics.kind}'); | 421 throw new UnsupportedError('Unsupported access kind: ${semantics.kind}'); |
| 420 } | 422 } |
| 421 } | 423 } |
| 422 | 424 |
| 423 /// Deserialize a [AccessSemantics] from [decoder]. | 425 /// Deserialize a [AccessSemantics] from [decoder]. |
| 426 // ignore: MISSING_RETURN |
| 424 AccessSemantics deserializeAccessSemantics(ObjectDecoder decoder) { | 427 AccessSemantics deserializeAccessSemantics(ObjectDecoder decoder) { |
| 425 AccessKind kind = decoder.getEnum(Key.KIND, AccessKind.values); | 428 AccessKind kind = decoder.getEnum(Key.KIND, AccessKind.values); |
| 426 switch (kind) { | 429 switch (kind) { |
| 427 case AccessKind.EXPRESSION: | 430 case AccessKind.EXPRESSION: |
| 428 return const DynamicAccess.expression(); | 431 return const DynamicAccess.expression(); |
| 429 case AccessKind.THIS: | 432 case AccessKind.THIS: |
| 430 return const DynamicAccess.thisAccess(); | 433 return const DynamicAccess.thisAccess(); |
| 431 case AccessKind.THIS_PROPERTY: | 434 case AccessKind.THIS_PROPERTY: |
| 432 return new DynamicAccess.thisProperty(deserializeName(decoder)); | 435 return new DynamicAccess.thisProperty(deserializeName(decoder)); |
| 433 case AccessKind.DYNAMIC_PROPERTY: | 436 case AccessKind.DYNAMIC_PROPERTY: |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 ObjectDecoder sourceSpanDecoder = | 582 ObjectDecoder sourceSpanDecoder = |
| 580 object.getObject(Key.SOURCE_SPAN, isOptional: true); | 583 object.getObject(Key.SOURCE_SPAN, isOptional: true); |
| 581 if (sourceSpanDecoder != null) { | 584 if (sourceSpanDecoder != null) { |
| 582 sourceSpan = deserializeSourceSpan(sourceSpanDecoder); | 585 sourceSpan = deserializeSourceSpan(sourceSpanDecoder); |
| 583 } | 586 } |
| 584 MessageKind messageKind = object.getEnum(Key.KIND, MessageKind.values); | 587 MessageKind messageKind = object.getEnum(Key.KIND, MessageKind.values); |
| 585 Map<String, dynamic> messageArguments = | 588 Map<String, dynamic> messageArguments = |
| 586 deserializeMessageArguments(object, Key.ARGUMENTS); | 589 deserializeMessageArguments(object, Key.ARGUMENTS); |
| 587 return new WrappedMessage(sourceSpan, messageKind, messageArguments); | 590 return new WrappedMessage(sourceSpan, messageKind, messageArguments); |
| 588 } | 591 } |
| OLD | NEW |