[0.2.x] refactored : typeInfo class

git-svn-id: https://pykd.svn.codeplex.com/svn@78580 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\kernelnet_cp 2012-08-07 13:35:05 +00:00 committed by Mikhail I. Izmestev
parent 98ff37bb29
commit 91e158ea6a
2 changed files with 45 additions and 36 deletions

View File

@ -78,9 +78,28 @@ ULONG64 TypeInfo::getSymbolSize( const std::string &fullName )
TypeInfoPtr TypeInfo::getTypeInfo( SymbolPtr &typeSym ) TypeInfoPtr TypeInfo::getTypeInfo( SymbolPtr &typeSym )
{ {
const ULONG symTag = typeSym->getSymTag(); ULONG symTag = typeSym->getSymTag();
switch( symTag ) switch( symTag )
{ {
case SymTagData:
if ( typeSym->getLocType() == LocIsBitField )
{
return TypeInfoPtr( new BitFieldTypeInfo(typeSym) );
}
if ( typeSym->getDataKind() == DataIsConstant )
{
BaseTypeVariant constVal;
typeSym->getValue( constVal );
TypeInfoPtr ptr = getTypeInfo( typeSym->getType() );
ptr->setConstant( constVal );
return ptr;
}
return getTypeInfo( typeSym->getType() );
case SymTagBaseType: case SymTagBaseType:
return getBaseTypeInfo( typeSym ); return getBaseTypeInfo( typeSym );
@ -129,7 +148,28 @@ TypeInfoPtr TypeInfo::getTypeInfo( SymbolPtr &symScope, const std::string &symN
if ( basePtr != 0 ) if ( basePtr != 0 )
return basePtr; return basePtr;
return getTypeInfo( symScope, symScope->getChildByName( symName ) ); SymbolPtr symType = symScope->getChildByName( symName );
if ( symType->getSymTag() == SymTagData )
{
if ( symType->getLocType() == LocIsBitField )
{
return TypeInfoPtr( new BitFieldTypeInfo(symType) );
}
if ( symType->getDataKind() == DataIsConstant )
{
BaseTypeVariant constVal;
symType->getValue( constVal );
TypeInfoPtr ptr = getTypeInfo( symType->getType() );
ptr->setConstant( constVal );
return ptr;
}
symType = symType->getType();
}
return getTypeInfo( symType );
} }
return getComplexType( symScope, symName ); return getComplexType( symScope, symName );
@ -137,34 +177,6 @@ TypeInfoPtr TypeInfo::getTypeInfo( SymbolPtr &symScope, const std::string &symN
///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
TypeInfoPtr TypeInfo::getTypeInfo( SymbolPtr &symScope, SymbolPtr &symChild )
{
SymbolPtr symType = symChild;
if ( symType->getSymTag() == SymTagData )
{
if ( symType->getLocType() == LocIsBitField )
{
return TypeInfoPtr( new BitFieldTypeInfo(symType) );
}
if ( symType->getDataKind() == DataIsConstant )
{
BaseTypeVariant constVal;
symType->getValue( constVal );
TypeInfoPtr ptr = getTypeInfo( symType->getType() );
ptr->setConstant( constVal );
return ptr;
}
symType = symType->getType();
}
return getTypeInfo( symType );
}
/////////////////////////////////////////////////////////////////////////////////////
static const boost::regex baseMatch("^(Char)|(WChar)|(Int1B)|(UInt1B)|(Int2B)|(UInt2B)|(Int4B)|(UInt4B)|(Int8B)|(UInt8B)|(Long)|(ULong)|(Float)|(Bool)|(Double)$" ); static const boost::regex baseMatch("^(Char)|(WChar)|(Int1B)|(UInt1B)|(Int2B)|(UInt2B)|(Int4B)|(UInt4B)|(Int8B)|(UInt8B)|(Long)|(ULong)|(Float)|(Bool)|(Double)$" );
bool bool
@ -558,7 +570,7 @@ void UdtTypeInfo::getFields(
else else
if ( symTag == SymTagData ) if ( symTag == SymTagData )
{ {
TypeInfoPtr ti = TypeInfo::getTypeInfo( rootSym, childSym ); TypeInfoPtr ti = TypeInfo::getTypeInfo( childSym );
ULONG fieldOffset = 0; ULONG fieldOffset = 0;
switch ( childSym->getDataKind() ) switch ( childSym->getDataKind() )
@ -587,7 +599,7 @@ void UdtTypeInfo::getFields(
else else
if ( symTag == SymTagVTable ) if ( symTag == SymTagVTable )
{ {
TypeInfoPtr ti = TypeInfo::getTypeInfo( rootSym, childSym ); TypeInfoPtr ti = TypeInfo::getTypeInfo( childSym );
if ( baseVirtualSym ) if ( baseVirtualSym )
{ {

View File

@ -23,7 +23,7 @@ class TypeInfo : boost::noncopyable, public intBase, public boost::enable_shared
public: public:
static static
TypeInfoPtr getTypeInfoByName( const std::string &symName ); TypeInfoPtr getTypeInfoByName( const std::string &symName );
static static
ULONG64 getSymbolSize( const std::string &symName ); ULONG64 getSymbolSize( const std::string &symName );
@ -31,9 +31,6 @@ public:
static static
TypeInfoPtr getTypeInfo( SymbolPtr &symScope, const std::string &symName ); TypeInfoPtr getTypeInfo( SymbolPtr &symScope, const std::string &symName );
static
TypeInfoPtr getTypeInfo( SymbolPtr &symScope, SymbolPtr &symChild );
static static
TypeInfoPtr getTypeInfo( SymbolPtr &symbol ); TypeInfoPtr getTypeInfo( SymbolPtr &symbol );