fixes, safeguards and docs for "compile-time arithmetics"

This commit is contained in:
2020-10-28 18:24:51 +01:00
parent 83996348cb
commit 02f73a21f4
8 changed files with 98 additions and 41 deletions
+9
View File
@@ -757,6 +757,15 @@ impl OpTrait for ArithOp {
ArithOp::FloatHypAcot { dst, a } => to_sexp_1_or_2("facoth", dst, a),
}
}
fn is_compile_time_evaluable(&self) -> bool {
match self {
ArithOp::Test { .. } | ArithOp::Compare { .. } | ArithOp::RangeTest { .. }
| ArithOp::FloatTest { .. } | ArithOp::FloatCompare { .. } | ArithOp::FloatRangeTest { .. } => false,
// rng is allowed... makes little sense, but it also has no side effects
_ => true, // a bold claim...
}
}
}
fn to_sexp_2_or_3(name: &str, dst: &Wr, a: &Rd, b: &Rd) -> Sexp {