Skip to content

Move from globally-unique ScopedId to function-local IDs #50

Open
@SnirkImmington

Description

@SnirkImmington

Edit: See my comment below.

This is a tracking issue regarding the use of ScopedIds in the AST (currently in the typeck branch). These de Bruijn indices currently have some properties that I try to uphold but don't depend on; the structure of a ScopedId could be useful in the future (if the AST design is upheld.

When creating ScopedIds on variables:

  • The default() of [0] is never assigned (this is depended upon).
  • Top-level items in visit_unit are numbered [0, 0] .. [0, n].
  • If visit_unit is called k times then items in unit k are numbered [k, 0] .. [k, n].
  • The k parameters of function [0, n] are numbered [0, n, 0] .. [0, n, k].
  • The opening block of a function [0, n] is [0, n, 0, 0]
  • The kth top-level variable defined in a function [0, n] is [0, n, 0, k].

When creating ScopedIds on types:

  • (), bool, and float are [1], [2], and [3] respectively.
  • The types of functions are equivalent to the functions' ScopedIds, i.e. [0, n]

Additional things we could do:

  • [ ] Dump function parameters into the top level scope (see identify/names/item_identifier.rs

These changes are all in the typeck branch. I'll revisit this issue after that is merged in.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: ASTIssues which affect AST codearea: checkCode validationarea: identifyThe "identify pass" - the ScopedId De Brujin index, or "ensure name exists in scope"change: expansionA change which includes new features, improvements, or APIspriority: lowConsider higher priority issues first

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions