Skip to content

Commit 492fa91

Browse files
authored
Merge pull request #330 from JuliaGPU/tb/mangling
Name mangling fixes and improvements
2 parents 4662783 + 270f560 commit 492fa91

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/irgen.jl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@ end
109109
function mangle_param(t, substitutions)
110110
t == Nothing && return "v"
111111

112-
if isa(t, DataType) || isa(t, Core.Function)
112+
if isa(t, DataType) && t <: Ptr
113+
tn = mangle_param(eltype(t), substitutions)
114+
"P$tn"
115+
elseif isa(t, DataType) || isa(t, Core.Function)
113116
tn = safe_name(t)
114117

115118
# handle substitutions
@@ -134,9 +137,13 @@ function mangle_param(t, substitutions)
134137

135138
str
136139
elseif isa(t, Integer)
137-
"Li$(t)E"
140+
t > 0 ? "Li$(t)E" : "Lin$(abs(t))E"
138141
else
139-
tn = safe_name(t)
142+
tn = safe_name(t) # TODO: actually does support digits...
143+
if startswith(tn, r"\d")
144+
# C++ classes cannot start with a digit, so mangling doesn't support it
145+
tn = "_$(tn)"
146+
end
140147
"$(length(tn))$tn"
141148
end
142149
end

0 commit comments

Comments
 (0)