Rust: regenerate code

This commit is contained in:
Arthur Baars
2024-10-01 15:18:17 +02:00
parent 69f0e8bcf7
commit 6ede20cccc
20 changed files with 472 additions and 13 deletions

View File

@@ -1,2 +1,2 @@
mod.rs 4bcb9def847469aae9d8649461546b7c21ec97cf6e63d3cf394e339915ce65d7 4bcb9def847469aae9d8649461546b7c21ec97cf6e63d3cf394e339915ce65d7
top.rs 855f5f0639dfafd8603c9b842f6470ca6d1214bb72391890a1de64db2adebba1 855f5f0639dfafd8603c9b842f6470ca6d1214bb72391890a1de64db2adebba1
top.rs 00321b829ffca674c66daa86c003b9d5f8c64fef42873d03fa677cfa479039a2 00321b829ffca674c66daa86c003b9d5f8c64fef42873d03fa677cfa479039a2

View File

@@ -1032,6 +1032,110 @@ impl From<trap::Label<Lifetime>> for trap::Label<Locatable> {
}
}
#[derive(Debug)]
pub struct MacroItems {
pub id: trap::TrapId<MacroItems>,
pub items: Vec<trap::Label<Item>>,
}
impl trap::TrapEntry for MacroItems {
fn extract_id(&mut self) -> trap::TrapId<Self> {
std::mem::replace(&mut self.id, trap::TrapId::Star)
}
fn emit(self, id: trap::Label<Self>, out: &mut trap::Writer) {
out.add_tuple("macro_items", vec![id.into()]);
for (i, v) in self.items.into_iter().enumerate() {
out.add_tuple("macro_items_items", vec![id.into(), i.into(), v.into()]);
}
}
}
impl trap::TrapClass for MacroItems {
fn class_name() -> &'static str { "MacroItems" }
}
impl From<trap::Label<MacroItems>> for trap::Label<AstNode> {
fn from(value: trap::Label<MacroItems>) -> Self {
// SAFETY: this is safe because in the dbscheme MacroItems is a subclass of AstNode
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<MacroItems>> for trap::Label<Element> {
fn from(value: trap::Label<MacroItems>) -> Self {
// SAFETY: this is safe because in the dbscheme MacroItems is a subclass of Element
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<MacroItems>> for trap::Label<Locatable> {
fn from(value: trap::Label<MacroItems>) -> Self {
// SAFETY: this is safe because in the dbscheme MacroItems is a subclass of Locatable
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
#[derive(Debug)]
pub struct MacroStmts {
pub id: trap::TrapId<MacroStmts>,
pub expr: Option<trap::Label<Expr>>,
pub statements: Vec<trap::Label<Stmt>>,
}
impl trap::TrapEntry for MacroStmts {
fn extract_id(&mut self) -> trap::TrapId<Self> {
std::mem::replace(&mut self.id, trap::TrapId::Star)
}
fn emit(self, id: trap::Label<Self>, out: &mut trap::Writer) {
out.add_tuple("macro_stmts", vec![id.into()]);
if let Some(v) = self.expr {
out.add_tuple("macro_stmts_exprs", vec![id.into(), v.into()]);
}
for (i, v) in self.statements.into_iter().enumerate() {
out.add_tuple("macro_stmts_statements", vec![id.into(), i.into(), v.into()]);
}
}
}
impl trap::TrapClass for MacroStmts {
fn class_name() -> &'static str { "MacroStmts" }
}
impl From<trap::Label<MacroStmts>> for trap::Label<AstNode> {
fn from(value: trap::Label<MacroStmts>) -> Self {
// SAFETY: this is safe because in the dbscheme MacroStmts is a subclass of AstNode
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<MacroStmts>> for trap::Label<Element> {
fn from(value: trap::Label<MacroStmts>) -> Self {
// SAFETY: this is safe because in the dbscheme MacroStmts is a subclass of Element
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<MacroStmts>> for trap::Label<Locatable> {
fn from(value: trap::Label<MacroStmts>) -> Self {
// SAFETY: this is safe because in the dbscheme MacroStmts is a subclass of Locatable
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
#[derive(Debug)]
pub struct MatchArm {
pub id: trap::TrapId<MatchArm>,