mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-10-26 07:00:35 +03:00
clean up output
This commit is contained in:
parent
ac48138621
commit
833590ad40
@ -1,9 +1,6 @@
|
|||||||
def test(field x) -> (field):
|
struct Foo {
|
||||||
return 1
|
bool x
|
||||||
|
}
|
||||||
def test2(bool b) -> (bool):
|
def main() -> (bool):
|
||||||
return b
|
Foo f = Foo {x: true}
|
||||||
|
return f.x
|
||||||
def main() -> (field):
|
|
||||||
a = test2(true)
|
|
||||||
return a
|
|
||||||
|
@ -634,21 +634,7 @@ impl ResolvedProgram {
|
|||||||
ResolvedValue::Return(
|
ResolvedValue::Return(
|
||||||
statements
|
statements
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|expression| match expression {
|
.map(|expression| self.enforce_expression(cs, expression))
|
||||||
Expression::Boolean(boolean_expression) => {
|
|
||||||
self.enforce_boolean_expression(cs, boolean_expression)
|
|
||||||
}
|
|
||||||
Expression::FieldElement(field_expression) => {
|
|
||||||
self.enforce_field_expression(cs, field_expression)
|
|
||||||
}
|
|
||||||
Expression::Variable(variable) => {
|
|
||||||
self.resolved_variables.get_mut(&variable).unwrap().clone()
|
|
||||||
}
|
|
||||||
Expression::Struct(_v, _m) => {
|
|
||||||
unimplemented!("return struct not impl");
|
|
||||||
}
|
|
||||||
expr => unimplemented!("expression {} can't be returned yet", expr),
|
|
||||||
})
|
|
||||||
.collect::<Vec<ResolvedValue>>(),
|
.collect::<Vec<ResolvedValue>>(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,7 @@ pub struct Program {
|
|||||||
pub id: String,
|
pub id: String,
|
||||||
pub structs: HashMap<Variable, Struct>,
|
pub structs: HashMap<Variable, Struct>,
|
||||||
pub functions: HashMap<Variable, Function>,
|
pub functions: HashMap<Variable, Function>,
|
||||||
pub statements: Vec<Statement>,
|
// pub statements: Vec<Statement>,
|
||||||
pub arguments: Vec<Variable>,
|
pub arguments: Vec<Variable>,
|
||||||
pub returns: Vec<Variable>,
|
pub returns: Vec<Variable>,
|
||||||
}
|
}
|
||||||
|
@ -703,25 +703,29 @@ impl<'ast> From<ast::File<'ast>> for types::Program {
|
|||||||
let mut functions = HashMap::new();
|
let mut functions = HashMap::new();
|
||||||
|
|
||||||
file.structs.into_iter().for_each(|struct_def| {
|
file.structs.into_iter().for_each(|struct_def| {
|
||||||
let struct_definition = types::Struct::from(struct_def);
|
structs.insert(
|
||||||
structs.insert(struct_definition.variable.clone(), struct_definition);
|
types::Variable::from(struct_def.variable.clone()),
|
||||||
|
types::Struct::from(struct_def),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
file.functions.into_iter().for_each(|function_def| {
|
file.functions.into_iter().for_each(|function_def| {
|
||||||
let function_definition = types::Function::from(function_def);
|
functions.insert(
|
||||||
functions.insert(function_definition.variable.clone(), function_definition);
|
types::Variable::from(function_def.variable.clone()),
|
||||||
|
types::Function::from(function_def),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
let statements: Vec<types::Statement> = file
|
// let statements: Vec<types::Statement> = file
|
||||||
.statements
|
// .statements
|
||||||
.into_iter()
|
// .into_iter()
|
||||||
.map(|statement| types::Statement::from(statement))
|
// .map(|statement| types::Statement::from(statement))
|
||||||
.collect();
|
// .collect();
|
||||||
|
|
||||||
types::Program {
|
types::Program {
|
||||||
id: "main".into(),
|
id: "main".into(),
|
||||||
structs,
|
structs,
|
||||||
functions,
|
functions,
|
||||||
statements,
|
// statements,
|
||||||
arguments: vec![],
|
arguments: vec![],
|
||||||
returns: vec![],
|
returns: vec![],
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user