New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add support for Object.RTTypeid template #11459
base: master
Are you sure you want to change the base?
Conversation
Thanks for your pull request, @WalterBright! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + dmd#11459" |
So the call to toObjFile is planned to be removed? |
?? |
See also: dlang/druntime#3172. Need to fix the associative arrays first. |
Doesn't this completely obsolete RTInfo? It is currently just accessible through typeinfo and if typeinfo is itself a template, whatever we want from RTInfo can simply be done in here. |
@adamdruppe maybe they can be merged in the future. |
I modified it so if RTTypeid doesn't return a variable, it'll just use the old builtin method. This is so a partial implementation of RTTypeid can be developed. |
@WalterBright Thanks, that didn't work with: template RTTypeid(T)
if (is(T == int))
{
...
} I get a bunch of errors such as:
They suggest |
Even simpler to eliminate all possibilities of error: struct neverusedbyanyone {}
template RTTypeid(T)
if (is(T == neverusedbyanyone))
{
} causes the same errors |
Oh, even simpler: template RTTypeid(T)
if (false)
{
} This also causes errors. That's the simplest baseline. |
7bba5bd
to
f6f13ac
Compare
f6f13ac
to
b3cf6ce
Compare
src/dmd/frontend.h
Outdated
@@ -1249,6 +1249,7 @@ class Type : public ASTNode | |||
static ClassDeclaration* typeinfoshared; | |||
static ClassDeclaration* typeinfowild; | |||
static TemplateDeclaration* rtinfo; | |||
static TemplateDeclaration* rttypeid; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So basically until we can switch fully to the auto-generated headers, updates to the frontend header file are a strong indication that the old header files need to be manually updated as well.
71ab36b
to
8122a43
Compare
Currently, instances of TypeInfo are generated by a complex and tedious process inside the compiler. This change experiments with using a template in druntime, Object.RTTypeid instead, to generate it. The compiler will know nothing about the contents of TypeInfo, leaving people free to innovate with the definition of RTTypeid. (All that code in the compiler will be removed once RTTypeid is successful.)
This is analogous to the successful use of Object.RTinfo to generate info for the garbage collector. The implementation of RTTypeid is very similar for that for RTinfo, which can be found in Semantic3Visitor in semantic3.d
This PR makes it so that if Object.RTTypeid is not there, it falls back to the original compiler implementation of TypeInfo.