Make tables indexable via pointer value
This commit is contained in:
parent
10bc804a01
commit
3360f14913
@ -109,3 +109,4 @@ SETMETATABLE(table, {
|
|||||||
|
|
||||||
print(table + 5)
|
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;
|
pub struct Print;
|
||||||
impl value::RustFunction for Print {
|
impl value::RustFunction for Print {
|
||||||
fn execute(&self, parameters: Vec<value::Value>) -> Result<Vec<value::Value>, RuntimeError> {
|
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())
|
Ok(Vec::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -202,7 +202,7 @@ impl Display for Value {
|
|||||||
}
|
}
|
||||||
Value::Function(closure) => write!(f, "<function({})>", closure.prototype),
|
Value::Function(closure) => write!(f, "<function({})>", closure.prototype),
|
||||||
Value::Nil => write!(f, "nil"),
|
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