IsAtomic(RegType),
IsCompound(RegType),
IsInteger(RegType),
+ IsNumber(RegType),
IsRational(RegType),
IsFloat(RegType),
IsNonVar(RegType),
m.insert(("atomic", 1), ClauseType::Inlined(InlinedClauseType::IsAtomic(r1)));
m.insert(("compound", 1), ClauseType::Inlined(InlinedClauseType::IsCompound(r1)));
m.insert(("integer", 1), ClauseType::Inlined(InlinedClauseType::IsInteger(r1)));
+ m.insert(("number", 1), ClauseType::Inlined(InlinedClauseType::IsNumber(r1)));
m.insert(("rational", 1), ClauseType::Inlined(InlinedClauseType::IsRational(r1)));
m.insert(("float", 1), ClauseType::Inlined(InlinedClauseType::IsFloat(r1)));
m.insert(("nonvar", 1), ClauseType::Inlined(InlinedClauseType::IsNonVar(r1)));
&InlinedClauseType::IsAtom(..) => "atom",
&InlinedClauseType::IsAtomic(..) => "atomic",
&InlinedClauseType::IsCompound(..) => "compound",
+ &InlinedClauseType::IsNumber(..) => "number",
&InlinedClauseType::IsInteger(..) => "integer",
&InlinedClauseType::IsRational(..) => "rational",
&InlinedClauseType::IsFloat(..) => "float",
code.push(fail!());
}
},
+ &InlinedClauseType::IsNumber(..) => match terms[0].as_ref() {
+ &Term::Constant(_, Constant::Float(_)) |
+ &Term::Constant(_, Constant::Rational(_)) |
+ &Term::Constant(_, Constant::Integer(_)) |
+ &Term::Constant(_, Constant::Fixnum(_)) |
+ &Term::Constant(_, Constant::Usize(_)) => {
+ code.push(succeed!());
+ }
+ &Term::Var(ref vr, ref name) => {
+ self.marker.reset_arg(1);
+ let r = self.mark_non_callable(name.clone(), 1, term_loc, vr, code);
+ code.push(is_number!(r));
+ }
+ _ => {
+ code.push(fail!());
+ }
+ },
&InlinedClauseType::IsNonVar(..) => match terms[0].as_ref() {
&Term::AnonVar => {
code.push(fail!());
},
&InlinedClauseType::IsInteger(..) => match terms[0].as_ref() {
&Term::Constant(_, Constant::Integer(_)) |
- &Term::Constant(_, Constant::Fixnum(_)) => {
+ &Term::Constant(_, Constant::Fixnum(_)) |
+ &Term::Constant(_, Constant::Usize(_)) => {
code.push(succeed!());
}
&Term::Var(ref vr, ref name) => {
_ => self.fail = true,
};
}
+ &InlinedClauseType::IsNumber(r1) => {
+ match self.store(self.deref(self[r1])) {
+ Addr::Float(_) => self.p += 1,
+ d => match Number::try_from((d, &self.heap)) {
+ Ok(Number::Fixnum(_)) => {
+ self.p += 1;
+ }
+ Ok(Number::Integer(_)) => {
+ self.p += 1;
+ }
+ Ok(Number::Rational(n)) => {
+ if n.denom() == &1 {
+ self.p += 1;
+ } else {
+ self.fail = true;
+ }
+ }
+ _ => {
+ self.fail = true;
+ }
+ }
+ }
+ }
&InlinedClauseType::IsRational(r1) => {
let d = self.store(self.deref(self[r1]));
};
}
+macro_rules! is_number {
+ ($r:expr) => {
+ call_clause!(ClauseType::Inlined(InlinedClauseType::IsNumber($r)), 1, 0)
+ };
+}
+
macro_rules! is_nonvar {
($r:expr) => {
call_clause!(ClauseType::Inlined(InlinedClauseType::IsNonVar($r)), 1, 0)