-
Notifications
You must be signed in to change notification settings - Fork 39
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
vm: move ExpandToAst
logic into own instruction
#281
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make makes more sense that it works this way.
One question about the statement list handling, style bit if you're in there.
compiler/vm/vm.nim
Outdated
templCall.add(node) | ||
|
||
var a = evalTemplate(templCall, prc, genSymOwner, c.config, c.cache, c.templInstCounter, c.idgen) | ||
if a.kind == nkStmtList and a.len == 1: a = a[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if a.kind == nkStmtList and a.len == 1: a = a[0] | |
if a.kind == nkStmtList and a.len == 1: # flatten if a single statement | |
a = a[0] |
Also, reading this code, what if it's empty? Should this be an nkEmpty then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know. In order to preserve the previous behaviour, I left this as is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, let's stick with it for now, it does feel like a bug waiting to happen. 😬
b747342
to
9d8abbd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bors r+
The logic for template expansion as needed by the `mExpandToAst` magic (used by `quote`) is now implemented as a separate instruction instead of as part of `IndCallAsgn`. This makes the role of template expansion less confusing ("why are templates 'called' inside the VM?", "weren't they expanded already?") and also allows for a different instruction argument make-up. The latter is required by both a future overhaul of macro expansion and the refactored VM. User-facing behaviour stays the same
Build succeeded: |
The logic for template expansion as needed by the
mExpandToAst
magic(used by
quote
) is now implemented as a separate instruction insteadof as part of
IndCallAsgn
. This makes the role of template expansionless confusing ("why are templates 'called' inside the VM?", "weren't
they expanded already?") and also allows for a different instruction
argument make-up. The latter is required for both a future overhaul
of macro expansion and the refactored VM.
User-facing behaviour stays the same