Don't hide errors in QDirIterator
[qt-netbsd.git] / src / script / qscriptasm_p.h
blob7d54d43be1c185ccfc41b3a70c0c35168aeec36c
1 /****************************************************************************
2 **
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: Nokia Corporation (qt-info@nokia.com)
5 **
6 ** This file is part of the QtScript module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** No Commercial Usage
10 ** This file contains pre-release code and may not be distributed.
11 ** You may use this file in accordance with the terms and conditions
12 ** contained in the either Technology Preview License Agreement or the
13 ** Beta Release License Agreement.
15 ** GNU Lesser General Public License Usage
16 ** Alternatively, this file may be used under the terms of the GNU Lesser
17 ** General Public License version 2.1 as published by the Free Software
18 ** Foundation and appearing in the file LICENSE.LGPL included in the
19 ** packaging of this file. Please review the following information to
20 ** ensure the GNU Lesser General Public License version 2.1 requirements
21 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23 ** In addition, as a special exception, Nokia gives you certain
24 ** additional rights. These rights are described in the Nokia Qt LGPL
25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26 ** package.
28 ** GNU General Public License Usage
29 ** Alternatively, this file may be used under the terms of the GNU
30 ** General Public License version 3.0 as published by the Free Software
31 ** Foundation and appearing in the file LICENSE.GPL included in the
32 ** packaging of this file. Please review the following information to
33 ** ensure the GNU General Public License version 3.0 requirements will be
34 ** met: http://www.gnu.org/copyleft/gpl.html.
36 ** If you are unsure which license is appropriate for your use, please
37 ** contact the sales department at http://www.qtsoftware.com/contact.
38 ** $QT_END_LICENSE$
40 ****************************************************************************/
42 #ifndef QSCRIPTASM_P_H
43 #define QSCRIPTASM_P_H
46 // W A R N I N G
47 // -------------
49 // This file is not part of the Qt API. It exists purely as an
50 // implementation detail. This header file may change from version to
51 // version without notice, or even be removed.
53 // We mean it.
56 #include <QtCore/qglobal.h>
58 #ifndef QT_NO_SCRIPT
60 #include <QtCore/qvector.h>
62 #include "qscriptvalueimplfwd_p.h"
64 QT_BEGIN_NAMESPACE
66 class QTextStream;
68 class QScriptInstruction
70 public:
71 enum Operator {
72 #define Q_SCRIPT_DEFINE_OPERATOR(op) OP_##op,
73 #include "instruction.table"
74 #undef Q_SCRIPT_DEFINE_OPERATOR
75 OP_Dummy
78 public:
79 Operator op;
80 QScriptValueImpl operand[2];
81 #if defined(Q_SCRIPT_DIRECT_CODE)
82 void *code;
83 #endif
85 void print(QTextStream &out) const;
87 static const char *opcode[];
90 namespace QScript {
92 class NodePool;
94 class ExceptionHandlerDescriptor
96 public:
97 ExceptionHandlerDescriptor()
98 : m_startInstruction(0),
99 m_endInstruction(0),
100 m_handlerInstruction(0) {}
102 ExceptionHandlerDescriptor(
103 int startInstruction,
104 int endInstruction,
105 int handlerInstruction)
106 : m_startInstruction(startInstruction),
107 m_endInstruction(endInstruction),
108 m_handlerInstruction(handlerInstruction) {}
110 inline int startInstruction() const { return m_startInstruction; }
111 inline int endInstruction() const { return m_endInstruction; }
112 inline int handlerInstruction() const { return m_handlerInstruction; }
114 private:
115 int m_startInstruction;
116 int m_endInstruction;
117 int m_handlerInstruction;
120 class CompilationUnit
122 public:
123 CompilationUnit(): m_valid(true),
124 m_errorLineNumber(-1) {}
126 bool isValid() const { return m_valid; }
128 void setError(const QString &message, int lineNumber)
130 m_errorMessage = message;
131 m_errorLineNumber = lineNumber;
132 m_valid = false;
135 QString errorMessage() const
136 { return m_errorMessage; }
137 int errorLineNumber() const
138 { return m_errorLineNumber; }
140 QVector<QScriptInstruction> instructions() const
141 { return m_instructions; }
142 void setInstructions(const QVector<QScriptInstruction> &instructions)
143 { m_instructions = instructions; }
145 QVector<ExceptionHandlerDescriptor> exceptionHandlers() const
146 { return m_exceptionHandlers; }
147 void setExceptionHandlers(const QVector<ExceptionHandlerDescriptor> &exceptionHandlers)
148 { m_exceptionHandlers = exceptionHandlers; }
150 private:
151 bool m_valid;
152 QString m_errorMessage;
153 int m_errorLineNumber;
154 QVector<QScriptInstruction> m_instructions;
155 QVector<ExceptionHandlerDescriptor> m_exceptionHandlers;
158 class Code
160 public:
161 Code();
162 ~Code();
164 void init(const CompilationUnit &compilation, NodePool *astPool);
166 public: // attributes
167 bool optimized;
168 QScriptInstruction *firstInstruction;
169 QScriptInstruction *lastInstruction;
170 QVector<ExceptionHandlerDescriptor> exceptionHandlers;
171 NodePool *astPool;
173 private:
174 Q_DISABLE_COPY(Code)
178 } // namespace QScript
180 QT_END_NAMESPACE
182 #endif // QT_NO_SCRIPT
183 #endif // QSCRIPTASM_P_H