I thought that all fb mangled names were c++ based.coderJeff wrote: ↑Jan 07, 2023 17:42 fxm, dodicat, neato. I think is good approach letting fbc handle the assignment as it would give consistent results for all arrays with normal user code (and unlike what I wrote, doesn't require some new procedure full of funky operations that have to be tested separately).
A couple of users have in the past asked for something that would deal with the type names:
- something like GetMangledTypeName( integer ptr ) that would return something like "INTEGER_PTR" that can be used as single token identifier for that type. Maybe something to try that could be added to `__fb_query_symbol__` thing (if we ever get back to it). Still kind of hack-ish but maybe still a slight improvement. idk.
For a sub(as integer ptr)
If you have g++ on path, my previous mangler
viz
Code: Select all
#inclib "stdc++"
declare function demangle cdecl alias "__cxa_demangle"(as zstring ptr,as zstring ptr=0,as long=0,byref as long=0) as zstring ptr
function getdemangledname(mn as string) as string
dim as long k
dim as string z=*demangle(mn,0,0,k)
print "Demangling: ";iif(len(z)=0,"Fail","OK")
select case k
case 0:print "The demangling operation succeeded."
case -1:print "A memory allocation failiure occurred."
case -2:print "mangled_name is not a valid name under the C++ ABI mangling rules."
case -3:print "One of the arguments is invalid."
end select
return z
end function
Function savefile(filename As String,p As String) As String
Dim As Long n=Freefile
If Open (filename For Binary Access Write As #n)=0 Then
Put #n,,p
Close
Else
Print "Unable to save " + filename:Sleep:End
End If
Return filename
End Function
Function loadfile(file As String) As String
Dim As Long f=Freefile
If Open (file For Binary Access Read As #f)=0 Then
Dim As String text
If Lof(f) > 0 Then
text = String(Lof(f), 0)
Get #f, , text
End If
Close #f
Return text
Else
Print file;" not found":Sleep:End
End If
End Function
function getmangledname(cppproc As String) as string
color 3
Kill "mangle.o"
savefile("mangle.cpp",cppproc)
Print " c++ function: "+chr(10);
color 15
Print loadfile("mangle.cpp")
color 3
Shell "g++ -c " +Curdir+ "\mangle.cpp "
Var f= loadfile("mangle.o")
Var m= Mid(f,Instr(f,"_Z"))
Var dist=Instr(m,Chr(0))
m=Mid(m,1,dist)
Print "From .o file, mangled name: ";
color 15
Print m
Kill "mangle.cpp"
Kill "mangle.o"
return m
End function
var m= getmangledname("void test(int*){};")
print
print getdemangledname(m)
sleep
Code: Select all
c++ function:
void test(int*){};
From .o file, mangled name: _Z4testPi
Demangling: OK
The demangling operation succeeded.
test(int*)
But it looks like you are looking for a non c++ mangled name parser.