www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - runtime reflection issues

reply Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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



-----BEGIN PGP SIGNATURE-----

iD8DBQFFc0cqLK5blCcjpWoRArY+AJ9aXLNNnhf3fCw7rJ8qURfos6NkwgCeNGPl
ARCQldEJZIo9PgW7eKKeqko=
=XQnh
-----END PGP SIGNATURE-----
Dec 03 2006
parent Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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 -----BEGIN PGP SIGNATURE----- iD8DBQFFc0fiLK5blCcjpWoRAqpWAJ98Gshncw4SEAQNjWSbAVRPeO2VwwCbBHNa 6mohahfqL9JWpKYCBUyx1RI= =kg7V -----END PGP SIGNATURE-----
Dec 03 2006