/usr/lib/perl6/sources/FE7156F9200E802D3DB8FA628CF91AD6B020539B is in rakudo 2018.03-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | unit class NativeCall::Compiler::GNU;
use NativeCall::Types;
our sub mangle_cpp_symbol(Routine $r, $symbol) {
$r.signature.set_returns($r.package)
if $r.name eq 'new' && !$r.signature.has_returns && $r.package !~~ GLOBAL;
my $mangled = '_Z'
~ ($r.package.REPR eq 'CPPStruct' ?? 'N' !! '')
~ $symbol.split('::').map({$_ eq 'new' ?? 'C1' !! $_.chars ~ $_}).join('')
~ ($r.package.REPR eq 'CPPStruct' ?? 'E' !! '');
my @params = $r.signature.params;
if $r ~~ Method {
@params.shift;
@params.pop if @params.tail.name eq '%_';
}
my $params = join '', @params.map: {
my $R = $_.?cpp-ref ?? 'R' !! ''; # reference
my $P = .rw ?? 'P' !! ''; # pointer
my $K = ($R || $P) && $_.?cpp-const ?? 'K' !! ''; # const
cpp_param_letter(.type, :$R, :$P, :$K)
};
$mangled ~= $params || 'v';
}
sub cpp_param_letter($type, :$R = '', :$P = '', :$K = '') {
given $type {
when NativeCall::Types::void {
$R ~ $P ~ $K ~ 'v'
}
when Bool {
$R ~ $P ~ $K ~ 'b'
}
when int8 {
$R ~ $P ~ $K ~ 'c'
}
when uint8 {
$R ~ $P ~ $K ~ 'h'
}
when int16 {
$R ~ $P ~ $K ~ 's'
}
when uint16 {
$R ~ $P ~ $K ~ 't'
}
when int32 {
$R ~ $P ~ $K ~ 'i'
}
when uint32 {
$R ~ $P ~ $K ~ 'j'
}
when NativeCall::Types::long {
$R ~ $P ~ $K ~ 'l'
}
when NativeCall::Types::ulong {
$R ~ $P ~ $K ~ 'm'
}
when int64 {
$R ~ $P ~ $K ~ 'x'
}
when NativeCall::Types::longlong {
$R ~ $P ~ $K ~ 'x'
}
when uint64 {
$R ~ $P ~ $K ~ 'y'
}
when NativeCall::Types::ulonglong {
$R ~ $P ~ $K ~ 'y'
}
when num32 {
$R ~ $P ~ $K ~ 'f'
}
when num64 {
$R ~ $P ~ $K ~ 'd'
}
when Str {
'Pc'
}
when NativeCall::Types::CArray | NativeCall::Types::Pointer {
'P' ~ $K ~ cpp_param_letter(.of);
}
default {
my $name = .^name;
$R ~ $P ~ $K ~ $name.chars ~ $name;
}
}
}
|