/usr/lib/perl6/sources/2ACCA56EF5582D3ED623105F00BD76D7449263F7 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 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | unit class NativeCall::Compiler::MSVC;
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 = '?';
if $r ~~ Method {
$mangled ~= $symbol.split('::').reverse.map({$_ eq 'new' ?? '?0' !! "$_@"}).join('')
~ '@'
~ ($r.name eq 'new' ?? 'QE' !! 'UE');
}
else {
$mangled ~= $symbol.split('::').reverse.map({"$_@"}).join('')
~ '@'
~ 'Y'
~ 'A' # http://en.wikipedia.org/wiki/Visual_C%2B%2B_name_mangling#Function_Property
~ ($r.signature.has_returns ?? cpp_param_letter($r.returns) !! 'X');
}
my @params = $r.signature.params;
if $r ~~ Method {
@params.shift;
@params.pop if @params.tail.name eq '%_';
}
my $params = join '', @params.map: {
my $R = ''; # reference
my $P = .rw ?? 'PE' !! ''; # pointer
my $K = $P ?? ($_.?cpp-const ?? 'B' !! 'A') !! ''; # const
cpp_param_letter(.type, :$R, :$P, :$K)
};
if $r ~~ Method {
$mangled ~= 'AA';
$mangled ~= $r.signature.has_returns && $r.name ne 'new' ?? cpp_param_letter($r.returns) !! '';
$mangled ~= $params;
$mangled ~= '@' if $params || $r.name eq 'new';
$mangled ~= $params ?? 'Z' !! 'XZ';
}
else {
$mangled ~= $params || 'X';
$mangled ~= '@' if $r.package.REPR eq 'CPPStruct';
$mangled ~= 'Z';
}
$mangled
}
sub cpp_param_letter($type, :$R = '', :$P = '', :$K = '') {
given $type {
when NativeCall::Types::void {
$R ~ $K ~ 'X'
}
when Bool {
$R ~ $K ~ '_N'
}
when int8 {
$R ~ $K ~ 'D'
}
when uint8 {
$R ~ $K ~ 'E'
}
when int16 {
$R ~ $K ~ 'F'
}
when uint16 {
$R ~ $K ~ 'G'
}
when int32 {
$P ~ $K ~ 'H'
}
when uint32 {
$P ~ $K ~ 'I'
}
when NativeCall::Types::long {
$R ~ $K ~ 'J'
}
when NativeCall::Types::ulong {
$R ~ $K ~ 'K'
}
when int64 {
$R ~ '_J'
}
when NativeCall::Types::longlong {
$R ~ '_J'
}
when uint64 {
$R ~ '_K'
}
when NativeCall::Types::ulonglong {
$R ~ '_K'
}
when num32 {
$R ~ $K ~ 'M'
}
when num64 {
$R ~ $K ~ 'N'
}
when Str {
'PEAD'
}
when NativeCall::Types::CArray {
'QEA' ~ cpp_param_letter(.of);
}
when NativeCall::Types::Pointer {
'PEA' ~ cpp_param_letter(.of);
}
default {
my $name = .^name;
$P ~ $K ~ $name.chars ~ $name;
}
}
}
|