diff options
author | Roberto Raggi <roberto.raggi@nokia.com> | 2010-08-13 16:17:44 +0200 |
---|---|---|
committer | Roberto Raggi <roberto.raggi@nokia.com> | 2010-08-13 16:55:43 +0200 |
commit | 0540aa362de61c9ef19f3efb9e63839ac0b0e0be (patch) | |
tree | 7f9bf6c600f513a3673fc473511824b82911f2fc /src/shared/cplusplus/CheckName.cpp | |
parent | 6659e3ecba7279f933280ea3f07fcc0730476b64 (diff) | |
download | qt-creator-0540aa362de61c9ef19f3efb9e63839ac0b0e0be.tar.gz |
Get rid of the old Semantic pass.
Diffstat (limited to 'src/shared/cplusplus/CheckName.cpp')
-rw-r--r-- | src/shared/cplusplus/CheckName.cpp | 419 |
1 files changed, 0 insertions, 419 deletions
diff --git a/src/shared/cplusplus/CheckName.cpp b/src/shared/cplusplus/CheckName.cpp deleted file mode 100644 index 4e67a6124c..0000000000 --- a/src/shared/cplusplus/CheckName.cpp +++ /dev/null @@ -1,419 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ -// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com> -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#include "CheckName.h" -#include "Semantic.h" -#include "AST.h" -#include "Control.h" -#include "TranslationUnit.h" -#include "Literals.h" -#include "Names.h" -#include "CoreTypes.h" -#include "Symbols.h" -#include "Scope.h" -#include <cassert> - -using namespace CPlusPlus; - -CheckName::CheckName(Semantic *semantic) - : SemanticCheck(semantic), - _name(0), - _scope(0) -{ } - -CheckName::~CheckName() -{ } - -const Name *CheckName::check(NameAST *name, Scope *scope) -{ - const Name *previousName = switchName(0); - Scope *previousScope = switchScope(scope); - accept(name); - - if (_name && name) - name->name = _name; - - (void) switchScope(previousScope); - return switchName(previousName); -} - -const Name *CheckName::check(NestedNameSpecifierListAST *nested_name_specifier_list, Scope *scope) -{ - const Name *previousName = switchName(0); - Scope *previousScope = switchScope(scope); - - for (NestedNameSpecifierListAST *it = nested_name_specifier_list; it; it = it->next) { - NestedNameSpecifierAST *nested_name_specifier = it->value; - const Name *n = semantic()->check(nested_name_specifier->class_or_namespace_name, _scope); - if (! _name) - _name = n; - else - _name = control()->qualifiedNameId(_name, n); - } - - (void) switchScope(previousScope); - return switchName(previousName); -} - -void CheckName::check(ObjCMessageArgumentDeclarationAST *arg, Scope *scope) -{ - const Name *previousName = switchName(0); - Scope *previousScope = switchScope(scope); - - accept(arg); - - (void) switchScope(previousScope); - (void) switchName(previousName); -} - -const Name *CheckName::switchName(const Name *name) -{ - const Name *previousName = _name; - _name = name; - return previousName; -} - -Scope *CheckName::switchScope(Scope *scope) -{ - Scope *previousScope = _scope; - _scope = scope; - return previousScope; -} - -bool CheckName::visit(QualifiedNameAST *ast) -{ - for (NestedNameSpecifierListAST *it = ast->nested_name_specifier_list; it; it = it->next) { - NestedNameSpecifierAST *nested_name_specifier = it->value; - const Name *n = semantic()->check(nested_name_specifier->class_or_namespace_name, _scope); - if (_name || ast->global_scope_token) - _name = control()->qualifiedNameId(_name, n); - else - _name = n; - } - - const Name *n = semantic()->check(ast->unqualified_name, _scope); - if (_name || ast->global_scope_token) - _name = control()->qualifiedNameId(_name, n); - else - _name = n; - - ast->name = _name; - return false; -} - -bool CheckName::visit(OperatorFunctionIdAST *ast) -{ - assert(ast->op != 0); - - OperatorNameId::Kind kind = OperatorNameId::InvalidOp; - - switch (tokenKind(ast->op->op_token)) { - case T_NEW: - if (ast->op->open_token) - kind = OperatorNameId::NewArrayOp; - else - kind = OperatorNameId::NewOp; - break; - - case T_DELETE: - if (ast->op->open_token) - kind = OperatorNameId::DeleteArrayOp; - else - kind = OperatorNameId::DeleteOp; - break; - - case T_PLUS: - kind = OperatorNameId::PlusOp; - break; - - case T_MINUS: - kind = OperatorNameId::MinusOp; - break; - - case T_STAR: - kind = OperatorNameId::StarOp; - break; - - case T_SLASH: - kind = OperatorNameId::SlashOp; - break; - - case T_PERCENT: - kind = OperatorNameId::PercentOp; - break; - - case T_CARET: - kind = OperatorNameId::CaretOp; - break; - - case T_AMPER: - kind = OperatorNameId::AmpOp; - break; - - case T_PIPE: - kind = OperatorNameId::PipeOp; - break; - - case T_TILDE: - kind = OperatorNameId::TildeOp; - break; - - case T_EXCLAIM: - kind = OperatorNameId::ExclaimOp; - break; - - case T_EQUAL: - kind = OperatorNameId::EqualOp; - break; - - case T_LESS: - kind = OperatorNameId::LessOp; - break; - - case T_GREATER: - kind = OperatorNameId::GreaterOp; - break; - - case T_PLUS_EQUAL: - kind = OperatorNameId::PlusEqualOp; - break; - - case T_MINUS_EQUAL: - kind = OperatorNameId::MinusEqualOp; - break; - - case T_STAR_EQUAL: - kind = OperatorNameId::StarEqualOp; - break; - - case T_SLASH_EQUAL: - kind = OperatorNameId::SlashEqualOp; - break; - - case T_PERCENT_EQUAL: - kind = OperatorNameId::PercentEqualOp; - break; - - case T_CARET_EQUAL: - kind = OperatorNameId::CaretEqualOp; - break; - - case T_AMPER_EQUAL: - kind = OperatorNameId::AmpEqualOp; - break; - - case T_PIPE_EQUAL: - kind = OperatorNameId::PipeEqualOp; - break; - - case T_LESS_LESS: - kind = OperatorNameId::LessLessOp; - break; - - case T_GREATER_GREATER: - kind = OperatorNameId::GreaterGreaterOp; - break; - - case T_LESS_LESS_EQUAL: - kind = OperatorNameId::LessLessEqualOp; - break; - - case T_GREATER_GREATER_EQUAL: - kind = OperatorNameId::GreaterGreaterEqualOp; - break; - - case T_EQUAL_EQUAL: - kind = OperatorNameId::EqualEqualOp; - break; - - case T_EXCLAIM_EQUAL: - kind = OperatorNameId::ExclaimEqualOp; - break; - - case T_LESS_EQUAL: - kind = OperatorNameId::LessEqualOp; - break; - - case T_GREATER_EQUAL: - kind = OperatorNameId::GreaterEqualOp; - break; - - case T_AMPER_AMPER: - kind = OperatorNameId::AmpAmpOp; - break; - - case T_PIPE_PIPE: - kind = OperatorNameId::PipePipeOp; - break; - - case T_PLUS_PLUS: - kind = OperatorNameId::PlusPlusOp; - break; - - case T_MINUS_MINUS: - kind = OperatorNameId::MinusMinusOp; - break; - - case T_COMMA: - kind = OperatorNameId::CommaOp; - break; - - case T_ARROW_STAR: - kind = OperatorNameId::ArrowStarOp; - break; - - case T_ARROW: - kind = OperatorNameId::ArrowOp; - break; - - case T_LPAREN: - kind = OperatorNameId::FunctionCallOp; - break; - - case T_LBRACKET: - kind = OperatorNameId::ArrayAccessOp; - break; - - default: - kind = OperatorNameId::InvalidOp; - } // switch - - _name = control()->operatorNameId(kind); - ast->name = _name; - return false; -} - -bool CheckName::visit(ConversionFunctionIdAST *ast) -{ - FullySpecifiedType ty = semantic()->check(ast->type_specifier_list, _scope); - ty = semantic()->check(ast->ptr_operator_list, ty, _scope); - _name = control()->conversionNameId(ty); - return false; -} - -bool CheckName::visit(SimpleNameAST *ast) -{ - const Identifier *id = identifier(ast->identifier_token); - _name = control()->nameId(id); - ast->name = _name; - return false; -} - -bool CheckName::visit(DestructorNameAST *ast) -{ - const Identifier *id = identifier(ast->identifier_token); - _name = control()->destructorNameId(id); - ast->name = _name; - return false; -} - -bool CheckName::visit(TemplateIdAST *ast) -{ - const Identifier *id = identifier(ast->identifier_token); - std::vector<FullySpecifiedType> templateArguments; - for (ExpressionListAST *it = ast->template_argument_list; it; - it = it->next) { - ExpressionAST *arg = it->value; - FullySpecifiedType exprTy = semantic()->check(arg, _scope); - templateArguments.push_back(exprTy); - } - if (templateArguments.empty()) - _name = control()->templateNameId(id); - else - _name = control()->templateNameId(id, &templateArguments[0], - templateArguments.size()); - ast->name = _name; - return false; -} - -bool CheckName::visit(ObjCSelectorAST *ast) -{ - std::vector<const Name *> names; - bool hasArgs = false; - for (ObjCSelectorArgumentListAST *it = ast->selector_argument_list; it; it = it->next) { - if (it->value->name_token) { - const Identifier *id = control()->identifier(spell(it->value->name_token)); - const NameId *nameId = control()->nameId(id); - names.push_back(nameId); - - if (!hasArgs && it->value->colon_token) - hasArgs = true; - } else { - // we have an incomplete name due, probably due to error recovery. So, back out completely - return false; - } - } - - if (!names.empty()) { - _name = control()->selectorNameId(&names[0], names.size(), hasArgs); - ast->name = _name; - } - - return false; -} - -bool CheckName::visit(ObjCMessageArgumentDeclarationAST *ast) -{ - FullySpecifiedType type; - - if (ast->type_name && ast->type_name->type_id) - type = semantic()->check(ast->type_name->type_id, _scope); - - if (ast->param_name) { - accept(ast->param_name); - - Argument *arg = control()->newArgument(ast->param_name->firstToken(), - ast->param_name->name); - ast->argument = arg; - arg->setType(type); - arg->setInitializer(0); - _scope->addMember(arg); - } - - return false; -} |