Make tables indexable
This commit is contained in:
parent
ce3ee7a273
commit
10bc804a01
@ -125,7 +125,8 @@ impl Debug for Constant {
|
||||
}
|
||||
}
|
||||
|
||||
pub type Table = Rc<RefCell<HashMap<IndexableValue, Value>>>;
|
||||
pub type Table = Rc<RefCell<TableMap>>;
|
||||
pub type TableMap = HashMap<IndexableValue, Value>;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub enum Value {
|
||||
@ -151,7 +152,7 @@ impl Value {
|
||||
}
|
||||
Value::Function(closure) => Ok(IndexableValue::Function(closure.prototype)),
|
||||
Value::Nil => Err(RuntimeError::InvalidTableIndex(self)),
|
||||
Value::Table { .. } => Err(RuntimeError::InvalidTableIndex(self)),
|
||||
Value::Table { contents, .. } => Ok(IndexableValue::Table(contents.as_ptr())),
|
||||
}
|
||||
}
|
||||
|
||||
@ -621,6 +622,7 @@ pub enum IndexableValue {
|
||||
Bool(LuaBool),
|
||||
RustFunction(String),
|
||||
Function(u32),
|
||||
Table(*mut TableMap),
|
||||
}
|
||||
|
||||
impl From<&str> for IndexableValue {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user