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

Side by Side Diff: src/parser.h

Issue 1077153005: Allow eval/arguments in arrow functions (Closed) Base URL: https://chromium.googlesource.com/v8/v8@master
Patch Set: Created 5 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
« no previous file with comments | « src/messages.js ('k') | src/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_PARSER_H_ 5 #ifndef V8_PARSER_H_
6 #define V8_PARSER_H_ 6 #define V8_PARSER_H_
7 7
8 #include "src/allocation.h" 8 #include "src/allocation.h"
9 #include "src/ast.h" 9 #include "src/ast.h"
10 #include "src/compiler.h" // TODO(titzer): remove this include dependency 10 #include "src/compiler.h" // TODO(titzer): remove this include dependency
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 const AstRawString* arg, 689 const AstRawString* arg,
690 ParseErrorType error_type = kSyntaxError); 690 ParseErrorType error_type = kSyntaxError);
691 691
692 // "null" return type creators. 692 // "null" return type creators.
693 static const AstRawString* EmptyIdentifier() { 693 static const AstRawString* EmptyIdentifier() {
694 return NULL; 694 return NULL;
695 } 695 }
696 static Expression* EmptyExpression() { 696 static Expression* EmptyExpression() {
697 return NULL; 697 return NULL;
698 } 698 }
699 static Expression* EmptyArrowParamList() { return NULL; }
700 static Literal* EmptyLiteral() { 699 static Literal* EmptyLiteral() {
701 return NULL; 700 return NULL;
702 } 701 }
703 static ObjectLiteralProperty* EmptyObjectLiteralProperty() { return NULL; } 702 static ObjectLiteralProperty* EmptyObjectLiteralProperty() { return NULL; }
704 static FunctionLiteral* EmptyFunctionLiteral() { return NULL; } 703 static FunctionLiteral* EmptyFunctionLiteral() { return NULL; }
705 704
706 // Used in error return values. 705 // Used in error return values.
707 static ZoneList<Expression*>* NullExpressionList() { 706 static ZoneList<Expression*>* NullExpressionList() {
708 return NULL; 707 return NULL;
709 } 708 }
(...skipping 29 matching lines...) Expand all
739 } 738 }
740 ZoneList<ObjectLiteral::Property*>* NewPropertyList(int size, Zone* zone) { 739 ZoneList<ObjectLiteral::Property*>* NewPropertyList(int size, Zone* zone) {
741 return new(zone) ZoneList<ObjectLiteral::Property*>(size, zone); 740 return new(zone) ZoneList<ObjectLiteral::Property*>(size, zone);
742 } 741 }
743 ZoneList<v8::internal::Statement*>* NewStatementList(int size, Zone* zone) { 742 ZoneList<v8::internal::Statement*>* NewStatementList(int size, Zone* zone) {
744 return new(zone) ZoneList<v8::internal::Statement*>(size, zone); 743 return new(zone) ZoneList<v8::internal::Statement*>(size, zone);
745 } 744 }
746 V8_INLINE Scope* NewScope(Scope* parent_scope, ScopeType scope_type, 745 V8_INLINE Scope* NewScope(Scope* parent_scope, ScopeType scope_type,
747 FunctionKind kind = kNormalFunction); 746 FunctionKind kind = kNormalFunction);
748 747
749 // Utility functions
750 int DeclareArrowParametersFromExpression(Expression* expression, Scope* scope,
751 FormalParameterErrorLocations* locs,
752 bool* ok);
753
754 bool DeclareFormalParameter(Scope* scope, const AstRawString* name, 748 bool DeclareFormalParameter(Scope* scope, const AstRawString* name,
755 bool is_rest) { 749 bool is_rest) {
756 bool is_duplicate = false; 750 bool is_duplicate = false;
757 Variable* var = scope->DeclareParameter(name, VAR, is_rest, &is_duplicate); 751 Variable* var = scope->DeclareParameter(name, VAR, is_rest, &is_duplicate);
758 if (is_sloppy(scope->language_mode())) { 752 if (is_sloppy(scope->language_mode())) {
759 // TODO(sigurds) Mark every parameter as maybe assigned. This is a 753 // TODO(sigurds) Mark every parameter as maybe assigned. This is a
760 // conservative approximation necessary to account for parameters 754 // conservative approximation necessary to account for parameters
761 // that are assigned via the arguments array. 755 // that are assigned via the arguments array.
762 var->set_maybe_assigned(); 756 var->set_maybe_assigned();
763 } 757 }
764 return is_duplicate; 758 return is_duplicate;
765 } 759 }
766 760
761 void DeclareArrowFunctionParameters(Scope* scope, Expression* expr,
762 const Scanner::Location& params_loc,
763 FormalParameterErrorLocations* error_locs,
764 bool* ok);
765 void ParseArrowFunctionFormalParameters(
766 Scope* scope, Expression* params, const Scanner::Location& params_loc,
767 FormalParameterErrorLocations* error_locs, bool* is_rest, bool* ok);
768
767 // Temporary glue; these functions will move to ParserBase. 769 // Temporary glue; these functions will move to ParserBase.
768 Expression* ParseV8Intrinsic(bool* ok); 770 Expression* ParseV8Intrinsic(bool* ok);
769 FunctionLiteral* ParseFunctionLiteral( 771 FunctionLiteral* ParseFunctionLiteral(
770 const AstRawString* name, Scanner::Location function_name_location, 772 const AstRawString* name, Scanner::Location function_name_location,
771 bool name_is_strict_reserved, FunctionKind kind, 773 bool name_is_strict_reserved, FunctionKind kind,
772 int function_token_position, FunctionLiteral::FunctionType type, 774 int function_token_position, FunctionLiteral::FunctionType type,
773 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); 775 FunctionLiteral::ArityRestriction arity_restriction, bool* ok);
774 V8_INLINE void SkipLazyFunctionBody(const AstRawString* name, 776 V8_INLINE void SkipLazyFunctionBody(const AstRawString* name,
775 int* materialized_literal_count, 777 int* materialized_literal_count,
776 int* expected_property_count, bool* ok); 778 int* expected_property_count, bool* ok);
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 Expression* SpreadCallNew(Expression* function, 1055 Expression* SpreadCallNew(Expression* function,
1054 ZoneList<v8::internal::Expression*>* args, int pos); 1056 ZoneList<v8::internal::Expression*>* args, int pos);
1055 1057
1056 Scanner scanner_; 1058 Scanner scanner_;
1057 PreParser* reusable_preparser_; 1059 PreParser* reusable_preparser_;
1058 Scope* original_scope_; // for ES5 function declarations in sloppy eval 1060 Scope* original_scope_; // for ES5 function declarations in sloppy eval
1059 Target* target_stack_; // for break, continue statements 1061 Target* target_stack_; // for break, continue statements
1060 ScriptCompiler::CompileOptions compile_options_; 1062 ScriptCompiler::CompileOptions compile_options_;
1061 ParseData* cached_parse_data_; 1063 ParseData* cached_parse_data_;
1062 1064
1063 bool parsing_lazy_arrow_parameters_; // for lazily parsed arrow functions.
1064
1065 PendingCompilationErrorHandler pending_error_handler_; 1065 PendingCompilationErrorHandler pending_error_handler_;
1066 1066
1067 // Other information which will be stored in Parser and moved to Isolate after 1067 // Other information which will be stored in Parser and moved to Isolate after
1068 // parsing. 1068 // parsing.
1069 int use_counts_[v8::Isolate::kUseCounterFeatureCount]; 1069 int use_counts_[v8::Isolate::kUseCounterFeatureCount];
1070 int total_preparse_skipped_; 1070 int total_preparse_skipped_;
1071 HistogramTimer* pre_parse_timer_; 1071 HistogramTimer* pre_parse_timer_;
1072 1072
1073 bool parsing_on_main_thread_; 1073 bool parsing_on_main_thread_;
1074 }; 1074 };
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 } 1177 }
1178 1178
1179 1179
1180 Expression* ParserTraits::SpreadCallNew( 1180 Expression* ParserTraits::SpreadCallNew(
1181 Expression* function, ZoneList<v8::internal::Expression*>* args, int pos) { 1181 Expression* function, ZoneList<v8::internal::Expression*>* args, int pos) {
1182 return parser_->SpreadCallNew(function, args, pos); 1182 return parser_->SpreadCallNew(function, args, pos);
1183 } 1183 }
1184 } } // namespace v8::internal 1184 } } // namespace v8::internal
1185 1185
1186 #endif // V8_PARSER_H_ 1186 #endif // V8_PARSER_H_
OLDNEW
« no previous file with comments | « src/messages.js ('k') | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698