Skip to content

Commit

Permalink
Address comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
rbartlensky committed Jan 15, 2019
1 parent 6a8d0f7 commit ee8361c
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions luavm/src/lib/instructions/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ pub fn get_attr(vm: &mut Vm, instr: u32) -> Result<(), LuaError> {
let from = &vm.registers[arg2];
let attr = &vm.registers[third_arg(instr) as usize];
match attr.get_constant_index() {
Some(i) if arg2 == ENV_REG => vm.env_attrs[i].clone(),
Some(i) => {
if arg2 == ENV_REG {
vm.env_attrs[i].clone()
} else {
from.get_attr(attr)?
}
}
_ => from.get_attr(attr)?,
}
};
Expand All @@ -24,7 +30,13 @@ pub fn set_attr(vm: &mut Vm, instr: u32) -> Result<(), LuaError> {
let val = vm.registers[third_arg(instr) as usize].clone();
let arg1 = first_arg(instr) as usize;
match attr.get_constant_index() {
Some(i) if arg1 == ENV_REG => vm.env_attrs[i] = val,
Some(i) => {
if arg1 == ENV_REG {
vm.env_attrs[i] = val
} else {
vm.registers[arg1].set_attr(attr, val)?
}
}
_ => vm.registers[arg1].set_attr(attr, val)?,
}
Ok(())
Expand Down

0 comments on commit ee8361c

Please sign in to comment.