| 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 #ifndef V8_PARSING_PARSER_BASE_H | 5 #ifndef V8_PARSING_PARSER_BASE_H |
| 6 #define V8_PARSING_PARSER_BASE_H | 6 #define V8_PARSING_PARSER_BASE_H |
| 7 | 7 |
| 8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
| 9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
| 10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
| (...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 DCHECK_NOT_NULL(parent); | 722 DCHECK_NOT_NULL(parent); |
| 723 return new (zone()) Scope(zone(), parent, scope_type); | 723 return new (zone()) Scope(zone(), parent, scope_type); |
| 724 } | 724 } |
| 725 | 725 |
| 726 DeclarationScope* NewFunctionScope(FunctionKind kind) const { | 726 DeclarationScope* NewFunctionScope(FunctionKind kind) const { |
| 727 DCHECK(ast_value_factory()); | 727 DCHECK(ast_value_factory()); |
| 728 DeclarationScope* result = | 728 DeclarationScope* result = |
| 729 new (zone()) DeclarationScope(zone(), scope(), FUNCTION_SCOPE, kind); | 729 new (zone()) DeclarationScope(zone(), scope(), FUNCTION_SCOPE, kind); |
| 730 // TODO(verwaest): Move into the DeclarationScope constructor. | 730 // TODO(verwaest): Move into the DeclarationScope constructor. |
| 731 if (!IsArrowFunction(kind)) { | 731 if (!IsArrowFunction(kind)) { |
| 732 result->DeclareThis(ast_value_factory()); | |
| 733 result->DeclareDefaultFunctionVariables(ast_value_factory()); | 732 result->DeclareDefaultFunctionVariables(ast_value_factory()); |
| 734 } | 733 } |
| 735 return result; | 734 return result; |
| 736 } | 735 } |
| 737 | 736 |
| 738 V8_INLINE DeclarationScope* GetDeclarationScope() const { | 737 V8_INLINE DeclarationScope* GetDeclarationScope() const { |
| 739 return scope()->GetDeclarationScope(); | 738 return scope()->GetDeclarationScope(); |
| 740 } | 739 } |
| 741 V8_INLINE DeclarationScope* GetClosureScope() const { | 740 V8_INLINE DeclarationScope* GetClosureScope() const { |
| 742 return scope()->GetClosureScope(); | 741 return scope()->GetClosureScope(); |
| (...skipping 3182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3925 formal_parameters.scope | 3924 formal_parameters.scope |
| 3926 ->AllowsLazyParsingWithoutUnresolvedVariables()); | 3925 ->AllowsLazyParsingWithoutUnresolvedVariables()); |
| 3927 // TODO(marja): consider lazy-parsing inner arrow functions too. is_this | 3926 // TODO(marja): consider lazy-parsing inner arrow functions too. is_this |
| 3928 // handling in Scope::ResolveVariable needs to change. | 3927 // handling in Scope::ResolveVariable needs to change. |
| 3929 if (is_lazily_parsed) { | 3928 if (is_lazily_parsed) { |
| 3930 Scanner::BookmarkScope bookmark(scanner()); | 3929 Scanner::BookmarkScope bookmark(scanner()); |
| 3931 bookmark.Set(); | 3930 bookmark.Set(); |
| 3932 LazyParsingResult result = impl()->SkipLazyFunctionBody( | 3931 LazyParsingResult result = impl()->SkipLazyFunctionBody( |
| 3933 &materialized_literal_count, &expected_property_count, false, true, | 3932 &materialized_literal_count, &expected_property_count, false, true, |
| 3934 CHECK_OK); | 3933 CHECK_OK); |
| 3935 formal_parameters.scope->ResetAfterPreparsing(result == | 3934 formal_parameters.scope->ResetAfterPreparsing( |
| 3936 kLazyParsingAborted); | 3935 ast_value_factory_, result == kLazyParsingAborted); |
| 3937 | 3936 |
| 3938 if (formal_parameters.materialized_literals_count > 0) { | 3937 if (formal_parameters.materialized_literals_count > 0) { |
| 3939 materialized_literal_count += | 3938 materialized_literal_count += |
| 3940 formal_parameters.materialized_literals_count; | 3939 formal_parameters.materialized_literals_count; |
| 3941 } | 3940 } |
| 3942 | 3941 |
| 3943 if (result == kLazyParsingAborted) { | 3942 if (result == kLazyParsingAborted) { |
| 3944 bookmark.Apply(); | 3943 bookmark.Apply(); |
| 3945 // Trigger eager (re-)parsing, just below this block. | 3944 // Trigger eager (re-)parsing, just below this block. |
| 3946 is_lazily_parsed = false; | 3945 is_lazily_parsed = false; |
| (...skipping 1490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5437 has_seen_constructor_ = true; | 5436 has_seen_constructor_ = true; |
| 5438 return; | 5437 return; |
| 5439 } | 5438 } |
| 5440 } | 5439 } |
| 5441 | 5440 |
| 5442 | 5441 |
| 5443 } // namespace internal | 5442 } // namespace internal |
| 5444 } // namespace v8 | 5443 } // namespace v8 |
| 5445 | 5444 |
| 5446 #endif // V8_PARSING_PARSER_BASE_H | 5445 #endif // V8_PARSING_PARSER_BASE_H |
| OLD | NEW |