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

Side by Side Diff: src/preparser.h

Issue 332053004: Parser: Refactor strict mode checks for functions (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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
« no previous file with comments | « src/parser.cc ('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 #ifndef V8_PREPARSER_H 5 #ifndef V8_PREPARSER_H
6 #define V8_PREPARSER_H 6 #define V8_PREPARSER_H
7 7
8 #include "src/func-name-inferrer.h" 8 #include "src/func-name-inferrer.h"
9 #include "src/hashmap.h" 9 #include "src/hashmap.h"
10 #include "src/scopes.h" 10 #include "src/scopes.h"
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 void CheckOctalLiteral(int beg_pos, int end_pos, bool* ok) { 327 void CheckOctalLiteral(int beg_pos, int end_pos, bool* ok) {
328 Scanner::Location octal = scanner()->octal_position(); 328 Scanner::Location octal = scanner()->octal_position();
329 if (octal.IsValid() && beg_pos <= octal.beg_pos && 329 if (octal.IsValid() && beg_pos <= octal.beg_pos &&
330 octal.end_pos <= end_pos) { 330 octal.end_pos <= end_pos) {
331 ReportMessageAt(octal, "strict_octal_literal"); 331 ReportMessageAt(octal, "strict_octal_literal");
332 scanner()->clear_octal_position(); 332 scanner()->clear_octal_position();
333 *ok = false; 333 *ok = false;
334 } 334 }
335 } 335 }
336 336
337 // Validates strict mode for function parameter lists. This has to be
338 // done after parsing the function, since the function can declare
339 // itself strict.
340 void CheckStrictFunctionNameAndParameters(
341 IdentifierT function_name,
342 bool function_name_is_strict_reserved,
343 const Scanner::Location& function_name_loc,
344 const Scanner::Location& eval_args_error_loc,
345 const Scanner::Location& dupe_error_loc,
346 const Scanner::Location& reserved_loc,
347 bool* ok) {
348 if (this->IsEvalOrArguments(function_name)) {
349 Traits::ReportMessageAt(function_name_loc, "strict_eval_arguments");
350 *ok = false;
351 return;
352 }
353 if (function_name_is_strict_reserved) {
354 Traits::ReportMessageAt(function_name_loc, "unexpected_strict_reserved");
355 *ok = false;
356 return;
357 }
358 if (eval_args_error_loc.IsValid()) {
359 Traits::ReportMessageAt(eval_args_error_loc, "strict_eval_arguments");
360 *ok = false;
361 return;
362 }
363 if (dupe_error_loc.IsValid()) {
364 Traits::ReportMessageAt(dupe_error_loc, "strict_param_dupe");
365 *ok = false;
366 return;
367 }
368 if (reserved_loc.IsValid()) {
369 Traits::ReportMessageAt(reserved_loc, "unexpected_strict_reserved");
370 *ok = false;
371 return;
372 }
373 }
374
337 // Determine precedence of given token. 375 // Determine precedence of given token.
338 static int Precedence(Token::Value token, bool accept_IN) { 376 static int Precedence(Token::Value token, bool accept_IN) {
339 if (token == Token::IN && !accept_IN) 377 if (token == Token::IN && !accept_IN)
340 return 0; // 0 precedence will terminate binary expression parsing 378 return 0; // 0 precedence will terminate binary expression parsing
341 return Token::Precedence(token); 379 return Token::Precedence(token);
342 } 380 }
343 381
344 typename Traits::Type::Factory* factory() { 382 typename Traits::Type::Factory* factory() {
345 return function_state_->factory(); 383 return function_state_->factory();
346 } 384 }
(...skipping 1818 matching lines...) Expand 10 before | Expand all | Expand 10 after
2165 parser()->ReportMessage("accessor_get_set"); 2203 parser()->ReportMessage("accessor_get_set");
2166 } 2204 }
2167 *ok = false; 2205 *ok = false;
2168 } 2206 }
2169 } 2207 }
2170 2208
2171 2209
2172 } } // v8::internal 2210 } } // v8::internal
2173 2211
2174 #endif // V8_PREPARSER_H 2212 #endif // V8_PREPARSER_H
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698