Move stuff around
This commit is contained in:
parent
0246e510ca
commit
98de15c07d
@ -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) { }
|
||||
@ -117,7 +120,7 @@ impl ASTVisitor for SchalaPrinter {
|
||||
self.s.push_str("some_expr");
|
||||
}
|
||||
|
||||
fn binding(&mut self, name: &Rc<String>, constant: &bool, _expr: &Expression) {
|
||||
fn binding(&mut self, name: &Rc<String>, constant: &bool, _expr: &Expression) {
|
||||
self.s.push_str(&format!("let{} {} = {}",
|
||||
if *constant { "" } else { " mut" },
|
||||
name,
|
||||
|
Loading…
Reference in New Issue
Block a user