fix signature and visibility
This commit is contained in:
parent
2980d8da02
commit
88c755ff79
3 changed files with 20 additions and 8 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -1227,7 +1227,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "zokrates_pest_ast"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/Schaeff/zokrates_pest_ast?branch=grammar-overhaul#0b07caa537411efaf572dd7d1e20ba96cba0025d"
|
||||
source = "git+https://github.com/Schaeff/zokrates_pest_ast?branch=grammar-overhaul#a5af535857f923fd219c13c6df03b759f313addb"
|
||||
dependencies = [
|
||||
"from-pest 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
|
@ -76,11 +76,17 @@ impl<'ast> From<pest::Parameter<'ast>> for absy::ParameterNode {
|
|||
fn from(param: pest::Parameter<'ast>) -> absy::ParameterNode {
|
||||
use absy::NodeValue;
|
||||
|
||||
absy::Parameter::new(
|
||||
absy::Variable::new(param.id.value, Type::from(param.ty)).at(42, 42, 0),
|
||||
true,
|
||||
)
|
||||
.at(42, 42, 0)
|
||||
let private = param
|
||||
.visibility
|
||||
.map(|v| match v {
|
||||
pest::Visibility::Private(_) => true,
|
||||
pest::Visibility::Public(_) => false,
|
||||
})
|
||||
.unwrap_or(false);
|
||||
|
||||
let variable = absy::Variable::new(param.id.value, Type::from(param.ty)).at(42, 42, 0);
|
||||
|
||||
absy::Parameter::new(variable, private).at(42, 42, 0)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -464,6 +470,7 @@ mod tests {
|
|||
let source = "def main(private field a, bool b) -> (field): return 42
|
||||
";
|
||||
let ast = pest::generate_ast(&source).unwrap();
|
||||
|
||||
let expected: absy::Prog<FieldPrime> = absy::Prog {
|
||||
functions: vec![absy::Function {
|
||||
id: String::from("main"),
|
||||
|
@ -483,13 +490,14 @@ mod tests {
|
|||
)
|
||||
.into()],
|
||||
signature: absy::Signature::new()
|
||||
.inputs(vec![])
|
||||
.inputs(vec![Type::FieldElement, Type::Boolean])
|
||||
.outputs(vec![Type::FieldElement]),
|
||||
}
|
||||
.into()],
|
||||
imports: vec![],
|
||||
imported_functions: vec![],
|
||||
};
|
||||
|
||||
assert_eq!(absy::Prog::<FieldPrime>::from(ast), expected);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,10 @@ impl fmt::Display for Parameter {
|
|||
|
||||
impl fmt::Debug for Parameter {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "Parameter(variable: {:?})", self.id)
|
||||
write!(
|
||||
f,
|
||||
"Parameter(variable: {:?}, private: {:?})",
|
||||
self.id, self.private
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue