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

Side by Side Diff: pkg/analyzer/lib/src/summary/fasta/summary_builder.dart

Issue 2755013003: Remove unneeded `strong_mode_down_cast_composite` ignores. (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « no previous file | pkg/analyzer/tool/summary/mini_ast.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 /// Logic to build unlinked summaries. 5 /// Logic to build unlinked summaries.
6 library summary.src.summary_builder; 6 library summary.src.summary_builder;
7 7
8 import 'package:front_end/src/fasta/parser/class_member_parser.dart'; 8 import 'package:front_end/src/fasta/parser/class_member_parser.dart';
9 import 'package:front_end/src/fasta/parser/identifier_context.dart'; 9 import 'package:front_end/src/fasta/parser/identifier_context.dart';
10 import 'package:front_end/src/fasta/parser/parser.dart'; 10 import 'package:front_end/src/fasta/parser/parser.dart';
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 _withinCascades--; 249 _withinCascades--;
250 throw new UnimplementedError(); // TODO(paulberry): fix the code below. 250 throw new UnimplementedError(); // TODO(paulberry): fix the code below.
251 // _endCascade(); 251 // _endCascade();
252 } 252 }
253 253
254 void endConstructorReference( 254 void endConstructorReference(
255 Token start, Token periodBeforeName, Token endToken) { 255 Token start, Token periodBeforeName, Token endToken) {
256 debugEvent("ConstructorReference $start $periodBeforeName"); 256 debugEvent("ConstructorReference $start $periodBeforeName");
257 Ref ctorName = popIfNotNull(periodBeforeName); 257 Ref ctorName = popIfNotNull(periodBeforeName);
258 assert(ctorName?.prefix == null); 258 assert(ctorName?.prefix == null);
259 // ignore: strong_mode_down_cast_composite
260 List<TypeRef> typeArgs = pop(); 259 List<TypeRef> typeArgs = pop();
261 Ref type = pop(); 260 Ref type = pop();
262 push(new ConstructorName(new TypeRef(type, typeArgs), ctorName?.name)); 261 push(new ConstructorName(new TypeRef(type, typeArgs), ctorName?.name));
263 } 262 }
264 263
265 void endFormalParameter( 264 void endFormalParameter(
266 Token covariantKeyword, Token thisKeyword, FormalParameterType kind) { 265 Token covariantKeyword, Token thisKeyword, FormalParameterType kind) {
267 debugEvent("FormalParameter"); 266 debugEvent("FormalParameter");
268 assert(ignore); 267 assert(ignore);
269 } 268 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 void endReturnStatement(hasValue, Token begin, Token end) { 314 void endReturnStatement(hasValue, Token begin, Token end) {
316 debugEvent("ReturnStatement"); 315 debugEvent("ReturnStatement");
317 assert(ignore); 316 assert(ignore);
318 } 317 }
319 318
320 // type-arguments are expected to be type references passed to constructors 319 // type-arguments are expected to be type references passed to constructors
321 // and generic methods, we need them to model instantiations. 320 // and generic methods, we need them to model instantiations.
322 void endSend(Token beginToken, Token endToken) { 321 void endSend(Token beginToken, Token endToken) {
323 debugEvent("EndSend"); 322 debugEvent("EndSend");
324 if (ignore) return; 323 if (ignore) return;
325 // ignore: strong_mode_down_cast_composite
326 List<Expression> args = pop(); 324 List<Expression> args = pop();
327 if (args != null) { 325 if (args != null) {
328 /* var typeArgs = */ pop(); 326 /* var typeArgs = */ pop();
329 var receiver = pop(); 327 var receiver = pop();
330 // TODO(sigmund): consider making identical a binary operator. 328 // TODO(sigmund): consider making identical a binary operator.
331 if (receiver is Ref && receiver.name == 'identical') { 329 if (receiver is Ref && receiver.name == 'identical') {
332 assert(receiver.prefix == null); 330 assert(receiver.prefix == null);
333 assert(args.length == 2); 331 assert(args.length == 2);
334 push(new Identical(args[0], args[1])); 332 push(new Identical(args[0], args[1]));
335 return; 333 return;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 push(new Conditional(cond, trueBranch, falseBranch)); 405 push(new Conditional(cond, trueBranch, falseBranch));
408 } 406 }
409 407
410 void handleConstExpression(Token token) { 408 void handleConstExpression(Token token) {
411 debugEvent("ConstExpression"); 409 debugEvent("ConstExpression");
412 if (ignore) return; 410 if (ignore) return;
413 List args = pop(); 411 List args = pop();
414 var constructorName = pop(); 412 var constructorName = pop();
415 var positional = args.where((a) => a is! NamedArg).toList(); 413 var positional = args.where((a) => a is! NamedArg).toList();
416 var named = args.where((a) => a is NamedArg).toList(); 414 var named = args.where((a) => a is NamedArg).toList();
417 // ignore: strong_mode_down_cast_composite
418 push(new ConstCreation(constructorName, positional, named)); 415 push(new ConstCreation(constructorName, positional, named));
419 } 416 }
420 417
421 void handleIdentifier(Token token, IdentifierContext context) { 418 void handleIdentifier(Token token, IdentifierContext context) {
422 debugEvent("Identifier"); 419 debugEvent("Identifier");
423 if (ignore) return; 420 if (ignore) return;
424 push(new Ref(token.lexeme)); 421 push(new Ref(token.lexeme));
425 } 422 }
426 423
427 void handleIsOperator(Token operator, Token not, Token endToken) { 424 void handleIsOperator(Token operator, Token not, Token endToken) {
(...skipping 17 matching lines...) Expand all
445 void handleLiteralInt(Token token) { 442 void handleLiteralInt(Token token) {
446 debugEvent("LiteralInt"); 443 debugEvent("LiteralInt");
447 if (ignore) return; 444 if (ignore) return;
448 push(new IntLiteral(int.parse(token.lexeme))); 445 push(new IntLiteral(int.parse(token.lexeme)));
449 } 446 }
450 447
451 void handleLiteralList(count, begin, constKeyword, end) { 448 void handleLiteralList(count, begin, constKeyword, end) {
452 debugEvent("LiteralList"); 449 debugEvent("LiteralList");
453 if (ignore) return; 450 if (ignore) return;
454 var values = popList(count) ?? const <Expression>[]; 451 var values = popList(count) ?? const <Expression>[];
455 // ignore: strong_mode_down_cast_composite
456 List<TypeRef> typeArguments = pop(); 452 List<TypeRef> typeArguments = pop();
457 var type = typeArguments?.single; 453 var type = typeArguments?.single;
458 // ignore: strong_mode_down_cast_composite
459 push(new ListLiteral(type, values, constKeyword != null)); 454 push(new ListLiteral(type, values, constKeyword != null));
460 } 455 }
461 456
462 void handleLiteralMap(count, begin, constKeyword, end) { 457 void handleLiteralMap(count, begin, constKeyword, end) {
463 debugEvent('LiteralMap'); 458 debugEvent('LiteralMap');
464 if (ignore) return; 459 if (ignore) return;
465 var values = popList(count) ?? const <KeyValuePair>[]; 460 var values = popList(count) ?? const <KeyValuePair>[];
466 var typeArgs = pop() ?? const <TypeRef>[]; 461 var typeArgs = pop() ?? const <TypeRef>[];
467 // ignore: strong_mode_down_cast_composite
468 push(new MapLiteral(typeArgs, values, constKeyword != null)); 462 push(new MapLiteral(typeArgs, values, constKeyword != null));
469 } 463 }
470 464
471 void handleLiteralNull(Token token) { 465 void handleLiteralNull(Token token) {
472 debugEvent("LiteralNull"); 466 debugEvent("LiteralNull");
473 if (ignore) return; 467 if (ignore) return;
474 push(new NullLiteral()); 468 push(new NullLiteral());
475 } 469 }
476 470
477 void handleModifier(Token token) { 471 void handleModifier(Token token) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 542
549 void handleStringPart(token) { 543 void handleStringPart(token) {
550 debugEvent("handleStringPart"); 544 debugEvent("handleStringPart");
551 if (ignore) return; 545 if (ignore) return;
552 push(new StringLiteral(token.lexeme)); 546 push(new StringLiteral(token.lexeme));
553 } 547 }
554 548
555 void handleType(Token beginToken, Token endToken) { 549 void handleType(Token beginToken, Token endToken) {
556 debugEvent("Type"); 550 debugEvent("Type");
557 if (ignore) return; 551 if (ignore) return;
558 // ignore: strong_mode_down_cast_composite
559 List<TypeRef> arguments = pop(); 552 List<TypeRef> arguments = pop();
560 Ref name = pop(); 553 Ref name = pop();
561 push(new TypeRef(name, arguments)); 554 push(new TypeRef(name, arguments));
562 } 555 }
563 556
564 void handleUnaryPrefixExpression(Token operator) { 557 void handleUnaryPrefixExpression(Token operator) {
565 debugEvent("UnaryPrefix"); 558 debugEvent("UnaryPrefix");
566 if (ignore) return; 559 if (ignore) return;
567 push(new Unary(pop(), operator.kind)); 560 push(new Unary(pop(), operator.kind));
568 } 561 }
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 } 849 }
857 850
858 void endClassDeclaration( 851 void endClassDeclaration(
859 int interfacesCount, 852 int interfacesCount,
860 Token beginToken, 853 Token beginToken,
861 Token classKeyword, 854 Token classKeyword,
862 Token extendsKeyword, 855 Token extendsKeyword,
863 Token implementsKeyword, 856 Token implementsKeyword,
864 Token endToken) { 857 Token endToken) {
865 debugEvent("endClassDeclaration"); 858 debugEvent("endClassDeclaration");
866 // ignore: strong_mode_down_cast_composite
867 List<EntityRefBuilder> interfaces = popList(interfacesCount); 859 List<EntityRefBuilder> interfaces = popList(interfacesCount);
868 EntityRef supertype = pop(); 860 EntityRef supertype = pop();
869 // ignore: strong_mode_down_cast_composite
870 List<UnlinkedTypeParamBuilder> typeVariables = pop(); 861 List<UnlinkedTypeParamBuilder> typeVariables = pop();
871 String name = pop(); 862 String name = pop();
872 int modifiers = pop(); 863 int modifiers = pop();
873 List metadata = pop(); 864 List metadata = pop();
874 checkEmpty(); 865 checkEmpty();
875 866
876 ClassScope s = scope; 867 ClassScope s = scope;
877 s.className = name; 868 s.className = name;
878 s.currentClass 869 s.currentClass
879 ..name = name 870 ..name = name
880 ..isAbstract = modifiers & _abstract_flag != 0 871 ..isAbstract = modifiers & _abstract_flag != 0
881 // ignore: strong_mode_down_cast_composite
882 ..annotations = metadata 872 ..annotations = metadata
883 ..typeParameters = typeVariables 873 ..typeParameters = typeVariables
884 ..interfaces = interfaces; 874 ..interfaces = interfaces;
885 if (supertype != null) { 875 if (supertype != null) {
886 s.currentClass.supertype = supertype; 876 s.currentClass.supertype = supertype;
887 } else { 877 } else {
888 s.currentClass.hasNoSupertype = isCoreLibrary && name == 'Object'; 878 s.currentClass.hasNoSupertype = isCoreLibrary && name == 'Object';
889 } 879 }
890 scope = scope.parent; 880 scope = scope.parent;
891 topScope.unit.classes.add(s.currentClass); 881 topScope.unit.classes.add(s.currentClass);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 var className = pop(); 928 var className = pop();
939 push(['ctor-ref:', className, typeArguments, ctorName]); 929 push(['ctor-ref:', className, typeArguments, ctorName]);
940 } 930 }
941 931
942 void endDottedName(count, firstIdentifier) { 932 void endDottedName(count, firstIdentifier) {
943 push(popList(count).join('.')); 933 push(popList(count).join('.'));
944 } 934 }
945 935
946 void endEnum(Token enumKeyword, Token endBrace, int count) { 936 void endEnum(Token enumKeyword, Token endBrace, int count) {
947 debugEvent("Enum"); 937 debugEvent("Enum");
948 // ignore: strong_mode_down_cast_composite
949 List<String> constants = popList(count); 938 List<String> constants = popList(count);
950 String name = pop(); 939 String name = pop();
951 List metadata = pop(); 940 List metadata = pop();
952 checkEmpty(); 941 checkEmpty();
953 EnumScope s = scope; 942 EnumScope s = scope;
954 scope = s.parent; 943 scope = s.parent;
955 s.currentEnum 944 s.currentEnum
956 ..name = name 945 ..name = name
957 // ignore: strong_mode_down_cast_composite
958 ..annotations = metadata; 946 ..annotations = metadata;
959 s.top.unit.enums.add(s.currentEnum); 947 s.top.unit.enums.add(s.currentEnum);
960 948
961 // public namespace: 949 // public namespace:
962 var e = new UnlinkedPublicNameBuilder( 950 var e = new UnlinkedPublicNameBuilder(
963 name: name, kind: ReferenceKind.classOrEnum, numTypeParameters: 0); 951 name: name, kind: ReferenceKind.classOrEnum, numTypeParameters: 0);
964 for (var s in constants) { 952 for (var s in constants) {
965 e.members.add(new UnlinkedPublicNameBuilder( 953 e.members.add(new UnlinkedPublicNameBuilder(
966 name: s, kind: ReferenceKind.propertyAccessor, numTypeParameters: 0)); 954 name: s, kind: ReferenceKind.propertyAccessor, numTypeParameters: 0));
967 } 955 }
968 topScope.publicNamespace.names.add(e); 956 topScope.publicNamespace.names.add(e);
969 } 957 }
970 958
971 void endExport(Token exportKeyword, Token semicolon) { 959 void endExport(Token exportKeyword, Token semicolon) {
972 debugEvent("Export"); 960 debugEvent("Export");
973 // ignore: strong_mode_down_cast_composite
974 List<UnlinkedCombinator> combinators = pop(); 961 List<UnlinkedCombinator> combinators = pop();
975 // ignore: strong_mode_down_cast_composite
976 List<UnlinkedConfiguration> conditionalUris = pop(); 962 List<UnlinkedConfiguration> conditionalUris = pop();
977 String uri = pop(); 963 String uri = pop();
978 // ignore: strong_mode_down_cast_composite
979 List<UnlinkedExpr> metadata = pop(); 964 List<UnlinkedExpr> metadata = pop();
980 topScope.unit.exports 965 topScope.unit.exports
981 .add(new UnlinkedExportNonPublicBuilder(annotations: metadata)); 966 .add(new UnlinkedExportNonPublicBuilder(annotations: metadata));
982 topScope.publicNamespace.exports.add(new UnlinkedExportPublicBuilder( 967 topScope.publicNamespace.exports.add(new UnlinkedExportPublicBuilder(
983 uri: uri, combinators: combinators, configurations: conditionalUris)); 968 uri: uri, combinators: combinators, configurations: conditionalUris));
984 checkEmpty(); 969 checkEmpty();
985 } 970 }
986 971
987 void endFactoryMethod( 972 void endFactoryMethod(
988 Token beginToken, Token factoryKeyword, Token endToken) { 973 Token beginToken, Token factoryKeyword, Token endToken) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 // TODO(sigmund): clean up? 1008 // TODO(sigmund): clean up?
1024 var nameOrFormal = pop(); 1009 var nameOrFormal = pop();
1025 if (nameOrFormal is String) { 1010 if (nameOrFormal is String) {
1026 EntityRef type = pop(); 1011 EntityRef type = pop();
1027 pop(); // Modifiers 1012 pop(); // Modifiers
1028 List metadata = pop(); 1013 List metadata = pop();
1029 push(new UnlinkedParamBuilder( 1014 push(new UnlinkedParamBuilder(
1030 name: nameOrFormal, 1015 name: nameOrFormal,
1031 kind: _nextParamKind, 1016 kind: _nextParamKind,
1032 inheritsCovariantSlot: slotIf(type == null), 1017 inheritsCovariantSlot: slotIf(type == null),
1033 // ignore: strong_mode_down_cast_composite
1034 annotations: metadata, 1018 annotations: metadata,
1035 isInitializingFormal: thisKeyword != null, 1019 isInitializingFormal: thisKeyword != null,
1036 type: type)); 1020 type: type));
1037 } else { 1021 } else {
1038 push(nameOrFormal); 1022 push(nameOrFormal);
1039 } 1023 }
1040 } 1024 }
1041 1025
1042 void endFormalParameters(int count, Token beginToken, Token endToken) { 1026 void endFormalParameters(int count, Token beginToken, Token endToken) {
1043 debugEvent("FormalParameters"); 1027 debugEvent("FormalParameters");
(...skipping 20 matching lines...) Expand all
1064 List typeVariables = pop(); 1048 List typeVariables = pop();
1065 String name = pop(); 1049 String name = pop();
1066 EntityRef returnType = pop(); 1050 EntityRef returnType = pop();
1067 List metadata = pop(); 1051 List metadata = pop();
1068 // print('TODO: type alias $name'); 1052 // print('TODO: type alias $name');
1069 checkEmpty(); 1053 checkEmpty();
1070 1054
1071 scope = scope.parent; 1055 scope = scope.parent;
1072 topScope.unit.typedefs.add(new UnlinkedTypedefBuilder( 1056 topScope.unit.typedefs.add(new UnlinkedTypedefBuilder(
1073 name: name, 1057 name: name,
1074 // ignore: strong_mode_down_cast_composite
1075 typeParameters: typeVariables, 1058 typeParameters: typeVariables,
1076 returnType: returnType, 1059 returnType: returnType,
1077 // ignore: strong_mode_down_cast_composite
1078 parameters: formals, 1060 parameters: formals,
1079 // ignore: strong_mode_down_cast_composite
1080 annotations: metadata)); 1061 annotations: metadata));
1081 1062
1082 _addNameIfPublic(name, ReferenceKind.typedef, typeVariables.length); 1063 _addNameIfPublic(name, ReferenceKind.typedef, typeVariables.length);
1083 } 1064 }
1084 1065
1085 void endFunctionTypedFormalParameter( 1066 void endFunctionTypedFormalParameter(
1086 Token covariantKeyword, Token thisKeyword, FormalParameterType kind) { 1067 Token covariantKeyword, Token thisKeyword, FormalParameterType kind) {
1087 debugEvent("FunctionTypedFormalParameter"); 1068 debugEvent("FunctionTypedFormalParameter");
1088 // ignore: strong_mode_down_cast_composite
1089 List<UnlinkedParamBuilder> formals = pop(); 1069 List<UnlinkedParamBuilder> formals = pop();
1090 if (formals != null) formals.forEach((p) => p.inheritsCovariantSlot = null); 1070 if (formals != null) formals.forEach((p) => p.inheritsCovariantSlot = null);
1091 1071
1092 /* List typeVariables = */ pop(); 1072 /* List typeVariables = */ pop();
1093 String name = pop(); 1073 String name = pop();
1094 EntityRef returnType = pop(); 1074 EntityRef returnType = pop();
1095 /* int modifiers = */ pop(); 1075 /* int modifiers = */ pop();
1096 List metadata = pop(); 1076 List metadata = pop();
1097 1077
1098 push(new UnlinkedParamBuilder( 1078 push(new UnlinkedParamBuilder(
1099 name: name, 1079 name: name,
1100 kind: _nextParamKind, 1080 kind: _nextParamKind,
1101 isFunctionTyped: true, 1081 isFunctionTyped: true,
1102 parameters: formals, 1082 parameters: formals,
1103 // ignore: strong_mode_down_cast_composite
1104 annotations: metadata, 1083 annotations: metadata,
1105 type: returnType)); 1084 type: returnType));
1106 } 1085 }
1107 1086
1108 void endHide(_) { 1087 void endHide(_) {
1109 // ignore: strong_mode_down_cast_composite
1110 push(new UnlinkedCombinatorBuilder(hides: pop())); 1088 push(new UnlinkedCombinatorBuilder(hides: pop()));
1111 } 1089 }
1112 1090
1113 void endIdentifierList(int count) { 1091 void endIdentifierList(int count) {
1114 debugEvent("endIdentifierList"); 1092 debugEvent("endIdentifierList");
1115 push(popList(count) ?? NullValue.IdentifierList); 1093 push(popList(count) ?? NullValue.IdentifierList);
1116 } 1094 }
1117 1095
1118 void endImport(Token importKeyword, Token deferredKeyword, Token asKeyword, 1096 void endImport(Token importKeyword, Token deferredKeyword, Token asKeyword,
1119 Token semicolon) { 1097 Token semicolon) {
1120 debugEvent("endImport"); 1098 debugEvent("endImport");
1121 // ignore: strong_mode_down_cast_composite
1122 List<UnlinkedCombinator> combinators = pop(); 1099 List<UnlinkedCombinator> combinators = pop();
1123 String prefix = popIfNotNull(asKeyword); 1100 String prefix = popIfNotNull(asKeyword);
1124 int prefixIndex = 1101 int prefixIndex =
1125 prefix == null ? null : topScope.serializeReference(null, prefix); 1102 prefix == null ? null : topScope.serializeReference(null, prefix);
1126 // ignore: strong_mode_down_cast_composite
1127 List<UnlinkedConfiguration> conditionalUris = pop(); 1103 List<UnlinkedConfiguration> conditionalUris = pop();
1128 String uri = pop(); 1104 String uri = pop();
1129 // ignore: strong_mode_down_cast_composite
1130 List<UnlinkedExpr> metadata = pop(); // metadata 1105 List<UnlinkedExpr> metadata = pop(); // metadata
1131 1106
1132 topScope.unit.imports.add(new UnlinkedImportBuilder( 1107 topScope.unit.imports.add(new UnlinkedImportBuilder(
1133 uri: uri, 1108 uri: uri,
1134 prefixReference: prefixIndex, 1109 prefixReference: prefixIndex,
1135 combinators: combinators, 1110 combinators: combinators,
1136 configurations: conditionalUris, 1111 configurations: conditionalUris,
1137 isDeferred: deferredKeyword != null, 1112 isDeferred: deferredKeyword != null,
1138 annotations: metadata, 1113 annotations: metadata,
1139 )); 1114 ));
1140 if (uri == 'dart:core') isDartCoreImported = true; 1115 if (uri == 'dart:core') isDartCoreImported = true;
1141 checkEmpty(); 1116 checkEmpty();
1142 } 1117 }
1143 1118
1144 void endInitializer(Token assignmentOperator) { 1119 void endInitializer(Token assignmentOperator) {
1145 // TODO(paulberry): add support for this. 1120 // TODO(paulberry): add support for this.
1146 debugEvent("Initializer $typeSeen $assignmentOperator"); 1121 debugEvent("Initializer $typeSeen $assignmentOperator");
1147 } 1122 }
1148 1123
1149 void endInitializers(int count, Token beginToken, Token endToken) { 1124 void endInitializers(int count, Token beginToken, Token endToken) {
1150 debugEvent("Initializers"); 1125 debugEvent("Initializers");
1151 // TODO(sigmund): include const-constructor initializers 1126 // TODO(sigmund): include const-constructor initializers
1152 } 1127 }
1153 1128
1154 void endLibraryName(Token libraryKeyword, Token semicolon) { 1129 void endLibraryName(Token libraryKeyword, Token semicolon) {
1155 debugEvent("endLibraryName"); 1130 debugEvent("endLibraryName");
1156 String name = pop(); 1131 String name = pop();
1157 // ignore: strong_mode_down_cast_composite
1158 List<UnlinkedExpr> metadata = pop(); // metadata 1132 List<UnlinkedExpr> metadata = pop(); // metadata
1159 1133
1160 topScope.unit.libraryName = name; 1134 topScope.unit.libraryName = name;
1161 topScope.unit.libraryAnnotations = metadata; 1135 topScope.unit.libraryAnnotations = metadata;
1162 if (name == 'dart.core') isCoreLibrary = true; 1136 if (name == 'dart.core') isCoreLibrary = true;
1163 } 1137 }
1164 1138
1165 void endLiteralString(int interpolationCount, Token endToken) { 1139 void endLiteralString(int interpolationCount, Token endToken) {
1166 assert(interpolationCount == 0); // TODO(sigmund): handle interpolation 1140 assert(interpolationCount == 0); // TODO(sigmund): handle interpolation
1167 } 1141 }
(...skipping 25 matching lines...) Expand all
1193 } 1167 }
1194 1168
1195 void endMetadataStar(int count, bool forParameter) { 1169 void endMetadataStar(int count, bool forParameter) {
1196 debugEvent("MetadataStar"); 1170 debugEvent("MetadataStar");
1197 push(popList(count) ?? NullValue.Metadata); 1171 push(popList(count) ?? NullValue.Metadata);
1198 } 1172 }
1199 1173
1200 void endMethod(Token getOrSet, Token beginToken, Token endToken) { 1174 void endMethod(Token getOrSet, Token beginToken, Token endToken) {
1201 debugEvent("Method"); 1175 debugEvent("Method");
1202 int asyncModifier = pop(); 1176 int asyncModifier = pop();
1203 // ignore: strong_mode_down_cast_composite
1204 List<UnlinkedParam> formals = pop(); 1177 List<UnlinkedParam> formals = pop();
1205 // ignore: strong_mode_down_cast_composite
1206 List<UnlinkedTypeParamBuilder> typeVariables = pop(); 1178 List<UnlinkedTypeParamBuilder> typeVariables = pop();
1207 String name = pop(); 1179 String name = pop();
1208 EntityRef returnType = pop(); 1180 EntityRef returnType = pop();
1209 int modifiers = pop(); 1181 int modifiers = pop();
1210 List metadata = pop(); 1182 List metadata = pop();
1211 1183
1212 ClassScope s = scope; 1184 ClassScope s = scope;
1213 bool isStatic = modifiers & _static_flag != 0; 1185 bool isStatic = modifiers & _static_flag != 0;
1214 bool isConst = modifiers & _const_flag != 0; 1186 bool isConst = modifiers & _const_flag != 0;
1215 bool isGetter = getOrSet == 'get'; 1187 bool isGetter = getOrSet == 'get';
(...skipping 20 matching lines...) Expand all
1236 isExternal: modifiers & _external_flag != 0, 1208 isExternal: modifiers & _external_flag != 0,
1237 isAbstract: modifiers & _abstract_flag != 0, 1209 isAbstract: modifiers & _abstract_flag != 0,
1238 isAsynchronous: asyncModifier & _async_flag != 0, 1210 isAsynchronous: asyncModifier & _async_flag != 0,
1239 isGenerator: asyncModifier & _star_flag != 0, 1211 isGenerator: asyncModifier & _star_flag != 0,
1240 isStatic: isStatic, 1212 isStatic: isStatic,
1241 isConst: isConst, 1213 isConst: isConst,
1242 constCycleSlot: slotIf(isConst), 1214 constCycleSlot: slotIf(isConst),
1243 typeParameters: typeVariables, 1215 typeParameters: typeVariables,
1244 returnType: returnType, 1216 returnType: returnType,
1245 parameters: formals, // TODO: add inferred slot to args 1217 parameters: formals, // TODO: add inferred slot to args
1246 // ignore: strong_mode_down_cast_composite
1247 annotations: metadata, 1218 annotations: metadata,
1248 inferredReturnTypeSlot: 1219 inferredReturnTypeSlot:
1249 slotIf(returnType == null && !isStatic && !isConstructor))); 1220 slotIf(returnType == null && !isStatic && !isConstructor)));
1250 1221
1251 if (isConstructor && name == '') return; 1222 if (isConstructor && name == '') return;
1252 if (_isPrivate(name)) return; 1223 if (_isPrivate(name)) return;
1253 if (isSetter || isOperator) return; 1224 if (isSetter || isOperator) return;
1254 if (!isStatic && !isConstructor) return; 1225 if (!isStatic && !isConstructor) return;
1255 s.publicName.members.add(new UnlinkedPublicNameBuilder( 1226 s.publicName.members.add(new UnlinkedPublicNameBuilder(
1256 name: name, 1227 name: name,
1257 kind: isGetter 1228 kind: isGetter
1258 ? ReferenceKind.propertyAccessor 1229 ? ReferenceKind.propertyAccessor
1259 : (isConstructor 1230 : (isConstructor
1260 ? ReferenceKind.constructor 1231 ? ReferenceKind.constructor
1261 : ReferenceKind.method), 1232 : ReferenceKind.method),
1262 numTypeParameters: typeVariables.length)); 1233 numTypeParameters: typeVariables.length));
1263 } 1234 }
1264 1235
1265 void endMixinApplication(Token withKeyword) { 1236 void endMixinApplication(Token withKeyword) {
1266 debugEvent("MixinApplication"); 1237 debugEvent("MixinApplication");
1267 ClassScope s = scope; 1238 ClassScope s = scope;
1268 // ignore: strong_mode_down_cast_composite
1269 s.currentClass.mixins = pop(); 1239 s.currentClass.mixins = pop();
1270 } 1240 }
1271 1241
1272 void endNamedMixinApplication(Token begin, Token classKeyword, Token equals, 1242 void endNamedMixinApplication(Token begin, Token classKeyword, Token equals,
1273 Token implementsKeyword, Token endToken) { 1243 Token implementsKeyword, Token endToken) {
1274 debugEvent("endNamedMixinApplication"); 1244 debugEvent("endNamedMixinApplication");
1275 // ignore: strong_mode_down_cast_composite
1276 List<EntityRef> interfaces = popIfNotNull(implementsKeyword); 1245 List<EntityRef> interfaces = popIfNotNull(implementsKeyword);
1277 EntityRef supertype = pop(); 1246 EntityRef supertype = pop();
1278 List typeVariables = pop(); 1247 List typeVariables = pop();
1279 String name = pop(); 1248 String name = pop();
1280 int modifiers = pop(); 1249 int modifiers = pop();
1281 List metadata = pop(); 1250 List metadata = pop();
1282 // print('TODO: end mix, $name'); 1251 // print('TODO: end mix, $name');
1283 checkEmpty(); 1252 checkEmpty();
1284 1253
1285 ClassScope s = scope; 1254 ClassScope s = scope;
1286 s.currentClass 1255 s.currentClass
1287 ..name = name 1256 ..name = name
1288 ..isAbstract = modifiers & _abstract_flag != 0 1257 ..isAbstract = modifiers & _abstract_flag != 0
1289 ..isMixinApplication = true 1258 ..isMixinApplication = true
1290 // ignore: strong_mode_down_cast_composite
1291 ..annotations = metadata 1259 ..annotations = metadata
1292 // ignore: strong_mode_down_cast_composite
1293 ..typeParameters = typeVariables 1260 ..typeParameters = typeVariables
1294 ..interfaces = interfaces; 1261 ..interfaces = interfaces;
1295 if (supertype != null) { 1262 if (supertype != null) {
1296 s.currentClass.supertype = supertype; 1263 s.currentClass.supertype = supertype;
1297 } else { 1264 } else {
1298 s.currentClass.hasNoSupertype = isCoreLibrary && name == 'Object'; 1265 s.currentClass.hasNoSupertype = isCoreLibrary && name == 'Object';
1299 } 1266 }
1300 scope = scope.parent; 1267 scope = scope.parent;
1301 topScope.unit.classes.add(s.currentClass); 1268 topScope.unit.classes.add(s.currentClass);
1302 1269
1303 _addNameIfPublic(name, ReferenceKind.classOrEnum, typeVariables.length); 1270 _addNameIfPublic(name, ReferenceKind.classOrEnum, typeVariables.length);
1304 } 1271 }
1305 1272
1306 void endOptionalFormalParameters( 1273 void endOptionalFormalParameters(
1307 int count, Token beginToken, Token endToken) { 1274 int count, Token beginToken, Token endToken) {
1308 debugEvent("OptionalFormalParameters"); 1275 debugEvent("OptionalFormalParameters");
1309 push(popList(count)); 1276 push(popList(count));
1310 } 1277 }
1311 1278
1312 void endPart(Token partKeyword, Token semicolon) { 1279 void endPart(Token partKeyword, Token semicolon) {
1313 debugEvent("Part"); 1280 debugEvent("Part");
1314 String uri = pop(); 1281 String uri = pop();
1315 // ignore: strong_mode_down_cast_composite
1316 List<UnlinkedExpr> metadata = pop(); 1282 List<UnlinkedExpr> metadata = pop();
1317 topScope.unit.parts.add(new UnlinkedPartBuilder(annotations: metadata)); 1283 topScope.unit.parts.add(new UnlinkedPartBuilder(annotations: metadata));
1318 topScope.publicNamespace.parts.add(uri); 1284 topScope.publicNamespace.parts.add(uri);
1319 checkEmpty(); 1285 checkEmpty();
1320 } 1286 }
1321 1287
1322 void endPartOf(Token partKeyword, Token semicolon, bool hasName) { 1288 void endPartOf(Token partKeyword, Token semicolon, bool hasName) {
1323 debugEvent("endPartOf"); 1289 debugEvent("endPartOf");
1324 String name = pop(); 1290 String name = pop();
1325 pop(); // metadata 1291 pop(); // metadata
1326 topScope.unit.isPartOf = true; 1292 topScope.unit.isPartOf = true;
1327 if (name == 'dart.core') isCoreLibrary = true; 1293 if (name == 'dart.core') isCoreLibrary = true;
1328 } 1294 }
1329 1295
1330 void endRedirectingFactoryBody(Token beginToken, Token endToken) { 1296 void endRedirectingFactoryBody(Token beginToken, Token endToken) {
1331 debugEvent("RedirectingFactoryBody"); 1297 debugEvent("RedirectingFactoryBody");
1332 pop(); // Discard ConstructorReferenceBuilder. 1298 pop(); // Discard ConstructorReferenceBuilder.
1333 } 1299 }
1334 1300
1335 void endShow(_) { 1301 void endShow(_) {
1336 // ignore: strong_mode_down_cast_composite
1337 push(new UnlinkedCombinatorBuilder(shows: pop())); 1302 push(new UnlinkedCombinatorBuilder(shows: pop()));
1338 } 1303 }
1339 1304
1340 void endTopLevelFields(int count, Token beginToken, Token endToken) { 1305 void endTopLevelFields(int count, Token beginToken, Token endToken) {
1341 debugEvent("endTopLevelFields"); 1306 debugEvent("endTopLevelFields");
1342 _endFields(count, topScope.unit.variables, true); 1307 _endFields(count, topScope.unit.variables, true);
1343 checkEmpty(); 1308 checkEmpty();
1344 } 1309 }
1345 1310
1346 void endTopLevelMethod(Token beginToken, Token getOrSet, Token endToken) { 1311 void endTopLevelMethod(Token beginToken, Token getOrSet, Token endToken) {
(...skipping 14 matching lines...) Expand all
1361 : (getOrSet == 'set' 1326 : (getOrSet == 'set'
1362 ? UnlinkedExecutableKind.setter 1327 ? UnlinkedExecutableKind.setter
1363 : UnlinkedExecutableKind.functionOrMethod), 1328 : UnlinkedExecutableKind.functionOrMethod),
1364 isExternal: modifiers & _external_flag != 0, 1329 isExternal: modifiers & _external_flag != 0,
1365 isAbstract: modifiers & _abstract_flag != 0, 1330 isAbstract: modifiers & _abstract_flag != 0,
1366 isAsynchronous: asyncModifier & _async_flag != 0, 1331 isAsynchronous: asyncModifier & _async_flag != 0,
1367 isGenerator: asyncModifier & _star_flag != 0, 1332 isGenerator: asyncModifier & _star_flag != 0,
1368 isStatic: modifiers & _static_flag != 0, 1333 isStatic: modifiers & _static_flag != 0,
1369 typeParameters: [], // TODO 1334 typeParameters: [], // TODO
1370 returnType: returnType, 1335 returnType: returnType,
1371 // ignore: strong_mode_down_cast_composite
1372 parameters: formals, 1336 parameters: formals,
1373 // ignore: strong_mode_down_cast_composite
1374 annotations: metadata, 1337 annotations: metadata,
1375 inferredReturnTypeSlot: null, // not needed for top-levels 1338 inferredReturnTypeSlot: null, // not needed for top-levels
1376 // skip body. 1339 // skip body.
1377 )); 1340 ));
1378 1341
1379 String normalizedName = getOrSet == 'set' ? '$name=' : name; 1342 String normalizedName = getOrSet == 'set' ? '$name=' : name;
1380 _addNameIfPublic( 1343 _addNameIfPublic(
1381 normalizedName, 1344 normalizedName,
1382 getOrSet != null 1345 getOrSet != null
1383 ? ReferenceKind.topLevelPropertyAccessor 1346 ? ReferenceKind.topLevelPropertyAccessor
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1476 push("$receiver.$name"); 1439 push("$receiver.$name");
1477 } 1440 }
1478 1441
1479 void handleStringPart(token) { 1442 void handleStringPart(token) {
1480 debugEvent("handleStringPart"); 1443 debugEvent("handleStringPart");
1481 push(token.lexeme.substring(1, token.lexeme.length - 1)); 1444 push(token.lexeme.substring(1, token.lexeme.length - 1));
1482 } 1445 }
1483 1446
1484 void handleType(Token beginToken, Token endToken) { 1447 void handleType(Token beginToken, Token endToken) {
1485 debugEvent("Type"); 1448 debugEvent("Type");
1486 // ignore: strong_mode_down_cast_composite
1487 List<EntityRef> arguments = pop(); 1449 List<EntityRef> arguments = pop();
1488 String name = pop(); 1450 String name = pop();
1489 1451
1490 var type; 1452 var type;
1491 if (name.contains('.')) { 1453 if (name.contains('.')) {
1492 var parts = name.split('.'); 1454 var parts = name.split('.');
1493 for (var p in parts) { 1455 for (var p in parts) {
1494 type = type == null 1456 type = type == null
1495 ? new LazyEntityRef(p, scope) 1457 ? new LazyEntityRef(p, scope)
1496 : new NestedLazyEntityRef(type, p, scope); 1458 : new NestedLazyEntityRef(type, p, scope);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1535 /// Add `name` and, if requested, `name=` to the public namespace. 1497 /// Add `name` and, if requested, `name=` to the public namespace.
1536 void _addPropertyName(String name, {bool includeSetter: false}) { 1498 void _addPropertyName(String name, {bool includeSetter: false}) {
1537 _addName(name, ReferenceKind.topLevelPropertyAccessor); 1499 _addName(name, ReferenceKind.topLevelPropertyAccessor);
1538 if (includeSetter) { 1500 if (includeSetter) {
1539 _addName('$name=', ReferenceKind.topLevelPropertyAccessor); 1501 _addName('$name=', ReferenceKind.topLevelPropertyAccessor);
1540 } 1502 }
1541 } 1503 }
1542 1504
1543 void _endFields(int count, List result, bool isTopLevel) { 1505 void _endFields(int count, List result, bool isTopLevel) {
1544 debugEvent('EndFields: $count $isTopLevel'); 1506 debugEvent('EndFields: $count $isTopLevel');
1545 // ignore: strong_mode_down_cast_composite
1546 List<_InitializedName> fields = popList(count); 1507 List<_InitializedName> fields = popList(count);
1547 EntityRef type = pop(); 1508 EntityRef type = pop();
1548 int modifiers = pop(); 1509 int modifiers = pop();
1549 List metadata = pop(); 1510 List metadata = pop();
1550 1511
1551 bool isStatic = modifiers & _static_flag != 0; 1512 bool isStatic = modifiers & _static_flag != 0;
1552 bool isFinal = modifiers & _final_flag != 0; 1513 bool isFinal = modifiers & _final_flag != 0;
1553 bool isConst = modifiers & _const_flag != 0; 1514 bool isConst = modifiers & _const_flag != 0;
1554 bool isInstance = !isStatic && !isTopLevel; 1515 bool isInstance = !isStatic && !isTopLevel;
1555 for (var field in fields) { 1516 for (var field in fields) {
1556 var name = field.name; 1517 var name = field.name;
1557 var initializer = field.initializer; 1518 var initializer = field.initializer;
1558 bool needsPropagatedType = initializer != null && (isFinal || isConst); 1519 bool needsPropagatedType = initializer != null && (isFinal || isConst);
1559 bool needsInferredType = 1520 bool needsInferredType =
1560 type == null && (initializer != null || isInstance); 1521 type == null && (initializer != null || isInstance);
1561 result.add(new UnlinkedVariableBuilder( 1522 result.add(new UnlinkedVariableBuilder(
1562 isFinal: isFinal, 1523 isFinal: isFinal,
1563 isConst: isConst, 1524 isConst: isConst,
1564 isStatic: isStatic, 1525 isStatic: isStatic,
1565 name: name, 1526 name: name,
1566 type: type, 1527 type: type,
1567 // ignore: strong_mode_down_cast_composite
1568 annotations: metadata, 1528 annotations: metadata,
1569 initializer: initializer, 1529 initializer: initializer,
1570 propagatedTypeSlot: slotIf(needsPropagatedType), 1530 propagatedTypeSlot: slotIf(needsPropagatedType),
1571 inferredTypeSlot: slotIf(needsInferredType))); 1531 inferredTypeSlot: slotIf(needsInferredType)));
1572 1532
1573 if (_isPrivate(name)) continue; 1533 if (_isPrivate(name)) continue;
1574 if (isTopLevel) { 1534 if (isTopLevel) {
1575 _addPropertyName(name, includeSetter: !isFinal && !isConst); 1535 _addPropertyName(name, includeSetter: !isFinal && !isConst);
1576 } else if (isStatic) { 1536 } else if (isStatic) {
1577 // Any reason setters are not added as well? 1537 // Any reason setters are not added as well?
(...skipping 12 matching lines...) Expand all
1590 } 1550 }
1591 1551
1592 /// Internal representation of an initialized name. 1552 /// Internal representation of an initialized name.
1593 class _InitializedName { 1553 class _InitializedName {
1594 final String name; 1554 final String name;
1595 final UnlinkedExecutableBuilder initializer; 1555 final UnlinkedExecutableBuilder initializer;
1596 _InitializedName(this.name, this.initializer); 1556 _InitializedName(this.name, this.initializer);
1597 1557
1598 toString() => "II:" + (initializer != null ? "$name = $initializer" : name); 1558 toString() => "II:" + (initializer != null ? "$name = $initializer" : name);
1599 } 1559 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/tool/summary/mini_ast.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698