extract build_call
This commit is contained in:
parent
38659d86aa
commit
03e8673b6f
|
|
@ -131,6 +131,22 @@ fn build_expression(scope: &BuildContext<'_>, code: &ast::Expression) -> Express
|
|||
todo!()
|
||||
}
|
||||
|
||||
fn build_call(scope: &BuildContext<'_>, code: &ast::Call) -> Call {
|
||||
Call {
|
||||
callee: Box::new(build_expression(
|
||||
&scope,
|
||||
&ast::Expression::Variable(ast::Location::Variable {
|
||||
name: code.callee.clone(),
|
||||
}),
|
||||
)),
|
||||
args: code
|
||||
.args
|
||||
.iter()
|
||||
.map(|arg| build_expression(&scope, arg))
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
|
||||
fn build_in_scope(parent: &BuildContext<'_>, code: &ast::Function) -> Function {
|
||||
let scope = BuildContext {
|
||||
parent: Some(parent),
|
||||
|
|
@ -149,19 +165,8 @@ fn build_in_scope(parent: &BuildContext<'_>, code: &ast::Function) -> Function {
|
|||
source: Box::new(build_expression(&scope, source)),
|
||||
});
|
||||
}
|
||||
ast::Statement::Call(ast::Call { callee, args }) => {
|
||||
body.push(Statement::Call(Call {
|
||||
callee: Box::new(build_expression(
|
||||
&scope,
|
||||
&ast::Expression::Variable(ast::Location::Variable {
|
||||
name: callee.clone(),
|
||||
}),
|
||||
)),
|
||||
args: args
|
||||
.iter()
|
||||
.map(|arg| build_expression(&scope, arg))
|
||||
.collect(),
|
||||
}));
|
||||
ast::Statement::Call(call) => {
|
||||
body.push(Statement::Call(build_call(&scope, call)));
|
||||
}
|
||||
ast::Statement::Local { name, init } => {
|
||||
let init = init.as_ref().map(|init| build_expression(&scope, &init));
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user