refactor(tvix/eval): clean up implementation of compile_literal
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>
This commit is contained in:
parent
2f91543a42
commit
337d626f00
1 changed files with 7 additions and 10 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue