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

Side by Side Diff: src/parser.cc

Issue 1097723005: Lolcode candidate: Both Expression and FunctionLiteral define the same accessor (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 5 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/compiler.cc ('k') | src/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/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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 materialized_literal_count = function_state.materialized_literal_count(); 371 materialized_literal_count = function_state.materialized_literal_count();
372 expected_property_count = function_state.expected_property_count(); 372 expected_property_count = function_state.expected_property_count();
373 handler_count = function_state.handler_count(); 373 handler_count = function_state.handler_count();
374 } 374 }
375 375
376 FunctionLiteral* function_literal = factory()->NewFunctionLiteral( 376 FunctionLiteral* function_literal = factory()->NewFunctionLiteral(
377 name, ast_value_factory(), function_scope, body, 377 name, ast_value_factory(), function_scope, body,
378 materialized_literal_count, expected_property_count, handler_count, 378 materialized_literal_count, expected_property_count, handler_count,
379 parameter_count, FunctionLiteral::kNoDuplicateParameters, 379 parameter_count, FunctionLiteral::kNoDuplicateParameters,
380 FunctionLiteral::ANONYMOUS_EXPRESSION, FunctionLiteral::kIsFunction, 380 FunctionLiteral::ANONYMOUS_EXPRESSION, FunctionLiteral::kIsFunction,
381 FunctionLiteral::kNotParenthesized, kind, pos); 381 FunctionLiteral::kShouldLazyCompile, kind, pos);
382 382
383 return function_literal; 383 return function_literal;
384 } 384 }
385 385
386 386
387 // ---------------------------------------------------------------------------- 387 // ----------------------------------------------------------------------------
388 // Target is a support class to facilitate manipulation of the 388 // Target is a support class to facilitate manipulation of the
389 // Parser's target_stack_ (the stack of potential 'break' and 389 // Parser's target_stack_ (the stack of potential 'break' and
390 // 'continue' statement targets). Upon construction, a new target is 390 // 'continue' statement targets). Upon construction, a new target is
391 // added; it is removed upon destruction. 391 // added; it is removed upon destruction.
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 } 1032 }
1033 1033
1034 if (ok) { 1034 if (ok) {
1035 result = factory()->NewFunctionLiteral( 1035 result = factory()->NewFunctionLiteral(
1036 ast_value_factory()->empty_string(), ast_value_factory(), scope_, 1036 ast_value_factory()->empty_string(), ast_value_factory(), scope_,
1037 body, function_state.materialized_literal_count(), 1037 body, function_state.materialized_literal_count(),
1038 function_state.expected_property_count(), 1038 function_state.expected_property_count(),
1039 function_state.handler_count(), 0, 1039 function_state.handler_count(), 0,
1040 FunctionLiteral::kNoDuplicateParameters, 1040 FunctionLiteral::kNoDuplicateParameters,
1041 FunctionLiteral::ANONYMOUS_EXPRESSION, FunctionLiteral::kGlobalOrEval, 1041 FunctionLiteral::ANONYMOUS_EXPRESSION, FunctionLiteral::kGlobalOrEval,
1042 FunctionLiteral::kNotParenthesized, FunctionKind::kNormalFunction, 0); 1042 FunctionLiteral::kShouldLazyCompile, FunctionKind::kNormalFunction,
1043 0);
1043 } 1044 }
1044 } 1045 }
1045 1046
1046 // Make sure the target stack is empty. 1047 // Make sure the target stack is empty.
1047 DCHECK(target_stack_ == NULL); 1048 DCHECK(target_stack_ == NULL);
1048 1049
1049 return result; 1050 return result;
1050 } 1051 }
1051 1052
1052 1053
(...skipping 2773 matching lines...) Expand 10 before | Expand all | Expand 10 after
3826 // need to match the pre-parser's behavior. 3827 // need to match the pre-parser's behavior.
3827 if (expr->IsBinaryOperation()) { 3828 if (expr->IsBinaryOperation()) {
3828 BinaryOperation* binop = expr->AsBinaryOperation(); 3829 BinaryOperation* binop = expr->AsBinaryOperation();
3829 if (binop->op() != Token::COMMA) { 3830 if (binop->op() != Token::COMMA) {
3830 ReportMessageAt(params_loc, "malformed_arrow_function_parameter_list"); 3831 ReportMessageAt(params_loc, "malformed_arrow_function_parameter_list");
3831 *ok = false; 3832 *ok = false;
3832 return; 3833 return;
3833 } 3834 }
3834 Expression* left = binop->left(); 3835 Expression* left = binop->left();
3835 Expression* right = binop->right(); 3836 Expression* right = binop->right();
3836 if (left->is_parenthesized() || right->is_parenthesized()) { 3837 if (left->is_single_parenthesized() || right->is_single_parenthesized()) {
3837 ReportMessageAt(params_loc, "malformed_arrow_function_parameter_list"); 3838 ReportMessageAt(params_loc, "malformed_arrow_function_parameter_list");
3838 *ok = false; 3839 *ok = false;
3839 return; 3840 return;
3840 } 3841 }
3841 DeclareArrowFunctionParameters(scope, left, params_loc, error_locs, ok); 3842 DeclareArrowFunctionParameters(scope, left, params_loc, error_locs, ok);
3842 if (!*ok) return; 3843 if (!*ok) return;
3843 // LHS of comma expression should be unparenthesized. 3844 // LHS of comma expression should be unparenthesized.
3844 expr = right; 3845 expr = right;
3845 } 3846 }
3846 3847
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
3968 is_sloppy(language_mode()) && 3969 is_sloppy(language_mode()) &&
3969 (original_scope_ == original_declaration_scope || 3970 (original_scope_ == original_declaration_scope ||
3970 declaration_scope != original_declaration_scope) 3971 declaration_scope != original_declaration_scope)
3971 ? NewScope(declaration_scope, FUNCTION_SCOPE, kind) 3972 ? NewScope(declaration_scope, FUNCTION_SCOPE, kind)
3972 : NewScope(scope_, FUNCTION_SCOPE, kind); 3973 : NewScope(scope_, FUNCTION_SCOPE, kind);
3973 ZoneList<Statement*>* body = NULL; 3974 ZoneList<Statement*>* body = NULL;
3974 int materialized_literal_count = -1; 3975 int materialized_literal_count = -1;
3975 int expected_property_count = -1; 3976 int expected_property_count = -1;
3976 int handler_count = 0; 3977 int handler_count = 0;
3977 FormalParameterErrorLocations error_locs; 3978 FormalParameterErrorLocations error_locs;
3978 FunctionLiteral::IsParenthesizedFlag parenthesized = parenthesized_function_ 3979 FunctionLiteral::EagerCompileHint eager_compile_hint =
3979 ? FunctionLiteral::kIsParenthesized 3980 parenthesized_function_ ? FunctionLiteral::kShouldEagerCompile
3980 : FunctionLiteral::kNotParenthesized; 3981 : FunctionLiteral::kShouldLazyCompile;
3981 // Parse function body. 3982 // Parse function body.
3982 { 3983 {
3983 AstNodeFactory function_factory(ast_value_factory()); 3984 AstNodeFactory function_factory(ast_value_factory());
3984 FunctionState function_state(&function_state_, &scope_, scope, kind, 3985 FunctionState function_state(&function_state_, &scope_, scope, kind,
3985 &function_factory); 3986 &function_factory);
3986 scope_->SetScopeName(function_name); 3987 scope_->SetScopeName(function_name);
3987 3988
3988 if (is_generator) { 3989 if (is_generator) {
3989 // For generators, allocating variables in contexts is currently a win 3990 // For generators, allocating variables in contexts is currently a win
3990 // because it minimizes the work needed to suspend and resume an 3991 // because it minimizes the work needed to suspend and resume an
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
4116 } 4117 }
4117 4118
4118 FunctionLiteral::ParameterFlag duplicate_parameters = 4119 FunctionLiteral::ParameterFlag duplicate_parameters =
4119 error_locs.duplicate.IsValid() ? FunctionLiteral::kHasDuplicateParameters 4120 error_locs.duplicate.IsValid() ? FunctionLiteral::kHasDuplicateParameters
4120 : FunctionLiteral::kNoDuplicateParameters; 4121 : FunctionLiteral::kNoDuplicateParameters;
4121 4122
4122 FunctionLiteral* function_literal = factory()->NewFunctionLiteral( 4123 FunctionLiteral* function_literal = factory()->NewFunctionLiteral(
4123 function_name, ast_value_factory(), scope, body, 4124 function_name, ast_value_factory(), scope, body,
4124 materialized_literal_count, expected_property_count, handler_count, 4125 materialized_literal_count, expected_property_count, handler_count,
4125 num_parameters, duplicate_parameters, function_type, 4126 num_parameters, duplicate_parameters, function_type,
4126 FunctionLiteral::kIsFunction, parenthesized, kind, pos); 4127 FunctionLiteral::kIsFunction, eager_compile_hint, kind, pos);
4127 function_literal->set_function_token_position(function_token_pos); 4128 function_literal->set_function_token_position(function_token_pos);
4128 4129
4129 if (scope->has_rest_parameter()) { 4130 if (scope->has_rest_parameter()) {
4130 // TODO(caitp): enable optimization of functions with rest params 4131 // TODO(caitp): enable optimization of functions with rest params
4131 function_literal->set_dont_optimize_reason(kRestParameter); 4132 function_literal->set_dont_optimize_reason(kRestParameter);
4132 } 4133 }
4133 4134
4134 if (fni_ != NULL && should_infer_name) fni_->AddFunction(function_literal); 4135 if (fni_ != NULL && should_infer_name) fni_->AddFunction(function_literal);
4135 return function_literal; 4136 return function_literal;
4136 } 4137 }
(...skipping 1694 matching lines...) Expand 10 before | Expand all | Expand 10 after
5831 5832
5832 Expression* Parser::SpreadCallNew(Expression* function, 5833 Expression* Parser::SpreadCallNew(Expression* function,
5833 ZoneList<v8::internal::Expression*>* args, 5834 ZoneList<v8::internal::Expression*>* args,
5834 int pos) { 5835 int pos) {
5835 args->InsertAt(0, function, zone()); 5836 args->InsertAt(0, function, zone());
5836 5837
5837 return factory()->NewCallRuntime( 5838 return factory()->NewCallRuntime(
5838 ast_value_factory()->reflect_construct_string(), NULL, args, pos); 5839 ast_value_factory()->reflect_construct_string(), NULL, args, pos);
5839 } 5840 }
5840 } } // namespace v8::internal 5841 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compiler.cc ('k') | src/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698