Reviewers: Lasse Reichstein,

Message:
PTAL

Description:
Use StrictModeFlag in preparser and preparse data.


Please review this at http://codereview.chromium.org/8396040/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/globals.h
  M src/parser.h
  M src/parser.cc
  M src/preparse-data.h
  M src/preparser.h
  M src/preparser.cc
  M src/v8globals.h


Index: src/globals.h
diff --git a/src/globals.h b/src/globals.h
index cbe7abdf664bff14ed4d9d048027b424017dba87..26a0e5f655fe6fe06fcea278f1418f4bc6bb0f1f 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -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_
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index 3c6c4ba1e2ced0c5cac9b22805c9ebdfba5a8049..37204c9a018e9aa8d6010e8645717f314f957ab2 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -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);
Index: src/parser.h
diff --git a/src/parser.h b/src/parser.h
index 268b09474762c1f9e58dbbdbb01b0911da5e6e21..eaae6f7178a3cccb2da1dbcd3a7ec8dd319a3e81 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -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; }

Index: src/preparse-data.h
diff --git a/src/preparse-data.h b/src/preparse-data.h
index c6503c4fc1642aec6540bef36192169cd8901585..c4ddecdb6ff37bab69cdecdfabc3f0ed3a4b259e 100644
--- a/src/preparse-data.h
+++ b/src/preparse-data.h
@@ -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);
Index: src/preparser.cc
diff --git a/src/preparser.cc b/src/preparser.cc
index 3313658ef72c4fa398c46727407fcd8915374225..b1628eb5c54d5dde11b6dedb1372be5bf54acfce 100644
--- a/src/preparser.cc
+++ b/src/preparser.cc
@@ -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);
Index: src/preparser.h
diff --git a/src/preparser.h b/src/preparser.h
index 6a0b97a56e0b056add04371da5415abc659e6d13..45e81e9ac5e6253584ec72ea2ee5b99f154a7ad7 100644
--- a/src/preparser.h
+++ b/src/preparser.h
@@ -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(); }

Index: src/v8globals.h
diff --git a/src/v8globals.h b/src/v8globals.h
index f4703ff090258a64dbc4e8cb562c0efb7df61e20..40ce30c1d550511dd6d7b4edec3ee37466ea7141 100644
--- a/src/v8globals.h
+++ b/src/v8globals.h
@@ -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.


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to