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

Side by Side Diff: src/parsing/parser.h

Issue 1871923003: Add parsing for ambient declarations (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@types-devel
Patch Set: Created 4 years, 8 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_PARSING_PARSER_H_ 5 #ifndef V8_PARSING_PARSER_H_
6 #define V8_PARSING_PARSER_H_ 6 #define V8_PARSING_PARSER_H_
7 7
8 #include "src/allocation.h" 8 #include "src/allocation.h"
9 #include "src/ast/ast.h" 9 #include "src/ast/ast.h"
10 #include "src/ast/scopes.h" 10 #include "src/ast/scopes.h"
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 int* materialized_literal_count, int* expected_property_count, bool* ok, 609 int* materialized_literal_count, int* expected_property_count, bool* ok,
610 Scanner::BookmarkScope* bookmark = nullptr); 610 Scanner::BookmarkScope* bookmark = nullptr);
611 V8_INLINE ZoneList<Statement*>* ParseEagerFunctionBody( 611 V8_INLINE ZoneList<Statement*>* ParseEagerFunctionBody(
612 const AstRawString* name, int pos, 612 const AstRawString* name, int pos,
613 const ParserFormalParameters& parameters, FunctionKind kind, 613 const ParserFormalParameters& parameters, FunctionKind kind,
614 FunctionLiteral::FunctionType function_type, bool* ok); 614 FunctionLiteral::FunctionType function_type, bool* ok);
615 615
616 ClassLiteral* ParseClassLiteral(const AstRawString* name, 616 ClassLiteral* ParseClassLiteral(const AstRawString* name,
617 Scanner::Location class_name_location, 617 Scanner::Location class_name_location,
618 bool name_is_strict_reserved, int pos, 618 bool name_is_strict_reserved, int pos,
619 bool* ok); 619 bool ambient, bool* ok);
620 620
621 V8_INLINE void CheckConflictingVarDeclarations(v8::internal::Scope* scope, 621 V8_INLINE void CheckConflictingVarDeclarations(v8::internal::Scope* scope,
622 bool* ok); 622 bool* ok);
623 623
624 class TemplateLiteral : public ZoneObject { 624 class TemplateLiteral : public ZoneObject {
625 public: 625 public:
626 TemplateLiteral(Zone* zone, int pos) 626 TemplateLiteral(Zone* zone, int pos)
627 : cooked_(8, zone), raw_(8, zone), expressions_(8, zone), pos_(pos) {} 627 : cooked_(8, zone), raw_(8, zone), expressions_(8, zone), pos_(pos) {}
628 628
629 const ZoneList<Expression*>* cooked() const { return &cooked_; } 629 const ZoneList<Expression*>* cooked() const { return &cooked_; }
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 cached_parse_data_ != NULL; 777 cached_parse_data_ != NULL;
778 } 778 }
779 bool produce_cached_parse_data() const { 779 bool produce_cached_parse_data() const {
780 return compile_options_ == ScriptCompiler::kProduceParserCache; 780 return compile_options_ == ScriptCompiler::kProduceParserCache;
781 } 781 }
782 782
783 // All ParseXXX functions take as the last argument an *ok parameter 783 // All ParseXXX functions take as the last argument an *ok parameter
784 // which is set to false if parsing failed; it is unchanged otherwise. 784 // which is set to false if parsing failed; it is unchanged otherwise.
785 // By making the 'exception handling' explicit, we are forced to check 785 // By making the 'exception handling' explicit, we are forced to check
786 // for failure at the call sites. 786 // for failure at the call sites.
787 void* ParseStatementList(ZoneList<Statement*>* body, int end_token, bool* ok); 787 void* ParseStatementList(ZoneList<Statement*>* body, int end_token,
788 Statement* ParseStatementListItem(bool* ok); 788 bool top_level, bool* ok);
rossberg 2016/04/20 15:16:34 Instead of this flag, couldn't you simply look at
nickie 2016/04/21 13:57:10 Depending on https://codereview.chromium.org/19067
789 Statement* ParseStatementListItem(bool top_level, bool* ok);
789 void* ParseModuleItemList(ZoneList<Statement*>* body, bool* ok); 790 void* ParseModuleItemList(ZoneList<Statement*>* body, bool* ok);
790 Statement* ParseModuleItem(bool* ok); 791 Statement* ParseModuleItem(bool* ok);
791 const AstRawString* ParseModuleSpecifier(bool* ok); 792 const AstRawString* ParseModuleSpecifier(bool* ok);
792 Statement* ParseImportDeclaration(bool* ok); 793 Statement* ParseImportDeclaration(bool* ok);
793 Statement* ParseExportDeclaration(bool* ok); 794 Statement* ParseExportDeclaration(bool* ok);
794 Statement* ParseExportDefault(bool* ok); 795 Statement* ParseExportDefault(bool* ok);
795 void* ParseExportClause(ZoneList<const AstRawString*>* export_names, 796 void* ParseExportClause(ZoneList<const AstRawString*>* export_names,
796 ZoneList<Scanner::Location>* export_locations, 797 ZoneList<Scanner::Location>* export_locations,
797 ZoneList<const AstRawString*>* local_names, 798 ZoneList<const AstRawString*>* local_names,
798 Scanner::Location* reserved_loc, bool* ok); 799 Scanner::Location* reserved_loc, bool* ok);
799 ZoneList<ImportDeclaration*>* ParseNamedImports(int pos, bool* ok); 800 ZoneList<ImportDeclaration*>* ParseNamedImports(int pos, bool* ok);
800 Statement* ParseStatement(ZoneList<const AstRawString*>* labels, 801 Statement* ParseStatement(ZoneList<const AstRawString*>* labels,
801 AllowLabelledFunctionStatement allow_function, 802 AllowLabelledFunctionStatement allow_function,
802 bool* ok); 803 bool* ok);
803 Statement* ParseSubStatement(ZoneList<const AstRawString*>* labels, 804 Statement* ParseSubStatement(ZoneList<const AstRawString*>* labels,
804 AllowLabelledFunctionStatement allow_function, 805 AllowLabelledFunctionStatement allow_function,
805 bool* ok); 806 bool* ok);
806 Statement* ParseStatementAsUnlabelled(ZoneList<const AstRawString*>* labels, 807 Statement* ParseStatementAsUnlabelled(ZoneList<const AstRawString*>* labels,
807 bool* ok); 808 bool* ok);
808 Statement* ParseFunctionDeclaration(ZoneList<const AstRawString*>* names, 809 Statement* ParseFunctionDeclaration(ZoneList<const AstRawString*>* names,
809 bool* ok); 810 bool ambient, bool* ok);
810 Statement* ParseFunctionDeclaration(int pos, bool is_generator, 811 Statement* ParseFunctionDeclaration(int pos, bool is_generator,
811 ZoneList<const AstRawString*>* names, 812 ZoneList<const AstRawString*>* names,
812 bool* ok); 813 bool ambient, bool* ok);
813 Statement* ParseClassDeclaration(ZoneList<const AstRawString*>* names, 814 Statement* ParseClassDeclaration(ZoneList<const AstRawString*>* names,
814 bool* ok); 815 bool ambient, bool* ok);
815 Statement* ParseNativeDeclaration(bool* ok); 816 Statement* ParseNativeDeclaration(bool* ok);
816 Block* ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok); 817 Block* ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok);
817 Block* ParseBlock(ZoneList<const AstRawString*>* labels, 818 Block* ParseBlock(ZoneList<const AstRawString*>* labels,
818 bool finalize_block_scope, bool* ok); 819 bool finalize_block_scope, bool* ok);
819 Block* ParseVariableStatement(VariableDeclarationContext var_context, 820 Block* ParseVariableStatement(VariableDeclarationContext var_context,
820 ZoneList<const AstRawString*>* names, 821 ZoneList<const AstRawString*>* names,
821 bool* ok); 822 bool ambient, bool* ok);
822 DoExpression* ParseDoExpression(bool* ok); 823 DoExpression* ParseDoExpression(bool* ok);
823 Expression* ParseYieldStarExpression(bool* ok); 824 Expression* ParseYieldStarExpression(bool* ok);
824 825
825 struct DeclarationDescriptor { 826 struct DeclarationDescriptor {
826 enum Kind { NORMAL, PARAMETER }; 827 enum Kind { NORMAL, PARAMETER };
827 Parser* parser; 828 Parser* parser;
828 Scope* scope; 829 Scope* scope;
829 Scope* hoist_scope; 830 Scope* hoist_scope;
830 VariableMode mode; 831 VariableMode mode;
831 int declaration_pos; 832 int declaration_pos;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 const DeclarationDescriptor* descriptor_; 936 const DeclarationDescriptor* descriptor_;
936 ZoneList<const AstRawString*>* names_; 937 ZoneList<const AstRawString*>* names_;
937 Expression* current_value_; 938 Expression* current_value_;
938 int recursion_level_; 939 int recursion_level_;
939 bool* ok_; 940 bool* ok_;
940 }; 941 };
941 942
942 Block* ParseVariableDeclarations(VariableDeclarationContext var_context, 943 Block* ParseVariableDeclarations(VariableDeclarationContext var_context,
943 DeclarationParsingResult* parsing_result, 944 DeclarationParsingResult* parsing_result,
944 ZoneList<const AstRawString*>* names, 945 ZoneList<const AstRawString*>* names,
945 bool* ok); 946 bool ambient, bool* ok);
946 Statement* ParseExpressionOrLabelledStatement( 947 Statement* ParseExpressionOrLabelledStatement(
947 ZoneList<const AstRawString*>* labels, 948 ZoneList<const AstRawString*>* labels,
948 AllowLabelledFunctionStatement allow_function, bool* ok); 949 AllowLabelledFunctionStatement allow_function, bool* ok);
949 IfStatement* ParseIfStatement(ZoneList<const AstRawString*>* labels, 950 IfStatement* ParseIfStatement(ZoneList<const AstRawString*>* labels,
950 bool* ok); 951 bool* ok);
951 Statement* ParseContinueStatement(bool* ok); 952 Statement* ParseContinueStatement(bool* ok);
952 Statement* ParseBreakStatement(ZoneList<const AstRawString*>* labels, 953 Statement* ParseBreakStatement(ZoneList<const AstRawString*>* labels,
953 bool* ok); 954 bool* ok);
954 Statement* ParseReturnStatement(bool* ok); 955 Statement* ParseReturnStatement(bool* ok);
955 Statement* ParseWithStatement(ZoneList<const AstRawString*>* labels, 956 Statement* ParseWithStatement(ZoneList<const AstRawString*>* labels,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 FunctionLiteral* ParseFunctionLiteral( 1000 FunctionLiteral* ParseFunctionLiteral(
1000 const AstRawString* name, Scanner::Location function_name_location, 1001 const AstRawString* name, Scanner::Location function_name_location,
1001 FunctionNameValidity function_name_validity, FunctionKind kind, 1002 FunctionNameValidity function_name_validity, FunctionKind kind,
1002 int function_token_position, FunctionLiteral::FunctionType type, 1003 int function_token_position, FunctionLiteral::FunctionType type,
1003 LanguageMode language_mode, typesystem::TypeFlags type_flags, bool* ok); 1004 LanguageMode language_mode, typesystem::TypeFlags type_flags, bool* ok);
1004 1005
1005 1006
1006 ClassLiteral* ParseClassLiteral(const AstRawString* name, 1007 ClassLiteral* ParseClassLiteral(const AstRawString* name,
1007 Scanner::Location class_name_location, 1008 Scanner::Location class_name_location,
1008 bool name_is_strict_reserved, int pos, 1009 bool name_is_strict_reserved, int pos,
1009 bool* ok); 1010 bool ambient, bool* ok);
1010 1011
1011 // Magical syntax support. 1012 // Magical syntax support.
1012 Expression* ParseV8Intrinsic(bool* ok); 1013 Expression* ParseV8Intrinsic(bool* ok);
1013 1014
1014 // Get odd-ball literals. 1015 // Get odd-ball literals.
1015 Literal* GetLiteralUndefined(int position); 1016 Literal* GetLiteralUndefined(int position);
1016 1017
1017 // Check if the scope has conflicting var/let declarations from different 1018 // Check if the scope has conflicting var/let declarations from different
1018 // scopes. This covers for example 1019 // scopes. This covers for example
1019 // 1020 //
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
1323 1324
1324 DoExpression* ParserTraits::ParseDoExpression(bool* ok) { 1325 DoExpression* ParserTraits::ParseDoExpression(bool* ok) {
1325 return parser_->ParseDoExpression(ok); 1326 return parser_->ParseDoExpression(ok);
1326 } 1327 }
1327 1328
1328 1329
1329 } // namespace internal 1330 } // namespace internal
1330 } // namespace v8 1331 } // namespace v8
1331 1332
1332 #endif // V8_PARSING_PARSER_H_ 1333 #endif // V8_PARSING_PARSER_H_
OLDNEW
« no previous file with comments | « src/messages.h ('k') | src/parsing/parser.cc » ('j') | src/parsing/preparser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698