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

Side by Side Diff: src/preparser.h

Issue 633053002: Do not save/restore AST id generator. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « src/parser.cc ('k') | src/preparser.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_PREPARSER_H 5 #ifndef V8_PREPARSER_H
6 #define V8_PREPARSER_H 6 #define V8_PREPARSER_H
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/bailout-reason.h" 10 #include "src/bailout-reason.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 } 116 }
117 void set_allow_harmony_numeric_literals(bool allow) { 117 void set_allow_harmony_numeric_literals(bool allow) {
118 scanner()->SetHarmonyNumericLiterals(allow); 118 scanner()->SetHarmonyNumericLiterals(allow);
119 } 119 }
120 void set_allow_classes(bool allow) { scanner()->SetHarmonyClasses(allow); } 120 void set_allow_classes(bool allow) { scanner()->SetHarmonyClasses(allow); }
121 void set_allow_harmony_object_literals(bool allow) { 121 void set_allow_harmony_object_literals(bool allow) {
122 allow_harmony_object_literals_ = allow; 122 allow_harmony_object_literals_ = allow;
123 } 123 }
124 124
125 protected: 125 protected:
126 friend class Traits::Checkpoint;
127
128 enum AllowEvalOrArgumentsAsIdentifier { 126 enum AllowEvalOrArgumentsAsIdentifier {
129 kAllowEvalOrArguments, 127 kAllowEvalOrArguments,
130 kDontAllowEvalOrArguments 128 kDontAllowEvalOrArguments
131 }; 129 };
132 130
133 enum Mode { 131 enum Mode {
134 PARSE_LAZILY, 132 PARSE_LAZILY,
135 PARSE_EAGERLY 133 PARSE_EAGERLY
136 }; 134 };
137 135
138 class CheckpointBase; 136 class Checkpoint;
139 class ObjectLiteralChecker; 137 class ObjectLiteralChecker;
140 138
141 // --------------------------------------------------------------------------- 139 // ---------------------------------------------------------------------------
142 // FunctionState and BlockState together implement the parser's scope stack. 140 // FunctionState and BlockState together implement the parser's scope stack.
143 // The parser's current scope is in scope_. BlockState and FunctionState 141 // The parser's current scope is in scope_. BlockState and FunctionState
144 // constructors push on the scope stack and the destructors pop. They are also 142 // constructors push on the scope stack and the destructors pop. They are also
145 // used to hold the parser's per-function and per-block state. 143 // used to hold the parser's per-function and per-block state.
146 class BlockState BASE_EMBEDDED { 144 class BlockState BASE_EMBEDDED {
147 public: 145 public:
148 BlockState(typename Traits::Type::Scope** scope_stack, 146 BlockState(typename Traits::Type::Scope** scope_stack,
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 FunctionState** function_state_stack_; 226 FunctionState** function_state_stack_;
229 FunctionState* outer_function_state_; 227 FunctionState* outer_function_state_;
230 typename Traits::Type::Scope** scope_stack_; 228 typename Traits::Type::Scope** scope_stack_;
231 typename Traits::Type::Scope* outer_scope_; 229 typename Traits::Type::Scope* outer_scope_;
232 AstNode::IdGen* ast_node_id_gen_; // Only used by ParserTraits. 230 AstNode::IdGen* ast_node_id_gen_; // Only used by ParserTraits.
233 AstNode::IdGen saved_id_gen_; // Ditto. 231 AstNode::IdGen saved_id_gen_; // Ditto.
234 typename Traits::Type::Zone* extra_param_; 232 typename Traits::Type::Zone* extra_param_;
235 typename Traits::Type::Factory factory_; 233 typename Traits::Type::Factory factory_;
236 234
237 friend class ParserTraits; 235 friend class ParserTraits;
238 friend class CheckpointBase; 236 friend class Checkpoint;
239 }; 237 };
240 238
241 // Annoyingly, arrow functions first parse as comma expressions, then when we 239 // Annoyingly, arrow functions first parse as comma expressions, then when we
242 // see the => we have to go back and reinterpret the arguments as being formal 240 // see the => we have to go back and reinterpret the arguments as being formal
243 // parameters. To do so we need to reset some of the parser state back to 241 // parameters. To do so we need to reset some of the parser state back to
244 // what it was before the arguments were first seen. 242 // what it was before the arguments were first seen.
245 class CheckpointBase BASE_EMBEDDED { 243 class Checkpoint BASE_EMBEDDED {
246 public: 244 public:
247 explicit CheckpointBase(ParserBase* parser) { 245 explicit Checkpoint(ParserBase* parser) {
248 function_state_ = parser->function_state_; 246 function_state_ = parser->function_state_;
249 next_materialized_literal_index_ = 247 next_materialized_literal_index_ =
250 function_state_->next_materialized_literal_index_; 248 function_state_->next_materialized_literal_index_;
251 next_handler_index_ = function_state_->next_handler_index_; 249 next_handler_index_ = function_state_->next_handler_index_;
252 expected_property_count_ = function_state_->expected_property_count_; 250 expected_property_count_ = function_state_->expected_property_count_;
253 } 251 }
254 252
255 void Restore() { 253 void Restore() {
256 function_state_->next_materialized_literal_index_ = 254 function_state_->next_materialized_literal_index_ =
257 next_materialized_literal_index_; 255 next_materialized_literal_index_;
(...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 typedef PreParserExpression ObjectLiteralProperty; 1140 typedef PreParserExpression ObjectLiteralProperty;
1143 typedef PreParserExpression Literal; 1141 typedef PreParserExpression Literal;
1144 typedef PreParserExpressionList ExpressionList; 1142 typedef PreParserExpressionList ExpressionList;
1145 typedef PreParserExpressionList PropertyList; 1143 typedef PreParserExpressionList PropertyList;
1146 typedef PreParserStatementList StatementList; 1144 typedef PreParserStatementList StatementList;
1147 1145
1148 // For constructing objects returned by the traversing functions. 1146 // For constructing objects returned by the traversing functions.
1149 typedef PreParserFactory Factory; 1147 typedef PreParserFactory Factory;
1150 }; 1148 };
1151 1149
1152 class Checkpoint;
1153
1154 explicit PreParserTraits(PreParser* pre_parser) : pre_parser_(pre_parser) {} 1150 explicit PreParserTraits(PreParser* pre_parser) : pre_parser_(pre_parser) {}
1155 1151
1156 // Custom operations executed when FunctionStates are created and 1152 // Custom operations executed when FunctionStates are created and
1157 // destructed. (The PreParser doesn't need to do anything.) 1153 // destructed. (The PreParser doesn't need to do anything.)
1158 template <typename FunctionState> 1154 template <typename FunctionState>
1159 static void SetUpFunctionState(FunctionState* function_state) {} 1155 static void SetUpFunctionState(FunctionState* function_state) {}
1160 template <typename FunctionState> 1156 template <typename FunctionState>
1161 static void TearDownFunctionState(FunctionState* function_state) {} 1157 static void TearDownFunctionState(FunctionState* function_state) {}
1162 1158
1163 // Helper functions for recursive descent. 1159 // Helper functions for recursive descent.
(...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after
2157 // YieldExpression 2153 // YieldExpression
2158 // LeftHandSideExpression AssignmentOperator AssignmentExpression 2154 // LeftHandSideExpression AssignmentOperator AssignmentExpression
2159 2155
2160 Scanner::Location lhs_location = scanner()->peek_location(); 2156 Scanner::Location lhs_location = scanner()->peek_location();
2161 2157
2162 if (peek() == Token::YIELD && is_generator()) { 2158 if (peek() == Token::YIELD && is_generator()) {
2163 return this->ParseYieldExpression(ok); 2159 return this->ParseYieldExpression(ok);
2164 } 2160 }
2165 2161
2166 if (fni_ != NULL) fni_->Enter(); 2162 if (fni_ != NULL) fni_->Enter();
2167 typename Traits::Checkpoint checkpoint(this); 2163 ParserBase<Traits>::Checkpoint checkpoint(this);
2168 ExpressionT expression = 2164 ExpressionT expression =
2169 this->ParseConditionalExpression(accept_IN, CHECK_OK); 2165 this->ParseConditionalExpression(accept_IN, CHECK_OK);
2170 2166
2171 if (allow_arrow_functions() && peek() == Token::ARROW) { 2167 if (allow_arrow_functions() && peek() == Token::ARROW) {
2172 checkpoint.Restore(); 2168 checkpoint.Restore();
2173 expression = this->ParseArrowFunctionLiteral(lhs_location.beg_pos, 2169 expression = this->ParseArrowFunctionLiteral(lhs_location.beg_pos,
2174 expression, CHECK_OK); 2170 expression, CHECK_OK);
2175 return expression; 2171 return expression;
2176 } 2172 }
2177 2173
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
2845 DCHECK(IsAccessorAccessorConflict(old_type, type)); 2841 DCHECK(IsAccessorAccessorConflict(old_type, type));
2846 // Both accessors of the same type. 2842 // Both accessors of the same type.
2847 parser()->ReportMessage("accessor_get_set"); 2843 parser()->ReportMessage("accessor_get_set");
2848 } 2844 }
2849 *ok = false; 2845 *ok = false;
2850 } 2846 }
2851 } 2847 }
2852 } } // v8::internal 2848 } } // v8::internal
2853 2849
2854 #endif // V8_PREPARSER_H 2850 #endif // V8_PREPARSER_H
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | src/preparser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698