1 /****************************************************************************
3 ** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
4 ** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
6 ** This file is part of the Qt Script Generator project on Trolltech Labs.
8 ** This file may be used under the terms of the GNU General Public
9 ** License version 2.0 as published by the Free Software Foundation
10 ** and appearing in the file LICENSE.GPL included in the packaging of
11 ** this file. Please review the following information to ensure GNU
12 ** General Public Licensing requirements will be met:
13 ** http://www.trolltech.com/products/qt/opensource.html
15 ** If you are unsure which license is appropriate for your use, please
16 ** review the following information:
17 ** http://www.trolltech.com/products/qt/licensing.html or contact the
18 ** sales department at sales@trolltech.com.
20 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
21 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
23 ****************************************************************************/
25 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
28 #include "type_compiler.h"
29 #include "name_compiler.h"
35 #include <QtCore/QString>
37 TypeCompiler::TypeCompiler(Binder
*binder
)
38 : _M_binder (binder
), _M_token_stream(binder
->tokenStream ())
42 void TypeCompiler::run(TypeSpecifierAST
*node
)
51 const ListNode
<std::size_t> *it
= node
->cv
->toFront();
52 const ListNode
<std::size_t> *end
= it
;
55 int kind
= _M_token_stream
->kind(it
->element
);
56 if (! _M_cv
.contains(kind
))
65 void TypeCompiler::visitClassSpecifier(ClassSpecifierAST
*node
)
70 void TypeCompiler::visitEnumSpecifier(EnumSpecifierAST
*node
)
75 void TypeCompiler::visitElaboratedTypeSpecifier(ElaboratedTypeSpecifierAST
*node
)
80 void TypeCompiler::visitSimpleTypeSpecifier(SimpleTypeSpecifierAST
*node
)
82 if (const ListNode
<std::size_t> *it
= node
->integrals
)
85 const ListNode
<std::size_t> *end
= it
;
89 std::size_t token
= it
->element
;
90 current_item
+= token_name(_M_token_stream
->kind(token
));
95 _M_type
+= current_item
.trimmed();
97 else if (node
->type_of
)
100 _M_type
+= QLatin1String("typeof<...>");
106 void TypeCompiler::visitName(NameAST
*node
)
108 NameCompiler
name_cc(_M_binder
);
110 _M_type
= name_cc
.qualifiedName();
113 QStringList
TypeCompiler::cvString() const
117 foreach (int q
, cv())
119 if (q
== Token_const
)
120 lst
.append(QLatin1String("const"));
121 else if (q
== Token_volatile
)
122 lst
.append(QLatin1String("volatile"));
128 bool TypeCompiler::isConstant() const
130 return _M_cv
.contains(Token_const
);
133 bool TypeCompiler::isVolatile() const
135 return _M_cv
.contains(Token_volatile
);
138 // kate: space-indent on; indent-width 2; replace-tabs on;