-
-
Notifications
You must be signed in to change notification settings - Fork 474
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
feat(tasks/ast_codegen): prototype for codegen AST related code #3815
Conversation
Your org has enabled the Graphite merge queue for merging into mainAdd the label “merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix. You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link. |
CodSpeed Performance ReportMerging #3815 will not alter performanceComparing Summary
|
8d45b85
to
e203bc9
Compare
What I had in mind for the "schema" is more abstracted, and would not use // `TypeId` is an index into `Types`
type TypeId = usize;
struct Types(Vec<TypeDef>);
enum TypeDef {
Struct(StructDef),
Enum(EnumDef),
Box(BoxDef),
Vec(VecDef),
Option(OptionDef),
Cell(CellDef),
Primitive(PrimitiveDef),
StrRef(StrRefDef),
// I think that's all of them?
}
struct StructDef {
name: String,
fields: Vec<StructFieldDef>,
has_lifetime: bool,
}
struct StructFieldDef {
name: String,
type_id: TypeId,
}
struct EnumDef {
name: String,
variants: Vec<EnumVariantDef>,
// For `@inherits` inherited enum variants
inherits: Vec<TypeId>,
has_lifetime: bool,
}
struct EnumVariantDef {
name: String,
type_id: Option<TypeId>, // `None` for fieldless variants
discriminant: Option<u8>,
}
// ... and so on ... My thought was codegen proceeds in 2 steps:
The types above are similar to what
Does this make any sense? What do you think? |
I'll add the simple output, I keep the syn type in the building process so we can expand macros and generate AST in the future if needed. you are looking at the Module sturct not the Schema. |
Sorry if I misunderstood. I don't quite understand what you're doing, but no matter. I'm sure you have a plan! |
It is totally on me, Currently, the code is full of unused types and dirty prototypes, I'm focused on getting the whole pipeline to work and then going back to clean it up. I also opted for interior mutability and cloning where needed since there aren't many performance concerns in this crate. I thought it would make development easier if we could be a little careless with how we pass around stuff, After all this script only runs once in a while and the runtime is minimal so not having to fight with borrow checker constantly is much more favorable than having a well-optimized build script. |
8922486
to
2f96e2a
Compare
89d63cc
to
f029273
Compare
37b34fc
to
50fdc91
Compare
50fdc91
to
ee085f6
Compare
@Boshen @overlookmotel This is almost ready, You may want to give it a spin. |
2f010c1
to
835e59c
Compare
7c0eb38
to
363d3d5
Compare
@overlookmotel can you help me review and merge this one? This is beyond me 😅 I'll chime in when the edit - save workflow is up and running. |
@overlookmotel I suggest you only review #3852 there is some stuff I've changed after this PR and I was too lazy to cherry-pick and merge them here. |
@overlookmotel Just to make your life easier, I'm adding comments to help with the review process, I'll mention you in up stack PR as soon as I submit my docs commit. |
8c3a170
to
f014d23
Compare
d22b9d0
to
b6e7c2b
Compare
0599a1d
to
1f85f1a
Compare
b6e7c2b
to
47b89bd
Compare
47b89bd
to
e7b0225
Compare
Merge activity
|
e7b0225
to
f6c4ec4
Compare
Mark everything mentioned in #3815 (comment) as AST. We now error on the occurrence of non-ast items in the source of truth. It doesn't make sure that all fields and variants are `#[ast]` and therefore `repr_stable` but there are only a handful of non-AST types used here(mainly Atom and Span). Since we don't have access to the external types we can't make sure of it unless we find a way to const assert it. The best we can do until then is to check all field/variant types to be either `#[ast]` or in a white list. I can add this check to the codegen in an upcoming PR.
Part of #3819