📄 undname.cpp
字号:
// And return
return callType;
} // End of IF then
else
return DN_invalid;
} // End of IF then
else
return DN_truncated;
} // End of "UnDecorator" FUNCTION "getCallingConvention"
DName __near UnDecorator::getReturnType ( DName * pDeclarator )
{
if ( *gName == '@' ) // Return type for constructors and destructors ?
{
gName++;
return DName ( pDeclarator );
} // End of IF then
else
return getDataType ( pDeclarator );
} // End of "UnDecorator" FUNCTION "getReturnType"
DName __near UnDecorator::getDataType ( DName * pDeclarator )
{
DName superType ( pDeclarator );
// What type is it ?
switch ( *gName )
{
case 0:
return ( DN_truncated + superType );
case DT_void:
gName++;
if ( superType.isEmpty ())
return "void";
else
return "void " + superType;
case '?':
{
gName++; // Skip the '?'
superType = getDataIndirectType ( superType, 0, DName (), 0);
return getPrimaryDataType ( superType );
return superType;
} // End of CASE '?'
default:
return getPrimaryDataType ( superType );
} // End of SWITCH
} // End of "UnDecorator" FUNCTION "getDataType"
DName __near UnDecorator::getPrimaryDataType ( const DName & superType )
{
DName cvType;
switch ( *gName )
{
case 0:
return ( DN_truncated + superType );
case PDT_volatileReference:
cvType = "volatile";
if ( !superType.isEmpty ())
cvType += ' ';
// No break
case PDT_reference:
{
DName copyOfSuperType ( superType );
gName++;
return getReferenceType ( cvType, copyOfSuperType.setPtrRef ());
} // End of CASE 'PDT_reference'
case PDT_extend:
{
//
// Extended Primary Data Type (items overlooked in original design):
// prefixed by '$$'.
//
if ( gName[1] != PDT_extend )
if ( gName[1] == '\0' )
return DN_truncated + superType;
else
return DN_invalid;
gName += 2;
switch ( *gName )
{
case PDT_ex_function:
gName++;
return getFunctionIndirectType( superType );
case PDT_ex_other:
gName++;
return getPtrRefDataType( superType, /* isPtr = */ TRUE );
case PDT_ex_qualified:
gName++;
return(getBasicDataType(getDataIndirectType ( superType, 0, DName (), 0)));
case 0:
return ( DN_truncated + superType );
default:
return DN_invalid;
}
}
default:
return getBasicDataType ( superType );
} // End of SWITCH
} // End of "UnDecorator" FUNCTION "getPrimaryDataType"
DName __near UnDecorator::getArgumentTypes ( void )
{
switch ( *gName )
{
case AT_ellipsis:
return ( gName++, "..." );
case AT_void:
return ( gName++, "void" );
default:
{
DName arguments ( getArgumentList ());
// Now, is it a varargs function or not ?
if ( arguments.status () == DN_valid )
switch ( *gName )
{
case 0:
return arguments;
case AT_ellipsis:
return ( gName++, arguments + ",..." );
case AT_endoflist:
return ( gName++, arguments );
default:
return DN_invalid;
} // End of SWITCH
else
return arguments;
} // End of DEFAULT
} // End of SWITCH
} // End of "UnDecorator" FUNCTION "getArgumentTypes"
DName __near UnDecorator::getArgumentList ( void )
{
int first = TRUE;
DName aList;
while (( aList.status () == DN_valid ) && ( *gName != AT_endoflist ) && ( *gName != AT_ellipsis ))
{
// Insert the argument list separator if not the first argument
if ( first )
first = FALSE;
else
aList += ',';
// Get the individual argument type
if ( *gName )
{
int argIndex = *gName - '0';
// Handle 'argument-replicators', otherwise a new argument type
if (( argIndex >= 0 ) && ( argIndex <= 9 ))
{
gName++; // Skip past the replicator
// Append to the argument list
aList += ( *pArgList )[ argIndex ];
} // End of IF then
else
{
pcchar_t oldGName = gName;
// Extract the 'argument' type
DName arg ( getPrimaryDataType ( DName ()));
// Add it to the current list of 'argument's, if it is bigger than a one byte encoding
if ((( gName - oldGName ) > 1 ) && !pArgList->isFull ())
*pArgList += arg;
// Append to the argument list
aList += arg;
} // End of IF else
} // End of IF then
else
{
aList += DN_truncated;
break;
} // End of IF else
} // End of WHILE
// Return the completed argument list
return aList;
} // End of "UnDecorator" FUNCTION "getArgumentList"
DName __near UnDecorator::getThrowTypes ( void )
{
if ( *gName )
if ( *gName == AT_ellipsis ) // Handle ellipsis here to suppress the 'throw' signature
return ( gName++, DName ());
else
return ( " throw(" + getArgumentTypes () + ')' );
else
return ( DName ( " throw(" ) + DN_truncated + ')' );
} // End of "UnDecorator" FUNCTION "getThrowTypes"
DName __near UnDecorator::getBasicDataType ( const DName & superType )
{
if ( *gName )
{
unsigned char bdtCode = *gName++;
unsigned char extended_bdtCode;
int pCvCode = -1;
DName basicDataType;
// Extract the principal type information itself, and validate the codes
switch ( bdtCode )
{
case BDT_schar:
case BDT_char:
case ( BDT_char | BDT_unsigned ):
basicDataType = "char";
break;
case BDT_short:
case ( BDT_short | BDT_unsigned ):
basicDataType = "short";
break;
case BDT_int:
case ( BDT_int | BDT_unsigned ):
basicDataType = "int";
break;
case BDT_long:
case ( BDT_long | BDT_unsigned ):
basicDataType = "long";
break;
#if !VERS_32BIT
case BDT_segment:
basicDataType = UScore ( TOK_segment );
break;
#endif
case BDT_float:
basicDataType = "float";
break;
case BDT_longdouble:
basicDataType = "long ";
// No break
case BDT_double:
basicDataType += "double";
break;
case BDT_pointer:
case ( BDT_pointer | BDT_const ):
case ( BDT_pointer | BDT_volatile ):
case ( BDT_pointer | BDT_const | BDT_volatile ):
pCvCode = ( bdtCode & ( BDT_const | BDT_volatile ));
break;
case BDT_extend:
switch(extended_bdtCode = *gName++) {
case BDT_bool:
basicDataType = "bool";
break;
case BDT_int8:
case ( BDT_int8 | BDT_unsigned ):
basicDataType = "__int8";
break;
case BDT_int16:
case ( BDT_int16 | BDT_unsigned ):
basicDataType = "__int16";
break;
case BDT_int32:
case ( BDT_int32 | BDT_unsigned ):
basicDataType = "__int32";
break;
case BDT_int64:
case ( BDT_int64 | BDT_unsigned ):
basicDataType = "__int64";
break;
case BDT_int128:
case ( BDT_int128 | BDT_unsigned ):
basicDataType = "__int128";
break;
case BDT_wchar_t:
basicDataType = "wchar_t";
break;
#if CC_COR || CC_COR2
case BDT_coclass:
case BDT_interface:
{
gName--; // Backup, since 'ecsu-data-type' does it's own decoding
basicDataType = getECSUDataType();
if ( basicDataType.isEmpty()) {
return basicDataType;
}
}
break;
#endif // CC_COR || CC_COR2
default:
basicDataType = "UNKNOWN";
break;
}
break;
default:
gName--; // Backup, since 'ecsu-data-type' does it's own decoding
basicDataType = getECSUDataType ();
if ( basicDataType.isEmpty ())
return basicDataType;
break;
} // End of SWITCH
// What type of basic data type composition is involved ?
if ( pCvCode == -1 ) // Simple ?
{
// Determine the 'signed/unsigned'ness
switch ( bdtCode )
{
case ( BDT_char | BDT_unsigned ):
case ( BDT_short | BDT_unsigned ):
case ( BDT_int | BDT_unsigned ):
case ( BDT_long | BDT_unsigned ):
basicDataType = "unsigned " + basicDataType;
break;
case BDT_schar:
basicDataType = "signed " + basicDataType;
break;
case BDT_extend:
switch ( extended_bdtCode )
{
case ( BDT_int8 | BDT_unsigned ):
case ( BDT_int16 | BDT_unsigned ):
case ( BDT_int32 | BDT_unsigned ):
case ( BDT_int64 | BDT_unsigned ):
case ( BDT_int128 | BDT_unsigned ):
basicDataType = "unsigned " + basicDataType;
break;
} // End of SWITCH
break;
} // End of SWITCH
// Add the indirection type to the type
if ( !superType.isEmpty ())
basicDataType += ' ' + superType;
// And return the completed type
return basicDataType;
} // End of IF then
else
{
DName cvType;
DName copyOfSuperType ( superType );
// Is it 'const/volatile' qualified ?
if ( superType . isEmpty() )
{
//
// const/volatile are redundantly encoded, except at the start
// of a "type only" context. In such a context, the super-type
// is empty.
//
if ( pCvCode & BDT_const )
{
cvType = "const";
if ( pCvCode & BDT_volatile )
cvType += " volatile";
} // End of IF then
elif ( pCvCode & BDT_volatile )
cvType = "volatile";
} // End of IF then
// Construct the appropriate pointer type declaration
return getPointerType ( cvType, copyOfSuperType );
} // End of IF else
} // End of IF then
else
return ( DN_truncated + superType );
} // End of "UnDecorator" FUNCTION "getBasicDataType"
DName __near UnDecorator::getECSUDataType ( void )
{
// Extract the principal type information itself, and validate the codes
int fPrefix = doEcsu() && !doNameOnly();
DName Prefix;
switch ( *gName++ )
{
case 0:
gName--; // Backup to permit later error recovery to work safely
return "`unknown ecsu'" + DN_truncated;
case BDT_union:
Prefix = "union ";
break;
case BDT_struct:
Prefix = "struct ";
break;
case BDT_class:
Prefix = "class ";
break;
#if CC_COR || CC_COR2
case BDT_coclass:
Prefix = "coclass ";
break;
case BDT_interface:
Prefix = "interface ";
break;
#endif // CC_COR || CC_COR2
case BDT_enum:
fPrefix = doEcsu();
Prefix = "enum " + getEnumType ();
break;
// default:
// return DN_invalid;
} // End of SWITCH
DName ecsuDataType;
if ( fPrefix )
ecsuDataType = Prefix;
// Get the 'class/struct/union' name
ecsuDataType += getECSUName ();
// And return the formed 'ecsu-data-type'
return ecsuDataType;
} // End of "UnDecorator" FUNCTION "getECSUDataType"
//
// Undecorator::getFunctionIndirectType
//
// Note: this function gets both the function-indirect-type and the function-type.
//
DName UnDecorator::getFunctionIndirectType( const DName & superType )
{
if ( ! *gName )
return DN_truncated + superType;
if ( ! IT_isfunction( *gName ))
return DN_invalid;
int fitCode = *gName++ - '6';
if ( fitCode == ( '_' - '6' ))
{
if ( *gName )
{
fitCode = *gName++ - 'A' + FIT_based;
if (( fitCode < FIT_based ) || ( fitCode > ( FIT_based | FIT_far | FIT_member )))
fitCode = -1;
} // End of IF then
else
return ( DN_truncated + superType );
} // End of IF then
elif (( fitCode < FIT_near ) || ( fitCode > ( FIT_far | FIT_member )))
fitCode = -1;
// Return if invalid name
if ( fitCode == -1 )
return DN_invalid;
// Otherwise, what are the function indirect attributes
DName thisType;
DName fitType = superType;
// Is it a pointe
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -