From aa92c84e08a23ce60b21382daae7fb57bb0e691f Mon Sep 17 00:00:00 2001
From: Roberto Raggi <roberto.raggi@nokia.com>
Date: Tue, 26 Jan 2010 15:12:47 +0100
Subject: [PATCH] Group the members of ConvertToString and ConvertToNumber.

---
 src/libs/qmljs/qmljsinterpreter.cpp | 161 ++++++++++++++--------------
 1 file changed, 78 insertions(+), 83 deletions(-)

diff --git a/src/libs/qmljs/qmljsinterpreter.cpp b/src/libs/qmljs/qmljsinterpreter.cpp
index 9c3468a1645..4d664ee8cc9 100644
--- a/src/libs/qmljs/qmljsinterpreter.cpp
+++ b/src/libs/qmljs/qmljsinterpreter.cpp
@@ -1060,6 +1060,45 @@ const Value *ConvertToNumber::switchResult(const Value *value)
     return previousResult;
 }
 
+void ConvertToNumber::visit(const NullValue *)
+{
+    _result = _engine->numberValue();
+}
+
+void ConvertToNumber::visit(const UndefinedValue *)
+{
+    _result = _engine->numberValue();
+}
+
+void ConvertToNumber::visit(const NumberValue *value)
+{
+    _result = value;
+}
+
+void ConvertToNumber::visit(const BooleanValue *)
+{
+    _result = _engine->numberValue();
+}
+
+void ConvertToNumber::visit(const StringValue *)
+{
+    _result = _engine->numberValue();
+}
+
+void ConvertToNumber::visit(const ObjectValue *object)
+{
+    if (const FunctionValue *valueOfMember = value_cast<const FunctionValue *>(object->lookup("valueOf"))) {
+        _result = value_cast<const NumberValue *>(valueOfMember->call(object)); // ### invoke convert-to-number?
+    }
+}
+
+void ConvertToNumber::visit(const FunctionValue *object)
+{
+    if (const FunctionValue *valueOfMember = value_cast<const FunctionValue *>(object->lookup("valueOf"))) {
+        _result = value_cast<const NumberValue *>(valueOfMember->call(object)); // ### invoke convert-to-number?
+    }
+}
+
 ConvertToString::ConvertToString(Engine *engine)
     : _engine(engine), _result(0)
 {
@@ -1082,6 +1121,45 @@ const Value *ConvertToString::switchResult(const Value *value)
     return previousResult;
 }
 
+void ConvertToString::visit(const NullValue *)
+{
+    _result = _engine->stringValue();
+}
+
+void ConvertToString::visit(const UndefinedValue *)
+{
+    _result = _engine->stringValue();
+}
+
+void ConvertToString::visit(const NumberValue *)
+{
+    _result = _engine->stringValue();
+}
+
+void ConvertToString::visit(const BooleanValue *)
+{
+    _result = _engine->stringValue();
+}
+
+void ConvertToString::visit(const StringValue *value)
+{
+    _result = value;
+}
+
+void ConvertToString::visit(const ObjectValue *object)
+{
+    if (const FunctionValue *toStringMember = value_cast<const FunctionValue *>(object->lookup("toString"))) {
+        _result = value_cast<const StringValue *>(toStringMember->call(object)); // ### invoke convert-to-string?
+    }
+}
+
+void ConvertToString::visit(const FunctionValue *object)
+{
+    if (const FunctionValue *toStringMember = value_cast<const FunctionValue *>(object->lookup("toString"))) {
+        _result = value_cast<const StringValue *>(toStringMember->call(object)); // ### invoke convert-to-string?
+    }
+}
+
 ConvertToObject::ConvertToObject(Engine *engine)
     : _engine(engine), _result(0)
 {
@@ -1740,86 +1818,3 @@ ObjectValue *Engine::newQmlObject(const QString &name)
 #endif
 }
 
-////////////////////////////////////////////////////////////////////////////////
-// convert to number
-////////////////////////////////////////////////////////////////////////////////
-void ConvertToNumber::visit(const NullValue *)
-{
-    _result = _engine->numberValue();
-}
-
-void ConvertToNumber::visit(const UndefinedValue *)
-{
-    _result = _engine->numberValue();
-}
-
-void ConvertToNumber::visit(const NumberValue *value)
-{
-    _result = value;
-}
-
-void ConvertToNumber::visit(const BooleanValue *)
-{
-    _result = _engine->numberValue();
-}
-
-void ConvertToNumber::visit(const StringValue *)
-{
-    _result = _engine->numberValue();
-}
-
-void ConvertToNumber::visit(const ObjectValue *object)
-{
-    if (const FunctionValue *valueOfMember = value_cast<const FunctionValue *>(object->lookup("valueOf"))) {
-        _result = value_cast<const NumberValue *>(valueOfMember->call(object)); // ### invoke convert-to-number?
-    }
-}
-
-void ConvertToNumber::visit(const FunctionValue *object)
-{
-    if (const FunctionValue *valueOfMember = value_cast<const FunctionValue *>(object->lookup("valueOf"))) {
-        _result = value_cast<const NumberValue *>(valueOfMember->call(object)); // ### invoke convert-to-number?
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// convert to string
-////////////////////////////////////////////////////////////////////////////////
-void ConvertToString::visit(const NullValue *)
-{
-    _result = _engine->stringValue();
-}
-
-void ConvertToString::visit(const UndefinedValue *)
-{
-    _result = _engine->stringValue();
-}
-
-void ConvertToString::visit(const NumberValue *)
-{
-    _result = _engine->stringValue();
-}
-
-void ConvertToString::visit(const BooleanValue *)
-{
-    _result = _engine->stringValue();
-}
-
-void ConvertToString::visit(const StringValue *value)
-{
-    _result = value;
-}
-
-void ConvertToString::visit(const ObjectValue *object)
-{
-    if (const FunctionValue *toStringMember = value_cast<const FunctionValue *>(object->lookup("toString"))) {
-        _result = value_cast<const StringValue *>(toStringMember->call(object)); // ### invoke convert-to-string?
-    }
-}
-
-void ConvertToString::visit(const FunctionValue *object)
-{
-    if (const FunctionValue *toStringMember = value_cast<const FunctionValue *>(object->lookup("toString"))) {
-        _result = value_cast<const StringValue *>(toStringMember->call(object)); // ### invoke convert-to-string?
-    }
-}
-- 
GitLab