Chromium Code Reviews| Index: src/parser.cc |
| diff --git a/src/parser.cc b/src/parser.cc |
| index c0976988ea3c077800842816c03981ee5cf7b248..58fa1d10e7ae8a21c11883daa185a2833bea6603 100644 |
| --- a/src/parser.cc |
| +++ b/src/parser.cc |
| @@ -616,7 +616,8 @@ Parser::Parser(Handle<Script> script, |
| FunctionLiteral* Parser::ParseProgram(Handle<String> source, |
| - bool in_global_context) { |
| + bool in_global_context, |
| + bool strict_mode) { |
| CompilationZoneScope zone_scope(DONT_DELETE_ON_EXIT); |
| HistogramTimerScope timer(&Counters::parse); |
| @@ -632,17 +633,18 @@ FunctionLiteral* Parser::ParseProgram(Handle<String> source, |
| ExternalTwoByteStringUC16CharacterStream stream( |
| Handle<ExternalTwoByteString>::cast(source), 0, source->length()); |
| scanner_.Initialize(&stream); |
| - return DoParseProgram(source, in_global_context, &zone_scope); |
| + return DoParseProgram(source, in_global_context, strict_mode, &zone_scope); |
| } else { |
| GenericStringUC16CharacterStream stream(source, 0, source->length()); |
| scanner_.Initialize(&stream); |
| - return DoParseProgram(source, in_global_context, &zone_scope); |
| + return DoParseProgram(source, in_global_context, strict_mode, &zone_scope); |
| } |
| } |
| FunctionLiteral* Parser::DoParseProgram(Handle<String> source, |
| bool in_global_context, |
| + bool strict_mode, |
| ZoneScope* zone_scope) { |
| ASSERT(target_stack_ == NULL); |
| if (pre_data_ != NULL) pre_data_->Initialize(); |
| @@ -662,6 +664,7 @@ FunctionLiteral* Parser::DoParseProgram(Handle<String> source, |
| LexicalScope lexical_scope(&this->top_scope_, &this->with_nesting_level_, |
| scope); |
| TemporaryScope temp_scope(&this->temp_scope_); |
| + if (strict_mode) temp_scope.EnableStrictMode(); |
|
Martin Maly
2011/02/02 23:56:22
Restore strict mode (the eval call path)
|
| ZoneList<Statement*>* body = new ZoneList<Statement*>(16); |
| bool ok = true; |
| int beg_loc = scanner().location().beg_pos; |
| @@ -747,6 +750,10 @@ FunctionLiteral* Parser::ParseLazy(Handle<SharedFunctionInfo> info, |
| scope); |
| TemporaryScope temp_scope(&this->temp_scope_); |
| + if (info->strict_mode()) { |
| + temp_scope.EnableStrictMode(); |
| + } |
|
Martin Maly
2011/02/02 23:56:22
In lazy compilation, strict flag is stored on Shar
Lasse Reichstein
2011/02/03 12:36:01
Is it only for lazily compiled functions that the
Martin Maly
2011/02/04 01:02:34
All SharedFunctionInfo have the correct strict mod
|
| + |
| FunctionLiteralType type = |
| info->is_expression() ? EXPRESSION : DECLARATION; |
| bool ok = true; |
| @@ -5025,7 +5032,9 @@ bool ParserApi::Parse(CompilationInfo* info) { |
| ASSERT(Top::has_pending_exception()); |
| } else { |
| Handle<String> source = Handle<String>(String::cast(script->source())); |
| - result = parser.ParseProgram(source, info->is_global()); |
| + result = parser.ParseProgram(source, |
| + info->is_global(), |
| + info->is_strict()); |
| } |
| } |