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

feat(frontend): aztec syntactic sugar (feature flagged) #2403

Merged
merged 23 commits into from
Aug 29, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat(attributes): allow for custom attributes
Maddiaa0 committed Aug 22, 2023
commit 2b6a3e6677a6331129f04cbeb185d5e5eedac806
5 changes: 4 additions & 1 deletion crates/noirc_evaluator/src/ssa/ssa_gen/mod.rs
Original file line number Diff line number Diff line change
@@ -130,7 +130,10 @@ impl<'a> FunctionContext<'a> {
let slice_contents = self.codegen_array(elements, typ[1].clone());
Tree::Branch(vec![slice_length.into(), slice_contents])
}
_ => unreachable!("ICE: array literal type must be an array or a slice, but got {}", array.typ),
_ => unreachable!(
"ICE: array literal type must be an array or a slice, but got {}",
array.typ
),
}
}
ast::Literal::Integer(value, typ) => {
1 change: 1 addition & 0 deletions crates/noirc_frontend/src/ast/function.rs
Original file line number Diff line number Diff line change
@@ -86,6 +86,7 @@ impl From<FunctionDefinition> for NoirFunction {
Some(Attribute::Test) => FunctionKind::Normal,
Some(Attribute::Oracle(_)) => FunctionKind::Oracle,
Some(Attribute::Deprecated(_)) | None => FunctionKind::Normal,
Some(Attribute::Custom(_)) => FunctionKind::Normal,
};

NoirFunction { def: fd, kind }
7 changes: 7 additions & 0 deletions crates/noirc_frontend/src/lexer/token.rs
Original file line number Diff line number Diff line change
@@ -326,6 +326,7 @@ pub enum Attribute {
Oracle(String),
Deprecated(Option<String>),
Test,
Custom(String),
}

impl fmt::Display for Attribute {
@@ -337,6 +338,7 @@ impl fmt::Display for Attribute {
Attribute::Test => write!(f, "#[test]"),
Attribute::Deprecated(None) => write!(f, "#[deprecated]"),
Attribute::Deprecated(Some(ref note)) => write!(f, r#"#[deprecated("{note}")]"#),
Attribute::Custom(ref k) => write!(f, "#[{k}]"),
}
}
}
@@ -390,6 +392,10 @@ impl Attribute {
Attribute::Deprecated(name.trim_matches('"').to_string().into())
}
["test"] => Attribute::Test,
[name] => {
validate(name)?;
Attribute::Custom(name.to_string())
}
_ => {
return Err(LexerErrorKind::MalformedFuncAttribute { span, found: word.to_owned() })
}
@@ -429,6 +435,7 @@ impl AsRef<str> for Attribute {
Attribute::Oracle(string) => string,
Attribute::Deprecated(Some(string)) => string,
Attribute::Test | Attribute::Deprecated(None) => "",
Attribute::Custom(string) => string,
}
}
}