Created
October 20, 2014 23:50
-
-
Save nickik/8a614bc360c702fee43f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[deriving(Show, Clone)] | |
pub enum Slot { | |
Nil, | |
Int(i64), | |
Float(f64), | |
Bool(bool), | |
Str(String), | |
Key(Keyword), | |
Func(uint), | |
VFunc(uint), | |
Obj(CljObject), | |
CType(uint), | |
SCC(Closure), | |
} | |
macro_rules! execute ( | |
(using $vm:ident with $args:ident | |
$($op:pat as $ty:ty => $code:expr),+) => ( | |
impl Execute for Instr { | |
fn execute(&self, $vm:&mut Vm) -> Instr { | |
match self.decode() { | |
$($op => { let $args : $ty = from_instr(self); $code }),+ | |
} | |
} | |
} | |
) | |
) | |
vm::GETFREEVAR as OpAD => { | |
let idx = args.d as uint; | |
let dst_idx = args.a as uint; | |
let freevar = match vm.slots.slot[1].clone() { | |
SCC(clos) => clos.freevar[idx].clone(), | |
_ => fail!("Not Closure in Slot") | |
} | |
vm.slots.store(dst_idx, freevar); | |
vm.fetch_next() | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment