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

Query-based compiler #34

Open
Mesabloo opened this issue Nov 8, 2020 · 0 comments
Open

Query-based compiler #34

Mesabloo opened this issue Nov 8, 2020 · 0 comments
Labels
enhancement New feature or request queries About compiler queries
Milestone

Comments

@Mesabloo
Copy link
Member

Mesabloo commented Nov 8, 2020

Our first refactor will be to introduce queries in our compiler.

"What would be the use?"

would you say.

Queries will allow us to simply ask for something, like the type of a symbol, or whether a symbol is dynamically/statically linked, or something else.
We will have to create a simple query language extensible enough to also be used in gzc while remaining simple and easy to write/use. Our main inspiration will be SQL.

That way, we can create some sort of ORM on top of the internal black box of the compiler and use it efficiently. This also means, unfortunately, that the memory footprint will be higher, but for a good reason.

This will also help us achieve incremental compilation, where only modified parts will need to be recompiled.


Query examples:

/** Selects the type of a known symbol from a given file. */
select type from (symbol """print""") in file """std/io.nst"""
-- forall (s: Ts). { %rsp: { sptr *{ %rsp: sptr s }::s }, %rdi: *char }

/** Selects the type of an expression given a file and a line number. */
select type from (expr """4(%rsp)""") in file """std/io.nst""" at line 32
-- s32

/** Ask the compiler to fully compile the file into an ELF object. 
    We also could ask to only compile specific functions. */
compile * from file """std/io.nst""" into """std/io.o""" as ELF
Disclaimer: the syntax and semantics are not yet fixed. This is the goal of this issue, to keep track of all those changes. The examples above are therefore not necessarily valid.
@Mesabloo Mesabloo added the enhancement New feature or request label Nov 8, 2020
@Mesabloo Mesabloo added this to the N* v1 milestone Nov 8, 2020
@Mesabloo Mesabloo added the queries About compiler queries label Nov 8, 2020
@Mesabloo Mesabloo modified the milestones: N* v1, N* v2 Jan 20, 2021
@Mesabloo Mesabloo removed this from the N* v3 milestone Mar 14, 2021
@Mesabloo Mesabloo moved this to Todo in Issue tracker Nov 1, 2021
@Mesabloo Mesabloo added this to the Later milestone Sep 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request queries About compiler queries
Projects
Status: Todo
Development

No branches or pull requests

1 participant