Skip to content
Permalink
master
Go to file
 
 
Cannot retrieve contributors at this time
584 lines (481 sloc) 17.1 KB
// ðåàëèçàöèÿ èíòåðôåñà ðàáîòàþùåãî ñ ïåðåãðóçêîé è ïåðåêðûòèåì èìåí - Overload.cpp
#pragma warning(disable: 4786)
#include <nrc.h>
using namespace NRC;
#include "Limits.h"
#include "Application.h"
#include "LexicalAnalyzer.h"
#include "Object.h"
#include "Scope.h"
#include "Class.h"
#include "Manager.h"
#include "Maker.h"
#include "Parser.h"
#include "Checker.h"
#include "Overload.h"
// ñðàâíèâàåò destID ñ òèïèçèðîâàííîé ñóùíîñòüþ è åñëè èõ òèïû íå ýêâèâàëåíòíû,
// âåðíóòü false. Ìåòîä ó÷èòûâàåò òèï âõîäíîãî ïàðàìåòðà. Íàïðèìåð ó
// ïàðàìåòðà ôóíêöèè íå ïðîâåðÿåòñÿ êîíñòàíòíîñòü è throw-ñïåöèôèêàöèÿ.
// Ñëåäóåò ó÷åñòü, ÷òî ìåòîä íå ïðîâåðÿåò ñïåöèôèêàòîðû õðàíåíèÿ
bool RedeclaredChecker::DeclEqual( const TypyziedEntity &ob1, const TypyziedEntity &ob2 )
{
// 1. ïðîâåðÿåì áàçîâûå òèïû
const BaseType &bt1 = ob1.GetBaseType(),
&bt2 = ob2.GetBaseType();
// ïðîâåðÿåì ñíà÷àëà êîäû, âñå êîäû äîëæíû ñîâïàäàòü
if( bt1.GetBaseTypeCode() != bt2.GetBaseTypeCode() ||
bt1.GetSignModifier() != bt2.GetSignModifier() ||
bt1.GetSizeModifier() != bt2.GetSizeModifier() )
return false;
// åñëè òèïû îòíîñÿòñÿ ê ñîñòàâíûì òèïàì òàêèì êàê êëàññ èëè ïåðå÷èñëåíèå
// èõ óêàçàòåëè äîëæíû ñîâïàäàòü
BaseType::BT bc = bt1.GetBaseTypeCode();
if( bc == BaseType::BT_CLASS || bc == BaseType::BT_STRUCT ||
bc == BaseType::BT_UNION || bc == BaseType::BT_ENUM )
if( &bt1 != &bt2 )
return false;
// 2. ïðîâåðÿåì cv-êâàëèôèêàòîðû
if( ob1.IsConst() != ob2.IsConst() ||
ob1.IsVolatile() != ob2.IsVolatile() )
{
// ó ïàðàìåòðîâ, ìîæíî ïðîèãíîðèðîâàòü, åñëè
// êâàëèôèêàòîð îòíîñèòñÿ ê áàçîâîìó òèïó, íå ê ïðîèçâîäíîìó
if( ob1.IsParametr() && ob1.GetDerivedTypeList().IsEmpty() &&
ob2.IsParametr() && ob2.GetDerivedTypeList().IsEmpty() )
;
else
return false;
}
// 3. ïðîâåðÿåì ñïèñîê ïðîèçâîäíûõ òèïîâ
const DerivedTypeList &dtl1 = ob1.GetDerivedTypeList(),
&dtl2 = ob2.GetDerivedTypeList();
// 3à. ðàçìåðû ñïèñêîâ äîëæíû ñîâïàäàòü
if( dtl1.GetDerivedTypeCount() != dtl2.GetDerivedTypeCount() )
return false;
// ïðîõîäèì ïî âñåìó ñïèñêó ïðîâåðÿÿ êàæäûé ïðîèçâîäíûé òèï ïî îòäåëüíîñòè
for( int i = 0; i<dtl1.GetDerivedTypeCount(); i++ )
{
const DerivedType &dt1 = *dtl1.GetDerivedType(i),
&dt2 = *dtl2.GetDerivedType(i);
// åñëè êîäû ïðîèçâîäíûõ òèïîâ íå ðàâíû âûõîäèì
if( dt1.GetDerivedTypeCode() != dt2.GetDerivedTypeCode() )
return false;
// èíà÷å ïðîâåðÿåì ñåìàíòè÷åñêîå çíà÷åíèå ïðîèçâîäíîãî òèïà
DerivedType::DT dc1 = dt1.GetDerivedTypeCode(),
dc2 = dt2.GetDerivedTypeCode();
// åñëè ññûëêà, òî ïðîâåðÿòü íå÷åãî
if( dc1 == DerivedType::DT_REFERENCE )
;
// åñëè óêàçàòåëü, ïðîâåðèì êâàëèôèêàòîðû
else if( dc1 == DerivedType::DT_POINTER )
{
if( i == 0 && ob1.IsParametr() && ob2.IsParametr() )
continue;
if( ((const Pointer &)dt1).IsConst() != ((const Pointer &)dt2).IsConst() ||
((const Pointer &)dt1).IsVolatile() != ((const Pointer &)dt2).IsVolatile() )
return false;
}
// åñëè óêàçàòåëü íà ÷ëåí ïðîâåðèì êâàëèôèêàòîðû è êëàññ ê êîòîðîìó
// ïðèíàäëåæèò óêàçàòåëü
else if( dc1 == DerivedType::DT_POINTER_TO_MEMBER )
{
if( i == 0 && ob1.IsParametr() && ob2.IsParametr() )
continue;
const PointerToMember &ptm1 = static_cast<const PointerToMember &>(dt1),
&ptm2 = static_cast<const PointerToMember &>(dt2);
if( ptm1.IsConst() != ptm2.IsConst() ||
ptm1.IsVolatile() != ptm2.IsVolatile() ||
&ptm1.GetMemberClassType() != &ptm2.GetMemberClassType() )
return false;
}
// åñëè ìàññèâ, ïðîâåðèì ðàçìåðû äâóõ ìàññèâîâ
else if( dc1 == DerivedType::DT_ARRAY )
{
if( dt1.GetDerivedTypeSize() != dt2.GetDerivedTypeSize() )
return false;
}
// åñëè ïðîòîòèï ôóíêöèè, òî ïðèìåíèì äàííóþ ôóíêöèþ äëÿ êàæäîãî ïàðàìåòðà,
// à òàêæå ïðîâåðèì cv-êâàëèôèêàòîðû è throw-ñïåöèôèêàöèþ
else if( dc1 == DerivedType::DT_FUNCTION_PROTOTYPE )
{
const FunctionPrototype &fp1 = static_cast<const FunctionPrototype &>(dt1),
&fp2 = static_cast<const FunctionPrototype &>(dt2);
// êîëè÷åñòâî ïàðàìåòðîâ äîëæíî ñîâïàäàòü
const FunctionParametrList &fpl1 = fp1.GetParametrList(),
&fpl2 = fp2.GetParametrList();
if( fpl1.GetFunctionParametrCount() != fpl2.GetFunctionParametrCount() )
return false;
// ïðîâåðÿåì êàæäûé ïàðàìåòð â ñïèñêå íà ñîîòâåòñòâèå
for( int i = 0; i<fpl1.GetFunctionParametrCount(); i++ )
if( !DeclEqual(*fpl1[i], *fpl2[i]) )
return false;
// ïðîâåðÿåì cv-êâàëèôèêàòîðû
if( fp1.IsConst() != fp2.IsConst() ||
fp1.IsVolatile() != fp2.IsVolatile() )
return false;
// ïðîâåðÿåì throw-ñïåöèôèêàöèþ
if( !ob1.IsParametr() )
{
if( fp1.CanThrowExceptions() != fp2.CanThrowExceptions() )
return false;
// ïðîâåðÿåì ñïèñîê throw-òèïîâ
const FunctionThrowTypeList &ftt1 = fp1.GetThrowTypeList(),
&ftt2 = fp2.GetThrowTypeList();
// êîëè÷åñòâî äîëæíî áûòü ðàâíî
if( ftt1.GetThrowTypeCount() != ftt2.GetThrowTypeCount() )
return false;
// ïðîâåðÿåì êàæäûé òèï â ñïåöèôèêàöèè
for( i = 0; i<ftt1.GetThrowTypeCount(); i++ )
if( !DeclEqual(*ftt1[i], *ftt2[i]) )
return false;
}
}
// èíà÷å íåèçâåñòíûé êîä
else
INTERNAL("'RedeclaredChecker::DeclEqual' íåèçâåñòíûé êîä ïðîèçâîäíîãî òèïà");
}
return true;
}
// ïðîáåãàåò ïî ñïèñêó ðîëåé è ïûòàåòñÿ íàéòè ôóíêöèþ
// ñîâïàäàþùóþ ïî ïðîòîòèïó ñ èìåþùèéñÿ. Åñëè ôóíêöèÿ íàéäåíà, âîçâðàùàåòñÿ
// óêàçàòåëü íà íåå, èíà÷å NULL
const Function *RedeclaredChecker::FnMatch( ) const
{
INTERNAL_IF( !(destIDRole >= R_FUNCTION && destIDRole <= R_CONSTRUCTOR) );
const Function *rval = NULL;
const FunctionPrototype &fp1 = dynamic_cast<const FunctionPrototype &>(
*destID.GetDerivedTypeList().GetHeadDerivedType());
for( RoleList::const_iterator p = roleList.begin(); p != roleList.end(); p++ )
{
if( (*p).second != destIDRole )
continue;
// ïðîâåðÿåì ÷òîáû ïðîòîòèïû ôóíêöèé ñîâïàäàëè
const Function *cand = dynamic_cast<const Function *>((*p).first);
const FunctionPrototype &fp2 = cand->GetFunctionPrototype();
INTERNAL_IF( cand == NULL );
// îáúÿâëåíèå ïåðåãðóæåííûõ ôóíêöèé â ëîêàëüíîé îáëàñòè âèäèìîñòè,
// ñëåäóåò çàïðåòèòü èç-çà íåâåðíîé ãåíåðàöèè êîäà
if( (destIDRole == R_FUNCTION || destIDRole == R_OVERLOAD_OPERATOR) &&
(GetCurrentSymbolTable().IsFunctionSymbolTable() ||
GetCurrentSymbolTable().IsLocalSymbolTable()) )
theApp.Error(errPos,
"'%s' - îáúÿâëåíèå ëîêàëüíîé ïåðåãðóæåííîé ôóíêöèè íåâîçìîæíî",
cand->GetName().c_str());
// êîëè÷åñòâî ïàðàìåòðîâ äîëæíî ñîâïàäàòü
const FunctionParametrList &fpl1 = fp1.GetParametrList(),
&fpl2 = fp2.GetParametrList();
if( fpl1.GetFunctionParametrCount() != fpl2.GetFunctionParametrCount() )
continue;
// cv-êâàëèôèêàòîðû òàêæå äîëæíû ñîâïàäàòü
if( fp1.IsConst() != fp2.IsConst() || fp1.IsVolatile() != fp2.IsVolatile() )
continue;
// ïðîâåðÿåì êàæäûé ïàðàìåòð â ñïèñêå íà ñîîòâåòñòâèå
bool eq = true;
for( int i = 0; i<fpl1.GetFunctionParametrCount(); i++ )
if( !DeclEqual(*fpl1[i], *fpl2[i]) )
{
eq = false;
break;
}
// åñëè ñïèñêè ïàðàìåòðîâ ñîâïàëè ñëåäóåò ïîëíîñòüþ ïðîâåðèòü
// òèïû ôóíêöèé è ñïåöèôèêàòîðû õðàíåíèÿ
if( eq )
{
// ìîæåò áûòü òîëüêî îäíî ñîîòâ. ïåðåãðóæåííîé ôóíêöèè
if( rval != NULL )
INTERNAL( "íåñêîëüêî ñîîòâåòñòâèé ïåðåãðóæåííîé ôóíêöèè" );
rval = cand;
if( !DeclEqual( destID, *cand ) ||
(destID.IsFunction() &&
(cand->GetStorageSpecifier() !=
static_cast<const Function&>(destID).GetStorageSpecifier() ||
cand->GetCallingConvention() !=
static_cast<const Function&>(destID).GetCallingConvention()) ) )
theApp.Error( errPos,
"'%s' - íåñîîòâåòñòâèå òèïà ñ ïðåäûäóùåé äåêëàðàöèåé",
cand->GetName().c_str());
}
}
return rval;
}
// ïðîâåðèòü, âîçìîæíî ëè îáúÿâëåíèå ôóíêöèè èëè îáúåêòà â òåêóùåé
// îáëàñòè âèäèìîñòè. Åñëè íåâîçìîæíî óñòàíàâëèâàåò redeclared â false
void RedeclaredChecker::Check()
{
INTERNAL_IF( !(destIDRole >= R_OBJECT && destIDRole <= R_CONSTRUCTOR) );
bool isFn = destIDRole >= R_FUNCTION && destIDRole <= R_CONSTRUCTOR;
// â ïåðâóþ î÷åðåäü, åñëè ñïèñîê ðîëåé ïóñòîé, çíà÷èò íè÷åãî ïðîâåðÿòü
// íå íóæíî
if( roleList.empty() )
return;
// äàëåå ñëåäóåò ïðîâåðèòü ñïèñîê ðîëåé, ìû èãíîðèðóåì òå èìåíà,
// êîòîðûå ÿâëÿþòñÿ êëàññîì èëè ïåðå÷èñëåíèåì, à òàêæå òå êîòîðûå
// èìåþò êîä íàøåãî èäåíòèôèêàòîðà
for( RoleList::const_iterator p = roleList.begin(); p != roleList.end(); p++ )
{
if( (*p).second == R_CLASS_TYPE || (*p).second == R_UNION_CLASS_TYPE ||
(*p).second == R_ENUM_TYPE )
{
// ïðîâåðÿåì, åñëè îáúÿâëÿåòñÿ typedef, òî ýòî îøèáêà
if( destIDRole == R_OBJECT )
{
const ::Object *ob = dynamic_cast<const ::Object *>(&destID);
INTERNAL_IF( ob == NULL );
if( ob->GetStorageSpecifier() == ::Object::SS_TYPEDEF )
{
redeclared = true;
theApp.Error(errPos,
"'%s' - òèï óæå îáúÿâëåí", ob->GetQualifiedName().c_str());
return;
}
}
// èíà÷å èãíîðèðóåì òèï
continue;
}
// åñëè êîäû ñîâïàëè, ïðîâåðÿåì âîçìîæíîñòü ïåðåîïðåäåëåíèÿ
if( (*p).second == destIDRole )
{
// ñîîòâåòñòâèå ïåðåãðóæåííûõ ôóíêöèé ïðîâåðèì ïîçæå
if( isFn )
;
// èíà÷å åñëè îáúåêò, íåîáõîäèìî ÷òîáû îí áûë
// typedef èëè extern è òèïû ñîâïàäàëè
else
{
INTERNAL_IF( prevID != NULL );
prevID = (*p).first;
redeclared = true;
// åñëè ïîëó÷èëè äåéñòâèòåëüíûé îáúåêò, ïðîâåðèì âìåñòå ñî ñïåöèôèêàòîðàìè,
// èíà÷å ñðàâíèì òîëüêî òèïû
if( const ::Object *ob1 = dynamic_cast<const ::Object *>(&destID) )
{
const ::Object &ob2 = static_cast<const ::Object&>(*prevID);
::Object::SS ss1 = ob1 ? ob1->GetStorageSpecifier() : ::Object::SS_NONE,
ss2 = ob2.GetStorageSpecifier();
if( ob1->IsCLinkSpecification() != ob2.IsCLinkSpecification() )
goto err;
if( ss1 != ss2 )
{
// ïðîâåðÿåì, åñëè ñòàòè÷åñêèé ÷ëåí îïðåäåëÿåòñÿ
// â ãëîáàëüíîé îáëàñòè âèäèìîñòè
if( ss2 == ::Object::SS_STATIC && ob2.IsClassMember() &&
ss1 == ::Object::SS_NONE &&
!GetCurrentSymbolTable().IsClassSymbolTable() )
;
else if( ss2 != ::Object::SS_EXTERN && ss1 != ::Object::SS_NONE )
goto err;
if( !DeclEqual(destID, ob2) )
goto err;
}
else if( (ss1 != ::Object::SS_TYPEDEF && ss1 != ::Object::SS_EXTERN ) ||
!DeclEqual(destID, ob2) )
err:
theApp.Error(errPos,
"'%s' - óæå îáúÿâëåí",
ob2.GetQualifiedName().c_str());
}
// èíà÷å ñðàâíèì òîëüêî òèïû
else if( !DeclEqual(destID, static_cast<const ::Object&>(*prevID)) )
theApp.Error(errPos,
"'%s' - íå ñîâïàäåíèå òèïîâ ñ ïðåäûäóùåé äåêëàðàöèåé",
prevID->GetQualifiedName().c_str());
}
}
// â ïðîòèâíîì ñëó÷àå èìÿ óæå èñïîëüçóåòñÿ è ýòî ñ÷èòàåòñÿ îøèáêîé
else
{
theApp.Error(errPos,
"'%s' - èìÿ ïåðåîïðåäåëåíî", (*p).first->GetName().c_str());
prevID = (*p).first;
redeclared = true;
return ;
}
}
// åñëè ôóíêöèÿ, ñëåäóåò ïðîâåðèòü âîçìîæíîñòü åå îïðåäåëåíèÿ ñðåäè ïåðåãðóæåííûõ
// ôóíêöèé
if( isFn )
if( const Function *fn = FnMatch() )
{
prevID = fn;
redeclared = true;
}
}
// ôóíêöèÿ, èñïîëüçóåòñÿ äëÿ îïðåäåëåíèÿ ñåìàíòè÷åñêîé ãðóïïû èìåíè.
// Âî-ïåðâûõ, âñå êîäû â ñïèñêå, äîëæíû áûòü ðàâíû r, âî âòîðûõ,
// åñëè ïðàâèëî îäèí âåðíî, çíà÷èò êàæäûé óêàçàòåëü â ñïèñêå, äîëæåí
// áûòü ðàâåí ïåðâîìó óêàçàòåëþ â ñïèñêå.  ñëó÷àå åñëè îáà ïðàâèëà
// ðàâíû, âîçâðàùàåòñÿ èäåíòèôèêàòîð, èíà÷å - NULL
const Identifier *AmbiguityChecker::IsDestRole( Role r ) const
{
Identifier *rval = NULL;
if( rlist.empty() || rlist.front().second != r )
return NULL;
rval = rlist.front().first;
for( RoleList::const_iterator p = rlist.begin(); p != rlist.end(); p++ )
{
// åñëè ðîëè íå ñîâïàäàþò ëèáî óêàçàòåëè
if( (*p).second != r || (*p).first != rval )
{
// âûâîäèì ñîîáù. òîëüêî åñëè èäåíòèôèêàòîðû èç ðàçíûõ ÎÂ
if( diagnostic )
{
if( &(*p).first->GetSymbolTableEntry() != &rval->GetSymbolTableEntry() )
theApp.Error(errPos, "íåîäíîçíà÷íîñòü ìåæäó '%s' è '%s'",
rval->GetQualifiedName().c_str(), (*p).first->GetQualifiedName().c_str());
// âñå ðàâíî âîçâðàùàåì rval, ÷òîáû âûçûâàþùàÿ ôóíêöèÿ ìîãëà åãî
// ïðîàíàëèçèðîâàòü
return rval;
}
// èíà÷å 0
else
return NULL;
}
}
return rval;
}
// åñëè èìÿ ÿâëÿåòñÿ ñèíîíèìîì òèïà typedef, âåðíóòü óêàçàòåëü íà íåãî
const ::Object *AmbiguityChecker::IsTypedef( ) const
{
if( rlist.empty() )
return NULL;
Role r = (*rlist.begin()).second;
if( r != R_OBJECT && r != R_DATAMEMBER )
return NULL;
const ::Object *rval = static_cast<const ::Object *>(IsDestRole(r));
if( !rval || rval->GetStorageSpecifier() != ::Object::SS_TYPEDEF )
return NULL;
return rval;
}
// ïðîâåðèòü ÿâëÿåòñÿ ëè òèï ïåðå÷èñëåíèåì, åñëè ïàðàìåòð withOverload == true,
// òîãäà äîñòàòî÷íî, ÷òîáû ðîëü ïðèñóòñòâîâàëà â ñïèñêå, â ïðîòèâíîì ñëó÷àå,
// ðîëü äîëæíà áûòü îäíà
const EnumType *AmbiguityChecker::IsEnumType( bool withOverload ) const
{
if( withOverload )
{
// ñëåäóåò ïðîâåðèòü âåñü ñïèñîê, ò.ê. â ñïèñêå ìîæåò áûòü íåñêîëüêî
// òèïîâ, â ýòîì ñëó÷àå áóäåò íåîäíîçíà÷íîñòü è ñëåäóåò âåðíóòü NULL
EnumType *rval = NULL;
for( RoleList::const_iterator p = rlist.begin(); p != rlist.end(); p++ )
{
// ëþáîå èìÿ êðîìå îáúåêòà, ôóíêöèè, êîíñòàíòû ïåðå÷èñëåíèÿ,
// à òàêæå ïðîèçâîäíûõ îò íèõ, íå ìîæåò ñîñóùåñòâîâàòü ñ ïåðå÷èñëèìûì òèïîì.
// Ïðè÷åì äàæå åñëè îáúåêò îáúÿâëåí êàê typedef, ýòî íè÷åãî íå ìåíÿåò,
// ò.ê. êëþ÷ ïåðå÷èñëåíèÿ çàäàåòñÿ ÿâíî (ôëàã withOverload == true)
Role r = (*p).second;
if( r == R_OBJECT || r == R_DATAMEMBER || r == R_PARAMETR ||
r == R_ENUM_CONSTANT || r == R_CLASS_ENUM_CONSTANT ||
r == R_FUNCTION || r == R_METHOD )
continue;
else if( (*p).second == R_ENUM_TYPE )
{
if( rval == NULL )
rval = static_cast<EnumType *>( (*p).first );
// ïåðå÷èñëåíèå óæå çàäàíî. Åñëè èõ óêàçàòåëè ðàâíû,
// òàêîå ìîæåò ñëó÷èòñÿ ïðè íàñëåäîâàíèè èëè using,
// òîãäà ýòî íå ñ÷èòàåòñÿ íåîäíîçíà÷íîñòüþ
else if( rval == (*p).first )
continue;
// èíà÷å íåîäíîçíà÷íîñòü
else
{
if( diagnostic )
theApp.Error(errPos, "íåîäíîçíà÷íîñòü ìåæäó '%s' è '%s'",
rval->GetQualifiedName().c_str(),
(*p).first->GetQualifiedName().c_str());
// âîçâðàùàåì rval, ÷òîáû âûçûâàþùàÿ ôóíêöèÿ
// ìîãëà åãî ïðîàíàëèçèðîâàòü
return rval;
}
}
// â ïðîòèâíîì ñëó÷àå èìÿ íå ìîæåò ñîñóùåñòâîâàòü ñ ïåðå÷èñëèìûì
// òèïîì è íå ÿâëÿåòñÿ èì
else
return NULL;
}
return rval;
}
else
{
return static_cast<const EnumType *>( IsDestRole( R_ENUM_TYPE) );
}
}
// ïðîâåðèòü ÿâëÿåòñÿ ëè òèï êëàññîì, åñëè ïàðàìåòð withOverload == true,
// òîãäà äîñòàòî÷íî, ÷òîáû ðîëü ïðèñóòñòâîâàëà â ñïèñêå, â ïðîòèâíîì ñëó÷àå,
// ðîëü äîëæíà áûòü îäíà
const ClassType *AmbiguityChecker::IsClassType( bool withOverload ) const
{
if( withOverload )
{
// ñëåäóåò ïðîâåðèòü âåñü ñïèñîê, ò.ê. â ñïèñêå ìîæåò áûòü íåñêîëüêî
// òèïîâ, â ýòîì ñëó÷àå áóäåò íåîäíîçíà÷íîñòü è ñëåäóåò âåðíóòü NULL
ClassType *rval = NULL;
for( RoleList::const_iterator p = rlist.begin(); p != rlist.end(); p++ )
{
Role r = (*p).second;
if( r == R_OBJECT || r == R_DATAMEMBER || r == R_PARAMETR ||
r == R_ENUM_CONSTANT || r == R_CLASS_ENUM_CONSTANT ||
r == R_FUNCTION || r == R_METHOD )
continue;
else if( (*p).second == R_CLASS_TYPE ||
(*p).second == R_UNION_CLASS_TYPE )
{
if( rval == NULL )
rval = static_cast<ClassType *>( (*p).first );
else if( rval == (*p).first )
continue;
// èíà÷å íåîäíîçíà÷íîñòü
else
{
if( diagnostic )
theApp.Error(errPos, "íåîäíîçíà÷íîñòü ìåæäó '%s' è '%s'",
rval->GetQualifiedName().c_str(),
(*p).first->GetQualifiedName().c_str() );
return rval;
}
}
// â ïðîòèâíîì ñëó÷àå èìÿ íå ìîæåò ñîñóùåñòâîâàòü ñ ïåðå÷èñëèìûì
// òèïîì è íå ÿâëÿåòñÿ èì
else
return NULL;
}
return rval;
}
else
{
if( rlist.empty() ||
(rlist.front().second != R_CLASS_TYPE &&
rlist.front().second != R_UNION_CLASS_TYPE) )
return NULL;
return static_cast<const ClassType *>( IsDestRole(rlist.front().second) );
}
}
// ïðîèíñïåêòèðîâàòü èìÿ - ÿâëÿåòñÿ ëè îíî èìåíåì òèïà,
// ò.å. êëàññîì, ïåðå÷èñëåíèåì, òèïîì typedef, øàáëîííûì ïàðàìåòðîì òèïà.
// Åñëè ó èìåíè > 1 ðîëü, âåðíóòü false, ò.ê. èìÿ òèïà äîëæíî áûòü óíèêàëüíûì
// â ñâîåé îáëàñòè âèäèìîñòè, â ïðîòèâíîì ñëó÷àå îíî ïåðåêðûâàåòñÿ
const Identifier *AmbiguityChecker::IsTypeName( bool withOverload ) const
{
const Identifier *id = NULL;
// åñëè èìååì äåëî ñ øàáëîííûì ïàðàìåòðîì òèïà
if( IsDestRole(R_TEMPLATE_TYPE_PARAMETR) != NULL )
return (*rlist.begin()).first;
else if( (id = IsTypedef()) != NULL )
return id;
else if( (id = IsClassType( withOverload)) != NULL )
return id;
else if( (id = IsEnumType( withOverload)) != NULL )
return id;
// èíà÷å íå èìÿ òèïà
return NULL;
}
// åñëè èìÿ ÿâëÿåòñÿ øàáëîííûì êëàññîì
const TemplateClassType *AmbiguityChecker::IsTemplateClass( ) const
{
return static_cast<const TemplateClassType *>( IsDestRole( R_TEMPLATE_CLASS) );
}
// åñëè èìÿ ÿâëÿåòñÿ èìåíîâàííîé îáëàñòüþ âèäèìîñòè
const NameSpace *AmbiguityChecker::IsNameSpace( ) const
{
return static_cast<const NameSpace *>( IsDestRole(R_NAMESPACE) );
}
You can’t perform that action at this time.