add library(reif)
This commit is contained in:
@@ -156,12 +156,14 @@ impl MachineState {
|
||||
|
||||
fn print_attribute_goals(&mut self, var_dict: &HeapVarDict)
|
||||
{
|
||||
let attr_goals = mem::replace(&mut self.attr_var_init.attribute_goals, vec![]);
|
||||
let mut attr_goals = mem::replace(&mut self.attr_var_init.attribute_goals, vec![]);
|
||||
|
||||
if attr_goals.is_empty() {
|
||||
return;
|
||||
}
|
||||
|
||||
self.term_dedup(&mut attr_goals);
|
||||
|
||||
let mut output = PrinterOutputter::new();
|
||||
|
||||
for goal_addr in attr_goals {
|
||||
|
||||
@@ -114,6 +114,7 @@ impl MachineError {
|
||||
pub enum ValidType {
|
||||
Atom,
|
||||
Atomic,
|
||||
Boolean,
|
||||
// Byte,
|
||||
Callable,
|
||||
// Character,
|
||||
@@ -134,6 +135,7 @@ impl ValidType {
|
||||
match self {
|
||||
ValidType::Atom => "atom",
|
||||
ValidType::Atomic => "atomic",
|
||||
ValidType::Boolean => "boolean",
|
||||
// ValidType::Byte => "byte",
|
||||
ValidType::Callable => "callable",
|
||||
// ValidType::Character => "character",
|
||||
|
||||
@@ -572,6 +572,48 @@ pub(crate) trait CallPolicy: Any {
|
||||
|
||||
return_from_clause!(machine_st.last_call, machine_st)
|
||||
},
|
||||
&BuiltInClauseType::ReifySwitch => {
|
||||
let truth_value = machine_st[temp_v!(1)].clone();
|
||||
let truth_value = machine_st.store(machine_st.deref(truth_value));
|
||||
|
||||
match truth_value {
|
||||
Addr::Con(Constant::Atom(atom, spec)) =>
|
||||
match atom.as_str() {
|
||||
"true" => {
|
||||
let t_branch = machine_st[temp_v!(2)].clone();
|
||||
|
||||
machine_st[temp_v!(1)] = t_branch;
|
||||
self.call_n(machine_st, 1, indices)
|
||||
},
|
||||
"false" => {
|
||||
let f_branch = machine_st[temp_v!(3)].clone();
|
||||
|
||||
machine_st[temp_v!(1)] = f_branch;
|
||||
self.call_n(machine_st, 1, indices)
|
||||
}
|
||||
_ => {
|
||||
let truth_value = Addr::Con(Constant::Atom(atom, spec));
|
||||
|
||||
let stub = MachineError::functor_stub(clause_name!("if_"), 3);
|
||||
let err = MachineError::type_error(ValidType::Boolean, truth_value);
|
||||
|
||||
Err(machine_st.error_form(err, stub))
|
||||
}
|
||||
},
|
||||
ref addr if addr.is_ref() => {
|
||||
let stub = MachineError::functor_stub(clause_name!("if_"), 3);
|
||||
let err = MachineError::instantiation_error();
|
||||
|
||||
Err(machine_st.error_form(err, stub))
|
||||
},
|
||||
addr => {
|
||||
let stub = MachineError::functor_stub(clause_name!("if_"), 3);
|
||||
let err = MachineError::type_error(ValidType::Boolean, addr);
|
||||
|
||||
Err(machine_st.error_form(err, stub))
|
||||
}
|
||||
}
|
||||
},
|
||||
&BuiltInClauseType::CopyTerm => {
|
||||
machine_st.duplicate_term();
|
||||
return_from_clause!(machine_st.last_call, machine_st)
|
||||
|
||||
@@ -321,6 +321,7 @@ static DCGS: &str = include_str!("../lib/dcgs.pl");
|
||||
static ATTS: &str = include_str!("../lib/atts.pl");
|
||||
static DIF: &str = include_str!("../lib/dif.pl");
|
||||
static FREEZE: &str = include_str!("../lib/freeze.pl");
|
||||
static REIF: &str = include_str!("../lib/reif.pl");
|
||||
|
||||
impl Machine {
|
||||
fn compile_special_forms(&mut self) {
|
||||
@@ -351,6 +352,7 @@ impl Machine {
|
||||
compile_user_module(self, ATTS.as_bytes());
|
||||
compile_user_module(self, DIF.as_bytes());
|
||||
compile_user_module(self, FREEZE.as_bytes());
|
||||
compile_user_module(self, REIF.as_bytes());
|
||||
}
|
||||
|
||||
pub fn new() -> Self {
|
||||
|
||||
@@ -409,7 +409,7 @@ impl MachineState {
|
||||
for (h, addr) in bindings {
|
||||
self.heap[h] = HeapCellValue::Addr(addr);
|
||||
}
|
||||
},
|
||||
},
|
||||
&SystemClauseType::RemoveCallPolicyCheck => {
|
||||
let restore_default =
|
||||
match call_policy.downcast_mut::<CWILCallPolicy>().ok() {
|
||||
|
||||
Reference in New Issue
Block a user