| 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(); }
|
|
|
|
|