diff --git a/src/libs/qmljs/qmljsmetatypesystem.cpp b/src/libs/qmljs/qmljsmetatypesystem.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..03e39bc704f964e3a350012012f504e2e309322f
--- /dev/null
+++ b/src/libs/qmljs/qmljsmetatypesystem.cpp
@@ -0,0 +1,87 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://qt.nokia.com/contact.
+**
+**************************************************************************/
+
+#include "qmljsinterpreter.h"
+#include "qmljsmetatypesystem.h"
+
+#ifndef NO_DECLARATIVE_BACKEND
+#include <QtDeclarative/QmlType>
+#include <QtDeclarative/QmlMetaType>
+#endif // NO_DECLARATIVE_BACKEND
+
+using namespace QmlJS;
+using namespace QmlJS::Interpreter;
+
+void MetaTypeSystem::reload(Interpreter::Engine *interpreter)
+{
+    _importedTypes.clear();
+
+#ifndef NO_DECLARATIVE_BACKEND
+    foreach (QmlType *type, QmlMetaType::qmlTypes()) {
+        const QString fqType = type->qmlTypeName();
+        const int sepIdx = fqType.lastIndexOf(QLatin1Char('/'));
+        QString typeName;
+        QString package;
+        if (sepIdx == -1) {
+            typeName = fqType;
+        } else {
+            typeName = fqType.mid(sepIdx + 1);
+            package = fqType.left(sepIdx);
+        }
+
+        _importedTypes[package].append(interpreter->newQmlObject(typeName, package, type->majorVersion(), type->minorVersion()));
+    }
+}
+
+QList<QmlObjectValue *> MetaTypeSystem::staticTypesForImport(const QString &prefix, int majorVersion, int minorVersion) const
+{
+    QMap<QString, QmlObjectValue *> objectValuesByName;
+
+    foreach (QmlObjectValue *qmlObjectValue, _importedTypes[prefix]) {
+        if (qmlObjectValue->majorVersion() < majorVersion ||
+            (qmlObjectValue->majorVersion() == majorVersion && qmlObjectValue->minorVersion() <= minorVersion)) {
+            // we got a candidate.
+            const QString typeName = qmlObjectValue->qmlTypeName();
+            QmlObjectValue *previousCandidate = objectValuesByName.value(typeName, 0);
+            if (previousCandidate) {
+                // check if our new candidate is newer than the one we found previously
+                if (qmlObjectValue->majorVersion() > previousCandidate->majorVersion() ||
+                    (qmlObjectValue->majorVersion() == previousCandidate->majorVersion() && qmlObjectValue->minorVersion() > previousCandidate->minorVersion())) {
+                    // the new candidate has a higher version no. than the one we found previously, so replace it
+                    objectValuesByName.insert(typeName, qmlObjectValue);
+                }
+            } else {
+                objectValuesByName.insert(typeName, qmlObjectValue);
+            }
+        }
+    }
+
+    return objectValuesByName.values();
+#endif // NO_DECLARATIVE_BACKEND
+}
diff --git a/src/libs/qmljs/qmljsmetatypesystem.h b/src/libs/qmljs/qmljsmetatypesystem.h
new file mode 100644
index 0000000000000000000000000000000000000000..8f96a56d457c47f5f397d8e04c83e15237adcbd9
--- /dev/null
+++ b/src/libs/qmljs/qmljsmetatypesystem.h
@@ -0,0 +1,58 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://qt.nokia.com/contact.
+**
+**************************************************************************/
+
+#ifndef QMLJSMETATYPESYSTEM_H
+#define QMLJSMETATYPESYSTEM_H
+
+#include <QtCore/QHash>
+#include <QtCore/QString>
+
+namespace QmlJS {
+
+namespace Interpreter {
+    class Engine;
+    class QmlObjectValue;
+} // namespace Interpreter
+
+class MetaTypeSystem
+{
+public:
+    void reload(Interpreter::Engine *interpreter);
+
+#ifndef NO_DECLARATIVE_BACKEND
+    QList<Interpreter::QmlObjectValue *> staticTypesForImport(const QString &prefix, int majorVersion, int minorVersion) const;
+#endif // NO_DECLARATIVE_BACKEND
+
+private:
+    QHash<QString, QList<Interpreter::QmlObjectValue *> > _importedTypes;
+};
+
+} // namespace QmlJS
+
+#endif // QMLJSMETATYPESYSTEM_H