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