diff options
author | Vincent Ambo <mail@tazj.in> | 2022-09-17T16·08+0300 |
---|---|---|
committer | tazjin <tazjin@tvl.su> | 2022-09-17T18·58+0000 |
commit | 337d626f0024fe0aa732acf6c0f595a327f2a468 (patch) | |
tree | b10c5cbeef364553a8ef0a59c73c7ee5d9b5c425 /tvix | |
parent | 2f91543a42e14a790b5a5dabc008f8f3757d60db (diff) |
refactor(tvix/eval): clean up implementation of `compile_literal` r/4889
Suggested by sterni in cl/6231 Change-Id: I58bbc8a922d360ea79a4dacb76cf8aa1fad93757 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6622 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
Diffstat (limited to 'tvix')
-rw-r--r-- | tvix/eval/src/compiler/mod.rs | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/tvix/eval/src/compiler/mod.rs b/tvix/eval/src/compiler/mod.rs index 0322733676a2..52b6e8e542ee 100644 --- a/tvix/eval/src/compiler/mod.rs +++ b/tvix/eval/src/compiler/mod.rs @@ -190,20 +190,17 @@ impl Compiler<'_, '_> { } fn compile_literal(&mut self, node: ast::Literal) { - match node.kind() { - ast::LiteralKind::Float(f) => { - self.emit_constant(Value::Float(f.value().unwrap()), &node); - } - - ast::LiteralKind::Integer(i) => { - self.emit_constant(Value::Integer(i.value().unwrap()), &node); - } + let value = match node.kind() { + ast::LiteralKind::Float(f) => Value::Float(f.value().unwrap()), + ast::LiteralKind::Integer(i) => Value::Integer(i.value().unwrap()), ast::LiteralKind::Uri(u) => { self.emit_warning(&node, WarningKind::DeprecatedLiteralURL); - self.emit_constant(Value::String(u.syntax().text().into()), &node); + Value::String(u.syntax().text().into()) } - } + }; + + self.emit_constant(value, &node); } fn compile_path(&mut self, node: ast::Path) { |