Remove "All rights reserved" line from license headers.
[profile/ivi/qtdeclarative.git] / src / declarative / qml / parser / qdeclarativejsengine_p.cpp
index a449f77..534849c 100644 (file)
@@ -1,8 +1,7 @@
 /****************************************************************************
 **
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
 **
 ** This file is part of the QtDeclarative module of the Qt Toolkit.
 **
 **
 **
 **
+**
 ** $QT_END_LICENSE$
 **
 ****************************************************************************/
 
 #include "qdeclarativejsengine_p.h"
-
 #include "qdeclarativejsglobal_p.h"
-#include "qdeclarativejsnodepool_p.h"
 
 #include <qnumeric.h>
 #include <QHash>
+#include <QDebug>
 
 QT_QML_BEGIN_NAMESPACE
 
 namespace QDeclarativeJS {
 
-uint qHash(const QDeclarativeJS::NameId &id)
-{ return qHash(id.asString()); }
-
-QString numberToString(double value)
-{ return QString::number(value); }
-
-int Ecma::RegExp::flagFromChar(const QChar &ch)
-{
-    static QHash<QChar, int> flagsHash;
-    if (flagsHash.isEmpty()) {
-        flagsHash[QLatin1Char('g')] = Global;
-        flagsHash[QLatin1Char('i')] = IgnoreCase;
-        flagsHash[QLatin1Char('m')] = Multiline;
-    }
-    QHash<QChar, int>::const_iterator it;
-    it = flagsHash.constFind(ch);
-    if (it == flagsHash.constEnd())
-        return 0;
-    return it.value();
-}
-
-QString Ecma::RegExp::flagsToString(int flags)
-{
-    QString result;
-    if (flags & Global)
-        result += QLatin1Char('g');
-    if (flags & IgnoreCase)
-        result += QLatin1Char('i');
-    if (flags & Multiline)
-        result += QLatin1Char('m');
-    return result;
-}
-
-NodePool::NodePool(const QString &fileName, Engine *engine)
-    : m_fileName(fileName), m_engine(engine)
-{
-    m_engine->setNodePool(this);
-}
-
-NodePool::~NodePool()
-{
-}
-
-Code *NodePool::createCompiledCode(AST::Node *, CompilationUnit &)
-{
-    Q_ASSERT(0);
-    return 0;
-}
-
 static int toDigit(char c)
 {
     if ((c >= '0') && (c <= '9'))
@@ -172,14 +122,14 @@ double integerFromString(const QString &str, int radix)
 
 
 Engine::Engine()
-    : _lexer(0), _nodePool(0)
+    : _lexer(0)
 { }
 
 Engine::~Engine()
 { }
 
-QSet<NameId> Engine::literals() const
-{ return _literals; }
+void Engine::setCode(const QString &code)
+{ _code = code; }
 
 void Engine::addComment(int pos, int len, int line, int col)
 { if (len > 0) _comments.append(QDeclarativeJS::AST::SourceLocation(pos, len, line, col)); }
@@ -187,25 +137,24 @@ void Engine::addComment(int pos, int len, int line, int col)
 QList<QDeclarativeJS::AST::SourceLocation> Engine::comments() const
 { return _comments; }
 
-NameId *Engine::intern(const QChar *u, int s)
-{ return const_cast<NameId *>(&*_literals.insert(NameId(u, s))); }
-
-QString Engine::toString(NameId *id)
-{ return id->asString(); }
-
 Lexer *Engine::lexer() const
 { return _lexer; }
 
 void Engine::setLexer(Lexer *lexer)
 { _lexer = lexer; }
 
-NodePool *Engine::nodePool() const
-{ return _nodePool; }
-
-void Engine::setNodePool(NodePool *nodePool)
-{ _nodePool = nodePool; }
+MemoryPool *Engine::pool()
+{ return &_pool; }
 
+QStringRef Engine::newStringRef(const QString &text)
+{
+    const int pos = _extraCode.length();
+    _extraCode += text;
+    return _extraCode.midRef(pos, text.length());
+}
 
+QStringRef Engine::newStringRef(const QChar *chars, int size)
+{ return newStringRef(QString(chars, size)); }
 
 } // end of namespace QDeclarativeJS