10b7940fe3423cf1b2ce992b2ceeb7ebe75e8d98
[profile/ivi/qtdeclarative.git] / src / declarative / qml / qdeclarativeinstruction.cpp
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: http://www.qt-project.org/
6 **
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
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
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General 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 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
29 **
30 ** Other Usage
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #include "qdeclarativeinstruction_p.h"
43
44 #include "qdeclarativecompiler_p.h"
45
46 #include <QtCore/qdebug.h>
47
48 QT_BEGIN_NAMESPACE
49
50 void QDeclarativeCompiledData::dump(QDeclarativeInstruction *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 QDeclarativeInstruction::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 QDeclarativeInstruction::DeferInit:
61         qWarning().nospace() << idx << "\t\t" << "DEFER_INIT\t\t" << instr->deferInit.bindingsSize << "\t" << instr->deferInit.parserStatusSize;
62         break;
63     case QDeclarativeInstruction::Done:
64         qWarning().nospace() << idx << "\t\t" << "DONE";
65         break;
66     case QDeclarativeInstruction::CreateCppObject:
67         qWarning().nospace() << idx << "\t\t" << "CREATECPP\t\t\t" << instr->create.type << "\t\t\t" << types.at(instr->create.type).className;
68         break;
69     case QDeclarativeInstruction::CreateQMLObject:
70         qWarning().nospace() << idx << "\t\t" << "CREATEQML\t\t\t" << instr->createQml.type << "\t" << instr->createQml.bindingBits << "\t\t" << types.at(instr->createQml.type).className;
71         break;
72     case QDeclarativeInstruction::CompleteQMLObject:
73         qWarning().nospace() << idx << "\t\t" << "COMPLETEQML";
74         break;
75     case QDeclarativeInstruction::CreateSimpleObject:
76         qWarning().nospace() << idx << "\t\t" << "CREATE_SIMPLE\t\t" << instr->createSimple.typeSize;
77         break;
78     case QDeclarativeInstruction::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 QDeclarativeInstruction::SetDefault:
82         qWarning().nospace() << idx << "\t\t" << "SET_DEFAULT";
83         break;
84     case QDeclarativeInstruction::CreateComponent:
85         qWarning().nospace() << idx << "\t\t" << "CREATE_COMPONENT\t" << instr->createComponent.count;
86         break;
87     case QDeclarativeInstruction::StoreMetaObject:
88         qWarning().nospace() << idx << "\t\t" << "STORE_META\t\t" << instr->storeMeta.data;
89         break;
90     case QDeclarativeInstruction::StoreFloat:
91         qWarning().nospace() << idx << "\t\t" << "STORE_FLOAT\t\t" << instr->storeFloat.propertyIndex << "\t" << instr->storeFloat.value;
92         break;
93     case QDeclarativeInstruction::StoreDouble:
94         qWarning().nospace() << idx << "\t\t" << "STORE_DOUBLE\t\t" << instr->storeDouble.propertyIndex << "\t" << instr->storeDouble.value;
95         break;
96     case QDeclarativeInstruction::StoreDoubleQList:
97         qWarning().nospace() << idx << "\t\t" << "STORE_DOUBLE_QLIST\t\t" << instr->storeDouble.propertyIndex << "\t" << instr->storeDouble.value;
98         break;
99     case QDeclarativeInstruction::StoreInteger:
100         qWarning().nospace() << idx << "\t\t" << "STORE_INTEGER\t\t" << instr->storeInteger.propertyIndex << "\t" << instr->storeInteger.value;
101         break;
102     case QDeclarativeInstruction::StoreIntegerQList:
103         qWarning().nospace() << idx << "\t\t" << "STORE_INTEGER_QLIST\t\t" << instr->storeInteger.propertyIndex << "\t" << instr->storeInteger.value;
104         break;
105     case QDeclarativeInstruction::StoreBool:
106         qWarning().nospace() << idx << "\t\t" << "STORE_BOOL\t\t" << instr->storeBool.propertyIndex << "\t" << instr->storeBool.value;
107         break;
108     case QDeclarativeInstruction::StoreBoolQList:
109         qWarning().nospace() << idx << "\t\t" << "STORE_BOOL_QLIST\t\t" << instr->storeBool.propertyIndex << "\t" << instr->storeBool.value;
110         break;
111     case QDeclarativeInstruction::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 QDeclarativeInstruction::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 QDeclarativeInstruction::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 QDeclarativeInstruction::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 QDeclarativeInstruction::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 QDeclarativeInstruction::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 QDeclarativeInstruction::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 QDeclarativeInstruction::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 QDeclarativeInstruction::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 QDeclarativeInstruction::StoreDate:
139         qWarning().nospace() << idx << "\t\t" << "STORE_DATE\t\t" << instr->storeDate.propertyIndex << "\t" << instr->storeDate.value;
140         break;
141     case QDeclarativeInstruction::StoreTime:
142         qWarning().nospace() << idx << "\t\t" << "STORE_TIME\t\t" << instr->storeTime.propertyIndex;
143         break;
144     case QDeclarativeInstruction::StoreDateTime:
145         qWarning().nospace() << idx << "\t\t" << "STORE_DATETIME\t\t" << instr->storeDateTime.propertyIndex;
146         break;
147     case QDeclarativeInstruction::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 QDeclarativeInstruction::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 QDeclarativeInstruction::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 QDeclarativeInstruction::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 QDeclarativeInstruction::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 QDeclarativeInstruction::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 QDeclarativeInstruction::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 QDeclarativeInstruction::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 QDeclarativeInstruction::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 QDeclarativeInstruction::StoreVariantInteger:
175         qWarning().nospace() << idx << "\t\t" << "STORE_VARIANT_INTEGER\t\t" << instr->storeInteger.propertyIndex << "\t" << instr->storeInteger.value;
176         break;
177     case QDeclarativeInstruction::StoreVariantDouble:
178         qWarning().nospace() << idx << "\t\t" << "STORE_VARIANT_DOUBLE\t\t" << instr->storeDouble.propertyIndex << "\t" << instr->storeDouble.value;
179         break;
180     case QDeclarativeInstruction::StoreVariantBool:
181         qWarning().nospace() << idx << "\t\t" << "STORE_VARIANT_BOOL\t\t" << instr->storeBool.propertyIndex << "\t" << instr->storeBool.value;
182         break;
183     case QDeclarativeInstruction::StoreObject:
184         qWarning().nospace() << idx << "\t\t" << "STORE_OBJECT\t\t" << instr->storeObject.propertyIndex;
185         break;
186     case QDeclarativeInstruction::StoreVariantObject:
187         qWarning().nospace() << idx << "\t\t" << "STORE_VARIANT_OBJECT\t" << instr->storeObject.propertyIndex;
188         break;
189     case QDeclarativeInstruction::StoreInterface:
190         qWarning().nospace() << idx << "\t\t" << "STORE_INTERFACE\t\t" << instr->storeObject.propertyIndex;
191         break;
192     case QDeclarativeInstruction::StoreSignal:
193         qWarning().nospace() << idx << "\t\t" << "STORE_SIGNAL\t\t" << instr->storeSignal.signalIndex << "\t" << instr->storeSignal.value << "\t\t" << primitives.at(instr->storeSignal.value);
194         break;
195     case QDeclarativeInstruction::StoreImportedScript:
196         qWarning().nospace() << idx << "\t\t" << "STORE_IMPORTED_SCRIPT\t" << instr->storeScript.value;
197         break;
198     case QDeclarativeInstruction::StoreScriptString:
199         qWarning().nospace() << idx << "\t\t" << "STORE_SCRIPT_STRING\t" << instr->storeScriptString.propertyIndex << "\t" << instr->storeScriptString.value << "\t" << instr->storeScriptString.scope << "\t" << instr->storeScriptString.bindingId;
200         break;
201     case QDeclarativeInstruction::AssignSignalObject:
202         qWarning().nospace() << idx << "\t\t" << "ASSIGN_SIGNAL_OBJECT\t" << instr->assignSignalObject.signal << "\t\t\t" << primitives.at(instr->assignSignalObject.signal);
203         break;
204     case QDeclarativeInstruction::AssignCustomType:
205         qWarning().nospace() << idx << "\t\t" << "ASSIGN_CUSTOMTYPE\t" << instr->assignCustomType.propertyIndex << "\t" << instr->assignCustomType.primitive << "\t" << instr->assignCustomType.type;
206         break;
207     case QDeclarativeInstruction::InitV8Bindings:
208         qWarning().nospace() << idx << "\t\t" << "INIT_V8_BINDING\t" << instr->initV8Bindings.program << "\t" << instr->initV8Bindings.programIndex << "\t" << instr->initV8Bindings.line;
209         break;
210     case QDeclarativeInstruction::StoreBinding:
211         qWarning().nospace() << idx << "\t\t" << "STORE_BINDING\t" << instr->assignBinding.property.coreIndex << "\t" << instr->assignBinding.value << "\t" << instr->assignBinding.context;
212         break;
213     case QDeclarativeInstruction::StoreBindingOnAlias:
214         qWarning().nospace() << idx << "\t\t" << "STORE_BINDING_ALIAS\t" << instr->assignBinding.property.coreIndex << "\t" << instr->assignBinding.value << "\t" << instr->assignBinding.context;
215         break;
216     case QDeclarativeInstruction::StoreV4Binding:
217         qWarning().nospace() << idx << "\t\t" << "STORE_COMPILED_BINDING\t" << instr->assignV4Binding.property << "\t" << instr->assignV4Binding.value << "\t" << instr->assignV4Binding.context;
218         break;
219     case QDeclarativeInstruction::StoreV8Binding:
220         qWarning().nospace() << idx << "\t\t" << "STORE_V8_BINDING\t" << instr->assignBinding.property.coreIndex << "\t" << instr->assignBinding.value << "\t" << instr->assignBinding.context;
221         break;
222     case QDeclarativeInstruction::StoreValueSource:
223         qWarning().nospace() << idx << "\t\t" << "STORE_VALUE_SOURCE\t" << instr->assignValueSource.property.coreIndex << "\t" << instr->assignValueSource.castValue;
224         break;
225     case QDeclarativeInstruction::StoreValueInterceptor:
226         qWarning().nospace() << idx << "\t\t" << "STORE_VALUE_INTERCEPTOR\t" << instr->assignValueInterceptor.property.coreIndex << "\t" << instr->assignValueInterceptor.castValue;
227         break;
228     case QDeclarativeInstruction::BeginObject:
229         qWarning().nospace() << idx << "\t\t" << "BEGIN\t\t\t" << instr->begin.castValue;
230         break;
231     case QDeclarativeInstruction::StoreObjectQList:
232         qWarning().nospace() << idx << "\t\t" << "STORE_OBJECT_QLIST";
233         break;
234     case QDeclarativeInstruction::AssignObjectList:
235         qWarning().nospace() << idx << "\t\t" << "ASSIGN_OBJECT_LIST";
236         break;
237     case QDeclarativeInstruction::FetchAttached:
238         qWarning().nospace() << idx << "\t\t" << "FETCH_ATTACHED\t\t" << instr->fetchAttached.id;
239         break;
240     case QDeclarativeInstruction::FetchQList:
241         qWarning().nospace() << idx << "\t\t" << "FETCH_QLIST\t\t" << instr->fetch.property;
242         break;
243     case QDeclarativeInstruction::FetchObject:
244         qWarning().nospace() << idx << "\t\t" << "FETCH\t\t\t" << instr->fetch.property;
245         break;
246     case QDeclarativeInstruction::FetchValueType:
247         qWarning().nospace() << idx << "\t\t" << "FETCH_VALUE\t\t" << instr->fetchValue.property << "\t" << instr->fetchValue.type << "\t" << instr->fetchValue.bindingSkipList;
248         break;
249     case QDeclarativeInstruction::PopFetchedObject:
250         qWarning().nospace() << idx << "\t\t" << "POP";
251         break;
252     case QDeclarativeInstruction::PopQList:
253         qWarning().nospace() << idx << "\t\t" << "POP_QLIST";
254         break;
255     case QDeclarativeInstruction::PopValueType:
256         qWarning().nospace() << idx << "\t\t" << "POP_VALUE\t\t" << instr->fetchValue.property << "\t" << instr->fetchValue.type;
257         break;
258     case QDeclarativeInstruction::Defer:
259         qWarning().nospace() << idx << "\t\t" << "DEFER" << "\t\t\t" << instr->defer.deferCount;
260         break;
261     default:
262         qWarning().nospace() << idx << "\t\t" << "XXX UNKNOWN INSTRUCTION" << "\t" << instructionType(instr);
263         break;
264     }
265 #endif // QT_NO_DEBUG_STREAM
266 }
267
268 int QDeclarativeInstruction::size(Type type)
269 {
270 #define QML_RETURN_INSTR_SIZE(I, FMT) case I: return QDeclarativeInstructionMeta<(int)I>::Size;
271     switch (type) {
272     FOR_EACH_QML_INSTR(QML_RETURN_INSTR_SIZE)
273     default: return 0;
274     }
275 #undef QML_RETURN_INSTR_SIZE
276 }
277
278 QT_END_NAMESPACE