I'd like to implement a small subset of Rust language features into a JIT data definition language to implement a kind of strongly typed serde. The language would include a subset of struct initialization like:
MyStruct{
a: 0, // i32
b: B{ c: 123, //usize
..B::default() }, // B
d: [ 1,2,3,4,5 ], // [ u32; 5 ]
e: ( true, 1, 1.6 ), // ( bool, i32, f32 )
.. MyStruct::default() // defaults a-z
}
MyStruct
, B
, <T>::default()
and everything from a
to z
would be defined in Rust and the struct definitions made available to the JIT directly from Rust. I wouldn't support control structures of any form, but some impl
functions would be included(e.g. default).
Where do I start?
You might be able to get more specific support from a Rust community. I believe there's a Zulip for Rust, for example. Perhaps you'd also be interested in the RON format, which seems to do some of what you're interested in.
https://www.rust-lang.org/community
IFcoltransG said:
You might be able to get more specific support from a Rust community. I believe there's a Zulip for Rust, for example. Perhaps you'd also be interested in the RON format, which seems to do some of what you're interested in.
https://www.rust-lang.org/community
Thanks. So, what I'm trying to accomplish is a data definition language that's a subset of Rust, so that I can do something like the following, which would give me compile errors when running cargo test
.
#[cfg(test)]
mod test {
fn test_data() {
use crate::my_data_objects::*;
let _data = include!("my_data/data.rd");
}
}
fn load_data( path: &str ) -> MyStruct { // path = "my_data/data.rd"
micro_rust::jit::load::<MyStruct>(path)
}
So, I'm really am looking to implement a Jit using cranelift
Last updated: Nov 22 2024 at 16:03 UTC