nim-works/nimskull

Clean up `ast.TIdTable` type definition

Open

#145 opened on Dec 31, 2021

 (3 comments) (0 reactions) (0 assignees)Nim (39 forks)auto 404
good first issuerefactor

Repository metrics

Stars
 (346 stars)
PR merge metrics
 (PR metrics pending)

Description

ast defines TIdTable type that is used in several parts of the semantic pass. Type defined as follows:

  TIdPair* = object
    key*: PIdObj
    val*: RootRef

  TIdPairSeq* = seq[TIdPair]
  TIdTable* = object # the same as table[PIdent] of PObject
    counter*: int
    data*: TIdPairSeq

All the uses of the val: RootRef field are either converted to PType or PSym (result = PType(idTableGet(c.bindings, t)) etc.). This means RootRef can be easily replaced with

type
  PSymOrTyp = object
    case isSym*: bool
      of true:
        sym*: PSym

      of false:
        typ*: PType

This would not create any functional difference, but will clean up the code a little.

Contributor guide