-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathserialization.dart
77 lines (67 loc) · 2.59 KB
/
serialization.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:collection';
import 'dart:typed_data';
import 'package:kernel/ast.dart' as ir;
import '../closure.dart';
import '../common.dart';
import '../common/codegen.dart';
import '../constants/constant_system.dart' as constant_system;
import '../constants/values.dart';
import '../deferred_load/output_unit.dart' show OutputUnit;
import '../elements/entities.dart';
import '../elements/names.dart';
import '../elements/types.dart';
import '../inferrer/abstract_value_domain.dart';
import '../io/source_information.dart';
import '../ir/constants.dart';
import '../js/js.dart' as js;
import '../js_model/closure.dart';
import '../js_model/elements.dart';
import '../js_model/locals.dart';
import '../js_model/type_recipe.dart' show TypeRecipe;
import '../universe/record_shape.dart' show RecordShape;
import '../universe/selector.dart';
import '../options.dart';
import 'deferrable.dart';
import 'member_data.dart';
import 'indexed_sink_source.dart';
import 'tags.dart';
export 'binary_sink.dart';
export 'binary_source.dart';
export 'indexed_sink_source.dart' show SerializationIndices;
export 'member_data.dart' show ComponentLookup, computeMemberName;
export 'object_sink.dart';
export 'object_source.dart';
export 'tags.dart';
part 'sink.dart';
part 'source.dart';
part 'helpers.dart';
abstract class StringInterner {
String internString(String string);
}
class ValueInterner {
final Map<DartType, DartType> _dartTypeMap = HashMap();
final Map<ir.DartType?, ir.DartType?> _dartTypeNodeMap = HashMap();
DartType internDartType(DartType dartType) {
return _dartTypeMap[dartType] ??= dartType;
}
ir.DartType? internDartTypeNode(ir.DartType? dartType) {
return _dartTypeNodeMap[dartType] ??= dartType;
}
}
/// Interface used for reading codegen only data during deserialization.
abstract class CodegenReader {
AbstractValue readAbstractValue(DataSourceReader source);
OutputUnit readOutputUnitReference(DataSourceReader source);
js.Node readJsNode(DataSourceReader source);
TypeRecipe readTypeRecipe(DataSourceReader source);
}
/// Interface used for writing codegen only data during serialization.
abstract class CodegenWriter {
void writeAbstractValue(DataSinkWriter sink, AbstractValue value);
void writeOutputUnitReference(DataSinkWriter sink, OutputUnit value);
void writeJsNode(DataSinkWriter sink, js.Node node);
void writeTypeRecipe(DataSinkWriter sink, TypeRecipe recipe);
}