Interpreter - Use Value.to_string() for print statements
This commit is contained in:
parent
621ca9d9f1
commit
afb465d6df
1 changed files with 1 additions and 8 deletions
|
@ -172,14 +172,7 @@ impl StmtNode {
|
||||||
/// Handle the `print` statement.
|
/// Handle the `print` statement.
|
||||||
fn on_print(&self, es: &mut InterpreterState, expr: &ExprNode) -> InterpreterResult {
|
fn on_print(&self, es: &mut InterpreterState, expr: &ExprNode) -> InterpreterResult {
|
||||||
let value = expr.interpret(es)?.result();
|
let value = expr.interpret(es)?.result();
|
||||||
let output = match value {
|
let output = value.to_string();
|
||||||
Value::Nil => String::from("nil"),
|
|
||||||
Value::Boolean(true) => String::from("true"),
|
|
||||||
Value::Boolean(false) => String::from("false"),
|
|
||||||
Value::Number(n) => n.to_string(),
|
|
||||||
Value::String(s) => s,
|
|
||||||
Value::Callable(c) => c.borrow().to_string(),
|
|
||||||
};
|
|
||||||
println!("{}", output);
|
println!("{}", output);
|
||||||
Ok(InterpreterFlowControl::default())
|
Ok(InterpreterFlowControl::default())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue