nim-works/nimskull

Clean up `ast.TIdTable` type definition

Aperta

#145 aperta il 31 dic 2021

 (3 commenti) (0 reazioni) (0 assegnatari)Nim (39 fork)auto 404
good first issuerefactor

Metriche repository

Star
 (346 stelle)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

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.

Guida contributor