Use StrictModeFlag in preparser and preparse data.
Review URL: http://codereview.chromium.org/8396040 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9818 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
a5b40e27b8
commit
6e767e3f2d
@ -358,6 +358,20 @@ F FUNCTION_CAST(Address addr) {
|
||||
class FreeStoreAllocationPolicy;
|
||||
template <typename T, class P = FreeStoreAllocationPolicy> class List;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Declarations for use in both the preparser and the rest of V8.
|
||||
|
||||
// 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
|
||||
};
|
||||
|
||||
|
||||
} } // namespace v8::internal
|
||||
|
||||
#endif // V8_GLOBALS_H_
|
||||
|
@ -4006,7 +4006,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> function_name,
|
||||
scanner().SeekForward(scope->end_position() - 1);
|
||||
materialized_literal_count = entry.literal_count();
|
||||
expected_property_count = entry.property_count();
|
||||
if (entry.strict_mode()) top_scope_->SetStrictModeFlag(kStrictMode);
|
||||
top_scope_->SetStrictModeFlag(entry.strict_mode_flag());
|
||||
only_simple_this_property_assignments = false;
|
||||
this_property_assignments = isolate()->factory()->empty_fixed_array();
|
||||
Expect(Token::RBRACE, CHECK_OK);
|
||||
|
@ -76,7 +76,9 @@ class FunctionEntry BASE_EMBEDDED {
|
||||
int end_pos() { return backing_[kEndPosOffset]; }
|
||||
int literal_count() { return backing_[kLiteralCountOffset]; }
|
||||
int property_count() { return backing_[kPropertyCountOffset]; }
|
||||
bool strict_mode() { return backing_[kStrictModeOffset] != 0; }
|
||||
StrictModeFlag strict_mode_flag() {
|
||||
return static_cast<StrictModeFlag>(backing_[kStrictModeOffset]);
|
||||
}
|
||||
|
||||
bool is_valid() { return backing_.length() > 0; }
|
||||
|
||||
|
@ -49,7 +49,7 @@ class ParserRecorder {
|
||||
int end,
|
||||
int literals,
|
||||
int properties,
|
||||
int strict_mode) = 0;
|
||||
StrictModeFlag strict_mode) = 0;
|
||||
|
||||
// Logs a symbol creation of a literal or identifier.
|
||||
virtual void LogAsciiSymbol(int start, Vector<const char> literal) { }
|
||||
@ -89,7 +89,7 @@ class FunctionLoggingParserRecorder : public ParserRecorder {
|
||||
int end,
|
||||
int literals,
|
||||
int properties,
|
||||
int strict_mode) {
|
||||
StrictModeFlag strict_mode) {
|
||||
function_store_.Add(start);
|
||||
function_store_.Add(end);
|
||||
function_store_.Add(literals);
|
||||
|
@ -1364,7 +1364,7 @@ PreParser::Expression PreParser::ParseFunctionLiteral(bool* ok) {
|
||||
log_->LogFunction(function_block_pos, end_pos,
|
||||
function_scope.materialized_literal_count(),
|
||||
function_scope.expected_properties(),
|
||||
strict_mode() ? 1 : 0);
|
||||
strict_mode_flag());
|
||||
} else {
|
||||
ParseSourceElements(i::Token::RBRACE, CHECK_OK);
|
||||
Expect(i::Token::RBRACE, CHECK_OK);
|
||||
|
@ -408,16 +408,6 @@ 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)
|
||||
@ -428,7 +418,7 @@ class PreParser {
|
||||
expected_properties_(0),
|
||||
with_nesting_count_(0),
|
||||
strict_mode_flag_((prev_ != NULL) ? prev_->strict_mode_flag()
|
||||
: kNonStrictMode) {
|
||||
: i::kNonStrictMode) {
|
||||
*variable = this;
|
||||
}
|
||||
~Scope() { *variable_ = prev_; }
|
||||
@ -438,11 +428,11 @@ 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_mode() { return strict_mode_flag_ == kStrictMode; }
|
||||
StrictModeFlag strict_mode_flag() {
|
||||
bool is_strict_mode() { return strict_mode_flag_ == i::kStrictMode; }
|
||||
i::StrictModeFlag strict_mode_flag() {
|
||||
return strict_mode_flag_;
|
||||
}
|
||||
void set_strict_mode_flag(StrictModeFlag strict_mode_flag) {
|
||||
void set_strict_mode_flag(i::StrictModeFlag strict_mode_flag) {
|
||||
strict_mode_flag_ = strict_mode_flag;
|
||||
}
|
||||
void EnterWith() { with_nesting_count_++; }
|
||||
@ -455,7 +445,7 @@ class PreParser {
|
||||
int materialized_literal_count_;
|
||||
int expected_properties_;
|
||||
int with_nesting_count_;
|
||||
StrictModeFlag strict_mode_flag_;
|
||||
i::StrictModeFlag strict_mode_flag_;
|
||||
};
|
||||
|
||||
// Private constructor only used in PreParseProgram.
|
||||
@ -591,10 +581,12 @@ class PreParser {
|
||||
bool peek_any_identifier();
|
||||
|
||||
void set_strict_mode() {
|
||||
scope_->set_strict_mode_flag(kStrictMode);
|
||||
scope_->set_strict_mode_flag(i::kStrictMode);
|
||||
}
|
||||
|
||||
bool strict_mode() { return scope_->strict_mode_flag() == kStrictMode; }
|
||||
bool strict_mode() { return scope_->strict_mode_flag() == i::kStrictMode; }
|
||||
|
||||
i::StrictModeFlag strict_mode_flag() { return scope_->strict_mode_flag(); }
|
||||
|
||||
void Consume(i::Token::Value token) { Next(); }
|
||||
|
||||
|
@ -482,16 +482,6 @@ enum CpuFeature { SSE4_1 = 32 + 19, // x86
|
||||
SAHF = 0, // x86
|
||||
FPU = 1}; // MIPS
|
||||
|
||||
// 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
|
||||
};
|
||||
|
||||
|
||||
// Used to specify if a macro instruction must perform a smi check on tagged
|
||||
// values.
|
||||
|
Loading…
Reference in New Issue
Block a user