process float/1 and pi/0
This commit is contained in:
@@ -138,7 +138,7 @@ The following predicates are built-in to Scryer.
|
||||
`(rem)/2`, `(mod)/2`, `(/\)/2`, `(\/)/2`, `(>>)/2`,`(<<)/2`,
|
||||
`(\)/1`, `abs/1`, `sin/1`, `cos/1`, `tan/1`, `asin/1`, `acos/1`,
|
||||
`atan/1`, `atan2/2`, `log/1`, `exp/1`, `sqrt/1`, `float/1`,
|
||||
`truncate/1`, `round/1`, `floor/1`, `ceiling/1`
|
||||
`truncate/1`, `round/1`, `floor/1`, `ceiling/1`, `pi/0`
|
||||
* Comparison operators: `>`, `<`, `=<`, `>=`, `=:=`, `=\=`.
|
||||
* `(:)/2`
|
||||
* `(@>)/2`
|
||||
|
||||
@@ -40,6 +40,10 @@ impl<'a> ArithInstructionIterator<'a> {
|
||||
match ClauseType::from(name.clone(), terms.len(), fixity.clone()) {
|
||||
ct @ ClauseType::Named(..) | ct @ ClauseType::Op(..) =>
|
||||
Ok(TermIterState::Clause(Level::Shallow, 0, cell, ct, terms)),
|
||||
ClauseType::Inlined(InlinedClauseType::IsFloat(_)) => {
|
||||
let ct = ClauseType::Named(clause_name!("float"), 1, CodeIndex::default());
|
||||
Ok(TermIterState::Clause(Level::Shallow, 0, cell, ct, terms))
|
||||
},
|
||||
_ => Err(ArithmeticError::NonEvaluableFunctor(Constant::Atom(name.clone(),
|
||||
fixity.clone()),
|
||||
terms.len()))
|
||||
@@ -233,6 +237,8 @@ impl<'a> ArithmeticEvaluator<'a>
|
||||
self.interm.push(ArithmeticTerm::Number(Number::Float(n.clone()))),
|
||||
&Constant::Rational(ref n) =>
|
||||
self.interm.push(ArithmeticTerm::Number(Number::Rational(n.clone()))),
|
||||
&Constant::Atom(ref name, _) if name.as_str() == "pi" =>
|
||||
self.interm.push(ArithmeticTerm::Number(Number::Float(OrderedFloat(f64::consts::PI)))),
|
||||
_ =>
|
||||
return Err(ArithmeticError::NonEvaluableFunctor(c.clone(), 0))
|
||||
}
|
||||
|
||||
@@ -930,6 +930,9 @@ impl MachineState {
|
||||
interms.push(Number::Float(n)),
|
||||
HeapCellValue::Addr(Addr::Con(Constant::Rational(n))) =>
|
||||
interms.push(Number::Rational(n)),
|
||||
HeapCellValue::Addr(Addr::Con(Constant::Atom(ref name, _)))
|
||||
if name.as_str() == "pi" =>
|
||||
interms.push(Number::Float(OrderedFloat(f64::consts::PI))),
|
||||
_ =>
|
||||
return Err(self.error_form(MachineError::instantiation_error(), caller))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user