Skip to content

Commit

Permalink
Implement fmtstr::quoted in Noir
Browse files Browse the repository at this point in the history
  • Loading branch information
asterite committed Sep 12, 2024
1 parent c8f293a commit 0994b46
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
13 changes: 0 additions & 13 deletions compiler/noirc_frontend/src/hir/comptime/interpreter/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ impl<'local, 'context> Interpreter<'local, 'context> {
"expr_is_continue" => expr_is_continue(interner, arguments, location),
"expr_resolve" => expr_resolve(self, arguments, location),
"is_unconstrained" => Ok(Value::Bool(true)),
"fmtstr_quoted" => fmtstr_quoted(interner, arguments, location),
"fmtstr_quoted_contents" => fmtstr_quoted_contents(interner, arguments, location),
"fresh_type_variable" => fresh_type_variable(interner),
"function_def_add_attribute" => function_def_add_attribute(self, arguments, location),
Expand Down Expand Up @@ -1898,18 +1897,6 @@ fn unwrap_expr_value(interner: &NodeInterner, mut expr_value: ExprValue) -> Expr
expr_value
}

// fn quoted(self) -> Quoted
fn fmtstr_quoted(
interner: &NodeInterner,
arguments: Vec<(Value, Location)>,
location: Location,
) -> IResult<Value> {
let self_argument = check_one_argument(arguments, location)?;
let (string, _) = get_format_string(interner, self_argument)?;
let token = Token::Str((*string).clone());
Ok(Value::Quoted(Rc::new(vec![token])))
}

// fn quoted_contents(self) -> Quoted
fn fmtstr_quoted_contents(
interner: &NodeInterner,
Expand Down
5 changes: 3 additions & 2 deletions noir_stdlib/src/meta/format_string.nr
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
impl <let N: u32, T> fmtstr<N, T> {
#[builtin(fmtstr_quoted)]
// docs:start:quoted
comptime fn quoted(self) -> Quoted {}
comptime fn quoted(self) -> Quoted {
crate::meta::unquote!(quote { $self })
}
// docs:end:quoted

#[builtin(fmtstr_quoted_contents)]
Expand Down

0 comments on commit 0994b46

Please sign in to comment.