in src/main/abi-symbols/abi-dumper.pl [3321:3556]
sub formatName($$)
{ # type name correction
if(defined $Cache{"formatName"}{$_[1]}{$_[0]}) {
return $Cache{"formatName"}{$_[1]}{$_[0]};
}
my $N = $_[0];
if($_[1] ne "S")
{
$N=~s/\A[ ]+//g;
$N=~s/[ ]+\Z//g;
$N=~s/[ ]{2,}/ /g;
}
$N=~s/[ ]*(\W)[ ]*/$1/g; # std::basic_string<char> const
$N=~s/\b(const|volatile) ([\w\:]+)([\*&,>]|\Z)/$2 $1$3/g; # "const void" to "void const"
$N=~s/\bvolatile const\b/const volatile/g;
$N=~s/\b(long long|short|long) unsigned\b/unsigned $1/g;
$N=~s/\b(short|long) int\b/$1/g;
$N=~s/([\)\]])(const|volatile)\b/$1 $2/g;
while($N=~s/>>/> >/g) {};
if($_[1] eq "S")
{
if(index($N, "operator")!=-1) {
$N=~s/\b(operator[ ]*)> >/$1>>/;
}
}
$N=~s/,/, /g;
if(defined $LambdaSupport)
{ # struct {lambda()}
$N=~s/(\w)\{/$1 \{/g;
}
return ($Cache{"formatName"}{$_[1]}{$_[0]} = $N);
}
sub sepParams($)
{
my $Str = $_[0];
my @Parts = ();
my %B = ( "("=>0, "<"=>0, ")"=>0, ">"=>0 );
my $Part = 0;
foreach my $Pos (0 .. length($Str) - 1)
{
my $S = substr($Str, $Pos, 1);
if(defined $B{$S}) {
$B{$S} += 1;
}
if($S eq "," and
$B{"("}==$B{")"} and $B{"<"}==$B{">"}) {
$Part += 1;
}
else {
$Parts[$Part] .= $S;
}
}
# remove spaces
foreach (@Parts)
{
s/\A //g;
s/ \Z//g;
}
return @Parts;
}
sub initFuncType($$$)
{
my ($TInfo, $FTid, $Type) = @_;
$TInfo->{"Type"} = $Type;
if($TInfo->{"Return"} = $DWARF_Info{$FTid}{"type"}) {
getTypeInfo($TInfo->{"Return"});
}
else
{ # void
$TInfo->{"Return"} = "1";
}
delete($TInfo->{"BaseType"});
my @Prms = ();
my $PPos = 0;
foreach my $Pos (sort {$a<=>$b} keys(%{$FuncParam{$FTid}}))
{
my $ParamId = $FuncParam{$FTid}{$Pos};
my %PInfo = %{$DWARF_Info{$ParamId}};
if(defined $PInfo{"art"})
{ # this
next;
}
if(my $PTypeId = $PInfo{"type"})
{
$TInfo->{"Param"}{$PPos}{"type"} = $PTypeId;
getTypeInfo($PTypeId);
push(@Prms, $TypeInfo{$PTypeId}{"Name"});
}
$PPos += 1;
}
$TInfo->{"Name"} = $TypeInfo{$TInfo->{"Return"}}{"Name"};
if($Type eq "FuncPtr") {
$TInfo->{"Name"} .= "(*)";
}
$TInfo->{"Name"} .= "(".join(",", @Prms).")";
}
sub getShortName($)
{
my $Name = $_[0];
if(my $C = findCenter($Name, "<"))
{
return substr($Name, 0, $C);
}
return $Name;
}
sub getTKeys($)
{
my @TParams = @{$_[0]};
my @TKeys = ();
foreach my $Pos (0 .. $#TParams)
{
my $TRef = $TParams[$Pos];
if(defined $Compressed
and not defined $AllUnits)
{ # not all types are available in the current compile unit
# so handling them later
my $Key = undef;
if(defined $TRef->{"val"}) {
$Key = computeValue($TRef);
}
elsif(defined $TRef->{"name"}) {
$Key = $TRef->{"name"};
}
elsif(my $KeyT = $TRef->{"type"})
{
if(defined $TypeInfo{$KeyT}
and my $TN = $TypeInfo{$KeyT}{"Name"})
{
if(index($TN, "#")==-1) {
$Key = simpleName($TN);
}
else {
$Key = "T#".$KeyT;
}
}
else {
$Key = "T#".$KeyT;
}
}
push(@TKeys, $Key);
}
else
{
my $Key = undef;
if(defined $TRef->{"val"}) {
$Key = computeValue($TRef);
}
elsif(my $KeyT = $TRef->{"type"}) {
$Key = simpleName($TypeInfo{$KeyT}{"Name"});
}
else {
$Key = $TRef->{"name"};
}
push(@TKeys, $Key);
}
}
return @TKeys;
}
sub getTParams($$)
{
my ($ID, $Name) = @_;
my ($Short, $TParams) = ();
if(defined $TmplParam{$ID})
{
$Short = getShortName($Name);
$TParams = getTParams_I($ID);
my ($AddShort, $AddParam) = ();
foreach my $Pos (0 .. $#{$TParams})
{
my $P = $TParams->[$Pos];
if(not defined $P->{"val"}
and defined $P->{"type"})
{
my $TTid = $P->{"type"};
if(not defined $TypeInfo{$TTid}
or not $TypeInfo{$TTid}{"Name"})
{
if(not $AddParam) {
($AddShort, $AddParam) = parseTParams($Name);
}
if($Pos<=$#{$AddParam}) {
$P->{"name"} = $AddParam->[$Pos]{"name"};
}
}
}
}
}
else {
($Short, $TParams) = parseTParams($Name);
}
if(not $TParams) {
return ();
}
return ($Short, $TParams);
}