Skip to content

Commit

Permalink
Add/remove pub
Browse files Browse the repository at this point in the history
  • Loading branch information
asterite committed Oct 2, 2024
1 parent 6eeee56 commit 29ffae4
Show file tree
Hide file tree
Showing 14 changed files with 107 additions and 107 deletions.
12 changes: 6 additions & 6 deletions noir_stdlib/src/bigint.nr
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ pub struct BigInt {

impl BigInt {
#[builtin(bigint_add)]
pub fn bigint_add(self, other: BigInt) -> BigInt {}
fn bigint_add(self, other: BigInt) -> BigInt {}
#[builtin(bigint_sub)]
pub fn bigint_sub(self, other: BigInt) -> BigInt {}
fn bigint_sub(self, other: BigInt) -> BigInt {}
#[builtin(bigint_mul)]
pub fn bigint_mul(self, other: BigInt) -> BigInt {}
fn bigint_mul(self, other: BigInt) -> BigInt {}
#[builtin(bigint_div)]
pub fn bigint_div(self, other: BigInt) -> BigInt {}
fn bigint_div(self, other: BigInt) -> BigInt {}
#[builtin(bigint_from_le_bytes)]
pub fn from_le_bytes(bytes: [u8], modulus: [u8]) -> BigInt {}
fn from_le_bytes(bytes: [u8], modulus: [u8]) -> BigInt {}
#[builtin(bigint_to_le_bytes)]
pub fn to_le_bytes(self) -> [u8; 32] {}
fn to_le_bytes(self) -> [u8; 32] {}

fn check_32_bytes(self: Self, other: BigInt) -> bool {
let bytes = self.to_le_bytes();
Expand Down
4 changes: 2 additions & 2 deletions noir_stdlib/src/embedded_curve_ops.nr
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ pub struct EmbeddedCurvePoint {
impl EmbeddedCurvePoint {
/// Elliptic curve point doubling operation
/// returns the doubled point of a point P, i.e P+P
fn double(self) -> EmbeddedCurvePoint {
pub fn double(self) -> EmbeddedCurvePoint {
embedded_curve_add(self, self)
}

/// Returns the null element of the curve; 'the point at infinity'
fn point_at_infinity() -> EmbeddedCurvePoint {
pub fn point_at_infinity() -> EmbeddedCurvePoint {
EmbeddedCurvePoint { x: 0, y: 0, is_infinite: true }
}
}
Expand Down
8 changes: 4 additions & 4 deletions noir_stdlib/src/meta/ctstring.nr
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ use crate::append::Append;

impl CtString {
// docs:start:new
comptime fn new() -> Self {
pub comptime fn new() -> Self {
// docs:end:new
"".as_ctstring()
}

// Bug: using &mut self as the object results in this method not being found
// docs:start:append_str
comptime fn append_str<let N: u32>(self, s: str<N>) -> Self {
pub comptime fn append_str<let N: u32>(self, s: str<N>) -> Self {
// docs:end:append_str
f"{self}{s}".as_ctstring()
}

// docs:start:append_fmtstr
comptime fn append_fmtstr<let N: u32, T>(self, s: fmtstr<N, T>) -> Self {
pub comptime fn append_fmtstr<let N: u32, T>(self, s: fmtstr<N, T>) -> Self {
// docs:end:append_fmtstr
f"{self}{s}".as_ctstring()
}
Expand All @@ -24,7 +24,7 @@ impl CtString {
/// To get around this, we return a quoted str and the underlying str can
/// be accessed using macro insertion `foo.as_quoted_str!()`.
// docs:start:as_quoted_str
comptime fn as_quoted_str(self) -> Quoted {
pub comptime fn as_quoted_str(self) -> Quoted {
// docs:end:as_quoted_str
quote { $self }
}
Expand Down
64 changes: 32 additions & 32 deletions noir_stdlib/src/meta/expr.nr
Original file line number Diff line number Diff line change
Expand Up @@ -8,180 +8,180 @@ impl Expr {
/// If this expression is an array literal `[elem1, ..., elemN]`, this returns a slice of each element in the array.
#[builtin(expr_as_array)]
// docs:start:as_array
comptime fn as_array(self) -> Option<[Expr]> {}
pub comptime fn as_array(self) -> Option<[Expr]> {}
// docs:end:as_array

/// If this expression is an assert, this returns the assert expression and the optional message.
#[builtin(expr_as_assert)]
// docs:start:as_assert
comptime fn as_assert(self) -> Option<(Expr, Option<Expr>)> {}
pub comptime fn as_assert(self) -> Option<(Expr, Option<Expr>)> {}
// docs:end:as_assert

/// If this expression is an assert_eq, this returns the left-hand-side and right-hand-side
/// expressions, together with the optional message.
#[builtin(expr_as_assert_eq)]
// docs:start:as_assert_eq
comptime fn as_assert_eq(self) -> Option<(Expr, Expr, Option<Expr>)> {}
pub comptime fn as_assert_eq(self) -> Option<(Expr, Expr, Option<Expr>)> {}
// docs:end:as_assert_eq

/// If this expression is an assignment, this returns a tuple with the left hand side
/// and right hand side in order.
#[builtin(expr_as_assign)]
// docs:start:as_assign
comptime fn as_assign(self) -> Option<(Expr, Expr)> {}
pub comptime fn as_assign(self) -> Option<(Expr, Expr)> {}
// docs:end:as_assign

/// If this expression is a binary operator operation `<lhs> <op> <rhs>`,
/// return the left-hand side, operator, and the right-hand side of the operation.
#[builtin(expr_as_binary_op)]
// docs:start:as_binary_op
comptime fn as_binary_op(self) -> Option<(Expr, BinaryOp, Expr)> {}
pub comptime fn as_binary_op(self) -> Option<(Expr, BinaryOp, Expr)> {}
// docs:end:as_binary_op

/// If this expression is a block `{ stmt1; stmt2; ...; stmtN }`, return
/// a slice containing each statement.
#[builtin(expr_as_block)]
// docs:start:as_block
comptime fn as_block(self) -> Option<[Expr]> {}
pub comptime fn as_block(self) -> Option<[Expr]> {}
// docs:end:as_block

/// If this expression is a boolean literal, return that literal.
#[builtin(expr_as_bool)]
// docs:start:as_bool
comptime fn as_bool(self) -> Option<bool> {}
pub comptime fn as_bool(self) -> Option<bool> {}
// docs:end:as_bool

/// If this expression is a cast expression `expr as type`, returns the casted
/// expression and the type to cast to.
// docs:start:as_cast
#[builtin(expr_as_cast)]
comptime fn as_cast(self) -> Option<(Expr, UnresolvedType)> {}
pub comptime fn as_cast(self) -> Option<(Expr, UnresolvedType)> {}
// docs:end:as_cast

/// If this expression is a `comptime { stmt1; stmt2; ...; stmtN }` block,
/// return each statement in the block.
#[builtin(expr_as_comptime)]
// docs:start:as_comptime
comptime fn as_comptime(self) -> Option<[Expr]> {}
pub comptime fn as_comptime(self) -> Option<[Expr]> {}
// docs:end:as_comptime

/// If this expression is a constructor `Type { field1: expr1, ..., fieldN: exprN }`,
/// return the type and the fields.
#[builtin(expr_as_constructor)]
// docs:start:as_constructor
comptime fn as_constructor(self) -> Option<(UnresolvedType, [(Quoted, Expr)])> {}
pub comptime fn as_constructor(self) -> Option<(UnresolvedType, [(Quoted, Expr)])> {}
// docs:end:as_constructor

/// If this expression is a for statement over a single expression, return the identifier,
/// the expression and the for loop body.
#[builtin(expr_as_for)]
// docs:start:as_for
comptime fn as_for(self) -> Option<(Quoted, Expr, Expr)> {}
pub comptime fn as_for(self) -> Option<(Quoted, Expr, Expr)> {}
// docs:end:as_for

/// If this expression is a for statement over a range, return the identifier,
/// the range start, the range end and the for loop body.
#[builtin(expr_as_for_range)]
// docs:start:as_for_range
comptime fn as_for_range(self) -> Option<(Quoted, Expr, Expr, Expr)> {}
pub comptime fn as_for_range(self) -> Option<(Quoted, Expr, Expr, Expr)> {}
// docs:end:as_for_range

/// If this expression is a function call `foo(arg1, ..., argN)`, return
/// the function and a slice of each argument.
#[builtin(expr_as_function_call)]
// docs:start:as_function_call
comptime fn as_function_call(self) -> Option<(Expr, [Expr])> {}
pub comptime fn as_function_call(self) -> Option<(Expr, [Expr])> {}
// docs:end:as_function_call

/// If this expression is an `if condition { then_branch } else { else_branch }`,
/// return the condition, then branch, and else branch. If there is no else branch,
/// `None` is returned for that branch instead.
#[builtin(expr_as_if)]
// docs:start:as_if
comptime fn as_if(self) -> Option<(Expr, Expr, Option<Expr>)> {}
pub comptime fn as_if(self) -> Option<(Expr, Expr, Option<Expr>)> {}
// docs:end:as_if

/// If this expression is an index into an array `array[index]`, return the
/// array and the index.
#[builtin(expr_as_index)]
// docs:start:as_index
comptime fn as_index(self) -> Option<(Expr, Expr)> {}
pub comptime fn as_index(self) -> Option<(Expr, Expr)> {}
// docs:end:as_index

/// If this expression is an integer literal, return the integer as a field
/// as well as whether the integer is negative (true) or not (false).
#[builtin(expr_as_integer)]
// docs:start:as_integer
comptime fn as_integer(self) -> Option<(Field, bool)> {}
pub comptime fn as_integer(self) -> Option<(Field, bool)> {}
// docs:end:as_integer

/// If this expression is a lambda, returns the parameters, return type and body.
#[builtin(expr_as_lambda)]
// docs:start:as_lambda
comptime fn as_lambda(self) -> Option<([(Expr, Option<UnresolvedType>)], Option<UnresolvedType>, Expr)> {}
pub comptime fn as_lambda(self) -> Option<([(Expr, Option<UnresolvedType>)], Option<UnresolvedType>, Expr)> {}
// docs:end:as_lambda

/// If this expression is a let statement, returns the let pattern as an `Expr`,
/// the optional type annotation, and the assigned expression.
#[builtin(expr_as_let)]
// docs:start:as_let
comptime fn as_let(self) -> Option<(Expr, Option<UnresolvedType>, Expr)> {}
pub comptime fn as_let(self) -> Option<(Expr, Option<UnresolvedType>, Expr)> {}
// docs:end:as_let

/// If this expression is a member access `foo.bar`, return the struct/tuple
/// expression and the field. The field will be represented as a quoted value.
#[builtin(expr_as_member_access)]
// docs:start:as_member_access
comptime fn as_member_access(self) -> Option<(Expr, Quoted)> {}
pub comptime fn as_member_access(self) -> Option<(Expr, Quoted)> {}
// docs:end:as_member_access

/// If this expression is a method call `foo.bar::<generic1, ..., genericM>(arg1, ..., argN)`, return
/// the receiver, method name, a slice of each generic argument, and a slice of each argument.
#[builtin(expr_as_method_call)]
// docs:start:as_method_call
comptime fn as_method_call(self) -> Option<(Expr, Quoted, [UnresolvedType], [Expr])> {}
pub comptime fn as_method_call(self) -> Option<(Expr, Quoted, [UnresolvedType], [Expr])> {}
// docs:end:as_method_call

/// If this expression is a repeated element array `[elem; length]`, return
/// the repeated element and the length expressions.
#[builtin(expr_as_repeated_element_array)]
// docs:start:as_repeated_element_array
comptime fn as_repeated_element_array(self) -> Option<(Expr, Expr)> {}
pub comptime fn as_repeated_element_array(self) -> Option<(Expr, Expr)> {}
// docs:end:as_repeated_element_array

/// If this expression is a repeated element slice `[elem; length]`, return
/// the repeated element and the length expressions.
#[builtin(expr_as_repeated_element_slice)]
// docs:start:as_repeated_element_slice
comptime fn as_repeated_element_slice(self) -> Option<(Expr, Expr)> {}
pub comptime fn as_repeated_element_slice(self) -> Option<(Expr, Expr)> {}
// docs:end:as_repeated_element_slice

/// If this expression is a slice literal `&[elem1, ..., elemN]`,
/// return each element of the slice.
#[builtin(expr_as_slice)]
// docs:start:as_slice
comptime fn as_slice(self) -> Option<[Expr]> {}
pub comptime fn as_slice(self) -> Option<[Expr]> {}
// docs:end:as_slice

/// If this expression is a tuple `(field1, ..., fieldN)`,
/// return each element of the tuple.
#[builtin(expr_as_tuple)]
// docs:start:as_tuple
comptime fn as_tuple(self) -> Option<[Expr]> {}
pub comptime fn as_tuple(self) -> Option<[Expr]> {}
// docs:end:as_tuple

/// If this expression is a unary operation `<op> <rhs>`,
/// return the unary operator as well as the right-hand side expression.
#[builtin(expr_as_unary_op)]
// docs:start:as_unary_op
comptime fn as_unary_op(self) -> Option<(UnaryOp, Expr)> {}
pub comptime fn as_unary_op(self) -> Option<(UnaryOp, Expr)> {}
// docs:end:as_unary_op

/// If this expression is an `unsafe { stmt1; ...; stmtN }` block,
/// return each statement inside in a slice.
#[builtin(expr_as_unsafe)]
// docs:start:as_unsafe
comptime fn as_unsafe(self) -> Option<[Expr]> {}
pub comptime fn as_unsafe(self) -> Option<[Expr]> {}
// docs:end:as_unsafe

/// Returns `true` if this expression is trailed by a semicolon.
Expand All @@ -202,19 +202,19 @@ impl Expr {
/// ```
#[builtin(expr_has_semicolon)]
// docs:start:has_semicolon
comptime fn has_semicolon(self) -> bool {}
pub comptime fn has_semicolon(self) -> bool {}
// docs:end:has_semicolon

/// Returns `true` if this expression is `break`.
#[builtin(expr_is_break)]
// docs:start:is_break
comptime fn is_break(self) -> bool {}
pub comptime fn is_break(self) -> bool {}
// docs:end:is_break

/// Returns `true` if this expression is `continue`.
#[builtin(expr_is_continue)]
// docs:start:is_continue
comptime fn is_continue(self) -> bool {}
pub comptime fn is_continue(self) -> bool {}
// docs:end:is_continue

/// Applies a mapping function to this expression and to all of its sub-expressions.
Expand All @@ -225,7 +225,7 @@ impl Expr {
/// For example, calling `modify` on `(&[1], &[2, 3])` with an `f` that returns `Option::some`
/// for expressions that are integers, doubling them, would return `(&[2], &[4, 6])`.
// docs:start:modify
comptime fn modify<Env>(self, f: fn[Env](Expr) -> Option<Expr>) -> Expr {
pub comptime fn modify<Env>(self, f: fn[Env](Expr) -> Option<Expr>) -> Expr {
// docs:end:modify
let result = modify_array(self, f);
let result = result.or_else(|| modify_assert(self, f));
Expand Down Expand Up @@ -262,7 +262,7 @@ impl Expr {

/// Returns this expression as a `Quoted` value. It's the same as `quote { $self }`.
// docs:start:quoted
comptime fn quoted(self) -> Quoted {
pub comptime fn quoted(self) -> Quoted {
// docs:end:quoted
quote { $self }
}
Expand All @@ -278,7 +278,7 @@ impl Expr {
/// the current `comptime` function.
#[builtin(expr_resolve)]
// docs:start:resolve
comptime fn resolve(self, in_function: Option<FunctionDefinition>) -> TypedExpr {}
pub comptime fn resolve(self, in_function: Option<FunctionDefinition>) -> TypedExpr {}
// docs:end:resolve
}

Expand Down
2 changes: 1 addition & 1 deletion noir_stdlib/src/meta/format_string.nr
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
impl <let N: u32, T> fmtstr<N, T> {
#[builtin(fmtstr_quoted_contents)]
// docs:start:quoted_contents
comptime fn quoted_contents(self) -> Quoted {}
pub comptime fn quoted_contents(self) -> Quoted {}
// docs:end:quoted_contents
}
Loading

0 comments on commit 29ffae4

Please sign in to comment.