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

Side by Side Diff: src/preparser.cc

Issue 160073006: Implement handling of arrow functions in the parser (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Removed ParamListFinder Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
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 "include/v8stdint.h" 7 #include "include/v8stdint.h"
8 8
9 #include "src/allocation.h" 9 #include "src/allocation.h"
10 #include "src/checks.h" 10 #include "src/checks.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 name, function_name_location, name_is_strict_reserved, is_generator, 101 name, function_name_location, name_is_strict_reserved, is_generator,
102 function_token_position, type, arity_restriction, ok); 102 function_token_position, type, arity_restriction, ok);
103 } 103 }
104 104
105 105
106 PreParser::PreParseResult PreParser::PreParseLazyFunction( 106 PreParser::PreParseResult PreParser::PreParseLazyFunction(
107 StrictMode strict_mode, bool is_generator, ParserRecorder* log) { 107 StrictMode strict_mode, bool is_generator, ParserRecorder* log) {
108 log_ = log; 108 log_ = log;
109 // Lazy functions always have trivial outer scopes (no with/catch scopes). 109 // Lazy functions always have trivial outer scopes (no with/catch scopes).
110 PreParserScope top_scope(scope_, GLOBAL_SCOPE); 110 PreParserScope top_scope(scope_, GLOBAL_SCOPE);
111 FunctionState top_state(&function_state_, &scope_, &top_scope); 111 FunctionState top_state(&function_state_, &scope_, &top_scope,
112 NULL, this->ast_value_factory());
marja 2014/06/26 14:38:13 this->ast_value_factory is always NULL, right? So
112 scope_->SetStrictMode(strict_mode); 113 scope_->SetStrictMode(strict_mode);
113 PreParserScope function_scope(scope_, FUNCTION_SCOPE); 114 PreParserScope function_scope(scope_, FUNCTION_SCOPE);
114 FunctionState function_state(&function_state_, &scope_, &function_scope); 115 FunctionState function_state(&function_state_, &scope_, &function_scope,
116 NULL, this->ast_value_factory());
115 function_state.set_is_generator(is_generator); 117 function_state.set_is_generator(is_generator);
116 ASSERT_EQ(Token::LBRACE, scanner()->current_token()); 118 ASSERT_EQ(Token::LBRACE, scanner()->current_token());
117 bool ok = true; 119 bool ok = true;
118 int start_position = peek_position(); 120 int start_position = peek_position();
119 ParseLazyFunctionLiteralBody(&ok); 121 ParseLazyFunctionLiteralBody(&ok);
120 if (stack_overflow()) return kPreParseStackOverflow; 122 if (stack_overflow()) return kPreParseStackOverflow;
121 if (!ok) { 123 if (!ok) {
122 ReportUnexpectedToken(scanner()->current_token()); 124 ReportUnexpectedToken(scanner()->current_token());
123 } else { 125 } else {
124 ASSERT_EQ(Token::RBRACE, scanner()->peek()); 126 ASSERT_EQ(Token::RBRACE, scanner()->peek());
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 int function_token_pos, 804 int function_token_pos,
803 FunctionLiteral::FunctionType function_type, 805 FunctionLiteral::FunctionType function_type,
804 FunctionLiteral::ArityRestriction arity_restriction, 806 FunctionLiteral::ArityRestriction arity_restriction,
805 bool* ok) { 807 bool* ok) {
806 // Function :: 808 // Function ::
807 // '(' FormalParameterList? ')' '{' FunctionBody '}' 809 // '(' FormalParameterList? ')' '{' FunctionBody '}'
808 810
809 // Parse function body. 811 // Parse function body.
810 ScopeType outer_scope_type = scope_->type(); 812 ScopeType outer_scope_type = scope_->type();
811 PreParserScope function_scope(scope_, FUNCTION_SCOPE); 813 PreParserScope function_scope(scope_, FUNCTION_SCOPE);
812 FunctionState function_state(&function_state_, &scope_, &function_scope); 814 FunctionState function_state(&function_state_, &scope_, &function_scope,
815 NULL, this->ast_value_factory());
813 function_state.set_is_generator(is_generator); 816 function_state.set_is_generator(is_generator);
814 // FormalParameterList :: 817 // FormalParameterList ::
815 // '(' (Identifier)*[','] ')' 818 // '(' (Identifier)*[','] ')'
816 Expect(Token::LPAREN, CHECK_OK); 819 Expect(Token::LPAREN, CHECK_OK);
817 int start_position = position(); 820 int start_position = position();
818 DuplicateFinder duplicate_finder(scanner()->unicode_cache()); 821 DuplicateFinder duplicate_finder(scanner()->unicode_cache());
819 // We don't yet know if the function will be strict, so we cannot yet produce 822 // We don't yet know if the function will be strict, so we cannot yet produce
820 // errors for parameter names or duplicates. However, we remember the 823 // errors for parameter names or duplicates. However, we remember the
821 // locations of these errors if they occur and produce the errors later. 824 // locations of these errors if they occur and produce the errors later.
822 Scanner::Location eval_args_error_loc = Scanner::Location::invalid(); 825 Scanner::Location eval_args_error_loc = Scanner::Location::invalid();
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); 930 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK);
928 ParseArguments(ok); 931 ParseArguments(ok);
929 932
930 return Expression::Default(); 933 return Expression::Default();
931 } 934 }
932 935
933 #undef CHECK_OK 936 #undef CHECK_OK
934 937
935 938
936 } } // v8::internal 939 } } // v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698