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

Side by Side Diff: src/parser.h

Issue 485473004: Refactor parser Checkpoints. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased Created 6 years, 4 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 | « no previous file | 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" // For CachedDataMode 10 #include "src/compiler.h" // For CachedDataMode
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 // TODO(marja): To be removed. The Traits object should contain all the data 348 // TODO(marja): To be removed. The Traits object should contain all the data
349 // it needs. 349 // it needs.
350 typedef v8::internal::Parser* Parser; 350 typedef v8::internal::Parser* Parser;
351 351
352 // Used by FunctionState and BlockState. 352 // Used by FunctionState and BlockState.
353 typedef v8::internal::Scope Scope; 353 typedef v8::internal::Scope Scope;
354 typedef v8::internal::Scope* ScopePtr; 354 typedef v8::internal::Scope* ScopePtr;
355 typedef Variable GeneratorVariable; 355 typedef Variable GeneratorVariable;
356 typedef v8::internal::Zone Zone; 356 typedef v8::internal::Zone Zone;
357 357
358 class Checkpoint BASE_EMBEDDED {
359 public:
360 template <typename Parser>
361 explicit Checkpoint(Parser* parser) {
362 isolate_ = parser->zone()->isolate();
363 saved_ast_node_id_ = isolate_->ast_node_id();
364 }
365
366 void Restore() { isolate_->set_ast_node_id(saved_ast_node_id_); }
367
368 private:
369 Isolate* isolate_;
370 int saved_ast_node_id_;
371 };
372
373 typedef v8::internal::AstProperties AstProperties; 358 typedef v8::internal::AstProperties AstProperties;
374 typedef Vector<VariableProxy*> ParameterIdentifierVector; 359 typedef Vector<VariableProxy*> ParameterIdentifierVector;
375 360
376 // Return types for traversing functions. 361 // Return types for traversing functions.
377 typedef const AstRawString* Identifier; 362 typedef const AstRawString* Identifier;
378 typedef v8::internal::Expression* Expression; 363 typedef v8::internal::Expression* Expression;
379 typedef Yield* YieldExpression; 364 typedef Yield* YieldExpression;
380 typedef v8::internal::FunctionLiteral* FunctionLiteral; 365 typedef v8::internal::FunctionLiteral* FunctionLiteral;
381 typedef v8::internal::Literal* Literal; 366 typedef v8::internal::Literal* Literal;
382 typedef ObjectLiteral::Property* ObjectLiteralProperty; 367 typedef ObjectLiteral::Property* ObjectLiteralProperty;
383 typedef ZoneList<v8::internal::Expression*>* ExpressionList; 368 typedef ZoneList<v8::internal::Expression*>* ExpressionList;
384 typedef ZoneList<ObjectLiteral::Property*>* PropertyList; 369 typedef ZoneList<ObjectLiteral::Property*>* PropertyList;
385 typedef ZoneList<v8::internal::Statement*>* StatementList; 370 typedef ZoneList<v8::internal::Statement*>* StatementList;
386 371
387 // For constructing objects returned by the traversing functions. 372 // For constructing objects returned by the traversing functions.
388 typedef AstNodeFactory<AstConstructionVisitor> Factory; 373 typedef AstNodeFactory<AstConstructionVisitor> Factory;
389 }; 374 };
390 375
376 class Checkpoint;
377
391 explicit ParserTraits(Parser* parser) : parser_(parser) {} 378 explicit ParserTraits(Parser* parser) : parser_(parser) {}
392 379
393 // Custom operations executed when FunctionStates are created and destructed. 380 // Custom operations executed when FunctionStates are created and destructed.
394 template<typename FunctionState> 381 template<typename FunctionState>
395 static void SetUpFunctionState(FunctionState* function_state, Zone* zone) { 382 static void SetUpFunctionState(FunctionState* function_state, Zone* zone) {
396 Isolate* isolate = zone->isolate(); 383 Isolate* isolate = zone->isolate();
397 function_state->saved_ast_node_id_ = isolate->ast_node_id(); 384 function_state->saved_ast_node_id_ = isolate->ast_node_id();
398 isolate->set_ast_node_id(BailoutId::FirstUsable().ToInt()); 385 isolate->set_ast_node_id(BailoutId::FirstUsable().ToInt());
399 } 386 }
400 387
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 private: 890 private:
904 static const int kLiteralTypeSlot = 0; 891 static const int kLiteralTypeSlot = 0;
905 static const int kElementsSlot = 1; 892 static const int kElementsSlot = 1;
906 893
907 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); 894 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue);
908 }; 895 };
909 896
910 } } // namespace v8::internal 897 } } // namespace v8::internal
911 898
912 #endif // V8_PARSER_H_ 899 #endif // V8_PARSER_H_
OLDNEW
« no previous file with comments | « no previous file | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698