| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/api.h" | 7 #include "src/api.h" |
| 8 #include "src/ast.h" | 8 #include "src/ast.h" |
| 9 #include "src/base/platform/platform.h" | 9 #include "src/base/platform/platform.h" |
| 10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
| (...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 info->SetGlobalScope(scope); | 794 info->SetGlobalScope(scope); |
| 795 if (!info->context().is_null() && !info->context()->IsNativeContext()) { | 795 if (!info->context().is_null() && !info->context()->IsNativeContext()) { |
| 796 scope = Scope::DeserializeScopeChain(*info->context(), scope, zone()); | 796 scope = Scope::DeserializeScopeChain(*info->context(), scope, zone()); |
| 797 // The Scope is backed up by ScopeInfo (which is in the V8 heap); this | 797 // The Scope is backed up by ScopeInfo (which is in the V8 heap); this |
| 798 // means the Parser cannot operate independent of the V8 heap. Tell the | 798 // means the Parser cannot operate independent of the V8 heap. Tell the |
| 799 // string table to internalize strings and values right after they're | 799 // string table to internalize strings and values right after they're |
| 800 // created. | 800 // created. |
| 801 ast_value_factory_->Internalize(isolate()); | 801 ast_value_factory_->Internalize(isolate()); |
| 802 } | 802 } |
| 803 original_scope_ = scope; | 803 original_scope_ = scope; |
| 804 if (info->is_eval()) { | 804 if (info->is_eval() && |
| 805 if (!scope->is_global_scope() || info->strict_mode() == STRICT) { | 805 (!scope->is_global_scope() || info->strict_mode() == STRICT)) { |
| 806 scope = NewScope(scope, EVAL_SCOPE); | 806 scope = NewScope(scope, EVAL_SCOPE); |
| 807 } | |
| 808 } else if (info->is_global()) { | 807 } else if (info->is_global()) { |
| 809 scope = NewScope(scope, GLOBAL_SCOPE); | 808 scope = NewScope(scope, SCRIPT_SCOPE); |
| 810 } | 809 } |
| 811 scope->set_start_position(0); | 810 scope->set_start_position(0); |
| 812 scope->set_end_position(source->length()); | 811 scope->set_end_position(source->length()); |
| 813 | 812 |
| 814 // Compute the parsing mode. | 813 // Compute the parsing mode. |
| 815 Mode mode = (FLAG_lazy && allow_lazy()) ? PARSE_LAZILY : PARSE_EAGERLY; | 814 Mode mode = (FLAG_lazy && allow_lazy()) ? PARSE_LAZILY : PARSE_EAGERLY; |
| 816 if (allow_natives_syntax() || | 815 if (allow_natives_syntax() || |
| 817 extension_ != NULL || | 816 extension_ != NULL || |
| 818 scope->is_eval_scope()) { | 817 scope->is_eval_scope()) { |
| 819 mode = PARSE_EAGERLY; | 818 mode = PARSE_EAGERLY; |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1394 Statement* Parser::ParseExportDeclaration(bool* ok) { | 1393 Statement* Parser::ParseExportDeclaration(bool* ok) { |
| 1395 // ExportDeclaration: | 1394 // ExportDeclaration: |
| 1396 // 'export' Identifier (',' Identifier)* ';' | 1395 // 'export' Identifier (',' Identifier)* ';' |
| 1397 // 'export' VariableDeclaration | 1396 // 'export' VariableDeclaration |
| 1398 // 'export' FunctionDeclaration | 1397 // 'export' FunctionDeclaration |
| 1399 // 'export' GeneratorDeclaration | 1398 // 'export' GeneratorDeclaration |
| 1400 // 'export' ModuleDeclaration | 1399 // 'export' ModuleDeclaration |
| 1401 // | 1400 // |
| 1402 // TODO(ES6): implement structuring ExportSpecifiers | 1401 // TODO(ES6): implement structuring ExportSpecifiers |
| 1403 | 1402 |
| 1404 ASSERT(strict_mode() == STRICT); | |
| 1405 | |
| 1406 Expect(Token::EXPORT, CHECK_OK); | 1403 Expect(Token::EXPORT, CHECK_OK); |
| 1407 | 1404 |
| 1408 Statement* result = NULL; | 1405 Statement* result = NULL; |
| 1409 ZoneList<const AstRawString*> names(1, zone()); | 1406 ZoneList<const AstRawString*> names(1, zone()); |
| 1410 switch (peek()) { | 1407 switch (peek()) { |
| 1411 case Token::IDENTIFIER: { | 1408 case Token::IDENTIFIER: { |
| 1412 int pos = position(); | 1409 int pos = position(); |
| 1413 const AstRawString* name = | 1410 const AstRawString* name = |
| 1414 ParseIdentifier(kDontAllowEvalOrArguments, CHECK_OK); | 1411 ParseIdentifier(kDontAllowEvalOrArguments, CHECK_OK); |
| 1415 // Handle 'module' as a context-sensitive keyword. | 1412 // Handle 'module' as a context-sensitive keyword. |
| (...skipping 3379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4795 info()->SetAstValueFactory(ast_value_factory_); | 4792 info()->SetAstValueFactory(ast_value_factory_); |
| 4796 } | 4793 } |
| 4797 ast_value_factory_ = NULL; | 4794 ast_value_factory_ = NULL; |
| 4798 | 4795 |
| 4799 InternalizeUseCounts(); | 4796 InternalizeUseCounts(); |
| 4800 | 4797 |
| 4801 return (result != NULL); | 4798 return (result != NULL); |
| 4802 } | 4799 } |
| 4803 | 4800 |
| 4804 } } // namespace v8::internal | 4801 } } // namespace v8::internal |
| OLD | NEW |