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

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

Issue 2601123002: Remove unnecessary language_mode arg from Parser::DefaultConstructor (Closed)
Patch Set: Created 3 years, 11 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/parsing/parser.h ('k') | no next file » | 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 <memory> 7 #include <memory>
8 8
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/ast/ast-expression-rewriter.h" 10 #include "src/ast/ast-expression-rewriter.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 if (consume_cached_parse_data()) { 158 if (consume_cached_parse_data()) {
159 if (allow_lazy_) { 159 if (allow_lazy_) {
160 cached_parse_data_ = ParseData::FromCachedData(*info->cached_data()); 160 cached_parse_data_ = ParseData::FromCachedData(*info->cached_data());
161 if (cached_parse_data_ != nullptr) return; 161 if (cached_parse_data_ != nullptr) return;
162 } 162 }
163 compile_options_ = ScriptCompiler::kNoCompileOptions; 163 compile_options_ = ScriptCompiler::kNoCompileOptions;
164 } 164 }
165 } 165 }
166 166
167 FunctionLiteral* Parser::DefaultConstructor(const AstRawString* name, 167 FunctionLiteral* Parser::DefaultConstructor(const AstRawString* name,
168 bool call_super, 168 bool call_super, int pos,
169 int pos, int end_pos, 169 int end_pos) {
170 LanguageMode language_mode) {
171 int materialized_literal_count = -1; 170 int materialized_literal_count = -1;
172 int expected_property_count = -1; 171 int expected_property_count = -1;
173 const int parameter_count = 0; 172 const int parameter_count = 0;
174 if (name == nullptr) name = ast_value_factory()->empty_string(); 173 if (name == nullptr) name = ast_value_factory()->empty_string();
175 174
176 FunctionKind kind = call_super ? FunctionKind::kDefaultSubclassConstructor 175 FunctionKind kind = call_super ? FunctionKind::kDefaultSubclassConstructor
177 : FunctionKind::kDefaultBaseConstructor; 176 : FunctionKind::kDefaultBaseConstructor;
178 DeclarationScope* function_scope = NewFunctionScope(kind); 177 DeclarationScope* function_scope = NewFunctionScope(kind);
179 SetLanguageMode(function_scope, 178 SetLanguageMode(function_scope, STRICT);
180 static_cast<LanguageMode>(language_mode | STRICT));
181 // Set start and end position to the same value 179 // Set start and end position to the same value
182 function_scope->set_start_position(pos); 180 function_scope->set_start_position(pos);
183 function_scope->set_end_position(pos); 181 function_scope->set_end_position(pos);
184 ZoneList<Statement*>* body = NULL; 182 ZoneList<Statement*>* body = NULL;
185 183
186 { 184 {
187 FunctionState function_state(&function_state_, &scope_state_, 185 FunctionState function_state(&function_state_, &scope_state_,
188 function_scope); 186 function_scope);
189 187
190 body = new (zone()) ZoneList<Statement*>(call_super ? 2 : 1, zone()); 188 body = new (zone()) ZoneList<Statement*>(call_super ? 2 : 1, zone());
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 result = expression->AsFunctionLiteral(); 930 result = expression->AsFunctionLiteral();
933 } else { 931 } else {
934 ok = false; 932 ok = false;
935 } 933 }
936 } 934 }
937 } 935 }
938 } else if (IsDefaultConstructor(kind)) { 936 } else if (IsDefaultConstructor(kind)) {
939 DCHECK_EQ(scope(), outer); 937 DCHECK_EQ(scope(), outer);
940 bool is_subclass_constructor = IsSubclassConstructor(kind); 938 bool is_subclass_constructor = IsSubclassConstructor(kind);
941 result = DefaultConstructor(raw_name, is_subclass_constructor, 939 result = DefaultConstructor(raw_name, is_subclass_constructor,
942 info->start_position(), info->end_position(), 940 info->start_position(), info->end_position());
943 info->language_mode());
944 } else { 941 } else {
945 result = ParseFunctionLiteral( 942 result = ParseFunctionLiteral(
946 raw_name, Scanner::Location::invalid(), kSkipFunctionNameCheck, kind, 943 raw_name, Scanner::Location::invalid(), kSkipFunctionNameCheck, kind,
947 kNoSourcePosition, function_type, info->language_mode(), &ok); 944 kNoSourcePosition, function_type, info->language_mode(), &ok);
948 } 945 }
949 // Make sure the results agree. 946 // Make sure the results agree.
950 DCHECK(ok == (result != nullptr)); 947 DCHECK(ok == (result != nullptr));
951 } 948 }
952 949
953 // Make sure the target stack is empty. 950 // Make sure the target stack is empty.
(...skipping 2373 matching lines...) Expand 10 before | Expand all | Expand 10 after
3327 ClassInfo* class_info, int pos, 3324 ClassInfo* class_info, int pos,
3328 bool* ok) { 3325 bool* ok) {
3329 int end_pos = scanner()->location().end_pos; 3326 int end_pos = scanner()->location().end_pos;
3330 Block* do_block = factory()->NewBlock(nullptr, 1, false, pos); 3327 Block* do_block = factory()->NewBlock(nullptr, 1, false, pos);
3331 Variable* result_var = NewTemporary(ast_value_factory()->empty_string()); 3328 Variable* result_var = NewTemporary(ast_value_factory()->empty_string());
3332 DoExpression* do_expr = factory()->NewDoExpression(do_block, result_var, pos); 3329 DoExpression* do_expr = factory()->NewDoExpression(do_block, result_var, pos);
3333 3330
3334 bool has_extends = class_info->extends != nullptr; 3331 bool has_extends = class_info->extends != nullptr;
3335 bool has_default_constructor = class_info->constructor == nullptr; 3332 bool has_default_constructor = class_info->constructor == nullptr;
3336 if (has_default_constructor) { 3333 if (has_default_constructor) {
3337 class_info->constructor = DefaultConstructor( 3334 class_info->constructor =
3338 name, has_extends, pos, end_pos, scope()->language_mode()); 3335 DefaultConstructor(name, has_extends, pos, end_pos);
3339 } 3336 }
3340 3337
3341 scope()->set_end_position(end_pos); 3338 scope()->set_end_position(end_pos);
3342 3339
3343 if (name != nullptr) { 3340 if (name != nullptr) {
3344 DCHECK_NOT_NULL(class_info->proxy); 3341 DCHECK_NOT_NULL(class_info->proxy);
3345 class_info->proxy->var()->set_initializer_position(end_pos); 3342 class_info->proxy->var()->set_initializer_position(end_pos);
3346 } 3343 }
3347 3344
3348 ClassLiteral* class_literal = factory()->NewClassLiteral( 3345 ClassLiteral* class_literal = factory()->NewClassLiteral(
(...skipping 1785 matching lines...) Expand 10 before | Expand all | Expand 10 after
5134 5131
5135 return final_loop; 5132 return final_loop;
5136 } 5133 }
5137 5134
5138 #undef CHECK_OK 5135 #undef CHECK_OK
5139 #undef CHECK_OK_VOID 5136 #undef CHECK_OK_VOID
5140 #undef CHECK_FAILED 5137 #undef CHECK_FAILED
5141 5138
5142 } // namespace internal 5139 } // namespace internal
5143 } // namespace v8 5140 } // namespace v8
OLDNEW
« no previous file with comments | « src/parsing/parser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698