codegen: don't use PSym
for labels
#940
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
In the code generators, represent block labels with a dedicated type
and
node, instead of using
PSym
for that. This is an internal-onlychange,
and another step towards removing all
PSym
usage from the codegenerators.
Details
cnkLabel
node kind toCgNode
BlockId
, and appears as sub-node for bothcnkBlockStmt
and
cnkBreakStmt
BlockId
is not a unique ID within aBody
-- instead itidentifies the enclosing
block
for abreak
. This matches how thecode generators previously used
skLabel
symbolscgirgen
now no longer queries or modifies the identifier cache(
IdentCache
), so all usages of the type are removed. Theidents
import is turned into a narrow import
The code generators are updated accordingly:
cgen
uses itsblocks
stack not only forcnkBlockStmt
s, but forC blocks (
{}
) in general. Therefore,TBlock
stores theBlockId
offset by 1, leaving '0' to mean "not corresponding to a
cnkBlockStmt
"jsgen
uses theBlockId
as an index into theblocks
stack, whichis now a
seq[int]
(the previously usedTBlock
type had only asingle field)
vmgen
also uses theBlockId
as an index into itsblocks
stack,making the previous search logic obsolete. The
withBlock
andpopBlocks
routines were only used in a single place -- they'reinlined and removed. In addition, the
blocks
stack embeds theending list directly, removing the need for the
TBlock
type