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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parser.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/preparser.h
diff --git a/src/preparser.h b/src/preparser.h
index 287c26bf742ecd2ab89fd80945317e6b13f1d592..f17a5bd9f5b830da718ebdb9f5aff0b84018d1c4 100644
--- a/src/preparser.h
+++ b/src/preparser.h
@@ -334,6 +334,44 @@ class ParserBase : public Traits {
}
}
+ // Validates strict mode for function parameter lists. This has to be
+ // done after parsing the function, since the function can declare
+ // itself strict.
+ void CheckStrictFunctionNameAndParameters(
+ IdentifierT function_name,
+ bool function_name_is_strict_reserved,
+ const Scanner::Location& function_name_loc,
+ const Scanner::Location& eval_args_error_loc,
+ const Scanner::Location& dupe_error_loc,
+ const Scanner::Location& reserved_loc,
+ bool* ok) {
+ if (this->IsEvalOrArguments(function_name)) {
+ Traits::ReportMessageAt(function_name_loc, "strict_eval_arguments");
+ *ok = false;
+ return;
+ }
+ if (function_name_is_strict_reserved) {
+ Traits::ReportMessageAt(function_name_loc, "unexpected_strict_reserved");
+ *ok = false;
+ return;
+ }
+ if (eval_args_error_loc.IsValid()) {
+ Traits::ReportMessageAt(eval_args_error_loc, "strict_eval_arguments");
+ *ok = false;
+ return;
+ }
+ if (dupe_error_loc.IsValid()) {
+ Traits::ReportMessageAt(dupe_error_loc, "strict_param_dupe");
+ *ok = false;
+ return;
+ }
+ if (reserved_loc.IsValid()) {
+ Traits::ReportMessageAt(reserved_loc, "unexpected_strict_reserved");
+ *ok = false;
+ return;
+ }
+ }
+
// Determine precedence of given token.
static int Precedence(Token::Value token, bool accept_IN) {
if (token == Token::IN && !accept_IN)
« 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