Remove old single-purpose instructions
These instructions were used because it was more painful to implement lookups and function calls for operators with the AST body compiler. This is less of a hurdle now with the list compiler, and since these instructions are extensive and involve a lot of copy-paste, they have been removed to help with code bloat. They may be reintroduced in the future for optimization purposes. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
122
src/vm/mod.rs
122
src/vm/mod.rs
@@ -285,128 +285,6 @@ impl<'c> Vm<'c> {
|
||||
Inst::Return => {
|
||||
signal = Some(Signal::Return);
|
||||
}
|
||||
Inst::UnNeg => todo!("Inst::UnNeg"),
|
||||
Inst::UnPos => todo!("Inst::UnPos"),
|
||||
Inst::BinPlus => {
|
||||
let rhs = self.pop().unwrap();
|
||||
let lhs = self.pop().unwrap();
|
||||
let fun = {
|
||||
read_obj!(let lhs = lhs);
|
||||
lhs.get_plus()
|
||||
.expect("TODO: throw an error for missing __add__ attr")
|
||||
};
|
||||
signal = Some(Signal::Call(fun, vec![rhs]));
|
||||
}
|
||||
Inst::BinMinus => {
|
||||
let rhs = self.pop().unwrap();
|
||||
let lhs = self.pop().unwrap();
|
||||
let fun = {
|
||||
read_obj!(let lhs = lhs);
|
||||
lhs.get_minus()
|
||||
.expect("TODO: throw an error for missing __sub__ attr")
|
||||
};
|
||||
signal = Some(Signal::Call(fun, vec![rhs]));
|
||||
}
|
||||
Inst::BinMul => {
|
||||
let rhs = self.pop().unwrap();
|
||||
let lhs = self.pop().unwrap();
|
||||
let fun = {
|
||||
read_obj!(let lhs = lhs);
|
||||
lhs.get_mul()
|
||||
.expect("TODO: throw an error for missing __mul__ attr")
|
||||
};
|
||||
signal = Some(Signal::Call(fun, vec![rhs]));
|
||||
}
|
||||
Inst::BinDiv => {
|
||||
let rhs = self.pop().unwrap();
|
||||
let lhs = self.pop().unwrap();
|
||||
let fun = {
|
||||
read_obj!(let lhs = lhs);
|
||||
lhs.get_div()
|
||||
.expect("TODO: throw an error for missing __div__ attr")
|
||||
};
|
||||
signal = Some(Signal::Call(fun, vec![rhs]));
|
||||
}
|
||||
Inst::BinEq => {
|
||||
let rhs = self.pop().unwrap();
|
||||
let lhs = self.pop().unwrap();
|
||||
let fun = {
|
||||
read_obj!(let lhs = lhs);
|
||||
lhs.get_eq()
|
||||
.expect("TODO: throw an error for missing __eq__ attr")
|
||||
};
|
||||
signal = Some(Signal::Call(fun, vec![rhs]));
|
||||
}
|
||||
Inst::BinNeq => {
|
||||
let rhs = self.pop().unwrap();
|
||||
let lhs = self.pop().unwrap();
|
||||
let fun = {
|
||||
read_obj!(let lhs = lhs);
|
||||
lhs.get_ne()
|
||||
.expect("TODO: throw an error for missing __ne__ attr")
|
||||
};
|
||||
signal = Some(Signal::Call(fun, vec![rhs]));
|
||||
}
|
||||
Inst::BinLt => {
|
||||
let rhs = self.pop().unwrap();
|
||||
let lhs = self.pop().unwrap();
|
||||
let fun = {
|
||||
read_obj!(let lhs = lhs);
|
||||
lhs.get_lt()
|
||||
.expect("TODO: throw an error for missing __lt__ attr")
|
||||
};
|
||||
signal = Some(Signal::Call(fun, vec![rhs]));
|
||||
}
|
||||
Inst::BinLe => {
|
||||
let rhs = self.pop().unwrap();
|
||||
let lhs = self.pop().unwrap();
|
||||
let fun = {
|
||||
read_obj!(let lhs = lhs);
|
||||
lhs.get_le()
|
||||
.expect("TODO: throw an error for missing __le__ attr")
|
||||
};
|
||||
signal = Some(Signal::Call(fun, vec![rhs]));
|
||||
}
|
||||
Inst::BinGt => {
|
||||
let rhs = self.pop().unwrap();
|
||||
let lhs = self.pop().unwrap();
|
||||
let fun = {
|
||||
read_obj!(let lhs = lhs);
|
||||
lhs.get_gt()
|
||||
.expect("TODO: throw an error for missing __gt__ attr")
|
||||
};
|
||||
signal = Some(Signal::Call(fun, vec![rhs]));
|
||||
}
|
||||
Inst::BinGe => {
|
||||
let rhs = self.pop().unwrap();
|
||||
let lhs = self.pop().unwrap();
|
||||
let fun = {
|
||||
read_obj!(let lhs = lhs);
|
||||
lhs.get_ge()
|
||||
.expect("TODO: throw an error for missing __ge__ attr")
|
||||
};
|
||||
signal = Some(Signal::Call(fun, vec![rhs]));
|
||||
}
|
||||
Inst::BinAnd => todo!(), /*{
|
||||
let rhs = self.pop().unwrap();
|
||||
let lhs = self.pop().unwrap();
|
||||
let fun = {
|
||||
read_obj!(let lhs = lhs);
|
||||
lhs.get_and()
|
||||
.expect("TODO: throw an error for missing __and__ attr")
|
||||
};
|
||||
signal = Some(Signal::Call(fun, vec![rhs]));
|
||||
}*/
|
||||
Inst::BinOr => todo!(), /*{
|
||||
let rhs = self.pop().unwrap();
|
||||
let lhs = self.pop().unwrap();
|
||||
let fun = {
|
||||
read_obj!(let lhs = lhs);
|
||||
lhs.get_or()
|
||||
.expect("TODO: throw an error for missing __or__ attr")
|
||||
};
|
||||
signal = Some(Signal::Call(fun, vec![rhs]));
|
||||
}*/
|
||||
}
|
||||
self.set_pc(next_pc);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user