OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 dart2js.parser.element_listener; | 5 library dart2js.parser.element_listener; |
6 | 6 |
7 import '../common.dart'; | 7 import '../common.dart'; |
8 import '../diagnostics/messages.dart' show MessageTemplate; | 8 import '../diagnostics/messages.dart' show MessageTemplate; |
9 import '../elements/elements.dart' | 9 import '../elements/elements.dart' |
10 show Element, LibraryElement, MetadataAnnotation; | 10 show Element, LibraryElement, MetadataAnnotation; |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 void rejectBuiltInIdentifier(Identifier name) { | 282 void rejectBuiltInIdentifier(Identifier name) { |
283 if (name.token is KeywordToken) { | 283 if (name.token is KeywordToken) { |
284 Keyword keyword = (name.token as KeywordToken).keyword; | 284 Keyword keyword = (name.token as KeywordToken).keyword; |
285 if (!keyword.isPseudo) { | 285 if (!keyword.isPseudo) { |
286 recoverableError(name, "Illegal name '${keyword.syntax}'."); | 286 recoverableError(name, "Illegal name '${keyword.syntax}'."); |
287 } | 287 } |
288 } | 288 } |
289 } | 289 } |
290 | 290 |
291 @override | 291 @override |
292 void endFunctionTypeAlias(Token typedefKeyword, Token endToken) { | 292 void endFunctionTypeAlias( |
293 popNode(); // TODO(karlklose): do not throw away typeVariables. | 293 Token typedefKeyword, Token equals, Token endToken) { |
294 Identifier name = popNode(); | 294 Identifier name; |
295 popNode(); // returnType | 295 if (equals == null) { |
| 296 popNode(); // TODO(karlklose): do not throw away typeVariables. |
| 297 name = popNode(); |
| 298 popNode(); // returnType |
| 299 } else { |
| 300 popNode(); // Function type. |
| 301 popNode(); // TODO(karlklose): do not throw away typeVariables. |
| 302 name = popNode(); |
| 303 } |
296 pushElement(new PartialTypedefElement( | 304 pushElement(new PartialTypedefElement( |
297 name.source, compilationUnitElement, typedefKeyword, endToken)); | 305 name.source, compilationUnitElement, typedefKeyword, endToken)); |
298 rejectBuiltInIdentifier(name); | 306 rejectBuiltInIdentifier(name); |
299 } | 307 } |
300 | 308 |
301 @override | 309 @override |
302 void endNamedMixinApplication( | 310 void endNamedMixinApplication( |
303 Token beginToken, Token classKeyword, Token equals, | 311 Token beginToken, Token classKeyword, Token equals, |
304 Token implementsKeyword, Token endToken) { | 312 Token implementsKeyword, Token endToken) { |
305 NodeList interfaces = (implementsKeyword != null) ? popNode() : null; | 313 NodeList interfaces = (implementsKeyword != null) ? popNode() : null; |
(...skipping 13 matching lines...) Expand all Loading... |
319 int id = idGenerator.getNextFreeId(); | 327 int id = idGenerator.getNextFreeId(); |
320 Element enclosing = compilationUnitElement; | 328 Element enclosing = compilationUnitElement; |
321 pushElement(new NamedMixinApplicationElementX( | 329 pushElement(new NamedMixinApplicationElementX( |
322 name.source, enclosing, id, namedMixinApplication)); | 330 name.source, enclosing, id, namedMixinApplication)); |
323 rejectBuiltInIdentifier(name); | 331 rejectBuiltInIdentifier(name); |
324 } | 332 } |
325 | 333 |
326 @override | 334 @override |
327 void endMixinApplication() { | 335 void endMixinApplication() { |
328 NodeList mixins = popNode(); | 336 NodeList mixins = popNode(); |
329 TypeAnnotation superclass = popNode(); | 337 NominalTypeAnnotation superclass = popNode(); |
330 pushNode(new MixinApplication(superclass, mixins)); | 338 pushNode(new MixinApplication(superclass, mixins)); |
331 } | 339 } |
332 | 340 |
333 @override | 341 @override |
334 void handleVoidKeyword(Token token) { | 342 void handleVoidKeyword(Token token) { |
335 pushNode(new TypeAnnotation(new Identifier(token), null)); | 343 pushNode(new NominalTypeAnnotation(new Identifier(token), null)); |
336 } | 344 } |
337 | 345 |
338 @override | 346 @override |
339 void endTopLevelMethod(Token beginToken, Token getOrSet, Token endToken) { | 347 void endTopLevelMethod(Token beginToken, Token getOrSet, Token endToken) { |
340 bool hasParseError = currentMemberHasParseError; | 348 bool hasParseError = currentMemberHasParseError; |
341 memberErrors = memberErrors.tail; | 349 memberErrors = memberErrors.tail; |
342 popNode(); // typeVariables | 350 popNode(); // typeVariables |
343 Identifier name = popNode(); | 351 Identifier name = popNode(); |
344 popNode(); // type | 352 popNode(); // type |
345 Modifiers modifiers = popNode(); | 353 Modifiers modifiers = popNode(); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 pushNode(new Send(first, last)); | 406 pushNode(new Send(first, last)); |
399 } | 407 } |
400 | 408 |
401 @override | 409 @override |
402 void handleNoType(Token token) { | 410 void handleNoType(Token token) { |
403 pushNode(null); | 411 pushNode(null); |
404 } | 412 } |
405 | 413 |
406 @override | 414 @override |
407 void endTypeVariable(Token token, Token extendsOrSuper) { | 415 void endTypeVariable(Token token, Token extendsOrSuper) { |
408 TypeAnnotation bound = popNode(); | 416 NominalTypeAnnotation bound = popNode(); |
409 Identifier name = popNode(); | 417 Identifier name = popNode(); |
410 pushNode(new TypeVariable(name, extendsOrSuper, bound)); | 418 pushNode(new TypeVariable(name, extendsOrSuper, bound)); |
411 rejectBuiltInIdentifier(name); | 419 rejectBuiltInIdentifier(name); |
412 } | 420 } |
413 | 421 |
414 @override | 422 @override |
415 void endTypeVariables(int count, Token beginToken, Token endToken) { | 423 void endTypeVariables(int count, Token beginToken, Token endToken) { |
416 pushNode(makeNodeList(count, beginToken, endToken, ',')); | 424 pushNode(makeNodeList(count, beginToken, endToken, ',')); |
417 } | 425 } |
418 | 426 |
419 @override | 427 @override |
420 void handleNoTypeVariables(Token token) { | 428 void handleNoTypeVariables(Token token) { |
421 pushNode(null); | 429 pushNode(null); |
422 } | 430 } |
423 | 431 |
424 @override | 432 @override |
425 void endTypeArguments(int count, Token beginToken, Token endToken) { | 433 void endTypeArguments(int count, Token beginToken, Token endToken) { |
426 pushNode(makeNodeList(count, beginToken, endToken, ',')); | 434 pushNode(makeNodeList(count, beginToken, endToken, ',')); |
427 } | 435 } |
428 | 436 |
429 @override | 437 @override |
430 void handleNoTypeArguments(Token token) { | 438 void handleNoTypeArguments(Token token) { |
431 pushNode(null); | 439 pushNode(null); |
432 } | 440 } |
433 | 441 |
434 @override | 442 @override |
435 void endType(Token beginToken, Token endToken) { | 443 void handleType(Token beginToken, Token endToken) { |
436 NodeList typeArguments = popNode(); | 444 NodeList typeArguments = popNode(); |
437 Expression typeName = popNode(); | 445 Expression typeName = popNode(); |
438 pushNode(new TypeAnnotation(typeName, typeArguments)); | 446 pushNode(new NominalTypeAnnotation(typeName, typeArguments)); |
| 447 } |
| 448 |
| 449 void handleNoName(Token token) { |
| 450 pushNode(null); |
439 } | 451 } |
440 | 452 |
441 @override | 453 @override |
| 454 void handleFunctionType(Token functionToken, Token endToken) { |
| 455 popNode(); // Type parameters. |
| 456 popNode(); // Return type. |
| 457 pushNode(null); |
| 458 } |
| 459 |
| 460 @override |
442 void handleParenthesizedExpression(BeginGroupToken token) { | 461 void handleParenthesizedExpression(BeginGroupToken token) { |
443 Expression expression = popNode(); | 462 Expression expression = popNode(); |
444 pushNode(new ParenthesizedExpression(expression, token)); | 463 pushNode(new ParenthesizedExpression(expression, token)); |
445 } | 464 } |
446 | 465 |
447 @override | 466 @override |
448 void handleModifier(Token token) { | 467 void handleModifier(Token token) { |
449 pushNode(new Identifier(token)); | 468 pushNode(new Identifier(token)); |
450 } | 469 } |
451 | 470 |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 errorCode = MessageKind.INVALID_AWAIT_FOR; | 646 errorCode = MessageKind.INVALID_AWAIT_FOR; |
628 break; | 647 break; |
629 | 648 |
630 case ErrorKind.AsciiControlCharacter: | 649 case ErrorKind.AsciiControlCharacter: |
631 case ErrorKind.NonAsciiIdentifier: | 650 case ErrorKind.NonAsciiIdentifier: |
632 case ErrorKind.NonAsciiWhitespace: | 651 case ErrorKind.NonAsciiWhitespace: |
633 case ErrorKind.Encoding: | 652 case ErrorKind.Encoding: |
634 errorCode = MessageKind.BAD_INPUT_CHARACTER; | 653 errorCode = MessageKind.BAD_INPUT_CHARACTER; |
635 break; | 654 break; |
636 | 655 |
| 656 case ErrorKind.InvalidInlineFunctionType: |
| 657 errorCode = MessageKind.INVALID_INLINE_FUNCTION_TYPE; |
| 658 break; |
| 659 |
637 case ErrorKind.InvalidSyncModifier: | 660 case ErrorKind.InvalidSyncModifier: |
638 errorCode = MessageKind.INVALID_SYNC_MODIFIER; | 661 errorCode = MessageKind.INVALID_SYNC_MODIFIER; |
639 break; | 662 break; |
640 | 663 |
641 case ErrorKind.InvalidVoid: | 664 case ErrorKind.InvalidVoid: |
642 errorCode = MessageKind.VOID_NOT_ALLOWED; | 665 errorCode = MessageKind.VOID_NOT_ALLOWED; |
643 break; | 666 break; |
644 | 667 |
645 case ErrorKind.UnexpectedDollarInString: | 668 case ErrorKind.UnexpectedDollarInString: |
646 errorCode = MessageKind.MALFORMED_STRING_LITERAL; | 669 errorCode = MessageKind.MALFORMED_STRING_LITERAL; |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
914 memberErrors = memberErrors.tail.prepend(true); | 937 memberErrors = memberErrors.tail.prepend(true); |
915 } | 938 } |
916 reporter.reportErrorMessage(spannable, errorCode, arguments); | 939 reporter.reportErrorMessage(spannable, errorCode, arguments); |
917 } | 940 } |
918 | 941 |
919 void reportErrorFromToken(Token token, MessageKind errorCode, | 942 void reportErrorFromToken(Token token, MessageKind errorCode, |
920 [Map arguments = const {}]) { | 943 [Map arguments = const {}]) { |
921 reportError(reporter.spanFromToken(token), errorCode, arguments); | 944 reportError(reporter.spanFromToken(token), errorCode, arguments); |
922 } | 945 } |
923 } | 946 } |
OLD | NEW |