December 03, 2006 runtime reflection issues | ||||
---|---|---|---|---|
| ||||
Attachments: | Below are the main issues I stumbled on when trying to implement runtime reflection for D. If anybody knows a solution I've been missing don't hesitate to say so. I'm only interested at module level types and functions, thus the non-remapped name mangling of nested symbols isn't an issue. 1) hidden this pointers Given a fully qualified class name I can find all member functions of that class and their type. However the member functions have no indication if they are static and require no this pointer or dynamic and require a this pointer. suggested solution: enhance the name mangling to include the this pointer 2) sizes of enums and enum initialisers There is currently no way to identify the name of an enum unless one finds a module level instance(the size can be determined via the size allocated in the binary). suggested solution: Provide a ...6__initZ symbol for enums even so they are only required for reflections purposes. 3) sizes of structs and unions The same problem as enums(see above). There is however another hint: Find the next symbol after the initialiser (...6__initZ). The difference between those two symbols is the maximum size of the struct. suggested solution: Fix the object code generation so that struct initialisers don't claim to be of size 0. 4) non-fullyqualified class names in ClassInfos Currently the ClassInfo's name isn't fullyqualified. e.g. "File" instead of "std.stream.File" While one can find the fully qualified name by querying the address of the ClassInfo, finding the symbol for that address and then demangling the symbol the process is needlessly complicated. suggested solution: Store the fully qualified name in ClassInfo.name. For the plain name simply use name[rfind(name, ".") .. $]; Thomas |
December 03, 2006 Re: runtime reflection issues | ||||
---|---|---|---|---|
| ||||
Posted in reply to Thomas Kuehne Attachments: | Thomas Kuehne schrieb am 2006-12-03:
> 2) sizes of enums and enum initialisers
> There is currently no way to identify the name of an enum unless one
> finds a module level instance(the size can be determined via the size
> allocated in the binary).
Should have been:
"There is currently no way to identify the size of"
Thomas
|
Copyright © 1999-2021 by the D Language Foundation