Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement structures #448

Merged
merged 44 commits into from
Oct 7, 2019
Merged

Implement structures #448

merged 44 commits into from
Oct 7, 2019

Conversation

Schaeff
Copy link
Member

@Schaeff Schaeff commented Aug 7, 2019

Implement structures in ZoKrates:

from "./bar.code" import Bar

struct Foo {
   Bar bar
   field[3] baz
}

def main(private Foo f) -> (Bar):
   return f.bar

Changes

  • New explicit syntax for imports: from PATH import SYMBOL as ALIAS, we have backward compatibility by aliasing import PATH to from PATH import main as PATH.FILENAME
  • structs can be declared, defined, accessed, mutated

@Schaeff Schaeff changed the base branch from modules-v2 to rec-arrays August 27, 2019 12:52
t.code Outdated Show resolved Hide resolved
@Schaeff Schaeff changed the base branch from rec-arrays to develop September 23, 2019 09:26
@stefandeml stefandeml self-assigned this Sep 23, 2019
@Schaeff Schaeff changed the title [WIP] Implement structures Implement structures Sep 23, 2019
stefandeml
stefandeml previously approved these changes Oct 6, 2019
out.code Outdated Show resolved Hide resolved
zokrates_book/src/concepts/types.md Outdated Show resolved Hide resolved
zokrates_book/src/concepts/types.md Show resolved Hide resolved
zokrates_core/src/absy/from_ast.rs Outdated Show resolved Hide resolved
@@ -1035,6 +1232,9 @@ impl<'ast, T: Field> Flattener<'ast, T> {
assert!(exprs_flattened.expressions.len() == 1); // outside of MultipleDefinition, FunctionCalls must return a single value
exprs_flattened.expressions[0].clone()
}
FieldElementExpression::Member(box s, id) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no change but on line 1147 there is the following TODO:

// we require from the base to be linear
// TODO change that

this origins from this commit:
0b83db9

something we want to fix?

zokrates_core/src/absy/mod.rs Outdated Show resolved Hide resolved
mod variable;

pub use crate::typed_absy::parameter::Parameter;
pub use crate::typed_absy::variable::Variable;
use crate::types::{FunctionKey, Signature, Type};

use crate::typed_absy::types::{FunctionKey, MemberId, Signature, Type};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 77: Delete or add comment

zokrates_core/src/typed_absy/variable.rs Show resolved Hide resolved
@@ -0,0 +1,120 @@
//! Add runtime boolean checks on user inputs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That means we now check for all Boolean inputs strictly.

Eg in that example code:

struct A {
        bool b
}

def main(A a) -> (field):
  field dummy = 12
  return dummy

we will add boolean checks for the input a.

Co-Authored-By: Stefan <stefandeml@gmail.com>
@Schaeff Schaeff merged commit 8abf996 into develop Oct 7, 2019
@Schaeff Schaeff mentioned this pull request Oct 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants