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

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

Issue 1439693002: [runtime] Support Proxy setPrototypeOf trap (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@2015-11-09_new_Proxy_1417063011
Patch Set: merging with master Created 5 years 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
« no previous file with comments | « src/parsing/json-parser.h ('k') | src/parsing/parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 kStartPositionIndex, 210 kStartPositionIndex,
211 kEndPositionIndex, 211 kEndPositionIndex,
212 kLiteralCountIndex, 212 kLiteralCountIndex,
213 kPropertyCountIndex, 213 kPropertyCountIndex,
214 kLanguageModeIndex, 214 kLanguageModeIndex,
215 kUsesSuperPropertyIndex, 215 kUsesSuperPropertyIndex,
216 kCallsEvalIndex, 216 kCallsEvalIndex,
217 kSize 217 kSize
218 }; 218 };
219 219
220 explicit FunctionEntry(Vector<unsigned> backing) 220 explicit FunctionEntry(Vector<unsigned> backing) : backing_(backing) {}
221 : backing_(backing) { }
222 221
223 FunctionEntry() : backing_() { } 222 FunctionEntry() : backing_() {}
224 223
225 int start_pos() { return backing_[kStartPositionIndex]; } 224 int start_pos() { return backing_[kStartPositionIndex]; }
226 int end_pos() { return backing_[kEndPositionIndex]; } 225 int end_pos() { return backing_[kEndPositionIndex]; }
227 int literal_count() { return backing_[kLiteralCountIndex]; } 226 int literal_count() { return backing_[kLiteralCountIndex]; }
228 int property_count() { return backing_[kPropertyCountIndex]; } 227 int property_count() { return backing_[kPropertyCountIndex]; }
229 LanguageMode language_mode() { 228 LanguageMode language_mode() {
230 DCHECK(is_valid_language_mode(backing_[kLanguageModeIndex])); 229 DCHECK(is_valid_language_mode(backing_[kLanguageModeIndex]));
231 return static_cast<LanguageMode>(backing_[kLanguageModeIndex]); 230 return static_cast<LanguageMode>(backing_[kLanguageModeIndex]);
232 } 231 }
233 bool uses_super_property() { return backing_[kUsesSuperPropertyIndex]; } 232 bool uses_super_property() { return backing_[kUsesSuperPropertyIndex]; }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 class BufferedZoneList { 295 class BufferedZoneList {
297 public: 296 public:
298 BufferedZoneList() : list_(NULL), last_(NULL) {} 297 BufferedZoneList() : list_(NULL), last_(NULL) {}
299 298
300 // Adds element at end of list. This element is buffered and can 299 // Adds element at end of list. This element is buffered and can
301 // be read using last() or removed using RemoveLast until a new Add or until 300 // be read using last() or removed using RemoveLast until a new Add or until
302 // RemoveLast or GetList has been called. 301 // RemoveLast or GetList has been called.
303 void Add(T* value, Zone* zone) { 302 void Add(T* value, Zone* zone) {
304 if (last_ != NULL) { 303 if (last_ != NULL) {
305 if (list_ == NULL) { 304 if (list_ == NULL) {
306 list_ = new(zone) ZoneList<T*>(initial_size, zone); 305 list_ = new (zone) ZoneList<T*>(initial_size, zone);
307 } 306 }
308 list_->Add(last_, zone); 307 list_->Add(last_, zone);
309 } 308 }
310 last_ = value; 309 last_ = value;
311 } 310 }
312 311
313 T* last() { 312 T* last() {
314 DCHECK(last_ != NULL); 313 DCHECK(last_ != NULL);
315 return last_; 314 return last_;
316 } 315 }
(...skipping 28 matching lines...) Expand all
345 last_ = NULL; 344 last_ = NULL;
346 } 345 }
347 346
348 int length() { 347 int length() {
349 int length = (list_ == NULL) ? 0 : list_->length(); 348 int length = (list_ == NULL) ? 0 : list_->length();
350 return length + ((last_ == NULL) ? 0 : 1); 349 return length + ((last_ == NULL) ? 0 : 1);
351 } 350 }
352 351
353 ZoneList<T*>* GetList(Zone* zone) { 352 ZoneList<T*>* GetList(Zone* zone) {
354 if (list_ == NULL) { 353 if (list_ == NULL) {
355 list_ = new(zone) ZoneList<T*>(initial_size, zone); 354 list_ = new (zone) ZoneList<T*>(initial_size, zone);
356 } 355 }
357 if (last_ != NULL) { 356 if (last_ != NULL) {
358 list_->Add(last_, zone); 357 list_->Add(last_, zone);
359 last_ = NULL; 358 last_ = NULL;
360 } 359 }
361 return list_; 360 return list_;
362 } 361 }
363 362
364 private: 363 private:
365 ZoneList<T*>* list_; 364 ZoneList<T*>* list_;
366 T* last_; 365 T* last_;
367 }; 366 };
368 367
369 368
370 // Accumulates RegExp atoms and assertions into lists of terms and alternatives. 369 // Accumulates RegExp atoms and assertions into lists of terms and alternatives.
371 class RegExpBuilder: public ZoneObject { 370 class RegExpBuilder : public ZoneObject {
372 public: 371 public:
373 explicit RegExpBuilder(Zone* zone); 372 explicit RegExpBuilder(Zone* zone);
374 void AddCharacter(uc16 character); 373 void AddCharacter(uc16 character);
375 // "Adds" an empty expression. Does nothing except consume a 374 // "Adds" an empty expression. Does nothing except consume a
376 // following quantifier 375 // following quantifier
377 void AddEmpty(); 376 void AddEmpty();
378 void AddAtom(RegExpTree* tree); 377 void AddAtom(RegExpTree* tree);
379 void AddAssertion(RegExpTree* tree); 378 void AddAssertion(RegExpTree* tree);
380 void NewAlternative(); // '|' 379 void NewAlternative(); // '|'
381 void AddQuantifierToAtom( 380 void AddQuantifierToAtom(int min, int max,
382 int min, int max, RegExpQuantifier::QuantifierType type); 381 RegExpQuantifier::QuantifierType type);
383 RegExpTree* ToRegExp(); 382 RegExpTree* ToRegExp();
384 383
385 private: 384 private:
386 void FlushCharacters(); 385 void FlushCharacters();
387 void FlushText(); 386 void FlushText();
388 void FlushTerms(); 387 void FlushTerms();
389 Zone* zone() const { return zone_; } 388 Zone* zone() const { return zone_; }
390 389
391 Zone* zone_; 390 Zone* zone_;
392 bool pending_empty_; 391 bool pending_empty_;
393 ZoneList<uc16>* characters_; 392 ZoneList<uc16>* characters_;
394 BufferedZoneList<RegExpTree, 2> terms_; 393 BufferedZoneList<RegExpTree, 2> terms_;
395 BufferedZoneList<RegExpTree, 2> text_; 394 BufferedZoneList<RegExpTree, 2> text_;
396 BufferedZoneList<RegExpTree, 2> alternatives_; 395 BufferedZoneList<RegExpTree, 2> alternatives_;
397 #ifdef DEBUG 396 #ifdef DEBUG
398 enum {ADD_NONE, ADD_CHAR, ADD_TERM, ADD_ASSERT, ADD_ATOM} last_added_; 397 enum { ADD_NONE, ADD_CHAR, ADD_TERM, ADD_ASSERT, ADD_ATOM } last_added_;
399 #define LAST(x) last_added_ = x; 398 #define LAST(x) last_added_ = x;
400 #else 399 #else
401 #define LAST(x) 400 #define LAST(x)
402 #endif 401 #endif
403 }; 402 };
404 403
405 404
406 class RegExpParser BASE_EMBEDDED { 405 class RegExpParser BASE_EMBEDDED {
407 public: 406 public:
408 RegExpParser(FlatStringReader* in, Handle<String>* error, bool multiline_mode, 407 RegExpParser(FlatStringReader* in, Handle<String>* error, bool multiline_mode,
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 void ReportMessage(MessageTemplate::Template message, const char* arg = NULL, 726 void ReportMessage(MessageTemplate::Template message, const char* arg = NULL,
728 ParseErrorType error_type = kSyntaxError); 727 ParseErrorType error_type = kSyntaxError);
729 void ReportMessage(MessageTemplate::Template message, const AstRawString* arg, 728 void ReportMessage(MessageTemplate::Template message, const AstRawString* arg,
730 ParseErrorType error_type = kSyntaxError); 729 ParseErrorType error_type = kSyntaxError);
731 void ReportMessageAt(Scanner::Location source_location, 730 void ReportMessageAt(Scanner::Location source_location,
732 MessageTemplate::Template message, 731 MessageTemplate::Template message,
733 const AstRawString* arg, 732 const AstRawString* arg,
734 ParseErrorType error_type = kSyntaxError); 733 ParseErrorType error_type = kSyntaxError);
735 734
736 // "null" return type creators. 735 // "null" return type creators.
737 static const AstRawString* EmptyIdentifier() { 736 static const AstRawString* EmptyIdentifier() { return NULL; }
738 return NULL; 737 static Expression* EmptyExpression() { return NULL; }
739 } 738 static Literal* EmptyLiteral() { return NULL; }
740 static Expression* EmptyExpression() {
741 return NULL;
742 }
743 static Literal* EmptyLiteral() {
744 return NULL;
745 }
746 static ObjectLiteralProperty* EmptyObjectLiteralProperty() { return NULL; } 739 static ObjectLiteralProperty* EmptyObjectLiteralProperty() { return NULL; }
747 static FunctionLiteral* EmptyFunctionLiteral() { return NULL; } 740 static FunctionLiteral* EmptyFunctionLiteral() { return NULL; }
748 741
749 // Used in error return values. 742 // Used in error return values.
750 static ZoneList<Expression*>* NullExpressionList() { 743 static ZoneList<Expression*>* NullExpressionList() { return NULL; }
751 return NULL;
752 }
753 static const AstRawString* EmptyFormalParameter() { return NULL; } 744 static const AstRawString* EmptyFormalParameter() { return NULL; }
754 745
755 // Non-NULL empty string. 746 // Non-NULL empty string.
756 V8_INLINE const AstRawString* EmptyIdentifierString(); 747 V8_INLINE const AstRawString* EmptyIdentifierString();
757 748
758 // Odd-ball literal creators. 749 // Odd-ball literal creators.
759 Literal* GetLiteralTheHole(int position, AstNodeFactory* factory); 750 Literal* GetLiteralTheHole(int position, AstNodeFactory* factory);
760 751
761 // Producing data during the recursive descent. 752 // Producing data during the recursive descent.
762 const AstRawString* GetSymbol(Scanner* scanner); 753 const AstRawString* GetSymbol(Scanner* scanner);
(...skipping 12 matching lines...) Expand all
775 int end_pos, LanguageMode language_mode); 766 int end_pos, LanguageMode language_mode);
776 Literal* ExpressionFromLiteral(Token::Value token, int pos, Scanner* scanner, 767 Literal* ExpressionFromLiteral(Token::Value token, int pos, Scanner* scanner,
777 AstNodeFactory* factory); 768 AstNodeFactory* factory);
778 Expression* ExpressionFromIdentifier(const AstRawString* name, 769 Expression* ExpressionFromIdentifier(const AstRawString* name,
779 int start_position, int end_position, 770 int start_position, int end_position,
780 Scope* scope, AstNodeFactory* factory); 771 Scope* scope, AstNodeFactory* factory);
781 Expression* ExpressionFromString(int pos, Scanner* scanner, 772 Expression* ExpressionFromString(int pos, Scanner* scanner,
782 AstNodeFactory* factory); 773 AstNodeFactory* factory);
783 Expression* GetIterator(Expression* iterable, AstNodeFactory* factory); 774 Expression* GetIterator(Expression* iterable, AstNodeFactory* factory);
784 ZoneList<v8::internal::Expression*>* NewExpressionList(int size, Zone* zone) { 775 ZoneList<v8::internal::Expression*>* NewExpressionList(int size, Zone* zone) {
785 return new(zone) ZoneList<v8::internal::Expression*>(size, zone); 776 return new (zone) ZoneList<v8::internal::Expression*>(size, zone);
786 } 777 }
787 ZoneList<ObjectLiteral::Property*>* NewPropertyList(int size, Zone* zone) { 778 ZoneList<ObjectLiteral::Property*>* NewPropertyList(int size, Zone* zone) {
788 return new(zone) ZoneList<ObjectLiteral::Property*>(size, zone); 779 return new (zone) ZoneList<ObjectLiteral::Property*>(size, zone);
789 } 780 }
790 ZoneList<v8::internal::Statement*>* NewStatementList(int size, Zone* zone) { 781 ZoneList<v8::internal::Statement*>* NewStatementList(int size, Zone* zone) {
791 return new(zone) ZoneList<v8::internal::Statement*>(size, zone); 782 return new (zone) ZoneList<v8::internal::Statement*>(size, zone);
792 } 783 }
793 784
794 V8_INLINE void AddParameterInitializationBlock( 785 V8_INLINE void AddParameterInitializationBlock(
795 const ParserFormalParameters& parameters, 786 const ParserFormalParameters& parameters,
796 ZoneList<v8::internal::Statement*>* body, bool* ok); 787 ZoneList<v8::internal::Statement*>* body, bool* ok);
797 788
798 V8_INLINE Scope* NewScope(Scope* parent_scope, ScopeType scope_type, 789 V8_INLINE Scope* NewScope(Scope* parent_scope, ScopeType scope_type,
799 FunctionKind kind = kNormalFunction); 790 FunctionKind kind = kNormalFunction);
800 791
801 V8_INLINE void AddFormalParameter(ParserFormalParameters* parameters, 792 V8_INLINE void AddFormalParameter(ParserFormalParameters* parameters,
802 Expression* pattern, 793 Expression* pattern,
803 Expression* initializer, 794 Expression* initializer,
804 int initializer_end_position, bool is_rest); 795 int initializer_end_position, bool is_rest);
805 V8_INLINE void DeclareFormalParameter( 796 V8_INLINE void DeclareFormalParameter(
806 Scope* scope, const ParserFormalParameters::Parameter& parameter, 797 Scope* scope, const ParserFormalParameters::Parameter& parameter,
807 ExpressionClassifier* classifier); 798 ExpressionClassifier* classifier);
808 void ParseArrowFunctionFormalParameters(ParserFormalParameters* parameters, 799 void ParseArrowFunctionFormalParameters(ParserFormalParameters* parameters,
809 Expression* params, 800 Expression* params,
810 const Scanner::Location& params_loc, 801 const Scanner::Location& params_loc,
811 bool* ok); 802 bool* ok);
812 void ParseArrowFunctionFormalParameterList( 803 void ParseArrowFunctionFormalParameterList(
813 ParserFormalParameters* parameters, Expression* params, 804 ParserFormalParameters* parameters, Expression* params,
814 const Scanner::Location& params_loc, 805 const Scanner::Location& params_loc, Scanner::Location* duplicate_loc,
815 Scanner::Location* duplicate_loc, bool* ok); 806 bool* ok);
816 807
817 V8_INLINE DoExpression* ParseDoExpression(bool* ok); 808 V8_INLINE DoExpression* ParseDoExpression(bool* ok);
818 809
819 void ReindexLiterals(const ParserFormalParameters& parameters); 810 void ReindexLiterals(const ParserFormalParameters& parameters);
820 811
821 // Temporary glue; these functions will move to ParserBase. 812 // Temporary glue; these functions will move to ParserBase.
822 Expression* ParseV8Intrinsic(bool* ok); 813 Expression* ParseV8Intrinsic(bool* ok);
823 FunctionLiteral* ParseFunctionLiteral( 814 FunctionLiteral* ParseFunctionLiteral(
824 const AstRawString* name, Scanner::Location function_name_location, 815 const AstRawString* name, Scanner::Location function_name_location,
825 FunctionNameValidity function_name_validity, FunctionKind kind, 816 FunctionNameValidity function_name_validity, FunctionKind kind,
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 return compile_options_; 940 return compile_options_;
950 } 941 }
951 bool consume_cached_parse_data() const { 942 bool consume_cached_parse_data() const {
952 return compile_options_ == ScriptCompiler::kConsumeParserCache && 943 return compile_options_ == ScriptCompiler::kConsumeParserCache &&
953 cached_parse_data_ != NULL; 944 cached_parse_data_ != NULL;
954 } 945 }
955 bool produce_cached_parse_data() const { 946 bool produce_cached_parse_data() const {
956 return compile_options_ == ScriptCompiler::kProduceParserCache; 947 return compile_options_ == ScriptCompiler::kProduceParserCache;
957 } 948 }
958 Scope* DeclarationScope(VariableMode mode) { 949 Scope* DeclarationScope(VariableMode mode) {
959 return IsLexicalVariableMode(mode) 950 return IsLexicalVariableMode(mode) ? scope_ : scope_->DeclarationScope();
960 ? scope_ : scope_->DeclarationScope();
961 } 951 }
962 952
963 // All ParseXXX functions take as the last argument an *ok parameter 953 // All ParseXXX functions take as the last argument an *ok parameter
964 // which is set to false if parsing failed; it is unchanged otherwise. 954 // which is set to false if parsing failed; it is unchanged otherwise.
965 // By making the 'exception handling' explicit, we are forced to check 955 // By making the 'exception handling' explicit, we are forced to check
966 // for failure at the call sites. 956 // for failure at the call sites.
967 void* ParseStatementList(ZoneList<Statement*>* body, int end_token, bool* ok); 957 void* ParseStatementList(ZoneList<Statement*>* body, int end_token, bool* ok);
968 Statement* ParseStatementListItem(bool* ok); 958 Statement* ParseStatementListItem(bool* ok);
969 void* ParseModuleItemList(ZoneList<Statement*>* body, bool* ok); 959 void* ParseModuleItemList(ZoneList<Statement*>* body, bool* ok);
970 Statement* ParseModuleItem(bool* ok); 960 Statement* ParseModuleItem(bool* ok);
971 const AstRawString* ParseModuleSpecifier(bool* ok); 961 const AstRawString* ParseModuleSpecifier(bool* ok);
972 Statement* ParseImportDeclaration(bool* ok); 962 Statement* ParseImportDeclaration(bool* ok);
973 Statement* ParseExportDeclaration(bool* ok); 963 Statement* ParseExportDeclaration(bool* ok);
974 Statement* ParseExportDefault(bool* ok); 964 Statement* ParseExportDefault(bool* ok);
975 void* ParseExportClause(ZoneList<const AstRawString*>* export_names, 965 void* ParseExportClause(ZoneList<const AstRawString*>* export_names,
976 ZoneList<Scanner::Location>* export_locations, 966 ZoneList<Scanner::Location>* export_locations,
977 ZoneList<const AstRawString*>* local_names, 967 ZoneList<const AstRawString*>* local_names,
978 Scanner::Location* reserved_loc, bool* ok); 968 Scanner::Location* reserved_loc, bool* ok);
979 ZoneList<ImportDeclaration*>* ParseNamedImports(int pos, bool* ok); 969 ZoneList<ImportDeclaration*>* ParseNamedImports(int pos, bool* ok);
980 Statement* ParseStatement(ZoneList<const AstRawString*>* labels, bool* ok); 970 Statement* ParseStatement(ZoneList<const AstRawString*>* labels, bool* ok);
981 Statement* ParseSubStatement(ZoneList<const AstRawString*>* labels, bool* ok); 971 Statement* ParseSubStatement(ZoneList<const AstRawString*>* labels, bool* ok);
982 Statement* ParseStatementAsUnlabelled(ZoneList<const AstRawString*>* labels, 972 Statement* ParseStatementAsUnlabelled(ZoneList<const AstRawString*>* labels,
983 bool* ok); 973 bool* ok);
984 Statement* ParseFunctionDeclaration(ZoneList<const AstRawString*>* names, 974 Statement* ParseFunctionDeclaration(ZoneList<const AstRawString*>* names,
985 bool* ok); 975 bool* ok);
986 Statement* ParseClassDeclaration(ZoneList<const AstRawString*>* names, 976 Statement* ParseClassDeclaration(ZoneList<const AstRawString*>* names,
987 bool* ok); 977 bool* ok);
988 Statement* ParseNativeDeclaration(bool* ok); 978 Statement* ParseNativeDeclaration(bool* ok);
989 Block* ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok); 979 Block* ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok);
990 Block* ParseVariableStatement(VariableDeclarationContext var_context, 980 Block* ParseVariableStatement(VariableDeclarationContext var_context,
991 ZoneList<const AstRawString*>* names, 981 ZoneList<const AstRawString*>* names, bool* ok);
992 bool* ok);
993 DoExpression* ParseDoExpression(bool* ok); 982 DoExpression* ParseDoExpression(bool* ok);
994 983
995 struct DeclarationDescriptor { 984 struct DeclarationDescriptor {
996 enum Kind { NORMAL, PARAMETER }; 985 enum Kind { NORMAL, PARAMETER };
997 Parser* parser; 986 Parser* parser;
998 Scope* declaration_scope; 987 Scope* declaration_scope;
999 Scope* scope; 988 Scope* scope;
1000 Scope* hoist_scope; 989 Scope* hoist_scope;
1001 VariableMode mode; 990 VariableMode mode;
1002 bool is_const; 991 bool is_const;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 TryStatement* ParseTryStatement(bool* ok); 1091 TryStatement* ParseTryStatement(bool* ok);
1103 DebuggerStatement* ParseDebuggerStatement(bool* ok); 1092 DebuggerStatement* ParseDebuggerStatement(bool* ok);
1104 1093
1105 // !%_IsSpecObject(result = iterator.next()) && 1094 // !%_IsSpecObject(result = iterator.next()) &&
1106 // %ThrowIteratorResultNotAnObject(result) 1095 // %ThrowIteratorResultNotAnObject(result)
1107 Expression* BuildIteratorNextResult(Expression* iterator, Variable* result, 1096 Expression* BuildIteratorNextResult(Expression* iterator, Variable* result,
1108 int pos); 1097 int pos);
1109 1098
1110 1099
1111 // Initialize the components of a for-in / for-of statement. 1100 // Initialize the components of a for-in / for-of statement.
1112 void InitializeForEachStatement(ForEachStatement* stmt, 1101 void InitializeForEachStatement(ForEachStatement* stmt, Expression* each,
1113 Expression* each, 1102 Expression* subject, Statement* body);
1114 Expression* subject,
1115 Statement* body);
1116 Statement* DesugarLexicalBindingsInForStatement( 1103 Statement* DesugarLexicalBindingsInForStatement(
1117 Scope* inner_scope, bool is_const, ZoneList<const AstRawString*>* names, 1104 Scope* inner_scope, bool is_const, ZoneList<const AstRawString*>* names,
1118 ForStatement* loop, Statement* init, Expression* cond, Statement* next, 1105 ForStatement* loop, Statement* init, Expression* cond, Statement* next,
1119 Statement* body, bool* ok); 1106 Statement* body, bool* ok);
1120 1107
1121 void RewriteDoExpression(Expression* expr, bool* ok); 1108 void RewriteDoExpression(Expression* expr, bool* ok);
1122 1109
1123 FunctionLiteral* ParseFunctionLiteral( 1110 FunctionLiteral* ParseFunctionLiteral(
1124 const AstRawString* name, Scanner::Location function_name_location, 1111 const AstRawString* name, Scanner::Location function_name_location,
1125 FunctionNameValidity function_name_validity, FunctionKind kind, 1112 FunctionNameValidity function_name_validity, FunctionKind kind,
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1211 ZoneList<v8::internal::Expression*>* args, int pos); 1198 ZoneList<v8::internal::Expression*>* args, int pos);
1212 Expression* SpreadCallNew(Expression* function, 1199 Expression* SpreadCallNew(Expression* function,
1213 ZoneList<v8::internal::Expression*>* args, int pos); 1200 ZoneList<v8::internal::Expression*>* args, int pos);
1214 1201
1215 void SetLanguageMode(Scope* scope, LanguageMode mode); 1202 void SetLanguageMode(Scope* scope, LanguageMode mode);
1216 void RaiseLanguageMode(LanguageMode mode); 1203 void RaiseLanguageMode(LanguageMode mode);
1217 1204
1218 Scanner scanner_; 1205 Scanner scanner_;
1219 PreParser* reusable_preparser_; 1206 PreParser* reusable_preparser_;
1220 Scope* original_scope_; // for ES5 function declarations in sloppy eval 1207 Scope* original_scope_; // for ES5 function declarations in sloppy eval
1221 Target* target_stack_; // for break, continue statements 1208 Target* target_stack_; // for break, continue statements
1222 ScriptCompiler::CompileOptions compile_options_; 1209 ScriptCompiler::CompileOptions compile_options_;
1223 ParseData* cached_parse_data_; 1210 ParseData* cached_parse_data_;
1224 1211
1225 PendingCompilationErrorHandler pending_error_handler_; 1212 PendingCompilationErrorHandler pending_error_handler_;
1226 1213
1227 // Other information which will be stored in Parser and moved to Isolate after 1214 // Other information which will be stored in Parser and moved to Isolate after
1228 // parsing. 1215 // parsing.
1229 int use_counts_[v8::Isolate::kUseCounterFeatureCount]; 1216 int use_counts_[v8::Isolate::kUseCounterFeatureCount];
1230 int total_preparse_skipped_; 1217 int total_preparse_skipped_;
1231 HistogramTimer* pre_parse_timer_; 1218 HistogramTimer* pre_parse_timer_;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1268 1255
1269 1256
1270 void ParserTraits::CheckConflictingVarDeclarations(v8::internal::Scope* scope, 1257 void ParserTraits::CheckConflictingVarDeclarations(v8::internal::Scope* scope,
1271 bool* ok) { 1258 bool* ok) {
1272 parser_->CheckConflictingVarDeclarations(scope, ok); 1259 parser_->CheckConflictingVarDeclarations(scope, ok);
1273 } 1260 }
1274 1261
1275 1262
1276 // Support for handling complex values (array and object literals) that 1263 // Support for handling complex values (array and object literals) that
1277 // can be fully handled at compile time. 1264 // can be fully handled at compile time.
1278 class CompileTimeValue: public AllStatic { 1265 class CompileTimeValue : public AllStatic {
1279 public: 1266 public:
1280 enum LiteralType { 1267 enum LiteralType {
1281 OBJECT_LITERAL_FAST_ELEMENTS, 1268 OBJECT_LITERAL_FAST_ELEMENTS,
1282 OBJECT_LITERAL_SLOW_ELEMENTS, 1269 OBJECT_LITERAL_SLOW_ELEMENTS,
1283 ARRAY_LITERAL 1270 ARRAY_LITERAL
1284 }; 1271 };
1285 1272
1286 static bool IsCompileTimeValue(Expression* expression); 1273 static bool IsCompileTimeValue(Expression* expression);
1287 1274
1288 // Get the value as a compile time value. 1275 // Get the value as a compile time value.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1365 1352
1366 void ParserTraits::DeclareFormalParameter( 1353 void ParserTraits::DeclareFormalParameter(
1367 Scope* scope, const ParserFormalParameters::Parameter& parameter, 1354 Scope* scope, const ParserFormalParameters::Parameter& parameter,
1368 ExpressionClassifier* classifier) { 1355 ExpressionClassifier* classifier) {
1369 bool is_duplicate = false; 1356 bool is_duplicate = false;
1370 bool is_simple = classifier->is_simple_parameter_list(); 1357 bool is_simple = classifier->is_simple_parameter_list();
1371 auto name = parameter.name; 1358 auto name = parameter.name;
1372 auto mode = is_simple ? VAR : TEMPORARY; 1359 auto mode = is_simple ? VAR : TEMPORARY;
1373 if (!is_simple) scope->SetHasNonSimpleParameters(); 1360 if (!is_simple) scope->SetHasNonSimpleParameters();
1374 bool is_optional = parameter.initializer != nullptr; 1361 bool is_optional = parameter.initializer != nullptr;
1375 Variable* var = scope->DeclareParameter( 1362 Variable* var = scope->DeclareParameter(name, mode, is_optional,
1376 name, mode, is_optional, parameter.is_rest, &is_duplicate); 1363 parameter.is_rest, &is_duplicate);
1377 if (is_duplicate) { 1364 if (is_duplicate) {
1378 classifier->RecordDuplicateFormalParameterError( 1365 classifier->RecordDuplicateFormalParameterError(
1379 parser_->scanner()->location()); 1366 parser_->scanner()->location());
1380 } 1367 }
1381 if (is_sloppy(scope->language_mode())) { 1368 if (is_sloppy(scope->language_mode())) {
1382 // TODO(sigurds) Mark every parameter as maybe assigned. This is a 1369 // TODO(sigurds) Mark every parameter as maybe assigned. This is a
1383 // conservative approximation necessary to account for parameters 1370 // conservative approximation necessary to account for parameters
1384 // that are assigned via the arguments array. 1371 // that are assigned via the arguments array.
1385 var->set_maybe_assigned(); 1372 var->set_maybe_assigned();
1386 } 1373 }
(...skipping 16 matching lines...) Expand all
1403 1390
1404 DoExpression* ParserTraits::ParseDoExpression(bool* ok) { 1391 DoExpression* ParserTraits::ParseDoExpression(bool* ok) {
1405 return parser_->ParseDoExpression(ok); 1392 return parser_->ParseDoExpression(ok);
1406 } 1393 }
1407 1394
1408 1395
1409 } // namespace internal 1396 } // namespace internal
1410 } // namespace v8 1397 } // namespace v8
1411 1398
1412 #endif // V8_PARSING_PARSER_H_ 1399 #endif // V8_PARSING_PARSER_H_
OLDNEW
« no previous file with comments | « src/parsing/json-parser.h ('k') | src/parsing/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698