Unreviewed, rolling out r199242.
https://bugs.webkit.org/show_bug.cgi?id=156442

Caused many many leaks (Requested by ap on #webkit).

Reverted changeset:

"Web Inspector: get rid of InspectorBasicValue and
InspectorString subclasses"
https://bugs.webkit.org/show_bug.cgi?id=156407
http://trac.webkit.org/changeset/199242

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@199276 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/inspector/InspectorValues.h b/Source/JavaScriptCore/inspector/InspectorValues.h
index 2dad504..c14efa5 100644
--- a/Source/JavaScriptCore/inspector/InspectorValues.h
+++ b/Source/JavaScriptCore/inspector/InspectorValues.h
@@ -51,14 +51,11 @@
 public:
     static const int maxDepth = 1000;
 
+    InspectorValue()
+        : m_type(Type::Null) { }
     virtual ~InspectorValue() { }
 
     static Ref<InspectorValue> null();
-    static Ref<InspectorValue> create(bool);
-    static Ref<InspectorValue> create(int);
-    static Ref<InspectorValue> create(double);
-    static Ref<InspectorValue> create(const String&);
-    static Ref<InspectorValue> create(const char*);
 
     enum class Type {
         Null = 0,
@@ -67,24 +64,24 @@
         Integer,
         String,
         Object,
-        Array,
+        Array
     };
 
     Type type() const { return m_type; }
+
     bool isNull() const { return m_type == Type::Null; }
 
-    bool asBoolean(bool&) const;
-    bool asInteger(int&) const;
-    bool asInteger(unsigned&) const;
-    bool asInteger(long&) const;
-    bool asInteger(long long&) const;
-    bool asInteger(unsigned long&) const;
-    bool asInteger(unsigned long long&) const;
-    bool asDouble(double&) const;
-    bool asDouble(float&) const;
-    bool asString(String&) const;
-    bool asValue(RefPtr<InspectorValue>&);
-
+    virtual bool asBoolean(bool&) const;
+    virtual bool asInteger(int&) const;
+    virtual bool asInteger(unsigned&) const;
+    virtual bool asInteger(long&) const;
+    virtual bool asInteger(long long&) const;
+    virtual bool asInteger(unsigned long&) const;
+    virtual bool asInteger(unsigned long long&) const;
+    virtual bool asDouble(double&) const;
+    virtual bool asDouble(float&) const;
+    virtual bool asString(String&) const;
+    virtual bool asValue(RefPtr<InspectorValue>&);
     virtual bool asObject(RefPtr<InspectorObject>&);
     virtual bool asArray(RefPtr<InspectorArray>&);
 
@@ -94,41 +91,73 @@
     virtual void writeJSON(StringBuilder& output) const;
 
 protected:
-    InspectorValue()
-        : m_type(Type::Null) { }
-
-    explicit InspectorValue(Type type)
-        : m_type(type) { }
-
-    explicit InspectorValue(bool value)
-        : m_type(Type::Boolean)
-        , m_booleanValue(value) { }
-
-    explicit InspectorValue(int value)
-        : m_type(Type::Integer)
-        , m_doubleValue(static_cast<double>(value)) { }
-
-    explicit InspectorValue(double value)
-        : m_type(Type::Double)
-        , m_doubleValue(value) { }
-
-    explicit InspectorValue(const String& value)
-        : m_type(Type::String)
-        , m_stringValue(value) { }
-
-    explicit InspectorValue(const char* value)
-        : m_type(Type::String)
-        , m_stringValue(value) { }
+    explicit InspectorValue(Type type) : m_type(type) { }
 
 private:
-    Type m_type { Type::Null };
+    Type m_type;
+};
+
+class JS_EXPORT_PRIVATE InspectorBasicValue : public InspectorValue {
+public:
+
+    static Ref<InspectorBasicValue> create(bool);
+    static Ref<InspectorBasicValue> create(int);
+    static Ref<InspectorBasicValue> create(double);
+
+    bool asBoolean(bool&) const override;
+    // Numbers from the frontend are always parsed as doubles, so we allow
+    // clients to convert to integral values with this function.
+    bool asInteger(int&) const override;
+    bool asInteger(unsigned&) const override;
+    bool asInteger(long&) const override;
+    bool asInteger(long long&) const override;
+    bool asInteger(unsigned long&) const override;
+    bool asInteger(unsigned long long&) const override;
+    bool asDouble(double&) const override;
+    bool asDouble(float&) const override;
+
+    void writeJSON(StringBuilder& output) const override;
+
+private:
+    explicit InspectorBasicValue(bool value)
+        : InspectorValue(Type::Boolean)
+        , m_booleanValue(value) { }
+
+    explicit InspectorBasicValue(int value)
+        : InspectorValue(Type::Integer)
+        , m_doubleValue(static_cast<double>(value)) { }
+
+    explicit InspectorBasicValue(double value)
+        : InspectorValue(Type::Double)
+        , m_doubleValue(value) { }
+
     union {
         bool m_booleanValue;
         double m_doubleValue;
-        String m_stringValue;
     };
 };
 
+class JS_EXPORT_PRIVATE InspectorString : public InspectorValue {
+public:
+    static Ref<InspectorString> create(const String&);
+    static Ref<InspectorString> create(const char*);
+
+    bool asString(String& output) const override;
+
+    void writeJSON(StringBuilder& output) const override;
+
+private:
+    explicit InspectorString(const String& value)
+        : InspectorValue(Type::String)
+        , m_stringValue(value) { }
+
+    explicit InspectorString(const char* value)
+        : InspectorValue(Type::String)
+        , m_stringValue(value) { }
+
+    String m_stringValue;
+};
+
 class JS_EXPORT_PRIVATE InspectorObjectBase : public InspectorValue {
 private:
     typedef HashMap<String, RefPtr<InspectorValue>> Dictionary;
@@ -300,22 +329,22 @@
 
 inline void InspectorObjectBase::setBoolean(const String& name, bool value)
 {
-    setValue(name, InspectorValue::create(value));
+    setValue(name, InspectorBasicValue::create(value));
 }
 
 inline void InspectorObjectBase::setInteger(const String& name, int value)
 {
-    setValue(name, InspectorValue::create(value));
+    setValue(name, InspectorBasicValue::create(value));
 }
 
 inline void InspectorObjectBase::setDouble(const String& name, double value)
 {
-    setValue(name, InspectorValue::create(value));
+    setValue(name, InspectorBasicValue::create(value));
 }
 
 inline void InspectorObjectBase::setString(const String& name, const String& value)
 {
-    setValue(name, InspectorValue::create(value));
+    setValue(name, InspectorString::create(value));
 }
 
 inline void InspectorObjectBase::setValue(const String& name, RefPtr<InspectorValue>&& value)
@@ -341,22 +370,22 @@
 
 inline void InspectorArrayBase::pushBoolean(bool value)
 {
-    m_data.append(InspectorValue::create(value));
+    m_data.append(InspectorBasicValue::create(value));
 }
 
 inline void InspectorArrayBase::pushInteger(int value)
 {
-    m_data.append(InspectorValue::create(value));
+    m_data.append(InspectorBasicValue::create(value));
 }
 
 inline void InspectorArrayBase::pushDouble(double value)
 {
-    m_data.append(InspectorValue::create(value));
+    m_data.append(InspectorBasicValue::create(value));
 }
 
 inline void InspectorArrayBase::pushString(const String& value)
 {
-    m_data.append(InspectorValue::create(value));
+    m_data.append(InspectorString::create(value));
 }
 
 inline void InspectorArrayBase::pushValue(RefPtr<InspectorValue>&& value)