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

internal: separate TLoc from TSym and TType #790

Merged
merged 8 commits into from
Jul 9, 2023

Commits on Jul 8, 2023

  1. cgen: decouple TLoc from TSym

    Store all locs associated with symbols in lookup tables, with `TSym.loc`
    only being queried (but never written) for the external name or user-
    provided flags.
    
    In order to efficiently associate a `TSym` with a code-generator `TLoc`,
    each `TSym` stores a one-based index (`locId`) into one of the code
    generator's lookup tables. A table-based approach would have too, but
    it's slightly slower (~1.4% when building the compiler itselfs).
    
    In general, `cgen` becomes more strict with locs, now requiring globals,
    constants, and parameters to have their loc set-up once at definition
    processing time. Procedures, fields, and locals still need to
    support ad-hoc loc setup.
    
    Other changes:
    - writing the mangled names to NDI files is temporarily disabled
    - in symbol definitions contexts, `loc.t` is replaced with the querying
      the symbol's type directly (both are equivalent)
    - locs for constants now store a symbol node in their `lode` field
    zerbina committed Jul 8, 2023
    Configuration menu
    Copy the full SHA
    1e167eb View commit details
    Browse the repository at this point in the history
  2. jsgen: decouple TLoc from TSym

    Use a `Table` to map symbols to the corresponding JavaScript name,
    which removes all modifications of `TSym.loc` from `jsgen`.
    
    Due the lesser complexity of the JavaScript code generator compared to
    the C code generator, a table-based approach works well enough.
    zerbina committed Jul 8, 2023
    Configuration menu
    Copy the full SHA
    bfe73f9 View commit details
    Browse the repository at this point in the history
  3. ast: remove TLoc from TSym and TType

    `TType` doesn't need a `TLoc` field at all, and `TSym` only needs to
    store the external name (`extname`) plus the interface flags
    (`locFlags`).
    
    The `TLoc`, `TLocKind`, and `TStorageLoc` types are moved to `cgendata`,
    with `TLocFlag` staying in the `ast` module for now.
    zerbina committed Jul 8, 2023
    Configuration menu
    Copy the full SHA
    c4e7b46 View commit details
    Browse the repository at this point in the history
  4. cbackend: restore NDI generation

    The orchestrator is now responsible for writing the mangled names to the
    NDI files.
    zerbina committed Jul 8, 2023
    Configuration menu
    Copy the full SHA
    397e5af View commit details
    Browse the repository at this point in the history
  5. cgen: less broad interface for the mangle procedures

    This is made possible by them no longer requiring access to an NDI
    file.
    zerbina committed Jul 8, 2023
    Configuration menu
    Copy the full SHA
    473b194 View commit details
    Browse the repository at this point in the history
  6. cgmeth: fix the dispatcher AST

    It stored in the name slot the symbol of the method that the dispatcher
    was derived from, which now causes problems. With the fix, for all
    routines reaching the backend, `sym.ast[namePos] == sym` *should* be
    true.
    zerbina committed Jul 8, 2023
    Configuration menu
    Copy the full SHA
    8af6d34 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    58d906d View commit details
    Browse the repository at this point in the history

Commits on Jul 9, 2023

  1. apply suggestions from code review

    Co-authored-by: Saem Ghani <saemghani+github@gmail.com>
    zerbina and saem authored Jul 9, 2023
    Configuration menu
    Copy the full SHA
    356ee71 View commit details
    Browse the repository at this point in the history