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

Side by Side Diff: src/parser.cc

Issue 6927075: Strict mode detection in preparser. (Closed)
Patch Set: Added TODO with bugnumber for R Created 9 years, 7 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/parser.h ('k') | src/preparse-data.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 3525 matching lines...) Expand 10 before | Expand all | Expand 10 after
3536 bool only_simple_this_property_assignments; 3536 bool only_simple_this_property_assignments;
3537 Handle<FixedArray> this_property_assignments; 3537 Handle<FixedArray> this_property_assignments;
3538 // Parse function body. 3538 // Parse function body.
3539 { LexicalScope lexical_scope(this, scope, isolate()); 3539 { LexicalScope lexical_scope(this, scope, isolate());
3540 top_scope_->SetScopeName(name); 3540 top_scope_->SetScopeName(name);
3541 3541
3542 // FormalParameterList :: 3542 // FormalParameterList ::
3543 // '(' (Identifier)*[','] ')' 3543 // '(' (Identifier)*[','] ')'
3544 Expect(Token::LPAREN, CHECK_OK); 3544 Expect(Token::LPAREN, CHECK_OK);
3545 start_pos = scanner().location().beg_pos; 3545 start_pos = scanner().location().beg_pos;
3546 Scanner::Location name_loc = Scanner::NoLocation(); 3546 Scanner::Location name_loc = Scanner::Location::invalid();
3547 Scanner::Location dupe_loc = Scanner::NoLocation(); 3547 Scanner::Location dupe_loc = Scanner::Location::invalid();
3548 Scanner::Location reserved_loc = Scanner::NoLocation(); 3548 Scanner::Location reserved_loc = Scanner::Location::invalid();
3549 3549
3550 bool done = (peek() == Token::RPAREN); 3550 bool done = (peek() == Token::RPAREN);
3551 while (!done) { 3551 while (!done) {
3552 bool is_reserved = false; 3552 bool is_reserved = false;
3553 Handle<String> param_name = 3553 Handle<String> param_name =
3554 ParseIdentifierOrReservedWord(&is_reserved, CHECK_OK); 3554 ParseIdentifierOrReservedWord(&is_reserved, CHECK_OK);
3555 3555
3556 // Store locations for possible future error reports. 3556 // Store locations for possible future error reports.
3557 if (!name_loc.IsValid() && IsEvalOrArguments(param_name)) { 3557 if (!name_loc.IsValid() && IsEvalOrArguments(param_name)) {
3558 name_loc = scanner().location(); 3558 name_loc = scanner().location();
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
3857 ? expression->AsVariableProxy() 3857 ? expression->AsVariableProxy()
3858 : NULL; 3858 : NULL;
3859 3859
3860 if (lhs != NULL && !lhs->is_this() && IsEvalOrArguments(lhs->name())) { 3860 if (lhs != NULL && !lhs->is_this() && IsEvalOrArguments(lhs->name())) {
3861 ReportMessage(error, Vector<const char*>::empty()); 3861 ReportMessage(error, Vector<const char*>::empty());
3862 *ok = false; 3862 *ok = false;
3863 } 3863 }
3864 } 3864 }
3865 3865
3866 3866
3867 // Checks whether octal literal last seen is between beg_pos and end_pos. 3867 // Checks whether an octal literal was last seen between beg_pos and end_pos.
3868 // If so, reports an error. 3868 // If so, reports an error. Only called for strict mode.
3869 void Parser::CheckOctalLiteral(int beg_pos, int end_pos, bool* ok) { 3869 void Parser::CheckOctalLiteral(int beg_pos, int end_pos, bool* ok) {
3870 int octal = scanner().octal_position(); 3870 Scanner::Location octal = scanner().octal_position();
3871 if (beg_pos <= octal && octal <= end_pos) { 3871 if (octal.IsValid() &&
3872 ReportMessageAt(Scanner::Location(octal, octal + 1), "strict_octal_literal", 3872 beg_pos <= octal.beg_pos &&
3873 octal.end_pos <= end_pos) {
3874 ReportMessageAt(octal, "strict_octal_literal",
3873 Vector<const char*>::empty()); 3875 Vector<const char*>::empty());
3874 scanner().clear_octal_position(); 3876 scanner().clear_octal_position();
3875 *ok = false; 3877 *ok = false;
3876 } 3878 }
3877 } 3879 }
3878 3880
3879 3881
3880 // This function reads an identifier and determines whether or not it 3882 // This function reads an identifier and determines whether or not it
3881 // is 'get' or 'set'. 3883 // is 'get' or 'set'.
3882 Handle<String> Parser::ParseIdentifierOrGetOrSet(bool* is_get, 3884 Handle<String> Parser::ParseIdentifierOrGetOrSet(bool* is_get,
(...skipping 1270 matching lines...) Expand 10 before | Expand all | Expand 10 after
5153 info->is_global(), 5155 info->is_global(),
5154 info->StrictMode()); 5156 info->StrictMode());
5155 } 5157 }
5156 } 5158 }
5157 5159
5158 info->SetFunction(result); 5160 info->SetFunction(result);
5159 return (result != NULL); 5161 return (result != NULL);
5160 } 5162 }
5161 5163
5162 } } // namespace v8::internal 5164 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/parser.h ('k') | src/preparse-data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698