| 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/full-codegen/full-codegen.h" | 5 #include "src/full-codegen/full-codegen.h" |
| 6 | 6 |
| 7 #include "src/ast/ast-numbering.h" | 7 #include "src/ast/ast-numbering.h" |
| 8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
| 9 #include "src/ast/prettyprinter.h" | 9 #include "src/ast/prettyprinter.h" |
| 10 #include "src/ast/scopes.h" | 10 #include "src/ast/scopes.h" |
| (...skipping 1900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1911 // The condition on the declaration scopes is a conservative check for | 1911 // The condition on the declaration scopes is a conservative check for |
| 1912 // nested functions that access a binding and are called before the | 1912 // nested functions that access a binding and are called before the |
| 1913 // binding is initialized: | 1913 // binding is initialized: |
| 1914 // function() { f(); let x = 1; function f() { x = 2; } } | 1914 // function() { f(); let x = 1; function f() { x = 2; } } |
| 1915 // | 1915 // |
| 1916 // The check cannot be skipped on non-linear scopes, namely switch | 1916 // The check cannot be skipped on non-linear scopes, namely switch |
| 1917 // scopes, to ensure tests are done in cases like the following: | 1917 // scopes, to ensure tests are done in cases like the following: |
| 1918 // switch (1) { case 0: let x = 2; case 1: f(x); } | 1918 // switch (1) { case 0: let x = 2; case 1: f(x); } |
| 1919 // The scope of the variable needs to be checked, in case the use is | 1919 // The scope of the variable needs to be checked, in case the use is |
| 1920 // in a sub-block which may be linear. | 1920 // in a sub-block which may be linear. |
| 1921 if (var->scope()->DeclarationScope() != scope()->DeclarationScope()) { | 1921 if (var->scope()->GetDeclarationScope() != scope()->GetDeclarationScope()) { |
| 1922 return true; | 1922 return true; |
| 1923 } | 1923 } |
| 1924 | 1924 |
| 1925 if (var->is_this()) { | 1925 if (var->is_this()) { |
| 1926 DCHECK(literal() != nullptr && | 1926 DCHECK(literal() != nullptr && |
| 1927 (literal()->kind() & kSubclassConstructor) != 0); | 1927 (literal()->kind() & kSubclassConstructor) != 0); |
| 1928 // TODO(littledan): implement 'this' hole check elimination. | 1928 // TODO(littledan): implement 'this' hole check elimination. |
| 1929 return true; | 1929 return true; |
| 1930 } | 1930 } |
| 1931 | 1931 |
| 1932 // Check that we always have valid source position. | 1932 // Check that we always have valid source position. |
| 1933 DCHECK(var->initializer_position() != kNoSourcePosition); | 1933 DCHECK(var->initializer_position() != kNoSourcePosition); |
| 1934 DCHECK(proxy->position() != kNoSourcePosition); | 1934 DCHECK(proxy->position() != kNoSourcePosition); |
| 1935 | 1935 |
| 1936 return var->scope()->is_nonlinear() || | 1936 return var->scope()->is_nonlinear() || |
| 1937 var->initializer_position() >= proxy->position(); | 1937 var->initializer_position() >= proxy->position(); |
| 1938 } | 1938 } |
| 1939 | 1939 |
| 1940 | 1940 |
| 1941 #undef __ | 1941 #undef __ |
| 1942 | 1942 |
| 1943 | 1943 |
| 1944 } // namespace internal | 1944 } // namespace internal |
| 1945 } // namespace v8 | 1945 } // namespace v8 |
| OLD | NEW |