support method
s with the VM backend
#775
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.
Summary
Enable dispatcher generation for the VM backend, which makes
method
(including multi-methods) available for the standalone VM target. Note
that this doesn't apply to compile-time execution, where using
method
sis still unsupported.
Details
chckNilDisp
compilerproc into thesystem
module andreplace the
== nil
withisNil
(more on that later)vmgne
when not in thestandalone
moderealType
procedure toroutineSignature
vmbackend
method
tests for the VM targetThe VM code generator (
vmgen
) previously checked for whether aprocedure returns something by testing for the presence of a procedure's
result
AST slot. For methods - where the AST always has aresult
slot, regardless of whether they have a return value - this test is
no longer enough, and is replaced with inspecting the return type.
Regarding the
== nil
->isNil
change: the VM comparison operator forpointer-like types (which
==
maps to) requires both operands to be ofsame dynamic type, but in
chckNilDisp
, this is not necessarily thecase (for example, when the dispatched-through type is a
ref
type).The proper solution would be for
cgmeth.genDispatcher
to wrap theargument in a
cast[pointer]
, but the VM doesn't yet support castingreferences to pointers.