1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
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.
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.
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.
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.
40 ****************************************************************************/
42 #include "private/qdeclarativeinstruction_p.h"
44 #include "private/qdeclarativecompiler_p.h"
46 #include <QtCore/qdebug.h>
50 void QDeclarativeCompiledData::dump(QDeclarativeInstruction *instr, int idx)
52 #ifdef QT_NO_DEBUG_STREAM
56 switch(instr->type()) {
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;
60 case QDeclarativeInstruction::Done:
61 qWarning().nospace() << idx << "\t\t" << "DONE";
63 case QDeclarativeInstruction::CreateObject:
64 qWarning().nospace() << idx << "\t\t" << "CREATE\t\t\t" << instr->create.type << "\t" << instr->create.bindingBits << "\t\t" << types.at(instr->create.type).className;
66 case QDeclarativeInstruction::CreateSimpleObject:
67 qWarning().nospace() << idx << "\t\t" << "CREATE_SIMPLE\t\t" << instr->createSimple.typeSize;
69 case QDeclarativeInstruction::SetId:
70 qWarning().nospace() << idx << "\t\t" << "SETID\t\t\t" << instr->setId.value << "\t\t\t" << primitives.at(instr->setId.value);
72 case QDeclarativeInstruction::SetDefault:
73 qWarning().nospace() << idx << "\t\t" << "SET_DEFAULT";
75 case QDeclarativeInstruction::CreateComponent:
76 qWarning().nospace() << idx << "\t\t" << "CREATE_COMPONENT\t" << instr->createComponent.count;
78 case QDeclarativeInstruction::StoreMetaObject:
79 qWarning().nospace() << idx << "\t\t" << "STORE_META\t\t" << instr->storeMeta.data;
81 case QDeclarativeInstruction::StoreFloat:
82 qWarning().nospace() << idx << "\t\t" << "STORE_FLOAT\t\t" << instr->storeFloat.propertyIndex << "\t" << instr->storeFloat.value;
84 case QDeclarativeInstruction::StoreDouble:
85 qWarning().nospace() << idx << "\t\t" << "STORE_DOUBLE\t\t" << instr->storeDouble.propertyIndex << "\t" << instr->storeDouble.value;
87 case QDeclarativeInstruction::StoreInteger:
88 qWarning().nospace() << idx << "\t\t" << "STORE_INTEGER\t\t" << instr->storeInteger.propertyIndex << "\t" << instr->storeInteger.value;
90 case QDeclarativeInstruction::StoreBool:
91 qWarning().nospace() << idx << "\t\t" << "STORE_BOOL\t\t" << instr->storeBool.propertyIndex << "\t" << instr->storeBool.value;
93 case QDeclarativeInstruction::StoreString:
94 qWarning().nospace() << idx << "\t\t" << "STORE_STRING\t\t" << instr->storeString.propertyIndex << "\t" << instr->storeString.value << "\t\t" << primitives.at(instr->storeString.value);
96 case QDeclarativeInstruction::StoreByteArray:
97 qWarning().nospace() << idx << "\t\t" << "STORE_BYTEARRAY" << instr->storeByteArray.propertyIndex << "\t" << instr->storeByteArray.value << "\t\t" << datas.at(instr->storeByteArray.value);
99 case QDeclarativeInstruction::StoreUrl:
100 qWarning().nospace() << idx << "\t\t" << "STORE_URL\t\t" << instr->storeUrl.propertyIndex << "\t" << instr->storeUrl.value << "\t\t" << urls.at(instr->storeUrl.value);
102 case QDeclarativeInstruction::StoreColor:
103 qWarning().nospace() << idx << "\t\t" << "STORE_COLOR\t\t" << instr->storeColor.propertyIndex << "\t\t\t" << QString::number(instr->storeColor.value, 16);
105 case QDeclarativeInstruction::StoreDate:
106 qWarning().nospace() << idx << "\t\t" << "STORE_DATE\t\t" << instr->storeDate.propertyIndex << "\t" << instr->storeDate.value;
108 case QDeclarativeInstruction::StoreTime:
109 qWarning().nospace() << idx << "\t\t" << "STORE_TIME\t\t" << instr->storeTime.propertyIndex;
111 case QDeclarativeInstruction::StoreDateTime:
112 qWarning().nospace() << idx << "\t\t" << "STORE_DATETIME\t\t" << instr->storeDateTime.propertyIndex;
114 case QDeclarativeInstruction::StorePoint:
115 qWarning().nospace() << idx << "\t\t" << "STORE_POINT\t\t" << instr->storePoint.propertyIndex << "\t" << instr->storePoint.point.xp << "\t" << instr->storePoint.point.yp;
117 case QDeclarativeInstruction::StorePointF:
118 qWarning().nospace() << idx << "\t\t" << "STORE_POINTF\t\t" << instr->storePointF.propertyIndex << "\t" << instr->storePointF.point.xp << "\t" << instr->storePointF.point.yp;
120 case QDeclarativeInstruction::StoreSize:
121 qWarning().nospace() << idx << "\t\t" << "STORE_SIZE\t\t" << instr->storeSize.propertyIndex << "\t" << instr->storeSize.size.wd << "\t" << instr->storeSize.size.ht;
123 case QDeclarativeInstruction::StoreSizeF:
124 qWarning().nospace() << idx << "\t\t" << "STORE_SIZEF\t\t" << instr->storeSizeF.propertyIndex << "\t" << instr->storeSizeF.size.wd << "\t" << instr->storeSizeF.size.ht;
126 case QDeclarativeInstruction::StoreRect:
127 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;
129 case QDeclarativeInstruction::StoreRectF:
130 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;
132 case QDeclarativeInstruction::StoreVector3D:
133 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;
135 case QDeclarativeInstruction::StoreVariant:
136 qWarning().nospace() << idx << "\t\t" << "STORE_VARIANT\t\t" << instr->storeString.propertyIndex << "\t" << instr->storeString.value << "\t\t" << primitives.at(instr->storeString.value);
138 case QDeclarativeInstruction::StoreVariantInteger:
139 qWarning().nospace() << idx << "\t\t" << "STORE_VARIANT_INTEGER\t\t" << instr->storeInteger.propertyIndex << "\t" << instr->storeInteger.value;
141 case QDeclarativeInstruction::StoreVariantDouble:
142 qWarning().nospace() << idx << "\t\t" << "STORE_VARIANT_DOUBLE\t\t" << instr->storeDouble.propertyIndex << "\t" << instr->storeDouble.value;
144 case QDeclarativeInstruction::StoreVariantBool:
145 qWarning().nospace() << idx << "\t\t" << "STORE_VARIANT_BOOL\t\t" << instr->storeBool.propertyIndex << "\t" << instr->storeBool.value;
147 case QDeclarativeInstruction::StoreObject:
148 qWarning().nospace() << idx << "\t\t" << "STORE_OBJECT\t\t" << instr->storeObject.propertyIndex;
150 case QDeclarativeInstruction::StoreVariantObject:
151 qWarning().nospace() << idx << "\t\t" << "STORE_VARIANT_OBJECT\t" << instr->storeObject.propertyIndex;
153 case QDeclarativeInstruction::StoreInterface:
154 qWarning().nospace() << idx << "\t\t" << "STORE_INTERFACE\t\t" << instr->storeObject.propertyIndex;
156 case QDeclarativeInstruction::StoreSignal:
157 qWarning().nospace() << idx << "\t\t" << "STORE_SIGNAL\t\t" << instr->storeSignal.signalIndex << "\t" << instr->storeSignal.value << "\t\t" << primitives.at(instr->storeSignal.value);
159 case QDeclarativeInstruction::StoreImportedScript:
160 qWarning().nospace() << idx << "\t\t" << "STORE_IMPORTED_SCRIPT\t" << instr->storeScript.value;
162 case QDeclarativeInstruction::StoreScriptString:
163 qWarning().nospace() << idx << "\t\t" << "STORE_SCRIPT_STRING\t" << instr->storeScriptString.propertyIndex << "\t" << instr->storeScriptString.value << "\t" << instr->storeScriptString.scope;
165 case QDeclarativeInstruction::AssignSignalObject:
166 qWarning().nospace() << idx << "\t\t" << "ASSIGN_SIGNAL_OBJECT\t" << instr->assignSignalObject.signal << "\t\t\t" << datas.at(instr->assignSignalObject.signal);
168 case QDeclarativeInstruction::AssignCustomType:
169 qWarning().nospace() << idx << "\t\t" << "ASSIGN_CUSTOMTYPE\t" << instr->assignCustomType.propertyIndex << "\t" << instr->assignCustomType.primitive << "\t" << instr->assignCustomType.type;
171 case QDeclarativeInstruction::StoreBinding:
172 qWarning().nospace() << idx << "\t\t" << "STORE_BINDING\t" << instr->assignBinding.property << "\t" << instr->assignBinding.value << "\t" << instr->assignBinding.context;
174 case QDeclarativeInstruction::StoreBindingOnAlias:
175 qWarning().nospace() << idx << "\t\t" << "STORE_BINDING_ALIAS\t" << instr->assignBinding.property << "\t" << instr->assignBinding.value << "\t" << instr->assignBinding.context;
177 case QDeclarativeInstruction::StoreCompiledBinding:
178 qWarning().nospace() << idx << "\t\t" << "STORE_COMPILED_BINDING\t" << instr->assignBinding.property << "\t" << instr->assignBinding.value << "\t" << instr->assignBinding.context;
180 case QDeclarativeInstruction::StoreValueSource:
181 qWarning().nospace() << idx << "\t\t" << "STORE_VALUE_SOURCE\t" << instr->assignValueSource.property << "\t" << instr->assignValueSource.castValue;
183 case QDeclarativeInstruction::StoreValueInterceptor:
184 qWarning().nospace() << idx << "\t\t" << "STORE_VALUE_INTERCEPTOR\t" << instr->assignValueInterceptor.property << "\t" << instr->assignValueInterceptor.castValue;
186 case QDeclarativeInstruction::BeginObject:
187 qWarning().nospace() << idx << "\t\t" << "BEGIN\t\t\t" << instr->begin.castValue;
189 case QDeclarativeInstruction::StoreObjectQList:
190 qWarning().nospace() << idx << "\t\t" << "STORE_OBJECT_QLIST";
192 case QDeclarativeInstruction::AssignObjectList:
193 qWarning().nospace() << idx << "\t\t" << "ASSIGN_OBJECT_LIST";
195 case QDeclarativeInstruction::FetchAttached:
196 qWarning().nospace() << idx << "\t\t" << "FETCH_ATTACHED\t\t" << instr->fetchAttached.id;
198 case QDeclarativeInstruction::FetchQList:
199 qWarning().nospace() << idx << "\t\t" << "FETCH_QLIST\t\t" << instr->fetch.property;
201 case QDeclarativeInstruction::FetchObject:
202 qWarning().nospace() << idx << "\t\t" << "FETCH\t\t\t" << instr->fetch.property;
204 case QDeclarativeInstruction::FetchValueType:
205 qWarning().nospace() << idx << "\t\t" << "FETCH_VALUE\t\t" << instr->fetchValue.property << "\t" << instr->fetchValue.type << "\t" << instr->fetchValue.bindingSkipList;
207 case QDeclarativeInstruction::PopFetchedObject:
208 qWarning().nospace() << idx << "\t\t" << "POP";
210 case QDeclarativeInstruction::PopQList:
211 qWarning().nospace() << idx << "\t\t" << "POP_QLIST";
213 case QDeclarativeInstruction::PopValueType:
214 qWarning().nospace() << idx << "\t\t" << "POP_VALUE\t\t" << instr->fetchValue.property << "\t" << instr->fetchValue.type;
216 case QDeclarativeInstruction::Defer:
217 qWarning().nospace() << idx << "\t\t" << "DEFER" << "\t\t\t" << instr->defer.deferCount;
220 qWarning().nospace() << idx << "\t\t" << "XXX UNKNOWN INSTRUCTION" << "\t" << instr->type();
223 #endif // QT_NO_DEBUG_STREAM
226 int QDeclarativeInstruction::size() const
228 #define QML_RETURN_INSTR_SIZE(I, FMT) case I: return QDeclarativeInstructionMeta<(int)I>::Size;
229 switch (common.instructionType) {
230 FOR_EACH_QML_INSTR(QML_RETURN_INSTR_SIZE)
233 #undef QML_RETURN_INSTR_SIZE