Add Bool builtin type, branches, and some more stuff
* obj::Bool builtin type is used for truthiness and decision-making * Branches are compiled and seem to be working for basic integer comparison * Updated version of Shredder to what is current as of writing * CheckTruth VM instruction that will explicitly set the condition flag * Probably some other stuff Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -254,6 +254,15 @@ impl<'c> Vm<'c> {
|
||||
todo!("TODO: throw an error for attributes that can't be set");
|
||||
}
|
||||
}
|
||||
Inst::CheckTruth => {
|
||||
let source = self.pop().expect("no source available for CheckTruth");
|
||||
read_obj_downcast!(let obj: Option<&Bool> = &source);
|
||||
if let Some(obj) = obj {
|
||||
self.condition = obj.value();
|
||||
} else {
|
||||
unreachable!("Expected a boolean for CheckTruth but got {:?} instead", source);
|
||||
}
|
||||
}
|
||||
Inst::Jump(addr) => {
|
||||
next_pc = addr;
|
||||
}
|
||||
@@ -272,12 +281,12 @@ impl<'c> Vm<'c> {
|
||||
.expect("TODO: throw an error for missing __call__ attr");
|
||||
signal = Some(Signal::Call(callee, args));
|
||||
}
|
||||
Inst::Index => todo!(),
|
||||
Inst::Index => todo!("Inst::Index"),
|
||||
Inst::Return => {
|
||||
signal = Some(Signal::Return);
|
||||
}
|
||||
Inst::UnNeg => todo!(),
|
||||
Inst::UnPos => todo!(),
|
||||
Inst::UnNeg => todo!("Inst::UnNeg"),
|
||||
Inst::UnPos => todo!("Inst::UnPos"),
|
||||
Inst::BinPlus => {
|
||||
let rhs = self.pop().unwrap();
|
||||
let lhs = self.pop().unwrap();
|
||||
|
||||
Reference in New Issue
Block a user