Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scope system rework #246

Open
serkonda7 opened this issue Nov 20, 2024 · 1 comment
Open

Scope system rework #246

serkonda7 opened this issue Nov 20, 2024 · 1 comment

Comments

@serkonda7
Copy link
Member

serkonda7 commented Nov 20, 2024

Continuously updated

Tracker for details regarding the current and future form of Bait's scope system.

Changes will be split up into multiple PRs.

Status Quo

Hierarchy:

global scope
+-- file 1
  +-- blocks
    +-- ...
  +-- ...
+-- file 2
+-- ...

Storage:

table.Table.global_scope &ast.Scope

Contents high-level:

  • global scope
    • consts
    • globals
    • foreign types
  • file scope
    • import aliases
    • functions
  • block scope
    • everything else

ScopeObject value variants:

// normal
Obj{
  name = full.pkg.name
  pkg = full.pkg
}

// builtin
Obj{
  name = name
  pkg = "builtin"
}

// ffi
Obj{
  name = LANG.pkg.name
  pkg = full.pkg
  lang = lang
}

Goal

Hierarchy:

universe
+-- ffi
+-- pkg 1
  +-- block (file 1)
    +-- blocks
      +-- ...
  +-- block (file 2)
  +-- ...
+-- pkg 2
+-- ...

Storage:

table.Table.pkg_scopes map[string]&ast.Scope

Contents high-level:

  • universe
    • primitive types
  • FFI
    • all C / JS declarations depending on the backend
  • package scope
    • globals
    • constants
    • functions
  • block scope (file toplevel)
    • import aliases
  • block scope (sub blocks)
    • everything else

ScopeObject value variants:

// normal
table.pkg_scopes[full.pkg]Obj{
  name = name
}

// builtin
table.pkg_scopes["builtin"]Obj{
  name = name
}

// ffi
table.pkg_scopes["FFI"]Obj{
  name = pkg.name
  lang = lang // this might not even be needed
}
@serkonda7
Copy link
Member Author

As of #257 the reworked scope system has fully replaced all functionality of the old one.

Next up I will expand it's usage for symbols that are currently tracked in some other messy way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant