Scope* Parser::NewScope(Scope* parent, ScopeType scope_type) {
- DCHECK(ast_value_factory_);
+ DCHECK(ast_value_factory());
Scope* result =
- new (zone()) Scope(parent, scope_type, ast_value_factory_, zone());
+ new (zone()) Scope(parent, scope_type, ast_value_factory(), zone());
result->Initialize();
return result;
}
bool ParserTraits::IsEvalOrArguments(const AstRawString* identifier) const {
- return identifier == parser_->ast_value_factory_->eval_string() ||
- identifier == parser_->ast_value_factory_->arguments_string();
+ return identifier == parser_->ast_value_factory()->eval_string() ||
+ identifier == parser_->ast_value_factory()->arguments_string();
}
fni->PushLiteralName(expression->AsLiteral()->AsRawPropertyName());
} else {
fni->PushLiteralName(
- parser_->ast_value_factory_->anonymous_function_string());
+ parser_->ast_value_factory()->anonymous_function_string());
}
}
Scope* scope) {
VariableProxy* callee = expression->AsVariableProxy();
if (callee != NULL &&
- callee->raw_name() == parser_->ast_value_factory_->eval_string()) {
+ callee->raw_name() == parser_->ast_value_factory()->eval_string()) {
scope->DeclarationScope()->RecordEvalCall();
}
}
Expression* ParserTraits::NewThrowReferenceError(const char* message, int pos) {
return NewThrowError(
- parser_->ast_value_factory_->make_reference_error_string(), message, NULL,
- pos);
+ parser_->ast_value_factory()->make_reference_error_string(), message,
+ NULL, pos);
}
Expression* ParserTraits::NewThrowSyntaxError(
const char* message, const AstRawString* arg, int pos) {
- return NewThrowError(parser_->ast_value_factory_->make_syntax_error_string(),
+ return NewThrowError(parser_->ast_value_factory()->make_syntax_error_string(),
message, arg, pos);
}
Expression* ParserTraits::NewThrowTypeError(
const char* message, const AstRawString* arg, int pos) {
- return NewThrowError(parser_->ast_value_factory_->make_type_error_string(),
+ return NewThrowError(parser_->ast_value_factory()->make_type_error_string(),
message, arg, pos);
}
Zone* zone = parser_->zone();
int argc = arg != NULL ? 1 : 0;
const AstRawString* type =
- parser_->ast_value_factory_->GetOneByteString(message);
+ parser_->ast_value_factory()->GetOneByteString(message);
ZoneList<const AstRawString*>* array =
new (zone) ZoneList<const AstRawString*>(argc, zone);
if (arg != NULL) {
const AstRawString* ParserTraits::GetSymbol(Scanner* scanner) {
const AstRawString* result =
- parser_->scanner()->CurrentSymbol(parser_->ast_value_factory_);
+ parser_->scanner()->CurrentSymbol(parser_->ast_value_factory());
DCHECK(result != NULL);
return result;
}
const AstRawString* ParserTraits::GetNextSymbol(Scanner* scanner) {
- return parser_->scanner()->NextSymbol(parser_->ast_value_factory_);
+ return parser_->scanner()->NextSymbol(parser_->ast_value_factory());
}
: ParserBase<ParserTraits>(&scanner_, parse_info->stack_limit,
info->extension(), NULL, info->zone(),
info->ast_node_id_gen(), this),
- isolate_(info->isolate()),
- script_(info->script()),
scanner_(parse_info->unicode_cache),
reusable_preparser_(NULL),
original_scope_(NULL),
target_stack_(NULL),
cached_parse_data_(NULL),
- ast_value_factory_(info->ast_value_factory()),
info_(info),
has_pending_error_(false),
pending_error_message_(NULL),
pending_error_char_arg_(NULL),
total_preparse_skipped_(0),
pre_parse_timer_(NULL) {
- DCHECK(!script_.is_null());
+ DCHECK(!script().is_null());
set_allow_harmony_scoping(!info->is_native() && FLAG_harmony_scoping);
set_allow_modules(!info->is_native() && FLAG_harmony_modules);
set_allow_natives_syntax(FLAG_allow_natives_syntax || info->is_native());
++feature) {
use_counts_[feature] = 0;
}
- if (ast_value_factory_ == NULL) {
- ast_value_factory_ = new AstValueFactory(zone(), parse_info->hash_seed);
+ if (info->ast_value_factory() == NULL) {
+ // info takes ownership of AstValueFactory.
+ info->SetAstValueFactory(
+ new AstValueFactory(zone(), parse_info->hash_seed));
}
}
// It's OK to use the counters here, since this function is only called in
// the main thread.
HistogramTimerScope timer_scope(isolate()->counters()->parse(), true);
- Handle<String> source(String::cast(script_->source()));
+ Handle<String> source(String::cast(script()->source()));
isolate()->counters()->total_parse_size()->Increment(source->length());
base::ElapsedTimer timer;
if (FLAG_trace_parse) {
timer.Start();
}
- fni_ = new(zone()) FuncNameInferrer(ast_value_factory_, zone());
+ fni_ = new (zone()) FuncNameInferrer(ast_value_factory(), zone());
// Initialize parser state.
CompleteParserRecorder recorder;
// means the Parser cannot operate independent of the V8 heap. Tell the
// string table to internalize strings and values right after they're
// created.
- ast_value_factory_->Internalize(isolate());
+ ast_value_factory()->Internalize(isolate());
}
original_scope_ = scope;
if (info->is_eval()) {
// Enters 'scope'.
FunctionState function_state(&function_state_, &scope_, scope, zone(),
- ast_value_factory_, info->ast_node_id_gen());
+ ast_value_factory(), info->ast_node_id_gen());
scope_->SetStrictMode(info->strict_mode());
ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone());
if (ok) {
result = factory()->NewFunctionLiteral(
- ast_value_factory_->empty_string(), ast_value_factory_, scope_, body,
- function_state.materialized_literal_count(),
+ ast_value_factory()->empty_string(), ast_value_factory(), scope_,
+ body, function_state.materialized_literal_count(),
function_state.expected_property_count(),
function_state.handler_count(), 0,
FunctionLiteral::kNoDuplicateParameters,
// It's OK to use the counters here, since this function is only called in
// the main thread.
HistogramTimerScope timer_scope(isolate()->counters()->parse_lazy());
- Handle<String> source(String::cast(script_->source()));
+ Handle<String> source(String::cast(script()->source()));
isolate()->counters()->total_parse_size()->Increment(source->length());
base::ElapsedTimer timer;
if (FLAG_trace_parse) {
DCHECK(target_stack_ == NULL);
Handle<String> name(String::cast(shared_info->name()));
- DCHECK(ast_value_factory_);
- fni_ = new(zone()) FuncNameInferrer(ast_value_factory_, zone());
- const AstRawString* raw_name = ast_value_factory_->GetString(name);
+ DCHECK(ast_value_factory());
+ fni_ = new (zone()) FuncNameInferrer(ast_value_factory(), zone());
+ const AstRawString* raw_name = ast_value_factory()->GetString(name);
fni_->PushEnclosingName(raw_name);
ParsingModeScope parsing_mode(this, PARSE_EAGERLY);
}
original_scope_ = scope;
FunctionState function_state(&function_state_, &scope_, scope, zone(),
- ast_value_factory_, info()->ast_node_id_gen());
+ ast_value_factory(),
+ info()->ast_node_id_gen());
DCHECK(scope->strict_mode() == SLOPPY || info()->strict_mode() == STRICT);
DCHECK(info()->strict_mode() == shared_info->strict_mode());
scope->SetStrictMode(shared_info->strict_mode());
// one can be present.
if (strict_mode() == SLOPPY &&
literal->raw_value()->AsString() ==
- ast_value_factory_->use_strict_string() &&
+ ast_value_factory()->use_strict_string() &&
token_loc.end_pos - token_loc.beg_pos ==
- ast_value_factory_->use_strict_string()->length() + 2) {
+ ast_value_factory()->use_strict_string()->length() + 2) {
// TODO(mstarzinger): Global strict eval calls, need their own scope
// as specified in ES5 10.4.2(3). The correct fix would be to always
// add this scope in DoParseProgram(), but that requires adaptations
// "use strict" is the only directive for now.
directive_prologue = false;
} else if (literal->raw_value()->AsString() ==
- ast_value_factory_->use_asm_string() &&
+ ast_value_factory()->use_asm_string() &&
token_loc.end_pos - token_loc.beg_pos ==
- ast_value_factory_->use_asm_string()->length() + 2) {
+ ast_value_factory()->use_asm_string()->length() + 2) {
// Store the usage count; The actual use counter on the isolate is
// incremented after parsing is done.
++use_counts_[v8::Isolate::kUseAsm];
ExpressionStatement* estmt = stmt->AsExpressionStatement();
if (estmt != NULL && estmt->expression()->AsVariableProxy() != NULL &&
estmt->expression()->AsVariableProxy()->raw_name() ==
- ast_value_factory_->module_string() &&
+ ast_value_factory()->module_string() &&
!scanner()->literal_contains_escapes()) {
return ParseModuleDeclaration(NULL, ok);
}
const AstRawString* name =
ParseIdentifier(kDontAllowEvalOrArguments, CHECK_OK);
// Handle 'module' as a context-sensitive keyword.
- if (name != ast_value_factory_->module_string()) {
+ if (name != ast_value_factory()->module_string()) {
names.Add(name, zone());
while (peek() == Token::COMMA) {
Consume(Token::COMMA);
// Note that the function does different things depending on
// the number of arguments (1 or 2).
initialize = factory()->NewCallRuntime(
- ast_value_factory_->initialize_const_global_string(),
- Runtime::FunctionForId(Runtime::kInitializeConstGlobal),
- arguments, pos);
+ ast_value_factory()->initialize_const_global_string(),
+ Runtime::FunctionForId(Runtime::kInitializeConstGlobal), arguments,
+ pos);
} else {
// Add strict mode.
// We may want to pass singleton to avoid Literal allocations.
// Construct the call to Runtime_InitializeVarGlobal
// and add it to the initialization statement block.
initialize = factory()->NewCallRuntime(
- ast_value_factory_->initialize_var_global_string(),
+ ast_value_factory()->initialize_var_global_string(),
Runtime::FunctionForId(Runtime::kInitializeVarGlobal), arguments,
pos);
} else {
// If we have an extension, we allow a native function declaration.
// A native function declaration starts with "native function" with
// no line-terminator between the two words.
- if (extension_ != NULL &&
- peek() == Token::FUNCTION &&
- !scanner()->HasAnyLineTerminatorBeforeNext() &&
- expr != NULL &&
+ if (extension_ != NULL && peek() == Token::FUNCTION &&
+ !scanner()->HasAnyLineTerminatorBeforeNext() && expr != NULL &&
expr->AsVariableProxy() != NULL &&
expr->AsVariableProxy()->raw_name() ==
- ast_value_factory_->native_string() &&
+ ast_value_factory()->native_string() &&
!scanner()->literal_contains_escapes()) {
return ParseNativeDeclaration(ok);
}
// Parsed expression statement, or the context-sensitive 'module' keyword.
// Only expect semicolon in the former case.
- if (!FLAG_harmony_modules ||
- peek() != Token::IDENTIFIER ||
+ if (!FLAG_harmony_modules || peek() != Token::IDENTIFIER ||
scanner()->HasAnyLineTerminatorBeforeNext() ||
expr->AsVariableProxy() == NULL ||
expr->AsVariableProxy()->raw_name() !=
- ast_value_factory_->module_string() ||
+ ast_value_factory()->module_string() ||
scanner()->literal_contains_escapes()) {
ExpectSemicolon(CHECK_OK);
}
if (for_of != NULL) {
Variable* iterator = scope_->DeclarationScope()->NewTemporary(
- ast_value_factory_->dot_iterator_string());
+ ast_value_factory()->dot_iterator_string());
Variable* result = scope_->DeclarationScope()->NewTemporary(
- ast_value_factory_->dot_result_string());
+ ast_value_factory()->dot_result_string());
Expression* assign_iterator;
Expression* next_result;
{
Expression* iterator_proxy = factory()->NewVariableProxy(iterator);
Expression* next_literal = factory()->NewStringLiteral(
- ast_value_factory_->next_string(), RelocInfo::kNoPosition);
+ ast_value_factory()->next_string(), RelocInfo::kNoPosition);
Expression* next_property = factory()->NewProperty(
iterator_proxy, next_literal, RelocInfo::kNoPosition);
ZoneList<Expression*>* next_arguments =
// result.done
{
Expression* done_literal = factory()->NewStringLiteral(
- ast_value_factory_->done_string(), RelocInfo::kNoPosition);
+ ast_value_factory()->done_string(), RelocInfo::kNoPosition);
Expression* result_proxy = factory()->NewVariableProxy(result);
result_done = factory()->NewProperty(
result_proxy, done_literal, RelocInfo::kNoPosition);
// each = result.value
{
Expression* value_literal = factory()->NewStringLiteral(
- ast_value_factory_->value_string(), RelocInfo::kNoPosition);
+ ast_value_factory()->value_string(), RelocInfo::kNoPosition);
Expression* result_proxy = factory()->NewVariableProxy(result);
Expression* result_value = factory()->NewProperty(
result_proxy, value_literal, RelocInfo::kNoPosition);
RelocInfo::kNoPosition);
outer_block->AddStatement(init, zone());
- const AstRawString* temp_name = ast_value_factory_->dot_for_string();
+ const AstRawString* temp_name = ast_value_factory()->dot_for_string();
// For each let variable x:
// make statement: temp_x = x.
// TODO(keuchel): Move the temporary variable to the block scope, after
// implementing stack allocated block scoped variables.
Variable* temp = scope_->DeclarationScope()->NewTemporary(
- ast_value_factory_->dot_for_string());
+ ast_value_factory()->dot_for_string());
VariableProxy* temp_proxy = factory()->NewVariableProxy(temp);
ForEachStatement* loop =
factory()->NewForEachStatement(mode, labels, pos);
// We want a non-null handle as the function name.
if (should_infer_name) {
- function_name = ast_value_factory_->empty_string();
+ function_name = ast_value_factory()->empty_string();
}
int num_parameters = 0;
// Parse function body.
{
FunctionState function_state(&function_state_, &scope_, scope, zone(),
- ast_value_factory_, info()->ast_node_id_gen());
+ ast_value_factory(),
+ info()->ast_node_id_gen());
scope_->SetScopeName(function_name);
if (is_generator) {
// in a temporary variable, a definition that is used by "yield"
// expressions. This also marks the FunctionState as a generator.
Variable* temp = scope_->DeclarationScope()->NewTemporary(
- ast_value_factory_->dot_generator_object_string());
+ ast_value_factory()->dot_generator_object_string());
function_state.set_generator_object_variable(temp);
}
}
FunctionLiteral* function_literal = factory()->NewFunctionLiteral(
- function_name, ast_value_factory_, scope, body,
+ function_name, ast_value_factory(), scope, body,
materialized_literal_count, expected_property_count, handler_count,
num_parameters, duplicate_parameters, function_type,
FunctionLiteral::kIsFunction, parenthesized, kind, pos);
ZoneList<Expression*>* arguments =
new(zone()) ZoneList<Expression*>(0, zone());
CallRuntime* allocation = factory()->NewCallRuntime(
- ast_value_factory_->empty_string(),
- Runtime::FunctionForId(Runtime::kCreateJSGeneratorObject),
- arguments, pos);
+ ast_value_factory()->empty_string(),
+ Runtime::FunctionForId(Runtime::kCreateJSGeneratorObject), arguments,
+ pos);
VariableProxy* init_proxy = factory()->NewVariableProxy(
function_state_->generator_object_variable());
Assignment* assignment = factory()->NewAssignment(
void Parser::ThrowPendingError() {
- DCHECK(ast_value_factory_->IsInternalized());
+ DCHECK(ast_value_factory()->IsInternalized());
if (has_pending_error_) {
- MessageLocation location(script_,
- pending_error_location_.beg_pos,
+ MessageLocation location(script(), pending_error_location_.beg_pos,
pending_error_location_.end_pos);
Factory* factory = isolate()->factory();
bool has_arg =
.ToHandleChecked();
elements->set(0, *arg_string);
}
- isolate()->debug()->OnCompileError(script_);
+ isolate()->debug()->OnCompileError(script());
Handle<JSArray> array = factory->NewJSArrayWithElements(elements);
Handle<Object> error;
void Parser::Internalize() {
// Internalize strings.
- ast_value_factory_->Internalize(isolate());
+ ast_value_factory()->Internalize(isolate());
// Error processing.
if (info()->function() == NULL) {
// If intrinsics are allowed, the Parser cannot operate independent of the
// V8 heap because of Runtime. Tell the string table to internalize strings
// and values right after they're created.
- ast_value_factory_->Internalize(isolate());
+ ast_value_factory()->Internalize(isolate());
}
if (info()->is_lazy()) {
info()->SetFunction(result);
Internalize();
- DCHECK(ast_value_factory_->IsInternalized());
- // info takes ownership of ast_value_factory_.
- if (info()->ast_value_factory() == NULL) {
- info()->SetAstValueFactory(ast_value_factory_);
- }
- ast_value_factory_ = NULL;
+ DCHECK(ast_value_factory()->IsInternalized());
return (result != NULL);
}