1 /****************************************************************************
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: Nokia Corporation (qt-info@nokia.com)
6 ** This file is part of the QtScript module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
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
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.
40 ****************************************************************************/
42 #ifndef QSCRIPTASM_P_H
43 #define QSCRIPTASM_P_H
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.
56 #include <QtCore/qglobal.h>
60 #include <QtCore/qvector.h>
62 #include "qscriptvalueimplfwd_p.h"
68 class QScriptInstruction
72 #define Q_SCRIPT_DEFINE_OPERATOR(op) OP_##op,
73 #include "instruction.table"
74 #undef Q_SCRIPT_DEFINE_OPERATOR
80 QScriptValueImpl operand
[2];
81 #if defined(Q_SCRIPT_DIRECT_CODE)
85 void print(QTextStream
&out
) const;
87 static const char *opcode
[];
94 class ExceptionHandlerDescriptor
97 ExceptionHandlerDescriptor()
98 : m_startInstruction(0),
100 m_handlerInstruction(0) {}
102 ExceptionHandlerDescriptor(
103 int startInstruction
,
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
; }
115 int m_startInstruction
;
116 int m_endInstruction
;
117 int m_handlerInstruction
;
120 class CompilationUnit
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
;
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
; }
152 QString m_errorMessage
;
153 int m_errorLineNumber
;
154 QVector
<QScriptInstruction
> m_instructions
;
155 QVector
<ExceptionHandlerDescriptor
> m_exceptionHandlers
;
164 void init(const CompilationUnit
&compilation
, NodePool
*astPool
);
166 public: // attributes
168 QScriptInstruction
*firstInstruction
;
169 QScriptInstruction
*lastInstruction
;
170 QVector
<ExceptionHandlerDescriptor
> exceptionHandlers
;
178 } // namespace QScript
182 #endif // QT_NO_SCRIPT
183 #endif // QSCRIPTASM_P_H