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):
|
||||
return 1
|
||||
|
||||
def test2(bool b) -> (bool):
|
||||
return b
|
||||
|
||||
def main() -> (field):
|
||||
a = test2(true)
|
||||
return a
|
||||
struct Foo {
|
||||
bool x
|
||||
}
|
||||
def main() -> (bool):
|
||||
Foo f = Foo {x: true}
|
||||
return f.x
|
||||
|
@ -634,21 +634,7 @@ impl ResolvedProgram {
|
||||
ResolvedValue::Return(
|
||||
statements
|
||||
.into_iter()
|
||||
.map(|expression| match 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),
|
||||
})
|
||||
.map(|expression| self.enforce_expression(cs, expression))
|
||||
.collect::<Vec<ResolvedValue>>(),
|
||||
)
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ pub struct Program {
|
||||
pub id: String,
|
||||
pub structs: HashMap<Variable, Struct>,
|
||||
pub functions: HashMap<Variable, Function>,
|
||||
pub statements: Vec<Statement>,
|
||||
// pub statements: Vec<Statement>,
|
||||
pub arguments: Vec<Variable>,
|
||||
pub returns: Vec<Variable>,
|
||||
}
|
||||
|
@ -703,25 +703,29 @@ impl<'ast> From<ast::File<'ast>> for types::Program {
|
||||
let mut functions = HashMap::new();
|
||||
|
||||
file.structs.into_iter().for_each(|struct_def| {
|
||||
let struct_definition = types::Struct::from(struct_def);
|
||||
structs.insert(struct_definition.variable.clone(), struct_definition);
|
||||
structs.insert(
|
||||
types::Variable::from(struct_def.variable.clone()),
|
||||
types::Struct::from(struct_def),
|
||||
);
|
||||
});
|
||||
file.functions.into_iter().for_each(|function_def| {
|
||||
let function_definition = types::Function::from(function_def);
|
||||
functions.insert(function_definition.variable.clone(), function_definition);
|
||||
functions.insert(
|
||||
types::Variable::from(function_def.variable.clone()),
|
||||
types::Function::from(function_def),
|
||||
);
|
||||
});
|
||||
|
||||
let statements: Vec<types::Statement> = file
|
||||
.statements
|
||||
.into_iter()
|
||||
.map(|statement| types::Statement::from(statement))
|
||||
.collect();
|
||||
// let statements: Vec<types::Statement> = file
|
||||
// .statements
|
||||
// .into_iter()
|
||||
// .map(|statement| types::Statement::from(statement))
|
||||
// .collect();
|
||||
|
||||
types::Program {
|
||||
id: "main".into(),
|
||||
structs,
|
||||
functions,
|
||||
statements,
|
||||
// statements,
|
||||
arguments: vec![],
|
||||
returns: vec![],
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user