Index: src/preparser.h |
diff --git a/src/preparser.h b/src/preparser.h |
index 14b801a560f574d7e7798f7f3c2a907dffea978a..81289832f58267dbf6d0900206c86ea5746bb03f 100644 |
--- a/src/preparser.h |
+++ b/src/preparser.h |
@@ -297,8 +297,7 @@ class ParserBase : public Traits { |
return function_state_->factory(); |
} |
- bool is_sloppy_mode() const { return scope_->is_sloppy_mode(); } |
- |
+ StrictMode strict_mode() { return scope_->strict_mode(); } |
bool is_generator() const { return function_state_->is_generator(); } |
// Report syntax errors. |
@@ -365,10 +364,10 @@ class ParserBase : public Traits { |
// Validation per ECMA 262 - 11.1.5 "Object Initialiser". |
class ObjectLiteralChecker { |
public: |
- ObjectLiteralChecker(ParserBase* parser, LanguageMode mode) |
+ ObjectLiteralChecker(ParserBase* parser, StrictMode strict_mode) |
: parser_(parser), |
finder_(scanner()->unicode_cache()), |
- language_mode_(mode) { } |
+ strict_mode_(strict_mode) { } |
void CheckProperty(Token::Value property, PropertyKind type, bool* ok); |
@@ -392,7 +391,7 @@ class ParserBase : public Traits { |
ParserBase* parser_; |
DuplicateFinder finder_; |
- LanguageMode language_mode_; |
+ StrictMode strict_mode_; |
}; |
// If true, the next (and immediately following) function literal is |
@@ -563,36 +562,27 @@ class PreParserScope { |
explicit PreParserScope(PreParserScope* outer_scope, ScopeType scope_type) |
: scope_type_(scope_type) { |
if (outer_scope) { |
- scope_inside_with_ = |
- outer_scope->scope_inside_with_ || is_with_scope(); |
- language_mode_ = outer_scope->language_mode(); |
+ scope_inside_with_ = outer_scope->scope_inside_with_ || is_with_scope(); |
+ strict_mode_ = outer_scope->strict_mode(); |
} else { |
scope_inside_with_ = is_with_scope(); |
- language_mode_ = SLOPPY_MODE; |
+ strict_mode_ = SLOPPY; |
} |
} |
bool is_with_scope() const { return scope_type_ == WITH_SCOPE; } |
- bool is_sloppy_mode() const { |
- return language_mode() == SLOPPY_MODE; |
- } |
- bool is_extended_mode() { |
- return language_mode() == EXTENDED_MODE; |
- } |
bool inside_with() const { |
return scope_inside_with_; |
} |
ScopeType type() { return scope_type_; } |
- LanguageMode language_mode() const { return language_mode_; } |
- void SetLanguageMode(LanguageMode language_mode) { |
- language_mode_ = language_mode; |
- } |
+ StrictMode strict_mode() const { return strict_mode_; } |
+ void SetStrictMode(StrictMode strict_mode) { strict_mode_ = strict_mode; } |
private: |
ScopeType scope_type_; |
bool scope_inside_with_; |
- LanguageMode language_mode_; |
+ StrictMode strict_mode_; |
}; |
@@ -763,7 +753,7 @@ class PreParser : public ParserBase<PreParserTraits> { |
if (stack_overflow()) return kPreParseStackOverflow; |
if (!ok) { |
ReportUnexpectedToken(scanner()->current_token()); |
- } else if (!scope_->is_sloppy_mode()) { |
+ } else if (scope_->strict_mode() == STRICT) { |
CheckOctalLiteral(start_position, scanner()->location().end_pos, &ok); |
} |
return kPreParseSuccess; |
@@ -777,7 +767,7 @@ class PreParser : public ParserBase<PreParserTraits> { |
// keyword and parameters, and have consumed the initial '{'. |
// At return, unless an error occurred, the scanner is positioned before the |
// the final '}'. |
- PreParseResult PreParseLazyFunction(LanguageMode mode, |
+ PreParseResult PreParseLazyFunction(StrictMode strict_mode, |
bool is_generator, |
ParserRecorder* log); |
@@ -973,9 +963,8 @@ void ParserBase<Traits>::ReportUnexpectedToken(Token::Value token) { |
return ReportMessageAt(source_location, "unexpected_reserved"); |
case Token::YIELD: |
case Token::FUTURE_STRICT_RESERVED_WORD: |
- return ReportMessageAt(source_location, |
- is_sloppy_mode() ? "unexpected_token_identifier" |
- : "unexpected_strict_reserved"); |
+ return ReportMessageAt(source_location, strict_mode() == SLOPPY |
+ ? "unexpected_token_identifier" : "unexpected_strict_reserved"); |
default: |
const char* name = Token::String(token); |
ASSERT(name != NULL); |
@@ -993,13 +982,14 @@ typename Traits::Type::Identifier ParserBase<Traits>::ParseIdentifier( |
if (next == Token::IDENTIFIER) { |
typename Traits::Type::Identifier name = this->GetSymbol(scanner()); |
if (allow_eval_or_arguments == kDontAllowEvalOrArguments && |
- !is_sloppy_mode() && this->IsEvalOrArguments(name)) { |
+ strict_mode() == STRICT && this->IsEvalOrArguments(name)) { |
ReportMessageAt(scanner()->location(), "strict_eval_arguments"); |
*ok = false; |
} |
return name; |
- } else if (is_sloppy_mode() && (next == Token::FUTURE_STRICT_RESERVED_WORD || |
- (next == Token::YIELD && !is_generator()))) { |
+ } else if (strict_mode() == SLOPPY && |
+ (next == Token::FUTURE_STRICT_RESERVED_WORD || |
+ (next == Token::YIELD && !is_generator()))) { |
return this->GetSymbol(scanner()); |
} else { |
this->ReportUnexpectedToken(next); |
@@ -1258,7 +1248,7 @@ void ParserBase<Traits>::ObjectLiteralChecker::CheckProperty( |
if (HasConflict(old_type, type)) { |
if (IsDataDataConflict(old_type, type)) { |
// Both are data properties. |
- if (language_mode_ == SLOPPY_MODE) return; |
+ if (strict_mode_ == SLOPPY) return; |
parser()->ReportMessageAt(scanner()->location(), |
"strict_duplicate_property"); |
} else if (IsDataAccessorConflict(old_type, type)) { |