Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: src/parsing/parser.cc

Issue 1851673007: [modules] Treat top-level functions as lexical (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | test/cctest/test-parsing.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/parsing/parser.h" 5 #include "src/parsing/parser.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/ast/ast.h" 8 #include "src/ast/ast.h"
9 #include "src/ast/ast-expression-rewriter.h" 9 #include "src/ast/ast-expression-rewriter.h"
10 #include "src/ast/ast-expression-visitor.h" 10 #include "src/ast/ast-expression-visitor.h"
(...skipping 1892 matching lines...) Expand 10 before | Expand all | Expand 10 after
1903 var = declaration_scope->LookupLocal(name); 1903 var = declaration_scope->LookupLocal(name);
1904 if (var == NULL) { 1904 if (var == NULL) {
1905 // Declare the name. 1905 // Declare the name.
1906 Variable::Kind kind = Variable::NORMAL; 1906 Variable::Kind kind = Variable::NORMAL;
1907 if (is_function_declaration) { 1907 if (is_function_declaration) {
1908 kind = Variable::FUNCTION; 1908 kind = Variable::FUNCTION;
1909 } 1909 }
1910 var = declaration_scope->DeclareLocal( 1910 var = declaration_scope->DeclareLocal(
1911 name, mode, declaration->initialization(), kind, kNotAssigned); 1911 name, mode, declaration->initialization(), kind, kNotAssigned);
1912 } else if ((IsLexicalVariableMode(mode) || 1912 } else if ((IsLexicalVariableMode(mode) ||
1913 IsLexicalVariableMode(var->mode())) && 1913 IsLexicalVariableMode(var->mode()) ||
1914 // At the top level of a Module, function declarations are
1915 // treated like lexical declarations rather than like var
1916 // declarations.
1917 (declaration_scope->is_module_scope() &&
adamk 2016/04/04 22:19:54 This code belongs not here, but in Parser::ParseFu
mike3 2016/04/13 21:18:44 Of course, that makes much more sense.
1918 (is_function_declaration || var->is_function()))) &&
1914 // Lexical bindings may appear for some parameters in sloppy 1919 // Lexical bindings may appear for some parameters in sloppy
1915 // mode even with --harmony-sloppy off. 1920 // mode even with --harmony-sloppy off.
1916 (is_strict(language_mode()) || allow_harmony_sloppy())) { 1921 (is_strict(language_mode()) || allow_harmony_sloppy())) {
1917 // Allow duplicate function decls for web compat, see bug 4693. 1922 // Allow duplicate function decls for web compat, see bug 4693.
1918 if (is_sloppy(language_mode()) && is_function_declaration && 1923 if (is_sloppy(language_mode()) && is_function_declaration &&
1919 var->is_function()) { 1924 var->is_function()) {
1920 DCHECK(IsLexicalVariableMode(mode) && 1925 DCHECK(IsLexicalVariableMode(mode) &&
1921 IsLexicalVariableMode(var->mode())); 1926 IsLexicalVariableMode(var->mode()));
1922 ++use_counts_[v8::Isolate::kSloppyModeBlockScopedFunctionRedefinition]; 1927 ++use_counts_[v8::Isolate::kSloppyModeBlockScopedFunctionRedefinition];
1923 } else { 1928 } else {
(...skipping 4936 matching lines...) Expand 10 before | Expand all | Expand 10 after
6860 try_block, target); 6865 try_block, target);
6861 final_loop = target; 6866 final_loop = target;
6862 } 6867 }
6863 6868
6864 return final_loop; 6869 return final_loop;
6865 } 6870 }
6866 6871
6867 6872
6868 } // namespace internal 6873 } // namespace internal
6869 } // namespace v8 6874 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698