OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / libs / qmljs / parser / qmljsnodepool_p.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
8 **
9 ** GNU Lesser General Public License Usage
10 **
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
14 ** Please review the following information to ensure the GNU Lesser General
15 ** Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 **
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 **
22 ** Other Usage
23 **
24 ** Alternatively, this file may be used in accordance with the terms and
25 ** conditions contained in a signed written agreement between you and Nokia.
26 **
27 ** If you have questions regarding the use of this file, please contact
28 ** Nokia at qt-info@nokia.com.
29 **
30 **************************************************************************/
31
32 #ifndef QMLJSNODEPOOL_P_H
33 #define QMLJSNODEPOOL_P_H
34
35 //
36 //  W A R N I N G
37 //  -------------
38 //
39 // This file is not part of the Qt API.  It exists purely as an
40 // implementation detail.  This header file may change from version to
41 // version without notice, or even be removed.
42 //
43 // We mean it.
44 //
45
46 #include "qmljsglobal_p.h"
47 #include "qmljsmemorypool_p.h"
48
49 #include <QtCore/QHash>
50 #include <QtCore/QString>
51
52 QT_QML_BEGIN_NAMESPACE
53
54 namespace QmlJS {
55
56 namespace AST {
57 class Node;
58 } // namespace AST
59
60 class Code;
61 class CompilationUnit;
62 class Engine;
63
64 template <typename NodeType>
65 inline NodeType *makeAstNode(MemoryPool *storage)
66 {
67     NodeType *node = new (storage->allocate(sizeof(NodeType))) NodeType();
68     return node;
69 }
70
71 template <typename NodeType, typename Arg1>
72 inline NodeType *makeAstNode(MemoryPool *storage, Arg1 arg1)
73 {
74     NodeType *node = new (storage->allocate(sizeof(NodeType))) NodeType(arg1);
75     return node;
76 }
77
78 template <typename NodeType, typename Arg1, typename Arg2>
79 inline NodeType *makeAstNode(MemoryPool *storage, Arg1 arg1, Arg2 arg2)
80 {
81     NodeType *node = new (storage->allocate(sizeof(NodeType))) NodeType(arg1, arg2);
82     return node;
83 }
84
85 template <typename NodeType, typename Arg1, typename Arg2, typename Arg3>
86 inline NodeType *makeAstNode(MemoryPool *storage, Arg1 arg1, Arg2 arg2, Arg3 arg3)
87 {
88     NodeType *node = new (storage->allocate(sizeof(NodeType))) NodeType(arg1, arg2, arg3);
89     return node;
90 }
91
92 template <typename NodeType, typename Arg1, typename Arg2, typename Arg3, typename Arg4>
93 inline NodeType *makeAstNode(MemoryPool *storage, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4)
94 {
95     NodeType *node = new (storage->allocate(sizeof(NodeType))) NodeType(arg1, arg2, arg3, arg4);
96     return node;
97 }
98
99 class QML_PARSER_EXPORT NodePool : public MemoryPool
100 {
101 public:
102     NodePool(const QString &fileName, Engine *engine);
103     virtual ~NodePool();
104
105     Code *createCompiledCode(AST::Node *node, CompilationUnit &compilation);
106
107     inline QString fileName() const { return m_fileName; }
108     inline Engine *engine() const { return m_engine; }
109 #ifndef J_SCRIPT_NO_EVENT_NOTIFY
110     inline qint64 id() const { return m_id; }
111 #endif
112
113 private:
114     QHash<AST::Node*, Code*> m_codeCache;
115     QString m_fileName;
116     Engine *m_engine;
117 #ifndef J_SCRIPT_NO_EVENT_NOTIFY
118     qint64 m_id;
119 #endif
120
121 private:
122     Q_DISABLE_COPY(NodePool)
123 };
124
125 } // namespace QmlJS
126
127 QT_QML_END_NAMESPACE
128
129 #endif