Index: src/parser.h |
diff --git a/src/parser.h b/src/parser.h |
index d8fb74b0723626bb2ca26fc109ac692a344b8957..7cb364b4d77e2679f09fcb6e2bcd8740cf68e8a7 100644 |
--- a/src/parser.h |
+++ b/src/parser.h |
@@ -389,7 +389,7 @@ class ParserTraits { |
typedef v8::internal::Zone Zone; |
// Return types for traversing functions. |
- typedef const AstString* Identifier; |
+ typedef Handle<String> Identifier; |
typedef v8::internal::Expression* Expression; |
typedef Yield* YieldExpression; |
typedef v8::internal::FunctionLiteral* FunctionLiteral; |
@@ -421,29 +421,29 @@ class ParserTraits { |
} |
// Helper functions for recursive descent. |
- bool IsEvalOrArguments(const AstString* identifier) const; |
+ bool IsEvalOrArguments(Handle<String> identifier) const; |
// Returns true if the expression is of type "this.foo". |
static bool IsThisProperty(Expression* expression); |
static bool IsIdentifier(Expression* expression); |
- static const AstString* AsIdentifier(Expression* expression) { |
+ static Handle<String> AsIdentifier(Expression* expression) { |
ASSERT(IsIdentifier(expression)); |
- return expression->AsVariableProxy()->raw_name(); |
+ return expression->AsVariableProxy()->name(); |
} |
static bool IsBoilerplateProperty(ObjectLiteral::Property* property) { |
return ObjectLiteral::IsBoilerplateProperty(property); |
} |
- static bool IsArrayIndex(const AstString* string, uint32_t* index) { |
- return string->AsArrayIndex(index); |
+ static bool IsArrayIndex(Handle<String> string, uint32_t* index) { |
+ return !string.is_null() && string->AsArrayIndex(index); |
} |
// Functions for encapsulating the differences between parsing and preparsing; |
// operations interleaved with the recursive descent. |
- static void PushLiteralName(FuncNameInferrer* fni, const AstString* id) { |
+ static void PushLiteralName(FuncNameInferrer* fni, Handle<String> id) { |
fni->PushLiteralName(id); |
} |
void PushPropertyName(FuncNameInferrer* fni, Expression* expression); |
@@ -501,17 +501,16 @@ class ParserTraits { |
// type. The first argument may be null (in the handle sense) in |
// which case no arguments are passed to the constructor. |
Expression* NewThrowSyntaxError( |
- const char* type, const AstString* arg, int pos); |
+ const char* type, Handle<Object> arg, int pos); |
// Generate AST node that throws a TypeError with the given |
// type. Both arguments must be non-null (in the handle sense). |
- Expression* NewThrowTypeError(const char* type, const AstString* arg, |
- int pos); |
+ Expression* NewThrowTypeError(const char* type, Handle<Object> arg, int pos); |
// Generic AST generator for throwing errors from compiled code. |
Expression* NewThrowError( |
- const AstString* constructor, const char* type, |
- const AstString* arg, int pos); |
+ Handle<String> constructor, const char* type, |
+ Vector<Handle<Object> > arguments, int pos); |
// Reporting errors. |
void ReportMessageAt(Scanner::Location source_location, |
@@ -519,19 +518,16 @@ class ParserTraits { |
const char* arg, |
bool is_reference_error = false); |
void ReportMessage(const char* message, |
- const char* arg = NULL, |
- bool is_reference_error = false); |
- void ReportMessage(const char* message, |
- const AstString* arg, |
+ MaybeHandle<String> arg, |
bool is_reference_error = false); |
void ReportMessageAt(Scanner::Location source_location, |
const char* message, |
- const AstString* arg, |
+ MaybeHandle<String> arg, |
bool is_reference_error = false); |
// "null" return type creators. |
- static const AstString* EmptyIdentifier() { |
- return NULL; |
+ static Handle<String> EmptyIdentifier() { |
+ return Handle<String>(); |
} |
static Expression* EmptyExpression() { |
return NULL; |
@@ -549,16 +545,16 @@ class ParserTraits { |
AstNodeFactory<AstConstructionVisitor>* factory); |
// Producing data during the recursive descent. |
- const AstString* GetSymbol(Scanner* scanner); |
- const AstString* GetNextSymbol(Scanner* scanner); |
- |
+ Handle<String> GetSymbol(Scanner* scanner = NULL); |
+ Handle<String> NextLiteralString(Scanner* scanner, |
+ PretenureFlag tenured); |
Expression* ThisExpression(Scope* scope, |
AstNodeFactory<AstConstructionVisitor>* factory); |
Literal* ExpressionFromLiteral( |
Token::Value token, int pos, Scanner* scanner, |
AstNodeFactory<AstConstructionVisitor>* factory); |
Expression* ExpressionFromIdentifier( |
- const AstString* name, int pos, Scope* scope, |
+ Handle<String> name, int pos, Scope* scope, |
AstNodeFactory<AstConstructionVisitor>* factory); |
Expression* ExpressionFromString( |
int pos, Scanner* scanner, |
@@ -576,7 +572,7 @@ class ParserTraits { |
// Temporary glue; these functions will move to ParserBase. |
Expression* ParseV8Intrinsic(bool* ok); |
FunctionLiteral* ParseFunctionLiteral( |
- const AstString* name, |
+ Handle<String> name, |
Scanner::Location function_name_location, |
bool name_is_strict_reserved, |
bool is_generator, |
@@ -648,7 +644,7 @@ class Parser : public ParserBase<ParserTraits> { |
Handle<String> source); |
// Report syntax error |
- void ReportInvalidCachedData(const AstString* name, bool* ok); |
+ void ReportInvalidCachedData(Handle<String> name, bool* ok); |
void SetCachedData(ScriptData** data, |
CachedDataMode cached_data_mode) { |
@@ -675,9 +671,8 @@ class Parser : public ParserBase<ParserTraits> { |
// for failure at the call sites. |
void* ParseSourceElements(ZoneList<Statement*>* processor, int end_token, |
bool is_eval, bool is_global, bool* ok); |
- Statement* ParseModuleElement(ZoneList<const AstString*>* labels, bool* ok); |
- Statement* ParseModuleDeclaration(ZoneList<const AstString*>* names, |
- bool* ok); |
+ Statement* ParseModuleElement(ZoneStringList* labels, bool* ok); |
+ Statement* ParseModuleDeclaration(ZoneStringList* names, bool* ok); |
Module* ParseModule(bool* ok); |
Module* ParseModuleLiteral(bool* ok); |
Module* ParseModulePath(bool* ok); |
@@ -686,42 +681,38 @@ class Parser : public ParserBase<ParserTraits> { |
Module* ParseModuleSpecifier(bool* ok); |
Block* ParseImportDeclaration(bool* ok); |
Statement* ParseExportDeclaration(bool* ok); |
- Statement* ParseBlockElement(ZoneList<const AstString*>* labels, bool* ok); |
- Statement* ParseStatement(ZoneList<const AstString*>* labels, bool* ok); |
- Statement* ParseFunctionDeclaration(ZoneList<const AstString*>* names, |
- bool* ok); |
+ Statement* ParseBlockElement(ZoneStringList* labels, bool* ok); |
+ Statement* ParseStatement(ZoneStringList* labels, bool* ok); |
+ Statement* ParseFunctionDeclaration(ZoneStringList* names, bool* ok); |
Statement* ParseNativeDeclaration(bool* ok); |
- Block* ParseBlock(ZoneList<const AstString*>* labels, bool* ok); |
+ Block* ParseBlock(ZoneStringList* labels, bool* ok); |
Block* ParseVariableStatement(VariableDeclarationContext var_context, |
- ZoneList<const AstString*>* names, |
+ ZoneStringList* names, |
bool* ok); |
Block* ParseVariableDeclarations(VariableDeclarationContext var_context, |
VariableDeclarationProperties* decl_props, |
- ZoneList<const AstString*>* names, |
- const AstString** out, |
+ ZoneStringList* names, |
+ Handle<String>* out, |
bool* ok); |
- Statement* ParseExpressionOrLabelledStatement( |
- ZoneList<const AstString*>* labels, bool* ok); |
- IfStatement* ParseIfStatement(ZoneList<const AstString*>* labels, bool* ok); |
+ Statement* ParseExpressionOrLabelledStatement(ZoneStringList* labels, |
+ bool* ok); |
+ IfStatement* ParseIfStatement(ZoneStringList* labels, bool* ok); |
Statement* ParseContinueStatement(bool* ok); |
- Statement* ParseBreakStatement(ZoneList<const AstString*>* labels, bool* ok); |
+ Statement* ParseBreakStatement(ZoneStringList* labels, bool* ok); |
Statement* ParseReturnStatement(bool* ok); |
- Statement* ParseWithStatement(ZoneList<const AstString*>* labels, bool* ok); |
+ Statement* ParseWithStatement(ZoneStringList* labels, bool* ok); |
CaseClause* ParseCaseClause(bool* default_seen_ptr, bool* ok); |
- SwitchStatement* ParseSwitchStatement(ZoneList<const AstString*>* labels, |
- bool* ok); |
- DoWhileStatement* ParseDoWhileStatement(ZoneList<const AstString*>* labels, |
- bool* ok); |
- WhileStatement* ParseWhileStatement(ZoneList<const AstString*>* labels, |
- bool* ok); |
- Statement* ParseForStatement(ZoneList<const AstString*>* labels, bool* ok); |
+ SwitchStatement* ParseSwitchStatement(ZoneStringList* labels, bool* ok); |
+ DoWhileStatement* ParseDoWhileStatement(ZoneStringList* labels, bool* ok); |
+ WhileStatement* ParseWhileStatement(ZoneStringList* labels, bool* ok); |
+ Statement* ParseForStatement(ZoneStringList* labels, bool* ok); |
Statement* ParseThrowStatement(bool* ok); |
Expression* MakeCatchContext(Handle<String> id, VariableProxy* value); |
TryStatement* ParseTryStatement(bool* ok); |
DebuggerStatement* ParseDebuggerStatement(bool* ok); |
// Support for hamony block scoped bindings. |
- Block* ParseScopedBlock(ZoneList<const AstString*>* labels, bool* ok); |
+ Block* ParseScopedBlock(ZoneStringList* labels, bool* ok); |
// Initialize the components of a for-in / for-of statement. |
void InitializeForEachStatement(ForEachStatement* stmt, |
@@ -729,12 +720,12 @@ class Parser : public ParserBase<ParserTraits> { |
Expression* subject, |
Statement* body); |
Statement* DesugarLetBindingsInForStatement( |
- Scope* inner_scope, ZoneList<const AstString*>* names, |
- ForStatement* loop, Statement* init, Expression* cond, Statement* next, |
- Statement* body, bool* ok); |
+ Scope* inner_scope, ZoneStringList* names, ForStatement* loop, |
+ Statement* init, Expression* cond, Statement* next, Statement* body, |
+ bool* ok); |
FunctionLiteral* ParseFunctionLiteral( |
- const AstString* name, |
+ Handle<String> name, |
Scanner::Location function_name_location, |
bool name_is_strict_reserved, |
bool is_generator, |
@@ -763,14 +754,14 @@ class Parser : public ParserBase<ParserTraits> { |
void CheckConflictingVarDeclarations(Scope* scope, bool* ok); |
// Parser support |
- VariableProxy* NewUnresolved(const AstString* name, |
+ VariableProxy* NewUnresolved(Handle<String> name, |
VariableMode mode, |
Interface* interface); |
void Declare(Declaration* declaration, bool resolve, bool* ok); |
- bool TargetStackContainsLabel(const AstString* label); |
- BreakableStatement* LookupBreakTarget(const AstString* label, bool* ok); |
- IterationStatement* LookupContinueTarget(const AstString* label, bool* ok); |
+ bool TargetStackContainsLabel(Handle<String> label); |
+ BreakableStatement* LookupBreakTarget(Handle<String> label, bool* ok); |
+ IterationStatement* LookupContinueTarget(Handle<String> label, bool* ok); |
void RegisterTargetUse(Label* target, Target* stop); |
@@ -780,7 +771,7 @@ class Parser : public ParserBase<ParserTraits> { |
// Skip over a lazy function, either using cached data if we have it, or |
// by parsing the function with PreParser. Consumes the ending }. |
- void SkipLazyFunctionBody(const AstString* function_name, |
+ void SkipLazyFunctionBody(Handle<String> function_name, |
int* materialized_literal_count, |
int* expected_property_count, |
bool* ok); |
@@ -789,7 +780,7 @@ class Parser : public ParserBase<ParserTraits> { |
SingletonLogger* logger); |
// Consumes the ending }. |
- ZoneList<Statement*>* ParseEagerFunctionBody(const AstString* function_name, |
+ ZoneList<Statement*>* ParseEagerFunctionBody(Handle<String> function_name, |
int pos, |
Variable* fvar, |
Token::Value fvar_init_op, |
@@ -807,7 +798,6 @@ class Parser : public ParserBase<ParserTraits> { |
Target* target_stack_; // for break, continue statements |
ScriptData** cached_data_; |
CachedDataMode cached_data_mode_; |
- AstValueFactory* ast_value_factory_; |
CompilationInfo* info_; |
@@ -815,7 +805,7 @@ class Parser : public ParserBase<ParserTraits> { |
bool has_pending_error_; |
Scanner::Location pending_error_location_; |
const char* pending_error_message_; |
- const AstString* pending_error_arg_; |
+ MaybeHandle<String> pending_error_arg_; |
const char* pending_error_char_arg_; |
bool pending_error_is_reference_error_; |
}; |