Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
19 changes: 19 additions & 0 deletions compiler/noirc_frontend/src/ast/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use noirc_errors::Location;

use crate::{
ast::{FunctionReturnType, Ident, Param},
hir::def_map::MAIN_FUNCTION,
token::{Attributes, FunctionAttributeKind, SecondaryAttribute},
};

Expand Down Expand Up @@ -76,6 +77,24 @@ impl NoirFunction {
pub fn location(&self) -> Location {
self.def.location
}
/// Both the `#[fold]` and `#[no_predicates]` alter a function's inline type and code generation in similar ways.
/// In certain cases such as type checking (for which the following flag will be used) both attributes
/// indicate we should code generate in the same way. Thus, we unify the attributes into one flag here.
pub(crate) fn has_inline_attribute(&self) -> bool {
let attributes = self.attributes();
attributes.is_no_predicates() || attributes.is_foldable()
}
pub(crate) fn is_entry_point(&self, in_contract: bool) -> bool {
if in_contract {
self.attributes().is_contract_entry_point()
} else {
self.name() == MAIN_FUNCTION
}
}
pub(crate) fn is_test_or_fuzz(&self) -> bool {
let attributes = self.attributes();
attributes.is_test_function() || attributes.is_fuzzing_harness()
}
}

impl From<FunctionDefinition> for NoirFunction {
Expand Down
Loading
Loading