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

Unified Diff: src/preparser.h

Issue 8344082: Replace boolean indications of strict mode by an enum value. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Some fixes and adapted the preparser. Created 9 years, 2 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
« src/compiler.cc ('K') | « src/parser.cc ('k') | src/runtime.h » ('j') | 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 658693f4aae8c5dd7ee7ef9a5e2bd27623f560a0..6a0b97a56e0b056add04371da5415abc659e6d13 100644
--- a/src/preparser.h
+++ b/src/preparser.h
@@ -408,6 +408,16 @@ class PreParser {
typedef int Arguments;
+ // The Strict Mode (ECMA-262 5th edition, 4.2.2).
+ enum StrictModeFlag {
+ kNonStrictMode,
+ kStrictMode,
+ // This value is never used, but is needed to prevent GCC 4.5 from failing
+ // to compile when we assert that a flag is either kNonStrictMode or
+ // kStrictMode.
+ kInvalidStrictFlag
+ };
+
class Scope {
public:
Scope(Scope** variable, ScopeType type)
@@ -417,7 +427,8 @@ class PreParser {
materialized_literal_count_(0),
expected_properties_(0),
with_nesting_count_(0),
- strict_((prev_ != NULL) && prev_->is_strict()) {
+ strict_mode_flag_((prev_ != NULL) ? prev_->strict_mode_flag()
+ : kNonStrictMode) {
*variable = this;
}
~Scope() { *variable_ = prev_; }
@@ -427,8 +438,13 @@ class PreParser {
int expected_properties() { return expected_properties_; }
int materialized_literal_count() { return materialized_literal_count_; }
bool IsInsideWith() { return with_nesting_count_ != 0; }
- bool is_strict() { return strict_; }
- void set_strict() { strict_ = true; }
+ bool is_strict_mode() { return strict_mode_flag_ == kStrictMode; }
+ StrictModeFlag strict_mode_flag() {
+ return strict_mode_flag_;
+ }
+ void set_strict_mode_flag(StrictModeFlag strict_mode_flag) {
+ strict_mode_flag_ = strict_mode_flag;
+ }
void EnterWith() { with_nesting_count_++; }
void LeaveWith() { with_nesting_count_--; }
@@ -439,7 +455,7 @@ class PreParser {
int materialized_literal_count_;
int expected_properties_;
int with_nesting_count_;
- bool strict_;
+ StrictModeFlag strict_mode_flag_;
};
// Private constructor only used in PreParseProgram.
@@ -470,7 +486,7 @@ class PreParser {
if (stack_overflow_) return kPreParseStackOverflow;
if (!ok) {
ReportUnexpectedToken(scanner_->current_token());
- } else if (scope_->is_strict()) {
+ } else if (scope_->is_strict_mode()) {
CheckOctalLiteral(start_position, scanner_->location().end_pos, &ok);
}
return kPreParseSuccess;
@@ -575,10 +591,10 @@ class PreParser {
bool peek_any_identifier();
void set_strict_mode() {
- scope_->set_strict();
+ scope_->set_strict_mode_flag(kStrictMode);
}
- bool strict_mode() { return scope_->is_strict(); }
+ bool strict_mode() { return scope_->strict_mode_flag() == kStrictMode; }
void Consume(i::Token::Value token) { Next(); }
« src/compiler.cc ('K') | « src/parser.cc ('k') | src/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698