From 833590ad407bb34d122f0ef2380095cd95d73260 Mon Sep 17 00:00:00 2001 From: collin Date: Wed, 15 Apr 2020 22:17:44 -0700 Subject: [PATCH] clean up output --- simple.program | 15 ++++++--------- src/aleo_program/constraints.rs | 16 +--------------- src/aleo_program/types.rs | 2 +- src/aleo_program/types_from.rs | 24 ++++++++++++++---------- 4 files changed, 22 insertions(+), 35 deletions(-) diff --git a/simple.program b/simple.program index 44b95e3837..dd5f5ba1e8 100644 --- a/simple.program +++ b/simple.program @@ -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 \ No newline at end of file +struct Foo { + bool x +} +def main() -> (bool): + Foo f = Foo {x: true} + return f.x diff --git a/src/aleo_program/constraints.rs b/src/aleo_program/constraints.rs index ab262e756e..0c753648a6 100644 --- a/src/aleo_program/constraints.rs +++ b/src/aleo_program/constraints.rs @@ -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::>(), ) } diff --git a/src/aleo_program/types.rs b/src/aleo_program/types.rs index 238290238a..3f61518019 100644 --- a/src/aleo_program/types.rs +++ b/src/aleo_program/types.rs @@ -165,7 +165,7 @@ pub struct Program { pub id: String, pub structs: HashMap, pub functions: HashMap, - pub statements: Vec, + // pub statements: Vec, pub arguments: Vec, pub returns: Vec, } diff --git a/src/aleo_program/types_from.rs b/src/aleo_program/types_from.rs index 0ea32a83ac..8ba951c389 100644 --- a/src/aleo_program/types_from.rs +++ b/src/aleo_program/types_from.rs @@ -703,25 +703,29 @@ impl<'ast> From> 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 = file - .statements - .into_iter() - .map(|statement| types::Statement::from(statement)) - .collect(); + // let statements: Vec = file + // .statements + // .into_iter() + // .map(|statement| types::Statement::from(statement)) + // .collect(); types::Program { id: "main".into(), structs, functions, - statements, + // statements, arguments: vec![], returns: vec![], }