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

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

Issue 1906923002: [modules] Infer strict mode from within scope object (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 | « src/ast/scopes.cc ('k') | src/parsing/preparser.h » ('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 899 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 } 910 }
911 911
912 scope->set_start_position(0); 912 scope->set_start_position(0);
913 913
914 // Enter 'scope' with the given parsing mode. 914 // Enter 'scope' with the given parsing mode.
915 ParsingModeScope parsing_mode_scope(this, parsing_mode); 915 ParsingModeScope parsing_mode_scope(this, parsing_mode);
916 AstNodeFactory function_factory(ast_value_factory()); 916 AstNodeFactory function_factory(ast_value_factory());
917 FunctionState function_state(&function_state_, &scope_, scope, 917 FunctionState function_state(&function_state_, &scope_, scope,
918 kNormalFunction, &function_factory); 918 kNormalFunction, &function_factory);
919 919
920 // Don't count the mode in the use counters--give the program a chance
921 // to enable script/module-wide strict mode below.
922 scope_->SetLanguageMode(info->language_mode());
923 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone()); 920 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone());
924 bool ok = true; 921 bool ok = true;
925 int beg_pos = scanner()->location().beg_pos; 922 int beg_pos = scanner()->location().beg_pos;
926 if (info->is_module()) { 923 if (info->is_module()) {
927 ParseModuleItemList(body, &ok); 924 ParseModuleItemList(body, &ok);
928 } else { 925 } else {
926 // Don't count the mode in the use counters--give the program a chance
927 // to enable script-wide strict mode below.
928 scope_->SetLanguageMode(info->language_mode());
929 ParseStatementList(body, Token::EOS, &ok); 929 ParseStatementList(body, Token::EOS, &ok);
930 } 930 }
931 931
932 // The parser will peek but not consume EOS. Our scope logically goes all 932 // The parser will peek but not consume EOS. Our scope logically goes all
933 // the way to the EOS, though. 933 // the way to the EOS, though.
934 scope->set_end_position(scanner()->peek_location().beg_pos); 934 scope->set_end_position(scanner()->peek_location().beg_pos);
935 935
936 if (ok && is_strict(language_mode())) { 936 if (ok && is_strict(language_mode())) {
937 CheckStrictOctalLiteral(beg_pos, scanner()->location().end_pos, &ok); 937 CheckStrictOctalLiteral(beg_pos, scanner()->location().end_pos, &ok);
938 } 938 }
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 1288
1289 void* Parser::ParseModuleItemList(ZoneList<Statement*>* body, bool* ok) { 1289 void* Parser::ParseModuleItemList(ZoneList<Statement*>* body, bool* ok) {
1290 // (Ecma 262 6th Edition, 15.2): 1290 // (Ecma 262 6th Edition, 15.2):
1291 // Module : 1291 // Module :
1292 // ModuleBody? 1292 // ModuleBody?
1293 // 1293 //
1294 // ModuleBody : 1294 // ModuleBody :
1295 // ModuleItem* 1295 // ModuleItem*
1296 1296
1297 DCHECK(scope_->is_module_scope()); 1297 DCHECK(scope_->is_module_scope());
1298 RaiseLanguageMode(STRICT);
1299 1298
1300 while (peek() != Token::EOS) { 1299 while (peek() != Token::EOS) {
1301 Statement* stat = ParseModuleItem(CHECK_OK); 1300 Statement* stat = ParseModuleItem(CHECK_OK);
1302 if (stat && !stat->IsEmpty()) { 1301 if (stat && !stat->IsEmpty()) {
1303 body->Add(stat, zone()); 1302 body->Add(stat, zone());
1304 } 1303 }
1305 } 1304 }
1306 1305
1307 // Check that all exports are bound. 1306 // Check that all exports are bound.
1308 ModuleDescriptor* descriptor = scope_->module(); 1307 ModuleDescriptor* descriptor = scope_->module();
(...skipping 5478 matching lines...) Expand 10 before | Expand all | Expand 10 after
6787 try_block, target); 6786 try_block, target);
6788 final_loop = target; 6787 final_loop = target;
6789 } 6788 }
6790 6789
6791 return final_loop; 6790 return final_loop;
6792 } 6791 }
6793 6792
6794 6793
6795 } // namespace internal 6794 } // namespace internal
6796 } // namespace v8 6795 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/scopes.cc ('k') | src/parsing/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698