Make tables indexable via pointer value
This commit is contained in:
parent
10bc804a01
commit
3360f14913
@ -108,4 +108,5 @@ SETMETATABLE(table, {
|
||||
})
|
||||
|
||||
print(table + 5)
|
||||
print(table("hello", "there"))
|
||||
print(table("hello", "there"))
|
||||
print("hello ", table)
|
||||
@ -25,7 +25,14 @@ impl value::RustFunction for Max {
|
||||
pub struct Print;
|
||||
impl value::RustFunction for Print {
|
||||
fn execute(&self, parameters: Vec<value::Value>) -> Result<Vec<value::Value>, RuntimeError> {
|
||||
println!("{:?}", parameters);
|
||||
println!(
|
||||
"{}",
|
||||
parameters
|
||||
.iter()
|
||||
.map(|v| format!("{}", v))
|
||||
.collect::<Vec<_>>()
|
||||
.join("\t")
|
||||
);
|
||||
Ok(Vec::new())
|
||||
}
|
||||
|
||||
|
||||
@ -202,7 +202,7 @@ impl Display for Value {
|
||||
}
|
||||
Value::Function(closure) => write!(f, "<function({})>", closure.prototype),
|
||||
Value::Nil => write!(f, "nil"),
|
||||
Value::Table { .. } => write!(f, "<table>"),
|
||||
Value::Table { contents, .. } => write!(f, "<table#{}>", contents.as_ptr() as u64),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user