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 ****************************************************************************/
31 _M_skipFunctionBody(false),
37 declareTypedef(findOrInsertName("__builtin_va_list",
38 strlen("__builtin_va_list")), 0);
45 Q_ASSERT(current_context
== 0);
48 Lexer
*Control::changeLexer(Lexer
*lexer
)
50 Lexer
*old
= _M_lexer
;
55 Parser
*Control::changeParser(Parser
*parser
)
57 Parser
*old
= _M_parser
;
62 Type
*Control::lookupType(const NameSymbol
*name
) const
64 Q_ASSERT(current_context
!= 0);
66 return current_context
->resolve(name
);
69 void Control::declare(const NameSymbol
*name
, Type
*type
)
71 //printf("*** Declare:");
74 Q_ASSERT(current_context
!= 0);
76 current_context
->bind(name
, type
);
79 void Control::pushContext()
81 // printf("+Context\n");
82 Context
*new_context
= new Context
;
83 new_context
->parent
= current_context
;
84 current_context
= new_context
;
87 void Control::popContext()
89 // printf("-Context\n");
90 Q_ASSERT(current_context
!= 0);
92 Context
*old_context
= current_context
;
93 current_context
= current_context
->parent
;
98 void Control::declareTypedef(const NameSymbol
*name
, Declarator
*d
)
100 // printf("declared typedef:");
101 // printSymbol(name);
103 stl_typedef_table
.insert(name
, d
);
106 bool Control::isTypedef(const NameSymbol
*name
) const
108 // printf("is typedef:");
109 // printSymbol(name);
110 // printf("= %d\n", (stl_typedef_table.find(name) != stl_typedef_table.end()));
112 return stl_typedef_table
.contains(name
);
115 QList
<Control::ErrorMessage
> Control::errorMessages () const
117 return _M_error_messages
;
120 void Control::clearErrorMessages ()
122 _M_error_messages
.clear ();
125 void Control::reportError (const ErrorMessage
&errmsg
)
127 _M_error_messages
.append(errmsg
);
130 // kate: space-indent on; indent-width 2; replace-tabs on;