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

feat: Add common trait impls to Ir types for external usage #85

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tools/codegen/src/ast/raw/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl Default for SyntaxVersion {
}
}

#[derive(Debug, Clone, PartialEq, Eq, Property)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Property)]
#[property(get(public))]
#[cfg_attr(
feature = "compiler-plugin",
Expand Down
28 changes: 14 additions & 14 deletions tools/codegen/src/ir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub(crate) use from_ast::ToIntermediate;
pub use crate::ast::SyntaxVersion;

/// Intermediate file.
#[derive(Debug, Property, Deserialize, Serialize)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Property, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct Ir {
#[serde(default)]
Expand All @@ -22,15 +22,15 @@ pub struct Ir {
pub decls: Vec<TopDecl>,
}

#[derive(Debug, Clone, Property, Deserialize, Serialize)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Property, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct ImportStmt {
pub name: String,
pub paths: Vec<String>,
pub path_supers: usize,
}

#[derive(Debug, Deserialize, Serialize)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)]
#[serde(deny_unknown_fields, tag = "type", rename_all = "lowercase")]
pub enum TopDecl {
#[serde(rename = "option")]
Expand All @@ -43,7 +43,7 @@ pub enum TopDecl {
Table(Table),
}

#[derive(Debug, Property, Deserialize, Serialize)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Property, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct Option_ {
pub name: String,
Expand All @@ -52,7 +52,7 @@ pub struct Option_ {
pub imported_depth: usize,
}

#[derive(Debug, Property, Deserialize, Serialize)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Property, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct Union {
pub name: String,
Expand All @@ -63,7 +63,7 @@ pub struct Union {
pub imported_depth: usize,
}

#[derive(Debug, Property, Deserialize, Serialize)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Property, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct Array {
pub name: String,
Expand All @@ -73,7 +73,7 @@ pub struct Array {
pub imported_depth: usize,
}

#[derive(Debug, Property, Deserialize, Serialize)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Property, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct Struct {
pub name: String,
Expand All @@ -82,7 +82,7 @@ pub struct Struct {
pub imported_depth: usize,
}

#[derive(Debug, Property, Deserialize, Serialize)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Property, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct FixVec {
pub name: String,
Expand All @@ -91,7 +91,7 @@ pub struct FixVec {
pub imported_depth: usize,
}

#[derive(Debug, Property, Deserialize, Serialize)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Property, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct DynVec {
pub name: String,
Expand All @@ -100,7 +100,7 @@ pub struct DynVec {
pub imported_depth: usize,
}

#[derive(Debug, Property, Deserialize, Serialize)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Property, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct Table {
pub name: String,
Expand All @@ -109,20 +109,20 @@ pub struct Table {
pub imported_depth: usize,
}

#[derive(Debug, Property, Deserialize, Serialize)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Property, Deserialize, Serialize)]
#[serde(deny_unknown_fields, transparent)]
pub struct ItemDecl {
pub typ: String,
}

#[derive(Debug, Property, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Property, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct UnionItemDecl {
pub typ: String,
pub id: usize,
}

#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UnionItemsForCompatibility {
ItemsForCompatibility(Vec<ItemDecl>),
Expand All @@ -147,7 +147,7 @@ where
})
}

#[derive(Debug, Property, Deserialize, Serialize)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Property, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct FieldDecl {
pub name: String,
Expand Down