Update to 5.0.0-beta1
[profile/ivi/qtdeclarative.git] / src / qml / qml / qqmlinstruction.cpp
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the QtQml module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
20 **
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
28 **
29 ** Other Usage
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #include "qqmlinstruction_p.h"
43
44 #include "qqmlcompiler_p.h"
45
46 #include <QtCore/qdebug.h>
47
48 QT_BEGIN_NAMESPACE
49
50 void QQmlCompiledData::dump(QQmlInstruction *instr, int idx)
51 {
52 #ifdef QT_NO_DEBUG_STREAM
53     Q_UNUSED(instr)
54     Q_UNUSED(idx)
55 #else
56     switch (instructionType(instr)) {
57     case QQmlInstruction::Init:
58         qWarning().nospace() << idx << "\t\t" << "INIT\t\t\t" << instr->init.bindingsSize << "\t" << instr->init.parserStatusSize << "\t" << instr->init.contextCache << "\t" << instr->init.compiledBinding;
59         break;
60     case QQmlInstruction::DeferInit:
61         qWarning().nospace() << idx << "\t\t" << "DEFER_INIT\t\t" << instr->deferInit.bindingsSize << "\t" << instr->deferInit.parserStatusSize;
62         break;
63     case QQmlInstruction::Done:
64         qWarning().nospace() << idx << "\t\t" << "DONE";
65         break;
66     case QQmlInstruction::CreateCppObject:
67         qWarning().nospace() << idx << "\t\t" << "CREATECPP\t\t\t" << instr->create.type;
68         break;
69     case QQmlInstruction::CreateQMLObject:
70         qWarning().nospace() << idx << "\t\t" << "CREATEQML\t\t\t" << instr->createQml.type << "\t" << instr->createQml.bindingBits;
71         break;
72     case QQmlInstruction::CompleteQMLObject:
73         qWarning().nospace() << idx << "\t\t" << "COMPLETEQML";
74         break;
75     case QQmlInstruction::CreateSimpleObject:
76         qWarning().nospace() << idx << "\t\t" << "CREATE_SIMPLE\t\t" << instr->createSimple.typeSize;
77         break;
78     case QQmlInstruction::SetId:
79         qWarning().nospace() << idx << "\t\t" << "SETID\t\t\t" << instr->setId.value << "\t\t\t" << primitives.at(instr->setId.value);
80         break;
81     case QQmlInstruction::SetDefault:
82         qWarning().nospace() << idx << "\t\t" << "SET_DEFAULT";
83         break;
84     case QQmlInstruction::CreateComponent:
85         qWarning().nospace() << idx << "\t\t" << "CREATE_COMPONENT\t" << instr->createComponent.count;
86         break;
87     case QQmlInstruction::StoreMetaObject:
88         qWarning().nospace() << idx << "\t\t" << "STORE_META\t\t";
89         break;
90     case QQmlInstruction::StoreFloat:
91         qWarning().nospace() << idx << "\t\t" << "STORE_FLOAT\t\t" << instr->storeFloat.propertyIndex << "\t" << instr->storeFloat.value;
92         break;
93     case QQmlInstruction::StoreDouble:
94         qWarning().nospace() << idx << "\t\t" << "STORE_DOUBLE\t\t" << instr->storeDouble.propertyIndex << "\t" << instr->storeDouble.value;
95         break;
96     case QQmlInstruction::StoreDoubleQList:
97         qWarning().nospace() << idx << "\t\t" << "STORE_DOUBLE_QLIST\t\t" << instr->storeDouble.propertyIndex << "\t" << instr->storeDouble.value;
98         break;
99     case QQmlInstruction::StoreInteger:
100         qWarning().nospace() << idx << "\t\t" << "STORE_INTEGER\t\t" << instr->storeInteger.propertyIndex << "\t" << instr->storeInteger.value;
101         break;
102     case QQmlInstruction::StoreIntegerQList:
103         qWarning().nospace() << idx << "\t\t" << "STORE_INTEGER_QLIST\t\t" << instr->storeInteger.propertyIndex << "\t" << instr->storeInteger.value;
104         break;
105     case QQmlInstruction::StoreBool:
106         qWarning().nospace() << idx << "\t\t" << "STORE_BOOL\t\t" << instr->storeBool.propertyIndex << "\t" << instr->storeBool.value;
107         break;
108     case QQmlInstruction::StoreBoolQList:
109         qWarning().nospace() << idx << "\t\t" << "STORE_BOOL_QLIST\t\t" << instr->storeBool.propertyIndex << "\t" << instr->storeBool.value;
110         break;
111     case QQmlInstruction::StoreString:
112         qWarning().nospace() << idx << "\t\t" << "STORE_STRING\t\t" << instr->storeString.propertyIndex << "\t" << instr->storeString.value << "\t\t" << primitives.at(instr->storeString.value);
113         break;
114     case QQmlInstruction::StoreStringList:
115         qWarning().nospace() << idx << "\t\t" << "STORE_STRINGLIST\t\t" << instr->storeString.propertyIndex << "\t" << instr->storeString.value << "\t\t" << primitives.at(instr->storeString.value);
116         break;
117     case QQmlInstruction::StoreStringQList:
118         qWarning().nospace() << idx << "\t\t" << "STORE_STRING_QLIST\t\t" << instr->storeString.propertyIndex << "\t" << instr->storeString.value << "\t\t" << primitives.at(instr->storeString.value);
119         break;
120     case QQmlInstruction::StoreTrString:
121         qWarning().nospace() << idx << "\t\t" << "STORE_TR_STRING\t" << instr->storeTrString.propertyIndex << "\t" << instr->storeTrString.context << "\t" << instr->storeTrString.text << "\t" << instr->storeTrString.comment << "\t" << instr->storeTrString.n;
122         break;
123     case QQmlInstruction::StoreTrIdString:
124         qWarning().nospace() << idx << "\t\t" << "STORE_TRID_STRING\t" << instr->storeTrIdString.propertyIndex << "\t" << instr->storeTrIdString.text << "\t" << instr->storeTrIdString.n;
125         break;
126     case QQmlInstruction::StoreByteArray:
127         qWarning().nospace() << idx << "\t\t" << "STORE_BYTEARRAY" << instr->storeByteArray.propertyIndex << "\t" << instr->storeByteArray.value << "\t\t" << datas.at(instr->storeByteArray.value);
128         break;
129     case QQmlInstruction::StoreUrl:
130         qWarning().nospace() << idx << "\t\t" << "STORE_URL\t\t" << instr->storeUrl.propertyIndex << "\t" << instr->storeUrl.value << "\t\t" << urls.at(instr->storeUrl.value);
131         break;
132     case QQmlInstruction::StoreUrlQList:
133         qWarning().nospace() << idx << "\t\t" << "STORE_URL_QLIST\t\t" << instr->storeUrl.propertyIndex << "\t" << instr->storeUrl.value << "\t\t" << urls.at(instr->storeUrl.value);
134         break;
135     case QQmlInstruction::StoreColor:
136         qWarning().nospace() << idx << "\t\t" << "STORE_COLOR\t\t" << instr->storeColor.propertyIndex << "\t\t\t" << QString::number(instr->storeColor.value, 16);
137         break;
138     case QQmlInstruction::StoreDate:
139         qWarning().nospace() << idx << "\t\t" << "STORE_DATE\t\t" << instr->storeDate.propertyIndex << "\t" << instr->storeDate.value;
140         break;
141     case QQmlInstruction::StoreTime:
142         qWarning().nospace() << idx << "\t\t" << "STORE_TIME\t\t" << instr->storeTime.propertyIndex;
143         break;
144     case QQmlInstruction::StoreDateTime:
145         qWarning().nospace() << idx << "\t\t" << "STORE_DATETIME\t\t" << instr->storeDateTime.propertyIndex;
146         break;
147     case QQmlInstruction::StorePoint:
148         qWarning().nospace() << idx << "\t\t" << "STORE_POINT\t\t" << instr->storePoint.propertyIndex << "\t" << instr->storePoint.point.xp << "\t" << instr->storePoint.point.yp;
149         break;
150     case QQmlInstruction::StorePointF:
151         qWarning().nospace() << idx << "\t\t" << "STORE_POINTF\t\t" << instr->storePointF.propertyIndex << "\t" << instr->storePointF.point.xp << "\t" << instr->storePointF.point.yp;
152         break;
153     case QQmlInstruction::StoreSize:
154         qWarning().nospace() << idx << "\t\t" << "STORE_SIZE\t\t" << instr->storeSize.propertyIndex << "\t" << instr->storeSize.size.wd << "\t" << instr->storeSize.size.ht;
155         break;
156     case QQmlInstruction::StoreSizeF:
157         qWarning().nospace() << idx << "\t\t" << "STORE_SIZEF\t\t" << instr->storeSizeF.propertyIndex << "\t" << instr->storeSizeF.size.wd << "\t" << instr->storeSizeF.size.ht;
158         break;
159     case QQmlInstruction::StoreRect:
160         qWarning().nospace() << idx << "\t\t" << "STORE_RECT\t\t" << instr->storeRect.propertyIndex << "\t" << instr->storeRect.rect.x1 << "\t" << instr->storeRect.rect.y1 << "\t" << instr->storeRect.rect.x2 << "\t" << instr->storeRect.rect.y2;
161         break;
162     case QQmlInstruction::StoreRectF:
163         qWarning().nospace() << idx << "\t\t" << "STORE_RECTF\t\t" << instr->storeRectF.propertyIndex << "\t" << instr->storeRectF.rect.xp << "\t" << instr->storeRectF.rect.yp << "\t" << instr->storeRectF.rect.w << "\t" << instr->storeRectF.rect.h;
164         break;
165     case QQmlInstruction::StoreVector3D:
166         qWarning().nospace() << idx << "\t\t" << "STORE_VECTOR3D\t\t" << instr->storeVector3D.propertyIndex << "\t" << instr->storeVector3D.vector.xp << "\t" << instr->storeVector3D.vector.yp << "\t" << instr->storeVector3D.vector.zp;
167         break;
168     case QQmlInstruction::StoreVector4D:
169         qWarning().nospace() << idx << "\t\t" << "STORE_VECTOR4D\t\t" << instr->storeVector4D.propertyIndex << "\t" << instr->storeVector4D.vector.xp << "\t" << instr->storeVector4D.vector.yp << "\t" << instr->storeVector4D.vector.zp << "\t" << instr->storeVector4D.vector.wp;
170         break;
171     case QQmlInstruction::StoreVariant:
172         qWarning().nospace() << idx << "\t\t" << "STORE_VARIANT\t\t" << instr->storeString.propertyIndex << "\t" << instr->storeString.value << "\t\t" << primitives.at(instr->storeString.value);
173         break;
174     case QQmlInstruction::StoreVariantInteger:
175         qWarning().nospace() << idx << "\t\t" << "STORE_VARIANT_INTEGER\t\t" << instr->storeInteger.propertyIndex << "\t" << instr->storeInteger.value;
176         break;
177     case QQmlInstruction::StoreVariantDouble:
178         qWarning().nospace() << idx << "\t\t" << "STORE_VARIANT_DOUBLE\t\t" << instr->storeDouble.propertyIndex << "\t" << instr->storeDouble.value;
179         break;
180     case QQmlInstruction::StoreVariantBool:
181         qWarning().nospace() << idx << "\t\t" << "STORE_VARIANT_BOOL\t\t" << instr->storeBool.propertyIndex << "\t" << instr->storeBool.value;
182         break;
183     case QQmlInstruction::StoreVar:
184         qWarning().nospace() << idx << "\t\t" << "STORE_VAR\t\t" << instr->storeString.propertyIndex << "\t" << instr->storeString.value << "\t\t" << primitives.at(instr->storeString.value);
185         break;
186     case QQmlInstruction::StoreVarInteger:
187         qWarning().nospace() << idx << "\t\t" << "STORE_VAR_INTEGER\t" << instr->storeInteger.propertyIndex << "\t" << instr->storeInteger.value;
188         break;
189     case QQmlInstruction::StoreVarDouble:
190         qWarning().nospace() << idx << "\t\t" << "STORE_VAR_DOUBLE\t" << instr->storeDouble.propertyIndex << "\t" << instr->storeDouble.value;
191         break;
192     case QQmlInstruction::StoreVarBool:
193         qWarning().nospace() << idx << "\t\t" << "STORE_VAR_BOOL\t\t" << instr->storeBool.propertyIndex << "\t" << instr->storeBool.value;
194         break;
195     case QQmlInstruction::StoreObject:
196         qWarning().nospace() << idx << "\t\t" << "STORE_OBJECT\t\t" << instr->storeObject.propertyIndex;
197         break;
198     case QQmlInstruction::StoreVariantObject:
199         qWarning().nospace() << idx << "\t\t" << "STORE_VARIANT_OBJECT\t" << instr->storeObject.propertyIndex;
200         break;
201     case QQmlInstruction::StoreVarObject:
202         qWarning().nospace() << idx << "\t\t" << "STORE_VAR_OBJECT\t" << instr->storeObject.propertyIndex;
203         break;
204     case QQmlInstruction::StoreInterface:
205         qWarning().nospace() << idx << "\t\t" << "STORE_INTERFACE\t\t" << instr->storeObject.propertyIndex;
206         break;
207     case QQmlInstruction::StoreSignal:
208         qWarning().nospace() << idx << "\t\t" << "STORE_SIGNAL\t\t" << instr->storeSignal.signalIndex << "\t" << instr->storeSignal.value;
209         break;
210     case QQmlInstruction::StoreImportedScript:
211         qWarning().nospace() << idx << "\t\t" << "STORE_IMPORTED_SCRIPT\t" << instr->storeScript.value;
212         break;
213     case QQmlInstruction::StoreScriptString:
214         qWarning().nospace() << idx << "\t\t" << "STORE_SCRIPT_STRING\t" << instr->storeScriptString.propertyIndex << "\t" << instr->storeScriptString.value << "\t" << instr->storeScriptString.scope << "\t" << instr->storeScriptString.bindingId;
215         break;
216     case QQmlInstruction::AssignSignalObject:
217         qWarning().nospace() << idx << "\t\t" << "ASSIGN_SIGNAL_OBJECT\t" << instr->assignSignalObject.signal;
218         break;
219     case QQmlInstruction::AssignCustomType:
220         qWarning().nospace() << idx << "\t\t" << "ASSIGN_CUSTOMTYPE\t" << instr->assignCustomType.propertyIndex << "\t" << instr->assignCustomType.primitive << "\t" << instr->assignCustomType.type;
221         break;
222     case QQmlInstruction::InitV8Bindings:
223         qWarning().nospace() << idx << "\t\t" << "INIT_V8_BINDING\t" << instr->initV8Bindings.programIndex << "\t" << instr->initV8Bindings.line;
224         break;
225     case QQmlInstruction::StoreBinding:
226         qWarning().nospace() << idx << "\t\t" << "STORE_BINDING\t" << instr->assignBinding.property.coreIndex << "\t" << instr->assignBinding.value << "\t" << instr->assignBinding.context;
227         break;
228     case QQmlInstruction::StoreV4Binding:
229         qWarning().nospace() << idx << "\t\t" << "STORE_COMPILED_BINDING\t" << instr->assignV4Binding.property << "\t" << instr->assignV4Binding.value << "\t" << instr->assignV4Binding.context;
230         break;
231     case QQmlInstruction::StoreV8Binding:
232         qWarning().nospace() << idx << "\t\t" << "STORE_V8_BINDING\t" << instr->assignBinding.property.coreIndex << "\t" << instr->assignBinding.value << "\t" << instr->assignBinding.context;
233         break;
234     case QQmlInstruction::StoreValueSource:
235         qWarning().nospace() << idx << "\t\t" << "STORE_VALUE_SOURCE\t" << instr->assignValueSource.property.coreIndex << "\t" << instr->assignValueSource.castValue;
236         break;
237     case QQmlInstruction::StoreValueInterceptor:
238         qWarning().nospace() << idx << "\t\t" << "STORE_VALUE_INTERCEPTOR\t" << instr->assignValueInterceptor.property.coreIndex << "\t" << instr->assignValueInterceptor.castValue;
239         break;
240     case QQmlInstruction::BeginObject:
241         qWarning().nospace() << idx << "\t\t" << "BEGIN\t\t\t" << instr->begin.castValue;
242         break;
243     case QQmlInstruction::StoreObjectQList:
244         qWarning().nospace() << idx << "\t\t" << "STORE_OBJECT_QLIST";
245         break;
246     case QQmlInstruction::AssignObjectList:
247         qWarning().nospace() << idx << "\t\t" << "ASSIGN_OBJECT_LIST";
248         break;
249     case QQmlInstruction::FetchAttached:
250         qWarning().nospace() << idx << "\t\t" << "FETCH_ATTACHED\t\t" << instr->fetchAttached.id;
251         break;
252     case QQmlInstruction::FetchQList:
253         qWarning().nospace() << idx << "\t\t" << "FETCH_QLIST\t\t" << instr->fetch.property;
254         break;
255     case QQmlInstruction::FetchObject:
256         qWarning().nospace() << idx << "\t\t" << "FETCH\t\t\t" << instr->fetch.property;
257         break;
258     case QQmlInstruction::FetchValueType:
259         qWarning().nospace() << idx << "\t\t" << "FETCH_VALUE\t\t" << instr->fetchValue.property << "\t" << instr->fetchValue.type << "\t" << instr->fetchValue.bindingSkipList;
260         break;
261     case QQmlInstruction::PopFetchedObject:
262         qWarning().nospace() << idx << "\t\t" << "POP";
263         break;
264     case QQmlInstruction::PopQList:
265         qWarning().nospace() << idx << "\t\t" << "POP_QLIST";
266         break;
267     case QQmlInstruction::PopValueType:
268         qWarning().nospace() << idx << "\t\t" << "POP_VALUE\t\t" << instr->fetchValue.property << "\t" << instr->fetchValue.type;
269         break;
270     case QQmlInstruction::Defer:
271         qWarning().nospace() << idx << "\t\t" << "DEFER" << "\t\t\t" << instr->defer.deferCount;
272         break;
273     default:
274         qWarning().nospace() << idx << "\t\t" << "XXX UNKNOWN INSTRUCTION" << "\t" << instructionType(instr);
275         break;
276     }
277 #endif // QT_NO_DEBUG_STREAM
278 }
279
280 int QQmlInstruction::size(Type type)
281 {
282 #define QML_RETURN_INSTR_SIZE(I, FMT) case I: return QQmlInstructionMeta<(int)I>::Size;
283     switch (type) {
284     FOR_EACH_QML_INSTR(QML_RETURN_INSTR_SIZE)
285     default: return 0;
286     }
287 #undef QML_RETURN_INSTR_SIZE
288 }
289
290 QT_END_NAMESPACE