From a07d246c36c4ad6cff454cf88de657c76bb007ac Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Sat, 21 Jan 2023 16:46:29 +0000 Subject: [PATCH 001/115] add cspell.json --- cspell.json | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 cspell.json diff --git a/cspell.json b/cspell.json new file mode 100644 index 00000000000..6c42db3f79f --- /dev/null +++ b/cspell.json @@ -0,0 +1,64 @@ +{ + "version": "0.2", + "words": [ + "acvm", + "acir", + "nargo", + "tempdir", + "noirc", + "monomorphise", + "monomorphisation", + "interner", + "analyse", + "callsite", + "optimisations", + "blackbox", + "serialise", + "canonicalize", + "codegen", + "lvalue", + "vecmap", + "funcid", + "ssafunc", + "Forall", + "Signedness", + "rtype", + "optim", + "usefull", + "perfom", + "optimise", + "optimisation", + "optype", + "bitsize", + "occurences", + "curr", + "coef", + "lowlevel", + "ltype", + "otype", + "puposes", + "notequal", + "udiv", + "sdiv", + "urem", + "srem", + "nvar", + "flattenning", + "constrain", + "bsize", + "eucl", + "adress", + "igen", + "nodeobj", + "lenghts", + "conresponding", + "contrain", + "initialised", + "Barretenberg", + "cdir", + "occured", + "optimised", + "initialise", + "uninstantiated" + ] +} \ No newline at end of file From 3939bfbddc7e11b4d4250389d07bcb2cbe9f8937 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Sat, 21 Jan 2023 16:48:13 +0000 Subject: [PATCH 002/115] add cspell to CI --- .github/workflows/rust.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 05448211414..844d7a580fa 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -95,3 +95,9 @@ jobs: with: command: fmt args: --all -- --check + + spellcheck: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: streetsidesoftware/cspell-action@v2 \ No newline at end of file From cca01db0198e6fb1dffa81516c896eb517f509ec Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Sat, 21 Jan 2023 16:54:07 +0000 Subject: [PATCH 003/115] include rs, ts, js --- .github/workflows/rust.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 844d7a580fa..00ea630464a 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -100,4 +100,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: streetsidesoftware/cspell-action@v2 \ No newline at end of file + - uses: streetsidesoftware/cspell-action@v2 + - with: + files: | + **/*.{rs, ts,js} \ No newline at end of file From 957bf5c8b11e2a3f22f913e5eaf69b5ca7433e44 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Sat, 21 Jan 2023 17:07:30 +0000 Subject: [PATCH 004/115] change root directory --- .github/workflows/rust.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 00ea630464a..01ad7de7dea 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -101,6 +101,5 @@ jobs: steps: - uses: actions/checkout@v3 - uses: streetsidesoftware/cspell-action@v2 - - with: - files: | - **/*.{rs, ts,js} \ No newline at end of file + with: + root: 'crates' # Should only spellcheck files in crates/ directory \ No newline at end of file From 51418ca7bb51ffaae4eff1d643009efffcb590b5 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Sun, 22 Jan 2023 13:08:24 +0000 Subject: [PATCH 005/115] remove contrain: - A simple test to check that the CI fails when an unknown word is in the code --- cspell.json | 1 - 1 file changed, 1 deletion(-) diff --git a/cspell.json b/cspell.json index 6c42db3f79f..04d4a2cef4d 100644 --- a/cspell.json +++ b/cspell.json @@ -52,7 +52,6 @@ "nodeobj", "lenghts", "conresponding", - "contrain", "initialised", "Barretenberg", "cdir", From 404980669e6092eebb5f8cc1d6442c2235ef5fb1 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Sun, 22 Jan 2023 13:47:16 +0000 Subject: [PATCH 006/115] ci : scan all files not just changed ones for this PR --- .github/workflows/rust.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 01ad7de7dea..e2ac75b11a3 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -102,4 +102,6 @@ jobs: - uses: actions/checkout@v3 - uses: streetsidesoftware/cspell-action@v2 with: - root: 'crates' # Should only spellcheck files in crates/ directory \ No newline at end of file + files: | + **/*.{md,rs} + incremental_files_only : false From 0da2a43d61bdf3ad9d698c4fc8f11b9308c7f101 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Sun, 22 Jan 2023 14:15:08 +0000 Subject: [PATCH 007/115] update cspell.json --- cspell.json | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 110 insertions(+), 1 deletion(-) diff --git a/cspell.json b/cspell.json index 04d4a2cef4d..033de68ef0b 100644 --- a/cspell.json +++ b/cspell.json @@ -58,6 +58,115 @@ "occured", "optimised", "initialise", - "uninstantiated" + "uninstantiated", + "libomp", + "clippy", + "rustfmt", + "pkgs", + "openmp", + "nixpkgs", + "rustup", + "contrain", + "chumsky", + "tokenkind", + "idents", + "foldl", + "comptime", + "shortfield", + "longfield", + "failable", + "subexpr", + "myfunc", + "desugared", + "elems", + "bindgen", + "gloo", + "deserialises", + "plonkc", + "virtualise", + "tempfile", + "rustc", + "ARKWORKS", + "arkworks", + "Kevaundray", + "Wedderburn", + "termcolor", + "arity", + "ncrate", + "Hasher", + "injective", + "thiserror", + "Deque", + "Oshoud", + "svec", + "concatened", + "Pedersen", + "Schnorr", + "Secp", + "Merkle", + "pvalue", + "assuption", + "conditionalize", + "synchronise", + "conditionalise", + "circtuit", + "binop", + "arbitraty", + "flatened", + "conditionalised", + "vmap", + "trunc", + "charac", + "insterted", + "memorymaps", + "maxbits", + "statment", + "arithmetization", + "bitand", + "bitcount", + "subexpression", + "dunmmy", + "recursiverly", + "recognise", + "binded", + "typenames", + "smol", + "Smol", + "normalisation", + "krate", + "dont", + "Comptimes", + "typevars", + "subtyping", + "ellide", + "Foralls", + "impls", + "nondeterministically", + "typevar", + "forscope", + "Arity", + "typecheck", + "Hindley", + "Milner", + "erce", + "Peekable", + "peekable", + "analysed", + "utilise", + "hexdigit", + "grammer", + "messsages", + "Chidren", + "monomorphised", + "Monomorphiser", + "monomorphiser", + "arraylen", + "aeiou", + "struct", + "stdlib", + "Opportunties", + "sanitisation", + "preprocess", + "noirup" ] } \ No newline at end of file From d0320ce3417da8c106aade4cbb53d2f8db2a6f99 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Sun, 22 Jan 2023 14:32:00 +0000 Subject: [PATCH 008/115] Push spelling mistakes to the top of the file --- cspell.json | 109 ++++++++++++++++++++++++++-------------------------- 1 file changed, 55 insertions(+), 54 deletions(-) diff --git a/cspell.json b/cspell.json index 033de68ef0b..e951d6ee2da 100644 --- a/cspell.json +++ b/cspell.json @@ -1,19 +1,69 @@ { "version": "0.2", "words": [ + // Spelling mistakes -- This includes using the english spelling + // of words over the american spelling. + "analyse", + "monomorphise", + "monomorphisation", + "optimisations", + "serialise", + "usefull", + "perfom", + "optimise", + "optimisation", + "occurences", + "puposes", + "flattenning", + "adress", + "lenghts", + "conresponding", + "initialised", + "occured", + "optimised", + "initialise", + "contrain", + "Oshoud", + "concatened", + "assuption", + "circtuit", + "synchronise", + "conditionalise", + "arbitraty", + "flatened", + "charac", + "insterted", + "statment", + "recursiverly", + "recognise", + "normalisation", + "dont", + "Secp", + "conditionalize", + "conditionalised", + "dunmmy", + "erce", + "analysed", + "utilise", + "grammer", + "messsages", + "Chidren", + "monomorphised", + "Monomorphiser", + "monomorphiser", + "aeiou", + "Opportunties", + "sanitisation", + "ellide", + // "acvm", "acir", "nargo", "tempdir", "noirc", - "monomorphise", - "monomorphisation", "interner", - "analyse", "callsite", - "optimisations", "blackbox", - "serialise", "canonicalize", "codegen", "lvalue", @@ -24,40 +74,26 @@ "Signedness", "rtype", "optim", - "usefull", - "perfom", - "optimise", - "optimisation", "optype", "bitsize", - "occurences", "curr", "coef", "lowlevel", "ltype", "otype", - "puposes", "notequal", "udiv", "sdiv", "urem", "srem", "nvar", - "flattenning", "constrain", "bsize", "eucl", - "adress", "igen", "nodeobj", - "lenghts", - "conresponding", - "initialised", "Barretenberg", "cdir", - "occured", - "optimised", - "initialise", "uninstantiated", "libomp", "clippy", @@ -66,7 +102,6 @@ "openmp", "nixpkgs", "rustup", - "contrain", "chumsky", "tokenkind", "idents", @@ -97,48 +132,27 @@ "injective", "thiserror", "Deque", - "Oshoud", "svec", - "concatened", "Pedersen", "Schnorr", - "Secp", "Merkle", "pvalue", - "assuption", - "conditionalize", - "synchronise", - "conditionalise", - "circtuit", "binop", - "arbitraty", - "flatened", - "conditionalised", "vmap", "trunc", - "charac", - "insterted", "memorymaps", "maxbits", - "statment", "arithmetization", "bitand", "bitcount", "subexpression", - "dunmmy", - "recursiverly", - "recognise", "binded", "typenames", "smol", - "Smol", - "normalisation", "krate", - "dont", "Comptimes", "typevars", "subtyping", - "ellide", "Foralls", "impls", "nondeterministically", @@ -148,24 +162,11 @@ "typecheck", "Hindley", "Milner", - "erce", - "Peekable", "peekable", - "analysed", - "utilise", "hexdigit", - "grammer", - "messsages", - "Chidren", - "monomorphised", - "Monomorphiser", - "monomorphiser", "arraylen", - "aeiou", "struct", "stdlib", - "Opportunties", - "sanitisation", "preprocess", "noirup" ] From 1173ed66efef101707927fe9e4708e32960544b4 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 11:01:54 +0000 Subject: [PATCH 009/115] analyse(d) -> analyze(d) --- crates/noirc_driver/src/lib.rs | 6 +++--- crates/noirc_frontend/src/lexer/lexer.rs | 2 +- cspell.json | 2 -- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/crates/noirc_driver/src/lib.rs b/crates/noirc_driver/src/lib.rs index 0f97ab351ce..ec96cccd8f2 100644 --- a/crates/noirc_driver/src/lib.rs +++ b/crates/noirc_driver/src/lib.rs @@ -127,12 +127,12 @@ impl Driver { } // NOTE: Maybe build could be skipped given that now it is a pass through method. - /// Statically analyses the local crate + /// Statically analyzes the local crate pub fn check(&mut self, allow_warnings: bool) { - self.analyse_crate(allow_warnings) + self.analyze_crate(allow_warnings) } - fn analyse_crate(&mut self, allow_warnings: bool) { + fn analyze_crate(&mut self, allow_warnings: bool) { let mut errs = vec![]; CrateDefMap::collect_defs(LOCAL_CRATE, &mut self.context, &mut errs); let mut error_count = 0; diff --git a/crates/noirc_frontend/src/lexer/lexer.rs b/crates/noirc_frontend/src/lexer/lexer.rs index 63140986473..ec3049dbcb1 100644 --- a/crates/noirc_frontend/src/lexer/lexer.rs +++ b/crates/noirc_frontend/src/lexer/lexer.rs @@ -236,7 +236,7 @@ impl<'a> Lexer<'a> { // Keep checking that we are not at the EOF while let Some(peek_char) = self.peek_char() { // Then check for the predicate, if predicate matches append char and increment the cursor - // If not, return word. The next character will be analysed on the next iteration of next_token, + // If not, return word. The next character will be analyzed on the next iteration of next_token, // Which will increment the cursor if !predicate(peek_char) { return (word, start, self.position); diff --git a/cspell.json b/cspell.json index e951d6ee2da..9c11af4bd1e 100644 --- a/cspell.json +++ b/cspell.json @@ -3,7 +3,6 @@ "words": [ // Spelling mistakes -- This includes using the english spelling // of words over the american spelling. - "analyse", "monomorphise", "monomorphisation", "optimisations", @@ -43,7 +42,6 @@ "conditionalised", "dunmmy", "erce", - "analysed", "utilise", "grammer", "messsages", From e45ab79995d9f3123656f92f20b2c4a2e0a17d2c Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 11:15:11 +0000 Subject: [PATCH 010/115] monomorphis -> monomorphiz --- crates/noirc_driver/src/lib.rs | 4 +- crates/noirc_evaluator/src/lib.rs | 2 +- crates/noirc_evaluator/src/ssa/code_gen.rs | 2 +- crates/noirc_evaluator/src/ssa/context.rs | 6 +-- crates/noirc_evaluator/src/ssa/function.rs | 2 +- crates/noirc_evaluator/src/ssa/inline.rs | 2 +- crates/noirc_evaluator/src/ssa/mem.rs | 2 +- crates/noirc_evaluator/src/ssa/node.rs | 2 +- crates/noirc_frontend/src/hir_def/types.rs | 4 +- crates/noirc_frontend/src/lib.rs | 2 +- .../ast.rs | 2 +- .../mod.rs | 40 +++++++++---------- .../printer.rs | 0 crates/noirc_frontend/src/node_interner.rs | 2 +- crates/readme.md | 2 +- cspell.json | 11 +++-- 16 files changed, 42 insertions(+), 43 deletions(-) rename crates/noirc_frontend/src/{monomorphisation => monomorphization}/ast.rs (99%) rename crates/noirc_frontend/src/{monomorphisation => monomorphization}/mod.rs (96%) rename crates/noirc_frontend/src/{monomorphisation => monomorphization}/printer.rs (100%) diff --git a/crates/noirc_driver/src/lib.rs b/crates/noirc_driver/src/lib.rs index ec96cccd8f2..3de92f7c1a6 100644 --- a/crates/noirc_driver/src/lib.rs +++ b/crates/noirc_driver/src/lib.rs @@ -8,7 +8,7 @@ use noirc_evaluator::create_circuit; use noirc_frontend::graph::{CrateId, CrateName, CrateType, LOCAL_CRATE}; use noirc_frontend::hir::def_map::CrateDefMap; use noirc_frontend::hir::Context; -use noirc_frontend::monomorphisation::monomorphise; +use noirc_frontend::monomorphization::monomorphize; use serde::{Deserialize, Serialize}; use std::path::{Path, PathBuf}; @@ -187,7 +187,7 @@ impl Driver { let func_meta = self.context.def_interner.function_meta(&main_function); let abi = func_meta.into_abi(&self.context.def_interner); - let program = monomorphise(main_function, self.context.def_interner); + let program = monomorphize(main_function, self.context.def_interner); // Compile Program let circuit = match create_circuit( diff --git a/crates/noirc_evaluator/src/lib.rs b/crates/noirc_evaluator/src/lib.rs index ba98393f7cd..2bf66f17bc5 100644 --- a/crates/noirc_evaluator/src/lib.rs +++ b/crates/noirc_evaluator/src/lib.rs @@ -8,7 +8,7 @@ use acvm::Language; use errors::{RuntimeError, RuntimeErrorKind}; use iter_extended::btree_map; use noirc_abi::{AbiType, AbiVisibility}; -use noirc_frontend::monomorphisation::ast::*; +use noirc_frontend::monomorphization::ast::*; use std::collections::BTreeMap; use ssa::{code_gen::IRGenerator, node}; diff --git a/crates/noirc_evaluator/src/ssa/code_gen.rs b/crates/noirc_evaluator/src/ssa/code_gen.rs index 0e3df891aec..de645e3ab9f 100644 --- a/crates/noirc_evaluator/src/ssa/code_gen.rs +++ b/crates/noirc_evaluator/src/ssa/code_gen.rs @@ -12,7 +12,7 @@ use crate::errors; use crate::ssa::block::BlockType; use acvm::FieldElement; use iter_extended::vecmap; -use noirc_frontend::monomorphisation::ast::*; +use noirc_frontend::monomorphization::ast::*; use noirc_frontend::{BinaryOpKind, UnaryOp}; use num_bigint::BigUint; use num_traits::Zero; diff --git a/crates/noirc_evaluator/src/ssa/context.rs b/crates/noirc_evaluator/src/ssa/context.rs index 6ae4f1bd399..0b9fc267b85 100644 --- a/crates/noirc_evaluator/src/ssa/context.rs +++ b/crates/noirc_evaluator/src/ssa/context.rs @@ -15,7 +15,7 @@ use crate::ssa::node::{Mark, Node}; use crate::Evaluator; use acvm::FieldElement; use iter_extended::vecmap; -use noirc_frontend::monomorphisation::ast::{Definition, FuncId}; +use noirc_frontend::monomorphization::ast::{Definition, FuncId}; use num_bigint::BigUint; use num_traits::{One, Zero}; @@ -1113,8 +1113,8 @@ impl SsaContext { } } - pub fn convert_type(&mut self, t: &noirc_frontend::monomorphisation::ast::Type) -> ObjectType { - use noirc_frontend::monomorphisation::ast::Type; + pub fn convert_type(&mut self, t: &noirc_frontend::monomorphization::ast::Type) -> ObjectType { + use noirc_frontend::monomorphization::ast::Type; use noirc_frontend::Signedness; match t { Type::Bool => ObjectType::Boolean, diff --git a/crates/noirc_evaluator/src/ssa/function.rs b/crates/noirc_evaluator/src/ssa/function.rs index f14d2f41d12..892bf9a63fc 100644 --- a/crates/noirc_evaluator/src/ssa/function.rs +++ b/crates/noirc_evaluator/src/ssa/function.rs @@ -3,7 +3,7 @@ use std::collections::{HashMap, VecDeque}; use crate::errors::RuntimeError; use crate::ssa::node::Opcode; use iter_extended::try_vecmap; -use noirc_frontend::monomorphisation::ast::{Call, Definition, FuncId, LocalId, Type}; +use noirc_frontend::monomorphization::ast::{Call, Definition, FuncId, LocalId, Type}; use super::builtin; use super::conditional::{AssumptionId, DecisionTree, TreeBuilder}; diff --git a/crates/noirc_evaluator/src/ssa/inline.rs b/crates/noirc_evaluator/src/ssa/inline.rs index 5d6626b39da..b6ae6d9d421 100644 --- a/crates/noirc_evaluator/src/ssa/inline.rs +++ b/crates/noirc_evaluator/src/ssa/inline.rs @@ -1,6 +1,6 @@ use std::collections::{hash_map::Entry, HashMap}; -use noirc_frontend::monomorphisation::ast::FuncId; +use noirc_frontend::monomorphization::ast::FuncId; use crate::{ errors::RuntimeError, diff --git a/crates/noirc_evaluator/src/ssa/mem.rs b/crates/noirc_evaluator/src/ssa/mem.rs index 2a40d502bad..ad6550eebd5 100644 --- a/crates/noirc_evaluator/src/ssa/mem.rs +++ b/crates/noirc_evaluator/src/ssa/mem.rs @@ -2,7 +2,7 @@ use super::acir_gen::InternalVar; use super::context::SsaContext; use super::node::{self, Node, NodeId}; use acvm::FieldElement; -use noirc_frontend::monomorphisation::ast::{Definition, LocalId}; +use noirc_frontend::monomorphization::ast::{Definition, LocalId}; use num_bigint::BigUint; use num_traits::ToPrimitive; diff --git a/crates/noirc_evaluator/src/ssa/node.rs b/crates/noirc_evaluator/src/ssa/node.rs index 760eef32c1b..fcf3d55d3a1 100644 --- a/crates/noirc_evaluator/src/ssa/node.rs +++ b/crates/noirc_evaluator/src/ssa/node.rs @@ -6,7 +6,7 @@ use acvm::FieldElement; use arena; use iter_extended::vecmap; use noirc_errors::Location; -use noirc_frontend::monomorphisation::ast::{Definition, FuncId}; +use noirc_frontend::monomorphization::ast::{Definition, FuncId}; use noirc_frontend::BinaryOpKind; use num_bigint::BigUint; use num_traits::{FromPrimitive, One}; diff --git a/crates/noirc_frontend/src/hir_def/types.rs b/crates/noirc_frontend/src/hir_def/types.rs index 2f7bdd250df..268c0ad062c 100644 --- a/crates/noirc_frontend/src/hir_def/types.rs +++ b/crates/noirc_frontend/src/hir_def/types.rs @@ -211,7 +211,7 @@ pub enum Type { /// A type generic over the given type variables. /// Storing both the TypeVariableId and TypeVariable isn't necessary /// but it makes handling them both easier. The TypeVariableId should - /// never be bound over during type checking, but during monomorphisation it + /// never be bound over during type checking, but during monomorphization it /// will be and thus needs the full TypeVariable link. Forall(Generics, Box), @@ -462,7 +462,7 @@ impl Type { /// A bit of an awkward name for this function - this function returns /// true for type variables or polymorphic integers which are unbound. /// NamedGenerics will always be false as although they are bindable, - /// they shouldn't be bound over until monomorphisation. + /// they shouldn't be bound over until monomorphization. pub fn is_bindable(&self) -> bool { match self { Type::PolymorphicInteger(_, binding) | Type::TypeVariable(binding) => { diff --git a/crates/noirc_frontend/src/lib.rs b/crates/noirc_frontend/src/lib.rs index 50501b22aed..64b98c64eb3 100644 --- a/crates/noirc_frontend/src/lib.rs +++ b/crates/noirc_frontend/src/lib.rs @@ -1,7 +1,7 @@ pub mod ast; pub mod graph; pub mod lexer; -pub mod monomorphisation; +pub mod monomorphization; pub mod node_interner; pub mod parser; diff --git a/crates/noirc_frontend/src/monomorphisation/ast.rs b/crates/noirc_frontend/src/monomorphization/ast.rs similarity index 99% rename from crates/noirc_frontend/src/monomorphisation/ast.rs rename to crates/noirc_frontend/src/monomorphization/ast.rs index 47796f96bcb..7fb3e772bb5 100644 --- a/crates/noirc_frontend/src/monomorphisation/ast.rs +++ b/crates/noirc_frontend/src/monomorphization/ast.rs @@ -160,7 +160,7 @@ pub struct Function { pub return_type: Type, } -/// A monomorphised Type has all type variables removed +/// A monomorphized Type has all type variables removed #[derive(Debug, PartialEq, Eq, Clone)] pub enum Type { Field, diff --git a/crates/noirc_frontend/src/monomorphisation/mod.rs b/crates/noirc_frontend/src/monomorphization/mod.rs similarity index 96% rename from crates/noirc_frontend/src/monomorphisation/mod.rs rename to crates/noirc_frontend/src/monomorphization/mod.rs index d20a520c4f6..53ff7809344 100644 --- a/crates/noirc_frontend/src/monomorphisation/mod.rs +++ b/crates/noirc_frontend/src/monomorphization/mod.rs @@ -18,14 +18,14 @@ use self::ast::{Definition, FuncId, Function, LocalId, Program}; pub mod ast; pub mod printer; -struct Monomorphiser { - // Store monomorphised globals and locals separately, - // only locals are cleared on each function call and only globals are monomorphised. +struct Monomorphizer { + // Store monomorphized globals and locals separately, + // only locals are cleared on each function call and only globals are monomorphized. // Nested HashMaps in globals lets us avoid cloning HirTypes when calling .get() globals: HashMap>, locals: HashMap, - /// Queue of functions to monomorphise next + /// Queue of functions to monomorphize next queue: VecDeque<(node_interner::FuncId, FuncId, TypeBindings)>, finished_functions: BTreeMap, @@ -38,26 +38,26 @@ struct Monomorphiser { type HirType = crate::Type; -pub fn monomorphise(main: node_interner::FuncId, interner: NodeInterner) -> Program { - let mut monomorphiser = Monomorphiser::new(interner); - let abi = monomorphiser.compile_main(main); +pub fn monomorphize(main: node_interner::FuncId, interner: NodeInterner) -> Program { + let mut monomorphizer = Monomorphizer::new(interner); + let abi = monomorphizer.compile_main(main); - while !monomorphiser.queue.is_empty() { - let (next_fn_id, new_id, bindings) = monomorphiser.queue.pop_front().unwrap(); - monomorphiser.locals.clear(); + while !monomorphizer.queue.is_empty() { + let (next_fn_id, new_id, bindings) = monomorphizer.queue.pop_front().unwrap(); + monomorphizer.locals.clear(); perform_instantiation_bindings(&bindings); - monomorphiser.function(next_fn_id, new_id); + monomorphizer.function(next_fn_id, new_id); undo_instantiation_bindings(bindings); } - let functions = vecmap(monomorphiser.finished_functions, |(_, f)| f); + let functions = vecmap(monomorphizer.finished_functions, |(_, f)| f); Program::new(functions, abi) } -impl Monomorphiser { - fn new(interner: NodeInterner) -> Monomorphiser { - Monomorphiser { +impl Monomorphizer { + fn new(interner: NodeInterner) -> Monomorphizer { + Monomorphizer { globals: HashMap::new(), locals: HashMap::new(), queue: VecDeque::new(), @@ -94,7 +94,7 @@ impl Monomorphiser { match self.globals.get(&id).and_then(|inner_map| inner_map.get(&typ)) { Some(id) => Definition::Function(*id), None => { - // Function has not been monomorphised yet + // Function has not been monomorphized yet let meta = self.interner.function_meta(&id); match meta.kind { FunctionKind::LowLevel => { @@ -192,7 +192,7 @@ impl Monomorphiser { assert!(existing.is_none()); } - /// Monomorphise each parameter, expanding tuple/struct patterns into multiple parameters + /// Monomorphize each parameter, expanding tuple/struct patterns into multiple parameters /// and binding any generic types found. fn parameters(&mut self, params: Parameters) -> Vec<(ast::LocalId, bool, String, ast::Type)> { let mut new_params = Vec::with_capacity(params.len()); @@ -499,7 +499,7 @@ impl Monomorphiser { } } - /// Convert a non-tuple/struct type to a monomorphised type + /// Convert a non-tuple/struct type to a monomorphized type fn convert_type(typ: &HirType) -> ast::Type { match typ { HirType::FieldElement(_) => ast::Type::Field, @@ -660,9 +660,9 @@ impl Monomorphiser { /// Follow any type variable links within the given TypeBindings to produce /// a new TypeBindings that won't be changed when bindings are pushed or popped - /// during {perform,undo}_monomorphisation_bindings. + /// during {perform,undo}_monomorphization_bindings. /// - /// Without this, a monomorphised type may fail to propagate passed more than 2 + /// Without this, a monomorphized type may fail to propagate passed more than 2 /// function calls deep since it is possible for a previous link in the chain to /// unbind a type variable that was previously bound. fn follow_bindings(&self, bindings: &TypeBindings) -> TypeBindings { diff --git a/crates/noirc_frontend/src/monomorphisation/printer.rs b/crates/noirc_frontend/src/monomorphization/printer.rs similarity index 100% rename from crates/noirc_frontend/src/monomorphisation/printer.rs rename to crates/noirc_frontend/src/monomorphization/printer.rs diff --git a/crates/noirc_frontend/src/node_interner.rs b/crates/noirc_frontend/src/node_interner.rs index 5b1c5aa2efb..847e7d96a99 100644 --- a/crates/noirc_frontend/src/node_interner.rs +++ b/crates/noirc_frontend/src/node_interner.rs @@ -152,7 +152,7 @@ pub struct NodeInterner { structs: HashMap>, /// Map from ExprId (referring to a Function/Method call) to its corresponding TypeBindings, - /// filled out during type checking from instantiated variables. Used during monomorphisation + /// filled out during type checking from instantiated variables. Used during monomorphization /// to map callsite types back onto function parameter types, and undo this binding as needed. instantiation_bindings: HashMap, diff --git a/crates/readme.md b/crates/readme.md index d51643891dc..6e1d6efc9f8 100644 --- a/crates/readme.md +++ b/crates/readme.md @@ -37,7 +37,7 @@ This crate can be seen as the middle end. It is in charge of generating the ACIR ## noirc_frontend -This crate comprises of the first few compiler passes that together we denote as the compiler frontend (in order): lexing, parsing, name resolution, type checking, and monomorphisation. If any of these passes error, the resulting monomorphised AST will not be passed to the middle-end (noirc_evaluator) +This crate comprises of the first few compiler passes that together we denote as the compiler frontend (in order): lexing, parsing, name resolution, type checking, and monomorphization. If any of these passes error, the resulting monomorphized AST will not be passed to the middle-end (noirc_evaluator) ## wasm diff --git a/cspell.json b/cspell.json index 9c11af4bd1e..cd9244135b0 100644 --- a/cspell.json +++ b/cspell.json @@ -3,8 +3,6 @@ "words": [ // Spelling mistakes -- This includes using the english spelling // of words over the american spelling. - "monomorphise", - "monomorphisation", "optimisations", "serialise", "usefull", @@ -46,9 +44,6 @@ "grammer", "messsages", "Chidren", - "monomorphised", - "Monomorphiser", - "monomorphiser", "aeiou", "Opportunties", "sanitisation", @@ -166,6 +161,10 @@ "struct", "stdlib", "preprocess", - "noirup" + "noirup", + "monomorphization", + "monomorphized", + "monomorphize", + "monomorphizer" ] } \ No newline at end of file From 55fd09fa671e6c4bc2d7d471bd0d2fd762591359 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 11:16:54 +0000 Subject: [PATCH 011/115] optimis -> optimiz --- crates/nargo/tests/test_data/range_fail/src/main.nr | 2 +- crates/noirc_evaluator/src/lib.rs | 8 ++++---- crates/noirc_evaluator/src/ssa/acir_gen.rs | 2 +- crates/noirc_evaluator/src/ssa/conditional.rs | 2 +- crates/noirc_evaluator/src/ssa/context.rs | 4 ++-- crates/noirc_evaluator/src/ssa/function.rs | 2 +- crates/noirc_evaluator/src/ssa/integer.rs | 6 +++--- cspell.json | 4 ---- 8 files changed, 13 insertions(+), 17 deletions(-) diff --git a/crates/nargo/tests/test_data/range_fail/src/main.nr b/crates/nargo/tests/test_data/range_fail/src/main.nr index 51fb073e27c..4535c5d9e5f 100644 --- a/crates/nargo/tests/test_data/range_fail/src/main.nr +++ b/crates/nargo/tests/test_data/range_fail/src/main.nr @@ -1,6 +1,6 @@ // Multiple integers constraints. // -// There is currently no range optimiser currently in ACIR :( +// There is currently no range optimizer currently in ACIR :( // fn main(x: u8, y: Field) { let _z = x + (y as u8); diff --git a/crates/noirc_evaluator/src/lib.rs b/crates/noirc_evaluator/src/lib.rs index 2bf66f17bc5..0c9aff657d5 100644 --- a/crates/noirc_evaluator/src/lib.rs +++ b/crates/noirc_evaluator/src/lib.rs @@ -24,9 +24,9 @@ pub struct Evaluator { opcodes: Vec, } -/// Compiles the Program into ACIR and applies optimisations to the arithmetic gates +/// Compiles the Program into ACIR and applies optimizations to the arithmetic gates // XXX: We return the num_witnesses, but this is the max number of witnesses -// Some of these could have been removed due to optimisations. We need this number because the +// Some of these could have been removed due to optimizations. We need this number because the // Standard format requires the number of witnesses. The max number is also fine. // If we had a composer object, we would not need it pub fn create_circuit( @@ -42,7 +42,7 @@ pub fn create_circuit( let witness_index = evaluator.current_witness_index(); - let optimised_circuit = acvm::compiler::compile( + let optimized_circuit = acvm::compiler::compile( Circuit { current_witness_index: witness_index, opcodes: evaluator.opcodes, @@ -53,7 +53,7 @@ pub fn create_circuit( ) .map_err(|_| RuntimeErrorKind::Spanless(String::from("produced an acvm compile error")))?; - Ok(optimised_circuit) + Ok(optimized_circuit) } impl Evaluator { diff --git a/crates/noirc_evaluator/src/ssa/acir_gen.rs b/crates/noirc_evaluator/src/ssa/acir_gen.rs index 679bf4de86c..84528ba683b 100644 --- a/crates/noirc_evaluator/src/ssa/acir_gen.rs +++ b/crates/noirc_evaluator/src/ssa/acir_gen.rs @@ -1079,7 +1079,7 @@ pub fn mul(a: &Expression, b: &Expression) -> Expression { let mut output = Expression::from_field(a.q_c * b.q_c); - //TODO to optimise... + //TODO to optimize... for lc in &a.linear_combinations { let single = single_mul(lc.1, b); output = add(&output, lc.0, &single); diff --git a/crates/noirc_evaluator/src/ssa/conditional.rs b/crates/noirc_evaluator/src/ssa/conditional.rs index df30bf5e8cf..58052d6d295 100644 --- a/crates/noirc_evaluator/src/ssa/conditional.rs +++ b/crates/noirc_evaluator/src/ssa/conditional.rs @@ -338,7 +338,7 @@ impl DecisionTree { if_block_id: BlockId, exit_block_id: BlockId, ) -> Result<(), RuntimeError> { - //basic reduction as a first step (i.e no optimisation) + //basic reduction as a first step (i.e no optimization) let if_block = &ctx[if_block_id]; let mut to_remove = Vec::new(); let left = if_block.left.unwrap(); diff --git a/crates/noirc_evaluator/src/ssa/context.rs b/crates/noirc_evaluator/src/ssa/context.rs index 0b9fc267b85..ffcec35d677 100644 --- a/crates/noirc_evaluator/src/ssa/context.rs +++ b/crates/noirc_evaluator/src/ssa/context.rs @@ -689,7 +689,7 @@ impl SsaContext { } } - //Optimise, flatten and truncate IR and then generates ACIR representation from it + //Optimize, flatten and truncate IR and then generates ACIR representation from it pub fn ir_to_acir( &mut self, evaluator: &mut Evaluator, @@ -699,7 +699,7 @@ impl SsaContext { self.log(enable_logging, "SSA:", "\ninline functions"); function::inline_all(self)?; - //Optimisation + //Optimization block::compute_dom(self); optim::full_cse(self, self.first_block, false)?; diff --git a/crates/noirc_evaluator/src/ssa/function.rs b/crates/noirc_evaluator/src/ssa/function.rs index 892bf9a63fc..230dd182e67 100644 --- a/crates/noirc_evaluator/src/ssa/function.rs +++ b/crates/noirc_evaluator/src/ssa/function.rs @@ -64,7 +64,7 @@ impl SSAFunction { pub fn compile(&self, igen: &mut IRGenerator) -> Result { let function_cfg = block::bfs(self.entry_block, None, &igen.context); block::compute_sub_dom(&mut igen.context, &function_cfg); - //Optimisation + //Optimization //catch the error because the function may not be called super::optim::full_cse(&mut igen.context, self.entry_block, false)?; //Unrolling diff --git a/crates/noirc_evaluator/src/ssa/integer.rs b/crates/noirc_evaluator/src/ssa/integer.rs index ed4945dcbfc..7de51693ef8 100644 --- a/crates/noirc_evaluator/src/ssa/integer.rs +++ b/crates/noirc_evaluator/src/ssa/integer.rs @@ -261,7 +261,7 @@ fn block_overflow( get_value_from_map(id, &value_map) }); - //we propagate optimised loads - todo check if it is needed because there is cse at the end + //we propagate optimized loads - todo check if it is needed because there is cse at the end //We retrieve get_current_value() in case a previous truncate has updated the value map let should_truncate_ins = ins.truncate_required(ctx); let ins_max_bits = get_instruction_max(ctx, &ins, max_map, &value_map).bits(); @@ -284,14 +284,14 @@ fn block_overflow( match ins.operation { Operation::Load { array_id, index } => { if let Some(val) = ctx.get_indexed_value(array_id, index) { - //optimise static load + //optimize static load ins.mark = Mark::ReplaceWith(*val); } } Operation::Store { array_id, index, value } => { if let Some(idx) = Memory::to_u32(ctx, index) { let absolute_adr = ctx.mem[array_id].absolute_adr(idx); - //optimise static store + //optimize static store memory_map.insert(absolute_adr, value); } } diff --git a/cspell.json b/cspell.json index cd9244135b0..50bc29231a2 100644 --- a/cspell.json +++ b/cspell.json @@ -3,12 +3,9 @@ "words": [ // Spelling mistakes -- This includes using the english spelling // of words over the american spelling. - "optimisations", "serialise", "usefull", "perfom", - "optimise", - "optimisation", "occurences", "puposes", "flattenning", @@ -17,7 +14,6 @@ "conresponding", "initialised", "occured", - "optimised", "initialise", "contrain", "Oshoud", From efcdbffde84dbc55e868bf67953c5642577fdda7 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 11:19:10 +0000 Subject: [PATCH 012/115] serialis -> serializ --- crates/nargo/src/cli/mod.rs | 2 +- crates/noirc_abi/src/input_parser/mod.rs | 4 ++-- crates/noirc_abi/src/input_parser/toml.rs | 2 +- crates/wasm/src/lib.rs | 2 +- cspell.json | 2 -- 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/crates/nargo/src/cli/mod.rs b/crates/nargo/src/cli/mod.rs index 269acbfbf6a..bea92e5788d 100644 --- a/crates/nargo/src/cli/mod.rs +++ b/crates/nargo/src/cli/mod.rs @@ -169,7 +169,7 @@ fn write_inputs_to_file>( dir_path }; - let serialized_output = format.serialise(w_map)?; + let serialized_output = format.serialize(w_map)?; write_to_file(serialized_output.as_bytes(), &file_path); Ok(()) diff --git a/crates/noirc_abi/src/input_parser/mod.rs b/crates/noirc_abi/src/input_parser/mod.rs index afaab0a2e15..680aef950e8 100644 --- a/crates/noirc_abi/src/input_parser/mod.rs +++ b/crates/noirc_abi/src/input_parser/mod.rs @@ -97,12 +97,12 @@ impl Format { } } - pub fn serialise( + pub fn serialize( &self, w_map: &BTreeMap, ) -> Result { match self { - Format::Toml => toml::serialise_to_toml(w_map), + Format::Toml => toml::serialize_to_toml(w_map), } } } diff --git a/crates/noirc_abi/src/input_parser/toml.rs b/crates/noirc_abi/src/input_parser/toml.rs index 069658ce7be..4ffff7c76e7 100644 --- a/crates/noirc_abi/src/input_parser/toml.rs +++ b/crates/noirc_abi/src/input_parser/toml.rs @@ -24,7 +24,7 @@ pub(crate) fn parse_toml( }) } -pub(crate) fn serialise_to_toml( +pub(crate) fn serialize_to_toml( w_map: &BTreeMap, ) -> Result { // Toml requires that values be emitted before tables. Thus, we must reorder our map in case a TomlTypes::Table comes before any other values in the toml map diff --git a/crates/wasm/src/lib.rs b/crates/wasm/src/lib.rs index 84390074188..da1394f79cb 100644 --- a/crates/wasm/src/lib.rs +++ b/crates/wasm/src/lib.rs @@ -13,7 +13,7 @@ pub fn compile(src: String) -> JsValue { let compiled_program = noirc_driver::Driver::compile_file(path, language); ::from_serde(&compiled_program).unwrap() } -// Deserialises bytes into ACIR structure +// Deserializes bytes into ACIR structure #[wasm_bindgen] pub fn acir_from_bytes(bytes: Vec) -> JsValue { console_error_panic_hook::set_once(); diff --git a/cspell.json b/cspell.json index 50bc29231a2..7bbba8ba6fe 100644 --- a/cspell.json +++ b/cspell.json @@ -3,7 +3,6 @@ "words": [ // Spelling mistakes -- This includes using the english spelling // of words over the american spelling. - "serialise", "usefull", "perfom", "occurences", @@ -105,7 +104,6 @@ "elems", "bindgen", "gloo", - "deserialises", "plonkc", "virtualise", "tempfile", From 48cac36c880ac15d383ea75072e3623ae067ff4c Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 11:20:36 +0000 Subject: [PATCH 013/115] usefull -> useful --- crates/noirc_evaluator/src/ssa/context.rs | 2 +- crates/noirc_evaluator/src/ssa/node.rs | 2 +- cspell.json | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/context.rs b/crates/noirc_evaluator/src/ssa/context.rs index ffcec35d677..3a1b3b7e2d4 100644 --- a/crates/noirc_evaluator/src/ssa/context.rs +++ b/crates/noirc_evaluator/src/ssa/context.rs @@ -761,7 +761,7 @@ impl SsaContext { } pub fn generate_empty_phi(&mut self, target_block: BlockId, phi_root: NodeId) -> NodeId { - //Ensure there is not already a phi for the variable (n.b. probably not usefull) + //Ensure there is not already a phi for the variable (n.b. probably not useful) for i in &self[target_block].instructions { match self.try_get_instruction(*i) { Some(Instruction { operation: Operation::Phi { root, .. }, .. }) diff --git a/crates/noirc_evaluator/src/ssa/node.rs b/crates/noirc_evaluator/src/ssa/node.rs index fcf3d55d3a1..63a921355ae 100644 --- a/crates/noirc_evaluator/src/ssa/node.rs +++ b/crates/noirc_evaluator/src/ssa/node.rs @@ -532,7 +532,7 @@ pub enum Operation { value: NodeId, }, - Intrinsic(builtin::Opcode, Vec), //Custom implementation of usefull primitives which are more performant with Aztec backend + Intrinsic(builtin::Opcode, Vec), //Custom implementation of useful primitives which are more performant with Aztec backend Nop, // no op } diff --git a/cspell.json b/cspell.json index 7bbba8ba6fe..cb83ae29601 100644 --- a/cspell.json +++ b/cspell.json @@ -3,7 +3,6 @@ "words": [ // Spelling mistakes -- This includes using the english spelling // of words over the american spelling. - "usefull", "perfom", "occurences", "puposes", From fd1e00470dced5b7d5c91a405ae87c0bc830c683 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 11:21:20 +0000 Subject: [PATCH 014/115] perfom -> perform --- crates/noirc_evaluator/src/ssa/context.rs | 2 +- cspell.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/context.rs b/crates/noirc_evaluator/src/ssa/context.rs index 3a1b3b7e2d4..078d5a9f9c6 100644 --- a/crates/noirc_evaluator/src/ssa/context.rs +++ b/crates/noirc_evaluator/src/ssa/context.rs @@ -812,7 +812,7 @@ impl SsaContext { // For instance: // - if lhs and rhs are standard variables, we create a new ssa variable of lhs // - if lhs is an array element, we generate a store instruction - // - if lhs and rhs are arrays, we perfom a copy of rhs into lhs, + // - if lhs and rhs are arrays, we perform a copy of rhs into lhs, // - if lhs is an array and rhs is a call instruction, we indicate in the call that lhs is the returned array (so that no copy is needed because the inlining will use it) // ... pub fn handle_assign( diff --git a/cspell.json b/cspell.json index cb83ae29601..25ffa114f10 100644 --- a/cspell.json +++ b/cspell.json @@ -3,7 +3,6 @@ "words": [ // Spelling mistakes -- This includes using the english spelling // of words over the american spelling. - "perfom", "occurences", "puposes", "flattenning", From 9305425ebdacaeff851fee0c209bf83f84726382 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 11:22:49 +0000 Subject: [PATCH 015/115] occurences -> occurrences --- crates/nargo/src/cli/mod.rs | 2 +- cspell.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/nargo/src/cli/mod.rs b/crates/nargo/src/cli/mod.rs index bea92e5788d..01299a408ae 100644 --- a/crates/nargo/src/cli/mod.rs +++ b/crates/nargo/src/cli/mod.rs @@ -88,7 +88,7 @@ pub fn start_cli() { ) .subcommand( App::new("gates") - .about("Counts the occurences of different gates in circuit") + .about("Counts the occurrences of different gates in circuit") .arg(show_ssa) .arg(allow_warnings), ) diff --git a/cspell.json b/cspell.json index 25ffa114f10..9e411ae792a 100644 --- a/cspell.json +++ b/cspell.json @@ -3,7 +3,6 @@ "words": [ // Spelling mistakes -- This includes using the english spelling // of words over the american spelling. - "occurences", "puposes", "flattenning", "adress", From a2e6b1345b32bb713c32fa5c4214427e73d4ff38 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 11:34:20 +0000 Subject: [PATCH 016/115] puposes -> purposes --- crates/noirc_evaluator/src/ssa/context.rs | 2 +- cspell.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/context.rs b/crates/noirc_evaluator/src/ssa/context.rs index 078d5a9f9c6..73a4ccfa2c1 100644 --- a/crates/noirc_evaluator/src/ssa/context.rs +++ b/crates/noirc_evaluator/src/ssa/context.rs @@ -142,7 +142,7 @@ impl SsaContext { block } - //Display an object for debugging puposes + //Display an object for debugging purposes fn id_to_string(&self, id: NodeId) -> String { let mut result = String::new(); if let Some(var) = self.try_get_node(id) { diff --git a/cspell.json b/cspell.json index 9e411ae792a..74c5e6401d1 100644 --- a/cspell.json +++ b/cspell.json @@ -3,7 +3,6 @@ "words": [ // Spelling mistakes -- This includes using the english spelling // of words over the american spelling. - "puposes", "flattenning", "adress", "lenghts", From 9f629d0614b755aa11944d6e6249a201effefc0d Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 11:35:51 +0000 Subject: [PATCH 017/115] flattenning -> flattening --- crates/noirc_evaluator/src/ssa/context.rs | 2 +- cspell.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/context.rs b/crates/noirc_evaluator/src/ssa/context.rs index 73a4ccfa2c1..f92276fceee 100644 --- a/crates/noirc_evaluator/src/ssa/context.rs +++ b/crates/noirc_evaluator/src/ssa/context.rs @@ -703,7 +703,7 @@ impl SsaContext { block::compute_dom(self); optim::full_cse(self, self.first_block, false)?; - //Flattenning + //flattening self.log(enable_logging, "\nCSE:", "\nunrolling:"); //Unrolling flatten::unroll_tree(self, self.first_block)?; diff --git a/cspell.json b/cspell.json index 74c5e6401d1..8fe09bd440f 100644 --- a/cspell.json +++ b/cspell.json @@ -3,7 +3,6 @@ "words": [ // Spelling mistakes -- This includes using the english spelling // of words over the american spelling. - "flattenning", "adress", "lenghts", "conresponding", From 934434d8b85d5ad05e80ba0d64c9840a4c972335 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 11:37:00 +0000 Subject: [PATCH 018/115] adress -> address --- crates/noirc_evaluator/src/ssa/acir_gen.rs | 2 +- crates/noirc_evaluator/src/ssa/mem.rs | 2 +- cspell.json | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/acir_gen.rs b/crates/noirc_evaluator/src/ssa/acir_gen.rs index 84528ba683b..d395299d010 100644 --- a/crates/noirc_evaluator/src/ssa/acir_gen.rs +++ b/crates/noirc_evaluator/src/ssa/acir_gen.rs @@ -25,7 +25,7 @@ use num_bigint::BigUint; #[derive(Default)] pub struct Acir { pub arith_cache: HashMap, - pub memory_map: HashMap, //maps memory adress to expression + pub memory_map: HashMap, //maps memory address to expression } #[derive(Default, Clone, Debug)] diff --git a/crates/noirc_evaluator/src/ssa/mem.rs b/crates/noirc_evaluator/src/ssa/mem.rs index ad6550eebd5..abce89ca434 100644 --- a/crates/noirc_evaluator/src/ssa/mem.rs +++ b/crates/noirc_evaluator/src/ssa/mem.rs @@ -13,7 +13,7 @@ use std::convert::TryInto; pub struct Memory { arrays: Vec, pub last_adr: u32, //last address in 'memory' - pub memory_map: HashMap, //maps memory adress to expression + pub memory_map: HashMap, //maps memory address to expression } #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] diff --git a/cspell.json b/cspell.json index 8fe09bd440f..6b6cca49f0d 100644 --- a/cspell.json +++ b/cspell.json @@ -3,7 +3,6 @@ "words": [ // Spelling mistakes -- This includes using the english spelling // of words over the american spelling. - "adress", "lenghts", "conresponding", "initialised", From fe66b0fcb46f0a97a8491c08cbbd6e66b240a33a Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 11:38:03 +0000 Subject: [PATCH 019/115] lenghts -> lengths --- crates/noirc_evaluator/src/ssa/acir_gen.rs | 2 +- cspell.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/acir_gen.rs b/crates/noirc_evaluator/src/ssa/acir_gen.rs index d395299d010..6dfc2a0f7e9 100644 --- a/crates/noirc_evaluator/src/ssa/acir_gen.rs +++ b/crates/noirc_evaluator/src/ssa/acir_gen.rs @@ -483,7 +483,7 @@ impl Acir { } //Generates gates for the expression: \sum_i(zero_eq(A[i]-B[i])) - //N.b. We assumes the lenghts of a and b are the same but it is not checked inside the function. + //N.b. We assumes the lengths of a and b are the same but it is not checked inside the function. fn zero_eq_array_sum( &mut self, a: &MemArray, diff --git a/cspell.json b/cspell.json index 6b6cca49f0d..a8c0b51d257 100644 --- a/cspell.json +++ b/cspell.json @@ -3,7 +3,6 @@ "words": [ // Spelling mistakes -- This includes using the english spelling // of words over the american spelling. - "lenghts", "conresponding", "initialised", "occured", From e7dac2c04cc91dbe0f901718f4354a12cfeb5ba6 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 11:40:14 +0000 Subject: [PATCH 020/115] conresponding -> corresponding --- crates/noirc_evaluator/src/ssa/context.rs | 2 +- cspell.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/context.rs b/crates/noirc_evaluator/src/ssa/context.rs index f92276fceee..5d117762118 100644 --- a/crates/noirc_evaluator/src/ssa/context.rs +++ b/crates/noirc_evaluator/src/ssa/context.rs @@ -588,7 +588,7 @@ impl SsaContext { None } - // Retrieve the object conresponding to the const value given in argument + // Retrieve the object corresponding to the const value given in argument // If such object does not exist, we create one pub fn get_or_create_const(&mut self, x: FieldElement, t: node::ObjectType) -> NodeId { let value = BigUint::from_bytes_be(&x.to_be_bytes()); diff --git a/cspell.json b/cspell.json index a8c0b51d257..b5b1ff8dd88 100644 --- a/cspell.json +++ b/cspell.json @@ -3,7 +3,6 @@ "words": [ // Spelling mistakes -- This includes using the english spelling // of words over the american spelling. - "conresponding", "initialised", "occured", "initialise", From d6bc8dd74543a0b09611a0c318c39f5d4d7f4e25 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 11:41:17 +0000 Subject: [PATCH 021/115] initialis -> initializ --- crates/noirc_evaluator/src/ssa/acir_gen.rs | 2 +- crates/noirc_evaluator/src/ssa/context.rs | 2 +- cspell.json | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/acir_gen.rs b/crates/noirc_evaluator/src/ssa/acir_gen.rs index 6dfc2a0f7e9..ec54c5aff9e 100644 --- a/crates/noirc_evaluator/src/ssa/acir_gen.rs +++ b/crates/noirc_evaluator/src/ssa/acir_gen.rs @@ -213,7 +213,7 @@ impl Acir { if self.memory_map.contains_key(&absolute_adr) { InternalVar::from(self.memory_map[&absolute_adr].expression.clone()) } else { - //if not found, then it must be a witness (else it is non-initialised memory) + //if not found, then it must be a witness (else it is non-initialized memory) let index = idx as usize; if mem_array.values.len() > index { mem_array.values[index].clone() diff --git a/crates/noirc_evaluator/src/ssa/context.rs b/crates/noirc_evaluator/src/ssa/context.rs index 5d117762118..4893ca46d51 100644 --- a/crates/noirc_evaluator/src/ssa/context.rs +++ b/crates/noirc_evaluator/src/ssa/context.rs @@ -844,7 +844,7 @@ impl SsaContext { }) = self.try_get_mut_instruction(func) { returned_arrays.push((a, idx)); - //Issue #579: we initialise the array, unless it is also in arguments in which case it is already initialised. + //Issue #579: we initialize the array, unless it is also in arguments in which case it is already initialized. let mut init = false; for i in arguments.clone() { if let ObjectType::Pointer(b) = self.get_object_type(i) { diff --git a/cspell.json b/cspell.json index b5b1ff8dd88..e354eb002c1 100644 --- a/cspell.json +++ b/cspell.json @@ -3,9 +3,7 @@ "words": [ // Spelling mistakes -- This includes using the english spelling // of words over the american spelling. - "initialised", "occured", - "initialise", "contrain", "Oshoud", "concatened", From 321cf7b254ad4085430489194f3179bc8a3b2924 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 11:42:33 +0000 Subject: [PATCH 022/115] occured -> occurred --- crates/nargo/tests/prove_and_verify.rs | 2 +- cspell.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/nargo/tests/prove_and_verify.rs b/crates/nargo/tests/prove_and_verify.rs index e0d43139107..382a2ca22b3 100644 --- a/crates/nargo/tests/prove_and_verify.rs +++ b/crates/nargo/tests/prove_and_verify.rs @@ -51,7 +51,7 @@ mod tests { let r = match verified { Ok(result) => result, Err(_) => { - panic!("\n\n\nPanic occured while running test {:?} (ignore the following panic)", c.file_name()); + panic!("\n\n\nPanic occurred while running test {:?} (ignore the following panic)", c.file_name()); } }; diff --git a/cspell.json b/cspell.json index e354eb002c1..a11340219e3 100644 --- a/cspell.json +++ b/cspell.json @@ -3,7 +3,6 @@ "words": [ // Spelling mistakes -- This includes using the english spelling // of words over the american spelling. - "occured", "contrain", "Oshoud", "concatened", From 2d0bf1126d3a749c2622df0bcf35021cd2212cc9 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 11:44:04 +0000 Subject: [PATCH 023/115] contrain -> constrain --- crates/noirc_evaluator/src/ssa/acir_gen.rs | 2 +- crates/noirc_evaluator/src/ssa/integer.rs | 2 +- cspell.json | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/acir_gen.rs b/crates/noirc_evaluator/src/ssa/acir_gen.rs index ec54c5aff9e..bd6040c045f 100644 --- a/crates/noirc_evaluator/src/ssa/acir_gen.rs +++ b/crates/noirc_evaluator/src/ssa/acir_gen.rs @@ -1247,7 +1247,7 @@ pub fn boolean_expr(expr: &Expression, evaluator: &mut Evaluator) -> Expression subtract(&mul_with_witness(evaluator, expr, expr), FieldElement::one(), expr) } -//contrain witness a to be num_bits-size integer, i.e between 0 and 2^num_bits-1 +//constrain witness a to be num_bits-size integer, i.e between 0 and 2^num_bits-1 pub fn range_constraint( witness: Witness, num_bits: u32, diff --git a/crates/noirc_evaluator/src/ssa/integer.rs b/crates/noirc_evaluator/src/ssa/integer.rs index 7de51693ef8..12756ba2222 100644 --- a/crates/noirc_evaluator/src/ssa/integer.rs +++ b/crates/noirc_evaluator/src/ssa/integer.rs @@ -65,7 +65,7 @@ fn get_instruction_max_operand( get_max_value(ins, max_map) } // Operation::Constrain(_) => { - //ContrainOp::Eq : + //ConstrainOp::Eq : //TODO... we should update the max_map AFTER the truncate is processed (else it breaks it) // let min = BigUint::min(left_max.clone(), right_max.clone()); // max_map.insert(ins.lhs, min.clone()); diff --git a/cspell.json b/cspell.json index a11340219e3..3c1a56ab263 100644 --- a/cspell.json +++ b/cspell.json @@ -3,7 +3,6 @@ "words": [ // Spelling mistakes -- This includes using the english spelling // of words over the american spelling. - "contrain", "Oshoud", "concatened", "assuption", From 82d5fa00130cef65ecbabe825934f16ccd50a3bb Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 11:49:15 +0000 Subject: [PATCH 024/115] Oshoud -> fix comment --- crates/noirc_evaluator/src/ssa/block.rs | 2 +- cspell.json | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/block.rs b/crates/noirc_evaluator/src/ssa/block.rs index 834cafe1038..453254027fb 100644 --- a/crates/noirc_evaluator/src/ssa/block.rs +++ b/crates/noirc_evaluator/src/ssa/block.rs @@ -226,7 +226,7 @@ pub fn link_with_target( if let Some(target_block) = ctx.try_get_block_mut(target) { target_block.right = right; target_block.left = left; - //TODO should also update the last instruction rhs to the first instruction of the current block -- TODOshoud we do it here?? + //TODO should also update the last instruction rhs to the first instruction of the current block -- TODO should we do it here?? if let Some(right_uw) = right { ctx[right_uw].dominator = Some(target); } diff --git a/cspell.json b/cspell.json index 3c1a56ab263..1132ae02409 100644 --- a/cspell.json +++ b/cspell.json @@ -1,9 +1,6 @@ { "version": "0.2", "words": [ - // Spelling mistakes -- This includes using the english spelling - // of words over the american spelling. - "Oshoud", "concatened", "assuption", "circtuit", From c1bd8420b8c749333e34dff6794ff78479a12eed Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 11:51:11 +0000 Subject: [PATCH 025/115] concatened -> concatenated --- crates/noirc_evaluator/src/ssa/block.rs | 2 +- cspell.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/block.rs b/crates/noirc_evaluator/src/ssa/block.rs index 453254027fb..247c446d082 100644 --- a/crates/noirc_evaluator/src/ssa/block.rs +++ b/crates/noirc_evaluator/src/ssa/block.rs @@ -550,7 +550,7 @@ pub fn merge_path( } } - //we assign the concatened list of instructions to the start block, using a CSE pass + //we assign the concatenated list of instructions to the start block, using a CSE pass let mut modified = false; super::optim::cse_block(ctx, start, &mut instructions, &mut modified)?; //Wires start to end diff --git a/cspell.json b/cspell.json index 1132ae02409..f407df1db42 100644 --- a/cspell.json +++ b/cspell.json @@ -1,7 +1,6 @@ { "version": "0.2", "words": [ - "concatened", "assuption", "circtuit", "synchronise", From d2d696122de95b72c41f3387eaf72b8db130eae5 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 11:52:15 +0000 Subject: [PATCH 026/115] assuption -> assumption --- crates/noirc_evaluator/src/ssa/conditional.rs | 2 +- cspell.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/conditional.rs b/crates/noirc_evaluator/src/ssa/conditional.rs index 58052d6d295..7d1836b0698 100644 --- a/crates/noirc_evaluator/src/ssa/conditional.rs +++ b/crates/noirc_evaluator/src/ssa/conditional.rs @@ -235,7 +235,7 @@ impl DecisionTree { } // is it an IF block? if let Some(ins) = ctx.get_if_condition(current_block) { - //add a new assuption for the IF + //add a new assumption for the IF if assumption.parent == AssumptionId::dummy() { //Root assumption parent = block_assumption; diff --git a/cspell.json b/cspell.json index f407df1db42..2782d298086 100644 --- a/cspell.json +++ b/cspell.json @@ -1,7 +1,6 @@ { "version": "0.2", "words": [ - "assuption", "circtuit", "synchronise", "conditionalise", From 0579178e61bce7ae816581213ad8ffe0b8bad87a Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 11:53:01 +0000 Subject: [PATCH 027/115] circtuit -> circuit --- crates/noirc_evaluator/src/ssa/conditional.rs | 4 ++-- cspell.json | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/conditional.rs b/crates/noirc_evaluator/src/ssa/conditional.rs index 7d1836b0698..7ee51c0993e 100644 --- a/crates/noirc_evaluator/src/ssa/conditional.rs +++ b/crates/noirc_evaluator/src/ssa/conditional.rs @@ -483,7 +483,7 @@ impl DecisionTree { stack: &mut StackFrame, ins_id: NodeId, predicate: AssumptionId, - short_circtuit: bool, + short_circuit: bool, ) -> Result { let ass_cond; let ass_value; @@ -515,7 +515,7 @@ impl DecisionTree { } let ins = ins1.clone(); - if short_circtuit { + if short_circuit { stack.set_zero(ctx, ins.res_type); let ins2 = ctx.get_mut_instruction(ins_id); if ins2.res_type == ObjectType::NotAnObject { diff --git a/cspell.json b/cspell.json index 2782d298086..75b15adcfe0 100644 --- a/cspell.json +++ b/cspell.json @@ -1,7 +1,6 @@ { "version": "0.2", "words": [ - "circtuit", "synchronise", "conditionalise", "arbitraty", From 360edd23cdf3d9e80c4ea20e6543052cd3ab3f5c Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 11:53:50 +0000 Subject: [PATCH 028/115] synchronise -> synchronize --- crates/noirc_evaluator/src/ssa/conditional.rs | 4 ++-- cspell.json | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/conditional.rs b/crates/noirc_evaluator/src/ssa/conditional.rs index 7ee51c0993e..05e91d50909 100644 --- a/crates/noirc_evaluator/src/ssa/conditional.rs +++ b/crates/noirc_evaluator/src/ssa/conditional.rs @@ -378,7 +378,7 @@ impl DecisionTree { } else { let left_ins = ctx[left].instructions.clone(); let right_ins = ctx[right].instructions.clone(); - merged_ins = self.synchronise(ctx, &left_ins, &right_ins, left); + merged_ins = self.synchronize(ctx, &left_ins, &right_ins, left); } let mut modified = false; super::optim::cse_block(ctx, left, &mut merged_ins, &mut modified)?; @@ -738,7 +738,7 @@ impl DecisionTree { } } - fn synchronise( + fn synchronize( &self, ctx: &mut SsaContext, left: &[NodeId], diff --git a/cspell.json b/cspell.json index 75b15adcfe0..575cdd54f3c 100644 --- a/cspell.json +++ b/cspell.json @@ -1,7 +1,6 @@ { "version": "0.2", "words": [ - "synchronise", "conditionalise", "arbitraty", "flatened", From 2334469dba4ecc701c58fd2adbffdee4224a6267 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 11:58:48 +0000 Subject: [PATCH 029/115] conditionalise -> conditionalize --- crates/noirc_evaluator/src/ssa/conditional.rs | 10 +++++----- crates/noirc_evaluator/src/ssa/inline.rs | 6 +++--- cspell.json | 6 ++++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/conditional.rs b/crates/noirc_evaluator/src/ssa/conditional.rs index 05e91d50909..7248b579224 100644 --- a/crates/noirc_evaluator/src/ssa/conditional.rs +++ b/crates/noirc_evaluator/src/ssa/conditional.rs @@ -405,14 +405,14 @@ impl DecisionTree { ) -> Result<(), RuntimeError> { let assumption_id = ctx[block].assumption; let instructions = ctx[block].instructions.clone(); - self.conditionalise_inline(ctx, &instructions, stack, assumption_id)?; + self.conditionalize_inline(ctx, &instructions, stack, assumption_id)?; ctx[block].instructions.clear(); ctx[block].instructions.append(&mut stack.stack); assert!(stack.stack.is_empty()); Ok(()) } - pub fn conditionalise_inline( + pub fn conditionalize_inline( &self, ctx: &mut SsaContext, instructions: &[NodeId], @@ -422,7 +422,7 @@ impl DecisionTree { if predicate == AssumptionId::dummy() || self[predicate].value != Some(ctx.zero()) { let mut short_circuit = false; for i in instructions { - if !self.conditionalise_into(ctx, result, *i, predicate, short_circuit)? { + if !self.conditionalize_into(ctx, result, *i, predicate, short_circuit)? { short_circuit = true; } } @@ -477,7 +477,7 @@ impl DecisionTree { } } - pub fn conditionalise_into( + pub fn conditionalize_into( &self, ctx: &mut SsaContext, stack: &mut StackFrame, @@ -667,7 +667,7 @@ impl DecisionTree { ObjectType::Pointer(array_dup), &mut memcpy_stack, ); - self.conditionalise_inline( + self.conditionalize_inline( ctx, &memcpy_stack.stack, stack, diff --git a/crates/noirc_evaluator/src/ssa/inline.rs b/crates/noirc_evaluator/src/ssa/inline.rs index b6ae6d9d421..0b3659db45a 100644 --- a/crates/noirc_evaluator/src/ssa/inline.rs +++ b/crates/noirc_evaluator/src/ssa/inline.rs @@ -378,14 +378,14 @@ pub fn inline_in_block( } } - // we conditionalise the stack frame into a new stack frame (to avoid ownership issues) + // we conditionalize the stack frame into a new stack frame (to avoid ownership issues) let mut stack2 = StackFrame::new(stack_frame.block); stack2.return_arrays = stack_frame.return_arrays.clone(); if short_circuit { super::block::short_circuit_inline(ctx, stack_frame.block); } else { - decision.conditionalise_inline(ctx, &stack_frame.stack, &mut stack2, predicate)?; - // we add the conditionalised instructions to the target_block, at proper location (really need a linked list!) + decision.conditionalize_inline(ctx, &stack_frame.stack, &mut stack2, predicate)?; + // we add the conditionalized instructions to the target_block, at proper location (really need a linked list!) stack2.apply(ctx, stack_frame.block, call_id, false); } diff --git a/cspell.json b/cspell.json index 575cdd54f3c..0cb6dba5ba8 100644 --- a/cspell.json +++ b/cspell.json @@ -1,7 +1,11 @@ { "version": "0.2", "words": [ + // TODO: Perhaps we should use the term `make_conditional` + // instead of conditionalize. This can be done in a separate PR "conditionalise", + "conditionalize", + "conditionalized", "arbitraty", "flatened", "charac", @@ -12,8 +16,6 @@ "normalisation", "dont", "Secp", - "conditionalize", - "conditionalised", "dunmmy", "erce", "utilise", From 69542f7c71b244dbf483f71416d2aadac4ca18f7 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 12:08:29 +0000 Subject: [PATCH 030/115] arbitraty -> arbitrary Fix comment and use arbitrarily instead --- crates/noirc_evaluator/src/ssa/inline.rs | 2 +- cspell.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/inline.rs b/crates/noirc_evaluator/src/ssa/inline.rs index 0b3659db45a..1fb4b534a07 100644 --- a/crates/noirc_evaluator/src/ssa/inline.rs +++ b/crates/noirc_evaluator/src/ssa/inline.rs @@ -21,7 +21,7 @@ use super::{ // Number of allowed times for inlining function calls inside a code block. // If a function calls another function, the inlining of the first function will leave the second function call that needs to be inlined as well. -// In case of recursive calls, this iterative inlining does not end so we arbitraty limit it. 100 nested calls should already support very complex programs. +// In case of recursive calls, this iterative inlining does not end so we arbitrarily limit it. 100 nested calls should already support very complex programs. const MAX_INLINE_TRIES: u32 = 100; //inline main diff --git a/cspell.json b/cspell.json index 0cb6dba5ba8..9be6f4d60a9 100644 --- a/cspell.json +++ b/cspell.json @@ -6,7 +6,6 @@ "conditionalise", "conditionalize", "conditionalized", - "arbitraty", "flatened", "charac", "insterted", From 671b088e5ffa79ea9f949407b74f9dbe0e0d53b4 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 12:09:24 +0000 Subject: [PATCH 031/115] flatened -> flattened --- crates/noirc_evaluator/src/ssa/inline.rs | 2 +- cspell.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/inline.rs b/crates/noirc_evaluator/src/ssa/inline.rs index 1fb4b534a07..0373f8d00c8 100644 --- a/crates/noirc_evaluator/src/ssa/inline.rs +++ b/crates/noirc_evaluator/src/ssa/inline.rs @@ -230,7 +230,7 @@ pub fn inline( } let mut result = true; - //3. inline in the block: we assume the function cfg is already flatened. + //3. inline in the block: we assume the function cfg is already flattened. let mut next_block = Some(ssa_func.entry_block); while let Some(next_b) = next_block { let mut nested_call = false; diff --git a/cspell.json b/cspell.json index 9be6f4d60a9..8e0aed94dec 100644 --- a/cspell.json +++ b/cspell.json @@ -6,7 +6,6 @@ "conditionalise", "conditionalize", "conditionalized", - "flatened", "charac", "insterted", "statment", From ef5a16274809d118859204de3750e7a713270377 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 12:10:28 +0000 Subject: [PATCH 032/115] charac -> (fix comment) --- crates/noirc_evaluator/src/ssa/integer.rs | 2 +- cspell.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/integer.rs b/crates/noirc_evaluator/src/ssa/integer.rs index 12756ba2222..504d5121710 100644 --- a/crates/noirc_evaluator/src/ssa/integer.rs +++ b/crates/noirc_evaluator/src/ssa/integer.rs @@ -228,7 +228,7 @@ fn block_overflow( memory_map: &mut HashMap, ) -> Result<(), RuntimeError> { //for each instruction, we compute the resulting max possible value (in term of the field representation of the operation) - //when it is over the field charac, or if the instruction requires it, then we insert truncate instructions + //when it is over the field characteristic, or if the instruction requires it, then we insert truncate instructions // The instructions are insterted in a duplicate list( because of rust ownership..), which we use for // processing another cse round for the block because the truncates may be duplicated. let mut new_list = Vec::new(); diff --git a/cspell.json b/cspell.json index 8e0aed94dec..b9d60b07c2d 100644 --- a/cspell.json +++ b/cspell.json @@ -6,7 +6,6 @@ "conditionalise", "conditionalize", "conditionalized", - "charac", "insterted", "statment", "recursiverly", From b46943a62914c40069412f1bb43c72b219e18a66 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 12:11:34 +0000 Subject: [PATCH 033/115] insterted -> inserted --- crates/noirc_evaluator/src/ssa/integer.rs | 2 +- cspell.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/integer.rs b/crates/noirc_evaluator/src/ssa/integer.rs index 504d5121710..2deb1bfa328 100644 --- a/crates/noirc_evaluator/src/ssa/integer.rs +++ b/crates/noirc_evaluator/src/ssa/integer.rs @@ -229,7 +229,7 @@ fn block_overflow( ) -> Result<(), RuntimeError> { //for each instruction, we compute the resulting max possible value (in term of the field representation of the operation) //when it is over the field characteristic, or if the instruction requires it, then we insert truncate instructions - // The instructions are insterted in a duplicate list( because of rust ownership..), which we use for + // The instructions are inserted in a duplicate list( because of rust ownership..), which we use for // processing another cse round for the block because the truncates may be duplicated. let mut new_list = Vec::new(); diff --git a/cspell.json b/cspell.json index b9d60b07c2d..4405e5534c2 100644 --- a/cspell.json +++ b/cspell.json @@ -6,7 +6,6 @@ "conditionalise", "conditionalize", "conditionalized", - "insterted", "statment", "recursiverly", "recognise", From 03b7675a496f5eb916016c1a3fe1e9b181408fa0 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 12:13:09 +0000 Subject: [PATCH 034/115] statment -> statement --- crates/noirc_evaluator/src/ssa/node.rs | 2 +- cspell.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/node.rs b/crates/noirc_evaluator/src/ssa/node.rs index 63a921355ae..b86c5e02238 100644 --- a/crates/noirc_evaluator/src/ssa/node.rs +++ b/crates/noirc_evaluator/src/ssa/node.rs @@ -364,7 +364,7 @@ impl Instruction { Operation::Load { .. } => false, Operation::Store { .. } => true, Operation::Intrinsic(_, _) => true, - Operation::Call { .. } => true, //return values are in the return statment + Operation::Call { .. } => true, //return values are in the return statement Operation::Return(_) => true, Operation::Result { .. } => false, } diff --git a/cspell.json b/cspell.json index 4405e5534c2..422e88c3bed 100644 --- a/cspell.json +++ b/cspell.json @@ -6,7 +6,6 @@ "conditionalise", "conditionalize", "conditionalized", - "statment", "recursiverly", "recognise", "normalisation", From 8ebf33447877b8a8680f50a7acbe5d3459b54ef7 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 12:14:11 +0000 Subject: [PATCH 035/115] recursiverly -> recursively --- crates/noirc_evaluator/src/ssa/ssa_form.rs | 2 +- cspell.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/ssa_form.rs b/crates/noirc_evaluator/src/ssa/ssa_form.rs index bdee4380aed..759e04bf34e 100644 --- a/crates/noirc_evaluator/src/ssa/ssa_form.rs +++ b/crates/noirc_evaluator/src/ssa/ssa_form.rs @@ -75,7 +75,7 @@ pub fn add_dummy_store(ctx: &mut SsaContext, entry: BlockId, join: BlockId) { } } -//look-up recursiverly into predecessors +//look-up recursively into predecessors pub fn get_block_value(ctx: &mut SsaContext, root: NodeId, block_id: BlockId) -> NodeId { let result = if !ctx.sealed_blocks.contains(&block_id) { //incomplete CFG diff --git a/cspell.json b/cspell.json index 422e88c3bed..bba18b5c01f 100644 --- a/cspell.json +++ b/cspell.json @@ -6,7 +6,6 @@ "conditionalise", "conditionalize", "conditionalized", - "recursiverly", "recognise", "normalisation", "dont", From 26e4c5f461b199a64576aae7b6426ef0b1aa7f5f Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 12:14:47 +0000 Subject: [PATCH 036/115] recognise -> recognize --- crates/noirc_frontend/src/ast/expression.rs | 2 +- cspell.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/noirc_frontend/src/ast/expression.rs b/crates/noirc_frontend/src/ast/expression.rs index 14a22826123..db08c7dae01 100644 --- a/crates/noirc_frontend/src/ast/expression.rs +++ b/crates/noirc_frontend/src/ast/expression.rs @@ -251,7 +251,7 @@ pub enum UnaryOp { impl UnaryOp { /// Converts a token to a unary operator - /// If you want the parser to recognise another Token as being a prefix operator, it is defined here + /// If you want the parser to recognize another Token as being a prefix operator, it is defined here pub fn from(token: &Token) -> Option { match token { Token::Minus => Some(UnaryOp::Minus), diff --git a/cspell.json b/cspell.json index bba18b5c01f..d41a8435dae 100644 --- a/cspell.json +++ b/cspell.json @@ -6,7 +6,6 @@ "conditionalise", "conditionalize", "conditionalized", - "recognise", "normalisation", "dont", "Secp", From 906337312bbf766797a6c1af9fbae9019ddafeb4 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 12:15:19 +0000 Subject: [PATCH 037/115] normalisation -> normalization --- crates/noirc_frontend/src/graph/mod.rs | 2 +- cspell.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/noirc_frontend/src/graph/mod.rs b/crates/noirc_frontend/src/graph/mod.rs index ad9984c364a..dadb558f9a6 100644 --- a/crates/noirc_frontend/src/graph/mod.rs +++ b/crates/noirc_frontend/src/graph/mod.rs @@ -28,7 +28,7 @@ impl CrateName { /// Creates a new CrateName rejecting any crate name that /// has a character on the blacklist. /// The difference between RA and this implementation is that - /// characters on the blacklist are never allowed; there is no normalisation. + /// characters on the blacklist are never allowed; there is no normalization. pub fn new(name: &str) -> Result { let is_invalid = name.chars().any(|n| CHARACTER_BLACK_LIST.contains(&n)); if is_invalid { diff --git a/cspell.json b/cspell.json index d41a8435dae..acdaf4ee99d 100644 --- a/cspell.json +++ b/cspell.json @@ -6,7 +6,6 @@ "conditionalise", "conditionalize", "conditionalized", - "normalisation", "dont", "Secp", "dunmmy", From 81662a65b0739f6613a51c9e8f667f053ae7aa85 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 12:15:48 +0000 Subject: [PATCH 038/115] dont -> don't --- crates/noirc_frontend/src/hir_def/types.rs | 2 +- cspell.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/noirc_frontend/src/hir_def/types.rs b/crates/noirc_frontend/src/hir_def/types.rs index 268c0ad062c..e4516cf8788 100644 --- a/crates/noirc_frontend/src/hir_def/types.rs +++ b/crates/noirc_frontend/src/hir_def/types.rs @@ -379,7 +379,7 @@ impl Comptime { (Comptime::Maybe(id1, _), Comptime::Maybe(id2, _)) if id1 == id2 => Ok(()), // This is the other differing case between this and Comptime::unify. - // If this is polymorphically comptime, dont force it to be non-comptime because it is + // If this is polymorphically comptime, don't force it to be non-comptime because it is // passed as an argument to a function expecting a non-comptime parameter. (Comptime::Maybe(_, binding), Comptime::No(_)) if binding.borrow().is_none() => Ok(()), diff --git a/cspell.json b/cspell.json index acdaf4ee99d..5ee270f5ecf 100644 --- a/cspell.json +++ b/cspell.json @@ -6,7 +6,6 @@ "conditionalise", "conditionalize", "conditionalized", - "dont", "Secp", "dunmmy", "erce", From 90c6c92e099ebae3d4e2146dc3820733b10e6e24 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 12:19:48 +0000 Subject: [PATCH 039/115] secp -> secp256k1 - Add brief explanation --- cspell.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cspell.json b/cspell.json index 5ee270f5ecf..d5d8de3dafb 100644 --- a/cspell.json +++ b/cspell.json @@ -6,7 +6,8 @@ "conditionalise", "conditionalize", "conditionalized", - "Secp", + // Refers to parameters for a specific elliptic curve + "secp256k1", "dunmmy", "erce", "utilise", From 3ec7df899613f57b665ba21705fa8954c1006cf2 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 12:20:31 +0000 Subject: [PATCH 040/115] dunmmy -> dummy --- crates/noirc_evaluator/src/ssa/optim.rs | 2 +- cspell.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/optim.rs b/crates/noirc_evaluator/src/ssa/optim.rs index 33f539a7941..c0fa4db5011 100644 --- a/crates/noirc_evaluator/src/ssa/optim.rs +++ b/crates/noirc_evaluator/src/ssa/optim.rs @@ -311,7 +311,7 @@ fn cse_block_with_anchor( } Operation::Return(..) => new_list.push(*ins_id), Operation::Intrinsic(_, args) => { - //Add dunmmy load for function arguments and enable CSE only if no array in argument + //Add dummy load for function arguments and enable CSE only if no array in argument let mut activate_cse = true; for arg in args { if let Some(obj) = ctx.try_get_node(*arg) { diff --git a/cspell.json b/cspell.json index d5d8de3dafb..31364f702b8 100644 --- a/cspell.json +++ b/cspell.json @@ -8,7 +8,6 @@ "conditionalized", // Refers to parameters for a specific elliptic curve "secp256k1", - "dunmmy", "erce", "utilise", "grammer", From 75b8a6909918ef1d6d1151ee4894028924915761 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 12:21:21 +0000 Subject: [PATCH 041/115] erce -> (Fix comment) --- crates/noirc_frontend/src/hir/type_check/stmt.rs | 2 +- cspell.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/noirc_frontend/src/hir/type_check/stmt.rs b/crates/noirc_frontend/src/hir/type_check/stmt.rs index 3f8cb46ef8a..8f91337431a 100644 --- a/crates/noirc_frontend/src/hir/type_check/stmt.rs +++ b/crates/noirc_frontend/src/hir/type_check/stmt.rs @@ -260,7 +260,7 @@ fn type_check_declaration( // If so, then we give it the same type as the expression if annotated_type != Type::Error { // Now check if LHS is the same type as the RHS - // Importantly, we do not co-erce any types implicitly + // Importantly, we do not coerce any types implicitly let expr_span = interner.expr_span(&rhs_expr); expr_type.make_subtype_of(&annotated_type, expr_span, errors, || { TypeCheckError::TypeMismatch { diff --git a/cspell.json b/cspell.json index 31364f702b8..ef6082399f0 100644 --- a/cspell.json +++ b/cspell.json @@ -8,7 +8,6 @@ "conditionalized", // Refers to parameters for a specific elliptic curve "secp256k1", - "erce", "utilise", "grammer", "messsages", From ca1d7a171f78f4a10128cb87ed84c9c842fd73a2 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 12:21:56 +0000 Subject: [PATCH 042/115] utilise -> utilize --- crates/noirc_frontend/src/lexer/lexer.rs | 2 +- cspell.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/noirc_frontend/src/lexer/lexer.rs b/crates/noirc_frontend/src/lexer/lexer.rs index ec3049dbcb1..5eafec622de 100644 --- a/crates/noirc_frontend/src/lexer/lexer.rs +++ b/crates/noirc_frontend/src/lexer/lexer.rs @@ -293,7 +293,7 @@ impl<'a> Lexer<'a> { Ok(attribute.into_span(start - 1, end + 1)) } - //XXX(low): Can increase performance if we use iterator semantic and utilise some of the methods on String. See below + //XXX(low): Can increase performance if we use iterator semantic and utilize some of the methods on String. See below // https://doc.rust-lang.org/stable/std/primitive.str.html#method.rsplit fn eat_word(&mut self, initial_char: char) -> SpannedTokenResult { let (word, start, end) = self.eat_while(Some(initial_char), |ch| { diff --git a/cspell.json b/cspell.json index ef6082399f0..48cb0adc74f 100644 --- a/cspell.json +++ b/cspell.json @@ -8,7 +8,6 @@ "conditionalized", // Refers to parameters for a specific elliptic curve "secp256k1", - "utilise", "grammer", "messsages", "Chidren", From 80e3cab928250066f6a91ad0f3e2fec9076b7d5b Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 12:22:43 +0000 Subject: [PATCH 043/115] grammer -> grammar --- crates/noirc_frontend/src/lexer/token.rs | 2 +- cspell.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/noirc_frontend/src/lexer/token.rs b/crates/noirc_frontend/src/lexer/token.rs index 5d0ed99b866..201dffa0c6c 100644 --- a/crates/noirc_frontend/src/lexer/token.rs +++ b/crates/noirc_frontend/src/lexer/token.rs @@ -129,7 +129,7 @@ pub enum Token { #[allow(clippy::upper_case_acronyms)] EOF, - // An invalid character is one that is not in noir's language or grammer. + // An invalid character is one that is not in noir's language or grammar. // Delaying reporting these as errors until parsing improves error messsages Invalid(char), } diff --git a/cspell.json b/cspell.json index 48cb0adc74f..5d1592afcd3 100644 --- a/cspell.json +++ b/cspell.json @@ -8,7 +8,6 @@ "conditionalized", // Refers to parameters for a specific elliptic curve "secp256k1", - "grammer", "messsages", "Chidren", "aeiou", From 758826a423e3c55a860ba3476b1f5ee8259de5ea Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 12:23:18 +0000 Subject: [PATCH 044/115] messsages -> messages --- crates/noirc_frontend/src/lexer/token.rs | 2 +- cspell.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/noirc_frontend/src/lexer/token.rs b/crates/noirc_frontend/src/lexer/token.rs index 201dffa0c6c..89f37af184c 100644 --- a/crates/noirc_frontend/src/lexer/token.rs +++ b/crates/noirc_frontend/src/lexer/token.rs @@ -130,7 +130,7 @@ pub enum Token { EOF, // An invalid character is one that is not in noir's language or grammar. - // Delaying reporting these as errors until parsing improves error messsages + // Delaying reporting these as errors until parsing improves error messages Invalid(char), } diff --git a/cspell.json b/cspell.json index 5d1592afcd3..84a7922e89f 100644 --- a/cspell.json +++ b/cspell.json @@ -8,7 +8,6 @@ "conditionalized", // Refers to parameters for a specific elliptic curve "secp256k1", - "messsages", "Chidren", "aeiou", "Opportunties", From 2bd0df5bda7aebe6dc7f2df6457bc071fbe3e6de Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 12:24:12 +0000 Subject: [PATCH 045/115] Chidren -> Children --- crates/noirc_frontend/src/main.rs | 2 +- cspell.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/noirc_frontend/src/main.rs b/crates/noirc_frontend/src/main.rs index ccc8f3ce9f4..7a61d8387ad 100644 --- a/crates/noirc_frontend/src/main.rs +++ b/crates/noirc_frontend/src/main.rs @@ -57,7 +57,7 @@ fn main() { // println!("-----------------------------Start Data for module at position {}----------------------------", i); // println!("current module id is: {:?}", module_index); // println!("parent module id is: {:?}", module_data.parent); - // println!("-----------------------------Chidren for module at position {}----------------------------", i); + // println!("-----------------------------Children for module at position {}----------------------------", i); // for (child_name, child_id) in &module_data.children { // println!("{:?} is a child module with id {:?}", child_name, child_id); // } diff --git a/cspell.json b/cspell.json index 84a7922e89f..ff4b015a500 100644 --- a/cspell.json +++ b/cspell.json @@ -8,7 +8,6 @@ "conditionalized", // Refers to parameters for a specific elliptic curve "secp256k1", - "Chidren", "aeiou", "Opportunties", "sanitisation", From d565ffb5d55e70ffb95d9b49580c70c7cd4b8f3d Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 12:25:20 +0000 Subject: [PATCH 046/115] Opportunties -> Opportunities --- CONTRIBUTING.md | 2 +- cspell.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 891c3559942..eaa89357fd9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -27,7 +27,7 @@ Before you create a pull request, create an issue that thoroughly describes the Noir is still very new and there are many cryptographic primitives that we have yet to build that will be useful for the community. If you have other ideas, please reach out on the [Aztec Discord](https://discord.gg/aztec) to discuss. You can find the current list of requested primitives in the [issues section](https://github.com/noir-lang/noir/labels/noir-stdlib) marked with the label `noir-stdlib`. -## Funding Opportunties +## Funding Opportunities Aztec is offering grants to people and teams that want to use, test or build Noir. You can find more information about the grants program [here](https://aztec.network/grants). diff --git a/cspell.json b/cspell.json index ff4b015a500..75b1d91f982 100644 --- a/cspell.json +++ b/cspell.json @@ -9,7 +9,6 @@ // Refers to parameters for a specific elliptic curve "secp256k1", "aeiou", - "Opportunties", "sanitisation", "ellide", // From 373554d4d1972b011454fd61df9bd3170bad7fe5 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 12:26:01 +0000 Subject: [PATCH 047/115] sanitisation -> sanitization --- README.md | 2 +- cspell.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index acad40d4c97..f5e6d0ec229 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ The current focus is to gather as much feedback as possible while in the alpha p Concretely the following items are on the road map: -- General code sanitisation and documentation (ongoing effort) +- General code sanitization and documentation (ongoing effort) - Prover and Verifier Key logic. (Prover and Verifier preprocess per compile) - Fallback mechanism for backend unsupported opcodes - Visibility modifiers diff --git a/cspell.json b/cspell.json index 75b1d91f982..97b60df47cf 100644 --- a/cspell.json +++ b/cspell.json @@ -9,7 +9,6 @@ // Refers to parameters for a specific elliptic curve "secp256k1", "aeiou", - "sanitisation", "ellide", // "acvm", From 62d46d64ab5a40a491398f642800bcbc95a155ca Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 12:27:06 +0000 Subject: [PATCH 048/115] ellide -> elide --- crates/noirc_frontend/src/hir_def/types.rs | 2 +- cspell.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/noirc_frontend/src/hir_def/types.rs b/crates/noirc_frontend/src/hir_def/types.rs index e4516cf8788..e45d5ba85c6 100644 --- a/crates/noirc_frontend/src/hir_def/types.rs +++ b/crates/noirc_frontend/src/hir_def/types.rs @@ -1068,7 +1068,7 @@ impl Type { pub fn iter_fields(&self) -> impl Iterator { let fields: Vec<_> = match self { // Unfortunately the .borrow() here forces us to collect into a Vec - // only to have to call .into_iter again afterward. Trying to ellide + // only to have to call .into_iter again afterward. Trying to elide // collecting to a Vec leads to us dropping the temporary Ref before // the iterator is returned Type::Struct(def, args) => vecmap(&def.borrow().fields, |(name, _)| { diff --git a/cspell.json b/cspell.json index 97b60df47cf..83006c16f7b 100644 --- a/cspell.json +++ b/cspell.json @@ -9,7 +9,6 @@ // Refers to parameters for a specific elliptic curve "secp256k1", "aeiou", - "ellide", // "acvm", "acir", From c042c1028115be86ed39c5f42848f48045ef2e73 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 12:34:45 +0000 Subject: [PATCH 049/115] interner -> Add brief comment --- cspell.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cspell.json b/cspell.json index 83006c16f7b..f9e94065a81 100644 --- a/cspell.json +++ b/cspell.json @@ -15,6 +15,8 @@ "nargo", "tempdir", "noirc", + // This is a computer science idiom. Its a data structure that stores only + // one distinct copy of an value. Google `String Interner` for a concrete example "interner", "callsite", "blackbox", From 784c13b4931298f9e23f07416047d5d5dceaeeee Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 12:44:27 +0000 Subject: [PATCH 050/115] callsite -> "call site" --- crates/noirc_driver/src/lib.rs | 2 +- crates/noirc_frontend/src/hir/type_check/expr.rs | 2 +- crates/noirc_frontend/src/hir_def/types.rs | 2 +- crates/noirc_frontend/src/monomorphization/mod.rs | 4 ++-- crates/noirc_frontend/src/node_interner.rs | 2 +- cspell.json | 1 - 6 files changed, 6 insertions(+), 7 deletions(-) diff --git a/crates/noirc_driver/src/lib.rs b/crates/noirc_driver/src/lib.rs index 3de92f7c1a6..1a822e9bcb7 100644 --- a/crates/noirc_driver/src/lib.rs +++ b/crates/noirc_driver/src/lib.rs @@ -199,7 +199,7 @@ impl Driver { Ok(circuit) => circuit, Err(err) => { // The FileId here will be the file id of the file with the main file - // Errors will be shown at the callsite without a stacktrace + // Errors will be shown at the call site without a stacktrace let file_id = err.location.map(|loc| loc.file); let error_count = Reporter::with_diagnostics( file_id, diff --git a/crates/noirc_frontend/src/hir/type_check/expr.rs b/crates/noirc_frontend/src/hir/type_check/expr.rs index b5ad956ed45..91c58ca2d9e 100644 --- a/crates/noirc_frontend/src/hir/type_check/expr.rs +++ b/crates/noirc_frontend/src/hir/type_check/expr.rs @@ -21,7 +21,7 @@ pub(crate) fn type_check_expression( HirExpression::Ident(ident) => { // An identifiers type may be forall-quantified in the case of generic functions. // E.g. `fn foo(t: T, field: Field) -> T` has type `forall T. fn(T, Field) -> T`. - // We must instantiate identifiers at every callsite to replace this T with a new type + // We must instantiate identifiers at every call site to replace this T with a new type // variable to handle generic functions. let t = interner.id_type(ident.id); let (typ, bindings) = t.instantiate(interner); diff --git a/crates/noirc_frontend/src/hir_def/types.rs b/crates/noirc_frontend/src/hir_def/types.rs index e45d5ba85c6..56242924e79 100644 --- a/crates/noirc_frontend/src/hir_def/types.rs +++ b/crates/noirc_frontend/src/hir_def/types.rs @@ -578,7 +578,7 @@ impl std::fmt::Display for Comptime { impl Type { /// Mutate the span for Comptime to track where comptime is required for better - /// error messages that show both the erroring callsite and the callsite before + /// error messages that show both the erroring call site and the call site before /// which required the variable to be comptime or non-comptime. pub fn set_comptime_span(&mut self, new_span: Span) { match self { diff --git a/crates/noirc_frontend/src/monomorphization/mod.rs b/crates/noirc_frontend/src/monomorphization/mod.rs index 53ff7809344..87458b41fa1 100644 --- a/crates/noirc_frontend/src/monomorphization/mod.rs +++ b/crates/noirc_frontend/src/monomorphization/mod.rs @@ -576,8 +576,8 @@ impl Monomorphizer { } /// Try to evaluate certain builtin functions (currently only 'arraylen' and field modulus methods) - /// at their callsite. - /// NOTE: Evaluating at the callsite means we cannot track aliased functions. + /// at their call site. + /// NOTE: Evaluating at the call site means we cannot track aliased functions. /// E.g. `let f = std::array::len; f(arr)` will fail to evaluate. /// To fix this we need to evaluate on the identifier instead, which /// requires us to evaluate to a Lambda value which isn't in noir yet. diff --git a/crates/noirc_frontend/src/node_interner.rs b/crates/noirc_frontend/src/node_interner.rs index 847e7d96a99..9cdc03253ad 100644 --- a/crates/noirc_frontend/src/node_interner.rs +++ b/crates/noirc_frontend/src/node_interner.rs @@ -153,7 +153,7 @@ pub struct NodeInterner { /// Map from ExprId (referring to a Function/Method call) to its corresponding TypeBindings, /// filled out during type checking from instantiated variables. Used during monomorphization - /// to map callsite types back onto function parameter types, and undo this binding as needed. + /// to map call site types back onto function parameter types, and undo this binding as needed. instantiation_bindings: HashMap, /// Remembers the field index a given HirMemberAccess expression was resolved to during type diff --git a/cspell.json b/cspell.json index f9e94065a81..f5b7d9fd0b0 100644 --- a/cspell.json +++ b/cspell.json @@ -18,7 +18,6 @@ // This is a computer science idiom. Its a data structure that stores only // one distinct copy of an value. Google `String Interner` for a concrete example "interner", - "callsite", "blackbox", "canonicalize", "codegen", From 815315faf5829c2c7b87c1f083d8aad935d75276 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 12:46:25 +0000 Subject: [PATCH 051/115] cspell -- remove capitalisations (this does not matter for spelling) --- cspell.json | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/cspell.json b/cspell.json index f5b7d9fd0b0..9b0bf7b4793 100644 --- a/cspell.json +++ b/cspell.json @@ -25,8 +25,8 @@ "vecmap", "funcid", "ssafunc", - "Forall", - "Signedness", + "forall", + "signedness", "rtype", "optim", "optype", @@ -75,10 +75,9 @@ "virtualise", "tempfile", "rustc", - "ARKWORKS", "arkworks", - "Kevaundray", - "Wedderburn", + "kevaundray", + "wedderburn", "termcolor", "arity", "ncrate", @@ -87,9 +86,9 @@ "thiserror", "Deque", "svec", - "Pedersen", - "Schnorr", - "Merkle", + "pedersen", + "schnorr", + "merkle", "pvalue", "binop", "vmap", @@ -112,10 +111,10 @@ "nondeterministically", "typevar", "forscope", - "Arity", + "arity", "typecheck", - "Hindley", - "Milner", + "hindley", + "milner", "peekable", "hexdigit", "arraylen", From 2c339639c9a8689b624bb70df1b31bb4ea0c1de4 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 12:46:52 +0000 Subject: [PATCH 052/115] bitsize -> "bit size" --- crates/noirc_evaluator/src/ssa/context.rs | 2 +- cspell.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/context.rs b/crates/noirc_evaluator/src/ssa/context.rs index 4893ca46d51..1c5bedd1e49 100644 --- a/crates/noirc_evaluator/src/ssa/context.rs +++ b/crates/noirc_evaluator/src/ssa/context.rs @@ -196,7 +196,7 @@ impl SsaContext { Operation::Cast(value) => format!("cast {}", self.id_to_string(*value)), Operation::Truncate { value, bit_size, max_bit_size } => { format!( - "truncate {}, bitsize = {bit_size}, max bitsize = {max_bit_size}", + "truncate {}, bit size = {bit_size}, max bit size = {max_bit_size}", self.id_to_string(*value), ) } diff --git a/cspell.json b/cspell.json index 9b0bf7b4793..f4d54dee070 100644 --- a/cspell.json +++ b/cspell.json @@ -30,7 +30,6 @@ "rtype", "optim", "optype", - "bitsize", "curr", "coef", "lowlevel", From 4537a199eae66ba6cbb6fe6085e3b60312d02401 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 12:48:23 +0000 Subject: [PATCH 053/115] optype -> op_type --- crates/noirc_evaluator/src/ssa/code_gen.rs | 4 ++-- crates/noirc_evaluator/src/ssa/context.rs | 8 ++++---- cspell.json | 1 - 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/code_gen.rs b/crates/noirc_evaluator/src/ssa/code_gen.rs index de645e3ab9f..fbe58816775 100644 --- a/crates/noirc_evaluator/src/ssa/code_gen.rs +++ b/crates/noirc_evaluator/src/ssa/code_gen.rs @@ -283,8 +283,8 @@ impl IRGenerator { let ltype = self.context.get_object_type(lhs); // Get the opcode from the infix operator let opcode = Operation::Binary(Binary::from_ast(op, ltype, lhs, rhs)); - let optype = self.context.get_result_type(&opcode, ltype); - self.context.new_instruction(opcode, optype) + let op_type = self.context.get_result_type(&opcode, ltype); + self.context.new_instruction(opcode, op_type) } fn codegen_indexed_value( diff --git a/crates/noirc_evaluator/src/ssa/context.rs b/crates/noirc_evaluator/src/ssa/context.rs index 1c5bedd1e49..8b808e4ffb7 100644 --- a/crates/noirc_evaluator/src/ssa/context.rs +++ b/crates/noirc_evaluator/src/ssa/context.rs @@ -557,10 +557,10 @@ impl SsaContext { pub fn new_instruction( &mut self, opcode: Operation, - optype: ObjectType, + op_type: ObjectType, ) -> Result { //Add a new instruction to the nodes arena - let mut i = Instruction::new(opcode, optype, Some(self.current_block)); + let mut i = Instruction::new(opcode, op_type, Some(self.current_block)); //Basic simplification - we ignore RunTimeErrors when creating an instruction //because they must be managed after handling conditionals. For instance if false { b } should not fail whatever b is doing. @@ -922,10 +922,10 @@ impl SsaContext { fn new_instruction_inline( &mut self, operation: node::Operation, - optype: node::ObjectType, + op_type: node::ObjectType, stack_frame: &mut StackFrame, ) -> NodeId { - let i = node::Instruction::new(operation, optype, Some(stack_frame.block)); + let i = node::Instruction::new(operation, op_type, Some(stack_frame.block)); let ins_id = self.add_instruction(i); stack_frame.push(ins_id); ins_id diff --git a/cspell.json b/cspell.json index f4d54dee070..dc9be073402 100644 --- a/cspell.json +++ b/cspell.json @@ -29,7 +29,6 @@ "signedness", "rtype", "optim", - "optype", "curr", "coef", "lowlevel", From 9dbfae0f2cedd8b3536ec7ebfdfa4dbd532afd95 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 12:49:21 +0000 Subject: [PATCH 054/115] lowlevel -> low level --- crates/noirc_evaluator/src/ssa/code_gen.rs | 2 +- crates/noirc_frontend/src/hir/resolution/resolver.rs | 2 +- cspell.json | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/code_gen.rs b/crates/noirc_evaluator/src/ssa/code_gen.rs index fbe58816775..723003b2175 100644 --- a/crates/noirc_evaluator/src/ssa/code_gen.rs +++ b/crates/noirc_evaluator/src/ssa/code_gen.rs @@ -248,7 +248,7 @@ impl IRGenerator { } Definition::Builtin(opcode) | Definition::LowLevel(opcode) => { let opcode = builtin::Opcode::lookup(opcode).unwrap_or_else(|| { - unreachable!("Unknown builtin/lowlevel opcode '{}'", opcode) + unreachable!("Unknown builtin/low level opcode '{}'", opcode) }); let function_node_id = self.context.get_or_create_opcode_node_id(opcode); Ok(Value::Single(function_node_id)) diff --git a/crates/noirc_frontend/src/hir/resolution/resolver.rs b/crates/noirc_frontend/src/hir/resolution/resolver.rs index 0845ee4aee1..3a6263d191b 100644 --- a/crates/noirc_frontend/src/hir/resolution/resolver.rs +++ b/crates/noirc_frontend/src/hir/resolution/resolver.rs @@ -878,7 +878,7 @@ impl<'a> Resolver<'a> { let id = self.resolve_path(path)?; if let Some(mut function) = TryFromModuleDefId::try_from(id) { - // Check if this is an unsupported lowlevel opcode. If so, replace it with + // Check if this is an unsupported low level opcode. If so, replace it with // an alternative in the stdlib. if let Some(meta) = self.interner.try_function_meta(&function) { if meta.kind == crate::FunctionKind::LowLevel { diff --git a/cspell.json b/cspell.json index dc9be073402..ea244fe608b 100644 --- a/cspell.json +++ b/cspell.json @@ -31,7 +31,6 @@ "optim", "curr", "coef", - "lowlevel", "ltype", "otype", "notequal", From 020b5373caf91d5b3a43c49e9cd276896dbb2099 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 13:18:00 +0000 Subject: [PATCH 055/115] otype -> "object type" --- crates/noirc_evaluator/src/ssa/code_gen.rs | 14 +++++++++----- cspell.json | 3 +-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/code_gen.rs b/crates/noirc_evaluator/src/ssa/code_gen.rs index 723003b2175..bc7251554d9 100644 --- a/crates/noirc_evaluator/src/ssa/code_gen.rs +++ b/crates/noirc_evaluator/src/ssa/code_gen.rs @@ -421,9 +421,13 @@ impl IRGenerator { let definition = Definition::Local(id); match value { Value::Single(node_id) => { - let otype = self.context.get_object_type(node_id); - let value = - self.bind_variable(name.to_owned(), Some(definition.clone()), otype, node_id)?; + let object_type = self.context.get_object_type(node_id); + let value = self.bind_variable( + name.to_owned(), + Some(definition.clone()), + object_type, + node_id, + )?; self.variable_values.insert(definition, value); } value @ Value::Tuple(_) => { @@ -441,8 +445,8 @@ impl IRGenerator { fn bind_fresh_pattern(&mut self, basename: &str, value: Value) -> Result { match value { Value::Single(node_id) => { - let otype = self.context.get_object_type(node_id); - self.bind_variable(basename.to_owned(), None, otype, node_id) + let object_type = self.context.get_object_type(node_id); + self.bind_variable(basename.to_owned(), None, object_type, node_id) } Value::Tuple(field_values) => { let values = field_values diff --git a/cspell.json b/cspell.json index ea244fe608b..56f5c65ee15 100644 --- a/cspell.json +++ b/cspell.json @@ -30,9 +30,8 @@ "rtype", "optim", "curr", - "coef", + "coeff", "ltype", - "otype", "notequal", "udiv", "sdiv", From 5c2f05461a913327a32482df5518a163aeae4a7e Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 13:18:43 +0000 Subject: [PATCH 056/115] coef_ -> coeff_ --- crates/noirc_evaluator/src/ssa/acir_gen.rs | 26 ++++++++++++---------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/acir_gen.rs b/crates/noirc_evaluator/src/ssa/acir_gen.rs index bd6040c045f..e72c139aa28 100644 --- a/crates/noirc_evaluator/src/ssa/acir_gen.rs +++ b/crates/noirc_evaluator/src/ssa/acir_gen.rs @@ -1089,24 +1089,26 @@ pub fn mul(a: &Expression, b: &Expression) -> Expression { let mut i1 = 0; //a let mut i2 = 0; //b while i1 < a.linear_combinations.len() && i2 < b.linear_combinations.len() { - let coef_a = b.q_c * a.linear_combinations[i1].0; - let coef_b = a.q_c * b.linear_combinations[i2].0; + let coeff_a = b.q_c * a.linear_combinations[i1].0; + let coeff_b = a.q_c * b.linear_combinations[i2].0; match a.linear_combinations[i1].1.cmp(&b.linear_combinations[i2].1) { Ordering::Greater => { - if coef_b != FieldElement::zero() { - output.linear_combinations.push((coef_b, b.linear_combinations[i2].1)); + if coeff_b != FieldElement::zero() { + output.linear_combinations.push((coeff_b, b.linear_combinations[i2].1)); } i2 += 1; } Ordering::Less => { - if coef_a != FieldElement::zero() { - output.linear_combinations.push((coef_a, a.linear_combinations[i1].1)); + if coeff_a != FieldElement::zero() { + output.linear_combinations.push((coeff_a, a.linear_combinations[i1].1)); } i1 += 1; } Ordering::Equal => { - if coef_a + coef_b != FieldElement::zero() { - output.linear_combinations.push((coef_a + coef_b, a.linear_combinations[i1].1)); + if coeff_a + coeff_b != FieldElement::zero() { + output + .linear_combinations + .push((coeff_a + coeff_b, a.linear_combinations[i1].1)); } i1 += 1; @@ -1115,13 +1117,13 @@ pub fn mul(a: &Expression, b: &Expression) -> Expression { } } while i1 < a.linear_combinations.len() { - let coef_a = b.q_c * a.linear_combinations[i1].0; - output.linear_combinations.push((coef_a, a.linear_combinations[i1].1)); + let coeff_a = b.q_c * a.linear_combinations[i1].0; + output.linear_combinations.push((coeff_a, a.linear_combinations[i1].1)); i1 += 1; } while i2 < b.linear_combinations.len() { - let coef_b = a.q_c * b.linear_combinations[i2].0; - output.linear_combinations.push((coef_b, b.linear_combinations[i2].1)); + let coeff_b = a.q_c * b.linear_combinations[i2].0; + output.linear_combinations.push((coeff_b, b.linear_combinations[i2].1)); i2 += 1; } From 54d40d2003b412c8c72c78f7f67cf0d55d2af8d4 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 13:19:37 +0000 Subject: [PATCH 057/115] coef -> coeff (Fix) --- crates/noirc_evaluator/src/ssa/acir_gen.rs | 36 +++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/acir_gen.rs b/crates/noirc_evaluator/src/ssa/acir_gen.rs index e72c139aa28..cd8cf4ff7d8 100644 --- a/crates/noirc_evaluator/src/ssa/acir_gen.rs +++ b/crates/noirc_evaluator/src/ssa/acir_gen.rs @@ -1145,9 +1145,9 @@ pub fn add(a: &Expression, k: FieldElement, b: &Expression) -> Expression { while i1 < a.linear_combinations.len() && i2 < b.linear_combinations.len() { match a.linear_combinations[i1].1.cmp(&b.linear_combinations[i2].1) { Ordering::Greater => { - let coef = b.linear_combinations[i2].0 * k; - if coef != FieldElement::zero() { - output.linear_combinations.push((coef, b.linear_combinations[i2].1)); + let coeff = b.linear_combinations[i2].0 * k; + if coeff != FieldElement::zero() { + output.linear_combinations.push((coeff, b.linear_combinations[i2].1)); } i2 += 1; } @@ -1156,9 +1156,9 @@ pub fn add(a: &Expression, k: FieldElement, b: &Expression) -> Expression { i1 += 1; } Ordering::Equal => { - let coef = a.linear_combinations[i1].0 + b.linear_combinations[i2].0 * k; - if coef != FieldElement::zero() { - output.linear_combinations.push((coef, a.linear_combinations[i1].1)); + let coeff = a.linear_combinations[i1].0 + b.linear_combinations[i2].0 * k; + if coeff != FieldElement::zero() { + output.linear_combinations.push((coeff, a.linear_combinations[i1].1)); } i2 += 1; i1 += 1; @@ -1170,9 +1170,9 @@ pub fn add(a: &Expression, k: FieldElement, b: &Expression) -> Expression { i1 += 1; } while i2 < b.linear_combinations.len() { - let coef = b.linear_combinations[i2].0 * k; - if coef != FieldElement::zero() { - output.linear_combinations.push((coef, b.linear_combinations[i2].1)); + let coeff = b.linear_combinations[i2].0 * k; + if coeff != FieldElement::zero() { + output.linear_combinations.push((coeff, b.linear_combinations[i2].1)); } i2 += 1; } @@ -1185,9 +1185,9 @@ pub fn add(a: &Expression, k: FieldElement, b: &Expression) -> Expression { while i1 < a.mul_terms.len() && i2 < b.mul_terms.len() { match (a.mul_terms[i1].1, a.mul_terms[i1].2).cmp(&(b.mul_terms[i2].1, b.mul_terms[i2].2)) { Ordering::Greater => { - let coef = b.mul_terms[i2].0 * k; - if coef != FieldElement::zero() { - output.mul_terms.push((coef, b.mul_terms[i2].1, b.mul_terms[i2].2)); + let coeff = b.mul_terms[i2].0 * k; + if coeff != FieldElement::zero() { + output.mul_terms.push((coeff, b.mul_terms[i2].1, b.mul_terms[i2].2)); } i2 += 1; } @@ -1196,9 +1196,9 @@ pub fn add(a: &Expression, k: FieldElement, b: &Expression) -> Expression { i1 += 1; } Ordering::Equal => { - let coef = a.mul_terms[i1].0 + b.mul_terms[i2].0 * k; - if coef != FieldElement::zero() { - output.mul_terms.push((coef, a.mul_terms[i1].1, a.mul_terms[i1].2)); + let coeff = a.mul_terms[i1].0 + b.mul_terms[i2].0 * k; + if coeff != FieldElement::zero() { + output.mul_terms.push((coeff, a.mul_terms[i1].1, a.mul_terms[i1].2)); } i2 += 1; i1 += 1; @@ -1211,9 +1211,9 @@ pub fn add(a: &Expression, k: FieldElement, b: &Expression) -> Expression { } while i2 < b.mul_terms.len() { - let coef = b.mul_terms[i2].0 * k; - if coef != FieldElement::zero() { - output.mul_terms.push((coef, b.mul_terms[i2].1, b.mul_terms[i2].2)); + let coeff = b.mul_terms[i2].0 * k; + if coeff != FieldElement::zero() { + output.mul_terms.push((coeff, b.mul_terms[i2].1, b.mul_terms[i2].2)); } i2 += 1; } From 197cd282f987270908fb0584ae139a63e4caf05b Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 13:20:22 +0000 Subject: [PATCH 058/115] flatenning -> flattening --- crates/noirc_evaluator/src/ssa/block.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/noirc_evaluator/src/ssa/block.rs b/crates/noirc_evaluator/src/ssa/block.rs index 247c446d082..07b7cffe8da 100644 --- a/crates/noirc_evaluator/src/ssa/block.rs +++ b/crates/noirc_evaluator/src/ssa/block.rs @@ -336,7 +336,7 @@ fn find_join_helper( } // Find the LCA of x and y -// n.b. this is a naive implementation which assumes there is no cycle in the graph, so it should be used after loop flatenning +// n.b. this is a naive implementation which assumes there is no cycle in the graph, so it should be used after loop flattening pub fn lca(ctx: &SsaContext, x: BlockId, y: BlockId) -> BlockId { if x == y { return x; From 5407b16693ec6e1318a9cf3e55d3bf90117b7a19 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 13:22:01 +0000 Subject: [PATCH 059/115] typevariable -> "type variable" --- crates/noirc_frontend/src/hir_def/types.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/noirc_frontend/src/hir_def/types.rs b/crates/noirc_frontend/src/hir_def/types.rs index 56242924e79..8f1841e3956 100644 --- a/crates/noirc_frontend/src/hir_def/types.rs +++ b/crates/noirc_frontend/src/hir_def/types.rs @@ -687,7 +687,7 @@ impl Type { TypeBinding::Unbound(id) => *id, }; - if let Some(binding) = self.get_inner_typevariable() { + if let Some(binding) = self.get_inner_type_variable() { match &*binding.borrow() { TypeBinding::Bound(typ) => return typ.try_bind_to(var), // Don't recursively bind the same id to itself @@ -706,7 +706,7 @@ impl Type { } } - fn get_inner_typevariable(&self) -> Option> { + fn get_inner_type_variable(&self) -> Option> { match self { Type::PolymorphicInteger(_, var) | Type::TypeVariable(var) From 76ae2196c8f5eaa24b08137a808478aab0f5cd8c Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 13:23:19 +0000 Subject: [PATCH 060/115] funcid -> "func id" --- crates/noirc_evaluator/src/ssa/context.rs | 6 +++--- crates/noirc_evaluator/src/ssa/function.rs | 4 ++-- crates/noirc_evaluator/src/ssa/inline.rs | 4 ++-- cspell.json | 1 - 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/context.rs b/crates/noirc_evaluator/src/ssa/context.rs index 8b808e4ffb7..676ab75d62e 100644 --- a/crates/noirc_evaluator/src/ssa/context.rs +++ b/crates/noirc_evaluator/src/ssa/context.rs @@ -234,7 +234,7 @@ impl SsaContext { Operation::Intrinsic(opcode, args) => format!("intrinsic {opcode}({})", join(args)), Operation::Nop => "nop".into(), Operation::Call { func, arguments, returned_arrays, .. } => { - let name = self.try_get_funcid(*func).map(|id| self.functions[&id].name.clone()); + let name = self.try_get_func_id(*func).map(|id| self.functions[&id].name.clone()); let name = name.unwrap_or_else(|| self.id_to_string(*func)); format!("call {name}({}) _ {returned_arrays:?}", join(arguments)) } @@ -378,7 +378,7 @@ impl SsaContext { self.functions.get(&func_id) } - pub fn try_get_funcid(&self, id: NodeId) -> Option { + pub fn try_get_func_id(&self, id: NodeId) -> Option { match &self[id] { NodeObj::Function(FunctionKind::Normal(id), ..) => Some(*id), _ => None, @@ -386,7 +386,7 @@ impl SsaContext { } pub fn try_get_ssafunc(&self, id: NodeId) -> Option<&SSAFunction> { - self.try_get_funcid(id).and_then(|id| self.get_ssafunc(id)) + self.try_get_func_id(id).and_then(|id| self.get_ssafunc(id)) } pub fn dummy_id() -> arena::Index { diff --git a/crates/noirc_evaluator/src/ssa/function.rs b/crates/noirc_evaluator/src/ssa/function.rs index 230dd182e67..3d54c302a65 100644 --- a/crates/noirc_evaluator/src/ssa/function.rs +++ b/crates/noirc_evaluator/src/ssa/function.rs @@ -253,7 +253,7 @@ impl IRGenerator { let call_instruction = self.context.new_instruction(call_op.clone(), ObjectType::NotAnObject)?; - if let Some(id) = self.context.try_get_funcid(func) { + if let Some(id) = self.context.try_get_func_id(func) { let callee = self.context.get_ssafunc(id).unwrap().idx; if let Some(caller) = self.function_context { update_call_graph(&mut self.context.call_graph, caller, callee); @@ -265,7 +265,7 @@ impl IRGenerator { // return an array of size 0. // we should check issue #628 again when this block is removed // we should also see if the lca check in StackFrame.is_new_array() can be removed (cf. issue #661) - if let Some(func_id) = self.context.try_get_funcid(func) { + if let Some(func_id) = self.context.try_get_func_id(func) { let rtt = self.context.functions[&func_id].result_types.clone(); let mut result = Vec::new(); for i in rtt.iter().enumerate() { diff --git a/crates/noirc_evaluator/src/ssa/inline.rs b/crates/noirc_evaluator/src/ssa/inline.rs index 0373f8d00c8..f59bc45af5d 100644 --- a/crates/noirc_evaluator/src/ssa/inline.rs +++ b/crates/noirc_evaluator/src/ssa/inline.rs @@ -71,7 +71,7 @@ fn inline_block( if let Some(ins) = ctx.try_get_instruction(*i) { if !ins.is_deleted() { if let Operation::Call { func, arguments, returned_arrays, .. } = &ins.operation { - if to_inline.is_none() || to_inline == ctx.try_get_funcid(*func) { + if to_inline.is_none() || to_inline == ctx.try_get_func_id(*func) { call_ins.push(( ins.id, *func, @@ -86,7 +86,7 @@ fn inline_block( } let mut result = true; for (ins_id, f, args, arrays, parent_block) in call_ins { - if let Some(func_id) = ctx.try_get_funcid(f) { + if let Some(func_id) = ctx.try_get_func_id(f) { let f_copy = ctx.get_ssafunc(func_id).unwrap().clone(); if !inline(ctx, &f_copy, &args, &arrays, parent_block, ins_id, decision)? { result = false; diff --git a/cspell.json b/cspell.json index 56f5c65ee15..ecd32c5013c 100644 --- a/cspell.json +++ b/cspell.json @@ -23,7 +23,6 @@ "codegen", "lvalue", "vecmap", - "funcid", "ssafunc", "forall", "signedness", From 874fbf32a225a7d9cebe72a66ba2c044fc16481c Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 13:24:44 +0000 Subject: [PATCH 061/115] ssafunc -> "ssa func" --- crates/noirc_evaluator/src/ssa/block.rs | 2 +- crates/noirc_evaluator/src/ssa/context.rs | 8 ++++---- crates/noirc_evaluator/src/ssa/function.rs | 4 ++-- crates/noirc_evaluator/src/ssa/inline.rs | 4 ++-- crates/noirc_evaluator/src/ssa/optim.rs | 2 +- cspell.json | 1 - 6 files changed, 10 insertions(+), 11 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/block.rs b/crates/noirc_evaluator/src/ssa/block.rs index 07b7cffe8da..4c9ceaa2c4e 100644 --- a/crates/noirc_evaluator/src/ssa/block.rs +++ b/crates/noirc_evaluator/src/ssa/block.rs @@ -116,7 +116,7 @@ impl BasicBlock { for a in returned_arrays { result.insert(a.0); } - if let Some(f) = ctx.try_get_ssafunc(*func) { + if let Some(f) = ctx.try_get_ssa_func(*func) { for typ in &f.result_types { if let node::ObjectType::Pointer(a) = typ { result.insert(*a); diff --git a/crates/noirc_evaluator/src/ssa/context.rs b/crates/noirc_evaluator/src/ssa/context.rs index 676ab75d62e..bc935eea1dc 100644 --- a/crates/noirc_evaluator/src/ssa/context.rs +++ b/crates/noirc_evaluator/src/ssa/context.rs @@ -374,7 +374,7 @@ impl SsaContext { id } - pub fn get_ssafunc(&self, func_id: FuncId) -> Option<&SSAFunction> { + pub fn get_ssa_func(&self, func_id: FuncId) -> Option<&SSAFunction> { self.functions.get(&func_id) } @@ -385,8 +385,8 @@ impl SsaContext { } } - pub fn try_get_ssafunc(&self, id: NodeId) -> Option<&SSAFunction> { - self.try_get_func_id(id).and_then(|id| self.get_ssafunc(id)) + pub fn try_get_ssa_func(&self, id: NodeId) -> Option<&SSAFunction> { + self.try_get_func_id(id).and_then(|id| self.get_ssa_func(id)) } pub fn dummy_id() -> arena::Index { @@ -1091,7 +1091,7 @@ impl SsaContext { } pub fn function_already_compiled(&self, func_id: FuncId) -> bool { - self.get_ssafunc(func_id).is_some() + self.get_ssa_func(func_id).is_some() } pub fn get_or_create_opcode_node_id(&mut self, opcode: builtin::Opcode) -> NodeId { diff --git a/crates/noirc_evaluator/src/ssa/function.rs b/crates/noirc_evaluator/src/ssa/function.rs index 3d54c302a65..b711f6f1f49 100644 --- a/crates/noirc_evaluator/src/ssa/function.rs +++ b/crates/noirc_evaluator/src/ssa/function.rs @@ -254,7 +254,7 @@ impl IRGenerator { self.context.new_instruction(call_op.clone(), ObjectType::NotAnObject)?; if let Some(id) = self.context.try_get_func_id(func) { - let callee = self.context.get_ssafunc(id).unwrap().idx; + let callee = self.context.get_ssa_func(id).unwrap().idx; if let Some(caller) = self.function_context { update_call_graph(&mut self.context.call_graph, caller, callee); } @@ -274,7 +274,7 @@ impl IRGenerator { *i.1, )?); } - let ssa_func = self.context.get_ssafunc(func_id).unwrap(); + let ssa_func = self.context.get_ssa_func(func_id).unwrap(); let func_arguments = ssa_func.arguments.clone(); for (caller_arg, func_arg) in arguments.iter().zip(func_arguments) { let mut is_array_result = false; diff --git a/crates/noirc_evaluator/src/ssa/inline.rs b/crates/noirc_evaluator/src/ssa/inline.rs index f59bc45af5d..090cc175ecf 100644 --- a/crates/noirc_evaluator/src/ssa/inline.rs +++ b/crates/noirc_evaluator/src/ssa/inline.rs @@ -48,7 +48,7 @@ pub fn inline_cfg( to_inline: Option, ) -> Result { let mut result = true; - let func = ctx.get_ssafunc(func_id).unwrap(); + let func = ctx.get_ssa_func(func_id).unwrap(); let func_cfg = block::bfs(func.entry_block, None, ctx); let decision = func.decision.clone(); for block_id in func_cfg { @@ -87,7 +87,7 @@ fn inline_block( let mut result = true; for (ins_id, f, args, arrays, parent_block) in call_ins { if let Some(func_id) = ctx.try_get_func_id(f) { - let f_copy = ctx.get_ssafunc(func_id).unwrap().clone(); + let f_copy = ctx.get_ssa_func(func_id).unwrap().clone(); if !inline(ctx, &f_copy, &args, &arrays, parent_block, ins_id, decision)? { result = false; } diff --git a/crates/noirc_evaluator/src/ssa/optim.rs b/crates/noirc_evaluator/src/ssa/optim.rs index c0fa4db5011..a9708964300 100644 --- a/crates/noirc_evaluator/src/ssa/optim.rs +++ b/crates/noirc_evaluator/src/ssa/optim.rs @@ -290,7 +290,7 @@ fn cse_block_with_anchor( let id = ctx.get_dummy_store(a.0); anchor.push_mem_instruction(ctx, id)?; } - if let Some(f) = ctx.try_get_ssafunc(*func) { + if let Some(f) = ctx.try_get_ssa_func(*func) { for typ in &f.result_types { if let ObjectType::Pointer(a) = typ { let id = ctx.get_dummy_store(*a); diff --git a/cspell.json b/cspell.json index ecd32c5013c..7a34b9b1032 100644 --- a/cspell.json +++ b/cspell.json @@ -23,7 +23,6 @@ "codegen", "lvalue", "vecmap", - "ssafunc", "forall", "signedness", "rtype", From 1fa5d15dc1ae0d6139171773c6097467fb4543c4 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 13:25:37 +0000 Subject: [PATCH 062/115] add todo for optim --- cspell.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cspell.json b/cspell.json index 7a34b9b1032..07251cfdfc2 100644 --- a/cspell.json +++ b/cspell.json @@ -26,6 +26,8 @@ "forall", "signedness", "rtype", + // TODO: we should just name this more descriptively + // TODO: ie is it optimisations or optimiser? "optim", "curr", "coeff", From 4df325dae61a7f7b1776c05648345cdc211fb47f Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 13:27:58 +0000 Subject: [PATCH 063/115] notequal -> "not equal" --- crates/noirc_evaluator/src/ssa/code_gen.rs | 4 ++-- cspell.json | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/code_gen.rs b/crates/noirc_evaluator/src/ssa/code_gen.rs index bc7251554d9..360814c5571 100644 --- a/crates/noirc_evaluator/src/ssa/code_gen.rs +++ b/crates/noirc_evaluator/src/ssa/code_gen.rs @@ -724,8 +724,8 @@ impl IRGenerator { let phi = self.context.generate_empty_phi(join_idx, iter_id); self.update_variable_id(iter_id, iter_id, phi); //is it still needed? - let notequal = Operation::binary(BinaryOp::Ne, phi, end_idx); - let cond = self.context.new_instruction(notequal, ObjectType::Boolean)?; + let not_equal = Operation::binary(BinaryOp::Ne, phi, end_idx); + let cond = self.context.new_instruction(not_equal, ObjectType::Boolean)?; let to_fix = self.context.new_instruction(Operation::Nop, ObjectType::NotAnObject)?; diff --git a/cspell.json b/cspell.json index 07251cfdfc2..d20f878f668 100644 --- a/cspell.json +++ b/cspell.json @@ -32,7 +32,6 @@ "curr", "coeff", "ltype", - "notequal", "udiv", "sdiv", "urem", From 4c67698434b8a6a2594c22db6d284c711f8ef103 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 13:28:16 +0000 Subject: [PATCH 064/115] constrain -> (remove) --- cspell.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cspell.json b/cspell.json index d20f878f668..5ff70f6e203 100644 --- a/cspell.json +++ b/cspell.json @@ -27,7 +27,7 @@ "signedness", "rtype", // TODO: we should just name this more descriptively - // TODO: ie is it optimisations or optimiser? + // TODO: ie is it optimizations or optimizer? "optim", "curr", "coeff", @@ -37,7 +37,6 @@ "urem", "srem", "nvar", - "constrain", "bsize", "eucl", "igen", From 98e5c5b8b20aea6ed4041eea064a009e92f71409 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 13:34:54 +0000 Subject: [PATCH 065/115] bsize -> "bit size" --- crates/noirc_evaluator/src/ssa/acir_gen.rs | 8 ++++---- cspell.json | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/acir_gen.rs b/crates/noirc_evaluator/src/ssa/acir_gen.rs index cd8cf4ff7d8..504f56d629b 100644 --- a/crates/noirc_evaluator/src/ssa/acir_gen.rs +++ b/crates/noirc_evaluator/src/ssa/acir_gen.rs @@ -869,8 +869,8 @@ fn evaluate_bitwise( let mut b_witness = rhs.generate_witness(evaluator); let result = evaluator.add_witness_to_cs(); - let bsize = if bit_size % 2 == 1 { bit_size + 1 } else { bit_size }; - assert!(bsize < FieldElement::max_num_bits() - 1); + let bit_size = if bit_size % 2 == 1 { bit_size + 1 } else { bit_size }; + assert!(bit_size < FieldElement::max_num_bits() - 1); let max = FieldElement::from((1_u128 << bit_size) - 1); let bit_gate = match opcode { BinaryOp::And => acvm::acir::BlackBoxFunc::AND, @@ -894,8 +894,8 @@ fn evaluate_bitwise( let gate = AcirOpcode::BlackBoxFuncCall(BlackBoxFuncCall { name: bit_gate, inputs: vec![ - FunctionInput { witness: a_witness, num_bits: bsize }, - FunctionInput { witness: b_witness, num_bits: bsize }, + FunctionInput { witness: a_witness, num_bits: bit_size }, + FunctionInput { witness: b_witness, num_bits: bit_size }, ], outputs: vec![result], }); diff --git a/cspell.json b/cspell.json index 5ff70f6e203..d546a185927 100644 --- a/cspell.json +++ b/cspell.json @@ -37,7 +37,6 @@ "urem", "srem", "nvar", - "bsize", "eucl", "igen", "nodeobj", From fbf89fdeef3bd836c41609f9e98ad878025b582e Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 2 Feb 2023 16:10:23 +0000 Subject: [PATCH 066/115] eucl -> euclidean --- crates/noirc_evaluator/src/ssa/acir_gen.rs | 4 ++-- cspell.json | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/acir_gen.rs b/crates/noirc_evaluator/src/ssa/acir_gen.rs index 504f56d629b..41855523265 100644 --- a/crates/noirc_evaluator/src/ssa/acir_gen.rs +++ b/crates/noirc_evaluator/src/ssa/acir_gen.rs @@ -982,9 +982,9 @@ pub fn evaluate_udiv( let mut d = mul_with_witness(evaluator, &rhs.expression, &Expression::from(&q_witness)); d = add(&d, FieldElement::one(), &Expression::from(&r_witness)); d = mul_with_witness(evaluator, &d, &predicate.expression); - let div_eucl = subtract(&pa, FieldElement::one(), &d); + let div_euclidean = subtract(&pa, FieldElement::one(), &d); - evaluator.opcodes.push(AcirOpcode::Arithmetic(div_eucl)); + evaluator.opcodes.push(AcirOpcode::Arithmetic(div_euclidean)); (q_witness, r_witness) } diff --git a/cspell.json b/cspell.json index d546a185927..119f849b45d 100644 --- a/cspell.json +++ b/cspell.json @@ -37,7 +37,6 @@ "urem", "srem", "nvar", - "eucl", "igen", "nodeobj", "Barretenberg", From 4132c1569775f3a749a105a151537483cf59f55f Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 11:39:53 +0000 Subject: [PATCH 067/115] shortfield -> "short field" --- crates/noirc_frontend/src/parser/parser.rs | 4 ++-- cspell.json | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/noirc_frontend/src/parser/parser.rs b/crates/noirc_frontend/src/parser/parser.rs index 22e0a352d83..9c7737cfcf0 100644 --- a/crates/noirc_frontend/src/parser/parser.rs +++ b/crates/noirc_frontend/src/parser/parser.rs @@ -378,11 +378,11 @@ fn pattern() -> impl NoirParser { .ignore_then(pattern.clone()) .map_with_span(|inner, span| Pattern::Mutable(Box::new(inner), span)); - let shortfield = ident().map(|name| (name.clone(), Pattern::Identifier(name))); + let short_field = ident().map(|name| (name.clone(), Pattern::Identifier(name))); let longfield = ident().then_ignore(just(Token::Colon)).then(pattern.clone()); let struct_pattern_fields = longfield - .or(shortfield) + .or(short_field) .separated_by(just(Token::Comma)) .delimited_by(just(Token::LeftBrace), just(Token::RightBrace)); diff --git a/cspell.json b/cspell.json index 119f849b45d..5f944aed92b 100644 --- a/cspell.json +++ b/cspell.json @@ -54,7 +54,6 @@ "idents", "foldl", "comptime", - "shortfield", "longfield", "failable", "subexpr", From d42667b2c35c7dd7c6196b6b7a1da2770ca7345e Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 11:40:29 +0000 Subject: [PATCH 068/115] longfield -> "long field" --- crates/noirc_frontend/src/parser/parser.rs | 4 ++-- cspell.json | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/noirc_frontend/src/parser/parser.rs b/crates/noirc_frontend/src/parser/parser.rs index 9c7737cfcf0..7b818601c5c 100644 --- a/crates/noirc_frontend/src/parser/parser.rs +++ b/crates/noirc_frontend/src/parser/parser.rs @@ -379,9 +379,9 @@ fn pattern() -> impl NoirParser { .map_with_span(|inner, span| Pattern::Mutable(Box::new(inner), span)); let short_field = ident().map(|name| (name.clone(), Pattern::Identifier(name))); - let longfield = ident().then_ignore(just(Token::Colon)).then(pattern.clone()); + let long_field = ident().then_ignore(just(Token::Colon)).then(pattern.clone()); - let struct_pattern_fields = longfield + let struct_pattern_fields = long_field .or(short_field) .separated_by(just(Token::Comma)) .delimited_by(just(Token::LeftBrace), just(Token::RightBrace)); diff --git a/cspell.json b/cspell.json index 5f944aed92b..0a58a58f7c4 100644 --- a/cspell.json +++ b/cspell.json @@ -54,7 +54,6 @@ "idents", "foldl", "comptime", - "longfield", "failable", "subexpr", "myfunc", From 3eccf1e2a9ea82bcb09cab7e34e7b09c099ddda8 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 11:49:07 +0000 Subject: [PATCH 069/115] "myfunc" -> "my_func" --- crates/noirc_frontend/src/parser/parser.rs | 2 +- cspell.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/noirc_frontend/src/parser/parser.rs b/crates/noirc_frontend/src/parser/parser.rs index 7b818601c5c..c629058952e 100644 --- a/crates/noirc_frontend/src/parser/parser.rs +++ b/crates/noirc_frontend/src/parser/parser.rs @@ -656,7 +656,7 @@ where MemberAccess((Ident, Option>)), } - // `(arg1, ..., argN)` in `myfunc(arg1, ..., argN)` + // `(arg1, ..., argN)` in `my_func(arg1, ..., argN)` let call_rhs = parenthesized(expression_list(expr_parser.clone())).map(UnaryRhs::Call); // `[expr]` in `arr[expr]` diff --git a/cspell.json b/cspell.json index 0a58a58f7c4..52c8125d915 100644 --- a/cspell.json +++ b/cspell.json @@ -56,7 +56,6 @@ "comptime", "failable", "subexpr", - "myfunc", "desugared", "elems", "bindgen", From fe53f4b918504bd36ba164cac89d1cb38ada02ac Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 11:50:33 +0000 Subject: [PATCH 070/115] arithematic -> arithmetic --- crates/noirc_frontend/src/lexer/lexer.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/noirc_frontend/src/lexer/lexer.rs b/crates/noirc_frontend/src/lexer/lexer.rs index 5eafec622de..6679128815a 100644 --- a/crates/noirc_frontend/src/lexer/lexer.rs +++ b/crates/noirc_frontend/src/lexer/lexer.rs @@ -447,7 +447,7 @@ fn test_int_type() { } #[test] -fn test_arithematic_sugar() { +fn test_arithmetic_sugar() { let input = "+= -= *= /= %="; let expected = vec![ From adeca4d1bbae692edd2f40db17fc307ee68d4208 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 11:52:20 +0000 Subject: [PATCH 071/115] maxbits -> "max bits" --- crates/noirc_evaluator/src/ssa/integer.rs | 8 ++++---- cspell.json | 3 --- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/integer.rs b/crates/noirc_evaluator/src/ssa/integer.rs index 2deb1bfa328..e0ff5a2d0d8 100644 --- a/crates/noirc_evaluator/src/ssa/integer.rs +++ b/crates/noirc_evaluator/src/ssa/integer.rs @@ -120,7 +120,7 @@ fn truncate( if *v_max >= BigUint::one() << bit_size { //TODO is max_bit_size leaking some info???? - //Create a new truncate instruction '(idx): obj trunc bit_size' + //Create a new truncate instruction '(idx): obj truncate bit_size' //set current value of obj to idx let max_bit_size = v_max.bits() as u32; @@ -347,15 +347,15 @@ fn block_overflow( ins.mark = Mark::ReplaceWith(value_id); } else { let max = get_obj_max_value(ctx, value_id, max_map, &value_map); - let maxbits = max.bits() as u32; + let max_bits = max.bits() as u32; - if ins.res_type.bits() < get_size_in_bits(obj) && maxbits > ins.res_type.bits() + if ins.res_type.bits() < get_size_in_bits(obj) && max_bits > ins.res_type.bits() { //we need to truncate ins.operation = Operation::Truncate { value: value_id, bit_size: ins.res_type.bits(), - max_bit_size: maxbits, + max_bit_size: max_bits, }; } } diff --git a/cspell.json b/cspell.json index 52c8125d915..73acc1c2408 100644 --- a/cspell.json +++ b/cspell.json @@ -81,9 +81,6 @@ "pvalue", "binop", "vmap", - "trunc", - "memorymaps", - "maxbits", "arithmetization", "bitand", "bitcount", From b48003e4d10ae531a978163d37974fb8f1a97322 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 11:53:21 +0000 Subject: [PATCH 072/115] typenames -> "type names" --- crates/noirc_frontend/src/ast/mod.rs | 2 +- cspell.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/noirc_frontend/src/ast/mod.rs b/crates/noirc_frontend/src/ast/mod.rs index f9c01ff6380..94fd5146b18 100644 --- a/crates/noirc_frontend/src/ast/mod.rs +++ b/crates/noirc_frontend/src/ast/mod.rs @@ -16,7 +16,7 @@ use crate::{parser::ParserError, token::IntType, BinaryTypeOperator, Comptime}; use iter_extended::vecmap; /// The parser parses types as 'UnresolvedType's which -/// require name resolution to resolve any typenames used +/// require name resolution to resolve any type names used /// for structs within, but are otherwise identical to Types. #[derive(Debug, PartialEq, Eq, Clone)] pub enum UnresolvedType { diff --git a/cspell.json b/cspell.json index 73acc1c2408..59385a2fca8 100644 --- a/cspell.json +++ b/cspell.json @@ -86,7 +86,6 @@ "bitcount", "subexpression", "binded", - "typenames", "smol", "krate", "Comptimes", From 873df26c47e8873390b20b87ae1df6e034c456fc Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 11:54:24 +0000 Subject: [PATCH 073/115] typecheck -> "type check" --- crates/noirc_frontend/src/hir/type_check/expr.rs | 4 ++-- cspell.json | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/noirc_frontend/src/hir/type_check/expr.rs b/crates/noirc_frontend/src/hir/type_check/expr.rs index 91c58ca2d9e..e0099ad22fc 100644 --- a/crates/noirc_frontend/src/hir/type_check/expr.rs +++ b/crates/noirc_frontend/src/hir/type_check/expr.rs @@ -384,7 +384,7 @@ fn lookup_method( } } -// We need a special function to typecheck method calls since the method +// We need a special function to type check method calls since the method // is not a Expression::Ident it must be manually instantiated here fn type_check_method_call( interner: &mut NodeInterner, @@ -426,7 +426,7 @@ fn bind_function_type( errors: &mut Vec, ) -> Type { // Could do a single unification for the entire function type, but matching beforehand - // lets us issue a more precise error on the individual argument that fails to typecheck. + // lets us issue a more precise error on the individual argument that fails to type check. match function { Type::TypeVariable(binding) => { if let TypeBinding::Bound(typ) = &*binding.borrow() { diff --git a/cspell.json b/cspell.json index 59385a2fca8..6406231ca2e 100644 --- a/cspell.json +++ b/cspell.json @@ -97,7 +97,6 @@ "typevar", "forscope", "arity", - "typecheck", "hindley", "milner", "peekable", From ff95eeb73d68b155b8dc99bfc6217053716e6001 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 11:56:19 +0000 Subject: [PATCH 074/115] preprocess -> "pre-process" --- README.md | 2 +- cspell.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index f5e6d0ec229..c03b9de897e 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ The current focus is to gather as much feedback as possible while in the alpha p Concretely the following items are on the road map: - General code sanitization and documentation (ongoing effort) -- Prover and Verifier Key logic. (Prover and Verifier preprocess per compile) +- Prover and Verifier Key logic. (Prover and Verifier pre-process per compile) - Fallback mechanism for backend unsupported opcodes - Visibility modifiers - Signed integers diff --git a/cspell.json b/cspell.json index 6406231ca2e..e85a01a9c59 100644 --- a/cspell.json +++ b/cspell.json @@ -104,7 +104,6 @@ "arraylen", "struct", "stdlib", - "preprocess", "noirup", "monomorphization", "monomorphized", From 8633133c5f4f83cdc9ec415736e12029f820f328 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 12:08:53 +0000 Subject: [PATCH 075/115] comptime -> "comp time" --- crates/noirc_frontend/src/ast/mod.rs | 10 +- .../noirc_frontend/src/hir/type_check/expr.rs | 22 +-- .../noirc_frontend/src/hir/type_check/mod.rs | 2 +- .../noirc_frontend/src/hir/type_check/stmt.rs | 6 +- crates/noirc_frontend/src/hir_def/types.rs | 126 +++++++++--------- crates/noirc_frontend/src/lexer/token.rs | 6 +- .../src/monomorphization/mod.rs | 8 +- crates/noirc_frontend/src/parser/parser.rs | 16 +-- cspell.json | 1 - 9 files changed, 98 insertions(+), 99 deletions(-) diff --git a/crates/noirc_frontend/src/ast/mod.rs b/crates/noirc_frontend/src/ast/mod.rs index 94fd5146b18..725455a8598 100644 --- a/crates/noirc_frontend/src/ast/mod.rs +++ b/crates/noirc_frontend/src/ast/mod.rs @@ -12,7 +12,7 @@ use noirc_errors::Span; pub use statement::*; pub use structure::*; -use crate::{parser::ParserError, token::IntType, BinaryTypeOperator, Comptime}; +use crate::{parser::ParserError, token::IntType, BinaryTypeOperator, CompTime}; use iter_extended::vecmap; /// The parser parses types as 'UnresolvedType's which @@ -20,10 +20,10 @@ use iter_extended::vecmap; /// for structs within, but are otherwise identical to Types. #[derive(Debug, PartialEq, Eq, Clone)] pub enum UnresolvedType { - FieldElement(Comptime), + FieldElement(CompTime), Array(Option, Box), // [4]Witness = Array(4, Witness) - Integer(Comptime, Signedness, u32), // u32 = Integer(unsigned, 32) - Bool(Comptime), + Integer(CompTime, Signedness, u32), // u32 = Integer(unsigned, 32) + Bool(CompTime), Expression(UnresolvedTypeExpression), String(Option), Unit, @@ -116,7 +116,7 @@ impl std::fmt::Display for UnresolvedTypeExpression { } impl UnresolvedType { - pub fn from_int_token(token: (Comptime, IntType)) -> UnresolvedType { + pub fn from_int_token(token: (CompTime, IntType)) -> UnresolvedType { use {IntType::*, UnresolvedType::Integer}; match token.1 { Signed(num_bits) => Integer(token.0, Signedness::Signed, num_bits), diff --git a/crates/noirc_frontend/src/hir/type_check/expr.rs b/crates/noirc_frontend/src/hir/type_check/expr.rs index e0099ad22fc..02218bf266b 100644 --- a/crates/noirc_frontend/src/hir/type_check/expr.rs +++ b/crates/noirc_frontend/src/hir/type_check/expr.rs @@ -7,7 +7,7 @@ use crate::{ types::Type, }, node_interner::{ExprId, FuncId, NodeInterner}, - Comptime, Shared, TypeBinding, + CompTime, Shared, TypeBinding, }; use super::{bind_pattern, errors::TypeCheckError}; @@ -60,11 +60,11 @@ pub(crate) fn type_check_expression( arr_type } - HirLiteral::Bool(_) => Type::Bool(Comptime::new(interner)), + HirLiteral::Bool(_) => Type::Bool(CompTime::new(interner)), HirLiteral::Integer(_) => { let id = interner.next_type_variable_id(); Type::PolymorphicInteger( - Comptime::new(interner), + CompTime::new(interner), Shared::new(TypeBinding::Unbound(id)), ) } @@ -584,7 +584,7 @@ pub fn infix_operand_type_rules( return infix_operand_type_rules(binding, op, other, span, interner, errors); } - let comptime = Comptime::No(None); + let comptime = CompTime::No(None); if other.try_bind_to_polymorphic_int(var, &comptime, true, op.location.span).is_ok() || other == &Type::Error { Ok(other.clone()) } else { @@ -606,9 +606,9 @@ fn check_if_expr( let then_type = type_check_expression(interner, &if_expr.consequence, errors); let expr_span = interner.expr_span(&if_expr.condition); - cond_type.unify(&Type::Bool(Comptime::new(interner)), expr_span, errors, || { + cond_type.unify(&Type::Bool(CompTime::new(interner)), expr_span, errors, || { TypeCheckError::TypeMismatch { - expected_typ: Type::Bool(Comptime::No(None)).to_string(), + expected_typ: Type::Bool(CompTime::No(None)).to_string(), expr_typ: cond_type.to_string(), expr_span, } @@ -768,7 +768,7 @@ pub fn comparator_operand_type_rules( } // Avoid reporting errors multiple times - (Error, _) | (_,Error) => Ok(Bool(Comptime::Yes(None))), + (Error, _) | (_,Error) => Ok(Bool(CompTime::Yes(None))), // Special-case == and != for arrays (Array(x_size, x_type), Array(y_size, y_type)) if matches!(op.kind, Equal | NotEqual) => { @@ -787,11 +787,11 @@ pub fn comparator_operand_type_rules( }); // We could check if all elements of all arrays are comptime but I am lazy - Ok(Bool(Comptime::No(Some(op.location.span)))) + Ok(Bool(CompTime::No(Some(op.location.span)))) } (NamedGeneric(binding_a, name_a), NamedGeneric(binding_b, name_b)) => { if binding_a == binding_b { - return Ok(Bool(Comptime::No(Some(op.location.span)))); + return Ok(Bool(CompTime::No(Some(op.location.span)))); } Err(format!("Unsupported types for comparison: {name_a} and {name_b}")) } @@ -801,7 +801,7 @@ pub fn comparator_operand_type_rules( return comparator_operand_type_rules(binding, other, op, errors); } - let comptime = Comptime::No(None); + let comptime = CompTime::No(None); if other.try_bind_to_polymorphic_int(var, &comptime, true, op.location.span).is_ok() || other == &Type::Error { Ok(other.clone()) } else { @@ -816,7 +816,7 @@ pub fn comparator_operand_type_rules( } }); - Ok(Bool(Comptime::No(Some(op.location.span)))) + Ok(Bool(CompTime::No(Some(op.location.span)))) } (lhs, rhs) => Err(format!("Unsupported types for comparison: {lhs} and {rhs}")), } diff --git a/crates/noirc_frontend/src/hir/type_check/mod.rs b/crates/noirc_frontend/src/hir/type_check/mod.rs index f659a14797e..8453d5e5f77 100644 --- a/crates/noirc_frontend/src/hir/type_check/mod.rs +++ b/crates/noirc_frontend/src/hir/type_check/mod.rs @@ -126,7 +126,7 @@ mod test { // Create let statement let let_stmt = HirLetStatement { pattern: Identifier(z), - r#type: Type::FieldElement(crate::Comptime::No(None)), + r#type: Type::FieldElement(crate::CompTime::No(None)), expression: expr_id, }; let stmt_id = interner.push_stmt(HirStatement::Let(let_stmt)); diff --git a/crates/noirc_frontend/src/hir/type_check/stmt.rs b/crates/noirc_frontend/src/hir/type_check/stmt.rs index 8f91337431a..966fa4bace7 100644 --- a/crates/noirc_frontend/src/hir/type_check/stmt.rs +++ b/crates/noirc_frontend/src/hir/type_check/stmt.rs @@ -5,7 +5,7 @@ use crate::hir_def::stmt::{ }; use crate::hir_def::types::Type; use crate::node_interner::{DefinitionId, ExprId, NodeInterner, StmtId}; -use crate::Comptime; +use crate::CompTime; use super::{errors::TypeCheckError, expr::type_check_expression}; @@ -235,10 +235,10 @@ fn type_check_constrain_stmt( let expr_type = type_check_expression(interner, &stmt.0, errors); let expr_span = interner.expr_span(&stmt.0); - expr_type.unify(&Type::Bool(Comptime::new(interner)), expr_span, errors, || { + expr_type.unify(&Type::Bool(CompTime::new(interner)), expr_span, errors, || { TypeCheckError::TypeMismatch { expr_typ: expr_type.to_string(), - expected_typ: Type::Bool(Comptime::No(None)).to_string(), + expected_typ: Type::Bool(CompTime::No(None)).to_string(), expr_span, } }); diff --git a/crates/noirc_frontend/src/hir_def/types.rs b/crates/noirc_frontend/src/hir_def/types.rs index 8f1841e3956..3afcc0a395b 100644 --- a/crates/noirc_frontend/src/hir_def/types.rs +++ b/crates/noirc_frontend/src/hir_def/types.rs @@ -190,11 +190,11 @@ impl std::fmt::Display for StructType { #[derive(Debug, PartialEq, Eq, Clone, Hash)] pub enum Type { - FieldElement(Comptime), + FieldElement(CompTime), Array(Box, Box), // Array(4, Field) = [Field; 4] - Integer(Comptime, Signedness, u32), // u32 = Integer(unsigned, 32) - PolymorphicInteger(Comptime, TypeVariable), - Bool(Comptime), + Integer(CompTime, Signedness, u32), // u32 = Integer(unsigned, 32) + PolymorphicInteger(CompTime, TypeVariable), + Bool(CompTime), String(Box), Unit, Struct(Shared, Vec), @@ -251,19 +251,19 @@ impl TypeBinding { pub struct TypeVariableId(pub usize); #[derive(Debug, Clone, Eq)] -pub enum Comptime { +pub enum CompTime { // Yes and No variants have optional spans representing the location in the source code - // which caused them to be comptime. + // which caused them to be compile time. Yes(Option), No(Option), - Maybe(TypeVariableId, Rc>>), + Maybe(TypeVariableId, Rc>>), } -impl std::hash::Hash for Comptime { +impl std::hash::Hash for CompTime { fn hash(&self, state: &mut H) { core::mem::discriminant(self).hash(state); - if let Comptime::Maybe(id, binding) = self { + if let CompTime::Maybe(id, binding) = self { if let Some(is_comptime) = &*binding.borrow() { is_comptime.hash(state); } else { @@ -273,10 +273,10 @@ impl std::hash::Hash for Comptime { } } -impl PartialEq for Comptime { +impl PartialEq for CompTime { fn eq(&self, other: &Self) -> bool { match (self, other) { - (Comptime::Maybe(id1, binding1), Comptime::Maybe(id2, binding2)) => { + (CompTime::Maybe(id1, binding1), CompTime::Maybe(id2, binding2)) => { if let Some(new_self) = &*binding1.borrow() { return new_self == other; } @@ -285,7 +285,7 @@ impl PartialEq for Comptime { } id1 == id2 } - (Comptime::Yes(_), Comptime::Yes(_)) | (Comptime::No(_), Comptime::No(_)) => true, + (CompTime::Yes(_), CompTime::Yes(_)) | (CompTime::No(_), CompTime::No(_)) => true, _ => false, } } @@ -295,12 +295,12 @@ impl PartialEq for Comptime { /// to provide better error messages #[derive(Debug)] pub enum SpanKind { - Comptime(Span), + CompTime(Span), NotComptime(Span), None, } -impl Comptime { +impl CompTime { pub fn new(interner: &mut NodeInterner) -> Self { let id = interner.next_type_variable_id(); Self::Maybe(id, Rc::new(RefCell::new(None))) @@ -308,8 +308,8 @@ impl Comptime { fn set_span(&mut self, new_span: Span) { match self { - Comptime::Yes(span) | Comptime::No(span) => *span = Some(new_span), - Comptime::Maybe(_, binding) => { + CompTime::Yes(span) | CompTime::No(span) => *span = Some(new_span), + CompTime::Maybe(_, binding) => { if let Some(binding) = &mut *binding.borrow_mut() { binding.set_span(new_span); } @@ -317,30 +317,30 @@ impl Comptime { } } - /// Try to unify these two Comptime constraints. + /// Try to unify these two CompTime constraints. pub fn unify(&self, other: &Self, span: Span) -> Result<(), SpanKind> { match (self, other) { - (Comptime::Yes(_), Comptime::Yes(_)) | (Comptime::No(_), Comptime::No(_)) => Ok(()), + (CompTime::Yes(_), CompTime::Yes(_)) | (CompTime::No(_), CompTime::No(_)) => Ok(()), - (Comptime::Yes(y), Comptime::No(n)) | (Comptime::No(n), Comptime::Yes(y)) => { + (CompTime::Yes(y), CompTime::No(n)) | (CompTime::No(n), CompTime::Yes(y)) => { Err(match (y, n) { (_, Some(span)) => SpanKind::NotComptime(*span), - (Some(span), _) => SpanKind::Comptime(*span), + (Some(span), _) => SpanKind::CompTime(*span), _ => SpanKind::None, }) } - (Comptime::Maybe(_, binding), other) | (other, Comptime::Maybe(_, binding)) + (CompTime::Maybe(_, binding), other) | (other, CompTime::Maybe(_, binding)) if binding.borrow().is_some() => { let binding = &*binding.borrow(); binding.as_ref().unwrap().unify(other, span) } - (Comptime::Maybe(id1, _), Comptime::Maybe(id2, _)) if id1 == id2 => Ok(()), + (CompTime::Maybe(id1, _), CompTime::Maybe(id2, _)) if id1 == id2 => Ok(()), // Both are unbound and do not refer to each other, arbitrarily set one equal to the other - (Comptime::Maybe(_, binding), other) | (other, Comptime::Maybe(_, binding)) => { + (CompTime::Maybe(_, binding), other) | (other, CompTime::Maybe(_, binding)) => { let mut clone = other.clone(); clone.set_span(span); *binding.borrow_mut() = Some(clone); @@ -349,47 +349,47 @@ impl Comptime { } } - /// Try to unify these two Comptime constraints. + /// Try to unify these two CompTime constraints. pub fn is_subtype_of(&self, other: &Self, span: Span) -> Result<(), SpanKind> { match (self, other) { - (Comptime::Yes(_), Comptime::Yes(_)) - | (Comptime::No(_), Comptime::No(_)) + (CompTime::Yes(_), CompTime::Yes(_)) + | (CompTime::No(_), CompTime::No(_)) - // This is one of the only 2 differing cases between this and Comptime::unify - | (Comptime::Yes(_), Comptime::No(_)) => Ok(()), + // This is one of the only 2 differing cases between this and CompTime::unify + | (CompTime::Yes(_), CompTime::No(_)) => Ok(()), - (Comptime::No(n), Comptime::Yes(y)) => { + (CompTime::No(n), CompTime::Yes(y)) => { Err(match (y, n) { (_, Some(span)) => SpanKind::NotComptime(*span), - (Some(span), _) => SpanKind::Comptime(*span), + (Some(span), _) => SpanKind::CompTime(*span), _ => SpanKind::None, }) } - (Comptime::Maybe(_, binding), other) if binding.borrow().is_some() => { + (CompTime::Maybe(_, binding), other) if binding.borrow().is_some() => { let binding = &*binding.borrow(); binding.as_ref().unwrap().is_subtype_of(other, span) } - (other, Comptime::Maybe(_, binding)) if binding.borrow().is_some() => { + (other, CompTime::Maybe(_, binding)) if binding.borrow().is_some() => { let binding = &*binding.borrow(); other.is_subtype_of(binding.as_ref().unwrap(), span) } - (Comptime::Maybe(id1, _), Comptime::Maybe(id2, _)) if id1 == id2 => Ok(()), + (CompTime::Maybe(id1, _), CompTime::Maybe(id2, _)) if id1 == id2 => Ok(()), - // This is the other differing case between this and Comptime::unify. + // This is the other differing case between this and CompTime::unify. // If this is polymorphically comptime, don't force it to be non-comptime because it is // passed as an argument to a function expecting a non-comptime parameter. - (Comptime::Maybe(_, binding), Comptime::No(_)) if binding.borrow().is_none() => Ok(()), + (CompTime::Maybe(_, binding), CompTime::No(_)) if binding.borrow().is_none() => Ok(()), - (Comptime::Maybe(_, binding), other) => { + (CompTime::Maybe(_, binding), other) => { let mut clone = other.clone(); clone.set_span(span); *binding.borrow_mut() = Some(clone); Ok(()) } - (other, Comptime::Maybe(_, binding)) => { + (other, CompTime::Maybe(_, binding)) => { let mut clone = other.clone(); clone.set_span(span); *binding.borrow_mut() = Some(clone); @@ -398,28 +398,28 @@ impl Comptime { } } - /// Combine these two Comptimes together, returning - /// - Comptime::Yes if both are Yes, - /// - Comptime::No if either are No, + /// Combine these two CompTimes together, returning + /// - CompTime::Yes if both are Yes, + /// - CompTime::No if either are No, /// - or if both are Maybe, unify them both and return the lhs. pub fn and(&self, other: &Self, span: Span) -> Self { match (self, other) { - (Comptime::Yes(_), Comptime::Yes(_)) => Comptime::Yes(Some(span)), + (CompTime::Yes(_), CompTime::Yes(_)) => CompTime::Yes(Some(span)), - (Comptime::No(_), Comptime::No(_)) - | (Comptime::Yes(_), Comptime::No(_)) - | (Comptime::No(_), Comptime::Yes(_)) => Comptime::No(Some(span)), + (CompTime::No(_), CompTime::No(_)) + | (CompTime::Yes(_), CompTime::No(_)) + | (CompTime::No(_), CompTime::Yes(_)) => CompTime::No(Some(span)), - (Comptime::Maybe(_, binding), other) | (other, Comptime::Maybe(_, binding)) + (CompTime::Maybe(_, binding), other) | (other, CompTime::Maybe(_, binding)) if binding.borrow().is_some() => { let binding = &*binding.borrow(); binding.as_ref().unwrap().and(other, span) } - (Comptime::Maybe(id1, _), Comptime::Maybe(id2, _)) if id1 == id2 => self.clone(), + (CompTime::Maybe(id1, _), CompTime::Maybe(id2, _)) if id1 == id2 => self.clone(), - (Comptime::Maybe(_, binding), other) | (other, Comptime::Maybe(_, binding)) => { + (CompTime::Maybe(_, binding), other) | (other, CompTime::Maybe(_, binding)) => { let mut clone = other.clone(); clone.set_span(span); *binding.borrow_mut() = Some(clone); @@ -430,9 +430,9 @@ impl Comptime { pub fn is_comptime(&self) -> bool { match self { - Comptime::Yes(_) => true, - Comptime::No(_) => false, - Comptime::Maybe(_, binding) => { + CompTime::Yes(_) => true, + CompTime::No(_) => false, + CompTime::Maybe(_, binding) => { if let Some(binding) = &*binding.borrow() { return binding.is_comptime(); } @@ -444,11 +444,11 @@ impl Comptime { impl Type { pub fn field(span: Option) -> Type { - Type::FieldElement(Comptime::No(span)) + Type::FieldElement(CompTime::No(span)) } pub fn comptime(span: Option) -> Type { - Type::FieldElement(Comptime::Yes(span)) + Type::FieldElement(CompTime::Yes(span)) } pub fn default_int_type(span: Option) -> Type { @@ -563,12 +563,12 @@ impl std::fmt::Display for TypeBinding { } } -impl std::fmt::Display for Comptime { +impl std::fmt::Display for CompTime { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - Comptime::Yes(_) => write!(f, "comptime "), - Comptime::No(_) => Ok(()), - Comptime::Maybe(_, binding) => match &*binding.borrow() { + CompTime::Yes(_) => write!(f, "comptime "), + CompTime::No(_) => Ok(()), + CompTime::Maybe(_, binding) => match &*binding.borrow() { Some(binding) => binding.fmt(f), None => write!(f, "comptime "), }, @@ -577,7 +577,7 @@ impl std::fmt::Display for Comptime { } impl Type { - /// Mutate the span for Comptime to track where comptime is required for better + /// Mutate the span for CompTime to track where comptime is required for better /// error messages that show both the erroring call site and the call site before /// which required the variable to be comptime or non-comptime. pub fn set_comptime_span(&mut self, new_span: Span) { @@ -595,7 +595,7 @@ impl Type { } } - pub fn set_comptime(&mut self, new_comptime: Comptime) { + pub fn set_comptime(&mut self, new_comptime: CompTime) { match self { Type::FieldElement(comptime) | Type::Integer(comptime, _, _) => { *comptime = new_comptime; @@ -611,12 +611,12 @@ impl Type { } /// Try to bind a PolymorphicInt variable to self, succeeding if self is an integer, field, - /// other PolymorphicInt type, or type variable. If use_subtype is true, the Comptime fields + /// other PolymorphicInt type, or type variable. If use_subtype is true, the CompTime fields /// of each will be checked via subtyping rather than unification. pub fn try_bind_to_polymorphic_int( &self, var: &TypeVariable, - var_comptime: &Comptime, + var_comptime: &CompTime, use_subtype: bool, span: Span, ) -> Result<(), SpanKind> { @@ -625,7 +625,7 @@ impl Type { TypeBinding::Unbound(id) => *id, }; - let bind = |int_comptime: &Comptime| { + let bind = |int_comptime: &CompTime| { let mut clone = self.clone(); let mut new_comptime = var_comptime.clone(); new_comptime.set_span(span); @@ -759,7 +759,7 @@ impl Type { let msg = "The value is non-comptime because of this expression, which uses another non-comptime value".into(); errors.push(TypeCheckError::Unstructured { msg, span }); } - (false, SpanKind::Comptime(span)) => { + (false, SpanKind::CompTime(span)) => { let msg = "The value is comptime because of this expression, which forces the value to be comptime".into(); errors.push(TypeCheckError::Unstructured { msg, span }); } @@ -872,7 +872,7 @@ impl Type { } /// The `subtype` term here is somewhat loose, the only subtyping relations remaining - /// have to do with Comptime tracking. + /// have to do with CompTime tracking. pub fn make_subtype_of( &self, expected: &Type, diff --git a/crates/noirc_frontend/src/lexer/token.rs b/crates/noirc_frontend/src/lexer/token.rs index 89f37af184c..4f1f6c0690f 100644 --- a/crates/noirc_frontend/src/lexer/token.rs +++ b/crates/noirc_frontend/src/lexer/token.rs @@ -396,7 +396,7 @@ pub enum Keyword { As, Bool, Char, - Comptime, + CompTime, Constrain, Crate, Dep, @@ -425,7 +425,7 @@ impl fmt::Display for Keyword { Keyword::As => write!(f, "as"), Keyword::Bool => write!(f, "bool"), Keyword::Char => write!(f, "char"), - Keyword::Comptime => write!(f, "comptime"), + Keyword::CompTime => write!(f, "comptime"), Keyword::Constrain => write!(f, "constrain"), Keyword::Crate => write!(f, "crate"), Keyword::Dep => write!(f, "dep"), @@ -459,7 +459,7 @@ impl Keyword { "as" => Keyword::As, "bool" => Keyword::Bool, "char" => Keyword::Char, - "comptime" => Keyword::Comptime, + "comptime" => Keyword::CompTime, "constrain" => Keyword::Constrain, "crate" => Keyword::Crate, "dep" => Keyword::Dep, diff --git a/crates/noirc_frontend/src/monomorphization/mod.rs b/crates/noirc_frontend/src/monomorphization/mod.rs index 87458b41fa1..857e2742c47 100644 --- a/crates/noirc_frontend/src/monomorphization/mod.rs +++ b/crates/noirc_frontend/src/monomorphization/mod.rs @@ -10,7 +10,7 @@ use crate::{ stmt::{HirAssignStatement, HirLValue, HirLetStatement, HirPattern, HirStatement}, }, node_interner::{self, DefinitionKind, NodeInterner, StmtId}, - Comptime, FunctionKind, TypeBinding, TypeBindings, + CompTime, FunctionKind, TypeBinding, TypeBindings, }; use self::ast::{Definition, FuncId, Function, LocalId, Program}; @@ -309,7 +309,7 @@ impl Monomorphizer { } HirExpression::If(if_expr) => { - let cond = self.expr(if_expr.condition, &HirType::Bool(Comptime::No(None))); + let cond = self.expr(if_expr.condition, &HirType::Bool(CompTime::No(None))); let then = self.expr(if_expr.consequence, typ); let else_ = if_expr.alternative.map(|alt| Box::new(self.expr(alt, typ))); ast::Expression::If(ast::If { @@ -336,7 +336,7 @@ impl Monomorphizer { match self.interner.statement(&id) { HirStatement::Let(let_statement) => self.let_statement(let_statement), HirStatement::Constrain(constrain) => { - let expr = self.expr(constrain.0, &HirType::Bool(Comptime::No(None))); + let expr = self.expr(constrain.0, &HirType::Bool(CompTime::No(None))); let location = self.interner.expr_location(&constrain.0); ast::Expression::Constrain(Box::new(expr), location) } @@ -529,7 +529,7 @@ impl Monomorphizer { // after type checking, but care should be taken that it doesn't change which // impls are chosen. *binding.borrow_mut() = - TypeBinding::Bound(HirType::FieldElement(Comptime::No(None))); + TypeBinding::Bound(HirType::FieldElement(CompTime::No(None))); ast::Type::Field } diff --git a/crates/noirc_frontend/src/parser/parser.rs b/crates/noirc_frontend/src/parser/parser.rs index c629058952e..c770a4ed1d2 100644 --- a/crates/noirc_frontend/src/parser/parser.rs +++ b/crates/noirc_frontend/src/parser/parser.rs @@ -8,7 +8,7 @@ use crate::lexer::Lexer; use crate::parser::{force, ignore_then_commit, statement_recovery}; use crate::token::{Attribute, Keyword, Token, TokenKind}; use crate::{ - BinaryOp, BinaryOpKind, BlockExpression, Comptime, ConstrainStatement, FunctionDefinition, + BinaryOp, BinaryOpKind, BlockExpression, CompTime, ConstrainStatement, FunctionDefinition, Ident, IfExpression, ImportStatement, InfixExpression, LValue, Lambda, NoirFunction, NoirImpl, NoirStruct, Path, PathKind, Pattern, Recoverable, UnaryOp, UnresolvedTypeExpression, }; @@ -277,10 +277,10 @@ fn check_statements_require_semicolon( fn global_type_annotation() -> impl NoirParser { ignore_then_commit(just(Token::Colon), parse_type()) .map(|r#type| match r#type { - UnresolvedType::FieldElement(_) => UnresolvedType::FieldElement(Comptime::Yes(None)), - UnresolvedType::Bool(_) => UnresolvedType::Bool(Comptime::Yes(None)), + UnresolvedType::FieldElement(_) => UnresolvedType::FieldElement(CompTime::Yes(None)), + UnresolvedType::Bool(_) => UnresolvedType::Bool(CompTime::Yes(None)), UnresolvedType::Integer(_, sign, size) => { - UnresolvedType::Integer(Comptime::Yes(None), sign, size) + UnresolvedType::Integer(CompTime::Yes(None), sign, size) } other => other, }) @@ -470,10 +470,10 @@ fn optional_visibility() -> impl NoirParser { }) } -fn maybe_comptime() -> impl NoirParser { - keyword(Keyword::Comptime).or_not().map(|opt| match opt { - Some(_) => Comptime::Yes(None), - None => Comptime::No(None), +fn maybe_comptime() -> impl NoirParser { + keyword(Keyword::CompTime).or_not().map(|opt| match opt { + Some(_) => CompTime::Yes(None), + None => CompTime::No(None), }) } diff --git a/cspell.json b/cspell.json index e85a01a9c59..9ca5713987a 100644 --- a/cspell.json +++ b/cspell.json @@ -88,7 +88,6 @@ "binded", "smol", "krate", - "Comptimes", "typevars", "subtyping", "Foralls", From 069ecaa3daf6e925c3bc09026dcf50eb467737d7 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 12:11:53 +0000 Subject: [PATCH 076/115] subexpr -> subexpression --- crates/noirc_frontend/src/parser/parser.rs | 4 ++-- cspell.json | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/noirc_frontend/src/parser/parser.rs b/crates/noirc_frontend/src/parser/parser.rs index c770a4ed1d2..ed6bc1787b9 100644 --- a/crates/noirc_frontend/src/parser/parser.rs +++ b/crates/noirc_frontend/src/parser/parser.rs @@ -567,8 +567,8 @@ fn expression() -> impl ExprParser { .labelled("expression") } -// An expression is a single term followed by 0 or more (OP subexpr)* -// where OP is an operator at the given precedence level and subexpr +// An expression is a single term followed by 0 or more (OP subexpression)* +// where OP is an operator at the given precedence level and subexpression // is an expression at the current precedence level plus one. fn expression_with_precedence<'a, P>( precedence: Precedence, diff --git a/cspell.json b/cspell.json index 9ca5713987a..922b463cfe8 100644 --- a/cspell.json +++ b/cspell.json @@ -55,7 +55,6 @@ "foldl", "comptime", "failable", - "subexpr", "desugared", "elems", "bindgen", From cf32f97144d5afab742df52d10cc1bf82889d32c Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 12:13:59 +0000 Subject: [PATCH 077/115] virtualise -> virtualize --- crates/fm/src/lib.rs | 4 ++-- cspell.json | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/fm/src/lib.rs b/crates/fm/src/lib.rs index b2fb1e3168a..ebc3d7021a8 100644 --- a/crates/fm/src/lib.rs +++ b/crates/fm/src/lib.rs @@ -46,7 +46,7 @@ impl FileManager { let source = file_reader::read_file_to_string(path_to_file).ok()?; let file_id = self.file_map.add_file(path_to_file.to_path_buf().into(), source); - let path_to_file = virtualise_path(path_to_file, file_type); + let path_to_file = virtualize_path(path_to_file, file_type); self.register_path(file_id, path_to_file); Some(file_id) @@ -99,7 +99,7 @@ impl Default for FileManager { /// Returns /// For Normal filetypes, given "src/mod.nr" this method returns "src/mod" /// For Root filetypes, given "src/mod.nr" this method returns "src" -fn virtualise_path(path: &Path, file_type: FileType) -> VirtualPath { +fn virtualize_path(path: &Path, file_type: FileType) -> VirtualPath { let mut path = path.to_path_buf(); let path = match file_type { FileType::Root => { diff --git a/cspell.json b/cspell.json index 922b463cfe8..681e0030516 100644 --- a/cspell.json +++ b/cspell.json @@ -60,7 +60,6 @@ "bindgen", "gloo", "plonkc", - "virtualise", "tempfile", "rustc", "arkworks", From 40d1b8dace81c3f20aeb274d6d1113adada436b3 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 12:15:23 +0000 Subject: [PATCH 078/115] binded -> bound --- crates/noirc_frontend/src/ast/function.rs | 2 +- crates/noirc_frontend/src/hir/type_check/stmt.rs | 2 +- cspell.json | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/noirc_frontend/src/ast/function.rs b/crates/noirc_frontend/src/ast/function.rs index af86b0fef4e..02ef4bf27bb 100644 --- a/crates/noirc_frontend/src/ast/function.rs +++ b/crates/noirc_frontend/src/ast/function.rs @@ -6,7 +6,7 @@ use super::{FunctionDefinition, UnresolvedType}; // A NoirFunction can be either a foreign low level function or a function definition // A closure / function definition will be stored under a name, so we do not differentiate between their variants -// The name for function literal will be the variable it is binded to, and the name for a function definition will +// The name for function literal will be the variable it is bound to, and the name for a function definition will // be the function name itself. #[derive(Clone, Debug, PartialEq, Eq)] pub struct NoirFunction { diff --git a/crates/noirc_frontend/src/hir/type_check/stmt.rs b/crates/noirc_frontend/src/hir/type_check/stmt.rs index 966fa4bace7..ed7a100eb6b 100644 --- a/crates/noirc_frontend/src/hir/type_check/stmt.rs +++ b/crates/noirc_frontend/src/hir/type_check/stmt.rs @@ -26,7 +26,7 @@ pub(crate) fn type_check( // 5; or x; or x+a; // // In these cases, you cannot even get the expr_id because - // it is not binded to anything. We could therefore. + // it is not bound to anything. We could therefore. // // However since TypeChecking checks the return type of the last statement // the type checker could in the future incorrectly return the type. diff --git a/cspell.json b/cspell.json index 681e0030516..27d758d7a2e 100644 --- a/cspell.json +++ b/cspell.json @@ -83,7 +83,6 @@ "bitand", "bitcount", "subexpression", - "binded", "smol", "krate", "typevars", From 88d6c21c3bb94bf3b08924b8b97f3eb2f8123b13 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 12:19:09 +0000 Subject: [PATCH 079/115] nodeobj -> "node object" --- crates/noirc_evaluator/src/ssa/acir_gen.rs | 6 +-- crates/noirc_evaluator/src/ssa/context.rs | 48 ++++++++++----------- crates/noirc_evaluator/src/ssa/flatten.rs | 22 +++++----- crates/noirc_evaluator/src/ssa/function.rs | 2 +- crates/noirc_evaluator/src/ssa/integer.rs | 16 +++---- crates/noirc_evaluator/src/ssa/node.rs | 50 +++++++++++----------- crates/noirc_evaluator/src/ssa/optim.rs | 2 +- cspell.json | 1 - 8 files changed, 73 insertions(+), 74 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/acir_gen.rs b/crates/noirc_evaluator/src/ssa/acir_gen.rs index 41855523265..ee7ffaaf553 100644 --- a/crates/noirc_evaluator/src/ssa/acir_gen.rs +++ b/crates/noirc_evaluator/src/ssa/acir_gen.rs @@ -115,12 +115,12 @@ impl Acir { return self.arith_cache[&id].clone(); } let var = match ctx.try_get_node(id) { - Some(node::NodeObj::Const(c)) => { + Some(node::NodeObject::Const(c)) => { let f_value = FieldElement::from_be_bytes_reduce(&c.value.to_bytes_be()); let expr = Expression::from_field(f_value); InternalVar::new(expr, None, id) } - Some(node::NodeObj::Obj(v)) => match v.get_type() { + Some(node::NodeObject::Obj(v)) => match v.get_type() { node::ObjectType::Pointer(_) => InternalVar::default(), _ => { let w = v.witness.unwrap_or_else(|| evaluator.add_witness_to_cs()); @@ -532,7 +532,7 @@ impl Acir { for a in args { let l_obj = cfg.try_get_node(*a).unwrap(); match l_obj { - node::NodeObj::Obj(v) => match l_obj.get_type() { + node::NodeObject::Obj(v) => match l_obj.get_type() { node::ObjectType::Pointer(a) => { let array = &cfg.mem[a]; let num_bits = array.element_type.bits(); diff --git a/crates/noirc_evaluator/src/ssa/context.rs b/crates/noirc_evaluator/src/ssa/context.rs index bc935eea1dc..e41ea5a54ad 100644 --- a/crates/noirc_evaluator/src/ssa/context.rs +++ b/crates/noirc_evaluator/src/ssa/context.rs @@ -3,7 +3,7 @@ use super::conditional::{DecisionTree, TreeBuilder}; use super::function::{FuncIndex, SSAFunction}; use super::inline::StackFrame; use super::mem::{ArrayId, Memory}; -use super::node::{BinaryOp, FunctionKind, Instruction, NodeId, NodeObj, ObjectType, Operation}; +use super::node::{BinaryOp, FunctionKind, Instruction, NodeId, NodeObject, ObjectType, Operation}; use super::{block, builtin, flatten, inline, integer, node, optim}; use std::collections::{HashMap, HashSet}; @@ -27,7 +27,7 @@ pub struct SsaContext { pub first_block: BlockId, pub current_block: BlockId, blocks: arena::Arena, - pub nodes: arena::Arena, + pub nodes: arena::Arena, value_names: HashMap, pub sealed_blocks: HashSet, pub mem: Memory, @@ -267,7 +267,7 @@ impl SsaContext { pub fn node_to_string(&self, id: NodeId) -> String { match self.try_get_node(id) { - Some(NodeObj::Instr(ins)) => { + Some(NodeObject::Instr(ins)) => { let mut str_res = if ins.res_name.is_empty() { format!("{:?}", id.0.into_raw_parts().0) } else { @@ -305,10 +305,10 @@ impl SsaContext { /// This function does NOT push the instruction to the current block. /// See push_instruction for that. pub fn add_instruction(&mut self, instruction: node::Instruction) -> NodeId { - let obj = NodeObj::Instr(instruction); + let obj = NodeObject::Instr(instruction); let id = NodeId(self.nodes.insert(obj)); match &mut self[id] { - NodeObj::Instr(i) => i.id = id, + NodeObject::Instr(i) => i.id = id, _ => unreachable!(), } @@ -318,7 +318,7 @@ impl SsaContext { /// Adds the instruction to self.nodes and pushes it to the current block pub fn push_instruction(&mut self, instruction: node::Instruction) -> NodeId { let id = self.add_instruction(instruction); - if let NodeObj::Instr(_) = &self[id] { + if let NodeObject::Instr(_) = &self[id] { self.get_current_block_mut().instructions.push(id); } id @@ -364,10 +364,10 @@ impl SsaContext { } pub fn add_const(&mut self, constant: node::Constant) -> NodeId { - let obj = NodeObj::Const(constant); + let obj = NodeObject::Const(constant); let id = NodeId(self.nodes.insert(obj)); match &mut self[id] { - NodeObj::Const(c) => c.id = id, + NodeObject::Const(c) => c.id = id, _ => unreachable!(), } @@ -380,7 +380,7 @@ impl SsaContext { pub fn try_get_func_id(&self, id: NodeId) -> Option { match &self[id] { - NodeObj::Function(FunctionKind::Normal(id), ..) => Some(*id), + NodeObject::Function(FunctionKind::Normal(id), ..) => Some(*id), _ => None, } } @@ -393,11 +393,11 @@ impl SsaContext { arena::Index::from_raw_parts(std::usize::MAX, 0) } - pub fn try_get_node(&self, id: NodeId) -> Option<&node::NodeObj> { + pub fn try_get_node(&self, id: NodeId) -> Option<&node::NodeObject> { self.nodes.get(id.0) } - pub fn try_get_node_mut(&mut self, id: NodeId) -> Option<&mut node::NodeObj> { + pub fn try_get_node_mut(&mut self, id: NodeId) -> Option<&mut node::NodeObject> { self.nodes.get_mut(id.0) } @@ -407,7 +407,7 @@ impl SsaContext { //Returns the object value if it is a constant, None if not. pub fn get_as_constant(&self, id: NodeId) -> Option { - if let Some(node::NodeObj::Const(c)) = self.try_get_node(id) { + if let Some(node::NodeObject::Const(c)) = self.try_get_node(id) { return Some(FieldElement::from_be_bytes_reduce(&c.value.to_bytes_be())); } None @@ -422,14 +422,14 @@ impl SsaContext { } pub fn try_get_instruction(&self, id: NodeId) -> Option<&node::Instruction> { - if let Some(NodeObj::Instr(i)) = self.try_get_node(id) { + if let Some(NodeObject::Instr(i)) = self.try_get_node(id) { return Some(i); } None } pub fn try_get_mut_instruction(&mut self, id: NodeId) -> Option<&mut node::Instruction> { - if let Some(NodeObj::Instr(i)) = self.try_get_node_mut(id) { + if let Some(NodeObject::Instr(i)) = self.try_get_node_mut(id) { return Some(i); } None @@ -438,7 +438,7 @@ impl SsaContext { pub fn get_variable(&self, id: NodeId) -> Result<&node::Variable, RuntimeErrorKind> { match self.nodes.get(id.0) { Some(t) => match t { - node::NodeObj::Obj(o) => Ok(o), + node::NodeObject::Obj(o) => Ok(o), _ => Err(RuntimeErrorKind::UnstructuredError { message: "Not an object".to_string(), }), @@ -453,7 +453,7 @@ impl SsaContext { ) -> Result<&mut node::Variable, RuntimeErrorKind> { match self.nodes.get_mut(id.0) { Some(t) => match t { - node::NodeObj::Obj(o) => Ok(o), + node::NodeObject::Obj(o) => Ok(o), _ => Err(RuntimeErrorKind::UnstructuredError { message: "Not an object".to_string(), }), @@ -469,7 +469,7 @@ impl SsaContext { index: u32, ) -> Option<&mut Instruction> { for id in &self.blocks[target.0].instructions { - if let Some(NodeObj::Instr(i)) = self.nodes.get(id.0) { + if let Some(NodeObject::Instr(i)) = self.nodes.get(id.0) { if i.operation == (Operation::Result { call_instruction, index }) { let id = *id; return self.try_get_mut_instruction(id); @@ -484,9 +484,9 @@ impl SsaContext { } pub fn add_variable(&mut self, obj: node::Variable, root: Option) -> NodeId { - let id = NodeId(self.nodes.insert(NodeObj::Obj(obj))); + let id = NodeId(self.nodes.insert(NodeObject::Obj(obj))); match &mut self[id] { - node::NodeObj::Obj(v) => { + node::NodeObject::Obj(v) => { v.id = id; v.root = root; } @@ -579,7 +579,7 @@ impl SsaContext { ) -> Option { //TODO We should map constant values to id for (idx, o) in &self.nodes { - if let node::NodeObj::Const(c) = o { + if let node::NodeObject::Const(c) = o { if c.value == *value && c.get_type() == e_type { return Some(NodeId(idx)); } @@ -1076,7 +1076,7 @@ impl SsaContext { pub fn push_function_id(&mut self, func_id: FuncId, name: &str) -> NodeId { let index = self.nodes.insert_with(|index| { let node_id = NodeId(index); - NodeObj::Function(FunctionKind::Normal(func_id), node_id, name.to_owned()) + NodeObject::Function(FunctionKind::Normal(func_id), node_id, name.to_owned()) }); NodeId(index) @@ -1100,7 +1100,7 @@ impl SsaContext { } let index = self.nodes.insert_with(|index| { - NodeObj::Function(FunctionKind::Builtin(opcode), NodeId(index), opcode.to_string()) + NodeObject::Function(FunctionKind::Builtin(opcode), NodeId(index), opcode.to_string()) }); self.opcode_ids.insert(opcode, NodeId(index)); NodeId(index) @@ -1108,7 +1108,7 @@ impl SsaContext { pub fn get_builtin_opcode(&self, node_id: NodeId) -> Option { match &self[node_id] { - NodeObj::Function(FunctionKind::Builtin(opcode), ..) => Some(*opcode), + NodeObject::Function(FunctionKind::Builtin(opcode), ..) => Some(*opcode), _ => None, } } @@ -1204,7 +1204,7 @@ impl std::ops::IndexMut for SsaContext { } impl std::ops::Index for SsaContext { - type Output = NodeObj; + type Output = NodeObject; fn index(&self, index: NodeId) -> &Self::Output { &self.nodes[index.0] diff --git a/crates/noirc_evaluator/src/ssa/flatten.rs b/crates/noirc_evaluator/src/ssa/flatten.rs index 2c67af06ec0..810a92fb63e 100644 --- a/crates/noirc_evaluator/src/ssa/flatten.rs +++ b/crates/noirc_evaluator/src/ssa/flatten.rs @@ -3,7 +3,7 @@ use crate::errors::RuntimeError; use super::{ block::{self, BlockId}, context::SsaContext, - node::{self, BinaryOp, Mark, Node, NodeEval, NodeId, NodeObj, Operation}, + node::{self, BinaryOp, Mark, Node, NodeEval, NodeId, NodeObject, Operation}, optim, }; use acvm::FieldElement; @@ -112,7 +112,7 @@ pub fn unroll_std_block( for i_id in &b_instructions { match &ctx[*i_id] { - node::NodeObj::Instr(i) => { + node::NodeObject::Instr(i) => { let new_op = i.operation.map_id(|id| { get_current_value(id, &unroll_ctx.eval_map).into_node_id().unwrap() }); @@ -286,7 +286,7 @@ fn get_current_value(id: NodeId, value_array: &HashMap) -> Nod *value_array.get(&id).unwrap_or(&NodeEval::VarOrInstruction(id)) } -//Same as get_current_value but for a NodeEval object instead of a NodeObj +//Same as get_current_value but for a NodeEval object instead of a NodeObject fn get_current_value_for_node_eval( obj: NodeEval, value_array: &HashMap, @@ -312,7 +312,7 @@ fn evaluate_one( } match &ctx[obj_id] { - NodeObj::Instr(i) => { + NodeObject::Instr(i) => { let new_id = optim::propagate(ctx, obj_id, &mut modified); if new_id != obj_id { return evaluate_one(NodeEval::VarOrInstruction(new_id), value_array, ctx); @@ -332,12 +332,12 @@ fn evaluate_one( } Ok(result) } - NodeObj::Const(c) => { + NodeObject::Const(c) => { let value = FieldElement::from_be_bytes_reduce(&c.value.to_bytes_be()); Ok(NodeEval::Const(value, c.get_type())) } - NodeObj::Obj(_) => Ok(NodeEval::VarOrInstruction(obj_id)), - NodeObj::Function(f, id, _) => Ok(NodeEval::Function(*f, *id)), + NodeObject::Obj(_) => Ok(NodeEval::VarOrInstruction(obj_id)), + NodeObject::Function(f, id, _) => Ok(NodeEval::Function(*f, *id)), } } } @@ -357,7 +357,7 @@ fn evaluate_object( } match &ctx[obj_id] { - NodeObj::Instr(i) => { + NodeObject::Instr(i) => { if let Operation::Phi { .. } = i.operation { return Ok(NodeEval::VarOrInstruction(i.id)); } @@ -374,12 +374,12 @@ fn evaluate_object( } Ok(result) } - NodeObj::Const(c) => { + NodeObject::Const(c) => { let value = FieldElement::from_be_bytes_reduce(&c.value.to_bytes_be()); Ok(NodeEval::Const(value, c.get_type())) } - NodeObj::Obj(_) => Ok(NodeEval::VarOrInstruction(obj_id)), - NodeObj::Function(f, id, _) => Ok(NodeEval::Function(*f, *id)), + NodeObject::Obj(_) => Ok(NodeEval::VarOrInstruction(obj_id)), + NodeObject::Function(f, id, _) => Ok(NodeEval::Function(*f, *id)), } } } diff --git a/crates/noirc_evaluator/src/ssa/function.rs b/crates/noirc_evaluator/src/ssa/function.rs index b711f6f1f49..f134479f4ef 100644 --- a/crates/noirc_evaluator/src/ssa/function.rs +++ b/crates/noirc_evaluator/src/ssa/function.rs @@ -132,7 +132,7 @@ impl SSAFunction { } let node_obj_opt = ctx.try_get_node(*node_id); - if let Some(node::NodeObj::Const(c)) = node_obj_opt { + if let Some(node::NodeObject::Const(c)) = node_obj_opt { ctx.get_or_create_const(c.get_value_field(), c.value_type) } else if let Some(id) = inline_map.get(node_id) { *id diff --git a/crates/noirc_evaluator/src/ssa/integer.rs b/crates/noirc_evaluator/src/ssa/integer.rs index e0ff5a2d0d8..fc93a26a738 100644 --- a/crates/noirc_evaluator/src/ssa/integer.rs +++ b/crates/noirc_evaluator/src/ssa/integer.rs @@ -5,7 +5,7 @@ use super::{ //block, context::SsaContext, mem::{ArrayId, Memory}, - node::{self, BinaryOp, Instruction, Mark, Node, NodeId, NodeObj, ObjectType, Operation}, + node::{self, BinaryOp, Instruction, Mark, Node, NodeId, NodeObject, ObjectType, Operation}, optim, }; use acvm::FieldElement; @@ -95,10 +95,10 @@ fn get_obj_max_value( let obj = &ctx[id]; let result = match obj { - NodeObj::Obj(v) => (BigUint::one() << v.size_in_bits()) - BigUint::one(), //TODO check for signed type - NodeObj::Instr(i) => get_instruction_max(ctx, i, max_map, vmap), - NodeObj::Const(c) => c.value.clone(), //TODO panic for string constants - NodeObj::Function(..) => BigUint::zero(), + NodeObject::Obj(v) => (BigUint::one() << v.size_in_bits()) - BigUint::one(), //TODO check for signed type + NodeObject::Instr(i) => get_instruction_max(ctx, i, max_map, vmap), + NodeObject::Const(c) => c.value.clone(), //TODO panic for string constants + NodeObject::Function(..) => BigUint::zero(), }; max_map.insert(id, result.clone()); result @@ -169,7 +169,7 @@ fn add_to_truncate( ) { let v_max = &max_map[&obj_id]; if *v_max >= BigUint::one() << bit_size { - if let Some(NodeObj::Const(_)) = &ctx.try_get_node(obj_id) { + if let Some(NodeObject::Const(_)) = &ctx.try_get_node(obj_id) { return; //a constant cannot be truncated, so we exit the function gracefully } let truncate_bits = match to_truncate.get(&obj_id) { @@ -417,7 +417,7 @@ pub fn get_value_from_map(id: NodeId, vmap: &HashMap) -> NodeId *vmap.get(&id).unwrap_or(&id) } -fn get_size_in_bits(obj: Option<&NodeObj>) -> u32 { +fn get_size_in_bits(obj: Option<&NodeObject>) -> u32 { if let Some(v) = obj { v.size_in_bits() } else { @@ -425,7 +425,7 @@ fn get_size_in_bits(obj: Option<&NodeObj>) -> u32 { } } -fn get_type(obj: Option<&NodeObj>) -> ObjectType { +fn get_type(obj: Option<&NodeObject>) -> ObjectType { if let Some(v) = obj { v.get_type() } else { diff --git a/crates/noirc_evaluator/src/ssa/node.rs b/crates/noirc_evaluator/src/ssa/node.rs index b86c5e02238..c252c0720ed 100644 --- a/crates/noirc_evaluator/src/ssa/node.rs +++ b/crates/noirc_evaluator/src/ssa/node.rs @@ -30,15 +30,15 @@ impl std::fmt::Display for Variable { } } -impl std::fmt::Display for NodeObj { +impl std::fmt::Display for NodeObject { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { use FunctionKind::*; match self { - NodeObj::Obj(o) => write!(f, "{o}"), - NodeObj::Instr(i) => write!(f, "{i}"), - NodeObj::Const(c) => write!(f, "{c}"), - NodeObj::Function(Normal(id), ..) => write!(f, "f{}", id.0), - NodeObj::Function(Builtin(opcode), ..) => write!(f, "{opcode}"), + NodeObject::Obj(o) => write!(f, "{o}"), + NodeObject::Instr(i) => write!(f, "{i}"), + NodeObject::Const(c) => write!(f, "{c}"), + NodeObject::Function(Normal(id), ..) => write!(f, "f{}", id.0), + NodeObject::Function(Builtin(opcode), ..) => write!(f, "{opcode}"), } } } @@ -63,31 +63,31 @@ impl Node for Variable { } } -impl Node for NodeObj { +impl Node for NodeObject { fn get_type(&self) -> ObjectType { match self { - NodeObj::Obj(o) => o.get_type(), - NodeObj::Instr(i) => i.res_type, - NodeObj::Const(o) => o.value_type, - NodeObj::Function(..) => ObjectType::Function, + NodeObject::Obj(o) => o.get_type(), + NodeObject::Instr(i) => i.res_type, + NodeObject::Const(o) => o.value_type, + NodeObject::Function(..) => ObjectType::Function, } } fn size_in_bits(&self) -> u32 { match self { - NodeObj::Obj(o) => o.size_in_bits(), - NodeObj::Instr(i) => i.res_type.bits(), - NodeObj::Const(c) => c.size_in_bits(), - NodeObj::Function(..) => 0, + NodeObject::Obj(o) => o.size_in_bits(), + NodeObject::Instr(i) => i.res_type.bits(), + NodeObject::Const(c) => c.size_in_bits(), + NodeObject::Function(..) => 0, } } fn get_id(&self) -> NodeId { match self { - NodeObj::Obj(o) => o.get_id(), - NodeObj::Instr(i) => i.id, - NodeObj::Const(c) => c.get_id(), - NodeObj::Function(_, id, _) => *id, + NodeObject::Obj(o) => o.get_id(), + NodeObject::Instr(i) => i.id, + NodeObject::Const(c) => c.get_id(), + NodeObject::Function(_, id, _) => *id, } } } @@ -116,7 +116,7 @@ impl NodeId { } #[derive(Debug)] -pub enum NodeObj { +pub enum NodeObject { Obj(Variable), Instr(Instruction), Const(Constant), @@ -299,8 +299,8 @@ impl NodeEval { } } - //returns the NodeObj index of a NodeEval object - //if NodeEval is a constant, it may creates a new NodeObj corresponding to the constant value + //returns the NodeObject index of a NodeEval object + //if NodeEval is a constant, it may creates a new NodeObject corresponding to the constant value pub fn to_index(self, ctx: &mut SsaContext) -> NodeId { match self { NodeEval::Const(c, t) => ctx.get_or_create_const(c, t), @@ -311,12 +311,12 @@ impl NodeEval { pub fn from_id(ctx: &SsaContext, id: NodeId) -> NodeEval { match &ctx[id] { - NodeObj::Const(c) => { + NodeObject::Const(c) => { let value = FieldElement::from_be_bytes_reduce(&c.value.to_bytes_be()); NodeEval::Const(value, c.get_type()) } - NodeObj::Function(f, id, _name) => NodeEval::Function(*f, *id), - NodeObj::Obj(_) | NodeObj::Instr(_) => NodeEval::VarOrInstruction(id), + NodeObject::Function(f, id, _name) => NodeEval::Function(*f, *id), + NodeObject::Obj(_) | NodeObject::Instr(_) => NodeEval::VarOrInstruction(id), } } diff --git a/crates/noirc_evaluator/src/ssa/optim.rs b/crates/noirc_evaluator/src/ssa/optim.rs index a9708964300..227cfb0e715 100644 --- a/crates/noirc_evaluator/src/ssa/optim.rs +++ b/crates/noirc_evaluator/src/ssa/optim.rs @@ -13,7 +13,7 @@ use super::{ pub fn simplify_id(ctx: &mut SsaContext, ins_id: NodeId) -> Result<(), RuntimeError> { let mut ins = ctx.get_instruction(ins_id).clone(); simplify(ctx, &mut ins)?; - ctx[ins_id] = super::node::NodeObj::Instr(ins); + ctx[ins_id] = super::node::NodeObject::Instr(ins); Ok(()) } diff --git a/cspell.json b/cspell.json index 27d758d7a2e..0086dc5a834 100644 --- a/cspell.json +++ b/cspell.json @@ -38,7 +38,6 @@ "srem", "nvar", "igen", - "nodeobj", "Barretenberg", "cdir", "uninstantiated", From 02b3cd6451b730d085b4d0596ab200e93b6e6c7f Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 12:29:08 +0000 Subject: [PATCH 080/115] add note about foldl --- cspell.json | 1 + 1 file changed, 1 insertion(+) diff --git a/cspell.json b/cspell.json index 0086dc5a834..c0e83c68b5b 100644 --- a/cspell.json +++ b/cspell.json @@ -51,6 +51,7 @@ "chumsky", "tokenkind", "idents", + // TODO: ask Jake if we can expand on "l" "foldl", "comptime", "failable", From a4f6472ad373f90dc2183b185841946d123df0a0 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 12:30:59 +0000 Subject: [PATCH 081/115] nodeobj -> node object --- crates/noirc_evaluator/src/ssa/acir_gen.rs | 2 +- crates/noirc_evaluator/src/ssa/integer.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/acir_gen.rs b/crates/noirc_evaluator/src/ssa/acir_gen.rs index ee7ffaaf553..011a7f5def5 100644 --- a/crates/noirc_evaluator/src/ssa/acir_gen.rs +++ b/crates/noirc_evaluator/src/ssa/acir_gen.rs @@ -104,7 +104,7 @@ impl From for InternalVar { impl Acir { //This function stores the substitution with the arithmetic expression in the cache //When an instruction performs arithmetic operation, its output can be represented as an arithmetic expression of its arguments - //Substitute a nodeobj as an arithmetic expression + //Substitute a node object as an arithmetic expression fn substitute( &mut self, id: NodeId, diff --git a/crates/noirc_evaluator/src/ssa/integer.rs b/crates/noirc_evaluator/src/ssa/integer.rs index fc93a26a738..b53f705034a 100644 --- a/crates/noirc_evaluator/src/ssa/integer.rs +++ b/crates/noirc_evaluator/src/ssa/integer.rs @@ -387,7 +387,7 @@ fn block_overflow( .. }) = &mut ins.operation { - //for now we pass the max value to the instruction, we could also keep the max_map e.g in the block (or max in each nodeobj) + //for now we pass the max value to the instruction, we could also keep the max_map e.g in the block (or max in each node object) //sub operations require the max value to ensure it does not underflow *max_rhs_value = max_map[rhs].clone(); //we may do that in future when the max_map becomes more used elsewhere (for other optim) From dc833e33102146169812919be5ea68c0292144ad Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 13:07:03 +0000 Subject: [PATCH 082/115] comptime : use snake case and camel case --- .../src/hir/resolution/resolver.rs | 6 +- .../noirc_frontend/src/hir/type_check/expr.rs | 36 ++++----- .../noirc_frontend/src/hir/type_check/stmt.rs | 4 +- crates/noirc_frontend/src/hir_def/types.rs | 81 ++++++++++--------- crates/noirc_frontend/src/parser/parser.rs | 8 +- 5 files changed, 68 insertions(+), 67 deletions(-) diff --git a/crates/noirc_frontend/src/hir/resolution/resolver.rs b/crates/noirc_frontend/src/hir/resolution/resolver.rs index 3a6263d191b..91feb20ea51 100644 --- a/crates/noirc_frontend/src/hir/resolution/resolver.rs +++ b/crates/noirc_frontend/src/hir/resolution/resolver.rs @@ -296,15 +296,15 @@ impl<'a> Resolver<'a> { /// freshly created TypeVariables created to new_variables. fn resolve_type_inner(&mut self, typ: UnresolvedType, new_variables: &mut Generics) -> Type { match typ { - UnresolvedType::FieldElement(comptime) => Type::FieldElement(comptime), + UnresolvedType::FieldElement(comp_time) => Type::FieldElement(comp_time), UnresolvedType::Array(size, elem) => { let resolved_size = self.resolve_array_size(size, new_variables); let elem = Box::new(self.resolve_type_inner(*elem, new_variables)); Type::Array(Box::new(resolved_size), elem) } UnresolvedType::Expression(expr) => self.convert_expression_type(expr), - UnresolvedType::Integer(comptime, sign, bits) => Type::Integer(comptime, sign, bits), - UnresolvedType::Bool(comptime) => Type::Bool(comptime), + UnresolvedType::Integer(comp_time, sign, bits) => Type::Integer(comp_time, sign, bits), + UnresolvedType::Bool(comp_time) => Type::Bool(comp_time), UnresolvedType::String(size) => { let resolved_size = self.resolve_array_size(size, new_variables); Type::String(Box::new(resolved_size)) diff --git a/crates/noirc_frontend/src/hir/type_check/expr.rs b/crates/noirc_frontend/src/hir/type_check/expr.rs index 02218bf266b..bb8521a4a19 100644 --- a/crates/noirc_frontend/src/hir/type_check/expr.rs +++ b/crates/noirc_frontend/src/hir/type_check/expr.rs @@ -153,7 +153,7 @@ pub(crate) fn type_check_expression( let end_range_type = type_check_expression(interner, &for_expr.end_range, errors); let span = interner.expr_span(&for_expr.start_range); - start_range_type.unify(&Type::comptime(Some(span)), span, errors, || { + start_range_type.unify(&Type::comp_time(Some(span)), span, errors, || { TypeCheckError::TypeCannotBeUsed { typ: start_range_type.clone(), place: "for loop", @@ -163,7 +163,7 @@ pub(crate) fn type_check_expression( }); let span = interner.expr_span(&for_expr.end_range); - end_range_type.unify(&Type::comptime(Some(span)), span, errors, || { + end_range_type.unify(&Type::comp_time(Some(span)), span, errors, || { TypeCheckError::TypeCannotBeUsed { typ: end_range_type.clone(), place: "for loop", @@ -257,7 +257,7 @@ fn type_check_index_expression( let index_type = type_check_expression(interner, &index_expr.index, errors); let span = interner.expr_span(&index_expr.index); - index_type.unify(&Type::comptime(Some(span)), span, errors, || { + index_type.unify(&Type::comp_time(Some(span)), span, errors, || { // Specialize the error in the case the user has a Field, just not a comptime one. if matches!(index_type, Type::FieldElement(..)) { TypeCheckError::Unstructured { @@ -292,14 +292,14 @@ fn type_check_index_expression( } fn check_cast(from: Type, to: Type, span: Span, errors: &mut Vec) -> Type { - let is_comptime = match from { - Type::Integer(is_comptime, ..) => is_comptime, - Type::FieldElement(is_comptime) => is_comptime, - Type::PolymorphicInteger(is_comptime, binding) => match &*binding.borrow() { + let is_comp_time = match from { + Type::Integer(is_comp_time, ..) => is_comp_time, + Type::FieldElement(is_comp_time) => is_comp_time, + Type::PolymorphicInteger(is_comp_time, binding) => match &*binding.borrow() { TypeBinding::Bound(from) => return check_cast(from.clone(), to, span, errors), - TypeBinding::Unbound(_) => is_comptime, + TypeBinding::Unbound(_) => is_comp_time, }, - Type::Bool(is_comptime) => is_comptime, + Type::Bool(is_comp_time) => is_comp_time, Type::Error => return Type::Error, from => { let msg = format!( @@ -313,28 +313,28 @@ fn check_cast(from: Type, to: Type, span: Span, errors: &mut Vec let error_message = "Cannot cast to a comptime type, argument to cast is not known at compile-time"; match to { - Type::Integer(dest_comptime, sign, bits) => { - if dest_comptime.is_comptime() && is_comptime.unify(&dest_comptime, span).is_err() { + Type::Integer(dest_comp_time, sign, bits) => { + if dest_comp_time.is_comp_time() && is_comp_time.unify(&dest_comp_time, span).is_err() { let msg = error_message.into(); errors.push(TypeCheckError::Unstructured { msg, span }); } - Type::Integer(is_comptime, sign, bits) + Type::Integer(is_comp_time, sign, bits) } - Type::FieldElement(dest_comptime) => { - if dest_comptime.is_comptime() && is_comptime.unify(&dest_comptime, span).is_err() { + Type::FieldElement(dest_comp_time) => { + if dest_comp_time.is_comp_time() && is_comp_time.unify(&dest_comp_time, span).is_err() { let msg = error_message.into(); errors.push(TypeCheckError::Unstructured { msg, span }); } - Type::FieldElement(is_comptime) + Type::FieldElement(is_comp_time) } - Type::Bool(dest_comptime) => { - if dest_comptime.is_comptime() && is_comptime.unify(&dest_comptime, span).is_err() { + Type::Bool(dest_comp_time) => { + if dest_comp_time.is_comp_time() && is_comp_time.unify(&dest_comp_time, span).is_err() { let msg = error_message.into(); errors.push(TypeCheckError::Unstructured { msg, span }); } - Type::Bool(dest_comptime) + Type::Bool(dest_comp_time) } Type::Error => Type::Error, _ => { diff --git a/crates/noirc_frontend/src/hir/type_check/stmt.rs b/crates/noirc_frontend/src/hir/type_check/stmt.rs index ed7a100eb6b..ac4c18139dd 100644 --- a/crates/noirc_frontend/src/hir/type_check/stmt.rs +++ b/crates/noirc_frontend/src/hir/type_check/stmt.rs @@ -183,7 +183,7 @@ fn type_check_lvalue( let index_type = type_check_expression(interner, &index, errors); let expr_span = interner.expr_span(&index); - index_type.unify(&Type::comptime(Some(expr_span)), expr_span, errors, || { + index_type.unify(&Type::comp_time(Some(expr_span)), expr_span, errors, || { TypeCheckError::TypeMismatch { expected_typ: "comptime Field".to_owned(), expr_typ: index_type.to_string(), @@ -221,7 +221,7 @@ fn type_check_let_stmt( let mut resolved_type = type_check_declaration(interner, let_stmt.expression, let_stmt.r#type, errors); - resolved_type.set_comptime_span(interner.expr_span(&let_stmt.expression)); + resolved_type.set_comp_time_span(interner.expr_span(&let_stmt.expression)); // Set the type of the pattern to be equal to the annotated type bind_pattern(interner, &let_stmt.pattern, resolved_type, errors); diff --git a/crates/noirc_frontend/src/hir_def/types.rs b/crates/noirc_frontend/src/hir_def/types.rs index 3afcc0a395b..f4e089d9c4e 100644 --- a/crates/noirc_frontend/src/hir_def/types.rs +++ b/crates/noirc_frontend/src/hir_def/types.rs @@ -264,8 +264,8 @@ impl std::hash::Hash for CompTime { core::mem::discriminant(self).hash(state); if let CompTime::Maybe(id, binding) = self { - if let Some(is_comptime) = &*binding.borrow() { - is_comptime.hash(state); + if let Some(is_comp_time) = &*binding.borrow() { + is_comp_time.hash(state); } else { id.hash(state); } @@ -296,7 +296,7 @@ impl PartialEq for CompTime { #[derive(Debug)] pub enum SpanKind { CompTime(Span), - NotComptime(Span), + NotCompTime(Span), None, } @@ -324,7 +324,7 @@ impl CompTime { (CompTime::Yes(y), CompTime::No(n)) | (CompTime::No(n), CompTime::Yes(y)) => { Err(match (y, n) { - (_, Some(span)) => SpanKind::NotComptime(*span), + (_, Some(span)) => SpanKind::NotCompTime(*span), (Some(span), _) => SpanKind::CompTime(*span), _ => SpanKind::None, }) @@ -360,7 +360,7 @@ impl CompTime { (CompTime::No(n), CompTime::Yes(y)) => { Err(match (y, n) { - (_, Some(span)) => SpanKind::NotComptime(*span), + (_, Some(span)) => SpanKind::NotCompTime(*span), (Some(span), _) => SpanKind::CompTime(*span), _ => SpanKind::None, }) @@ -428,13 +428,13 @@ impl CompTime { } } - pub fn is_comptime(&self) -> bool { + pub fn is_comp_time(&self) -> bool { match self { CompTime::Yes(_) => true, CompTime::No(_) => false, CompTime::Maybe(_, binding) => { if let Some(binding) = &*binding.borrow() { - return binding.is_comptime(); + return binding.is_comp_time(); } true } @@ -447,7 +447,7 @@ impl Type { Type::FieldElement(CompTime::No(span)) } - pub fn comptime(span: Option) -> Type { + pub fn comp_time(span: Option) -> Type { Type::FieldElement(CompTime::Yes(span)) } @@ -483,13 +483,13 @@ impl Type { impl std::fmt::Display for Type { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - Type::FieldElement(comptime) => { - write!(f, "{comptime}Field") + Type::FieldElement(comp_time) => { + write!(f, "{comp_time}Field") } Type::Array(len, typ) => write!(f, "[{typ}; {len}]"), - Type::Integer(comptime, sign, num_bits) => match sign { - Signedness::Signed => write!(f, "{comptime}i{num_bits}"), - Signedness::Unsigned => write!(f, "{comptime}u{num_bits}"), + Type::Integer(comp_time, sign, num_bits) => match sign { + Signedness::Signed => write!(f, "{comp_time}i{num_bits}"), + Signedness::Unsigned => write!(f, "{comp_time}u{num_bits}"), }, Type::PolymorphicInteger(_, binding) => { if let TypeBinding::Unbound(_) = &*binding.borrow() { @@ -513,7 +513,7 @@ impl std::fmt::Display for Type { let elements = vecmap(elements, ToString::to_string); write!(f, "({})", elements.join(", ")) } - Type::Bool(comptime) => write!(f, "{comptime}bool"), + Type::Bool(comp_time) => write!(f, "{comp_time}bool"), Type::String(len) => write!(f, "str<{len}>"), Type::Unit => write!(f, "()"), Type::Error => write!(f, "error"), @@ -580,14 +580,14 @@ impl Type { /// Mutate the span for CompTime to track where comptime is required for better /// error messages that show both the erroring call site and the call site before /// which required the variable to be comptime or non-comptime. - pub fn set_comptime_span(&mut self, new_span: Span) { + pub fn set_comp_time_span(&mut self, new_span: Span) { match self { Type::FieldElement(comptime) | Type::Integer(comptime, _, _) => { comptime.set_span(new_span) } Type::PolymorphicInteger(span, binding) => { if let TypeBinding::Bound(binding) = &mut *binding.borrow_mut() { - return binding.set_comptime_span(new_span); + return binding.set_comp_time_span(new_span); } span.set_span(new_span); } @@ -595,14 +595,14 @@ impl Type { } } - pub fn set_comptime(&mut self, new_comptime: CompTime) { + pub fn set_comp_time(&mut self, new_comptime: CompTime) { match self { Type::FieldElement(comptime) | Type::Integer(comptime, _, _) => { *comptime = new_comptime; } Type::PolymorphicInteger(comptime, binding) => { if let TypeBinding::Bound(binding) = &mut *binding.borrow_mut() { - return binding.set_comptime(new_comptime); + return binding.set_comp_time(new_comptime); } *comptime = new_comptime; } @@ -616,7 +616,7 @@ impl Type { pub fn try_bind_to_polymorphic_int( &self, var: &TypeVariable, - var_comptime: &CompTime, + var_comp_time: &CompTime, use_subtype: bool, span: Span, ) -> Result<(), SpanKind> { @@ -625,36 +625,36 @@ impl Type { TypeBinding::Unbound(id) => *id, }; - let bind = |int_comptime: &CompTime| { + let bind = |int_comp_time: &CompTime| { let mut clone = self.clone(); - let mut new_comptime = var_comptime.clone(); - new_comptime.set_span(span); - clone.set_comptime(new_comptime); + let mut new_comp_time = var_comp_time.clone(); + new_comp_time.set_span(span); + clone.set_comp_time(new_comp_time); *var.borrow_mut() = TypeBinding::Bound(clone); if use_subtype { - var_comptime.is_subtype_of(int_comptime, span) + var_comp_time.is_subtype_of(int_comp_time, span) } else { - var_comptime.unify(int_comptime, span) + var_comp_time.unify(int_comp_time, span) } }; match self { - Type::FieldElement(int_comptime, ..) | Type::Integer(int_comptime, ..) => { - bind(int_comptime) + Type::FieldElement(int_comp_time, ..) | Type::Integer(int_comp_time, ..) => { + bind(int_comp_time) } - Type::PolymorphicInteger(int_comptime, self_var) => { + Type::PolymorphicInteger(int_comp_time, self_var) => { let borrow = self_var.borrow(); match &*borrow { TypeBinding::Bound(typ) => { - typ.try_bind_to_polymorphic_int(var, var_comptime, use_subtype, span) + typ.try_bind_to_polymorphic_int(var, var_comp_time, use_subtype, span) } // Avoid infinitely recursive bindings TypeBinding::Unbound(id) if *id == target_id => Ok(()), TypeBinding::Unbound(_) => { drop(borrow); - bind(int_comptime) + bind(int_comp_time) } } } @@ -662,7 +662,7 @@ impl Type { let borrow = binding.borrow(); match &*borrow { TypeBinding::Bound(typ) => { - typ.try_bind_to_polymorphic_int(var, var_comptime, use_subtype, span) + typ.try_bind_to_polymorphic_int(var, var_comp_time, use_subtype, span) } // Avoid infinitely recursive bindings TypeBinding::Unbound(id) if *id == target_id => Ok(()), @@ -670,8 +670,9 @@ impl Type { drop(borrow); // PolymorphicInt is more specific than TypeVariable so we bind the type // variable to PolymorphicInt instead. - let mut clone = Type::PolymorphicInteger(var_comptime.clone(), var.clone()); - clone.set_comptime_span(span); + let mut clone = + Type::PolymorphicInteger(var_comp_time.clone(), var.clone()); + clone.set_comp_time_span(span); *binding.borrow_mut() = TypeBinding::Bound(clone); Ok(()) } @@ -715,15 +716,15 @@ impl Type { } } - fn is_comptime(&self) -> bool { + fn is_comp_time(&self) -> bool { match self { - Type::FieldElement(comptime) => comptime.is_comptime(), - Type::Integer(comptime, ..) => comptime.is_comptime(), + Type::FieldElement(comptime) => comptime.is_comp_time(), + Type::Integer(comptime, ..) => comptime.is_comp_time(), Type::PolymorphicInteger(comptime, binding) => { if let TypeBinding::Bound(binding) = &*binding.borrow() { - return binding.is_comptime(); + return binding.is_comp_time(); } - comptime.is_comptime() + comptime.is_comp_time() } _ => false, } @@ -754,8 +755,8 @@ impl Type { ) { errors.push(make_error()); - match (expected.is_comptime(), err_span) { - (true, SpanKind::NotComptime(span)) => { + match (expected.is_comp_time(), err_span) { + (true, SpanKind::NotCompTime(span)) => { let msg = "The value is non-comptime because of this expression, which uses another non-comptime value".into(); errors.push(TypeCheckError::Unstructured { msg, span }); } diff --git a/crates/noirc_frontend/src/parser/parser.rs b/crates/noirc_frontend/src/parser/parser.rs index ed6bc1787b9..be2b8e7f7cd 100644 --- a/crates/noirc_frontend/src/parser/parser.rs +++ b/crates/noirc_frontend/src/parser/parser.rs @@ -470,7 +470,7 @@ fn optional_visibility() -> impl NoirParser { }) } -fn maybe_comptime() -> impl NoirParser { +fn maybe_comp_time() -> impl NoirParser { keyword(Keyword::CompTime).or_not().map(|opt| match opt { Some(_) => CompTime::Yes(None), None => CompTime::No(None), @@ -478,11 +478,11 @@ fn maybe_comptime() -> impl NoirParser { } fn field_type() -> impl NoirParser { - maybe_comptime().then_ignore(keyword(Keyword::Field)).map(UnresolvedType::FieldElement) + maybe_comp_time().then_ignore(keyword(Keyword::Field)).map(UnresolvedType::FieldElement) } fn bool_type() -> impl NoirParser { - maybe_comptime().then_ignore(keyword(Keyword::Bool)).map(UnresolvedType::Bool) + maybe_comp_time().then_ignore(keyword(Keyword::Bool)).map(UnresolvedType::Bool) } fn string_type() -> impl NoirParser { @@ -494,7 +494,7 @@ fn string_type() -> impl NoirParser { } fn int_type() -> impl NoirParser { - maybe_comptime() + maybe_comp_time() .then(filter_map(|span, token: Token| match token { Token::IntType(int_type) => Ok(int_type), unexpected => { From 17d4e837b00e841aafe3a3a0fd53e6e16adfef0b Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 13:09:07 +0000 Subject: [PATCH 083/115] ltype -> "lhs type" --- crates/noirc_evaluator/src/ssa/code_gen.rs | 6 +++--- cspell.json | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/code_gen.rs b/crates/noirc_evaluator/src/ssa/code_gen.rs index 360814c5571..29c7f4ea935 100644 --- a/crates/noirc_evaluator/src/ssa/code_gen.rs +++ b/crates/noirc_evaluator/src/ssa/code_gen.rs @@ -280,10 +280,10 @@ impl IRGenerator { rhs: NodeId, op: BinaryOpKind, ) -> Result { - let ltype = self.context.get_object_type(lhs); + let lhs_type = self.context.get_object_type(lhs); // Get the opcode from the infix operator - let opcode = Operation::Binary(Binary::from_ast(op, ltype, lhs, rhs)); - let op_type = self.context.get_result_type(&opcode, ltype); + let opcode = Operation::Binary(Binary::from_ast(op, lhs_type, lhs, rhs)); + let op_type = self.context.get_result_type(&opcode, lhs_type); self.context.new_instruction(opcode, op_type) } diff --git a/cspell.json b/cspell.json index c0e83c68b5b..702abf63346 100644 --- a/cspell.json +++ b/cspell.json @@ -31,7 +31,6 @@ "optim", "curr", "coeff", - "ltype", "udiv", "sdiv", "urem", From e257852f7d0441015db4807bb36d690d5f531174 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 13:14:23 +0000 Subject: [PATCH 084/115] curr -> current --- crates/nargo/src/cli/compile_cmd.rs | 4 ++-- crates/nargo/src/cli/gates_cmd.rs | 4 ++-- crates/nargo/src/cli/prove_cmd.rs | 4 ++-- crates/nargo/src/cli/verify_cmd.rs | 8 ++++---- crates/noirc_frontend/src/lexer/lexer.rs | 4 ++-- cspell.json | 1 - 6 files changed, 12 insertions(+), 13 deletions(-) diff --git a/crates/nargo/src/cli/compile_cmd.rs b/crates/nargo/src/cli/compile_cmd.rs index 37eaf1bdf81..5e130a59822 100644 --- a/crates/nargo/src/cli/compile_cmd.rs +++ b/crates/nargo/src/cli/compile_cmd.rs @@ -21,13 +21,13 @@ pub(crate) fn run(args: ArgMatches) -> Result<(), CliError> { let witness = args.is_present("witness"); let allow_warnings = args.is_present("allow-warnings"); - let curr_dir = std::env::current_dir().unwrap(); + let current_dir = std::env::current_dir().unwrap(); let mut circuit_path = PathBuf::new(); circuit_path.push(TARGET_DIR); let result = generate_circuit_and_witness_to_disk( circuit_name, - curr_dir, + current_dir, circuit_path, witness, allow_warnings, diff --git a/crates/nargo/src/cli/gates_cmd.rs b/crates/nargo/src/cli/gates_cmd.rs index 6adb818f2f8..04f0ecab759 100644 --- a/crates/nargo/src/cli/gates_cmd.rs +++ b/crates/nargo/src/cli/gates_cmd.rs @@ -13,8 +13,8 @@ pub(crate) fn run(args: ArgMatches) -> Result<(), CliError> { } pub fn count_gates(show_ssa: bool, allow_warnings: bool) -> Result<(), CliError> { - let curr_dir = std::env::current_dir().unwrap(); - count_gates_with_path(curr_dir, show_ssa, allow_warnings) + let current_dir = std::env::current_dir().unwrap(); + count_gates_with_path(current_dir, show_ssa, allow_warnings) } pub fn count_gates_with_path>( diff --git a/crates/nargo/src/cli/prove_cmd.rs b/crates/nargo/src/cli/prove_cmd.rs index f9624ecc751..f19db676a35 100644 --- a/crates/nargo/src/cli/prove_cmd.rs +++ b/crates/nargo/src/cli/prove_cmd.rs @@ -29,12 +29,12 @@ pub(crate) fn run(args: ArgMatches) -> Result<(), CliError> { const WITNESS_OFFSET: u32 = 1; fn prove(proof_name: Option<&str>, show_ssa: bool, allow_warnings: bool) -> Result<(), CliError> { - let curr_dir = std::env::current_dir().unwrap(); + let current_dir = std::env::current_dir().unwrap(); let mut proof_dir = PathBuf::new(); proof_dir.push(PROOFS_DIR); - prove_with_path(proof_name, curr_dir, proof_dir, show_ssa, allow_warnings)?; + prove_with_path(proof_name, current_dir, proof_dir, show_ssa, allow_warnings)?; Ok(()) } diff --git a/crates/nargo/src/cli/verify_cmd.rs b/crates/nargo/src/cli/verify_cmd.rs index 30d184d92e4..f95548d8314 100644 --- a/crates/nargo/src/cli/verify_cmd.rs +++ b/crates/nargo/src/cli/verify_cmd.rs @@ -27,12 +27,12 @@ pub(crate) fn run(args: ArgMatches) -> Result<(), CliError> { } fn verify(proof_name: &str, allow_warnings: bool) -> Result { - let curr_dir = std::env::current_dir().unwrap(); + let current_dir = std::env::current_dir().unwrap(); let mut proof_path = PathBuf::new(); //or cur_dir? proof_path.push(PROOFS_DIR); proof_path.push(Path::new(proof_name)); proof_path.set_extension(PROOF_EXT); - verify_with_path(&curr_dir, &proof_path, false, allow_warnings) + verify_with_path(¤t_dir, &proof_path, false, allow_warnings) } pub fn verify_with_path>( @@ -48,9 +48,9 @@ pub fn verify_with_path>( let public_abi = compiled_program.abi.clone().unwrap().public_abi(); let num_pub_params = public_abi.num_parameters(); if num_pub_params != 0 { - let curr_dir = program_dir; + let current_dir = program_dir; public_inputs = - read_inputs_from_file(curr_dir, VERIFIER_INPUT_FILE, Format::Toml, public_abi)?; + read_inputs_from_file(current_dir, VERIFIER_INPUT_FILE, Format::Toml, public_abi)?; } let valid_proof = verify_proof(compiled_program, public_inputs, load_proof(proof_path)?)?; diff --git a/crates/noirc_frontend/src/lexer/lexer.rs b/crates/noirc_frontend/src/lexer/lexer.rs index 6679128815a..cbdae322e81 100644 --- a/crates/noirc_frontend/src/lexer/lexer.rs +++ b/crates/noirc_frontend/src/lexer/lexer.rs @@ -204,8 +204,8 @@ impl<'a> Lexer<'a> { if peeked_char.is_ascii_alphabetic() { // Okay to unwrap here because we already peeked to // see that we have a character - let curr_char = self.next_char().unwrap(); - return self.eat_word(curr_char); + let current_char = self.next_char().unwrap(); + return self.eat_word(current_char); } Ok(spanned_prev_token) diff --git a/cspell.json b/cspell.json index 702abf63346..b0911b5b71d 100644 --- a/cspell.json +++ b/cspell.json @@ -29,7 +29,6 @@ // TODO: we should just name this more descriptively // TODO: ie is it optimizations or optimizer? "optim", - "curr", "coeff", "udiv", "sdiv", From 1f2b9f7f8a0784e2c7c513c530299480338f1c89 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 13:22:42 +0000 Subject: [PATCH 085/115] failable -> fallible --- crates/noirc_frontend/src/parser/parser.rs | 4 ++-- cspell.json | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/noirc_frontend/src/parser/parser.rs b/crates/noirc_frontend/src/parser/parser.rs index be2b8e7f7cd..f512849cec8 100644 --- a/crates/noirc_frontend/src/parser/parser.rs +++ b/crates/noirc_frontend/src/parser/parser.rs @@ -404,9 +404,9 @@ fn assignment<'a, P>(expr_parser: P) -> impl NoirParser + 'a where P: ExprParser + 'a, { - let failable = lvalue(expr_parser.clone()).then(assign_operator()).labelled("statement"); + let fallible = lvalue(expr_parser.clone()).then(assign_operator()).labelled("statement"); - then_commit(failable, expr_parser).map_with_span( + then_commit(fallible, expr_parser).map_with_span( |((identifier, operator), expression), span| { Statement::assign(identifier, operator, expression, span) }, diff --git a/cspell.json b/cspell.json index b0911b5b71d..5e57c313672 100644 --- a/cspell.json +++ b/cspell.json @@ -52,7 +52,6 @@ // TODO: ask Jake if we can expand on "l" "foldl", "comptime", - "failable", "desugared", "elems", "bindgen", From cd812ede64c5a8a28c53cc0233176d8ff747fc54 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 13:24:15 +0000 Subject: [PATCH 086/115] lowlevel -> "low-level" --- crates/noirc_evaluator/src/ssa/function.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/noirc_evaluator/src/ssa/function.rs b/crates/noirc_evaluator/src/ssa/function.rs index f134479f4ef..57010205ac5 100644 --- a/crates/noirc_evaluator/src/ssa/function.rs +++ b/crates/noirc_evaluator/src/ssa/function.rs @@ -332,7 +332,7 @@ impl IRGenerator { }) } - //Lowlevel functions with no more than 2 arguments + //Low-level functions with no more than 2 arguments pub fn call_low_level( &mut self, op: builtin::Opcode, From e4086e75826ff6cb3e310a4ddbadf725ca4f481b Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 13:26:55 +0000 Subject: [PATCH 087/115] "forscope" -> "for-scope" --- crates/noirc_frontend/src/hir/scope/mod.rs | 2 +- cspell.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/noirc_frontend/src/hir/scope/mod.rs b/crates/noirc_frontend/src/hir/scope/mod.rs index bf65be9e6b0..59dd4ae12a8 100644 --- a/crates/noirc_frontend/src/hir/scope/mod.rs +++ b/crates/noirc_frontend/src/hir/scope/mod.rs @@ -112,7 +112,7 @@ impl Default for ScopeTree { } } -// XXX: This trait is needed because when we pop off a forscope in the resolver +// XXX: This trait is needed because when we pop off a for-scope in the resolver // We want to check it for unused variables and return. Currently, // we only have an API for this with ScopeTree in the resolver. impl From> for ScopeTree { diff --git a/cspell.json b/cspell.json index 5e57c313672..993ca35b304 100644 --- a/cspell.json +++ b/cspell.json @@ -88,7 +88,6 @@ "impls", "nondeterministically", "typevar", - "forscope", "arity", "hindley", "milner", From e6e519b8a071ce7f81f8aeede8a13ba329f70ead Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 13:28:14 +0000 Subject: [PATCH 088/115] nondeterministically -> non-deterministically --- crates/noirc_frontend/src/hir/def_collector/dc_crate.rs | 2 +- cspell.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/noirc_frontend/src/hir/def_collector/dc_crate.rs b/crates/noirc_frontend/src/hir/def_collector/dc_crate.rs index bc66698af2d..1b4bd7991d1 100644 --- a/crates/noirc_frontend/src/hir/def_collector/dc_crate.rs +++ b/crates/noirc_frontend/src/hir/def_collector/dc_crate.rs @@ -294,7 +294,7 @@ fn resolve_structs( ) { // We must first go through the struct list once to ensure all IDs are pushed to // the def_interner map. This lets structs refer to each other regardless of declaration order - // without resolve_struct_fields nondeterministically unwrapping a value + // without resolve_struct_fields non-deterministically unwrapping a value // that isn't in the HashMap. for (type_id, typ) in &structs { context.def_interner.push_empty_struct(*type_id, typ); diff --git a/cspell.json b/cspell.json index 993ca35b304..866433f2eca 100644 --- a/cspell.json +++ b/cspell.json @@ -86,7 +86,6 @@ "subtyping", "Foralls", "impls", - "nondeterministically", "typevar", "arity", "hindley", From 17745972a9272a1880e048274344a760635ffde8 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 13:30:04 +0000 Subject: [PATCH 089/115] subtyping -> "sub-typing" --- crates/noirc_frontend/src/hir_def/types.rs | 6 +++--- cspell.json | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/crates/noirc_frontend/src/hir_def/types.rs b/crates/noirc_frontend/src/hir_def/types.rs index f4e089d9c4e..5aa90eb5766 100644 --- a/crates/noirc_frontend/src/hir_def/types.rs +++ b/crates/noirc_frontend/src/hir_def/types.rs @@ -612,7 +612,7 @@ impl Type { /// Try to bind a PolymorphicInt variable to self, succeeding if self is an integer, field, /// other PolymorphicInt type, or type variable. If use_subtype is true, the CompTime fields - /// of each will be checked via subtyping rather than unification. + /// of each will be checked via sub-typing rather than unification. pub fn try_bind_to_polymorphic_int( &self, var: &TypeVariable, @@ -732,7 +732,7 @@ impl Type { /// Try to unify this type with another, setting any type variables found /// equal to the other type in the process. Unification is more strict - /// than subtyping but less strict than Eq. Returns true if the unification + /// than sub-typing but less strict than Eq. Returns true if the unification /// succeeded. Note that any bindings performed in a failed unification are /// not undone. This may cause further type errors later on. pub fn unify( @@ -872,7 +872,7 @@ impl Type { } } - /// The `subtype` term here is somewhat loose, the only subtyping relations remaining + /// The `subtype` term here is somewhat loose, the only sub-typing relations remaining /// have to do with CompTime tracking. pub fn make_subtype_of( &self, diff --git a/cspell.json b/cspell.json index 866433f2eca..d6fc2ea8f67 100644 --- a/cspell.json +++ b/cspell.json @@ -83,7 +83,6 @@ "smol", "krate", "typevars", - "subtyping", "Foralls", "impls", "typevar", From f64c57972c330254a20635c88ed310d9dea5b5c4 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 13:31:32 +0000 Subject: [PATCH 090/115] pvalue -> "parent value" --- crates/noirc_evaluator/src/ssa/conditional.rs | 6 +++--- cspell.json | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/conditional.rs b/crates/noirc_evaluator/src/ssa/conditional.rs index 7248b579224..8c52493f1b7 100644 --- a/crates/noirc_evaluator/src/ssa/conditional.rs +++ b/crates/noirc_evaluator/src/ssa/conditional.rs @@ -166,14 +166,14 @@ impl DecisionTree { if let Some(value) = assumption.value { return value; } - let pvalue = self[assumption.parent].value.unwrap(); + let parent_value = self[assumption.parent].value.unwrap(); let condition = self[assumption.parent].condition; let ins = if self.is_true_branch(block.assumption) { DecisionTree::new_instruction_after_phi( ctx, block_id, BinaryOp::Mul, - pvalue, + parent_value, condition, ObjectType::Boolean, ) @@ -190,7 +190,7 @@ impl DecisionTree { ctx, block_id, BinaryOp::Mul, - pvalue, + parent_value, not_condition, ObjectType::Boolean, not_condition, diff --git a/cspell.json b/cspell.json index d6fc2ea8f67..41f723766d5 100644 --- a/cspell.json +++ b/cspell.json @@ -73,7 +73,6 @@ "pedersen", "schnorr", "merkle", - "pvalue", "binop", "vmap", "arithmetization", From 1ee7d1dbb53ec26ac2a54d256cb927b88a2a8eec Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 13:34:32 +0000 Subject: [PATCH 091/115] svec -> "slave vec" --- crates/noirc_evaluator/src/ssa/block.rs | 8 ++++---- cspell.json | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/block.rs b/crates/noirc_evaluator/src/ssa/block.rs index 4c9ceaa2c4e..4e60159c8fc 100644 --- a/crates/noirc_evaluator/src/ssa/block.rs +++ b/crates/noirc_evaluator/src/ssa/block.rs @@ -244,10 +244,10 @@ pub fn compute_dom(ctx: &mut SsaContext) { dominator_link.entry(dom).or_insert_with(Vec::new).push(block.id); } } - for (master, svec) in dominator_link { + for (master, slave_vec) in dominator_link { if let Some(dom_b) = ctx.try_get_block_mut(master) { dom_b.dominated.clear(); - for slave in svec { + for slave in slave_vec { dom_b.dominated.push(slave); } } @@ -263,9 +263,9 @@ pub fn compute_sub_dom(ctx: &mut SsaContext, blocks: &[BlockId]) { dominator_link.entry(dom).or_insert_with(Vec::new).push(block.id); } } - for (master, svec) in dominator_link { + for (master, slave_vec) in dominator_link { let dom_b = &mut ctx[master]; - for slave in svec { + for slave in slave_vec { dom_b.dominated.push(slave); } } diff --git a/cspell.json b/cspell.json index 41f723766d5..1bf95444c64 100644 --- a/cspell.json +++ b/cspell.json @@ -69,7 +69,6 @@ "injective", "thiserror", "Deque", - "svec", "pedersen", "schnorr", "merkle", From a96044cfe31703f66b3f1ba639ee6da10bcbc35a Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 13:37:47 +0000 Subject: [PATCH 092/115] binop -> "binary op" --- crates/noirc_evaluator/src/ssa/conditional.rs | 14 +++++++------- crates/noirc_frontend/src/ast/statement.rs | 2 +- crates/noirc_frontend/src/lexer/token.rs | 6 +++--- crates/noirc_frontend/src/parser/parser.rs | 2 +- cspell.json | 1 - 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/conditional.rs b/crates/noirc_evaluator/src/ssa/conditional.rs index 8c52493f1b7..52bb62b5b73 100644 --- a/crates/noirc_evaluator/src/ssa/conditional.rs +++ b/crates/noirc_evaluator/src/ssa/conditional.rs @@ -553,9 +553,9 @@ impl DecisionTree { } stack.push(ins_id); } - Operation::Binary(binop) => { + Operation::Binary(binary_op) => { let mut cond = ass_value; - if let Some(pred) = binop.predicate { + if let Some(pred) = binary_op.predicate { assert_ne!(pred, NodeId::dummy()); if ass_value == NodeId::dummy() { cond = pred; @@ -576,13 +576,13 @@ impl DecisionTree { } } stack.push(ins_id); - match binop.operator { + match binary_op.operator { BinaryOp::Udiv | BinaryOp::Sdiv | BinaryOp::Urem | BinaryOp::Srem | BinaryOp::Div => { - if ctx.is_zero(binop.rhs) { + if ctx.is_zero(binary_op.rhs) { DecisionTree::short_circuit( ctx, stack, @@ -594,9 +594,9 @@ impl DecisionTree { if ctx.under_assumption(cond) { let ins2 = ctx.get_mut_instruction(ins_id); ins2.operation = Operation::Binary(crate::node::Binary { - lhs: binop.lhs, - rhs: binop.rhs, - operator: binop.operator.clone(), + lhs: binary_op.lhs, + rhs: binary_op.rhs, + operator: binary_op.operator.clone(), predicate: Some(cond), }); } diff --git a/crates/noirc_frontend/src/ast/statement.rs b/crates/noirc_frontend/src/ast/statement.rs index e7076b1ebd5..7c69147c0b0 100644 --- a/crates/noirc_frontend/src/ast/statement.rs +++ b/crates/noirc_frontend/src/ast/statement.rs @@ -214,7 +214,7 @@ impl Statement { let infix = crate::InfixExpression { lhs: lvalue_expr, - operator: operator.try_into_binop(span).expect(error_msg), + operator: operator.try_into_binary_op(span).expect(error_msg), rhs: expression, }; expression = Expression::new(ExpressionKind::Infix(Box::new(infix)), span); diff --git a/crates/noirc_frontend/src/lexer/token.rs b/crates/noirc_frontend/src/lexer/token.rs index 4f1f6c0690f..9f0a1fa65c0 100644 --- a/crates/noirc_frontend/src/lexer/token.rs +++ b/crates/noirc_frontend/src/lexer/token.rs @@ -235,9 +235,9 @@ impl Token { [Plus, Minus, Star, Slash, Percent, Ampersand, Caret, ShiftLeft, ShiftRight, Pipe] } - pub fn try_into_binop(self, span: Span) -> Option> { + pub fn try_into_binary_op(self, span: Span) -> Option> { use crate::BinaryOpKind::*; - let binop = match self { + let binary_op = match self { Token::Plus => Add, Token::Ampersand => And, Token::Caret => Xor, @@ -256,7 +256,7 @@ impl Token { Token::Percent => Modulo, _ => return None, }; - Some(Spanned::from(span, binop)) + Some(Spanned::from(span, binary_op)) } } diff --git a/crates/noirc_frontend/src/parser/parser.rs b/crates/noirc_frontend/src/parser/parser.rs index f512849cec8..5d37125147a 100644 --- a/crates/noirc_frontend/src/parser/parser.rs +++ b/crates/noirc_frontend/src/parser/parser.rs @@ -613,7 +613,7 @@ fn create_infix_expression(lhs: Expression, (operator, rhs): (BinaryOp, Expressi fn operator_with_precedence(precedence: Precedence) -> impl NoirParser> { filter_map(move |span, token: Token| { if Precedence::token_precedence(&token) == Some(precedence) { - Ok(token.try_into_binop(span).unwrap()) + Ok(token.try_into_binary_op(span).unwrap()) } else { Err(ParserError::expected_label("binary operator".to_string(), token, span)) } diff --git a/cspell.json b/cspell.json index 1bf95444c64..1395d11d66e 100644 --- a/cspell.json +++ b/cspell.json @@ -72,7 +72,6 @@ "pedersen", "schnorr", "merkle", - "binop", "vmap", "arithmetization", "bitand", From 29eb200cffeb36614ccb12f4d7b98f6b8a4d0d7d Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 13:38:43 +0000 Subject: [PATCH 093/115] bitcount -> "bit count" --- crates/noirc_evaluator/src/ssa/node.rs | 2 +- cspell.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/node.rs b/crates/noirc_evaluator/src/ssa/node.rs index c252c0720ed..f4a3a377638 100644 --- a/crates/noirc_evaluator/src/ssa/node.rs +++ b/crates/noirc_evaluator/src/ssa/node.rs @@ -1025,7 +1025,7 @@ impl Binary { } } -/// Perform the given numeric operation and modulo the result by the max value for the given bitcount +/// Perform the given numeric operation and modulo the result by the max value for the given bit count /// if the res_type is not a NativeField. fn wrapping( lhs: FieldElement, diff --git a/cspell.json b/cspell.json index 1395d11d66e..476821138d8 100644 --- a/cspell.json +++ b/cspell.json @@ -75,7 +75,6 @@ "vmap", "arithmetization", "bitand", - "bitcount", "subexpression", "smol", "krate", From 4a49b9944a4c7a605d7ae78cdda871e496d8f616 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 13:44:18 +0000 Subject: [PATCH 094/115] vmap -> "value map" --- crates/noirc_evaluator/src/ssa/integer.rs | 44 +++++++++++++---------- cspell.json | 1 - 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/integer.rs b/crates/noirc_evaluator/src/ssa/integer.rs index b53f705034a..973e4122ba1 100644 --- a/crates/noirc_evaluator/src/ssa/integer.rs +++ b/crates/noirc_evaluator/src/ssa/integer.rs @@ -27,7 +27,7 @@ fn get_instruction_max( ctx: &SsaContext, ins: &Instruction, max_map: &mut HashMap, - vmap: &HashMap, + value_map: &HashMap, ) -> BigUint { assert_ne!( ins.operation.opcode(), @@ -35,9 +35,9 @@ fn get_instruction_max( "Phi instructions must have been simplified" ); ins.operation.for_each_id(|id| { - get_obj_max_value(ctx, id, max_map, vmap); + get_obj_max_value(ctx, id, max_map, value_map); }); - get_instruction_max_operand(ctx, ins, max_map, vmap) + get_instruction_max_operand(ctx, ins, max_map, value_map) } //Gets the maximum value of the instruction result using the provided operand maximum @@ -45,10 +45,12 @@ fn get_instruction_max_operand( ctx: &SsaContext, ins: &Instruction, max_map: &mut HashMap, - vmap: &HashMap, + value_map: &HashMap, ) -> BigUint { match &ins.operation { - Operation::Load { array_id, index } => get_load_max(ctx, *index, max_map, vmap, *array_id), + Operation::Load { array_id, index } => { + get_load_max(ctx, *index, max_map, value_map, *array_id) + } Operation::Binary(node::Binary { operator, lhs, rhs, .. }) => { if let BinaryOp::Sub { .. } = operator { //TODO uses interval analysis instead @@ -82,9 +84,9 @@ fn get_obj_max_value( ctx: &SsaContext, id: NodeId, max_map: &mut HashMap, - vmap: &HashMap, + value_map: &HashMap, ) -> BigUint { - let id = get_value_from_map(id, vmap); + let id = get_value_from_map(id, value_map); if max_map.contains_key(&id) { return max_map[&id].clone(); } @@ -96,7 +98,7 @@ fn get_obj_max_value( let result = match obj { NodeObject::Obj(v) => (BigUint::one() << v.size_in_bits()) - BigUint::one(), //TODO check for signed type - NodeObject::Instr(i) => get_instruction_max(ctx, i, max_map, vmap), + NodeObject::Instr(i) => get_instruction_max(ctx, i, max_map, value_map), NodeObject::Const(c) => c.value.clone(), //TODO panic for string constants NodeObject::Function(..) => BigUint::zero(), }; @@ -151,11 +153,11 @@ fn fix_truncate( id: NodeId, prev_id: NodeId, block_idx: BlockId, - vmap: &mut HashMap, + value_map: &mut HashMap, ) { if let Some(ins) = eval.try_get_mut_instruction(id) { ins.parent_block = block_idx; - vmap.insert(prev_id, id); + value_map.insert(prev_id, id); } } @@ -187,12 +189,12 @@ fn process_to_truncate( to_truncate: &mut BTreeMap, max_map: &mut HashMap, block_idx: BlockId, - vmap: &mut HashMap, + value_map: &mut HashMap, ) { for (id, bit_size) in to_truncate.iter() { if let Some(truncate_idx) = truncate(ctx, *id, *bit_size, max_map) { //TODO properly handle signed arithmetic... - fix_truncate(ctx, truncate_idx, *id, block_idx, vmap); + fix_truncate(ctx, truncate_idx, *id, block_idx, value_map); new_list.push(truncate_idx); } } @@ -405,16 +407,20 @@ fn block_overflow( Ok(()) } -fn update_value_array(ctx: &mut SsaContext, block_id: BlockId, vmap: &HashMap) { +fn update_value_array( + ctx: &mut SsaContext, + block_id: BlockId, + value_map: &HashMap, +) { let block = &mut ctx[block_id]; - for (old, new) in vmap { + for (old, new) in value_map { block.value_map.insert(*old, *new); //TODO we must merge rather than update } } -//Get current value using the provided vmap -pub fn get_value_from_map(id: NodeId, vmap: &HashMap) -> NodeId { - *vmap.get(&id).unwrap_or(&id) +//Get current value using the provided value map +pub fn get_value_from_map(id: NodeId, value_map: &HashMap) -> NodeId { + *value_map.get(&id).unwrap_or(&id) } fn get_size_in_bits(obj: Option<&NodeObject>) -> u32 { @@ -437,12 +443,12 @@ fn get_load_max( ctx: &SsaContext, address: NodeId, max_map: &mut HashMap, - vmap: &HashMap, + value_map: &HashMap, array: ArrayId, // obj_type: ObjectType, ) -> BigUint { if let Some(&value) = ctx.get_indexed_value(array, address) { - return get_obj_max_value(ctx, value, max_map, vmap); + return get_obj_max_value(ctx, value, max_map, value_map); }; ctx.mem[array].max.clone() //return array max } diff --git a/cspell.json b/cspell.json index 476821138d8..30b0706f79b 100644 --- a/cspell.json +++ b/cspell.json @@ -72,7 +72,6 @@ "pedersen", "schnorr", "merkle", - "vmap", "arithmetization", "bitand", "subexpression", From 39b7d30f24c9923e50dff4effc48a345675b9952 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 13:46:51 +0000 Subject: [PATCH 095/115] tokenkind -> "token kind" --- crates/noirc_frontend/src/parser/parser.rs | 14 +++++++------- cspell.json | 1 - 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/crates/noirc_frontend/src/parser/parser.rs b/crates/noirc_frontend/src/parser/parser.rs index 5d37125147a..8e66015a1be 100644 --- a/crates/noirc_frontend/src/parser/parser.rs +++ b/crates/noirc_frontend/src/parser/parser.rs @@ -164,7 +164,7 @@ fn function_return_type() -> impl NoirParser<(AbiVisibility, UnresolvedType)> { } fn attribute() -> impl NoirParser { - tokenkind(TokenKind::Attribute).map(|token| match token { + token_kind(TokenKind::Attribute).map(|token| match token { Token::Attribute(attribute) => attribute, _ => unreachable!(), }) @@ -311,12 +311,12 @@ fn keyword(keyword: Keyword) -> impl NoirParser { just(Token::Keyword(keyword)) } -fn tokenkind(tokenkind: TokenKind) -> impl NoirParser { +fn token_kind(token_kind: TokenKind) -> impl NoirParser { filter_map(move |span, found: Token| { - if found.kind() == tokenkind { + if found.kind() == token_kind { Ok(found) } else { - Err(ParserError::expected_label(tokenkind.to_string(), found, span)) + Err(ParserError::expected_label(token_kind.to_string(), found, span)) } }) } @@ -336,7 +336,7 @@ fn path() -> impl NoirParser { } fn ident() -> impl NoirParser { - tokenkind(TokenKind::Ident).map_with_span(Ident::from_token) + token_kind(TokenKind::Ident).map_with_span(Ident::from_token) } fn statement<'a, P>(expr_parser: P) -> impl NoirParser + 'a @@ -851,7 +851,7 @@ where } fn field_name() -> impl NoirParser { - ident().or(tokenkind(TokenKind::Literal).validate(|token, span, emit| match token { + ident().or(token_kind(TokenKind::Literal).validate(|token, span, emit| match token { Token::Int(_) => Ident::from(Spanned::from(span, token.to_string())), other => { let reason = format!("Unexpected '{other}', expected a field name"); @@ -888,7 +888,7 @@ fn variable() -> impl NoirParser { } fn literal() -> impl NoirParser { - tokenkind(TokenKind::Literal).map(|token| match token { + token_kind(TokenKind::Literal).map(|token| match token { Token::Int(x) => ExpressionKind::integer(x), Token::Bool(b) => ExpressionKind::boolean(b), Token::Str(s) => ExpressionKind::string(s), diff --git a/cspell.json b/cspell.json index 30b0706f79b..5a75f5cd268 100644 --- a/cspell.json +++ b/cspell.json @@ -47,7 +47,6 @@ "nixpkgs", "rustup", "chumsky", - "tokenkind", "idents", // TODO: ask Jake if we can expand on "l" "foldl", From 0c30f6fe37d6624e88b4664e056fd26cebc955f1 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 14:01:04 +0000 Subject: [PATCH 096/115] rtype -> (rhs_type/result_type) --- crates/noirc_evaluator/src/ssa/code_gen.rs | 12 ++++++------ crates/noirc_evaluator/src/ssa/context.rs | 4 ++-- cspell.json | 1 - 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/code_gen.rs b/crates/noirc_evaluator/src/ssa/code_gen.rs index 29c7f4ea935..cdd3f94a9ac 100644 --- a/crates/noirc_evaluator/src/ssa/code_gen.rs +++ b/crates/noirc_evaluator/src/ssa/code_gen.rs @@ -262,15 +262,15 @@ impl IRGenerator { rhs: NodeId, op: UnaryOp, ) -> Result { - let rtype = self.context.get_object_type(rhs); + let rhs_type = self.context.get_object_type(rhs); match op { UnaryOp::Minus => { - let lhs = self.context.zero_with_type(rtype); + let lhs = self.context.zero_with_type(rhs_type); let operator = BinaryOp::Sub { max_rhs_value: BigUint::zero() }; let op = Operation::Binary(node::Binary { operator, lhs, rhs, predicate: None }); - self.context.new_instruction(op, rtype) + self.context.new_instruction(op, rhs_type) } - UnaryOp::Not => self.context.new_instruction(Operation::Not(rhs), rtype), + UnaryOp::Not => self.context.new_instruction(Operation::Not(rhs), rhs_type), } } @@ -607,9 +607,9 @@ impl IRGenerator { } Expression::Cast(cast_expr) => { let lhs = self.codegen_expression(&cast_expr.lhs)?.unwrap_id(); - let rtype = self.context.convert_type(&cast_expr.r#type); + let object_type = self.context.convert_type(&cast_expr.r#type); - Ok(Value::Single(self.context.new_instruction(Operation::Cast(lhs), rtype)?)) + Ok(Value::Single(self.context.new_instruction(Operation::Cast(lhs), object_type)?)) } Expression::Index(indexed_expr) => { // Evaluate the 'array' expression diff --git a/crates/noirc_evaluator/src/ssa/context.rs b/crates/noirc_evaluator/src/ssa/context.rs index e41ea5a54ad..e9f0671257d 100644 --- a/crates/noirc_evaluator/src/ssa/context.rs +++ b/crates/noirc_evaluator/src/ssa/context.rs @@ -884,11 +884,11 @@ impl SsaContext { } else if matches!(lhs_type, ObjectType::Pointer(_)) { if let Some(Instruction { operation: Operation::Intrinsic(_, _), - res_type: rtype, + res_type: result_type, .. }) = self.try_get_mut_instruction(rhs) { - *rtype = lhs_type; + *result_type = lhs_type; return Ok(lhs); } else { self.memcpy(lhs_type, rhs_type)?; diff --git a/cspell.json b/cspell.json index 5a75f5cd268..075c8d20c84 100644 --- a/cspell.json +++ b/cspell.json @@ -25,7 +25,6 @@ "vecmap", "forall", "signedness", - "rtype", // TODO: we should just name this more descriptively // TODO: ie is it optimizations or optimizer? "optim", From 47abf0b47656de16398d1c1c2d860427d8b2c668 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 14:15:22 +0000 Subject: [PATCH 097/115] arraylen -> "array len" --- crates/noirc_frontend/src/monomorphization/mod.rs | 4 ++-- cspell.json | 1 - noir_stdlib/src/array.nr | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/crates/noirc_frontend/src/monomorphization/mod.rs b/crates/noirc_frontend/src/monomorphization/mod.rs index 857e2742c47..3543e4ee800 100644 --- a/crates/noirc_frontend/src/monomorphization/mod.rs +++ b/crates/noirc_frontend/src/monomorphization/mod.rs @@ -575,7 +575,7 @@ impl Monomorphizer { })) } - /// Try to evaluate certain builtin functions (currently only 'arraylen' and field modulus methods) + /// Try to evaluate certain builtin functions (currently only 'array_len' and field modulus methods) /// at their call site. /// NOTE: Evaluating at the call site means we cannot track aliased functions. /// E.g. `let f = std::array::len; f(arr)` will fail to evaluate. @@ -588,7 +588,7 @@ impl Monomorphizer { ) -> Option { match func { ast::Expression::Ident(ident) => match &ident.definition { - Definition::Builtin(opcode) if opcode == "arraylen" => { + Definition::Builtin(opcode) if opcode == "array_len" => { let typ = self.interner.id_type(arguments[0]); let len = typ.evaluate_to_u64().unwrap(); Some(ast::Expression::Literal(ast::Literal::Integer( diff --git a/cspell.json b/cspell.json index 075c8d20c84..9952e538e56 100644 --- a/cspell.json +++ b/cspell.json @@ -84,7 +84,6 @@ "milner", "peekable", "hexdigit", - "arraylen", "struct", "stdlib", "noirup", diff --git a/noir_stdlib/src/array.nr b/noir_stdlib/src/array.nr index 30b146cdab8..b31b967ec8e 100644 --- a/noir_stdlib/src/array.nr +++ b/noir_stdlib/src/array.nr @@ -1,4 +1,4 @@ -#[builtin(arraylen)] +#[builtin(array_len)] fn len(_input : [T]) -> comptime Field {} // insertion sort - n.b. it is a quadratic sort From 2c6c72ef9835929bbd8a3536075a009fbc3be5b6 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 14:17:16 +0000 Subject: [PATCH 098/115] ncrate -> crate --- crates/noirc_driver/src/main.rs | 8 ++++---- cspell.json | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/crates/noirc_driver/src/main.rs b/crates/noirc_driver/src/main.rs index 7e7b4450129..5663d745898 100644 --- a/crates/noirc_driver/src/main.rs +++ b/crates/noirc_driver/src/main.rs @@ -11,12 +11,12 @@ fn main() { driver.create_local_crate(ROOT_DIR_MAIN, CrateType::Binary); // Add libraries into Driver - let ncrate_id1 = driver.create_non_local_crate(EXTERNAL_DIR2, CrateType::Library); - let ncrate_id2 = driver.create_non_local_crate(EXTERNAL_DIR, CrateType::Library); + let crate_id1 = driver.create_non_local_crate(EXTERNAL_DIR2, CrateType::Library); + let crate_id2 = driver.create_non_local_crate(EXTERNAL_DIR, CrateType::Library); // Add dependencies as package - driver.add_dep(LOCAL_CRATE, ncrate_id1, "coo4"); - driver.add_dep(LOCAL_CRATE, ncrate_id2, "coo3"); + driver.add_dep(LOCAL_CRATE, crate_id1, "coo4"); + driver.add_dep(LOCAL_CRATE, crate_id2, "coo3"); driver.into_compiled_program(acvm::Language::R1CS, false, false); } diff --git a/cspell.json b/cspell.json index 9952e538e56..001a2ca25b8 100644 --- a/cspell.json +++ b/cspell.json @@ -62,7 +62,6 @@ "wedderburn", "termcolor", "arity", - "ncrate", "Hasher", "injective", "thiserror", From 67632782fee53f2097c1a27ab860ad2248c9b347 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 14:26:08 +0000 Subject: [PATCH 099/115] cdir -> current_dir --- crates/nargo/tests/prove_and_verify.rs | 22 +++++++++++----------- cspell.json | 1 - 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/crates/nargo/tests/prove_and_verify.rs b/crates/nargo/tests/prove_and_verify.rs index 382a2ca22b3..f583b2cb27d 100644 --- a/crates/nargo/tests/prove_and_verify.rs +++ b/crates/nargo/tests/prove_and_verify.rs @@ -28,19 +28,19 @@ mod tests { #[test] fn noir_integration() { - let mut cdir = std::env::current_dir().unwrap(); - cdir.push(TEST_DIR); - cdir.push(TEST_DATA_DIR); + let mut current_dir = std::env::current_dir().unwrap(); + current_dir.push(TEST_DIR); + current_dir.push(TEST_DATA_DIR); //load config.tml file from test_data directory - cdir.push(CONFIG_FILE); - let config_path = std::fs::read_to_string(cdir).unwrap(); - let conf_data: BTreeMap> = load_conf(&config_path); - let mut cdir = std::env::current_dir().unwrap(); - cdir.push(TEST_DIR); - cdir.push(TEST_DATA_DIR); + current_dir.push(CONFIG_FILE); + let config_path = std::fs::read_to_string(current_dir).unwrap(); + let config_data: BTreeMap> = load_conf(&config_path); + let mut current_dir = std::env::current_dir().unwrap(); + current_dir.push(TEST_DIR); + current_dir.push(TEST_DATA_DIR); - for c in fs::read_dir(cdir.as_path()).unwrap().flatten() { + for c in fs::read_dir(current_dir.as_path()).unwrap().flatten() { if let Ok(test_name) = c.file_name().into_string() { println!("Running test {test_name:?}"); if c.path().is_dir() && !conf_data["exclude"].contains(&test_name) { @@ -55,7 +55,7 @@ mod tests { } }; - if conf_data["fail"].contains(&test_name) { + if config_data["fail"].contains(&test_name) { assert!(!r, "{:?} should not succeed", c.file_name()); } else { assert!(r, "verification fail for {:?}", c.file_name()); diff --git a/cspell.json b/cspell.json index 001a2ca25b8..6e3b30e5c80 100644 --- a/cspell.json +++ b/cspell.json @@ -36,7 +36,6 @@ "nvar", "igen", "Barretenberg", - "cdir", "uninstantiated", "libomp", "clippy", From d073e6b97683307975e731cbe78a276c2009618c Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 14:27:48 +0000 Subject: [PATCH 100/115] nvar -> "new var" (This is not great naming either way, but thats for another PR) --- crates/noirc_evaluator/src/ssa/context.rs | 4 ++-- cspell.json | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/context.rs b/crates/noirc_evaluator/src/ssa/context.rs index e9f0671257d..9d2343c37a2 100644 --- a/crates/noirc_evaluator/src/ssa/context.rs +++ b/crates/noirc_evaluator/src/ssa/context.rs @@ -511,8 +511,8 @@ impl SsaContext { *v_name += 1; let variable_id = *v_name; - if let Ok(nvar) = self.get_mut_variable(new_var) { - nvar.name = format!("{root_name}{variable_id}"); + if let Ok(new_var) = self.get_mut_variable(new_var) { + new_var.name = format!("{root_name}{variable_id}"); } } diff --git a/cspell.json b/cspell.json index 6e3b30e5c80..13e86638215 100644 --- a/cspell.json +++ b/cspell.json @@ -33,7 +33,6 @@ "sdiv", "urem", "srem", - "nvar", "igen", "Barretenberg", "uninstantiated", From 244244c824751ad02d950fe38af9026766174e0a Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 14:29:52 +0000 Subject: [PATCH 101/115] igen -> ir_gen --- crates/noirc_evaluator/src/lib.rs | 32 ++++++++++---------- crates/noirc_evaluator/src/ssa/anchor.rs | 4 +-- crates/noirc_evaluator/src/ssa/function.rs | 35 +++++++++++----------- crates/noirc_evaluator/src/ssa/optim.rs | 24 +++++++++------ cspell.json | 1 - 5 files changed, 51 insertions(+), 45 deletions(-) diff --git a/crates/noirc_evaluator/src/lib.rs b/crates/noirc_evaluator/src/lib.rs index 0c9aff657d5..3d02644f39c 100644 --- a/crates/noirc_evaluator/src/lib.rs +++ b/crates/noirc_evaluator/src/lib.rs @@ -89,14 +89,14 @@ impl Evaluator { program: Program, enable_logging: bool, ) -> Result<(), RuntimeError> { - let mut igen = IRGenerator::new(program); - self.parse_abi_alt(&mut igen); + let mut ir_gen = IRGenerator::new(program); + self.parse_abi_alt(&mut ir_gen); // Now call the main function - igen.codegen_main()?; + ir_gen.codegen_main()?; //Generates ACIR representation: - igen.context.ir_to_acir(self, enable_logging)?; + ir_gen.context.ir_to_acir(self, enable_logging)?; Ok(()) } @@ -119,7 +119,7 @@ impl Evaluator { def: Definition, param_type: &AbiType, visibility: &AbiVisibility, - igen: &mut IRGenerator, + ir_gen: &mut IRGenerator, ) -> Result<(), RuntimeErrorKind> { match param_type { AbiType::Field => { @@ -127,7 +127,7 @@ impl Evaluator { if *visibility == AbiVisibility::Public { self.public_inputs.push(witness); } - igen.create_new_variable( + ir_gen.create_new_variable( name.to_owned(), Some(def), node::ObjectType::NativeField, @@ -139,7 +139,7 @@ impl Evaluator { if *visibility == AbiVisibility::Public { self.public_inputs.extend(witnesses.clone()); } - igen.abi_array(name, Some(def), typ.as_ref(), *length, witnesses); + ir_gen.abi_array(name, Some(def), typ.as_ref(), *length, witnesses); } AbiType::Integer { sign: _, width } => { let witness = self.add_witness_to_cs(); @@ -147,8 +147,8 @@ impl Evaluator { if *visibility == AbiVisibility::Public { self.public_inputs.push(witness); } - let obj_type = igen.get_object_type_from_abi(param_type); // Fetch signedness of the integer - igen.create_new_variable(name.to_owned(), Some(def), obj_type, Some(witness)); + let obj_type = ir_gen.get_object_type_from_abi(param_type); // Fetch signedness of the integer + ir_gen.create_new_variable(name.to_owned(), Some(def), obj_type, Some(witness)); } AbiType::Boolean => { let witness = self.add_witness_to_cs(); @@ -157,7 +157,7 @@ impl Evaluator { self.public_inputs.push(witness); } let obj_type = node::ObjectType::Boolean; - igen.create_new_variable(name.to_owned(), Some(def), obj_type, Some(witness)); + ir_gen.create_new_variable(name.to_owned(), Some(def), obj_type, Some(witness)); } AbiType::Struct { fields } => { let new_fields = btree_map(fields, |(inner_name, value)| { @@ -172,7 +172,7 @@ impl Evaluator { struct_witnesses.values().flatten().cloned().collect(); self.public_inputs.extend(witnesses); } - igen.abi_struct(name, Some(def), fields, struct_witnesses); + ir_gen.abi_struct(name, Some(def), fields, struct_witnesses); } AbiType::String { length } => { let typ = AbiType::Integer { sign: noirc_abi::Sign::Unsigned, width: 8 }; @@ -180,7 +180,7 @@ impl Evaluator { if *visibility == AbiVisibility::Public { self.public_inputs.extend(witnesses.clone()); } - igen.abi_array(name, Some(def), &typ, *length, witnesses); + ir_gen.abi_array(name, Some(def), &typ, *length, witnesses); } } Ok(()) @@ -253,20 +253,20 @@ impl Evaluator { /// Noted in the noirc_abi, it is possible to convert Toml -> NoirTypes /// However, this intermediate representation is useful as it allows us to have /// intermediate Types which the core type system does not know about like Strings. - fn parse_abi_alt(&mut self, igen: &mut IRGenerator) { + fn parse_abi_alt(&mut self, ir_gen: &mut IRGenerator) { // XXX: Currently, the syntax only supports public witnesses // u8 and arrays are assumed to be private // This is not a short-coming of the ABI, but of the grammar // The new grammar has been conceived, and will be implemented. - let main = igen.program.main(); + let main = ir_gen.program.main(); let main_params = std::mem::take(&mut main.parameters); - let abi_params = std::mem::take(&mut igen.program.abi.parameters); + let abi_params = std::mem::take(&mut ir_gen.program.abi.parameters); assert_eq!(main_params.len(), abi_params.len()); for ((param_id, _, param_name, _), abi_param) in main_params.iter().zip(abi_params) { assert_eq!(param_name, &abi_param.name); let def = Definition::Local(*param_id); - self.param_to_var(param_name, def, &abi_param.typ, &abi_param.visibility, igen) + self.param_to_var(param_name, def, &abi_param.typ, &abi_param.visibility, ir_gen) .unwrap(); } } diff --git a/crates/noirc_evaluator/src/ssa/anchor.rs b/crates/noirc_evaluator/src/ssa/anchor.rs index c0ab28402ad..edd2419073b 100644 --- a/crates/noirc_evaluator/src/ssa/anchor.rs +++ b/crates/noirc_evaluator/src/ssa/anchor.rs @@ -67,7 +67,7 @@ impl Anchor { pub fn find_similar_cast( &self, - igen: &SsaContext, + ir_gen: &SsaContext, operator: &Operation, res_type: super::node::ObjectType, ) -> Option { @@ -77,7 +77,7 @@ impl Anchor { let by_type = &self.cast_map[id]; if by_type.contains_key(&res_type) { let tu = by_type[&res_type]; - if let Some(ins) = igen.try_get_instruction(tu) { + if let Some(ins) = ir_gen.try_get_instruction(tu) { if !ins.is_deleted() { return Some(tu); } diff --git a/crates/noirc_evaluator/src/ssa/function.rs b/crates/noirc_evaluator/src/ssa/function.rs index 57010205ac5..79e3f123e40 100644 --- a/crates/noirc_evaluator/src/ssa/function.rs +++ b/crates/noirc_evaluator/src/ssa/function.rs @@ -61,59 +61,60 @@ impl SSAFunction { } } - pub fn compile(&self, igen: &mut IRGenerator) -> Result { - let function_cfg = block::bfs(self.entry_block, None, &igen.context); - block::compute_sub_dom(&mut igen.context, &function_cfg); + pub fn compile(&self, ir_gen: &mut IRGenerator) -> Result { + let function_cfg = block::bfs(self.entry_block, None, &ir_gen.context); + block::compute_sub_dom(&mut ir_gen.context, &function_cfg); //Optimization //catch the error because the function may not be called - super::optim::full_cse(&mut igen.context, self.entry_block, false)?; + super::optim::full_cse(&mut ir_gen.context, self.entry_block, false)?; //Unrolling - super::flatten::unroll_tree(&mut igen.context, self.entry_block)?; + super::flatten::unroll_tree(&mut ir_gen.context, self.entry_block)?; //reduce conditionals - let mut decision = DecisionTree::new(&igen.context); + let mut decision = DecisionTree::new(&ir_gen.context); let mut builder = TreeBuilder::new(self.entry_block); for (arg, _) in &self.arguments { - if let ObjectType::Pointer(a) = igen.context.get_object_type(*arg) { + if let ObjectType::Pointer(a) = ir_gen.context.get_object_type(*arg) { builder.stack.created_arrays.insert(a, self.entry_block); } } let mut to_remove: VecDeque = VecDeque::new(); - let result = decision.make_decision_tree(&mut igen.context, builder); + let result = decision.make_decision_tree(&mut ir_gen.context, builder); if result.is_err() { // we take the last block to ensure we have the return instruction - let exit = block::exit(&igen.context, self.entry_block); + let exit = block::exit(&ir_gen.context, self.entry_block); //short-circuit for function: false constraint and return 0 - let instructions = &igen.context[exit].instructions.clone(); + let instructions = &ir_gen.context[exit].instructions.clone(); let stack = block::short_circuit_instructions( - &mut igen.context, + &mut ir_gen.context, self.entry_block, instructions, ); if self.entry_block != exit { for i in &stack { - igen.context.get_mut_instruction(*i).parent_block = self.entry_block; + ir_gen.context.get_mut_instruction(*i).parent_block = self.entry_block; } } - let function_block = &mut igen.context[self.entry_block]; + let function_block = &mut ir_gen.context[self.entry_block]; function_block.instructions.clear(); function_block.instructions = stack; function_block.left = None; to_remove.extend(function_cfg.iter()); //let's remove all the other blocks } else { - decision.reduce(&mut igen.context, decision.root)?; + decision.reduce(&mut ir_gen.context, decision.root)?; } //merge blocks - to_remove = block::merge_path(&mut igen.context, self.entry_block, BlockId::dummy(), None)?; + to_remove = + block::merge_path(&mut ir_gen.context, self.entry_block, BlockId::dummy(), None)?; - igen.context[self.entry_block].dominated.retain(|b| !to_remove.contains(b)); + ir_gen.context[self.entry_block].dominated.retain(|b| !to_remove.contains(b)); for i in to_remove { if i != self.entry_block { - igen.context.remove_block(i); + ir_gen.context.remove_block(i); } } Ok(decision) diff --git a/crates/noirc_evaluator/src/ssa/optim.rs b/crates/noirc_evaluator/src/ssa/optim.rs index 227cfb0e715..7c1e4e8a9d5 100644 --- a/crates/noirc_evaluator/src/ssa/optim.rs +++ b/crates/noirc_evaluator/src/ssa/optim.rs @@ -122,28 +122,34 @@ pub fn propagate(ctx: &SsaContext, id: NodeId, modified: &mut bool) -> NodeId { //common subexpression elimination, starting from the root pub fn cse( - igen: &mut SsaContext, + ir_gen: &mut SsaContext, first_block: BlockId, stop_on_error: bool, ) -> Result, RuntimeError> { let mut anchor = Anchor::default(); let mut modified = false; - cse_tree(igen, first_block, &mut anchor, &mut modified, stop_on_error) + cse_tree(ir_gen, first_block, &mut anchor, &mut modified, stop_on_error) } //Perform CSE for the provided block and then process its children following the dominator tree, passing around the anchor list. fn cse_tree( - igen: &mut SsaContext, + ir_gen: &mut SsaContext, block_id: BlockId, anchor: &mut Anchor, modified: &mut bool, stop_on_error: bool, ) -> Result, RuntimeError> { let mut instructions = Vec::new(); - let mut res = - cse_block_with_anchor(igen, block_id, &mut instructions, anchor, modified, stop_on_error)?; - for b in igen[block_id].dominated.clone() { - let sub_res = cse_tree(igen, b, &mut anchor.clone(), modified, stop_on_error)?; + let mut res = cse_block_with_anchor( + ir_gen, + block_id, + &mut instructions, + anchor, + modified, + stop_on_error, + )?; + for b in ir_gen[block_id].dominated.clone() { + let sub_res = cse_tree(ir_gen, b, &mut anchor.clone(), modified, stop_on_error)?; if sub_res.is_some() { res = sub_res; } @@ -153,7 +159,7 @@ fn cse_tree( //perform common subexpression elimination until there is no more change pub fn full_cse( - igen: &mut SsaContext, + ir_gen: &mut SsaContext, first_block: BlockId, report_error: bool, ) -> Result, RuntimeError> { @@ -162,7 +168,7 @@ pub fn full_cse( while modified { modified = false; let mut anchor = Anchor::default(); - result = cse_tree(igen, first_block, &mut anchor, &mut modified, report_error)?; + result = cse_tree(ir_gen, first_block, &mut anchor, &mut modified, report_error)?; } Ok(result) } diff --git a/cspell.json b/cspell.json index 13e86638215..6d7b4debb39 100644 --- a/cspell.json +++ b/cspell.json @@ -33,7 +33,6 @@ "sdiv", "urem", "srem", - "igen", "Barretenberg", "uninstantiated", "libomp", From ca49b3de486b023a52d514d28a870e1688bd37d4 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 14:34:30 +0000 Subject: [PATCH 102/115] cleanup dictionary --- cspell.json | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/cspell.json b/cspell.json index 6d7b4debb39..7fb4f8ff6ea 100644 --- a/cspell.json +++ b/cspell.json @@ -33,14 +33,9 @@ "sdiv", "urem", "srem", - "Barretenberg", + "barretenberg", "uninstantiated", - "libomp", "clippy", - "rustfmt", - "pkgs", - "openmp", - "nixpkgs", "rustup", "chumsky", "idents", @@ -59,10 +54,10 @@ "wedderburn", "termcolor", "arity", - "Hasher", + "hasher", "injective", "thiserror", - "Deque", + "deque", "pedersen", "schnorr", "merkle", @@ -72,7 +67,7 @@ "smol", "krate", "typevars", - "Foralls", + "foralls", "impls", "typevar", "arity", @@ -83,6 +78,7 @@ "struct", "stdlib", "noirup", + "formatcp", "monomorphization", "monomorphized", "monomorphize", From c815cb959b278b69a5e945a30af2512678972689 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 15:17:22 +0000 Subject: [PATCH 103/115] reformat dict list --- cspell.json | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/cspell.json b/cspell.json index 7fb4f8ff6ea..96d03f7493b 100644 --- a/cspell.json +++ b/cspell.json @@ -3,30 +3,22 @@ "words": [ // TODO: Perhaps we should use the term `make_conditional` // instead of conditionalize. This can be done in a separate PR - "conditionalise", "conditionalize", "conditionalized", - // Refers to parameters for a specific elliptic curve - "secp256k1", "aeiou", - // - "acvm", - "acir", - "nargo", - "tempdir", - "noirc", // This is a computer science idiom. Its a data structure that stores only // one distinct copy of an value. Google `String Interner` for a concrete example "interner", "blackbox", "canonicalize", "codegen", + // TODO: Issue -- add documentation "lvalue", "vecmap", "forall", "signedness", // TODO: we should just name this more descriptively - // TODO: ie is it optimizations or optimizer? + // TODO: it is optimizations "optim", "coeff", "udiv", @@ -35,24 +27,13 @@ "srem", "barretenberg", "uninstantiated", - "clippy", - "rustup", - "chumsky", "idents", - // TODO: ask Jake if we can expand on "l" - "foldl", "comptime", "desugared", "elems", - "bindgen", - "gloo", "plonkc", - "tempfile", - "rustc", - "arkworks", "kevaundray", "wedderburn", - "termcolor", "arity", "hasher", "injective", @@ -64,7 +45,6 @@ "arithmetization", "bitand", "subexpression", - "smol", "krate", "typevars", "foralls", @@ -75,13 +55,33 @@ "milner", "peekable", "hexdigit", - "struct", - "stdlib", "noirup", "formatcp", + // In code + "struct", + "stdlib", "monomorphization", "monomorphized", "monomorphize", - "monomorphizer" + "monomorphizer", + // Dependencies + "smol", + "clippy", + "rustup", + "chumsky", + "bindgen", + "gloo", + "termcolor", + "tempfile", + "rustc", + "arkworks", + "acvm", + "acir", + "nargo", + "tempdir", + "noirc", + // Refers to parameters for a specific elliptic curve + "secp256k1", + "foldl", ] } \ No newline at end of file From 720ccf9b5a185aeece040b083e9658227c122217 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 15:47:01 +0000 Subject: [PATCH 104/115] clarify comment on comptime --- crates/noirc_frontend/src/hir_def/types.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/noirc_frontend/src/hir_def/types.rs b/crates/noirc_frontend/src/hir_def/types.rs index 5aa90eb5766..2b07581be9b 100644 --- a/crates/noirc_frontend/src/hir_def/types.rs +++ b/crates/noirc_frontend/src/hir_def/types.rs @@ -577,8 +577,8 @@ impl std::fmt::Display for CompTime { } impl Type { - /// Mutate the span for CompTime to track where comptime is required for better - /// error messages that show both the erroring call site and the call site before + /// Mutate the span for the `CompTime` enum to track where a type is required to be `comptime` + /// for error messages that show both the erroring call site and the call site before /// which required the variable to be comptime or non-comptime. pub fn set_comp_time_span(&mut self, new_span: Span) { match self { From 87cc8ecac1820c84f6d03599d5f08cde4351aa79 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 18:02:17 +0000 Subject: [PATCH 105/115] elems -> elements --- crates/noirc_frontend/src/hir/resolution/resolver.rs | 4 ++-- crates/noirc_frontend/src/hir/type_check/expr.rs | 2 +- crates/noirc_frontend/src/hir_def/types.rs | 12 ++++++------ crates/noirc_frontend/src/monomorphization/ast.rs | 8 ++++---- crates/noirc_frontend/src/parser/parser.rs | 8 ++++---- cspell.json | 4 +--- 6 files changed, 18 insertions(+), 20 deletions(-) diff --git a/crates/noirc_frontend/src/hir/resolution/resolver.rs b/crates/noirc_frontend/src/hir/resolution/resolver.rs index 91feb20ea51..5b6e592907f 100644 --- a/crates/noirc_frontend/src/hir/resolution/resolver.rs +++ b/crates/noirc_frontend/src/hir/resolution/resolver.rs @@ -613,8 +613,8 @@ impl<'a> Resolver<'a> { let hir_expr = match expr.kind { ExpressionKind::Literal(literal) => HirExpression::Literal(match literal { Literal::Bool(b) => HirLiteral::Bool(b), - Literal::Array(ArrayLiteral::Standard(elems)) => { - HirLiteral::Array(vecmap(elems, |elem| self.resolve_expression(elem))) + Literal::Array(ArrayLiteral::Standard(elements)) => { + HirLiteral::Array(vecmap(elements, |elem| self.resolve_expression(elem))) } Literal::Array(ArrayLiteral::Repeated { repeated_element, length }) => { let len = self.eval_array_length(&length); diff --git a/crates/noirc_frontend/src/hir/type_check/expr.rs b/crates/noirc_frontend/src/hir/type_check/expr.rs index bb8521a4a19..ad0b4a3710a 100644 --- a/crates/noirc_frontend/src/hir/type_check/expr.rs +++ b/crates/noirc_frontend/src/hir/type_check/expr.rs @@ -258,7 +258,7 @@ fn type_check_index_expression( let span = interner.expr_span(&index_expr.index); index_type.unify(&Type::comp_time(Some(span)), span, errors, || { - // Specialize the error in the case the user has a Field, just not a comptime one. + // Specialize the error in the case the user has a Field, just not a `comptime` one. if matches!(index_type, Type::FieldElement(..)) { TypeCheckError::Unstructured { msg: format!("Array index must be known at compile-time, but here a non-comptime {index_type} was used instead"), diff --git a/crates/noirc_frontend/src/hir_def/types.rs b/crates/noirc_frontend/src/hir_def/types.rs index 2b07581be9b..b99cb917df4 100644 --- a/crates/noirc_frontend/src/hir_def/types.rs +++ b/crates/noirc_frontend/src/hir_def/types.rs @@ -799,11 +799,11 @@ impl Type { elem_a.try_unify(elem_b, span) } - (Tuple(elems_a), Tuple(elems_b)) => { - if elems_a.len() != elems_b.len() { + (Tuple(elements_a), Tuple(elements_b)) => { + if elements_a.len() != elements_b.len() { Err(SpanKind::None) } else { - for (a, b) in elems_a.iter().zip(elems_b) { + for (a, b) in elements_a.iter().zip(elements_b) { a.try_unify(b, span)?; } Ok(()) @@ -930,11 +930,11 @@ impl Type { elem_a.is_subtype_of(elem_b, span) } - (Tuple(elems_a), Tuple(elems_b)) => { - if elems_a.len() != elems_b.len() { + (Tuple(elements_a), Tuple(elements_b)) => { + if elements_a.len() != elements_b.len() { Err(SpanKind::None) } else { - for (a, b) in elems_a.iter().zip(elems_b) { + for (a, b) in elements_a.iter().zip(elements_b) { a.is_subtype_of(b, span)?; } Ok(()) diff --git a/crates/noirc_frontend/src/monomorphization/ast.rs b/crates/noirc_frontend/src/monomorphization/ast.rs index 7fb3e772bb5..bcd6c744ff5 100644 --- a/crates/noirc_frontend/src/monomorphization/ast.rs +++ b/crates/noirc_frontend/src/monomorphization/ast.rs @@ -253,7 +253,7 @@ impl std::fmt::Display for Type { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Type::Field => write!(f, "Field"), - Type::Array(len, elems) => write!(f, "[{elems}; {len}]"), + Type::Array(len, elements) => write!(f, "[{elements}; {len}]"), Type::Integer(sign, bits) => match sign { Signedness::Unsigned => write!(f, "u{bits}"), Signedness::Signed => write!(f, "i{bits}"), @@ -261,9 +261,9 @@ impl std::fmt::Display for Type { Type::Bool => write!(f, "bool"), Type::String(len) => write!(f, "str[{len}]"), Type::Unit => write!(f, "()"), - Type::Tuple(elems) => { - let elems = vecmap(elems, ToString::to_string); - write!(f, "({})", elems.join(", ")) + Type::Tuple(elements) => { + let elements = vecmap(elements, ToString::to_string); + write!(f, "({})", elements.join(", ")) } Type::Function(args, ret) => { let args = vecmap(args, ToString::to_string); diff --git a/crates/noirc_frontend/src/parser/parser.rs b/crates/noirc_frontend/src/parser/parser.rs index 8e66015a1be..686220c523c 100644 --- a/crates/noirc_frontend/src/parser/parser.rs +++ b/crates/noirc_frontend/src/parser/parser.rs @@ -763,14 +763,14 @@ where { expression_list(expr_parser) .delimited_by(just(Token::LeftBracket), just(Token::RightBracket)) - .validate(|elems, span, emit| { - if elems.is_empty() { + .validate(|elements, span, emit| { + if elements.is_empty() { emit(ParserError::with_reason( "Arrays must have at least one element".to_owned(), span, )) } - ExpressionKind::array(elems) + ExpressionKind::array(elements) }) } @@ -1046,7 +1046,7 @@ mod test { for expr in parse_all(array_expr(expression()), valid) { match expr_to_array(expr) { - ArrayLiteral::Standard(elems) => assert_eq!(elems.len(), 5), + ArrayLiteral::Standard(elements) => assert_eq!(elements.len(), 5), ArrayLiteral::Repeated { length, .. } => { assert_eq!(length.kind, ExpressionKind::integer(5i128.into())) } diff --git a/cspell.json b/cspell.json index 96d03f7493b..9cd664bfc0c 100644 --- a/cspell.json +++ b/cspell.json @@ -12,7 +12,6 @@ "blackbox", "canonicalize", "codegen", - // TODO: Issue -- add documentation "lvalue", "vecmap", "forall", @@ -30,7 +29,6 @@ "idents", "comptime", "desugared", - "elems", "plonkc", "kevaundray", "wedderburn", @@ -82,6 +80,6 @@ "noirc", // Refers to parameters for a specific elliptic curve "secp256k1", - "foldl", + "foldl" ] } \ No newline at end of file From 5dbda5850739d66c22969cd29b036b7b1c460100 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 18:02:46 +0000 Subject: [PATCH 106/115] change authors --- crates/nargo/src/cli/mod.rs | 2 +- cspell.json | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/crates/nargo/src/cli/mod.rs b/crates/nargo/src/cli/mod.rs index bcbca94b4f5..02bc8fc7d0e 100644 --- a/crates/nargo/src/cli/mod.rs +++ b/crates/nargo/src/cli/mod.rs @@ -43,7 +43,7 @@ pub fn start_cli() { let matches = App::new("nargo") .about("Noir's package manager") .version(VERSION_STRING) - .author("Kevaundray Wedderburn ") + .author("The Noir Team ") .subcommand( App::new("check") .about("Checks the constraint system for errors") diff --git a/cspell.json b/cspell.json index 9cd664bfc0c..a4450aa9945 100644 --- a/cspell.json +++ b/cspell.json @@ -30,8 +30,6 @@ "comptime", "desugared", "plonkc", - "kevaundray", - "wedderburn", "arity", "hasher", "injective", From 01735f475f8aaa9f6cfaa0271269f7785092c84d Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 18:05:19 +0000 Subject: [PATCH 107/115] change author in Cargo.toml --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 81a6361b7b4..6abd49313a1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ default-members = ["crates/nargo"] [workspace.package] version = "0.1.0" -authors = ["Kevaundray Wedderburn "] +authors = ["The Noir Team "] edition = "2021" rust-version = "1.64" From b23794e5fa5a8ffeb6b671191e2d0258a4210bda Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 18:09:19 +0000 Subject: [PATCH 108/115] conditionalize -> "apply condition" --- crates/noirc_evaluator/src/ssa/inline.rs | 4 ++-- cspell.json | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/inline.rs b/crates/noirc_evaluator/src/ssa/inline.rs index 31f0f5398a8..6811585bf34 100644 --- a/crates/noirc_evaluator/src/ssa/inline.rs +++ b/crates/noirc_evaluator/src/ssa/inline.rs @@ -378,7 +378,7 @@ pub fn inline_in_block( } } - // we conditionalize the stack frame into a new stack frame (to avoid ownership issues) + // we apply the `condition` to stack frame and place it into a new stack frame (to avoid ownership issues) let mut stack2 = StackFrame::new(stack_frame.block); stack2.return_arrays = stack_frame.return_arrays.clone(); if short_circuit { @@ -390,7 +390,7 @@ pub fn inline_in_block( &mut stack2, predicate, )?; - // we add the conditionalized instructions to the target_block, at proper location (really need a linked list!) + // we add the instructions which we have applied the conditions to, to the target_block, at proper location (really need a linked list!) stack2.apply(ctx, stack_frame.block, call_id, false); } diff --git a/cspell.json b/cspell.json index a4450aa9945..b43d98c3ae6 100644 --- a/cspell.json +++ b/cspell.json @@ -1,10 +1,6 @@ { "version": "0.2", "words": [ - // TODO: Perhaps we should use the term `make_conditional` - // instead of conditionalize. This can be done in a separate PR - "conditionalize", - "conditionalized", "aeiou", // This is a computer science idiom. Its a data structure that stores only // one distinct copy of an value. Google `String Interner` for a concrete example From e3f7857a653eb0172232c9af639b8e84e7d5e746 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 18:12:30 +0000 Subject: [PATCH 109/115] optim -> optimizations --- crates/noirc_evaluator/src/ssa/block.rs | 2 +- crates/noirc_evaluator/src/ssa/conditional.rs | 10 +++++----- crates/noirc_evaluator/src/ssa/context.rs | 10 +++++----- crates/noirc_evaluator/src/ssa/flatten.rs | 10 +++++----- crates/noirc_evaluator/src/ssa/function.rs | 4 ++-- crates/noirc_evaluator/src/ssa/inline.rs | 6 +++--- crates/noirc_evaluator/src/ssa/integer.rs | 8 ++++---- crates/noirc_evaluator/src/ssa/mod.rs | 2 +- .../src/ssa/{optim.rs => optimizations.rs} | 0 cspell.json | 3 --- 10 files changed, 26 insertions(+), 29 deletions(-) rename crates/noirc_evaluator/src/ssa/{optim.rs => optimizations.rs} (100%) diff --git a/crates/noirc_evaluator/src/ssa/block.rs b/crates/noirc_evaluator/src/ssa/block.rs index 4e60159c8fc..384ee386755 100644 --- a/crates/noirc_evaluator/src/ssa/block.rs +++ b/crates/noirc_evaluator/src/ssa/block.rs @@ -552,7 +552,7 @@ pub fn merge_path( //we assign the concatenated list of instructions to the start block, using a CSE pass let mut modified = false; - super::optim::cse_block(ctx, start, &mut instructions, &mut modified)?; + super::optimizations::cse_block(ctx, start, &mut instructions, &mut modified)?; //Wires start to end if !end.is_dummy() { rewire_block_left(ctx, start, end); diff --git a/crates/noirc_evaluator/src/ssa/conditional.rs b/crates/noirc_evaluator/src/ssa/conditional.rs index 87283416c0a..08aa26996c8 100644 --- a/crates/noirc_evaluator/src/ssa/conditional.rs +++ b/crates/noirc_evaluator/src/ssa/conditional.rs @@ -5,7 +5,7 @@ use crate::{ errors::{self, RuntimeError}, ssa::{ node::{Mark, ObjectType}, - optim, + optimizations, }, }; @@ -123,7 +123,7 @@ impl DecisionTree { ) -> Instruction { let operation = Operation::binary(operator, lhs, rhs); let mut i = Instruction::new(operation, typ, Some(block_id)); - super::optim::simplify(ctx, &mut i).unwrap(); + super::optimizations::simplify(ctx, &mut i).unwrap(); i } @@ -381,7 +381,7 @@ impl DecisionTree { merged_ins = self.synchronize(ctx, &left_ins, &right_ins, left); } let mut modified = false; - super::optim::cse_block(ctx, left, &mut merged_ins, &mut modified)?; + super::optimizations::cse_block(ctx, left, &mut merged_ins, &mut modified)?; //housekeeping... let if_block = &mut ctx[if_block_id]; @@ -548,7 +548,7 @@ impl DecisionTree { val_true: block_args[0].0, val_false: block_args[1].0, }; - optim::simplify_id(ctx, ins_id).unwrap(); + optimizations::simplify_id(ctx, ins_id).unwrap(); } stack.push(ins_id); } @@ -585,7 +585,7 @@ impl DecisionTree { ObjectType::Boolean, Some(stack.block), )); - optim::simplify_id(ctx, cond).unwrap(); + optimizations::simplify_id(ctx, cond).unwrap(); stack.push(cond); } } diff --git a/crates/noirc_evaluator/src/ssa/context.rs b/crates/noirc_evaluator/src/ssa/context.rs index 9d2343c37a2..55be0a578a8 100644 --- a/crates/noirc_evaluator/src/ssa/context.rs +++ b/crates/noirc_evaluator/src/ssa/context.rs @@ -4,7 +4,7 @@ use super::function::{FuncIndex, SSAFunction}; use super::inline::StackFrame; use super::mem::{ArrayId, Memory}; use super::node::{BinaryOp, FunctionKind, Instruction, NodeId, NodeObject, ObjectType, Operation}; -use super::{block, builtin, flatten, inline, integer, node, optim}; +use super::{block, builtin, flatten, inline, integer, node, optimizations}; use std::collections::{HashMap, HashSet}; use super::super::errors::RuntimeError; @@ -564,7 +564,7 @@ impl SsaContext { //Basic simplification - we ignore RunTimeErrors when creating an instruction //because they must be managed after handling conditionals. For instance if false { b } should not fail whatever b is doing. - optim::simplify(self, &mut i).ok(); + optimizations::simplify(self, &mut i).ok(); if let Mark::ReplaceWith(replacement) = i.mark { return Ok(replacement); @@ -701,7 +701,7 @@ impl SsaContext { //Optimization block::compute_dom(self); - optim::full_cse(self, self.first_block, false)?; + optimizations::full_cse(self, self.first_block, false)?; //flattening self.log(enable_logging, "\nCSE:", "\nunrolling:"); @@ -731,7 +731,7 @@ impl SsaContext { let first_block = self.first_block; self[first_block].dominated.clear(); - optim::cse(self, first_block, true)?; + optimizations::cse(self, first_block, true)?; //Truncation integer::overflow_strategy(self)?; @@ -1164,7 +1164,7 @@ impl SsaContext { ObjectType::Boolean, Some(stack.block), )); - optim::simplify_id(self, cond).unwrap(); + optimizations::simplify_id(self, cond).unwrap(); stack.push(cond); cond } diff --git a/crates/noirc_evaluator/src/ssa/flatten.rs b/crates/noirc_evaluator/src/ssa/flatten.rs index 810a92fb63e..da073d43748 100644 --- a/crates/noirc_evaluator/src/ssa/flatten.rs +++ b/crates/noirc_evaluator/src/ssa/flatten.rs @@ -4,7 +4,7 @@ use super::{ block::{self, BlockId}, context::SsaContext, node::{self, BinaryOp, Mark, Node, NodeEval, NodeId, NodeObject, Operation}, - optim, + optimizations, }; use acvm::FieldElement; use std::collections::HashMap; @@ -43,7 +43,7 @@ fn eval_block(block_id: BlockId, eval_map: &HashMap, ctx: &mut let ins_id = ins.id; // We ignore RunTimeErrors at this stage because unrolling is done before conditionals // While failures must be managed after handling conditionals: For instance if false { b } should not fail whatever b is doing. - optim::simplify_id(ctx, ins_id).ok(); + optimizations::simplify_id(ctx, ins_id).ok(); } } } @@ -127,7 +127,7 @@ pub fn unroll_std_block( Operation::Jmp(block) => assert_eq!(block, next), Operation::Nop => (), _ => { - optim::simplify(ctx, &mut new_ins).ok(); //ignore RuntimeErrors until conditionals are processed + optimizations::simplify(ctx, &mut new_ins).ok(); //ignore RuntimeErrors until conditionals are processed match new_ins.mark { Mark::None => { let id = ctx.push_instruction(new_ins); @@ -136,7 +136,7 @@ pub fn unroll_std_block( Mark::Deleted => (), Mark::ReplaceWith(replacement) => { // TODO: Should we insert into unrolled_instructions as well? - // If optim::simplify replaces with a constant then we should not, + // If optimizations::simplify replaces with a constant then we should not, // otherwise it may make sense if it is not already inserted. unroll_ctx .eval_map @@ -313,7 +313,7 @@ fn evaluate_one( match &ctx[obj_id] { NodeObject::Instr(i) => { - let new_id = optim::propagate(ctx, obj_id, &mut modified); + let new_id = optimizations::propagate(ctx, obj_id, &mut modified); if new_id != obj_id { return evaluate_one(NodeEval::VarOrInstruction(new_id), value_array, ctx); } diff --git a/crates/noirc_evaluator/src/ssa/function.rs b/crates/noirc_evaluator/src/ssa/function.rs index 79e3f123e40..0919cd93178 100644 --- a/crates/noirc_evaluator/src/ssa/function.rs +++ b/crates/noirc_evaluator/src/ssa/function.rs @@ -66,7 +66,7 @@ impl SSAFunction { block::compute_sub_dom(&mut ir_gen.context, &function_cfg); //Optimization //catch the error because the function may not be called - super::optim::full_cse(&mut ir_gen.context, self.entry_block, false)?; + super::optimizations::full_cse(&mut ir_gen.context, self.entry_block, false)?; //Unrolling super::flatten::unroll_tree(&mut ir_gen.context, self.entry_block)?; @@ -403,7 +403,7 @@ pub fn inline_all(ctx: &mut SsaContext) -> Result<(), RuntimeError> { while processed.len() < l { let i = get_new_leaf(ctx, &processed); if !processed.is_empty() { - super::optim::full_cse(ctx, ctx.functions[&i.1].entry_block, false)?; + super::optimizations::full_cse(ctx, ctx.functions[&i.1].entry_block, false)?; } let mut to_inline = Vec::new(); for f in ctx.functions.values() { diff --git a/crates/noirc_evaluator/src/ssa/inline.rs b/crates/noirc_evaluator/src/ssa/inline.rs index 6811585bf34..e85f77e2633 100644 --- a/crates/noirc_evaluator/src/ssa/inline.rs +++ b/crates/noirc_evaluator/src/ssa/inline.rs @@ -6,7 +6,7 @@ use crate::{ errors::RuntimeError, ssa::{ node::{Node, Operation}, - optim, + optimizations, }, }; @@ -95,7 +95,7 @@ fn inline_block( } if to_inline.is_none() { - optim::simple_cse(ctx, block_id)?; + optimizations::simple_cse(ctx, block_id)?; } Ok(result) } @@ -343,7 +343,7 @@ pub fn inline_in_block( new_ins.res_type = node::ObjectType::Pointer(new_id); } - let err = optim::simplify(ctx, &mut new_ins); + let err = optimizations::simplify(ctx, &mut new_ins); if err.is_err() { //add predicate if under condition, else short-circuit the target block. let ass_value = decision.get_assumption_value(predicate); diff --git a/crates/noirc_evaluator/src/ssa/integer.rs b/crates/noirc_evaluator/src/ssa/integer.rs index 4525be04d69..0d10c525d2d 100644 --- a/crates/noirc_evaluator/src/ssa/integer.rs +++ b/crates/noirc_evaluator/src/ssa/integer.rs @@ -6,7 +6,7 @@ use super::{ context::SsaContext, mem::{ArrayId, Memory}, node::{self, BinaryOp, Instruction, Mark, Node, NodeId, NodeObject, ObjectType, Operation}, - optim, + optimizations, }; use acvm::FieldElement; use iter_extended::vecmap; @@ -256,7 +256,7 @@ fn block_overflow( } ins.operation.map_id_mut(|id| { - let id = optim::propagate(ctx, id, &mut modified); + let id = optimizations::propagate(ctx, id, &mut modified); get_value_from_map(id, &value_map) }); @@ -389,7 +389,7 @@ fn block_overflow( //for now we pass the max value to the instruction, we could also keep the max_map e.g in the block (or max in each node object) //sub operations require the max value to ensure it does not underflow *max_rhs_value = max_map[rhs].clone(); - //we may do that in future when the max_map becomes more used elsewhere (for other optim) + //we may do that in future when the max_map becomes more used elsewhere (for other optimizations) } let old_ins = ctx.try_get_mut_instruction(ins.id).unwrap(); @@ -400,7 +400,7 @@ fn block_overflow( //We run another round of CSE for the block in order to remove possible duplicated truncates, this will assign 'new_list' to the block instructions let mut modified = false; - optim::cse_block(ctx, block_id, &mut new_list, &mut modified)?; + optimizations::cse_block(ctx, block_id, &mut new_list, &mut modified)?; Ok(()) } diff --git a/crates/noirc_evaluator/src/ssa/mod.rs b/crates/noirc_evaluator/src/ssa/mod.rs index 8c464fe9a6d..2512890fc1a 100644 --- a/crates/noirc_evaluator/src/ssa/mod.rs +++ b/crates/noirc_evaluator/src/ssa/mod.rs @@ -11,5 +11,5 @@ pub mod inline; pub mod integer; pub mod mem; pub mod node; -pub mod optim; +pub mod optimizations; pub mod ssa_form; diff --git a/crates/noirc_evaluator/src/ssa/optim.rs b/crates/noirc_evaluator/src/ssa/optimizations.rs similarity index 100% rename from crates/noirc_evaluator/src/ssa/optim.rs rename to crates/noirc_evaluator/src/ssa/optimizations.rs diff --git a/cspell.json b/cspell.json index b43d98c3ae6..4372294d8dc 100644 --- a/cspell.json +++ b/cspell.json @@ -12,9 +12,6 @@ "vecmap", "forall", "signedness", - // TODO: we should just name this more descriptively - // TODO: it is optimizations - "optim", "coeff", "udiv", "sdiv", From c9b3af5e2f99e415fc5c5f0571e8cd3a3f974e1e Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 18:14:25 +0000 Subject: [PATCH 110/115] add "higher-kinded" --- cspell.json | 1 + 1 file changed, 1 insertion(+) diff --git a/cspell.json b/cspell.json index 4372294d8dc..633effacb4c 100644 --- a/cspell.json +++ b/cspell.json @@ -53,6 +53,7 @@ "monomorphized", "monomorphize", "monomorphizer", + "higher-kinded", // Dependencies "smol", "clippy", From c49bcecd1aa7b468467f9428d73af768e01da0cf Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 18:22:37 +0000 Subject: [PATCH 111/115] separate words from dependencies and in code --- cspell.json | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/cspell.json b/cspell.json index 633effacb4c..bf0dd365676 100644 --- a/cspell.json +++ b/cspell.json @@ -1,12 +1,18 @@ { "version": "0.2", "words": [ - "aeiou", + // In code + "arity", + "uninstantiated", + "injective", + "desugared", + "idents", + "comptime", + "blackbox", // This is a computer science idiom. Its a data structure that stores only // one distinct copy of an value. Google `String Interner` for a concrete example "interner", - "blackbox", - "canonicalize", + "aeiou", "codegen", "lvalue", "vecmap", @@ -17,36 +23,19 @@ "sdiv", "urem", "srem", - "barretenberg", - "uninstantiated", - "idents", - "comptime", - "desugared", - "plonkc", - "arity", - "hasher", - "injective", - "thiserror", - "deque", "pedersen", "schnorr", "merkle", "arithmetization", - "bitand", + "barretenberg", "subexpression", "krate", "typevars", "foralls", "impls", "typevar", - "arity", - "hindley", - "milner", "peekable", - "hexdigit", - "noirup", - "formatcp", - // In code + "Hindley-Milner", "struct", "stdlib", "monomorphization", @@ -55,6 +44,15 @@ "monomorphizer", "higher-kinded", // Dependencies + "hasher", + "canonicalize", + "plonkc", + "hexdigit", + "bitand", + "noirup", + "formatcp", + "thiserror", + "deque", "smol", "clippy", "rustup", From 7f43202426b72bc4da0706a61d1b2dad576d7186 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 18:31:24 +0000 Subject: [PATCH 112/115] re-order alphabetically --- cspell.json | 100 ++++++++++++++++++++++++++-------------------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/cspell.json b/cspell.json index bf0dd365676..8c09501e96a 100644 --- a/cspell.json +++ b/cspell.json @@ -2,74 +2,74 @@ "version": "0.2", "words": [ // In code + "aeiou", + "arithmetization", "arity", - "uninstantiated", - "injective", + "barretenberg", + "blackbox", + "codegen", + "coeff", + "comptime", "desugared", + "forall", + "foralls", + "higher-kinded", + "Hindley-Milner", "idents", - "comptime", - "blackbox", + "impls", + "injective", // This is a computer science idiom. Its a data structure that stores only // one distinct copy of an value. Google `String Interner` for a concrete example "interner", - "aeiou", - "codegen", + "krate", "lvalue", - "vecmap", - "forall", - "signedness", - "coeff", - "udiv", - "sdiv", - "urem", - "srem", - "pedersen", - "schnorr", "merkle", - "arithmetization", - "barretenberg", - "subexpression", - "krate", - "typevars", - "foralls", - "impls", - "typevar", - "peekable", - "Hindley-Milner", - "struct", - "stdlib", "monomorphization", - "monomorphized", "monomorphize", + "monomorphized", "monomorphizer", - "higher-kinded", + "pedersen", + "peekable", + "schnorr", + "sdiv", + "signedness", + "srem", + "stdlib", + "struct", + "subexpression", + "typevar", + "typevars", + "udiv", + "uninstantiated", + "urem", + "vecmap", // Dependencies - "hasher", - "canonicalize", - "plonkc", - "hexdigit", + "acir", + "acvm", + "arkworks", + "bindgen", "bitand", - "noirup", - "formatcp", - "thiserror", - "deque", - "smol", - "clippy", - "rustup", + "canonicalize", "chumsky", - "bindgen", + "clippy", + "deque", + "foldl", + "formatcp", "gloo", - "termcolor", - "tempfile", - "rustc", - "arkworks", - "acvm", - "acir", + "hasher", + "hexdigit", "nargo", - "tempdir", "noirc", + "noirup", + "plonkc", + "rustc", + "rustup", // Refers to parameters for a specific elliptic curve "secp256k1", - "foldl" + "smol", + "tempdir", + "tempfile", + "termcolor", + "thiserror" ] } \ No newline at end of file From 9b9e8979bb017ebe9721885541541a11cc72dc27 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 18:32:15 +0000 Subject: [PATCH 113/115] remove comments in Cspell Can add comments to code itself --- cspell.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cspell.json b/cspell.json index 8c09501e96a..3fe9b47540f 100644 --- a/cspell.json +++ b/cspell.json @@ -2,6 +2,7 @@ "version": "0.2", "words": [ // In code + // "aeiou", "arithmetization", "arity", @@ -18,8 +19,6 @@ "idents", "impls", "injective", - // This is a computer science idiom. Its a data structure that stores only - // one distinct copy of an value. Google `String Interner` for a concrete example "interner", "krate", "lvalue", @@ -44,6 +43,7 @@ "urem", "vecmap", // Dependencies + // "acir", "acvm", "arkworks", @@ -64,7 +64,6 @@ "plonkc", "rustc", "rustup", - // Refers to parameters for a specific elliptic curve "secp256k1", "smol", "tempdir", From fc2b5e94ffd05a2d407b2e30a0679f08bcc5af38 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 18:36:48 +0000 Subject: [PATCH 114/115] - Do not fail CI if spelling mistake is found - Only run action on files which have changed --- .github/workflows/rust.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index e2ac75b11a3..63665b399c9 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -104,4 +104,5 @@ jobs: with: files: | **/*.{md,rs} - incremental_files_only : false + incremental_files_only : true # Run this action on files which have changed in PR + strict: false # Do not fail, if a spelling mistake is found (This can be annoying for contributors) From 57e77cc7473470ea3e6c636a066d5d50da3632c2 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Fri, 3 Feb 2023 18:46:27 +0000 Subject: [PATCH 115/115] fix typo: conf_data -> config_data --- crates/nargo/tests/prove_and_verify.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/nargo/tests/prove_and_verify.rs b/crates/nargo/tests/prove_and_verify.rs index f583b2cb27d..e62ca2a5186 100644 --- a/crates/nargo/tests/prove_and_verify.rs +++ b/crates/nargo/tests/prove_and_verify.rs @@ -43,7 +43,7 @@ mod tests { for c in fs::read_dir(current_dir.as_path()).unwrap().flatten() { if let Ok(test_name) = c.file_name().into_string() { println!("Running test {test_name:?}"); - if c.path().is_dir() && !conf_data["exclude"].contains(&test_name) { + if c.path().is_dir() && !config_data["exclude"].contains(&test_name) { let verified = std::panic::catch_unwind(|| { nargo::cli::prove_and_verify("pp", &c.path(), false) });