| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 <cmath> | 5 #include <cmath> |
| 6 | 6 |
| 7 #include "src/allocation.h" | 7 #include "src/allocation.h" |
| 8 #include "src/base/logging.h" | 8 #include "src/base/logging.h" |
| 9 #include "src/conversions-inl.h" | 9 #include "src/conversions-inl.h" |
| 10 #include "src/conversions.h" | 10 #include "src/conversions.h" |
| (...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 976 Identifier function_name, Scanner::Location function_name_location, | 976 Identifier function_name, Scanner::Location function_name_location, |
| 977 bool name_is_strict_reserved, FunctionKind kind, int function_token_pos, | 977 bool name_is_strict_reserved, FunctionKind kind, int function_token_pos, |
| 978 FunctionLiteral::FunctionType function_type, | 978 FunctionLiteral::FunctionType function_type, |
| 979 FunctionLiteral::ArityRestriction arity_restriction, bool* ok) { | 979 FunctionLiteral::ArityRestriction arity_restriction, bool* ok) { |
| 980 // Function :: | 980 // Function :: |
| 981 // '(' FormalParameterList? ')' '{' FunctionBody '}' | 981 // '(' FormalParameterList? ')' '{' FunctionBody '}' |
| 982 | 982 |
| 983 // Parse function body. | 983 // Parse function body. |
| 984 bool outer_is_script_scope = scope_->is_script_scope(); | 984 bool outer_is_script_scope = scope_->is_script_scope(); |
| 985 Scope* function_scope = NewScope(scope_, FUNCTION_SCOPE); | 985 Scope* function_scope = NewScope(scope_, FUNCTION_SCOPE); |
| 986 Scope* parameter_scope = NewScope(function_scope, PARAMETER_SCOPE); |
| 986 PreParserFactory factory(NULL); | 987 PreParserFactory factory(NULL); |
| 987 FunctionState function_state(&function_state_, &scope_, function_scope, kind, | 988 FunctionState function_state(&function_state_, &scope_, function_scope, kind, |
| 988 &factory); | 989 &factory); |
| 989 FormalParameterErrorLocations error_locs; | 990 FormalParameterErrorLocations error_locs; |
| 990 | 991 |
| 991 bool is_rest = false; | 992 bool is_rest = false; |
| 992 Expect(Token::LPAREN, CHECK_OK); | 993 Expect(Token::LPAREN, CHECK_OK); |
| 993 int start_position = scanner()->location().beg_pos; | 994 int start_position = scanner()->location().beg_pos; |
| 994 function_scope->set_start_position(start_position); | 995 function_scope->set_start_position(start_position); |
| 995 int num_parameters; | 996 int num_parameters; |
| 996 { | 997 { |
| 997 DuplicateFinder duplicate_finder(scanner()->unicode_cache()); | 998 DuplicateFinder duplicate_finder(scanner()->unicode_cache()); |
| 998 num_parameters = ParseFormalParameterList(&duplicate_finder, &error_locs, | 999 PreParserExpressionList initializers = NewExpressionList(0, zone()); |
| 999 &is_rest, CHECK_OK); | 1000 bool has_initializers = false; |
| 1001 |
| 1002 num_parameters = ParseFormalParameterList( |
| 1003 &duplicate_finder, parameter_scope, &error_locs, initializers, |
| 1004 &has_initializers, &is_rest, CHECK_OK); |
| 1000 } | 1005 } |
| 1001 Expect(Token::RPAREN, CHECK_OK); | 1006 Expect(Token::RPAREN, CHECK_OK); |
| 1002 int formals_end_position = scanner()->location().end_pos; | 1007 int formals_end_position = scanner()->location().end_pos; |
| 1003 | 1008 |
| 1004 CheckArityRestrictions(num_parameters, arity_restriction, start_position, | 1009 CheckArityRestrictions(num_parameters, arity_restriction, start_position, |
| 1005 formals_end_position, CHECK_OK); | 1010 formals_end_position, CHECK_OK); |
| 1006 | 1011 |
| 1007 // See Parser::ParseFunctionLiteral for more information about lazy parsing | 1012 // See Parser::ParseFunctionLiteral for more information about lazy parsing |
| 1008 // and lazy compilation. | 1013 // and lazy compilation. |
| 1009 bool is_lazily_parsed = | 1014 bool is_lazily_parsed = |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1134 | 1139 |
| 1135 DCHECK(!spread_pos.IsValid()); | 1140 DCHECK(!spread_pos.IsValid()); |
| 1136 | 1141 |
| 1137 return Expression::Default(); | 1142 return Expression::Default(); |
| 1138 } | 1143 } |
| 1139 | 1144 |
| 1140 #undef CHECK_OK | 1145 #undef CHECK_OK |
| 1141 | 1146 |
| 1142 | 1147 |
| 1143 } } // v8::internal | 1148 } } // v8::internal |
| OLD | NEW |