Declarative language for efficient serialization defined in terms of bytes.
|
6 napja | |
---|---|---|
bin | 6 napja | |
crates | 6 napja | |
examples | 2 hete | |
.gitignore | 1 éve | |
Cargo.lock | 6 napja | |
Cargo.toml | 1 hete | |
README.md | 1 hete |
Stencil is a programming language and data model for describing precise and efficient data structure for interchange between different languages.
Stencil is designed to give developers control over the layouts of data structures and generate efficient code in
The goal is to generate types that wrap buffers to enable interacting with data
structures from disk approaching the performance of mmap
ping a C struct from
disk, but with added safety and well-formedness checks.
Stencil has 3 frontends planned:
examples/demo.yml
examples/ip.stencil
for a rough planOnly the first exists today. I am focused on making the core of Stencil robust and powerful enough to suit its target use cases before exposing the full expressiveness of its internal representation. Right now we can suffer through that nonsense.
Stencil frontends target the layout reprensentation. This representation reasons more explicitly about the positions of fields within a structure and how different structures relate to each other. This is where we generate different instances of types when we need to talk about the same abstract type in different contexts, like builders for complex types.
From the layout representation, we generate Stencil MIR, or "middle intermediate representation". This describes types more concretely and generates function implementations for constructors, getters, setters, etc. We also do typechecking in this stage to ensure our generated code is self-consistent.
This is also the stage where we can inject functions for introspecting the types in specialized ways, like generating the merkle hasher functions for SSZ types.
There are back ends for each language we target.
Each backend needs a LangIR that it converts to from MIR. This is where we can resolve type names to local versions and make final checks. This wouldn't be a full native AST, but can represent a subset of the target language syntax that's useful for Stencil.
We can apply additional language transformations to the LangIR (adding annotations, attributes, instrumentation, etc, as desired) for additional functionality.
Then we can actually generate code from it. This phase isn't that sophisticated. It will be more sophisticated in the future when we have need for that.
The top priorities are:
These are what I have planned for my own uses.
Secondary priorities:
These I may get to if I have some desire to figure it out.
Contributions encouraged:
I either don't want to or don't trust myself to write/test code in these languages, but I see them as being very valuable to have:
or any other language you personally have a use for.