// ----------------------------------------------------------------------------
// Implementation of Parser
+class ParserTraits::Checkpoint
+ : public ParserBase<ParserTraits>::CheckpointBase {
+ public:
+ explicit Checkpoint(ParserBase<ParserTraits>* parser)
+ : CheckpointBase(parser) {
+ isolate_ = parser->zone()->isolate();
+ saved_ast_node_id_ = isolate_->ast_node_id();
+ }
+
+ void Restore() {
+ CheckpointBase::Restore();
+ isolate_->set_ast_node_id(saved_ast_node_id_);
+ }
+
+ private:
+ Isolate* isolate_;
+ int saved_ast_node_id_;
+};
+
+
bool ParserTraits::IsEvalOrArguments(const AstRawString* identifier) const {
return identifier == parser_->ast_value_factory_->eval_string() ||
identifier == parser_->ast_value_factory_->arguments_string();
typedef Variable GeneratorVariable;
typedef v8::internal::Zone Zone;
- class Checkpoint BASE_EMBEDDED {
- public:
- template <typename Parser>
- explicit Checkpoint(Parser* parser) {
- isolate_ = parser->zone()->isolate();
- saved_ast_node_id_ = isolate_->ast_node_id();
- }
-
- void Restore() { isolate_->set_ast_node_id(saved_ast_node_id_); }
-
- private:
- Isolate* isolate_;
- int saved_ast_node_id_;
- };
-
typedef v8::internal::AstProperties AstProperties;
typedef Vector<VariableProxy*> ParameterIdentifierVector;
typedef AstNodeFactory<AstConstructionVisitor> Factory;
};
+ class Checkpoint;
+
explicit ParserTraits(Parser* parser) : parser_(parser) {}
// Custom operations executed when FunctionStates are created and destructed.
}
protected:
- friend class Traits::Type::Checkpoint;
+ friend class Traits::Checkpoint;
enum AllowEvalOrArgumentsAsIdentifier {
kAllowEvalOrArguments,
PARSE_EAGERLY
};
- class ParserCheckpoint;
+ class CheckpointBase;
// ---------------------------------------------------------------------------
// FunctionState and BlockState together implement the parser's scope stack.
typename Traits::Type::Factory factory_;
friend class ParserTraits;
- friend class ParserCheckpoint;
+ friend class CheckpointBase;
};
// Annoyingly, arrow functions first parse as comma expressions, then when we
// see the => we have to go back and reinterpret the arguments as being formal
// parameters. To do so we need to reset some of the parser state back to
// what it was before the arguments were first seen.
- class ParserCheckpoint : public Traits::Type::Checkpoint {
+ class CheckpointBase BASE_EMBEDDED {
public:
- template <typename Parser>
- explicit ParserCheckpoint(Parser* parser)
- : Traits::Type::Checkpoint(parser) {
+ explicit CheckpointBase(ParserBase* parser) {
function_state_ = parser->function_state_;
next_materialized_literal_index_ =
function_state_->next_materialized_literal_index_;
}
void Restore() {
- Traits::Type::Checkpoint::Restore();
function_state_->next_materialized_literal_index_ =
next_materialized_literal_index_;
function_state_->next_handler_index_ = next_handler_index_;
typedef PreParserScope Scope;
typedef PreParserScope ScopePtr;
- class Checkpoint BASE_EMBEDDED {
- public:
- template <typename Parser>
- explicit Checkpoint(Parser* parser) {}
- void Restore() {}
- };
-
// PreParser doesn't need to store generator variables.
typedef void GeneratorVariable;
// No interaction with Zones.
typedef PreParserFactory Factory;
};
+ class Checkpoint;
+
explicit PreParserTraits(PreParser* pre_parser) : pre_parser_(pre_parser) {}
// Custom operations executed when FunctionStates are created and
}
if (fni_ != NULL) fni_->Enter();
- ParserCheckpoint checkpoint(this);
+ typename Traits::Checkpoint checkpoint(this);
ExpressionT expression =
this->ParseConditionalExpression(accept_IN, CHECK_OK);