Use StrictModeFlag in preparser and preparse data.
authorkeuchel@chromium.org <keuchel@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 27 Oct 2011 13:08:51 +0000 (13:08 +0000)
committerkeuchel@chromium.org <keuchel@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 27 Oct 2011 13:08:51 +0000 (13:08 +0000)
Review URL: http://codereview.chromium.org/8396040

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9818 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/globals.h
src/parser.cc
src/parser.h
src/preparse-data.h
src/preparser.cc
src/preparser.h
src/v8globals.h

index cbe7abd..26a0e5f 100644 (file)
@@ -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 3c6c4ba..37204c9 100644 (file)
@@ -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 268b094..eaae6f7 100644 (file)
@@ -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 c6503c4..c4ddecd 100644 (file)
@@ -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 3313658..b1628eb 100644 (file)
@@ -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 6a0b97a..45e81e9 100644 (file)
@@ -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 f4703ff..40ce30c 100644 (file)
@@ -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.