Skip to content
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

Primitive annotations for interpreter #11147

Merged
merged 2 commits into from
Aug 28, 2021

Conversation

asterite
Copy link
Member

This PR extracts a couple of changes from #10910 so that later that PR has the last amount of changes to non-interpreted Crystal.

There are two changes here:

  1. Allowing @[Primitive] on top of methods that have bodies. This is useful because for example raise will be a primitive in the interpreter, and it's a bit cumbersome to define the signature twice, one with an empty body and a primitive annotation, and the other one without an annotation and a body. It's just simpler to conditionally mark a method as @[Primitive] for the interpreter.
  2. Allowing @[Primitive] on top of lib fun declarations. In the interpreter all of the functions defined in the Intrinsics and LibM libs need to be primitives, and this is never needed in compiled Crystal.

This PR doesn't affect compiled Crystal. Well, a user could use @[Primitive] somewhere, but there's really no reason to do that.

This is useful for the interpreter because we want to make some exisitng
methods be primitives, and it would be cumbersome to have to remove the
body just for this.
The interpreter needs to make some funs be primitives, for example the
ones in Instrinsics and LibM.
@asterite asterite added this to the 1.2.0 milestone Aug 28, 2021
@asterite asterite merged commit ccd271c into master Aug 28, 2021
@asterite asterite deleted the feature/primitive-annotations-for-interpreter branch August 28, 2021 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants