1
1
/****************************************************************************
3
3
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4
** All rights reserved.
4
5
** Contact: Nokia Corporation (qt-info@nokia.com)
6
7
** This file is part of the Qt Linguist of the Qt Toolkit.
8
9
** $QT_BEGIN_LICENSE:LGPL$
10
** Licensees holding valid Qt Commercial licenses may use this file in
11
** accordance with the Qt Commercial License Agreement provided with the
12
** Software or, alternatively, in accordance with the terms contained in
13
** a written agreement between you and Nokia.
10
** No Commercial Usage
11
** This file contains pre-release code and may not be distributed.
12
** You may use this file in accordance with the terms and conditions
13
** contained in the Technology Preview License Agreement accompanying
15
16
** GNU Lesser General Public License Usage
16
17
** Alternatively, this file may be used under the terms of the GNU Lesser
20
21
** ensure the GNU Lesser General Public License version 2.1 requirements
21
22
** 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.
24
** In addition, as a special exception, Nokia gives you certain additional
25
** rights. These rights are described in the Nokia Qt LGPL Exception
26
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28
** If you have questions regarding the use of this file, please contact
29
** Nokia at qt-info@nokia.com.
38
38
** $QT_END_LICENSE$
40
40
****************************************************************************/
60
60
// --------------- ProBlock ----------------
61
62
ProBlock::ProBlock(ProBlock *parent)
67
69
ProBlock::~ProBlock()
69
qDeleteAll(m_proitems);
71
foreach (ProItem *itm, m_proitems)
72
if (itm->kind() == BlockKind)
73
static_cast<ProBlock *>(itm)->deref();
72
78
void ProBlock::appendItem(ProItem *proitem)
109
115
return ProItem::BlockKind;
112
bool ProBlock::Accept(AbstractProItemVisitor *visitor)
118
ProItem::ProItemReturn ProBlock::Accept(AbstractProItemVisitor *visitor)
114
visitor->visitBeginProBlock(this);
115
foreach (ProItem *item, m_proitems) {
116
if (!item->Accept(visitor))
120
if (visitor->visitBeginProBlock(this) == ReturnSkip)
122
ProItemReturn rt = ReturnTrue;
123
for (int i = 0; i < m_proitems.count(); ++i) {
124
rt = m_proitems.at(i)->Accept(visitor);
125
if (rt != ReturnTrue && rt != ReturnFalse) {
126
if (rt == ReturnLoop) {
128
while (visitor->visitProLoopIteration())
129
for (int j = i; ++j < m_proitems.count(); ) {
130
rt = m_proitems.at(j)->Accept(visitor);
131
if (rt != ReturnTrue && rt != ReturnFalse) {
132
if (rt == ReturnNext) {
136
if (rt == ReturnBreak)
142
visitor->visitProLoopCleanup();
119
return visitor->visitEndProBlock(this);
147
visitor->visitEndProBlock(this);
122
151
// --------------- ProVariable ----------------
148
177
return m_variable;
151
bool ProVariable::Accept(AbstractProItemVisitor *visitor)
180
ProItem::ProItemReturn ProVariable::Accept(AbstractProItemVisitor *visitor)
153
182
visitor->visitBeginProVariable(this);
154
foreach (ProItem *item, m_proitems) {
155
if (!item->Accept(visitor))
158
return visitor->visitEndProVariable(this);
183
foreach (ProItem *item, m_proitems)
184
item->Accept(visitor); // cannot fail
185
visitor->visitEndProVariable(this);
161
189
// --------------- ProValue ----------------
190
218
return ProItem::ValueKind;
193
bool ProValue::Accept(AbstractProItemVisitor *visitor)
221
ProItem::ProItemReturn ProValue::Accept(AbstractProItemVisitor *visitor)
195
return visitor->visitProValue(this);
223
visitor->visitProValue(this);
198
227
// --------------- ProFunction ----------------
216
245
return ProItem::FunctionKind;
219
bool ProFunction::Accept(AbstractProItemVisitor *visitor)
248
ProItem::ProItemReturn ProFunction::Accept(AbstractProItemVisitor *visitor)
221
250
return visitor->visitProFunction(this);
242
271
return ProItem::ConditionKind;
245
bool ProCondition::Accept(AbstractProItemVisitor *visitor)
274
ProItem::ProItemReturn ProCondition::Accept(AbstractProItemVisitor *visitor)
247
return visitor->visitProCondition(this);
276
visitor->visitProCondition(this);
250
280
// --------------- ProOperator ----------------
268
298
return ProItem::OperatorKind;
271
bool ProOperator::Accept(AbstractProItemVisitor *visitor)
301
ProItem::ProItemReturn ProOperator::Accept(AbstractProItemVisitor *visitor)
273
return visitor->visitProOperator(this);
303
visitor->visitProOperator(this);
276
307
// --------------- ProFile ----------------
315
346
return m_modified;
318
bool ProFile::Accept(AbstractProItemVisitor *visitor)
349
ProItem::ProItemReturn ProFile::Accept(AbstractProItemVisitor *visitor)
320
visitor->visitBeginProFile(this);
321
foreach (ProItem *item, m_proitems) {
322
if (!item->Accept(visitor))
352
if ((rt = visitor->visitBeginProFile(this)) != ReturnTrue)
354
ProBlock::Accept(visitor); // cannot fail
325
355
return visitor->visitEndProFile(this);