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

Side by Side Diff: src/parser.cc

Issue 718833002: Classes: Cleanup default constructor flag (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « src/objects-inl.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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/ast.h" 8 #include "src/ast.h"
9 #include "src/bailout-reason.h" 9 #include "src/bailout-reason.h"
10 #include "src/base/platform/platform.h" 10 #include "src/base/platform/platform.h"
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 277
278 FunctionLiteral* Parser::DefaultConstructor(bool call_super, Scope* scope, 278 FunctionLiteral* Parser::DefaultConstructor(bool call_super, Scope* scope,
279 int pos, int end_pos) { 279 int pos, int end_pos) {
280 int materialized_literal_count = -1; 280 int materialized_literal_count = -1;
281 int expected_property_count = -1; 281 int expected_property_count = -1;
282 int handler_count = 0; 282 int handler_count = 0;
283 int parameter_count = 0; 283 int parameter_count = 0;
284 AstProperties ast_properties; 284 AstProperties ast_properties;
285 BailoutReason dont_optimize_reason = kNoReason; 285 BailoutReason dont_optimize_reason = kNoReason;
286 const AstRawString* name = ast_value_factory()->empty_string(); 286 const AstRawString* name = ast_value_factory()->empty_string();
287 FunctionKind kind = call_super ? FunctionKind::kDefaultConstructorCallSuper
288 : FunctionKind::kDefaultConstructor;
289 287
290 Scope* function_scope = NewScope(scope, FUNCTION_SCOPE); 288 Scope* function_scope = NewScope(scope, FUNCTION_SCOPE);
291 function_scope->SetStrictMode(STRICT); 289 function_scope->SetStrictMode(STRICT);
292 // Set start and end position to the same value 290 // Set start and end position to the same value
293 function_scope->set_start_position(pos); 291 function_scope->set_start_position(pos);
294 function_scope->set_end_position(pos); 292 function_scope->set_end_position(pos);
295 ZoneList<Statement*>* body = NULL; 293 ZoneList<Statement*>* body = NULL;
296 294
297 { 295 {
298 AstNodeFactory<AstConstructionVisitor> function_factory( 296 AstNodeFactory<AstConstructionVisitor> function_factory(
299 ast_value_factory()); 297 ast_value_factory());
300 FunctionState function_state(&function_state_, &scope_, function_scope, 298 FunctionState function_state(&function_state_, &scope_, function_scope,
301 &function_factory); 299 &function_factory);
302 300
303 body = new (zone()) ZoneList<Statement*>(1, zone()); 301 body = new (zone()) ZoneList<Statement*>(1, zone());
304 if (call_super) { 302 if (call_super) {
305 ZoneList<Expression*>* args = 303 ZoneList<Expression*>* args =
306 new (zone()) ZoneList<Expression*>(0, zone()); 304 new (zone()) ZoneList<Expression*>(0, zone());
307 CallRuntime* call = factory()->NewCallRuntime( 305 CallRuntime* call = factory()->NewCallRuntime(
308 ast_value_factory()->empty_string(), 306 ast_value_factory()->empty_string(),
309 Runtime::FunctionForId(Runtime::kDefaultConstructorSuperCall), args, 307 Runtime::FunctionForId(Runtime::kDefaultConstructorSuperCall), args,
310 pos); 308 pos);
311 body->Add(factory()->NewExpressionStatement(call, pos), zone()); 309 body->Add(factory()->NewExpressionStatement(call, pos), zone());
310 function_scope->RecordSuperUsage();
312 } 311 }
313 312
314 materialized_literal_count = function_state.materialized_literal_count(); 313 materialized_literal_count = function_state.materialized_literal_count();
315 expected_property_count = function_state.expected_property_count(); 314 expected_property_count = function_state.expected_property_count();
316 handler_count = function_state.handler_count(); 315 handler_count = function_state.handler_count();
317 316
318 ast_properties = *factory()->visitor()->ast_properties(); 317 ast_properties = *factory()->visitor()->ast_properties();
319 dont_optimize_reason = factory()->visitor()->dont_optimize_reason(); 318 dont_optimize_reason = factory()->visitor()->dont_optimize_reason();
320 } 319 }
321 320
322 FunctionLiteral* function_literal = factory()->NewFunctionLiteral( 321 FunctionLiteral* function_literal = factory()->NewFunctionLiteral(
323 name, ast_value_factory(), function_scope, body, 322 name, ast_value_factory(), function_scope, body,
324 materialized_literal_count, expected_property_count, handler_count, 323 materialized_literal_count, expected_property_count, handler_count,
325 parameter_count, FunctionLiteral::kNoDuplicateParameters, 324 parameter_count, FunctionLiteral::kNoDuplicateParameters,
326 FunctionLiteral::ANONYMOUS_EXPRESSION, FunctionLiteral::kIsFunction, 325 FunctionLiteral::ANONYMOUS_EXPRESSION, FunctionLiteral::kIsFunction,
327 FunctionLiteral::kNotParenthesized, kind, pos); 326 FunctionLiteral::kNotParenthesized, FunctionKind::kDefaultConstructor,
327 pos);
328 328
329 function_literal->set_ast_properties(&ast_properties); 329 function_literal->set_ast_properties(&ast_properties);
330 function_literal->set_dont_optimize_reason(dont_optimize_reason); 330 function_literal->set_dont_optimize_reason(dont_optimize_reason);
331 331
332 return function_literal; 332 return function_literal;
333 } 333 }
334 334
335 335
336 // ---------------------------------------------------------------------------- 336 // ----------------------------------------------------------------------------
337 // Target is a support class to facilitate manipulation of the 337 // Target is a support class to facilitate manipulation of the
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 ? (shared_info->is_anonymous() 1062 ? (shared_info->is_anonymous()
1063 ? FunctionLiteral::ANONYMOUS_EXPRESSION 1063 ? FunctionLiteral::ANONYMOUS_EXPRESSION
1064 : FunctionLiteral::NAMED_EXPRESSION) 1064 : FunctionLiteral::NAMED_EXPRESSION)
1065 : FunctionLiteral::DECLARATION; 1065 : FunctionLiteral::DECLARATION;
1066 bool ok = true; 1066 bool ok = true;
1067 1067
1068 if (shared_info->is_arrow()) { 1068 if (shared_info->is_arrow()) {
1069 Expression* expression = ParseExpression(false, &ok); 1069 Expression* expression = ParseExpression(false, &ok);
1070 DCHECK(expression->IsFunctionLiteral()); 1070 DCHECK(expression->IsFunctionLiteral());
1071 result = expression->AsFunctionLiteral(); 1071 result = expression->AsFunctionLiteral();
1072 } else if (shared_info->is_default_constructor() || 1072 } else if (shared_info->is_default_constructor()) {
1073 shared_info->is_default_constructor_call_super()) { 1073 result = DefaultConstructor(shared_info->uses_super(), scope,
1074 result = DefaultConstructor( 1074 shared_info->start_position(),
1075 shared_info->is_default_constructor_call_super(), scope, 1075 shared_info->end_position());
1076 shared_info->start_position(), shared_info->end_position());
1077 } else { 1076 } else {
1078 result = ParseFunctionLiteral(raw_name, Scanner::Location::invalid(), 1077 result = ParseFunctionLiteral(raw_name, Scanner::Location::invalid(),
1079 false, // Strict mode name already checked. 1078 false, // Strict mode name already checked.
1080 shared_info->kind(), RelocInfo::kNoPosition, 1079 shared_info->kind(), RelocInfo::kNoPosition,
1081 function_type, 1080 function_type,
1082 FunctionLiteral::NORMAL_ARITY, &ok); 1081 FunctionLiteral::NORMAL_ARITY, &ok);
1083 } 1082 }
1084 // Make sure the results agree. 1083 // Make sure the results agree.
1085 DCHECK(ok == (result != NULL)); 1084 DCHECK(ok == (result != NULL));
1086 } 1085 }
(...skipping 3938 matching lines...) Expand 10 before | Expand all | Expand 10 after
5025 5024
5026 // We cannot internalize on a background thread; a foreground task will take 5025 // We cannot internalize on a background thread; a foreground task will take
5027 // care of calling Parser::Internalize just before compilation. 5026 // care of calling Parser::Internalize just before compilation.
5028 5027
5029 if (compile_options() == ScriptCompiler::kProduceParserCache) { 5028 if (compile_options() == ScriptCompiler::kProduceParserCache) {
5030 if (result != NULL) *info_->cached_data() = recorder.GetScriptData(); 5029 if (result != NULL) *info_->cached_data() = recorder.GetScriptData();
5031 log_ = NULL; 5030 log_ = NULL;
5032 } 5031 }
5033 } 5032 }
5034 } } // namespace v8::internal 5033 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698