Primitive annotations for interpreter #11147
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
@[Primitive]
on top of methods that have bodies. This is useful because for exampleraise
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.@[Primitive]
on top of lib fun declarations. In the interpreter all of the functions defined in theIntrinsics
andLibM
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.