ast: add getPIdent (#17684)

* ast: add getPIdent

* fixup
This commit is contained in:
Timothee Cour 2021-04-09 01:00:13 -05:00 • committed by GitHub
commit cce1b24b1c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 16 deletions

View file

@ -1054,6 +1054,14 @@ const
defaultAlignment = -1
defaultOffset = -1
proc getPIdent*(a: PNode): PIdent {.inline.} =
## Returns underlying `PIdent` for `{nkSym, nkIdent}`, or `nil`.
# xxx consider whether also returning the 1st ident for {nkOpenSymChoice, nkClosedSymChoice}
# which may simplify code.
case a.kind
of nkSym: a.sym.name
of nkIdent: a.ident
else: nil
proc getnimblePkg*(a: PSym): PSym =
result = a