Index: src/parser.h |
diff --git a/src/parser.h b/src/parser.h |
index e3bd0b182984a75137815c8ddec7cf81c60169c6..b351b1536a4f2d3439000837b9d6f0d1479347a8 100644 |
--- a/src/parser.h |
+++ b/src/parser.h |
@@ -385,9 +385,13 @@ class ParserTraits { |
// Used by FunctionState and BlockState. |
typedef v8::internal::Scope Scope; |
+ typedef v8::internal::Scope* ScopePtr; |
typedef Variable GeneratorVariable; |
typedef v8::internal::Zone Zone; |
+ typedef v8::internal::AstProperties AstProperties; |
+ typedef Vector<VariableProxy*> ParameterIdentifierVector; |
+ |
// Return types for traversing functions. |
typedef const AstString* Identifier; |
typedef v8::internal::Expression* Expression; |
@@ -422,6 +426,7 @@ class ParserTraits { |
// Helper functions for recursive descent. |
bool IsEvalOrArguments(const AstString* identifier) const; |
+ V8_INLINE bool IsFutureStrictReserved(const AstString* identifier) const; |
// Returns true if the expression is of type "this.foo". |
static bool IsThisProperty(Expression* expression); |
@@ -447,6 +452,10 @@ class ParserTraits { |
fni->PushLiteralName(id); |
} |
void PushPropertyName(FuncNameInferrer* fni, Expression* expression); |
+ static void InferFunctionName(FuncNameInferrer* fni, |
+ FunctionLiteral* func_to_infer) { |
+ fni->AddFunction(func_to_infer); |
+ } |
static void CheckFunctionLiteralInsideTopLevelObjectLiteral( |
Scope* scope, Expression* value, bool* has_function) { |
@@ -516,7 +525,7 @@ class ParserTraits { |
// Reporting errors. |
void ReportMessageAt(Scanner::Location source_location, |
const char* message, |
- const char* arg, |
+ const char* arg = NULL, |
bool is_reference_error = false); |
void ReportMessage(const char* message, |
const char* arg = NULL, |
@@ -539,11 +548,15 @@ class ParserTraits { |
static Literal* EmptyLiteral() { |
return NULL; |
} |
+ |
// Used in error return values. |
static ZoneList<Expression*>* NullExpressionList() { |
return NULL; |
} |
+ // Non-"null" empty string. |
+ V8_INLINE const AstString* EmptyIdentifierString(); |
+ |
// Odd-ball literal creators. |
Literal* GetLiteralTheHole(int position, |
AstNodeFactory<AstConstructionVisitor>* factory); |
@@ -553,7 +566,8 @@ class ParserTraits { |
const AstString* GetNextSymbol(Scanner* scanner); |
Expression* ThisExpression(Scope* scope, |
- AstNodeFactory<AstConstructionVisitor>* factory); |
+ AstNodeFactory<AstConstructionVisitor>* factory, |
+ int pos = RelocInfo::kNoPosition); |
Literal* ExpressionFromLiteral( |
Token::Value token, int pos, Scanner* scanner, |
AstNodeFactory<AstConstructionVisitor>* factory); |
@@ -572,6 +586,14 @@ class ParserTraits { |
ZoneList<v8::internal::Statement*>* NewStatementList(int size, Zone* zone) { |
return new(zone) ZoneList<v8::internal::Statement*>(size, zone); |
} |
+ V8_INLINE Scope* NewScope(Scope* parent_scope, ScopeType scope_type); |
+ |
+ // Utility functions |
+ Vector<VariableProxy*> ParameterListFromExpression( |
+ Expression* expression, bool* ok); |
+ void InferFunctionName(FunctionLiteral* func_to_infer); |
+ |
+ V8_INLINE AstValueFactory* ast_value_factory(); |
// Temporary glue; these functions will move to ParserBase. |
Expression* ParseV8Intrinsic(bool* ok); |
@@ -583,6 +605,21 @@ class ParserTraits { |
int function_token_position, |
FunctionLiteral::FunctionType type, |
bool* ok); |
+ V8_INLINE void SkipLazyFunctionBody( |
+ const AstString* name, |
+ int* materialized_literal_count, |
+ int* expected_property_count, |
+ bool* ok); |
+ V8_INLINE ZoneList<Statement*>* ParseEagerFunctionBody( |
+ const AstString* name, |
+ int pos, |
+ Variable* fvar, |
+ Token::Value fvar_init_op, |
+ bool is_generator, |
+ bool* ok); |
+ V8_INLINE void CheckConflictingVarDeclarations( |
+ v8::internal::Scope* scope, |
+ bool* ok); |
private: |
Parser* parser_; |
@@ -772,6 +809,9 @@ class Parser : public ParserBase<ParserTraits> { |
void RegisterTargetUse(Label* target, Target* stop); |
+ Vector<VariableProxy*> ParameterListFromExpression(Expression* expression, |
+ bool* ok); |
+ |
// Factory methods. |
Scope* NewScope(Scope* parent, ScopeType type); |
@@ -819,6 +859,53 @@ class Parser : public ParserBase<ParserTraits> { |
}; |
+AstValueFactory* ParserTraits::ast_value_factory() { |
+ return parser_->ast_value_factory_; |
+} |
+ |
+ |
+bool ParserTraits::IsFutureStrictReserved(const AstString* identifier) const { |
+ return identifier->IsOneByteEqualTo("yield") || |
+ parser_->scanner()->IdentifierIsFutureStrictReserved(identifier); |
+} |
+ |
+ |
+Scope* ParserTraits::NewScope(Scope* parent_scope, ScopeType scope_type) { |
+ return parser_->NewScope(parent_scope, scope_type); |
+} |
+ |
+ |
+const AstString* ParserTraits::EmptyIdentifierString() { |
+ return parser_->ast_value_factory()->empty_string(); |
+} |
+ |
+ |
+void ParserTraits::SkipLazyFunctionBody( |
+ const AstString* function_name, |
+ int* materialized_literal_count, |
+ int* expected_property_count, |
+ bool* ok) { |
+ return parser_->SkipLazyFunctionBody(function_name, |
+ materialized_literal_count, expected_property_count, ok); |
+} |
+ |
+ |
+ZoneList<Statement*>* ParserTraits::ParseEagerFunctionBody( |
+ const AstString* name, |
+ int pos, |
+ Variable* fvar, |
+ Token::Value fvar_init_op, |
+ bool is_generator, |
+ bool* ok) { |
+ return parser_->ParseEagerFunctionBody(name, pos, |
+ fvar, fvar_init_op, is_generator, ok); |
+} |
+ |
+void ParserTraits::CheckConflictingVarDeclarations( |
+ v8::internal::Scope* scope, bool* ok) { |
+ parser_->CheckConflictingVarDeclarations(scope, ok); |
+} |
+ |
// Support for handling complex values (array and object literals) that |
// can be fully handled at compile time. |
class CompileTimeValue: public AllStatic { |