Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/mv/test-gates-diff' into mv/test…
Browse files Browse the repository at this point in the history
…-gates-diff
  • Loading branch information
vezenovm committed Apr 23, 2024
2 parents 14d449a + 432815c commit 3dcb563
Show file tree
Hide file tree
Showing 83 changed files with 1,384 additions and 633 deletions.
2 changes: 1 addition & 1 deletion acvm-repo/acir/src/circuit/brillig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub struct Brillig {
/// This is purely a wrapper struct around a list of Brillig opcode's which represents
/// a full Brillig function to be executed by the Brillig VM.
/// This is stored separately on a program and accessed through a [BrilligPointer].
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Default)]
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Default, Debug)]
pub struct BrilligBytecode {
pub bytecode: Vec<BrilligOpcode>,
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use noirc_errors::{Location, Span};
use noirc_frontend::ast::{FunctionReturnType, NoirFunction, UnresolvedTypeData};
use noirc_frontend::{
graph::CrateId,
macros_api::{FileId, HirContext},
parse_program, FunctionReturnType, NoirFunction, Type, UnresolvedTypeData,
parse_program, Type,
};

use crate::utils::{
Expand Down
5 changes: 3 additions & 2 deletions aztec_macros/src/transforms/contract_interface.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use noirc_frontend::ast::{NoirFunction, UnresolvedTypeData};
use noirc_frontend::{
graph::CrateId,
macros_api::{FileId, HirContext, HirExpression, HirLiteral, HirStatement},
parse_program,
parser::SortedModule,
NoirFunction, Type, UnresolvedTypeData,
Type,
};

use crate::utils::{
Expand Down Expand Up @@ -52,7 +53,7 @@ pub fn stub_function(aztec_visibility: &str, func: &NoirFunction) -> String {
})
.collect::<Vec<_>>()
.join(", ");
let fn_return_type: noirc_frontend::UnresolvedType = func.return_type();
let fn_return_type: noirc_frontend::ast::UnresolvedType = func.return_type();

let fn_selector = format!("dep::aztec::protocol_types::abis::function_selector::FunctionSelector::from_signature(\"{}\")", SELECTOR_PLACEHOLDER);

Expand Down
6 changes: 4 additions & 2 deletions aztec_macros/src/transforms/events.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
use iter_extended::vecmap;
use noirc_errors::Span;
use noirc_frontend::ast::{
ExpressionKind, FunctionDefinition, FunctionReturnType, ItemVisibility, Literal, NoirFunction,
Visibility,
};
use noirc_frontend::{
graph::CrateId,
macros_api::{
Expand All @@ -8,8 +12,6 @@ use noirc_frontend::{
UnresolvedTypeData,
},
token::SecondaryAttribute,
ExpressionKind, FunctionDefinition, FunctionReturnType, ItemVisibility, Literal, NoirFunction,
Visibility,
};

use crate::{
Expand Down
15 changes: 9 additions & 6 deletions aztec_macros/src/transforms/functions.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
use convert_case::{Case, Casing};
use noirc_errors::Span;
use noirc_frontend::{
macros_api::FieldElement, parse_program, BlockExpression, ConstrainKind, ConstrainStatement,
Distinctness, Expression, ExpressionKind, ForLoopStatement, ForRange, FunctionReturnType,
Ident, Literal, NoirFunction, NoirStruct, Param, PathKind, Pattern, Signedness, Statement,
StatementKind, UnresolvedType, UnresolvedTypeData, Visibility,
use noirc_frontend::ast;
use noirc_frontend::ast::{
BlockExpression, ConstrainKind, ConstrainStatement, Distinctness, Expression, ExpressionKind,
ForLoopStatement, ForRange, FunctionReturnType, Ident, Literal, NoirFunction, NoirStruct,
Param, PathKind, Pattern, Signedness, Statement, StatementKind, UnresolvedType,
UnresolvedTypeData, Visibility,
};

use noirc_frontend::{macros_api::FieldElement, parse_program};

use crate::{
chained_dep, chained_path,
utils::{
Expand Down Expand Up @@ -334,7 +337,7 @@ fn serialize_to_hasher(
&UnresolvedType {
typ: UnresolvedTypeData::Integer(
Signedness::Unsigned,
noirc_frontend::IntegerBitSize::ThirtyTwo,
ast::IntegerBitSize::ThirtyTwo,
),
span: None,
},
Expand Down
8 changes: 6 additions & 2 deletions aztec_macros/src/transforms/note_interface.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
use noirc_errors::Span;
use noirc_frontend::ast::{
ItemVisibility, LetStatement, NoirFunction, NoirStruct, PathKind, TraitImplItem, TypeImpl,
UnresolvedTypeData, UnresolvedTypeExpression,
};
use noirc_frontend::{
graph::CrateId,
macros_api::{FileId, HirContext, HirExpression, HirLiteral, HirStatement},
parse_program,
parser::SortedModule,
ItemVisibility, LetStatement, NoirFunction, NoirStruct, PathKind, TraitImplItem, Type,
TypeImpl, UnresolvedTypeData, UnresolvedTypeExpression,
Type,
};

use regex::Regex;

use crate::{
Expand Down
8 changes: 5 additions & 3 deletions aztec_macros/src/transforms/storage.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
use std::borrow::Borrow;

use noirc_errors::Span;
use noirc_frontend::ast::{
BlockExpression, Expression, ExpressionKind, FunctionDefinition, Ident, Literal, NoirFunction,
NoirStruct, PathKind, Pattern, StatementKind, TypeImpl, UnresolvedType, UnresolvedTypeData,
};
use noirc_frontend::{
graph::CrateId,
macros_api::{
Expand All @@ -10,9 +14,7 @@ use noirc_frontend::{
parse_program,
parser::SortedModule,
token::SecondaryAttribute,
BlockExpression, Expression, ExpressionKind, FunctionDefinition, Ident, Literal, NoirFunction,
NoirStruct, PathKind, Pattern, StatementKind, Type, TypeImpl, UnresolvedType,
UnresolvedTypeData,
Type,
};

use crate::{
Expand Down
11 changes: 6 additions & 5 deletions aztec_macros/src/utils/ast_utils.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use noirc_errors::{Span, Spanned};
use noirc_frontend::{
token::SecondaryAttribute, BinaryOpKind, CallExpression, CastExpression, Expression,
ExpressionKind, FunctionReturnType, Ident, IndexExpression, InfixExpression, Lambda,
LetStatement, MethodCallExpression, NoirTraitImpl, Path, Pattern, PrefixExpression, Statement,
StatementKind, TraitImplItem, UnaryOp, UnresolvedType, UnresolvedTypeData,
use noirc_frontend::ast::{
BinaryOpKind, CallExpression, CastExpression, Expression, ExpressionKind, FunctionReturnType,
Ident, IndexExpression, InfixExpression, Lambda, LetStatement, MethodCallExpression,
NoirTraitImpl, Path, Pattern, PrefixExpression, Statement, StatementKind, TraitImplItem,
UnaryOp, UnresolvedType, UnresolvedTypeData,
};
use noirc_frontend::token::SecondaryAttribute;

//
// Helper macros for creating noir ast nodes
Expand Down
9 changes: 5 additions & 4 deletions aztec_macros/src/utils/errors.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
use noirc_errors::Span;
use noirc_frontend::{macros_api::MacroError, UnresolvedTypeData};
use noirc_frontend::ast;
use noirc_frontend::macros_api::MacroError;

use super::constants::MAX_CONTRACT_PRIVATE_FUNCTIONS;

#[derive(Debug, Clone)]
pub enum AztecMacroError {
AztecDepNotFound,
ContractHasTooManyPrivateFunctions { span: Span },
UnsupportedFunctionArgumentType { span: Span, typ: UnresolvedTypeData },
UnsupportedFunctionReturnType { span: Span, typ: UnresolvedTypeData },
UnsupportedStorageType { span: Option<Span>, typ: UnresolvedTypeData },
UnsupportedFunctionArgumentType { span: Span, typ: ast::UnresolvedTypeData },
UnsupportedFunctionReturnType { span: Span, typ: ast::UnresolvedTypeData },
UnsupportedStorageType { span: Option<Span>, typ: ast::UnresolvedTypeData },
CouldNotAssignStorageSlots { secondary_message: Option<String> },
CouldNotImplementComputeNoteHashAndNullifier { secondary_message: Option<String> },
CouldNotImplementNoteInterface { span: Option<Span>, secondary_message: Option<String> },
Expand Down
13 changes: 7 additions & 6 deletions aztec_macros/src/utils/hir_utils.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use iter_extended::vecmap;
use noirc_errors::Location;
use noirc_frontend::ast;
use noirc_frontend::{
graph::CrateId,
hir::{
Expand All @@ -9,7 +10,7 @@ use noirc_frontend::{
},
macros_api::{FileId, HirContext, MacroError, ModuleDefId, StructId},
node_interner::{FuncId, TraitId},
ItemVisibility, LetStatement, NoirFunction, Shared, Signedness, StructType, Type,
Shared, StructType, Type,
};

use super::ast_utils::is_custom_attribute;
Expand Down Expand Up @@ -65,8 +66,8 @@ pub fn collect_traits(context: &HirContext) -> Vec<TraitId> {
/// Computes the aztec signature for a resolved type.
pub fn signature_of_type(typ: &Type) -> String {
match typ {
Type::Integer(Signedness::Signed, bit_size) => format!("i{}", bit_size),
Type::Integer(Signedness::Unsigned, bit_size) => format!("u{}", bit_size),
Type::Integer(ast::Signedness::Signed, bit_size) => format!("i{}", bit_size),
Type::Integer(ast::Signedness::Unsigned, bit_size) => format!("u{}", bit_size),
Type::FieldElement => "Field".to_owned(),
Type::Bool => "bool".to_owned(),
Type::Array(len, typ) => {
Expand Down Expand Up @@ -165,7 +166,7 @@ pub fn get_contract_module_data(
pub fn inject_fn(
crate_id: &CrateId,
context: &mut HirContext,
func: NoirFunction,
func: ast::NoirFunction,
location: Location,
module_id: LocalModuleId,
file_id: FileId,
Expand All @@ -179,7 +180,7 @@ pub fn inject_fn(
);

context.def_map_mut(crate_id).unwrap().modules_mut()[module_id.0]
.declare_function(func.name_ident().clone(), ItemVisibility::Public, func_id)
.declare_function(func.name_ident().clone(), ast::ItemVisibility::Public, func_id)
.map_err(|err| MacroError {
primary_message: format!("Failed to declare autogenerated {} function", func.name()),
secondary_message: Some(format!("Duplicate definition found {}", err.0)),
Expand Down Expand Up @@ -214,7 +215,7 @@ pub fn inject_fn(
pub fn inject_global(
crate_id: &CrateId,
context: &mut HirContext,
global: LetStatement,
global: ast::LetStatement,
module_id: LocalModuleId,
file_id: FileId,
) {
Expand Down
2 changes: 1 addition & 1 deletion compiler/noirc_driver/src/abi_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ use std::collections::BTreeMap;
use acvm::acir::native_types::Witness;
use iter_extended::{btree_map, vecmap};
use noirc_abi::{Abi, AbiParameter, AbiReturnType, AbiType, AbiValue};
use noirc_frontend::ast::Visibility;
use noirc_frontend::{
hir::Context,
hir_def::{expr::HirArrayLiteral, function::Param, stmt::HirPattern},
macros_api::{HirExpression, HirLiteral},
node_interner::{FuncId, NodeInterner},
Visibility,
};
use std::ops::Range;

Expand Down
5 changes: 2 additions & 3 deletions compiler/noirc_evaluator/src/ssa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ use acvm::acir::{

use noirc_errors::debug_info::{DebugFunctions, DebugInfo, DebugTypes, DebugVariables};

use noirc_frontend::{
hir_def::function::FunctionSignature, monomorphization::ast::Program, Visibility,
};
use noirc_frontend::ast::Visibility;
use noirc_frontend::{hir_def::function::FunctionSignature, monomorphization::ast::Program};
use tracing::{span, Level};

use self::{acir_gen::GeneratedAcir, ssa_gen::Ssa};
Expand Down
Loading

0 comments on commit 3dcb563

Please sign in to comment.