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:
2020-11-10 19:14:56 -08:00
parent 6ec14e3ffa
commit 53feed7eab
2 changed files with 0 additions and 190 deletions

View File

@@ -63,60 +63,6 @@ pub enum Inst {
/// Pops the top value from the stack, and returns from the function, using the popped value as
/// a return value.
Return,
/// Replaces the top stack value with its negation applied.
UnNeg,
/// Replaces the top stack value with its absolute value applied.
UnPos,
/// Pops the top two items off of the stack, and applies the binary addition operator to them,
/// pushing the result to the stack.
BinPlus,
/// Pops the top two items off of the stack, and applies the binary subtraction operator to
/// them, pushing the result to the stack.
BinMinus,
/// Pops the top two items off of the stack, and applies the binary multiplication operator to
/// them, pushing the result to the stack.
BinMul,
/// Pops the top two items off of the stack, and applies the binary division operator to them,
/// pushing the result to the stack.
BinDiv,
/// Pops the top two items off of the stack, and applies the boolean equality operator to them,
/// pushing the result to the stack.
BinEq,
/// Pops the top two items off of the stack, and applies the boolean inequality operator to
/// them, pushing the result to the stack.
BinNeq,
/// Pops the top two items off of the stack, and applies the boolean less-than operator to
/// them, pushing the result to the stack.
BinLt,
/// Pops the top two items off of the stack, and applies the binary less-than or equals
/// operator to them, pushing the result to the stack.
BinLe,
/// Pops the top two items off of the stack, and applies the boolean greater-than operator to
/// them, pushing the result to the stack.
BinGt,
/// Pops the top two items off of the stack, and applies the binary greater-than or equals
/// operator to them, pushing the result to the stack.
BinGe,
/// Pops the top two items off of the stack, and applies the boolean and operator to them,
/// pushing the result to the stack.
BinAnd,
/// Pops the top two items off of the stack, and applies the boolean or operator to them,
/// pushing the result to the stack.
BinOr,
}
//
@@ -139,20 +85,6 @@ impl Inst {
Inst::Call(_) => "CALL",
Inst::Index => "INDEX",
Inst::Return => "RETURN",
Inst::UnNeg => "UN_NEG",
Inst::UnPos => "UN_POS",
Inst::BinPlus => "BIN_PLUS",
Inst::BinMinus => "BIN_MINUS",
Inst::BinMul => "BIN_MUL",
Inst::BinDiv => "BIN_DIV",
Inst::BinEq => "BIN_EQ",
Inst::BinNeq => "BIN_NEQ",
Inst::BinLt => "BIN_LT",
Inst::BinLe => "BIN_LE",
Inst::BinGt => "BIN_GT",
Inst::BinGe => "BIN_GE",
Inst::BinAnd => "BIN_AND",
Inst::BinOr => "BIN_OR",
}
}
}

View File

@@ -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);