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 ProcedureKind; | 7 import 'package:kernel/ast.dart' show ProcedureKind; |
8 | 8 |
9 import '../../scanner/token.dart' show Token; | 9 import '../../scanner/token.dart' show Token; |
10 | 10 |
11 import '../builder/builder.dart'; | 11 import '../builder/builder.dart'; |
12 | 12 |
13 import '../combinator.dart' show Combinator; | 13 import '../combinator.dart' show Combinator; |
14 | 14 |
15 import '../fasta_codes.dart' | 15 import '../fasta_codes.dart' |
16 show | 16 show |
17 Message, | 17 Message, |
18 codeExpectedBlockToSkip, | 18 codeExpectedBlockToSkip, |
| 19 messageNativeClauseShouldBeAnnotation, |
19 messageOperatorWithOptionalFormals, | 20 messageOperatorWithOptionalFormals, |
20 messageTypedefNotFunction, | 21 messageTypedefNotFunction, |
21 templateDuplicatedParameterName, | 22 templateDuplicatedParameterName, |
22 templateDuplicatedParameterNameCause, | 23 templateDuplicatedParameterNameCause, |
23 templateOperatorMinusParameterMismatch, | 24 templateOperatorMinusParameterMismatch, |
24 templateOperatorParameterMismatch0, | 25 templateOperatorParameterMismatch0, |
25 templateOperatorParameterMismatch1, | 26 templateOperatorParameterMismatch1, |
26 templateOperatorParameterMismatch2; | 27 templateOperatorParameterMismatch2; |
27 | 28 |
28 import '../modifier.dart' show abstractMask, externalMask, Modifier; | 29 import '../modifier.dart' show abstractMask, externalMask, Modifier; |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 @override | 291 @override |
291 void beginNamedMixinApplication(Token beginToken, Token name) { | 292 void beginNamedMixinApplication(Token beginToken, Token name) { |
292 library.currentDeclaration.name = name.lexeme; | 293 library.currentDeclaration.name = name.lexeme; |
293 } | 294 } |
294 | 295 |
295 @override | 296 @override |
296 void handleNativeClause(Token nativeToken, bool hasName) { | 297 void handleNativeClause(Token nativeToken, bool hasName) { |
297 if (hasName) { | 298 if (hasName) { |
298 // Pop the native clause which in this case is a StringLiteral. | 299 // Pop the native clause which in this case is a StringLiteral. |
299 pop(); // Char offset. | 300 pop(); // Char offset. |
300 pop(); // String. | 301 nativeMethodName = pop(); // String. |
| 302 } else { |
| 303 nativeMethodName = ''; |
301 } | 304 } |
302 } | 305 } |
303 | 306 |
304 @override | 307 @override |
305 void endClassDeclaration( | 308 void endClassDeclaration( |
306 int interfacesCount, | 309 int interfacesCount, |
307 Token beginToken, | 310 Token beginToken, |
308 Token classKeyword, | 311 Token classKeyword, |
309 Token extendsKeyword, | 312 Token extendsKeyword, |
310 Token implementsKeyword, | 313 Token implementsKeyword, |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 debugEvent("handleFunctionBodySkipped"); | 387 debugEvent("handleFunctionBodySkipped"); |
385 push(MethodBody.Regular); | 388 push(MethodBody.Regular); |
386 } | 389 } |
387 | 390 |
388 @override | 391 @override |
389 void beginMethod(Token token, Token name) { | 392 void beginMethod(Token token, Token name) { |
390 library.beginNestedDeclaration(name.lexeme, hasMembers: false); | 393 library.beginNestedDeclaration(name.lexeme, hasMembers: false); |
391 } | 394 } |
392 | 395 |
393 @override | 396 @override |
394 void endMethod(Token getOrSet, Token beginToken, Token endToken) { | 397 void endMethod( |
| 398 Token getOrSet, Token beginToken, Token nativeToken, Token endToken) { |
395 debugEvent("Method"); | 399 debugEvent("Method"); |
396 MethodBody bodyKind = pop(); | 400 MethodBody bodyKind = pop(); |
397 if (bodyKind == MethodBody.RedirectingFactoryBody) { | 401 if (bodyKind == MethodBody.RedirectingFactoryBody) { |
398 // This will cause an error later. | 402 // This will cause an error later. |
399 pop(); | 403 pop(); |
400 } | 404 } |
401 List<FormalParameterBuilder> formals = pop(); | 405 List<FormalParameterBuilder> formals = pop(); |
402 int formalsOffset = pop(); | 406 int formalsOffset = pop(); |
403 List<TypeVariableBuilder> typeVariables = pop(); | 407 List<TypeVariableBuilder> typeVariables = pop(); |
404 int charOffset = pop(); | 408 int charOffset = pop(); |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 } | 914 } |
911 | 915 |
912 @override | 916 @override |
913 void handleModifiers(int count) { | 917 void handleModifiers(int count) { |
914 debugEvent("Modifiers"); | 918 debugEvent("Modifiers"); |
915 push(popList(count) ?? NullValue.Modifiers); | 919 push(popList(count) ?? NullValue.Modifiers); |
916 } | 920 } |
917 | 921 |
918 @override | 922 @override |
919 void handleRecoverableError(Token token, Message message) { | 923 void handleRecoverableError(Token token, Message message) { |
| 924 if (message == messageNativeClauseShouldBeAnnotation) return; |
920 if (silenceParserErrors) { | 925 if (silenceParserErrors) { |
921 debugEvent("RecoverableError"); | 926 debugEvent("RecoverableError"); |
922 } else { | 927 } else { |
923 super.handleRecoverableError(token, message); | 928 super.handleRecoverableError(token, message); |
924 } | 929 } |
925 } | 930 } |
926 | 931 |
927 @override | 932 @override |
928 Token handleUnrecoverableError(Token token, Message message) { | 933 Token handleUnrecoverableError(Token token, Message message) { |
929 if (enableNative && message.code == codeExpectedBlockToSkip) { | 934 if (enableNative && message.code == codeExpectedBlockToSkip) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
974 docToken = docToken.next; | 979 docToken = docToken.next; |
975 } | 980 } |
976 return buffer.toString(); | 981 return buffer.toString(); |
977 } | 982 } |
978 | 983 |
979 @override | 984 @override |
980 void debugEvent(String name) { | 985 void debugEvent(String name) { |
981 // printEvent(name); | 986 // printEvent(name); |
982 } | 987 } |
983 } | 988 } |
OLD | NEW |