Move stuff around

This commit is contained in:
greg 2018-11-19 21:38:39 -08:00
parent 0246e510ca
commit 98de15c07d

View File

@ -11,15 +11,7 @@ pub fn dispatch<V: ASTVisitor>(visitor: &mut V, ast: &AST) {
visitor.expression(e);
},
Statement::Declaration(decl) => {
match decl {
Declaration::FuncSig(sig) => visitor.func_signature(sig),
Declaration::FuncDecl(sig, block) => visitor.func_declaration(sig, block),
Declaration::TypeDecl { name, body, mutable } => visitor.type_declaration(name, body, mutable),
Declaration::TypeAlias(alias, name) => visitor.type_alias(alias, name),
Declaration::Binding { name, constant, expr} => visitor.binding(name, constant, expr),
Declaration::Impl { type_name, interface_name, block } => visitor.impl_block(type_name, interface_name, block),
Declaration::Interface { name, signatures } => visitor.interface(name, signatures),
}
dispatch_declaration(visitor, decl);
visitor.declaration(decl);
},
};
@ -55,6 +47,17 @@ fn dispatch_expression<V: ASTVisitor>(visitor: &mut V, expression: &Expression)
}
}
fn dispatch_declaration<V: ASTVisitor>(visitor: &mut V, declaration: &Declaration) {
match declaration {
Declaration::FuncSig(sig) => visitor.func_signature(sig),
Declaration::FuncDecl(sig, block) => visitor.func_declaration(sig, block),
Declaration::TypeDecl { name, body, mutable } => visitor.type_declaration(name, body, mutable),
Declaration::TypeAlias(alias, name) => visitor.type_alias(alias, name),
Declaration::Binding { name, constant, expr} => visitor.binding(name, constant, expr),
Declaration::Impl { type_name, interface_name, block } => visitor.impl_block(type_name, interface_name, block),
Declaration::Interface { name, signatures } => visitor.interface(name, signatures),
}
}
pub trait ASTVisitor {
fn ast(&mut self, _ast: &AST) { }