-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
162: Remove the nOrig from all over the compiler r=alaviss a=krux02 `nOrig` is pretty much only used for `macros.callsite` which is deprecated/redundant since Nim has `untyped` as macro arguments. Since then it has huge negative value on both developers as well as the computer because all of this copyTree that is happening to preserve it. Before this change, callsite returned an AST like it got spit out by the parser. But overload resolution does modify the ast. arguments get converted into nkArgList for varargs for example. To actually preserve the unchanged AST, there is this `nOrig` parameter all over the compiler. The idea is, befere a change is applied to the ast, deep copy the tree and store it as `nOrig` and pass that down along `n`. But it this strict AST preservation isn't tested, so I wouldn't assume that it actually work. Now I am passing down the node `n` instead of `nOrig` to callsite. So when the macro expects typed arguments, the corresponding children in the call node are also sem checked. Varargs are grouped to `nkArgsList`. So callsite in `myMacro(a,b)` is now often `(nnkCall (ident "mymacro") (nnkArgsList (ident "a") (ident "b")))` instead of `(nnkCall (ident "mymacro") (ident "a") (ident "b"))` which causes indices to be wrong and the macro crashes or generates an invalid ast. The one thing to preserve callsite for, that can't be done with simply reading the argument (which should have been done for years now), is to get line information of the actual macro invocation. But for this it might be better to just pass the the first child of call, the `symbol` of the macro down to callsite. Co-authored-by: Arne Döring <arne.doering@gmx.net>
- Loading branch information
Showing
18 changed files
with
115 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.