OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 #ifndef RUNTIME_VM_PARSER_H_ | 5 #ifndef RUNTIME_VM_PARSER_H_ |
6 #define RUNTIME_VM_PARSER_H_ | 6 #define RUNTIME_VM_PARSER_H_ |
7 | 7 |
8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
9 | 9 |
10 #include "platform/assert.h" | 10 #include "platform/assert.h" |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 bool IsYieldKeyword(); | 396 bool IsYieldKeyword(); |
397 | 397 |
398 void SkipIf(Token::Kind); | 398 void SkipIf(Token::Kind); |
399 void SkipToMatching(); | 399 void SkipToMatching(); |
400 void SkipToMatchingParenthesis(); | 400 void SkipToMatchingParenthesis(); |
401 void SkipBlock(); | 401 void SkipBlock(); |
402 TokenPosition SkipMetadata(); | 402 TokenPosition SkipMetadata(); |
403 bool IsPatchAnnotation(TokenPosition pos); | 403 bool IsPatchAnnotation(TokenPosition pos); |
404 void SkipTypeArguments(); | 404 void SkipTypeArguments(); |
405 void SkipType(bool allow_void); | 405 void SkipType(bool allow_void); |
| 406 void SkipTypeOrFunctionType(bool allow_void); |
406 void SkipInitializers(); | 407 void SkipInitializers(); |
407 void SkipExpr(); | 408 void SkipExpr(); |
408 void SkipNestedExpr(); | 409 void SkipNestedExpr(); |
409 void SkipConditionalExpr(); | 410 void SkipConditionalExpr(); |
410 void SkipBinaryExpr(); | 411 void SkipBinaryExpr(); |
411 void SkipUnaryExpr(); | 412 void SkipUnaryExpr(); |
412 void SkipPostfixExpr(); | 413 void SkipPostfixExpr(); |
413 void SkipSelectors(); | 414 void SkipSelectors(); |
414 void SkipPrimary(); | 415 void SkipPrimary(); |
415 void SkipCompoundLiteral(); | 416 void SkipCompoundLiteral(); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 void ParseLibraryDefinition(const Object& tl_owner); | 507 void ParseLibraryDefinition(const Object& tl_owner); |
507 void ParseLibraryName(); | 508 void ParseLibraryName(); |
508 void ParseLibraryImportExport(const Object& tl_owner, | 509 void ParseLibraryImportExport(const Object& tl_owner, |
509 TokenPosition metadata_pos); | 510 TokenPosition metadata_pos); |
510 void ParseLibraryPart(); | 511 void ParseLibraryPart(); |
511 void ParsePartHeader(); | 512 void ParsePartHeader(); |
512 void ParseLibraryNameObsoleteSyntax(); | 513 void ParseLibraryNameObsoleteSyntax(); |
513 void ParseLibraryImportObsoleteSyntax(); | 514 void ParseLibraryImportObsoleteSyntax(); |
514 void ParseLibraryIncludeObsoleteSyntax(); | 515 void ParseLibraryIncludeObsoleteSyntax(); |
515 | 516 |
| 517 void ResolveSignature(ClassFinalizer::FinalizationKind finalization, |
| 518 const Function& signature); |
516 void ResolveType(ClassFinalizer::FinalizationKind finalization, | 519 void ResolveType(ClassFinalizer::FinalizationKind finalization, |
517 AbstractType* type); | 520 AbstractType* type); |
518 RawAbstractType* ParseType(ClassFinalizer::FinalizationKind finalization, | 521 RawAbstractType* ParseType(ClassFinalizer::FinalizationKind finalization, |
519 bool allow_deferred_type = false, | 522 bool allow_deferred_type = false, |
520 bool consume_unresolved_prefix = true); | 523 bool consume_unresolved_prefix = true); |
521 RawAbstractType* ParseType(ClassFinalizer::FinalizationKind finalization, | 524 RawAbstractType* ParseType(ClassFinalizer::FinalizationKind finalization, |
522 bool allow_deferred_type, | 525 bool allow_deferred_type, |
523 bool consume_unresolved_prefix, | 526 bool consume_unresolved_prefix, |
524 LibraryPrefix* prefix); | 527 LibraryPrefix* prefix); |
525 | 528 RawType* ParseFunctionType(const AbstractType& result_type, |
| 529 ClassFinalizer::FinalizationKind finalization); |
| 530 RawAbstractType* ParseTypeOrFunctionType( |
| 531 bool allow_void, |
| 532 ClassFinalizer::FinalizationKind finalization); |
526 void ParseTypeParameters(bool parameterizing_class); | 533 void ParseTypeParameters(bool parameterizing_class); |
527 RawTypeArguments* ParseTypeArguments( | 534 RawTypeArguments* ParseTypeArguments( |
528 ClassFinalizer::FinalizationKind finalization); | 535 ClassFinalizer::FinalizationKind finalization); |
529 void ParseMethodOrConstructor(ClassDesc* members, MemberDesc* method); | 536 void ParseMethodOrConstructor(ClassDesc* members, MemberDesc* method); |
530 void ParseFieldDefinition(ClassDesc* members, MemberDesc* field); | 537 void ParseFieldDefinition(ClassDesc* members, MemberDesc* field); |
531 void CheckMemberNameConflict(ClassDesc* members, MemberDesc* member); | 538 void CheckMemberNameConflict(ClassDesc* members, MemberDesc* member); |
532 void ParseClassMemberDefinition(ClassDesc* members, | 539 void ParseClassMemberDefinition(ClassDesc* members, |
533 TokenPosition metadata_pos); | 540 TokenPosition metadata_pos); |
| 541 void ParseParameterType(ParamList* params); |
534 void ParseFormalParameter(bool allow_explicit_default_value, | 542 void ParseFormalParameter(bool allow_explicit_default_value, |
535 bool evaluate_metadata, | 543 bool evaluate_metadata, |
536 ParamList* params); | 544 ParamList* params); |
537 void ParseFormalParameters(bool allow_explicit_default_values, | 545 void ParseFormalParameters(bool use_function_type_syntax, |
| 546 bool allow_explicit_default_values, |
538 bool evaluate_metadata, | 547 bool evaluate_metadata, |
539 ParamList* params); | 548 ParamList* params); |
540 void ParseFormalParameterList(bool allow_explicit_default_values, | 549 void ParseFormalParameterList(bool use_function_type_syntax, |
| 550 bool allow_explicit_default_values, |
541 bool evaluate_metadata, | 551 bool evaluate_metadata, |
542 ParamList* params); | 552 ParamList* params); |
543 void CheckFieldsInitialized(const Class& cls); | 553 void CheckFieldsInitialized(const Class& cls); |
544 void AddImplicitConstructor(const Class& cls); | 554 void AddImplicitConstructor(const Class& cls); |
545 void CheckConstructors(ClassDesc* members); | 555 void CheckConstructors(ClassDesc* members); |
546 AstNode* ParseExternalInitializedField(const Field& field); | 556 AstNode* ParseExternalInitializedField(const Field& field); |
547 void ParseInitializedInstanceFields( | 557 void ParseInitializedInstanceFields( |
548 const Class& cls, | 558 const Class& cls, |
549 LocalVariable* receiver, | 559 LocalVariable* receiver, |
550 GrowableArray<Field*>* initialized_fields); | 560 GrowableArray<Field*>* initialized_fields); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 TokenPosition field_pos); | 604 TokenPosition field_pos); |
595 AstNode* ParseSuperOperator(); | 605 AstNode* ParseSuperOperator(); |
596 AstNode* BuildUnarySuperOperator(Token::Kind op, PrimaryNode* super); | 606 AstNode* BuildUnarySuperOperator(Token::Kind op, PrimaryNode* super); |
597 | 607 |
598 static bool ParseFormalParameters(const Function& func, ParamList* params); | 608 static bool ParseFormalParameters(const Function& func, ParamList* params); |
599 | 609 |
600 void SetupDefaultsForOptionalParams(const ParamList& params); | 610 void SetupDefaultsForOptionalParams(const ParamList& params); |
601 ClosureNode* CreateImplicitClosureNode(const Function& func, | 611 ClosureNode* CreateImplicitClosureNode(const Function& func, |
602 TokenPosition token_pos, | 612 TokenPosition token_pos, |
603 AstNode* receiver); | 613 AstNode* receiver); |
| 614 void FinalizeFormalParameterTypes(const ParamList* params); |
604 void AddFormalParamsToFunction(const ParamList* params, const Function& func); | 615 void AddFormalParamsToFunction(const ParamList* params, const Function& func); |
605 void AddFormalParamsToScope(const ParamList* params, LocalScope* scope); | 616 void AddFormalParamsToScope(const ParamList* params, LocalScope* scope); |
606 | 617 |
607 SequenceNode* ParseConstructor(const Function& func); | 618 SequenceNode* ParseConstructor(const Function& func); |
608 SequenceNode* ParseFunc(const Function& func, bool check_semicolon); | 619 SequenceNode* ParseFunc(const Function& func, bool check_semicolon); |
609 | 620 |
610 void ParseNativeFunctionBlock(const ParamList* params, const Function& func); | 621 void ParseNativeFunctionBlock(const ParamList* params, const Function& func); |
611 | 622 |
612 SequenceNode* ParseInstanceGetter(const Function& func); | 623 SequenceNode* ParseInstanceGetter(const Function& func); |
613 SequenceNode* ParseInstanceSetter(const Function& func); | 624 SequenceNode* ParseInstanceSetter(const Function& func); |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 AstNode* ParseVariableDeclarationList(); | 753 AstNode* ParseVariableDeclarationList(); |
743 AstNode* ParseFunctionStatement(bool is_literal); | 754 AstNode* ParseFunctionStatement(bool is_literal); |
744 AstNode* ParseYieldStatement(); | 755 AstNode* ParseYieldStatement(); |
745 AstNode* ParseStatement(); | 756 AstNode* ParseStatement(); |
746 SequenceNode* ParseNestedStatement(bool parsing_loop_body, | 757 SequenceNode* ParseNestedStatement(bool parsing_loop_body, |
747 SourceLabel* label); | 758 SourceLabel* label); |
748 void ParseStatementSequence(); | 759 void ParseStatementSequence(); |
749 bool IsIdentifier(); | 760 bool IsIdentifier(); |
750 bool IsSymbol(const String& symbol); | 761 bool IsSymbol(const String& symbol); |
751 bool IsSimpleLiteral(const AbstractType& type, Instance* value); | 762 bool IsSimpleLiteral(const AbstractType& type, Instance* value); |
752 bool IsFunctionTypeAliasName(); | 763 bool IsFunctionTypeSymbol(); |
| 764 bool IsFunctionTypeAliasName(bool* use_function_type_syntax); |
753 bool TryParseQualIdent(); | 765 bool TryParseQualIdent(); |
754 bool TryParseTypeParameters(); | 766 bool TryParseTypeParameters(); |
755 bool TryParseTypeArguments(); | 767 bool TryParseTypeArguments(); |
756 bool IsTypeParameters(); | 768 bool IsTypeParameters(); |
757 bool IsArgumentPart(); | 769 bool IsArgumentPart(); |
758 bool IsParameterPart(); | 770 bool IsParameterPart(); |
759 bool TryParseOptionalType(); | 771 bool TryParseType(bool allow_void); |
760 bool TryParseReturnType(); | |
761 bool IsVariableDeclaration(); | 772 bool IsVariableDeclaration(); |
762 bool IsFunctionReturnType(); | 773 bool IsFunctionReturnType(); |
763 bool IsFunctionDeclaration(); | 774 bool IsFunctionDeclaration(); |
764 bool IsFunctionLiteral(); | 775 bool IsFunctionLiteral(); |
765 bool IsForInStatement(); | 776 bool IsForInStatement(); |
766 bool IsTopLevelAccessor(); | 777 bool IsTopLevelAccessor(); |
767 | 778 |
768 AstNode* ParseBinaryExpr(int min_preced); | 779 AstNode* ParseBinaryExpr(int min_preced); |
769 LiteralNode* ParseConstExpr(); | 780 LiteralNode* ParseConstExpr(); |
770 static const bool kRequireConst = true; | 781 static const bool kRequireConst = true; |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
974 | 985 |
975 intptr_t recursion_counter_; | 986 intptr_t recursion_counter_; |
976 friend class RecursionChecker; | 987 friend class RecursionChecker; |
977 | 988 |
978 DISALLOW_COPY_AND_ASSIGN(Parser); | 989 DISALLOW_COPY_AND_ASSIGN(Parser); |
979 }; | 990 }; |
980 | 991 |
981 } // namespace dart | 992 } // namespace dart |
982 | 993 |
983 #endif // RUNTIME_VM_PARSER_H_ | 994 #endif // RUNTIME_VM_PARSER_H_ |
OLD | NEW |