fix compile_seq, variable printing on standalone inlines.
This commit is contained in:
@@ -874,6 +874,8 @@ pub enum ArithmeticInstruction {
|
|||||||
|
|
||||||
pub enum BuiltInInstruction {
|
pub enum BuiltInInstruction {
|
||||||
CleanUpBlock,
|
CleanUpBlock,
|
||||||
|
CompareNumber(CompareNumberQT, ArithmeticTerm, ArithmeticTerm),
|
||||||
|
DynamicCompareNumber(CompareNumberQT),
|
||||||
EraseBall,
|
EraseBall,
|
||||||
Fail,
|
Fail,
|
||||||
GetArgCall,
|
GetArgCall,
|
||||||
@@ -884,6 +886,14 @@ pub enum BuiltInInstruction {
|
|||||||
InstallCleaner,
|
InstallCleaner,
|
||||||
InstallNewBlock,
|
InstallNewBlock,
|
||||||
InternalCallN,
|
InternalCallN,
|
||||||
|
IsAtomic(RegType),
|
||||||
|
IsCompound(RegType),
|
||||||
|
IsFloat(RegType),
|
||||||
|
IsInteger(RegType),
|
||||||
|
IsNonVar(RegType),
|
||||||
|
IsRational(RegType),
|
||||||
|
IsString(RegType),
|
||||||
|
IsVar(RegType),
|
||||||
ResetBlock,
|
ResetBlock,
|
||||||
RestoreCutPolicy,
|
RestoreCutPolicy,
|
||||||
SetBall,
|
SetBall,
|
||||||
@@ -903,7 +913,6 @@ pub enum ControlInstruction {
|
|||||||
CatchCall,
|
CatchCall,
|
||||||
CatchExecute,
|
CatchExecute,
|
||||||
CheckCpExecute,
|
CheckCpExecute,
|
||||||
CompareNumber(CompareNumberQT, ArithmeticTerm, ArithmeticTerm),
|
|
||||||
CompareTermCall(CompareTermQT),
|
CompareTermCall(CompareTermQT),
|
||||||
CompareTermExecute(CompareTermQT),
|
CompareTermExecute(CompareTermQT),
|
||||||
DisplayCall,
|
DisplayCall,
|
||||||
@@ -911,7 +920,6 @@ pub enum ControlInstruction {
|
|||||||
Deallocate,
|
Deallocate,
|
||||||
DuplicateTermCall,
|
DuplicateTermCall,
|
||||||
DuplicateTermExecute,
|
DuplicateTermExecute,
|
||||||
DynamicCompareNumber(CompareNumberQT),
|
|
||||||
DynamicIs,
|
DynamicIs,
|
||||||
EqCall,
|
EqCall,
|
||||||
EqExecute,
|
EqExecute,
|
||||||
@@ -927,14 +935,6 @@ pub enum ControlInstruction {
|
|||||||
JmpByCall(usize, usize), // arity, global_offset.
|
JmpByCall(usize, usize), // arity, global_offset.
|
||||||
JmpByExecute(usize, usize),
|
JmpByExecute(usize, usize),
|
||||||
IsCall(RegType, ArithmeticTerm),
|
IsCall(RegType, ArithmeticTerm),
|
||||||
IsAtomic(RegType),
|
|
||||||
IsCompound(RegType),
|
|
||||||
IsFloat(RegType),
|
|
||||||
IsInteger(RegType),
|
|
||||||
IsNonVar(RegType),
|
|
||||||
IsRational(RegType),
|
|
||||||
IsString(RegType),
|
|
||||||
IsVar(RegType),
|
|
||||||
IsExecute(RegType, ArithmeticTerm),
|
IsExecute(RegType, ArithmeticTerm),
|
||||||
NotEqCall,
|
NotEqCall,
|
||||||
NotEqExecute,
|
NotEqExecute,
|
||||||
@@ -951,14 +951,12 @@ impl ControlInstruction {
|
|||||||
&ControlInstruction::Call(_, _, _) => true,
|
&ControlInstruction::Call(_, _, _) => true,
|
||||||
&ControlInstruction::CatchCall => true,
|
&ControlInstruction::CatchCall => true,
|
||||||
&ControlInstruction::CatchExecute => true,
|
&ControlInstruction::CatchExecute => true,
|
||||||
&ControlInstruction::CompareNumber(..) => true,
|
|
||||||
&ControlInstruction::CompareTermCall(..) => true,
|
&ControlInstruction::CompareTermCall(..) => true,
|
||||||
&ControlInstruction::CompareTermExecute(..) => true,
|
&ControlInstruction::CompareTermExecute(..) => true,
|
||||||
&ControlInstruction::DisplayCall => true,
|
&ControlInstruction::DisplayCall => true,
|
||||||
&ControlInstruction::DisplayExecute => true,
|
&ControlInstruction::DisplayExecute => true,
|
||||||
&ControlInstruction::DuplicateTermCall => true,
|
&ControlInstruction::DuplicateTermCall => true,
|
||||||
&ControlInstruction::DuplicateTermExecute => true,
|
&ControlInstruction::DuplicateTermExecute => true,
|
||||||
&ControlInstruction::DynamicCompareNumber(_) => true,
|
|
||||||
&ControlInstruction::DynamicIs => true,
|
&ControlInstruction::DynamicIs => true,
|
||||||
&ControlInstruction::EqCall => true,
|
&ControlInstruction::EqCall => true,
|
||||||
&ControlInstruction::EqExecute => true,
|
&ControlInstruction::EqExecute => true,
|
||||||
@@ -976,14 +974,6 @@ impl ControlInstruction {
|
|||||||
&ControlInstruction::GotoExecute(..) => true,
|
&ControlInstruction::GotoExecute(..) => true,
|
||||||
&ControlInstruction::GroundCall => true,
|
&ControlInstruction::GroundCall => true,
|
||||||
&ControlInstruction::GroundExecute => true,
|
&ControlInstruction::GroundExecute => true,
|
||||||
&ControlInstruction::IsAtomic(_) => true,
|
|
||||||
&ControlInstruction::IsCompound(_) => true,
|
|
||||||
&ControlInstruction::IsFloat(_) => true,
|
|
||||||
&ControlInstruction::IsInteger(_) => true,
|
|
||||||
&ControlInstruction::IsNonVar(_) => true,
|
|
||||||
&ControlInstruction::IsRational(_) => true,
|
|
||||||
&ControlInstruction::IsString(_) => true,
|
|
||||||
&ControlInstruction::IsVar(_) => true,
|
|
||||||
&ControlInstruction::IsCall(..) => true,
|
&ControlInstruction::IsCall(..) => true,
|
||||||
&ControlInstruction::IsExecute(..) => true,
|
&ControlInstruction::IsExecute(..) => true,
|
||||||
&ControlInstruction::JmpByCall(..) => true,
|
&ControlInstruction::JmpByCall(..) => true,
|
||||||
|
|||||||
@@ -483,13 +483,12 @@ impl<'a, TermMarker: Allocator<'a>> CodeGenerator<'a, TermMarker>
|
|||||||
};
|
};
|
||||||
|
|
||||||
match *term {
|
match *term {
|
||||||
&QueryTerm::Cut => {
|
&QueryTerm::Cut =>
|
||||||
code.push(if chunk_num == 0 {
|
code.push(if chunk_num == 0 {
|
||||||
Line::Cut(CutInstruction::NeckCut)
|
Line::Cut(CutInstruction::NeckCut)
|
||||||
} else {
|
} else {
|
||||||
Line::Cut(CutInstruction::Cut(perm_v!(1)))
|
Line::Cut(CutInstruction::Cut(perm_v!(1)))
|
||||||
});
|
}),
|
||||||
},
|
|
||||||
&QueryTerm::Is(ref terms) => {
|
&QueryTerm::Is(ref terms) => {
|
||||||
let (mut acode, at) = self.call_arith_eval(terms[1].as_ref(), 1)?;
|
let (mut acode, at) = self.call_arith_eval(terms[1].as_ref(), 1)?;
|
||||||
code.append(&mut acode);
|
code.append(&mut acode);
|
||||||
@@ -520,7 +519,7 @@ impl<'a, TermMarker: Allocator<'a>> CodeGenerator<'a, TermMarker>
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
&QueryTerm::Inlined(ref term) =>
|
&QueryTerm::Inlined(ref term) =>
|
||||||
self.compile_inlined(term, term_loc, code)?,
|
try!(self.compile_inlined(term, term_loc, code)),
|
||||||
_ => {
|
_ => {
|
||||||
let num_perm_vars = if chunk_num == 0 {
|
let num_perm_vars = if chunk_num == 0 {
|
||||||
conjunct_info.perm_vars()
|
conjunct_info.perm_vars()
|
||||||
@@ -531,10 +530,10 @@ impl<'a, TermMarker: Allocator<'a>> CodeGenerator<'a, TermMarker>
|
|||||||
self.compile_query_line(term, term_loc, code, num_perm_vars, is_exposed);
|
self.compile_query_line(term, term_loc, code, num_perm_vars, is_exposed);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
self.marker.reset_contents();
|
self.marker.reset_contents();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -169,24 +169,8 @@ impl fmt::Display for ControlInstruction {
|
|||||||
write!(f, "is_call {}, {}", r, at),
|
write!(f, "is_call {}, {}", r, at),
|
||||||
&ControlInstruction::IsExecute(r, ref at) =>
|
&ControlInstruction::IsExecute(r, ref at) =>
|
||||||
write!(f, "is_execute {}, {}", r, at),
|
write!(f, "is_execute {}, {}", r, at),
|
||||||
&ControlInstruction::IsAtomic(r) =>
|
|
||||||
write!(f, "is_atomic {}", r),
|
|
||||||
&ControlInstruction::IsCompound(r) =>
|
|
||||||
write!(f, "is_compound {}", r),
|
|
||||||
&ControlInstruction::IsFloat(r) =>
|
|
||||||
write!(f, "is_float {}", r),
|
|
||||||
&ControlInstruction::IsRational(r) =>
|
|
||||||
write!(f, "is_rational {}", r),
|
|
||||||
&ControlInstruction::IsNonVar(r) =>
|
|
||||||
write!(f, "is_non_var {}", r),
|
|
||||||
&ControlInstruction::IsString(r) =>
|
|
||||||
write!(f, "is_string {}", r),
|
|
||||||
&ControlInstruction::IsInteger(r) =>
|
|
||||||
write!(f, "is_integer {}", r),
|
|
||||||
&ControlInstruction::DynamicIs =>
|
&ControlInstruction::DynamicIs =>
|
||||||
write!(f, "call_is"),
|
write!(f, "call_is"),
|
||||||
&ControlInstruction::IsVar(r) =>
|
|
||||||
write!(f, "is_var {}", r),
|
|
||||||
&ControlInstruction::JmpByCall(arity, offset) =>
|
&ControlInstruction::JmpByCall(arity, offset) =>
|
||||||
write!(f, "jmp_by_call {}/{}", offset, arity),
|
write!(f, "jmp_by_call {}/{}", offset, arity),
|
||||||
&ControlInstruction::JmpByExecute(arity, offset) =>
|
&ControlInstruction::JmpByExecute(arity, offset) =>
|
||||||
@@ -201,10 +185,6 @@ impl fmt::Display for ControlInstruction {
|
|||||||
write!(f, "call_throw"),
|
write!(f, "call_throw"),
|
||||||
&ControlInstruction::ThrowExecute =>
|
&ControlInstruction::ThrowExecute =>
|
||||||
write!(f, "execute_throw"),
|
write!(f, "execute_throw"),
|
||||||
&ControlInstruction::CompareNumber(cmp, ref at_1, ref at_2) =>
|
|
||||||
write!(f, "number_test {}, {}, {} ", cmp, at_1, at_2),
|
|
||||||
&ControlInstruction::DynamicCompareNumber(cmp) =>
|
|
||||||
write!(f, "dynamic_number_test {}", cmp),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -261,6 +241,26 @@ impl fmt::Display for BuiltInInstruction {
|
|||||||
write!(f, "unwind_stack"),
|
write!(f, "unwind_stack"),
|
||||||
&BuiltInInstruction::Unify =>
|
&BuiltInInstruction::Unify =>
|
||||||
write!(f, "unify"),
|
write!(f, "unify"),
|
||||||
|
&BuiltInInstruction::IsAtomic(r) =>
|
||||||
|
write!(f, "is_atomic {}", r),
|
||||||
|
&BuiltInInstruction::IsCompound(r) =>
|
||||||
|
write!(f, "is_compound {}", r),
|
||||||
|
&BuiltInInstruction::IsFloat(r) =>
|
||||||
|
write!(f, "is_float {}", r),
|
||||||
|
&BuiltInInstruction::IsRational(r) =>
|
||||||
|
write!(f, "is_rational {}", r),
|
||||||
|
&BuiltInInstruction::IsNonVar(r) =>
|
||||||
|
write!(f, "is_non_var {}", r),
|
||||||
|
&BuiltInInstruction::IsString(r) =>
|
||||||
|
write!(f, "is_string {}", r),
|
||||||
|
&BuiltInInstruction::IsInteger(r) =>
|
||||||
|
write!(f, "is_integer {}", r),
|
||||||
|
&BuiltInInstruction::IsVar(r) =>
|
||||||
|
write!(f, "is_var {}", r),
|
||||||
|
&BuiltInInstruction::CompareNumber(cmp, ref at_1, ref at_2) =>
|
||||||
|
write!(f, "number_test {}, {}, {} ", cmp, at_1, at_2),
|
||||||
|
&BuiltInInstruction::DynamicCompareNumber(cmp) =>
|
||||||
|
write!(f, "dynamic_number_test {}", cmp),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ pub static LISTS: &str = "member(X, [X|_]).
|
|||||||
|
|
||||||
memberchk(X, Xs) :- member(X, Xs), !.
|
memberchk(X, Xs) :- member(X, Xs), !.
|
||||||
|
|
||||||
reverse(Xs, Ys) :- reverse(Xs, [], Ys).
|
reverse(Xs, Ys) :- var(Ys), !, reverse(Xs, [], Ys).
|
||||||
|
reverse(Ys, Xs) :- var(Ys), reverse(Xs, [], Ys).
|
||||||
|
|
||||||
reverse([], Ys, Ys).
|
reverse([], Ys, Ys).
|
||||||
reverse([H|T], Ps, Rs) :-
|
reverse([H|T], Ps, Rs) :-
|
||||||
|
|||||||
@@ -1270,6 +1270,18 @@ impl MachineState {
|
|||||||
instr: &BuiltInInstruction)
|
instr: &BuiltInInstruction)
|
||||||
{
|
{
|
||||||
match instr {
|
match instr {
|
||||||
|
&BuiltInInstruction::CompareNumber(cmp, ref at_1, ref at_2) => {
|
||||||
|
let n1 = try_or_fail!(self, self.get_number(at_1));
|
||||||
|
let n2 = try_or_fail!(self, self.get_number(at_2));
|
||||||
|
|
||||||
|
self.compare_numbers(cmp, n1, n2);
|
||||||
|
},
|
||||||
|
&BuiltInInstruction::DynamicCompareNumber(cmp) => {
|
||||||
|
let n1 = try_or_fail!(self, self.arith_eval_by_metacall(temp_v!(1)));
|
||||||
|
let n2 = try_or_fail!(self, self.arith_eval_by_metacall(temp_v!(2)));
|
||||||
|
|
||||||
|
self.compare_numbers(cmp, n1, n2);
|
||||||
|
},
|
||||||
&BuiltInInstruction::GetArgCall =>
|
&BuiltInInstruction::GetArgCall =>
|
||||||
try_or_fail!(self, {
|
try_or_fail!(self, {
|
||||||
let val = self.try_get_arg();
|
let val = self.try_get_arg();
|
||||||
@@ -1339,6 +1351,70 @@ SetupCallCleanupCutPolicy.")
|
|||||||
|
|
||||||
self.p += 1;
|
self.p += 1;
|
||||||
},
|
},
|
||||||
|
&BuiltInInstruction::IsAtomic(r) => {
|
||||||
|
let d = self.store(self.deref(self[r].clone()));
|
||||||
|
|
||||||
|
match d {
|
||||||
|
Addr::Con(_) => self.p += 1,
|
||||||
|
_ => self.fail = true
|
||||||
|
};
|
||||||
|
},
|
||||||
|
&BuiltInInstruction::IsInteger(r) => {
|
||||||
|
let d = self.store(self.deref(self[r].clone()));
|
||||||
|
|
||||||
|
match d {
|
||||||
|
Addr::Con(Constant::Number(Number::Integer(_))) => self.p += 1,
|
||||||
|
_ => self.fail = true
|
||||||
|
};
|
||||||
|
},
|
||||||
|
&BuiltInInstruction::IsCompound(r) => {
|
||||||
|
let d = self.store(self.deref(self[r].clone()));
|
||||||
|
|
||||||
|
match d {
|
||||||
|
Addr::Str(_) => self.p += 1,
|
||||||
|
_ => self.fail = true
|
||||||
|
};
|
||||||
|
},
|
||||||
|
&BuiltInInstruction::IsFloat(r) => {
|
||||||
|
let d = self.store(self.deref(self[r].clone()));
|
||||||
|
|
||||||
|
match d {
|
||||||
|
Addr::Con(Constant::Number(Number::Float(_))) => self.p += 1,
|
||||||
|
_ => self.fail = true
|
||||||
|
};
|
||||||
|
},
|
||||||
|
&BuiltInInstruction::IsRational(r) => {
|
||||||
|
let d = self.store(self.deref(self[r].clone()));
|
||||||
|
|
||||||
|
match d {
|
||||||
|
Addr::Con(Constant::Number(Number::Rational(_))) => self.p += 1,
|
||||||
|
_ => self.fail = true
|
||||||
|
};
|
||||||
|
},
|
||||||
|
&BuiltInInstruction::IsString(r) => {
|
||||||
|
let d = self.store(self.deref(self[r].clone()));
|
||||||
|
|
||||||
|
match d {
|
||||||
|
Addr::Con(Constant::String(_)) => self.p += 1,
|
||||||
|
_ => self.fail = true
|
||||||
|
};
|
||||||
|
},
|
||||||
|
&BuiltInInstruction::IsNonVar(r) => {
|
||||||
|
let d = self.store(self.deref(self[r].clone()));
|
||||||
|
|
||||||
|
match d {
|
||||||
|
Addr::HeapCell(_) | Addr::StackCell(..) => self.fail = true,
|
||||||
|
_ => self.p += 1
|
||||||
|
};
|
||||||
|
},
|
||||||
|
&BuiltInInstruction::IsVar(r) => {
|
||||||
|
let d = self.store(self.deref(self[r].clone()));
|
||||||
|
|
||||||
|
match d {
|
||||||
|
Addr::HeapCell(_) | Addr::StackCell(_,_) => self.p += 1,
|
||||||
|
_ => self.fail = true
|
||||||
|
};
|
||||||
|
},
|
||||||
&BuiltInInstruction::RestoreCutPolicy => {
|
&BuiltInInstruction::RestoreCutPolicy => {
|
||||||
let restore_default =
|
let restore_default =
|
||||||
if let Ok(cut_policy) = cut_policy.downcast_ref::<SetupCallCleanupCutPolicy>() {
|
if let Ok(cut_policy) = cut_policy.downcast_ref::<SetupCallCleanupCutPolicy>() {
|
||||||
@@ -1738,18 +1814,6 @@ SetupCallCleanupCutPolicy.")
|
|||||||
self.duplicate_term();
|
self.duplicate_term();
|
||||||
self.p = self.cp;
|
self.p = self.cp;
|
||||||
},
|
},
|
||||||
&ControlInstruction::CompareNumber(cmp, ref at_1, ref at_2) => {
|
|
||||||
let n1 = try_or_fail!(self, self.get_number(at_1));
|
|
||||||
let n2 = try_or_fail!(self, self.get_number(at_2));
|
|
||||||
|
|
||||||
self.compare_numbers(cmp, n1, n2);
|
|
||||||
},
|
|
||||||
&ControlInstruction::DynamicCompareNumber(cmp) => {
|
|
||||||
let n1 = try_or_fail!(self, self.arith_eval_by_metacall(temp_v!(1)));
|
|
||||||
let n2 = try_or_fail!(self, self.arith_eval_by_metacall(temp_v!(2)));
|
|
||||||
|
|
||||||
self.compare_numbers(cmp, n1, n2);
|
|
||||||
},
|
|
||||||
&ControlInstruction::DynamicIs => {
|
&ControlInstruction::DynamicIs => {
|
||||||
let a = self[temp_v!(1)].clone();
|
let a = self[temp_v!(1)].clone();
|
||||||
let result = try_or_fail!(self, self.arith_eval_by_metacall(temp_v!(2)));
|
let result = try_or_fail!(self, self.arith_eval_by_metacall(temp_v!(2)));
|
||||||
@@ -1757,70 +1821,6 @@ SetupCallCleanupCutPolicy.")
|
|||||||
self.unify(a, Addr::Con(Constant::Number(result)));
|
self.unify(a, Addr::Con(Constant::Number(result)));
|
||||||
self.p += 1;
|
self.p += 1;
|
||||||
},
|
},
|
||||||
&ControlInstruction::IsAtomic(r) => {
|
|
||||||
let d = self.store(self.deref(self[r].clone()));
|
|
||||||
|
|
||||||
match d {
|
|
||||||
Addr::Con(_) => self.p += 1,
|
|
||||||
_ => self.fail = true
|
|
||||||
};
|
|
||||||
},
|
|
||||||
&ControlInstruction::IsInteger(r) => {
|
|
||||||
let d = self.store(self.deref(self[r].clone()));
|
|
||||||
|
|
||||||
match d {
|
|
||||||
Addr::Con(Constant::Number(Number::Integer(_))) => self.p += 1,
|
|
||||||
_ => self.fail = true
|
|
||||||
};
|
|
||||||
},
|
|
||||||
&ControlInstruction::IsCompound(r) => {
|
|
||||||
let d = self.store(self.deref(self[r].clone()));
|
|
||||||
|
|
||||||
match d {
|
|
||||||
Addr::Str(_) => self.p += 1,
|
|
||||||
_ => self.fail = true
|
|
||||||
};
|
|
||||||
},
|
|
||||||
&ControlInstruction::IsFloat(r) => {
|
|
||||||
let d = self.store(self.deref(self[r].clone()));
|
|
||||||
|
|
||||||
match d {
|
|
||||||
Addr::Con(Constant::Number(Number::Float(_))) => self.p += 1,
|
|
||||||
_ => self.fail = true
|
|
||||||
};
|
|
||||||
},
|
|
||||||
&ControlInstruction::IsRational(r) => {
|
|
||||||
let d = self.store(self.deref(self[r].clone()));
|
|
||||||
|
|
||||||
match d {
|
|
||||||
Addr::Con(Constant::Number(Number::Rational(_))) => self.p += 1,
|
|
||||||
_ => self.fail = true
|
|
||||||
};
|
|
||||||
},
|
|
||||||
&ControlInstruction::IsString(r) => {
|
|
||||||
let d = self.store(self.deref(self[r].clone()));
|
|
||||||
|
|
||||||
match d {
|
|
||||||
Addr::Con(Constant::String(_)) => self.p += 1,
|
|
||||||
_ => self.fail = true
|
|
||||||
};
|
|
||||||
},
|
|
||||||
&ControlInstruction::IsNonVar(r) => {
|
|
||||||
let d = self.store(self.deref(self[r].clone()));
|
|
||||||
|
|
||||||
match d {
|
|
||||||
Addr::HeapCell(_) | Addr::StackCell(..) => self.fail = true,
|
|
||||||
_ => self.p += 1
|
|
||||||
};
|
|
||||||
},
|
|
||||||
&ControlInstruction::IsVar(r) => {
|
|
||||||
let d = self.store(self.deref(self[r].clone()));
|
|
||||||
|
|
||||||
match d {
|
|
||||||
Addr::HeapCell(_) | Addr::StackCell(_,_) => self.p += 1,
|
|
||||||
_ => self.fail = true
|
|
||||||
};
|
|
||||||
},
|
|
||||||
&ControlInstruction::EqCall => {
|
&ControlInstruction::EqCall => {
|
||||||
self.fail = self.eq_test();
|
self.fail = self.eq_test();
|
||||||
self.p += 1;
|
self.p += 1;
|
||||||
|
|||||||
@@ -194,9 +194,11 @@ impl Machine {
|
|||||||
},
|
},
|
||||||
&VarData::Temp(cn, _, _) if cn == chunk_num => {
|
&VarData::Temp(cn, _, _) if cn == chunk_num => {
|
||||||
let r = var_data.as_reg_type();
|
let r = var_data.as_reg_type();
|
||||||
let addr = self.ms[r].clone();
|
|
||||||
|
|
||||||
|
if r.reg_num() != 0 {
|
||||||
|
let addr = self.ms[r].clone();
|
||||||
heap_locs.insert(var, addr);
|
heap_locs.insert(var, addr);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
@@ -224,7 +226,13 @@ impl Machine {
|
|||||||
|
|
||||||
match self.ms.p {
|
match self.ms.p {
|
||||||
CodePtr::TopLevel(_, p) if p > 0 => {},
|
CodePtr::TopLevel(_, p) if p > 0 => {},
|
||||||
_ => break
|
_ => {
|
||||||
|
if heap_locs.is_empty() {
|
||||||
|
self.record_var_places(0, alloc_locs, heap_locs);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ macro_rules! deallocate {
|
|||||||
|
|
||||||
macro_rules! compare_number_instr {
|
macro_rules! compare_number_instr {
|
||||||
($cmp: expr, $at_1: expr, $at_2: expr) => (
|
($cmp: expr, $at_1: expr, $at_2: expr) => (
|
||||||
Line::Control(ControlInstruction::CompareNumber($cmp, $at_1, $at_2))
|
Line::BuiltIn(BuiltInInstruction::CompareNumber($cmp, $at_1, $at_2))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,50 +158,50 @@ macro_rules! retry_me_else {
|
|||||||
|
|
||||||
macro_rules! is_atomic {
|
macro_rules! is_atomic {
|
||||||
($reg:expr) => (
|
($reg:expr) => (
|
||||||
Line::Control(ControlInstruction::IsAtomic($reg))
|
Line::BuiltIn(BuiltInInstruction::IsAtomic($reg))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! is_integer {
|
macro_rules! is_integer {
|
||||||
($reg:expr) => (
|
($reg:expr) => (
|
||||||
Line::Control(ControlInstruction::IsInteger($reg))
|
Line::BuiltIn(BuiltInInstruction::IsInteger($reg))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! is_compound {
|
macro_rules! is_compound {
|
||||||
($r:expr) => (
|
($r:expr) => (
|
||||||
Line::Control(ControlInstruction::IsCompound($r))
|
Line::BuiltIn(BuiltInInstruction::IsCompound($r))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! is_float {
|
macro_rules! is_float {
|
||||||
($r:expr) => (
|
($r:expr) => (
|
||||||
Line::Control(ControlInstruction::IsFloat($r))
|
Line::BuiltIn(BuiltInInstruction::IsFloat($r))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! is_rational {
|
macro_rules! is_rational {
|
||||||
($r:expr) => (
|
($r:expr) => (
|
||||||
Line::Control(ControlInstruction::IsRational($r))
|
Line::BuiltIn(BuiltInInstruction::IsRational($r))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
macro_rules! is_nonvar {
|
macro_rules! is_nonvar {
|
||||||
($r:expr) => (
|
($r:expr) => (
|
||||||
Line::Control(ControlInstruction::IsNonVar($r))
|
Line::BuiltIn(BuiltInInstruction::IsNonVar($r))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! is_string {
|
macro_rules! is_string {
|
||||||
($r:expr) => (
|
($r:expr) => (
|
||||||
Line::Control(ControlInstruction::IsString($r))
|
Line::BuiltIn(BuiltInInstruction::IsString($r))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! is_var {
|
macro_rules! is_var {
|
||||||
($reg:expr) => (
|
($reg:expr) => (
|
||||||
Line::Control(ControlInstruction::IsVar($reg))
|
Line::BuiltIn(BuiltInInstruction::IsVar($reg))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -475,7 +475,7 @@ macro_rules! dynamic_is {
|
|||||||
|
|
||||||
macro_rules! dynamic_num_test {
|
macro_rules! dynamic_num_test {
|
||||||
($cmp:expr) => (
|
($cmp:expr) => (
|
||||||
Line::Control(ControlInstruction::DynamicCompareNumber($cmp))
|
Line::BuiltIn(BuiltInInstruction::DynamicCompareNumber($cmp))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1302,6 +1302,7 @@ fn test_queries_on_builtins()
|
|||||||
|
|
||||||
assert_prolog_success!(&mut wam, "?- X is 3 rdiv 4, rational(X).");
|
assert_prolog_success!(&mut wam, "?- X is 3 rdiv 4, rational(X).");
|
||||||
assert_prolog_failure!(&mut wam, "?- rational(3).");
|
assert_prolog_failure!(&mut wam, "?- rational(3).");
|
||||||
|
assert_prolog_failure!(&mut wam, "?- rational(f(X)).");
|
||||||
assert_prolog_failure!(&mut wam, "?- rational(\"sdfsa\").");
|
assert_prolog_failure!(&mut wam, "?- rational(\"sdfsa\").");
|
||||||
assert_prolog_failure!(&mut wam, "?- rational(atom).");
|
assert_prolog_failure!(&mut wam, "?- rational(atom).");
|
||||||
assert_prolog_failure!(&mut wam, "?- rational(structure(functor)).");
|
assert_prolog_failure!(&mut wam, "?- rational(structure(functor)).");
|
||||||
@@ -1309,6 +1310,7 @@ fn test_queries_on_builtins()
|
|||||||
assert_prolog_failure!(&mut wam, "?- rational([1,2,X]).");
|
assert_prolog_failure!(&mut wam, "?- rational([1,2,X]).");
|
||||||
|
|
||||||
assert_prolog_success!(&mut wam, "?- compound(functor(compound)).");
|
assert_prolog_success!(&mut wam, "?- compound(functor(compound)).");
|
||||||
|
assert_prolog_success!(&mut wam, "?- compound(f(X)).");
|
||||||
assert_prolog_failure!(&mut wam, "?- compound(3.14159269).");
|
assert_prolog_failure!(&mut wam, "?- compound(3.14159269).");
|
||||||
assert_prolog_failure!(&mut wam, "?- compound(3).");
|
assert_prolog_failure!(&mut wam, "?- compound(3).");
|
||||||
assert_prolog_failure!(&mut wam, "?- compound(\"sdfsa\").");
|
assert_prolog_failure!(&mut wam, "?- compound(\"sdfsa\").");
|
||||||
@@ -1319,6 +1321,7 @@ fn test_queries_on_builtins()
|
|||||||
assert_prolog_failure!(&mut wam, "?- string(functor(string)).");
|
assert_prolog_failure!(&mut wam, "?- string(functor(string)).");
|
||||||
assert_prolog_failure!(&mut wam, "?- string(3.14159269).");
|
assert_prolog_failure!(&mut wam, "?- string(3.14159269).");
|
||||||
assert_prolog_failure!(&mut wam, "?- string(3).");
|
assert_prolog_failure!(&mut wam, "?- string(3).");
|
||||||
|
assert_prolog_failure!(&mut wam, "?- string(f(X)).");
|
||||||
assert_prolog_success!(&mut wam, "?- string(\"sdfsa\").");
|
assert_prolog_success!(&mut wam, "?- string(\"sdfsa\").");
|
||||||
assert_prolog_failure!(&mut wam, "?- string(atom).");
|
assert_prolog_failure!(&mut wam, "?- string(atom).");
|
||||||
assert_prolog_failure!(&mut wam, "?- string([1,2,3]).");
|
assert_prolog_failure!(&mut wam, "?- string([1,2,3]).");
|
||||||
@@ -1326,6 +1329,7 @@ fn test_queries_on_builtins()
|
|||||||
|
|
||||||
assert_prolog_success!(&mut wam, "?- X = nonvar, nonvar(X).");
|
assert_prolog_success!(&mut wam, "?- X = nonvar, nonvar(X).");
|
||||||
assert_prolog_failure!(&mut wam, "?- nonvar(X).");
|
assert_prolog_failure!(&mut wam, "?- nonvar(X).");
|
||||||
|
assert_prolog_success!(&mut wam, "?- nonvar(f(X)).");
|
||||||
assert_prolog_success!(&mut wam, "?- nonvar(functor(nonvar)).");
|
assert_prolog_success!(&mut wam, "?- nonvar(functor(nonvar)).");
|
||||||
assert_prolog_success!(&mut wam, "?- nonvar(3.14159269).");
|
assert_prolog_success!(&mut wam, "?- nonvar(3.14159269).");
|
||||||
assert_prolog_success!(&mut wam, "?- nonvar(3).");
|
assert_prolog_success!(&mut wam, "?- nonvar(3).");
|
||||||
|
|||||||
Reference in New Issue
Block a user