Index: src/parser.cc |
diff --git a/src/parser.cc b/src/parser.cc |
index cd3dd290aa2b4a8a4a7fb22b7f8bcb198fa81fa5..c1214162cb11fafacc5eac821d744de49587eb29 100644 |
--- a/src/parser.cc |
+++ b/src/parser.cc |
@@ -652,9 +652,7 @@ FunctionLiteral* Parser::DoParseProgram(Handle<String> source, |
FunctionLiteral* result = NULL; |
{ Scope* scope = NewScope(top_scope_, type); |
LexicalScope lexical_scope(this, scope, isolate()); |
- if (strict_mode == kStrictMode) { |
- top_scope_->EnableStrictMode(); |
- } |
+ top_scope_->SetStrictModeFlag(strict_mode); |
Yang
2011/10/20 14:18:59
Here again. This only works if you assume the prev
Steven
2011/10/21 13:59:00
Because we start with a GLOBAL or EVAL scope the p
|
ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16); |
bool ok = true; |
int beg_loc = scanner().location().beg_pos; |
@@ -741,15 +739,11 @@ FunctionLiteral* Parser::ParseLazy(CompilationInfo* info, |
{ |
// Parse the function literal. |
Scope* scope = NewScope(top_scope_, Scope::GLOBAL_SCOPE); |
+ scope->SetStrictModeFlag(shared_info->strict_mode_flag()); |
Yang
2011/10/20 14:18:59
Ditto.
Steven
2011/10/21 13:59:00
The move before the if was not correct. I added a
|
if (!info->closure().is_null()) { |
scope = Scope::DeserializeScopeChain(info, scope); |
} |
LexicalScope lexical_scope(this, scope, isolate()); |
- |
- if (shared_info->strict_mode()) { |
- top_scope_->EnableStrictMode(); |
- } |
- |
FunctionLiteral::Type type = shared_info->is_expression() |
? (shared_info->is_anonymous() |
? FunctionLiteral::ANONYMOUS_EXPRESSION |
@@ -1196,7 +1190,7 @@ void* Parser::ParseSourceElements(ZoneList<Statement*>* processor, |
directive->Equals(isolate()->heap()->use_strict()) && |
token_loc.end_pos - token_loc.beg_pos == |
isolate()->heap()->use_strict()->length() + 2) { |
- top_scope_->EnableStrictMode(); |
+ top_scope_->SetStrictModeFlag(kStrictMode); |
// "use strict" is the only directive for now. |
directive_prologue = false; |
} |
@@ -1596,9 +1590,6 @@ Block* Parser::ParseScopedBlock(ZoneStringList* labels, bool* ok) { |
// Construct block expecting 16 statements. |
Block* body = new(zone()) Block(isolate(), labels, 16, false); |
Scope* block_scope = NewScope(top_scope_, Scope::BLOCK_SCOPE); |
- if (top_scope_->is_strict_mode()) { |
- block_scope->EnableStrictMode(); |
- } |
// Parse the statements and collect escaping labels. |
Expect(Token::LBRACE, CHECK_OK); |
@@ -1844,9 +1835,7 @@ Block* Parser::ParseVariableDeclarations( |
} else { |
// Add strict mode. |
// We may want to pass singleton to avoid Literal allocations. |
- StrictModeFlag flag = initialization_scope->is_strict_mode() |
- ? kStrictMode |
- : kNonStrictMode; |
+ StrictModeFlag flag = initialization_scope->strict_mode_flag(); |
arguments->Add(NewNumberLiteral(flag)); |
// Be careful not to assign a value to the global variable if |
@@ -2256,9 +2245,6 @@ TryStatement* Parser::ParseTryStatement(bool* ok) { |
if (peek() == Token::LBRACE) { |
Target target(&this->target_stack_, &catch_collector); |
catch_scope = NewScope(top_scope_, Scope::CATCH_SCOPE); |
- if (top_scope_->is_strict_mode()) { |
- catch_scope->EnableStrictMode(); |
- } |
VariableMode mode = harmony_scoping_ ? LET : VAR; |
catch_variable = catch_scope->DeclareLocal(name, mode); |
@@ -2376,9 +2362,6 @@ Statement* Parser::ParseForStatement(ZoneStringList* labels, bool* ok) { |
// Create an in-between scope for let-bound iteration variables. |
Scope* saved_scope = top_scope_; |
Scope* for_scope = NewScope(top_scope_, Scope::BLOCK_SCOPE); |
- if (top_scope_->is_strict_mode()) { |
- for_scope->EnableStrictMode(); |
- } |
top_scope_ = for_scope; |
Expect(Token::FOR, CHECK_OK); |
@@ -3975,7 +3958,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> function_name, |
scanner().SeekForward(end_pos - 1); |
materialized_literal_count = entry.literal_count(); |
expected_property_count = entry.property_count(); |
- if (entry.strict_mode()) top_scope_->EnableStrictMode(); |
+ if (entry.strict_mode()) top_scope_->SetStrictModeFlag(kStrictMode); |
only_simple_this_property_assignments = false; |
this_property_assignments = isolate()->factory()->empty_fixed_array(); |
Expect(Token::RBRACE, CHECK_OK); |
@@ -5385,7 +5368,7 @@ bool ParserApi::Parse(CompilationInfo* info) { |
Handle<String> source = Handle<String>(String::cast(script->source())); |
result = parser.ParseProgram(source, |
info->is_global(), |
- info->StrictMode()); |
+ info->strict_mode_flag()); |
} |
} |
info->SetFunction(result); |