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 fasta.outline_builder; | 5 library fasta.outline_builder; |
6 | 6 |
7 import 'package:kernel/ast.dart' show | 7 import 'package:kernel/ast.dart' show |
8 AsyncMarker, | 8 AsyncMarker, |
9 ProcedureKind; | 9 ProcedureKind; |
10 | 10 |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 @override | 176 @override |
177 void endLibraryName(Token libraryKeyword, Token semicolon) { | 177 void endLibraryName(Token libraryKeyword, Token semicolon) { |
178 debugEvent("endLibraryName"); | 178 debugEvent("endLibraryName"); |
179 String name = pop(); | 179 String name = pop(); |
180 List<MetadataBuilder> metadata = pop(); | 180 List<MetadataBuilder> metadata = pop(); |
181 library.name = name; | 181 library.name = name; |
182 library.metadata = metadata; | 182 library.metadata = metadata; |
183 } | 183 } |
184 | 184 |
185 @override | 185 @override |
186 void beginClassDeclaration(Token token) { | 186 void beginClassDeclaration(Token begin) { |
187 library.beginNestedScope(); | 187 library.beginNestedDeclaration(); |
188 } | 188 } |
189 | 189 |
190 @override | 190 @override |
191 void endClassDeclaration(int interfacesCount, Token beginToken, | 191 void endClassDeclaration(int interfacesCount, Token beginToken, |
192 Token extendsKeyword, Token implementsKeyword, Token endToken) { | 192 Token extendsKeyword, Token implementsKeyword, Token endToken) { |
193 debugEvent("endClassDeclaration"); | 193 debugEvent("endClassDeclaration"); |
194 List<TypeBuilder> interfaces = popList(interfacesCount); | 194 List<TypeBuilder> interfaces = popList(interfacesCount); |
195 TypeBuilder supertype = pop(); | 195 TypeBuilder supertype = pop(); |
196 List<TypeVariableBuilder> typeVariables = pop(); | 196 List<TypeVariableBuilder> typeVariables = pop(); |
197 String name = pop(); | 197 String name = pop(); |
198 int modifiers = Modifier.validate(pop()); | 198 int modifiers = Modifier.validate(pop()); |
199 List<MetadataBuilder> metadata = pop(); | 199 List<MetadataBuilder> metadata = pop(); |
200 library.addClass( | 200 library.addClass( |
201 metadata, modifiers, name, typeVariables, supertype, interfaces); | 201 metadata, modifiers, name, typeVariables, supertype, interfaces); |
202 checkEmpty(); | 202 checkEmpty(); |
203 } | 203 } |
204 | 204 |
205 ProcedureKind computeProcedureKind(Token token) { | 205 ProcedureKind computeProcedureKind(Token token) { |
206 if (token == null) return ProcedureKind.Method; | 206 if (token == null) return ProcedureKind.Method; |
207 if (optional("get", token)) return ProcedureKind.Getter; | 207 if (optional("get", token)) return ProcedureKind.Getter; |
208 if (optional("set", token)) return ProcedureKind.Setter; | 208 if (optional("set", token)) return ProcedureKind.Setter; |
209 return internalError("Unhandled: ${token.value}"); | 209 return internalError("Unhandled: ${token.value}"); |
210 } | 210 } |
211 | 211 |
212 @override | 212 @override |
213 void beginTopLevelMethod(Token token, Token name) { | 213 void beginTopLevelMethod(Token token, Token name) { |
214 library.beginNestedScope(hasMembers: false); | 214 library.beginNestedDeclaration(hasMembers: false); |
215 } | 215 } |
216 | 216 |
217 @override | 217 @override |
218 ProcedureBuilder endTopLevelMethod( | 218 ProcedureBuilder endTopLevelMethod( |
219 Token beginToken, Token getOrSet, Token endToken) { | 219 Token beginToken, Token getOrSet, Token endToken) { |
220 debugEvent("endTopLevelMethod"); | 220 debugEvent("endTopLevelMethod"); |
221 MethodBody kind = pop(); | 221 MethodBody kind = pop(); |
222 AsyncMarker asyncModifier = pop(); | 222 AsyncMarker asyncModifier = pop(); |
223 List<FormalParameterBuilder> formals = pop(); | 223 List<FormalParameterBuilder> formals = pop(); |
224 List<TypeVariableBuilder> typeVariables = pop(); | 224 List<TypeVariableBuilder> typeVariables = pop(); |
(...skipping 14 matching lines...) Expand all Loading... |
239 } | 239 } |
240 | 240 |
241 @override | 241 @override |
242 void handleFunctionBodySkipped(Token token) { | 242 void handleFunctionBodySkipped(Token token) { |
243 debugEvent("handleFunctionBodySkipped"); | 243 debugEvent("handleFunctionBodySkipped"); |
244 push(MethodBody.Regular); | 244 push(MethodBody.Regular); |
245 } | 245 } |
246 | 246 |
247 @override | 247 @override |
248 void beginMethod(Token token, Token name) { | 248 void beginMethod(Token token, Token name) { |
249 library.beginNestedScope(hasMembers: false); | 249 library.beginNestedDeclaration(hasMembers: false); |
250 } | 250 } |
251 | 251 |
252 @override | 252 @override |
253 void endMethod(Token getOrSet, Token beginToken, Token endToken) { | 253 void endMethod(Token getOrSet, Token beginToken, Token endToken) { |
254 debugEvent("Method"); | 254 debugEvent("Method"); |
255 MethodBody kind = pop(); | 255 MethodBody kind = pop(); |
256 if (kind == MethodBody.RedirectingFactoryBody) { | 256 if (kind == MethodBody.RedirectingFactoryBody) { |
257 // This will cause an error later. | 257 // This will cause an error later. |
258 pop(); | 258 pop(); |
259 } | 259 } |
(...skipping 15 matching lines...) Expand all Loading... |
275 @override | 275 @override |
276 void endMixinApplication() { | 276 void endMixinApplication() { |
277 debugEvent("MixinApplication"); | 277 debugEvent("MixinApplication"); |
278 List<TypeBuilder> mixins = pop(); | 278 List<TypeBuilder> mixins = pop(); |
279 TypeBuilder supertype = pop(); | 279 TypeBuilder supertype = pop(); |
280 push(library.addMixinApplication(supertype, mixins)); | 280 push(library.addMixinApplication(supertype, mixins)); |
281 } | 281 } |
282 | 282 |
283 @override | 283 @override |
284 void beginNamedMixinApplication(Token token) { | 284 void beginNamedMixinApplication(Token token) { |
285 library.beginNestedScope(hasMembers: false); | 285 library.beginNestedDeclaration(hasMembers: false); |
286 } | 286 } |
287 | 287 |
288 @override | 288 @override |
289 void endNamedMixinApplication( | 289 void endNamedMixinApplication( |
290 Token classKeyword, Token implementsKeyword, Token endToken) { | 290 Token classKeyword, Token implementsKeyword, Token endToken) { |
291 debugEvent("endNamedMixinApplication"); | 291 debugEvent("endNamedMixinApplication"); |
292 List<TypeBuilder> interfaces = popIfNotNull(implementsKeyword); | 292 List<TypeBuilder> interfaces = popIfNotNull(implementsKeyword); |
293 TypeBuilder mixinApplication = pop(); | 293 TypeBuilder mixinApplication = pop(); |
294 List<TypeVariableBuilder> typeVariables = pop(); | 294 List<TypeVariableBuilder> typeVariables = pop(); |
295 String name = pop(); | 295 String name = pop(); |
296 int modifiers = Modifier.validate(pop()); | 296 int modifiers = Modifier.validate(pop()); |
297 List<MetadataBuilder> metadata = pop(); | 297 List<MetadataBuilder> metadata = pop(); |
298 library.addNamedMixinApplication( | 298 library.addNamedMixinApplication( |
299 metadata, name, typeVariables, modifiers, mixinApplication, interfaces); | 299 metadata, name, typeVariables, modifiers, mixinApplication, interfaces); |
300 checkEmpty(); | 300 checkEmpty(); |
301 } | 301 } |
302 | 302 |
303 @override | 303 @override |
304 void endTypeArguments(int count, Token beginToken, Token endToken) { | 304 void endTypeArguments(int count, Token beginToken, Token endToken) { |
305 debugEvent("TypeArguments"); | 305 debugEvent("TypeArguments"); |
306 push(popList(count) ?? NullValue.TypeArguments); | 306 push(popList(count) ?? NullValue.TypeArguments); |
307 } | 307 } |
308 | 308 |
309 @override | 309 @override |
310 void endType(Token beginToken, Token endToken) { | 310 void endType(Token beginToken, Token endToken) { |
311 debugEvent("Type"); | 311 debugEvent("Type"); |
312 List<TypeBuilder> arguments = pop(); | 312 List<TypeBuilder> arguments = pop(); |
313 String name = pop(); | 313 String name = pop(); |
314 push(library.addInterfaceType(name, arguments)); | 314 push(library.addNamedType(name, arguments)); |
315 } | 315 } |
316 | 316 |
317 @override | 317 @override |
318 void endTypeList(int count) { | 318 void endTypeList(int count) { |
319 debugEvent("TypeList"); | 319 debugEvent("TypeList"); |
320 push(popList(count) ?? NullValue.TypeList); | 320 push(popList(count) ?? NullValue.TypeList); |
321 } | 321 } |
322 | 322 |
323 @override | 323 @override |
324 void endTypeVariables(int count, Token beginToken, Token endToken) { | 324 void endTypeVariables(int count, Token beginToken, Token endToken) { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 void endEnum(Token enumKeyword, Token endBrace, int count) { | 405 void endEnum(Token enumKeyword, Token endBrace, int count) { |
406 List<String> constants = popList(count); | 406 List<String> constants = popList(count); |
407 String name = pop(); | 407 String name = pop(); |
408 List<MetadataBuilder> metadata = pop(); | 408 List<MetadataBuilder> metadata = pop(); |
409 library.addEnum(metadata, name, constants); | 409 library.addEnum(metadata, name, constants); |
410 checkEmpty(); | 410 checkEmpty(); |
411 } | 411 } |
412 | 412 |
413 @override | 413 @override |
414 void beginFunctionTypeAlias(Token token) { | 414 void beginFunctionTypeAlias(Token token) { |
415 library.beginNestedScope(); | 415 library.beginNestedDeclaration(hasMembers: false); |
416 } | 416 } |
417 | 417 |
418 @override | 418 @override |
419 void endFunctionTypeAlias(Token typedefKeyword, Token endToken) { | 419 void endFunctionTypeAlias(Token typedefKeyword, Token endToken) { |
420 debugEvent("endFunctionTypeAlias"); | 420 debugEvent("endFunctionTypeAlias"); |
421 List<FormalParameterBuilder> formals = pop(); | 421 List<FormalParameterBuilder> formals = pop(); |
422 List<TypeVariableBuilder> typeVariables = pop(); | 422 List<TypeVariableBuilder> typeVariables = pop(); |
423 String name = pop(); | 423 String name = pop(); |
424 TypeBuilder returnType = pop(); | 424 TypeBuilder returnType = pop(); |
425 List<MetadataBuilder> metadata = pop(); | 425 List<MetadataBuilder> metadata = pop(); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 Link<Token> handleMemberName(Link<Token> identifiers) { | 561 Link<Token> handleMemberName(Link<Token> identifiers) { |
562 if (!isDartLibrary || identifiers.isEmpty) return identifiers; | 562 if (!isDartLibrary || identifiers.isEmpty) return identifiers; |
563 return removeNativeClause(identifiers); | 563 return removeNativeClause(identifiers); |
564 } | 564 } |
565 | 565 |
566 @override | 566 @override |
567 void debugEvent(String name) { | 567 void debugEvent(String name) { |
568 // printEvent(name); | 568 // printEvent(name); |
569 } | 569 } |
570 } | 570 } |
OLD | NEW |