internal: use dedicated context type for vmbackend
#835
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
Add and use a dedicated type for the contextual state of the VM code-
generation orchestrator. This removes the hard coupling between
vmbackend
andvmdef.TCtx
and is another preparation for splitting upthe latter.
Details
The new
GenCtx
type replacesTCtx
as the contextual-state typefor the orchestrator. For now,
GenCtx
still stores an instance ofTCtx
, as the latter currently contains the code generator state.In preparation for splitting up
TCtx
, usage of itsidgen
andfunctions
fields are removed fromvmbackend.nim
. The ID generator isdirectly passed to procedures that need one, and the function table
(
functions
) is now stored inGenCtx
-- prior to serializing the VMenvironment, the function table stored with
GenCtx
's is moved into theTCtx
instance.With the new dedicated type for the orchestrator, the collected globals
don't have to be stored in
TCtx
anymore. ThecollectedGlobals
fieldis made part of
GenCtx
and is renamed to justglobals
.Misc
base
template forOrdinalSeq
and use it to reduce thenoise in the
OrdinalSeq
routinesadd
template forOrdinalSeq