mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 14:32:24 +00:00
[kernel] Remove dynamic access from text_serializer
Change-Id: Ic1012992472f8798c384af8795db8b1f42f8ccb1 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171945 Reviewed-by: Dmitry Stefantsov <dmitryas@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
parent
f5e26456bf
commit
c4622003a2
6 changed files with 394 additions and 316 deletions
|
@ -11,7 +11,7 @@
|
|||
"constraint, update this by running tools/generate_package_config.dart."
|
||||
],
|
||||
"configVersion": 2,
|
||||
"generated": "2020-10-26T09:42:07.748397",
|
||||
"generated": "2020-11-15T14:18:10.587065",
|
||||
"generator": "tools/generate_package_config.dart",
|
||||
"packages": [
|
||||
{
|
||||
|
@ -267,7 +267,7 @@
|
|||
"name": "front_end",
|
||||
"rootUri": "../pkg/front_end",
|
||||
"packageUri": "lib/",
|
||||
"languageVersion": "2.2"
|
||||
"languageVersion": "2.6"
|
||||
},
|
||||
{
|
||||
"name": "front_end_testcases",
|
||||
|
@ -361,7 +361,7 @@
|
|||
"name": "kernel",
|
||||
"rootUri": "../pkg/kernel",
|
||||
"packageUri": "lib/",
|
||||
"languageVersion": "2.2"
|
||||
"languageVersion": "2.6"
|
||||
},
|
||||
{
|
||||
"name": "language_versioning_2.7_test",
|
||||
|
|
|
@ -6,7 +6,7 @@ name: front_end
|
|||
publish_to: none
|
||||
|
||||
environment:
|
||||
sdk: '>=2.2.2 <3.0.0'
|
||||
sdk: '>=2.6.0 <3.0.0'
|
||||
|
||||
dependencies:
|
||||
_fe_analyzer_shared: any
|
||||
|
|
|
@ -40,28 +40,6 @@
|
|||
"pkg/front_end/lib/src/fasta/kernel/body_builder.dart": {
|
||||
"Dynamic invocation of 'buildForEffect'.": 1
|
||||
},
|
||||
"pkg/kernel/lib/text/text_serializer.dart": {
|
||||
"Dynamic access of 'first'.": 68,
|
||||
"Dynamic invocation of 'getReference'.": 10,
|
||||
"Dynamic access of 'second'.": 88,
|
||||
"Dynamic access of 'third'.": 29,
|
||||
"Dynamic access of 'fourth'.": 17,
|
||||
"Dynamic access of 'fifth'.": 3,
|
||||
"Dynamic access of 'sixth'.": 2,
|
||||
"Dynamic invocation of 'fold'.": 9,
|
||||
"Dynamic invocation of '|'.": 8,
|
||||
"Dynamic access of 'value'.": 11,
|
||||
"Dynamic access of 'key'.": 11,
|
||||
"Dynamic update to 'name'.": 2,
|
||||
"Dynamic invocation of 'addAnnotation'.": 1,
|
||||
"Dynamic access of 'expressions'.": 1,
|
||||
"Dynamic access of 'length'.": 3,
|
||||
"Dynamic invocation of '+'.": 2,
|
||||
"Dynamic invocation of 'toList'.": 5,
|
||||
"Dynamic invocation of 'cast'.": 5,
|
||||
"Dynamic invocation of 'where'.": 5,
|
||||
"Dynamic access of 'seventh'.": 1
|
||||
},
|
||||
"pkg/_fe_analyzer_shared/lib/src/util/link.dart": {
|
||||
"Dynamic access of 'isEmpty'.": 1
|
||||
},
|
||||
|
|
|
@ -24,10 +24,6 @@ general/call: TypeCheckError
|
|||
general/callable_type_variable: TypeCheckError
|
||||
general/candidate_found: TypeCheckError
|
||||
general/cascade: RuntimeError
|
||||
general/constants/with_unevaluated_agnostic/const_asserts: TextSerializationFailure
|
||||
general/constants/with_unevaluated_agnostic/const_collections_2: TextSerializationFailure
|
||||
general/constants/with_unevaluated_agnostic/various: TextSerializationFailure
|
||||
general/constants/with_unevaluated_agnostic/various_2: TextSerializationFailure
|
||||
general/constructor_initializer_invalid: RuntimeError
|
||||
general/covariant_field: TypeCheckError
|
||||
general/covariant_generic: RuntimeError
|
||||
|
|
|
@ -23,7 +23,7 @@ class NameTagger implements Tagger<Name> {
|
|||
TextSerializer<Name> publicName =
|
||||
Wrapped((w) => w.text, (u) => Name(u), const DartString());
|
||||
|
||||
TextSerializer<Name> privateName = Wrapped(
|
||||
TextSerializer<Name> privateName = Wrapped<Tuple2<String, CanonicalName>, Name>(
|
||||
(w) => Tuple2(w.text, w.library.canonicalName),
|
||||
(u) => Name.byReference(u.first, u.second.getReference()),
|
||||
Tuple2Serializer(DartString(), CanonicalNameSerializer()));
|
||||
|
@ -629,39 +629,48 @@ FunctionExpression wrapFunctionExpression(FunctionNode node) {
|
|||
return new FunctionExpression(node);
|
||||
}
|
||||
|
||||
TextSerializer<ListConcatenation> listConcatenationSerializer = Wrapped(
|
||||
(lc) => Tuple2(lc.typeArgument, lc.lists),
|
||||
(t) => ListConcatenation(t.second, typeArgument: t.first),
|
||||
Tuple2Serializer(dartTypeSerializer, ListSerializer(expressionSerializer)));
|
||||
TextSerializer<ListConcatenation> listConcatenationSerializer =
|
||||
Wrapped<Tuple2<DartType, List<Expression>>, ListConcatenation>(
|
||||
(lc) => Tuple2(lc.typeArgument, lc.lists),
|
||||
(t) => ListConcatenation(t.second, typeArgument: t.first),
|
||||
Tuple2Serializer(
|
||||
dartTypeSerializer, ListSerializer(expressionSerializer)));
|
||||
|
||||
TextSerializer<SetConcatenation> setConcatenationSerializer = Wrapped(
|
||||
(sc) => Tuple2(sc.typeArgument, sc.sets),
|
||||
(t) => SetConcatenation(t.second, typeArgument: t.first),
|
||||
Tuple2Serializer(dartTypeSerializer, ListSerializer(expressionSerializer)));
|
||||
TextSerializer<SetConcatenation> setConcatenationSerializer =
|
||||
Wrapped<Tuple2<DartType, List<Expression>>, SetConcatenation>(
|
||||
(sc) => Tuple2(sc.typeArgument, sc.sets),
|
||||
(t) => SetConcatenation(t.second, typeArgument: t.first),
|
||||
Tuple2Serializer(
|
||||
dartTypeSerializer, ListSerializer(expressionSerializer)));
|
||||
|
||||
TextSerializer<MapConcatenation> mapConcatenationSerializer = Wrapped(
|
||||
(mc) => Tuple3(mc.keyType, mc.valueType, mc.maps),
|
||||
(t) => MapConcatenation(t.third, keyType: t.first, valueType: t.second),
|
||||
Tuple3Serializer(dartTypeSerializer, dartTypeSerializer,
|
||||
ListSerializer(expressionSerializer)));
|
||||
TextSerializer<MapConcatenation> mapConcatenationSerializer =
|
||||
Wrapped<Tuple3<DartType, DartType, List<Expression>>, MapConcatenation>(
|
||||
(mc) => Tuple3(mc.keyType, mc.valueType, mc.maps),
|
||||
(t) => MapConcatenation(t.third, keyType: t.first, valueType: t.second),
|
||||
Tuple3Serializer(dartTypeSerializer, dartTypeSerializer,
|
||||
ListSerializer(expressionSerializer)));
|
||||
|
||||
TextSerializer<BlockExpression> blockExpressionSerializer = Wrapped(
|
||||
(w) => Tuple2(w.body.statements, w.value),
|
||||
(u) => BlockExpression(Block(u.first), u.second),
|
||||
const BlockSerializer());
|
||||
TextSerializer<BlockExpression> blockExpressionSerializer =
|
||||
Wrapped<Tuple2<List<Statement>, Expression>, BlockExpression>(
|
||||
(w) => Tuple2(w.body.statements, w.value),
|
||||
(u) => BlockExpression(Block(u.first), u.second),
|
||||
const BlockSerializer());
|
||||
|
||||
TextSerializer<Instantiation> instantiationSerializer = Wrapped(
|
||||
(i) => Tuple2(i.expression, i.typeArguments),
|
||||
(t) => Instantiation(t.first, t.second),
|
||||
Tuple2Serializer(expressionSerializer, ListSerializer(dartTypeSerializer)));
|
||||
TextSerializer<Instantiation> instantiationSerializer =
|
||||
Wrapped<Tuple2<Expression, List<DartType>>, Instantiation>(
|
||||
(i) => Tuple2(i.expression, i.typeArguments),
|
||||
(t) => Instantiation(t.first, t.second),
|
||||
Tuple2Serializer(
|
||||
expressionSerializer, ListSerializer(dartTypeSerializer)));
|
||||
|
||||
TextSerializer<NullCheck> nullCheckSerializer =
|
||||
Wrapped((nc) => nc.operand, (op) => NullCheck(op), expressionSerializer);
|
||||
|
||||
TextSerializer<FileUriExpression> fileUriExpressionSerializer = Wrapped(
|
||||
(fue) => Tuple2(fue.expression, fue.fileUri),
|
||||
(t) => FileUriExpression(t.first, t.second),
|
||||
Tuple2Serializer(expressionSerializer, const UriSerializer()));
|
||||
TextSerializer<FileUriExpression> fileUriExpressionSerializer =
|
||||
Wrapped<Tuple2<Expression, Uri>, FileUriExpression>(
|
||||
(fue) => Tuple2(fue.expression, fue.fileUri),
|
||||
(t) => FileUriExpression(t.first, t.second),
|
||||
Tuple2Serializer(expressionSerializer, const UriSerializer()));
|
||||
|
||||
TextSerializer<CheckLibraryIsLoaded> checkLibraryIsLoadedSerializer = Wrapped(
|
||||
(clil) => clil.import,
|
||||
|
@ -671,12 +680,16 @@ TextSerializer<CheckLibraryIsLoaded> checkLibraryIsLoadedSerializer = Wrapped(
|
|||
TextSerializer<LoadLibrary> loadLibrarySerializer = Wrapped(
|
||||
(ll) => ll.import, (i) => LoadLibrary(i), libraryDependencySerializer);
|
||||
|
||||
TextSerializer<ConstantExpression> constantExpressionSerializer = Wrapped(
|
||||
(ce) => Tuple2(ce.constant, ce.type),
|
||||
(t) => ConstantExpression(t.first, t.second),
|
||||
Tuple2Serializer(constantSerializer, dartTypeSerializer));
|
||||
TextSerializer<ConstantExpression> constantExpressionSerializer =
|
||||
Wrapped<Tuple2<Constant, DartType>, ConstantExpression>(
|
||||
(ce) => Tuple2(ce.constant, ce.type),
|
||||
(t) => ConstantExpression(t.first, t.second),
|
||||
Tuple2Serializer(constantSerializer, dartTypeSerializer));
|
||||
|
||||
TextSerializer<InstanceCreation> instanceCreationSerializer = Wrapped(
|
||||
TextSerializer<InstanceCreation> instanceCreationSerializer = Wrapped<
|
||||
Tuple6<CanonicalName, List<DartType>, List<CanonicalName>,
|
||||
List<Expression>, List<AssertStatement>, List<Expression>>,
|
||||
InstanceCreation>(
|
||||
(ic) => Tuple6(
|
||||
ic.classReference.canonicalName,
|
||||
ic.typeArguments,
|
||||
|
@ -684,8 +697,12 @@ TextSerializer<InstanceCreation> instanceCreationSerializer = Wrapped(
|
|||
ic.fieldValues.values.toList(),
|
||||
ic.asserts,
|
||||
ic.unusedArguments),
|
||||
(t) => InstanceCreation(t.first.getReference(), t.second,
|
||||
Map.fromIterables(t.third, t.fourth), t.fifth, t.sixth),
|
||||
(t) => InstanceCreation(
|
||||
t.first.getReference(),
|
||||
t.second,
|
||||
Map.fromIterables(t.third.map((cn) => cn.reference), t.fourth),
|
||||
t.fifth,
|
||||
t.sixth),
|
||||
Tuple6Serializer(
|
||||
CanonicalNameSerializer(),
|
||||
ListSerializer(dartTypeSerializer),
|
||||
|
@ -746,36 +763,39 @@ class VariableDeclarationFlagTagger implements Tagger<int> {
|
|||
}
|
||||
}
|
||||
|
||||
TextSerializer<int> variableDeclarationFlagsSerializer = Wrapped(
|
||||
(w) => List.generate(30, (i) => w & (1 << i)).where((f) => f != 0).toList(),
|
||||
(u) => u.fold(0, (fs, f) => fs |= f),
|
||||
ListSerializer(Case(
|
||||
VariableDeclarationFlagTagger(),
|
||||
Map.fromIterable(variableDeclarationFlagToName.entries,
|
||||
key: (e) => e.value,
|
||||
value: (e) => Wrapped((_) => null, (_) => e.key, Nothing())))));
|
||||
TextSerializer<int> variableDeclarationFlagsSerializer =
|
||||
Wrapped<List<int>, int>(
|
||||
(w) => List.generate(30, (i) => w & (1 << i))
|
||||
.where((f) => f != 0)
|
||||
.toList(),
|
||||
(u) => u.fold(0, (fs, f) => fs |= f),
|
||||
ListSerializer(Case(VariableDeclarationFlagTagger(),
|
||||
convertFlagsMap(variableDeclarationFlagToName))));
|
||||
|
||||
TextSerializer<VariableDeclaration> variableDeclarationSerializer = Wrapped(
|
||||
(v) => Tuple2(v.name, v),
|
||||
(t) => t.second..name = t.first,
|
||||
Binder<VariableDeclaration>(
|
||||
new Wrapped(
|
||||
(w) => Tuple4(w.flags, w.type, w.initializer, w.annotations),
|
||||
(u) => u.fourth.fold(
|
||||
VariableDeclaration(null,
|
||||
flags: u.first, type: u.second, initializer: u.third),
|
||||
(v, a) => v..addAnnotation(a)),
|
||||
Tuple4Serializer(
|
||||
variableDeclarationFlagsSerializer,
|
||||
dartTypeSerializer,
|
||||
new Optional(expressionSerializer),
|
||||
new ListSerializer(expressionSerializer))),
|
||||
));
|
||||
TextSerializer<VariableDeclaration> variableDeclarationSerializer =
|
||||
Wrapped<Tuple2<String, VariableDeclaration>, VariableDeclaration>(
|
||||
(v) => Tuple2(v.name, v),
|
||||
(t) => t.second..name = t.first,
|
||||
Binder<VariableDeclaration>(
|
||||
new Wrapped<Tuple4<int, DartType, Expression, List<Expression>>,
|
||||
VariableDeclaration>(
|
||||
(w) => Tuple4(w.flags, w.type, w.initializer, w.annotations),
|
||||
(u) => u.fourth.fold(
|
||||
VariableDeclaration(null,
|
||||
flags: u.first, type: u.second, initializer: u.third),
|
||||
(v, a) => v..addAnnotation(a)),
|
||||
Tuple4Serializer(
|
||||
variableDeclarationFlagsSerializer,
|
||||
dartTypeSerializer,
|
||||
new Optional(expressionSerializer),
|
||||
new ListSerializer(expressionSerializer))),
|
||||
));
|
||||
|
||||
TextSerializer<TypeParameter> typeParameterSerializer = Wrapped(
|
||||
(p) => Tuple2(p.name, p),
|
||||
(t) => t.second..name = t.first,
|
||||
Binder(Wrapped((_) => null, (_) => TypeParameter(), const Nothing())));
|
||||
TextSerializer<TypeParameter> typeParameterSerializer =
|
||||
Wrapped<Tuple2<String, TypeParameter>, TypeParameter>(
|
||||
(p) => Tuple2(p.name, p),
|
||||
(t) => t.second..name = t.first,
|
||||
Binder(Wrapped((_) => null, (_) => TypeParameter(), const Nothing())));
|
||||
|
||||
TextSerializer<List<TypeParameter>> typeParametersSerializer = new Zip(
|
||||
new Rebind(
|
||||
|
@ -1048,18 +1068,23 @@ YieldStatement wrapYieldStatement(Expression expression) {
|
|||
return new YieldStatement(expression);
|
||||
}
|
||||
|
||||
TextSerializer<AssertStatement> assertStatementSerializer = Wrapped(
|
||||
(a) => Tuple2(a.condition, a.message),
|
||||
(t) => AssertStatement(t.first, message: t.second),
|
||||
Tuple2Serializer(expressionSerializer, Optional(expressionSerializer)));
|
||||
TextSerializer<AssertStatement> assertStatementSerializer =
|
||||
Wrapped<Tuple2<Expression, Expression>, AssertStatement>(
|
||||
(a) => Tuple2(a.condition, a.message),
|
||||
(t) => AssertStatement(t.first, message: t.second),
|
||||
Tuple2Serializer(expressionSerializer, Optional(expressionSerializer)));
|
||||
|
||||
TextSerializer<Block> blockSerializer = new Wrapped(
|
||||
(w) => Tuple2(w.statements, null),
|
||||
(u) => Block(u.first),
|
||||
const BlockSerializer());
|
||||
TextSerializer<Block> blockSerializer =
|
||||
Wrapped<Tuple2<List<Statement>, Expression>, Block>(
|
||||
(w) => Tuple2(w.statements, null),
|
||||
(u) => Block(u.first),
|
||||
const BlockSerializer());
|
||||
|
||||
TextSerializer<AssertBlock> assertBlockSerializer = new Wrapped(
|
||||
(w) => Tuple2(w.statements, null), (u) => u.first, const BlockSerializer());
|
||||
TextSerializer<AssertBlock> assertBlockSerializer =
|
||||
Wrapped<Tuple2<List<Statement>, Expression>, AssertBlock>(
|
||||
(w) => Tuple2(w.statements, null),
|
||||
(u) => AssertBlock(u.first),
|
||||
const BlockSerializer());
|
||||
|
||||
/// Serializer for [Block]s.
|
||||
///
|
||||
|
@ -1179,7 +1204,10 @@ DoStatement wrapDoStatement(Tuple2<Statement, Expression> tuple) {
|
|||
return new DoStatement(tuple.first, tuple.second);
|
||||
}
|
||||
|
||||
TextSerializer<ForStatement> forStatementSerializer = new Wrapped(
|
||||
TextSerializer<ForStatement> forStatementSerializer = Wrapped<
|
||||
Tuple2<List<VariableDeclaration>,
|
||||
Tuple3<Expression, List<Expression>, Statement>>,
|
||||
ForStatement>(
|
||||
(w) => Tuple2(w.variables, Tuple3(w.condition, w.updates, w.body)),
|
||||
(u) =>
|
||||
ForStatement(u.first, u.second.first, u.second.second, u.second.third),
|
||||
|
@ -1223,7 +1251,7 @@ TextSerializer<LabeledStatement> labeledStatementSerializer =
|
|||
(ls) => Tuple2(ls, ls.body),
|
||||
(t) => t.first..body = t.second,
|
||||
Bind(
|
||||
Wrapped(
|
||||
Wrapped<Tuple2<String, LabeledStatement>, LabeledStatement>(
|
||||
(ls) => Tuple2("L", ls),
|
||||
(t) => t.second,
|
||||
Binder(Wrapped(
|
||||
|
@ -1243,37 +1271,47 @@ BreakStatement wrapBreakStatement(LabeledStatement node) {
|
|||
return new BreakStatement(node);
|
||||
}
|
||||
|
||||
TextSerializer<TryFinally> tryFinallySerializer = Wrapped(
|
||||
(w) => Tuple2(w.body, w.finalizer),
|
||||
(u) => TryFinally(u.first, u.second),
|
||||
Tuple2Serializer(statementSerializer, statementSerializer));
|
||||
TextSerializer<TryFinally> tryFinallySerializer =
|
||||
Wrapped<Tuple2<Statement, Statement>, TryFinally>(
|
||||
(w) => Tuple2(w.body, w.finalizer),
|
||||
(u) => TryFinally(u.first, u.second),
|
||||
Tuple2Serializer(statementSerializer, statementSerializer));
|
||||
|
||||
TextSerializer<TryCatch> tryCatchSerializer = Wrapped(
|
||||
(w) => Tuple2(w.body, w.catches),
|
||||
(u) => TryCatch(u.first, u.second),
|
||||
Tuple2Serializer(statementSerializer, ListSerializer(catchSerializer)));
|
||||
TextSerializer<TryCatch> tryCatchSerializer =
|
||||
Wrapped<Tuple2<Statement, List<Catch>>, TryCatch>(
|
||||
(w) => Tuple2(w.body, w.catches),
|
||||
(u) => TryCatch(u.first, u.second),
|
||||
Tuple2Serializer(statementSerializer, ListSerializer(catchSerializer)));
|
||||
|
||||
TextSerializer<Catch> catchSerializer = Wrapped(
|
||||
(w) => Tuple2(w.guard, Tuple2(Tuple2(w.exception, w.stackTrace), w.body)),
|
||||
(u) => Catch(u.second.first.first, u.second.second,
|
||||
stackTrace: u.second.first.second, guard: u.first),
|
||||
Tuple2Serializer(
|
||||
dartTypeSerializer,
|
||||
Bind(
|
||||
Tuple2Serializer(Optional(variableDeclarationSerializer),
|
||||
Optional(variableDeclarationSerializer)),
|
||||
statementSerializer)));
|
||||
TextSerializer<Catch> catchSerializer =
|
||||
Wrapped<
|
||||
Tuple2<
|
||||
DartType,
|
||||
Tuple2<Tuple2<VariableDeclaration, VariableDeclaration>,
|
||||
Statement>>,
|
||||
Catch>(
|
||||
(w) =>
|
||||
Tuple2(w.guard, Tuple2(Tuple2(w.exception, w.stackTrace), w.body)),
|
||||
(u) => Catch(u.second.first.first, u.second.second,
|
||||
stackTrace: u.second.first.second, guard: u.first),
|
||||
Tuple2Serializer(
|
||||
dartTypeSerializer,
|
||||
Bind(
|
||||
Tuple2Serializer(Optional(variableDeclarationSerializer),
|
||||
Optional(variableDeclarationSerializer)),
|
||||
statementSerializer)));
|
||||
|
||||
TextSerializer<SwitchStatement> switchStatementSerializer = Wrapped(
|
||||
(w) => Tuple2(w.expression, w.cases),
|
||||
(u) => SwitchStatement(u.first, u.second),
|
||||
Tuple2Serializer(
|
||||
expressionSerializer,
|
||||
Zip(
|
||||
Bind(ListSerializer<SwitchCase>(switchCaseSerializer),
|
||||
ListSerializer(statementSerializer)),
|
||||
(SwitchCase c, Statement b) => c..body = b,
|
||||
(SwitchCase z) => Tuple2(z, z.body))));
|
||||
TextSerializer<SwitchStatement> switchStatementSerializer =
|
||||
Wrapped<Tuple2<Expression, List<SwitchCase>>, SwitchStatement>(
|
||||
(w) => Tuple2(w.expression, w.cases),
|
||||
(u) => SwitchStatement(u.first, u.second),
|
||||
Tuple2Serializer(
|
||||
expressionSerializer,
|
||||
Zip(
|
||||
Bind(ListSerializer<SwitchCase>(switchCaseSerializer),
|
||||
ListSerializer(statementSerializer)),
|
||||
(SwitchCase c, Statement b) => c..body = b,
|
||||
(SwitchCase z) => Tuple2(z, z.body))));
|
||||
|
||||
class SwitchCaseTagger implements Tagger<SwitchCase> {
|
||||
String tag(SwitchCase node) {
|
||||
|
@ -1281,15 +1319,17 @@ class SwitchCaseTagger implements Tagger<SwitchCase> {
|
|||
}
|
||||
}
|
||||
|
||||
TextSerializer<SwitchCase> switchCaseCaseSerializer = Wrapped(
|
||||
(w) => Tuple2("L", w),
|
||||
(u) => u.second,
|
||||
Binder(Wrapped(
|
||||
(w) => w.expressions,
|
||||
(u) => SwitchCase(u, List.filled(u.length, 0), null),
|
||||
ListSerializer(expressionSerializer))));
|
||||
TextSerializer<SwitchCase> switchCaseCaseSerializer =
|
||||
Wrapped<Tuple2<String, SwitchCase>, SwitchCase>(
|
||||
(w) => Tuple2("L", w),
|
||||
(u) => u.second,
|
||||
Binder(Wrapped<List<Expression>, SwitchCase>(
|
||||
(w) => w.expressions,
|
||||
(u) => SwitchCase(u, List.filled(u.length, 0), null),
|
||||
ListSerializer(expressionSerializer))));
|
||||
|
||||
TextSerializer<SwitchCase> switchCaseDefaultSerializer = Wrapped(
|
||||
TextSerializer<SwitchCase> switchCaseDefaultSerializer = Wrapped<
|
||||
Tuple2<String, SwitchCase>, SwitchCase>(
|
||||
(w) => Tuple2("L", w),
|
||||
(u) => u.second,
|
||||
Binder(
|
||||
|
@ -1303,10 +1343,11 @@ TextSerializer<SwitchCase> switchCaseSerializer = Case(SwitchCaseTagger(), {
|
|||
TextSerializer<ContinueSwitchStatement> continueSwitchStatementSerializer =
|
||||
Wrapped((w) => w.target, (u) => ContinueSwitchStatement(u), ScopedUse());
|
||||
|
||||
TextSerializer<FunctionDeclaration> functionDeclarationSerializer = Wrapped(
|
||||
(w) => Tuple2(w.variable, w.function),
|
||||
(u) => FunctionDeclaration(u.first, u.second),
|
||||
Rebind(variableDeclarationSerializer, functionNodeSerializer));
|
||||
TextSerializer<FunctionDeclaration> functionDeclarationSerializer =
|
||||
Wrapped<Tuple2<VariableDeclaration, FunctionNode>, FunctionDeclaration>(
|
||||
(w) => Tuple2(w.variable, w.function),
|
||||
(u) => FunctionDeclaration(u.first, u.second),
|
||||
Rebind(variableDeclarationSerializer, functionNodeSerializer));
|
||||
|
||||
Case<Statement> statementSerializer =
|
||||
new Case.uninitialized(const StatementTagger());
|
||||
|
@ -1327,14 +1368,24 @@ class AsyncMarkerTagger implements Tagger<AsyncMarker> {
|
|||
}
|
||||
}
|
||||
|
||||
TextSerializer<AsyncMarker> asyncMarkerSerializer = Case(
|
||||
AsyncMarkerTagger(),
|
||||
Map.fromIterable(asyncMarkerToName.entries,
|
||||
key: (e) => e.value,
|
||||
value: (e) => Wrapped((_) => null, (_) => e.key, Nothing())));
|
||||
TextSerializer<AsyncMarker> asyncMarkerSerializer =
|
||||
Case(AsyncMarkerTagger(), convertFlagsMap(asyncMarkerToName));
|
||||
|
||||
TextSerializer<Tuple2<FunctionNode, List<Initializer>>>
|
||||
functionNodeWithInitializersSerializer = Wrapped(
|
||||
// '/**/' comments added to guide formatting.
|
||||
|
||||
TextSerializer<Tuple2<FunctionNode, List<Initializer>>> /**/
|
||||
functionNodeWithInitializersSerializer = Wrapped<
|
||||
Tuple2<
|
||||
AsyncMarker,
|
||||
Tuple2< /**/
|
||||
Tuple2< /**/
|
||||
List<TypeParameter>,
|
||||
Tuple3<
|
||||
List<VariableDeclaration>,
|
||||
List<VariableDeclaration>,
|
||||
List<VariableDeclaration>>>,
|
||||
Tuple3<DartType, List<Initializer>, Statement>>>,
|
||||
Tuple2<FunctionNode, List<Initializer>>>(
|
||||
(w) => Tuple2(
|
||||
w.first.asyncMarker,
|
||||
Tuple2(
|
||||
|
@ -1371,10 +1422,11 @@ TextSerializer<Tuple2<FunctionNode, List<Initializer>>>
|
|||
Optional(ListSerializer(initializerSerializer)),
|
||||
Optional(statementSerializer)))));
|
||||
|
||||
TextSerializer<FunctionNode> functionNodeSerializer = Wrapped(
|
||||
(w) => Tuple2(w, null),
|
||||
(u) => u.first,
|
||||
functionNodeWithInitializersSerializer);
|
||||
TextSerializer<FunctionNode> functionNodeSerializer =
|
||||
Wrapped<Tuple2<FunctionNode, List<Initializer>>, FunctionNode>(
|
||||
(w) => Tuple2(w, null),
|
||||
(u) => u.first,
|
||||
functionNodeWithInitializersSerializer);
|
||||
|
||||
const Map<int, String> procedureFlagToName = const {
|
||||
Procedure.FlagStatic: "static",
|
||||
|
@ -1400,14 +1452,11 @@ class ProcedureFlagTagger implements Tagger<int> {
|
|||
}
|
||||
}
|
||||
|
||||
TextSerializer<int> procedureFlagsSerializer = Wrapped(
|
||||
TextSerializer<int> procedureFlagsSerializer = Wrapped<List<int>, int>(
|
||||
(w) => List.generate(30, (i) => w & (1 << i)).where((f) => f != 0).toList(),
|
||||
(u) => u.fold(0, (fs, f) => fs |= f),
|
||||
ListSerializer(Case(
|
||||
ProcedureFlagTagger(),
|
||||
Map.fromIterable(procedureFlagToName.entries,
|
||||
key: (e) => e.value,
|
||||
value: (e) => Wrapped((_) => null, (_) => e.key, Nothing())))));
|
||||
ListSerializer(
|
||||
Case(ProcedureFlagTagger(), convertFlagsMap(procedureFlagToName))));
|
||||
|
||||
const Map<int, String> fieldFlagToName = const {
|
||||
Field.FlagFinal: "final",
|
||||
|
@ -1432,14 +1481,10 @@ class FieldFlagTagger implements Tagger<int> {
|
|||
}
|
||||
}
|
||||
|
||||
TextSerializer<int> fieldFlagsSerializer = Wrapped(
|
||||
TextSerializer<int> fieldFlagsSerializer = Wrapped<List<int>, int>(
|
||||
(w) => List.generate(30, (i) => w & (1 << i)).where((f) => f != 0).toList(),
|
||||
(u) => u.fold(0, (fs, f) => fs |= f),
|
||||
ListSerializer(Case(
|
||||
FieldFlagTagger(),
|
||||
Map.fromIterable(fieldFlagToName.entries,
|
||||
key: (e) => e.value,
|
||||
value: (e) => Wrapped((_) => null, (_) => e.key, Nothing())))));
|
||||
ListSerializer(Case(FieldFlagTagger(), convertFlagsMap(fieldFlagToName))));
|
||||
|
||||
const Map<int, String> constructorFlagToName = const {
|
||||
Constructor.FlagConst: "const",
|
||||
|
@ -1457,14 +1502,11 @@ class ConstructorFlagTagger implements Tagger<int> {
|
|||
}
|
||||
}
|
||||
|
||||
TextSerializer<int> constructorFlagsSerializer = Wrapped(
|
||||
TextSerializer<int> constructorFlagsSerializer = Wrapped<List<int>, int>(
|
||||
(w) => List.generate(30, (i) => w & (1 << i)).where((f) => f != 0).toList(),
|
||||
(u) => u.fold(0, (fs, f) => fs |= f),
|
||||
ListSerializer(Case(
|
||||
ConstructorFlagTagger(),
|
||||
Map.fromIterable(constructorFlagToName.entries,
|
||||
key: (e) => e.value,
|
||||
value: (e) => Wrapped((_) => null, (_) => e.key, Nothing())))));
|
||||
ListSerializer(
|
||||
Case(ConstructorFlagTagger(), convertFlagsMap(constructorFlagToName))));
|
||||
|
||||
const Map<int, String> redirectingFactoryConstructorFlagToName = const {
|
||||
RedirectingFactoryConstructor.FlagConst: "const",
|
||||
|
@ -1483,14 +1525,14 @@ class RedirectingFactoryConstructorFlagTagger implements Tagger<int> {
|
|||
}
|
||||
}
|
||||
|
||||
TextSerializer<int> redirectingFactoryConstructorFlagsSerializer = Wrapped(
|
||||
(w) => List.generate(30, (i) => w & (1 << i)).where((f) => f != 0).toList(),
|
||||
(u) => u.fold(0, (fs, f) => fs |= f),
|
||||
ListSerializer(Case(
|
||||
RedirectingFactoryConstructorFlagTagger(),
|
||||
Map.fromIterable(redirectingFactoryConstructorFlagToName.entries,
|
||||
key: (e) => e.value,
|
||||
value: (e) => Wrapped((_) => null, (_) => e.key, Nothing())))));
|
||||
TextSerializer<int> redirectingFactoryConstructorFlagsSerializer =
|
||||
Wrapped<List<int>, int>(
|
||||
(w) => List.generate(30, (i) => w & (1 << i))
|
||||
.where((f) => f != 0)
|
||||
.toList(),
|
||||
(u) => u.fold(0, (fs, f) => fs |= f),
|
||||
ListSerializer(Case(RedirectingFactoryConstructorFlagTagger(),
|
||||
convertFlagsMap(redirectingFactoryConstructorFlagToName))));
|
||||
|
||||
class MemberTagger implements Tagger<Member> {
|
||||
const MemberTagger();
|
||||
|
@ -1523,45 +1565,57 @@ class MemberTagger implements Tagger<Member> {
|
|||
}
|
||||
}
|
||||
|
||||
TextSerializer<Field> fieldSerializer = Wrapped(
|
||||
(w) => Tuple4(w.name, w.flags, w.type, w.initializer),
|
||||
(u) =>
|
||||
Field(u.first, type: u.third, initializer: u.fourth)..flags = u.second,
|
||||
Tuple4Serializer(nameSerializer, fieldFlagsSerializer, dartTypeSerializer,
|
||||
Optional(expressionSerializer)));
|
||||
TextSerializer<Field> fieldSerializer =
|
||||
Wrapped<Tuple4<Name, int, DartType, Expression>, Field>(
|
||||
(w) => Tuple4(w.name, w.flags, w.type, w.initializer),
|
||||
(u) => Field(u.first, type: u.third, initializer: u.fourth)
|
||||
..flags = u.second,
|
||||
Tuple4Serializer(nameSerializer, fieldFlagsSerializer,
|
||||
dartTypeSerializer, Optional(expressionSerializer)));
|
||||
|
||||
TextSerializer<Procedure> methodSerializer = Wrapped(
|
||||
(w) => Tuple3(w.name, w.flags, w.function),
|
||||
(u) => Procedure(u.first, ProcedureKind.Method, u.third)..flags = u.second,
|
||||
Tuple3Serializer(
|
||||
nameSerializer, procedureFlagsSerializer, functionNodeSerializer));
|
||||
TextSerializer<Procedure> methodSerializer =
|
||||
Wrapped<Tuple3<Name, int, FunctionNode>, Procedure>(
|
||||
(w) => Tuple3(w.name, w.flags, w.function),
|
||||
(u) =>
|
||||
Procedure(u.first, ProcedureKind.Method, u.third)..flags = u.second,
|
||||
Tuple3Serializer(
|
||||
nameSerializer, procedureFlagsSerializer, functionNodeSerializer));
|
||||
|
||||
TextSerializer<Procedure> getterSerializer = Wrapped(
|
||||
(w) => Tuple3(w.name, w.flags, w.function),
|
||||
(u) => Procedure(u.first, ProcedureKind.Getter, u.third)..flags = u.second,
|
||||
Tuple3Serializer(
|
||||
nameSerializer, procedureFlagsSerializer, functionNodeSerializer));
|
||||
TextSerializer<Procedure> getterSerializer =
|
||||
Wrapped<Tuple3<Name, int, FunctionNode>, Procedure>(
|
||||
(w) => Tuple3(w.name, w.flags, w.function),
|
||||
(u) =>
|
||||
Procedure(u.first, ProcedureKind.Getter, u.third)..flags = u.second,
|
||||
Tuple3Serializer(
|
||||
nameSerializer, procedureFlagsSerializer, functionNodeSerializer));
|
||||
|
||||
TextSerializer<Procedure> setterSerializer = Wrapped(
|
||||
(w) => Tuple3(w.name, w.flags, w.function),
|
||||
(u) => Procedure(u.first, ProcedureKind.Setter, u.third)..flags = u.second,
|
||||
Tuple3Serializer(
|
||||
nameSerializer, procedureFlagsSerializer, functionNodeSerializer));
|
||||
TextSerializer<Procedure> setterSerializer =
|
||||
Wrapped<Tuple3<Name, int, FunctionNode>, Procedure>(
|
||||
(w) => Tuple3(w.name, w.flags, w.function),
|
||||
(u) =>
|
||||
Procedure(u.first, ProcedureKind.Setter, u.third)..flags = u.second,
|
||||
Tuple3Serializer(
|
||||
nameSerializer, procedureFlagsSerializer, functionNodeSerializer));
|
||||
|
||||
TextSerializer<Procedure> operatorSerializer = Wrapped(
|
||||
(w) => Tuple3(w.name, w.flags, w.function),
|
||||
(u) =>
|
||||
Procedure(u.first, ProcedureKind.Operator, u.third)..flags = u.second,
|
||||
Tuple3Serializer(
|
||||
nameSerializer, procedureFlagsSerializer, functionNodeSerializer));
|
||||
TextSerializer<Procedure> operatorSerializer =
|
||||
Wrapped<Tuple3<Name, int, FunctionNode>, Procedure>(
|
||||
(w) => Tuple3(w.name, w.flags, w.function),
|
||||
(u) => Procedure(u.first, ProcedureKind.Operator, u.third)
|
||||
..flags = u.second,
|
||||
Tuple3Serializer(
|
||||
nameSerializer, procedureFlagsSerializer, functionNodeSerializer));
|
||||
|
||||
TextSerializer<Procedure> factorySerializer = Wrapped(
|
||||
(w) => Tuple3(w.name, w.flags, w.function),
|
||||
(u) => Procedure(u.first, ProcedureKind.Factory, u.third)..flags = u.second,
|
||||
Tuple3Serializer(
|
||||
nameSerializer, procedureFlagsSerializer, functionNodeSerializer));
|
||||
TextSerializer<Procedure> factorySerializer =
|
||||
Wrapped<Tuple3<Name, int, FunctionNode>, Procedure>(
|
||||
(w) => Tuple3(w.name, w.flags, w.function),
|
||||
(u) => Procedure(u.first, ProcedureKind.Factory, u.third)
|
||||
..flags = u.second,
|
||||
Tuple3Serializer(
|
||||
nameSerializer, procedureFlagsSerializer, functionNodeSerializer));
|
||||
|
||||
TextSerializer<Constructor> constructorSerializer = Wrapped(
|
||||
TextSerializer<Constructor> constructorSerializer = Wrapped<
|
||||
Tuple3<Name, int, Tuple2<FunctionNode, List<Initializer>>>,
|
||||
Constructor>(
|
||||
(w) => Tuple3(w.name, w.flags, Tuple2(w.function, w.initializers)),
|
||||
(u) =>
|
||||
Constructor(u.third.first, name: u.first, initializers: u.third.second)
|
||||
|
@ -1570,7 +1624,16 @@ TextSerializer<Constructor> constructorSerializer = Wrapped(
|
|||
functionNodeWithInitializersSerializer));
|
||||
|
||||
TextSerializer<RedirectingFactoryConstructor>
|
||||
redirectingFactoryConstructorSerializer = Wrapped(
|
||||
redirectingFactoryConstructorSerializer = Wrapped<
|
||||
Tuple4<
|
||||
Name,
|
||||
int,
|
||||
CanonicalName,
|
||||
Tuple2<
|
||||
List<TypeParameter>,
|
||||
Tuple4<List<VariableDeclaration>, List<VariableDeclaration>,
|
||||
List<VariableDeclaration>, List<DartType>>>>,
|
||||
RedirectingFactoryConstructor>(
|
||||
(w) => Tuple4(
|
||||
w.name,
|
||||
w.flags,
|
||||
|
@ -1586,7 +1649,7 @@ TextSerializer<RedirectingFactoryConstructor>
|
|||
.toList(),
|
||||
w.namedParameters,
|
||||
w.typeArguments))),
|
||||
(u) => RedirectingFactoryConstructor(u.third,
|
||||
(u) => RedirectingFactoryConstructor(u.third.reference,
|
||||
name: u.first,
|
||||
typeParameters: u.fourth.first,
|
||||
positionalParameters:
|
||||
|
@ -1609,10 +1672,11 @@ TextSerializer<RedirectingFactoryConstructor>
|
|||
|
||||
Case<Member> memberSerializer = new Case.uninitialized(const MemberTagger());
|
||||
|
||||
TextSerializer<LibraryPart> libraryPartSerializer = Wrapped(
|
||||
(w) => Tuple2(w.partUri, w.annotations),
|
||||
(u) => LibraryPart(u.second, u.first),
|
||||
Tuple2Serializer(DartString(), ListSerializer(expressionSerializer)));
|
||||
TextSerializer<LibraryPart> libraryPartSerializer =
|
||||
Wrapped<Tuple2<String, List<Expression>>, LibraryPart>(
|
||||
(w) => Tuple2(w.partUri, w.annotations),
|
||||
(u) => LibraryPart(u.second, u.first),
|
||||
Tuple2Serializer(DartString(), ListSerializer(expressionSerializer)));
|
||||
|
||||
class LibraryTagger implements Tagger<Library> {
|
||||
const LibraryTagger();
|
||||
|
@ -1638,16 +1702,16 @@ class LibraryFlagTagger implements Tagger<int> {
|
|||
}
|
||||
}
|
||||
|
||||
TextSerializer<int> libraryFlagsSerializer = Wrapped(
|
||||
TextSerializer<int> libraryFlagsSerializer = Wrapped<List<int>, int>(
|
||||
(w) => List.generate(30, (i) => w & (1 << i)).where((f) => f != 0).toList(),
|
||||
(u) => u.fold(0, (fs, f) => fs |= f),
|
||||
ListSerializer(Case(
|
||||
LibraryFlagTagger(),
|
||||
Map.fromIterable(libraryFlagToName.entries,
|
||||
key: (e) => e.value,
|
||||
value: (e) => Wrapped((_) => null, (_) => e.key, Nothing())))));
|
||||
ListSerializer(
|
||||
Case(LibraryFlagTagger(), convertFlagsMap(libraryFlagToName))));
|
||||
|
||||
TextSerializer<Library> librarySerializer = new Wrapped(
|
||||
TextSerializer<Library> librarySerializer = new Wrapped<
|
||||
Tuple7<Uri, int, List<LibraryPart>, List<Member>, List<Class>,
|
||||
List<Typedef>, List<Extension>>,
|
||||
Library>(
|
||||
(w) => Tuple7(w.importUri, w.flags, w.parts, [...w.fields, ...w.procedures],
|
||||
w.classes, w.typedefs, w.extensions),
|
||||
(u) => Library(u.first,
|
||||
|
@ -1669,16 +1733,17 @@ TextSerializer<Library> librarySerializer = new Wrapped(
|
|||
ListSerializer(extensionSerializer)),
|
||||
);
|
||||
|
||||
TextSerializer<Component> componentSerializer = Wrapped(
|
||||
(w) => w.libraries,
|
||||
(u) => Component(nameRoot: CanonicalName.root(), libraries: u),
|
||||
ListSerializer(librarySerializer));
|
||||
TextSerializer<Component> componentSerializer =
|
||||
Wrapped<List<Library>, Component>(
|
||||
(w) => w.libraries,
|
||||
(u) => Component(nameRoot: CanonicalName.root(), libraries: u),
|
||||
ListSerializer(librarySerializer));
|
||||
|
||||
class ShowHideTagger implements Tagger<Combinator> {
|
||||
String tag(Combinator node) => node.isShow ? "show" : "hide";
|
||||
}
|
||||
|
||||
TextSerializer<Combinator> showSerializer = Wrapped(
|
||||
TextSerializer<Combinator> showSerializer = Wrapped<List<String>, Combinator>(
|
||||
(c) => c.names, (ns) => Combinator(true, ns), ListSerializer(DartString()));
|
||||
|
||||
TextSerializer<Combinator> hideSerializer = Wrapped((c) => c.names,
|
||||
|
@ -1689,7 +1754,9 @@ Case<Combinator> showHideSerializer = new Case(ShowHideTagger(), {
|
|||
"hide": hideSerializer,
|
||||
});
|
||||
|
||||
TextSerializer<LibraryDependency> libraryDependencySerializer = Wrapped(
|
||||
TextSerializer<LibraryDependency> libraryDependencySerializer = Wrapped<
|
||||
Tuple5<CanonicalName, String, List<Combinator>, int, List<Expression>>,
|
||||
LibraryDependency>(
|
||||
(ld) => Tuple5(ld.importedLibraryReference.canonicalName, ld.name,
|
||||
ld.combinators, ld.flags, ld.annotations),
|
||||
(t) => LibraryDependency.byReference(
|
||||
|
@ -1725,64 +1792,78 @@ class ConstantTagger extends ConstantVisitor<String>
|
|||
}
|
||||
|
||||
TextSerializer<BoolConstant> boolConstantSerializer =
|
||||
Wrapped((w) => w.value, (u) => BoolConstant(u), DartBool());
|
||||
Wrapped<bool, BoolConstant>(
|
||||
(w) => w.value, (u) => BoolConstant(u), DartBool());
|
||||
|
||||
TextSerializer<DoubleConstant> doubleConstantSerializer =
|
||||
Wrapped((w) => w.value, (u) => DoubleConstant(u), DartDouble());
|
||||
Wrapped<double, DoubleConstant>(
|
||||
(w) => w.value, (u) => DoubleConstant(u), DartDouble());
|
||||
|
||||
TextSerializer<IntConstant> intConstantSerializer =
|
||||
Wrapped((w) => w.value, (u) => IntConstant(u), DartInt());
|
||||
Wrapped<int, IntConstant>((w) => w.value, (u) => IntConstant(u), DartInt());
|
||||
|
||||
TextSerializer<ListConstant> listConstantSerializer = Wrapped(
|
||||
(w) => Tuple2(w.typeArgument, w.entries),
|
||||
(u) => ListConstant(u.first, u.second),
|
||||
Tuple2Serializer(dartTypeSerializer, ListSerializer(constantSerializer)));
|
||||
TextSerializer<ListConstant> listConstantSerializer =
|
||||
Wrapped<Tuple2<DartType, List<Constant>>, ListConstant>(
|
||||
(w) => Tuple2(w.typeArgument, w.entries),
|
||||
(u) => ListConstant(u.first, u.second),
|
||||
Tuple2Serializer(
|
||||
dartTypeSerializer, ListSerializer(constantSerializer)));
|
||||
|
||||
TextSerializer<MapConstant> mapConstantSerializer = Wrapped(
|
||||
(w) => Tuple3(w.keyType, w.valueType, w.entries),
|
||||
(u) => MapConstant(u.first, u.second, u.third),
|
||||
Tuple3Serializer(
|
||||
dartTypeSerializer,
|
||||
dartTypeSerializer,
|
||||
Zip(
|
||||
Tuple2Serializer(ListSerializer(constantSerializer),
|
||||
ListSerializer(constantSerializer)),
|
||||
(k, v) => ConstantMapEntry(k, v),
|
||||
(z) => Tuple2(z.key, z.value))));
|
||||
TextSerializer<MapConstant> mapConstantSerializer =
|
||||
Wrapped<Tuple3<DartType, DartType, List<ConstantMapEntry>>, MapConstant>(
|
||||
(w) => Tuple3(w.keyType, w.valueType, w.entries),
|
||||
(u) => MapConstant(u.first, u.second, u.third),
|
||||
Tuple3Serializer(
|
||||
dartTypeSerializer,
|
||||
dartTypeSerializer,
|
||||
Zip(
|
||||
Tuple2Serializer(ListSerializer(constantSerializer),
|
||||
ListSerializer(constantSerializer)),
|
||||
(k, v) => ConstantMapEntry(k, v),
|
||||
(z) => Tuple2(z.key, z.value))));
|
||||
|
||||
TextSerializer<NullConstant> nullConstantSerializer =
|
||||
Wrapped((w) => null, (u) => NullConstant(), Nothing());
|
||||
Wrapped<void, NullConstant>((w) => null, (u) => NullConstant(), Nothing());
|
||||
|
||||
TextSerializer<PartialInstantiationConstant>
|
||||
partialInstantiationConstantSerializer = Wrapped(
|
||||
partialInstantiationConstantSerializer = Wrapped<
|
||||
Tuple2<TearOffConstant, List<DartType>>,
|
||||
PartialInstantiationConstant>(
|
||||
(w) => Tuple2(w.tearOffConstant, w.types),
|
||||
(u) => PartialInstantiationConstant(u.first, u.second),
|
||||
Tuple2Serializer(
|
||||
tearOffConstantSerializer, ListSerializer(dartTypeSerializer)));
|
||||
|
||||
TextSerializer<SetConstant> setConstantSerializer = Wrapped(
|
||||
(w) => Tuple2(w.typeArgument, w.entries),
|
||||
(u) => SetConstant(u.first, u.second),
|
||||
Tuple2Serializer(dartTypeSerializer, ListSerializer(constantSerializer)));
|
||||
TextSerializer<SetConstant> setConstantSerializer =
|
||||
Wrapped<Tuple2<DartType, List<Constant>>, SetConstant>(
|
||||
(w) => Tuple2(w.typeArgument, w.entries),
|
||||
(u) => SetConstant(u.first, u.second),
|
||||
Tuple2Serializer(
|
||||
dartTypeSerializer, ListSerializer(constantSerializer)));
|
||||
|
||||
TextSerializer<StringConstant> stringConstantSerializer =
|
||||
Wrapped((w) => w.value, (u) => StringConstant(u), DartString());
|
||||
Wrapped<String, StringConstant>(
|
||||
(w) => w.value, (u) => StringConstant(u), DartString());
|
||||
|
||||
TextSerializer<SymbolConstant> symbolConstantSerializer = Wrapped(
|
||||
(w) => Tuple2(w.name, w.libraryReference?.canonicalName),
|
||||
(u) => SymbolConstant(u.first, u.second?.getReference()),
|
||||
Tuple2Serializer(DartString(), Optional(CanonicalNameSerializer())));
|
||||
TextSerializer<SymbolConstant> symbolConstantSerializer =
|
||||
Wrapped<Tuple2<String, CanonicalName>, SymbolConstant>(
|
||||
(w) => Tuple2(w.name, w.libraryReference?.canonicalName),
|
||||
(u) => SymbolConstant(u.first, u.second?.getReference()),
|
||||
Tuple2Serializer(DartString(), Optional(CanonicalNameSerializer())));
|
||||
|
||||
TextSerializer<TearOffConstant> tearOffConstantSerializer = Wrapped(
|
||||
(w) => w.procedureReference.canonicalName,
|
||||
(u) => TearOffConstant.byReference(u.getReference()),
|
||||
CanonicalNameSerializer());
|
||||
TextSerializer<TearOffConstant> tearOffConstantSerializer =
|
||||
Wrapped<CanonicalName, TearOffConstant>(
|
||||
(w) => w.procedureReference.canonicalName,
|
||||
(u) => TearOffConstant.byReference(u.getReference()),
|
||||
CanonicalNameSerializer());
|
||||
|
||||
TextSerializer<TypeLiteralConstant> typeLiteralConstantSerializer =
|
||||
Wrapped((w) => w.type, (u) => TypeLiteralConstant(u), dartTypeSerializer);
|
||||
Wrapped<DartType, TypeLiteralConstant>(
|
||||
(w) => w.type, (u) => TypeLiteralConstant(u), dartTypeSerializer);
|
||||
|
||||
TextSerializer<UnevaluatedConstant> unevaluatedConstantSerializer = Wrapped(
|
||||
(w) => w.expression, (u) => UnevaluatedConstant(u), expressionSerializer);
|
||||
TextSerializer<UnevaluatedConstant> unevaluatedConstantSerializer =
|
||||
Wrapped<Expression, UnevaluatedConstant>((w) => w.expression,
|
||||
(u) => UnevaluatedConstant(u), expressionSerializer);
|
||||
|
||||
TextSerializer<InstanceConstant> instanceConstantSerializer =
|
||||
Wrapped<
|
||||
|
@ -1826,42 +1907,46 @@ class InitializerTagger implements Tagger<Initializer> {
|
|||
}
|
||||
}
|
||||
|
||||
TextSerializer<AssertInitializer> assertInitializerSerializer = Wrapped(
|
||||
(w) => w.statement, (u) => AssertInitializer(u), statementSerializer);
|
||||
TextSerializer<AssertInitializer> assertInitializerSerializer =
|
||||
Wrapped<Statement, AssertInitializer>(
|
||||
(w) => w.statement, (u) => AssertInitializer(u), statementSerializer);
|
||||
|
||||
TextSerializer<FieldInitializer> fieldInitializerSerializer = Wrapped(
|
||||
(w) => Tuple2(w.fieldReference.canonicalName, w.value),
|
||||
(u) => FieldInitializer.byReference(u.first.getReference(), u.second),
|
||||
Tuple2Serializer(CanonicalNameSerializer(), expressionSerializer));
|
||||
TextSerializer<FieldInitializer> fieldInitializerSerializer =
|
||||
Wrapped<Tuple2<CanonicalName, Expression>, FieldInitializer>(
|
||||
(w) => Tuple2(w.fieldReference.canonicalName, w.value),
|
||||
(u) => FieldInitializer.byReference(u.first.getReference(), u.second),
|
||||
Tuple2Serializer(CanonicalNameSerializer(), expressionSerializer));
|
||||
|
||||
TextSerializer<InvalidInitializer> invalidInitializerSerializer =
|
||||
Wrapped((_) => null, (_) => InvalidInitializer(), Nothing());
|
||||
Wrapped<void, InvalidInitializer>(
|
||||
(_) => null, (_) => InvalidInitializer(), Nothing());
|
||||
|
||||
TextSerializer<LocalInitializer> localInitializerSerializer = Wrapped(
|
||||
(w) => w.variable,
|
||||
(u) => LocalInitializer(u),
|
||||
variableDeclarationSerializer);
|
||||
TextSerializer<LocalInitializer> localInitializerSerializer =
|
||||
Wrapped<VariableDeclaration, LocalInitializer>((w) => w.variable,
|
||||
(u) => LocalInitializer(u), variableDeclarationSerializer);
|
||||
|
||||
TextSerializer<RedirectingInitializer> redirectingInitializerSerializer =
|
||||
Wrapped(
|
||||
Wrapped<Tuple2<CanonicalName, Arguments>, RedirectingInitializer>(
|
||||
(w) => Tuple2(w.targetReference.canonicalName, w.arguments),
|
||||
(u) => RedirectingInitializer.byReference(
|
||||
u.first.getReference(), u.second),
|
||||
Tuple2Serializer(CanonicalNameSerializer(), argumentsSerializer));
|
||||
|
||||
TextSerializer<SuperInitializer> superInitializerSerializer = Wrapped(
|
||||
(w) => Tuple2(w.targetReference.canonicalName, w.arguments),
|
||||
(u) => SuperInitializer.byReference(u.first.getReference(), u.second),
|
||||
Tuple2Serializer(CanonicalNameSerializer(), argumentsSerializer));
|
||||
TextSerializer<SuperInitializer> superInitializerSerializer =
|
||||
Wrapped<Tuple2<CanonicalName, Arguments>, SuperInitializer>(
|
||||
(w) => Tuple2(w.targetReference.canonicalName, w.arguments),
|
||||
(u) => SuperInitializer.byReference(u.first.getReference(), u.second),
|
||||
Tuple2Serializer(CanonicalNameSerializer(), argumentsSerializer));
|
||||
|
||||
Case<Initializer> initializerSerializer =
|
||||
Case.uninitialized(InitializerTagger());
|
||||
|
||||
TextSerializer<Supertype> supertypeSerializer = Wrapped(
|
||||
(w) => Tuple2(w.className.canonicalName, w.typeArguments),
|
||||
(u) => Supertype.byReference(u.first.getReference(), u.second),
|
||||
Tuple2Serializer(
|
||||
CanonicalNameSerializer(), ListSerializer(dartTypeSerializer)));
|
||||
TextSerializer<Supertype> supertypeSerializer =
|
||||
Wrapped<Tuple2<CanonicalName, List<DartType>>, Supertype>(
|
||||
(w) => Tuple2(w.className.canonicalName, w.typeArguments),
|
||||
(u) => Supertype.byReference(u.first.getReference(), u.second),
|
||||
Tuple2Serializer(
|
||||
CanonicalNameSerializer(), ListSerializer(dartTypeSerializer)));
|
||||
|
||||
const Map<int, String> classFlagToName = const {
|
||||
Class.FlagAbstract: "abstract",
|
||||
|
@ -1881,16 +1966,20 @@ class ClassFlagTagger implements Tagger<int> {
|
|||
}
|
||||
}
|
||||
|
||||
TextSerializer<int> classFlagsSerializer = Wrapped(
|
||||
TextSerializer<int> classFlagsSerializer = Wrapped<List<int>, int>(
|
||||
(w) => List.generate(30, (i) => w & (1 << i)).where((f) => f != 0).toList(),
|
||||
(u) => u.fold(0, (fs, f) => fs |= f),
|
||||
ListSerializer(Case(
|
||||
ClassFlagTagger(),
|
||||
Map.fromIterable(classFlagToName.entries,
|
||||
key: (e) => e.value,
|
||||
value: (e) => Wrapped((_) => null, (_) => e.key, Nothing())))));
|
||||
ListSerializer(Case(ClassFlagTagger(), convertFlagsMap(classFlagToName))));
|
||||
|
||||
TextSerializer<Class> classSerializer = Wrapped(
|
||||
TextSerializer<Class> classSerializer = Wrapped<
|
||||
Tuple3<
|
||||
String,
|
||||
int,
|
||||
Tuple2<
|
||||
List<TypeParameter>,
|
||||
/* Comment added to guide formatting. */
|
||||
Tuple4<Supertype, Supertype, List<Supertype>, List<Member>>>>,
|
||||
Class>(
|
||||
(w) => Tuple3(
|
||||
w.name,
|
||||
w.flags,
|
||||
|
@ -1928,11 +2017,13 @@ TextSerializer<Class> classSerializer = Wrapped(
|
|||
ListSerializer(supertypeSerializer),
|
||||
ListSerializer(memberSerializer)))));
|
||||
|
||||
TextSerializer<Typedef> typedefSerializer = Wrapped(
|
||||
(w) => Tuple2(w.name, Tuple2(w.typeParameters, w.type)),
|
||||
(u) => Typedef(u.first, u.second.second, typeParameters: u.second.first),
|
||||
Tuple2Serializer(
|
||||
DartString(), Bind(typeParametersSerializer, dartTypeSerializer)));
|
||||
TextSerializer<Typedef> typedefSerializer =
|
||||
Wrapped<Tuple2<String, Tuple2<List<TypeParameter>, DartType>>, Typedef>(
|
||||
(w) => Tuple2(w.name, Tuple2(w.typeParameters, w.type)),
|
||||
(u) =>
|
||||
Typedef(u.first, u.second.second, typeParameters: u.second.first),
|
||||
Tuple2Serializer(
|
||||
DartString(), Bind(typeParametersSerializer, dartTypeSerializer)));
|
||||
|
||||
const Map<int, String> extensionMemberDescriptorFlagToName = const {
|
||||
ExtensionMemberDescriptor.FlagStatic: "static",
|
||||
|
@ -1948,14 +2039,14 @@ class ExtensionMemberDescriptorFlagTagger implements Tagger<int> {
|
|||
}
|
||||
}
|
||||
|
||||
TextSerializer<int> extensionMemberDescriptorFlagsSerializer = Wrapped(
|
||||
(w) => List.generate(30, (i) => w & (1 << i)).where((f) => f != 0).toList(),
|
||||
(u) => u.fold(0, (fs, f) => fs |= f),
|
||||
ListSerializer(Case(
|
||||
ExtensionMemberDescriptorFlagTagger(),
|
||||
Map.fromIterable(extensionMemberDescriptorFlagToName.entries,
|
||||
key: (e) => e.value,
|
||||
value: (e) => Wrapped((_) => null, (_) => e.key, Nothing())))));
|
||||
TextSerializer<int> extensionMemberDescriptorFlagsSerializer =
|
||||
Wrapped<List<int>, int>(
|
||||
(w) => List.generate(30, (i) => w & (1 << i))
|
||||
.where((f) => f != 0)
|
||||
.toList(),
|
||||
(u) => u.fold(0, (fs, f) => fs |= f),
|
||||
ListSerializer(Case(ExtensionMemberDescriptorFlagTagger(),
|
||||
convertFlagsMap(extensionMemberDescriptorFlagToName))));
|
||||
|
||||
const Map<ExtensionMemberKind, String> extensionMemberKindToName = const {
|
||||
ExtensionMemberKind.Field: "field",
|
||||
|
@ -1976,13 +2067,11 @@ class ExtensionMemberKindTagger implements Tagger<ExtensionMemberKind> {
|
|||
}
|
||||
|
||||
TextSerializer<ExtensionMemberKind> extensionMemberKindSerializer = Case(
|
||||
ExtensionMemberKindTagger(),
|
||||
Map.fromIterable(extensionMemberKindToName.entries,
|
||||
key: (e) => e.value,
|
||||
value: (e) => Wrapped((_) => null, (_) => e.key, Nothing())));
|
||||
ExtensionMemberKindTagger(), convertFlagsMap(extensionMemberKindToName));
|
||||
|
||||
TextSerializer<ExtensionMemberDescriptor> extensionMemberDescriptorSerializer =
|
||||
Wrapped(
|
||||
Wrapped<Tuple4<Name, ExtensionMemberKind, int, CanonicalName>,
|
||||
ExtensionMemberDescriptor>(
|
||||
(w) => Tuple4(w.name, w.kind, w.flags, w.member.canonicalName),
|
||||
(u) => ExtensionMemberDescriptor()
|
||||
..name = u.first
|
||||
|
@ -1995,7 +2084,10 @@ TextSerializer<ExtensionMemberDescriptor> extensionMemberDescriptorSerializer =
|
|||
extensionMemberDescriptorFlagsSerializer,
|
||||
CanonicalNameSerializer()));
|
||||
|
||||
TextSerializer<Extension> extensionSerializer = Wrapped(
|
||||
TextSerializer<Extension> extensionSerializer = Wrapped<
|
||||
Tuple3<String, Tuple2<List<TypeParameter>, DartType>,
|
||||
List<ExtensionMemberDescriptor>>,
|
||||
Extension>(
|
||||
(w) => Tuple3(w.name, Tuple2(w.typeParameters, w.onType), w.members),
|
||||
(u) => Extension(
|
||||
name: u.first,
|
||||
|
@ -2135,3 +2227,15 @@ void initializeSerializers() {
|
|||
"super": superInitializerSerializer,
|
||||
});
|
||||
}
|
||||
|
||||
Map<String, Wrapped<void, T>> convertFlagsMap<T>(Map<T, String> map) {
|
||||
return map.entries.toMap(
|
||||
key: (e) => e.value,
|
||||
value: (e) => Wrapped((_) => null, (_) => e.key, Nothing()));
|
||||
}
|
||||
|
||||
extension MapFromIterable<E> on Iterable<E> {
|
||||
Map<K, V> toMap<K, V>({K Function(E) key, V Function(E) value}) {
|
||||
return {for (E e in this) key(e): value(e)};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ name: kernel
|
|||
publish_to: none
|
||||
|
||||
environment:
|
||||
sdk: '>=2.2.2 <3.0.0'
|
||||
sdk: '>=2.6.0 <3.0.0'
|
||||
dependencies:
|
||||
meta: ^1.0.0
|
||||
dev_dependencies:
|
||||
|
|
Loading…
Reference in a new issue