Skip to content

Commit

Permalink
feat: LSP document symbol (noir-lang/noir#5532)
Browse files Browse the repository at this point in the history
feat: add comptime support for `modulus_*` compiler builtins (noir-lang/noir#5530)
chore: Remove unknown annotation warning (noir-lang/noir#5531)
feat: Add TraitConstraint type (noir-lang/noir#5499)
fix: Error on empty function bodies (noir-lang/noir#5519)
feat: LSP inlay hints for let and global (noir-lang/noir#5510)
chore: Remove dbg on find_func_with_name (noir-lang/noir#5526)
chore: Remove the remainder of legacy code (noir-lang/noir#5525)
chore: Remove `--use-legacy` and resolution code (noir-lang/noir#5248)
chore: switch to Noir Keccak implementation with variable size support (noir-lang/noir#5508)
chore: standardize experimental feature disclaimer across documentation (noir-lang/noir#5367)
  • Loading branch information
AztecBot committed Jul 18, 2024
2 parents dd6d9c1 + d0e3734 commit 101f375
Show file tree
Hide file tree
Showing 10 changed files with 822 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .noir-sync-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5bbce7977f72b07336bc8ef09f6acff687f1644a
1fabcde195f3965c6b8701eb4e1fed49ec1bde4b
23 changes: 9 additions & 14 deletions noir/noir-repo/compiler/noirc_frontend/src/ast/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -800,12 +800,8 @@ impl FunctionDefinition {
return_visibility: Visibility::Private,
}
}
}

impl Display for FunctionDefinition {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
writeln!(f, "{:?}", self.attributes)?;

pub fn signature(&self) -> String {
let parameters = vecmap(&self.parameters, |Param { visibility, pattern, typ, span: _ }| {
if *visibility == Visibility::Public {
format!("{pattern}: {visibility} {typ}")
Expand All @@ -827,15 +823,14 @@ impl Display for FunctionDefinition {
format!(" -> {}", self.return_type)
};

write!(
f,
"fn {}({}){}{} {}",
self.name,
parameters.join(", "),
return_type,
where_clause_str,
self.body
)
format!("fn {}({}){}{}", self.name, parameters.join(", "), return_type, where_clause_str)
}
}

impl Display for FunctionDefinition {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
writeln!(f, "{:?}", self.attributes)?;
write!(f, "fn {} {}", self.signature(), self.body)
}
}

Expand Down
3 changes: 3 additions & 0 deletions noir/noir-repo/noir_stdlib/src/embedded_curve_ops.nr
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ fn multi_scalar_mul_array_return<let N: u32>(points: [EmbeddedCurvePoint; N], sc
#[foreign(multi_scalar_mul)]
pub(crate) fn multi_scalar_mul_slice(points: [EmbeddedCurvePoint], scalars: [EmbeddedCurveScalar]) -> [Field; 3] {}

#[foreign(multi_scalar_mul)]
pub(crate) fn multi_scalar_mul_slice(points: [EmbeddedCurvePoint], scalars: [EmbeddedCurveScalar]) -> [Field; 3] {}

// docs:start:fixed_base_scalar_mul
pub fn fixed_base_scalar_mul(scalar: EmbeddedCurveScalar) -> EmbeddedCurvePoint
// docs:end:fixed_base_scalar_mul
Expand Down
21 changes: 1 addition & 20 deletions noir/noir-repo/noir_stdlib/src/hash/mod.nr
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,7 @@ pub fn pedersen_commitment<let N: u32>(input: [Field; N]) -> EmbeddedCurvePoint
pedersen_commitment_with_separator(input, 0)
}

fn pedersen_hash_with_separator<let N: u32>(input: [Field; N], separator: u32) -> Field {
__pedersen_hash_with_separator(input, separator)
}

fn pedersen_commitment_with_separator<let N: u32>(input: [Field; N], separator: u32) -> EmbeddedCurvePoint {
let value = __pedersen_commitment_with_separator(input, separator);
if (value[0] == 0) & (value[1] == 0) {
EmbeddedCurvePoint { x: 0, y: 0, is_infinite: true }
} else {
EmbeddedCurvePoint { x: value[0], y: value[1], is_infinite: false }
}
}

fn pedersen_commitment_with_separator_noir<let N: u32>(input: [Field; N], separator: u32) -> EmbeddedCurvePoint {
let mut points = [EmbeddedCurveScalar { lo: 0, hi: 0 }; N];
for i in 0..N {
// we use the unsafe version because the multi_scalar_mul will constraint the scalars.
Expand All @@ -56,7 +43,7 @@ fn pedersen_commitment_with_separator_noir<let N: u32>(input: [Field; N], separa
multi_scalar_mul(generators, points)
}

fn pedersen_hash_with_separator_noir<let N: u32>(input: [Field; N], separator: u32) -> Field {
fn pedersen_hash_with_separator<let N: u32>(input: [Field; N], separator: u32) -> Field {
let mut scalars: Vec<EmbeddedCurveScalar> = Vec::from_slice([EmbeddedCurveScalar { lo: 0, hi: 0 }; N].as_slice()); //Vec::new();

for i in 0..N {
Expand Down Expand Up @@ -84,12 +71,6 @@ fn derive_generators<let N: u32, let M: u32>(domain_separator_bytes: [u8; M], st
__derive_generators(domain_separator_bytes, starting_index)
}

#[foreign(pedersen_hash)]
pub fn __pedersen_hash_with_separator<let N: u32>(input: [Field; N], separator: u32) -> Field {}

#[foreign(pedersen_commitment)]
fn __pedersen_commitment_with_separator<let N: u32>(input: [Field; N], separator: u32) -> [Field; 2] {}

#[builtin(derive_pedersen_generators)]
#[field(bn254)]
fn __derive_generators<let N: u32, let M: u32>(
Expand Down
14 changes: 9 additions & 5 deletions noir/noir-repo/tooling/lsp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ use async_lsp::{
use fm::{codespan_files as files, FileManager};
use fxhash::FxHashSet;
use lsp_types::{
request::{HoverRequest, InlayHintRequest, PrepareRenameRequest, References, Rename},
request::{
DocumentSymbolRequest, HoverRequest, InlayHintRequest, PrepareRenameRequest, References,
Rename,
},
CodeLens,
};
use nargo::{
Expand All @@ -45,10 +48,10 @@ use notifications::{
on_did_open_text_document, on_did_save_text_document, on_exit, on_initialized,
};
use requests::{
on_code_lens_request, on_formatting, on_goto_declaration_request, on_goto_definition_request,
on_goto_type_definition_request, on_hover_request, on_initialize, on_inlay_hint_request,
on_prepare_rename_request, on_profile_run_request, on_references_request, on_rename_request,
on_shutdown, on_test_run_request, on_tests_request,
on_code_lens_request, on_document_symbol_request, on_formatting, on_goto_declaration_request,
on_goto_definition_request, on_goto_type_definition_request, on_hover_request, on_initialize,
on_inlay_hint_request, on_prepare_rename_request, on_profile_run_request,
on_references_request, on_rename_request, on_shutdown, on_test_run_request, on_tests_request,
};
use serde_json::Value as JsonValue;
use thiserror::Error;
Expand Down Expand Up @@ -126,6 +129,7 @@ impl NargoLspService {
.request::<request::GotoDefinition, _>(on_goto_definition_request)
.request::<request::GotoDeclaration, _>(on_goto_declaration_request)
.request::<request::GotoTypeDefinition, _>(on_goto_type_definition_request)
.request::<DocumentSymbolRequest, _>(on_document_symbol_request)
.request::<References, _>(on_references_request)
.request::<PrepareRenameRequest, _>(on_prepare_rename_request)
.request::<Rename, _>(on_rename_request)
Expand Down
Loading

0 comments on commit 101f375

Please sign in to comment.