aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2014-08-17 09:15:57 +0000
committerdos-reis <gdr@axiomatics.org>2014-08-17 09:15:57 +0000
commitc50f5cd58337e96609479484c2cfd7fcd80db182 (patch)
treec7bda8ed377403803910cdc3ffddc1cab8b1cd49 /src/include
parent92de8ff340378dbd50678babe98ac8a5ffd8bc9c (diff)
downloadopen-axiom-c50f5cd58337e96609479484c2cfd7fcd80db182.tar.gz
OpenAxiom::VM::Fixnum is now a distinct type.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/vm.H19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/include/vm.H b/src/include/vm.H
index d386e4c3..0ef6f973 100644
--- a/src/include/vm.H
+++ b/src/include/vm.H
@@ -166,25 +166,28 @@ namespace OpenAxiom {
// VM integers are divided into classes: small numbers,
// and large numbers. A small number fits entirely in a register.
// A large number is allocated and represented by its address.
- using Fixnum = intptr_t;
+ using FixnumBits = intptr_t;
+ enum class Fixnum : FixnumBits {
+ minimum = FixnumBits(~(~ValueBits() >> 2)),
+ zero = FixnumBits(0),
+ one = FixnumBits(1),
+ maximum = FixnumBits(~ValueBits() >> 2),
+ };
constexpr ValueBits fix_tag = 0x1;
constexpr bool is_fixnum(Value v) {
- return (v & 0x1) == fix_tag;
+ return (ValueBits(v) & 0x1) == fix_tag;
}
constexpr Fixnum to_fixnum(Value v) {
- return Fixnum(v >> 1);
+ return Fixnum(FixnumBits(v) >> 1);
}
constexpr Value from_fixnum(Fixnum i) {
- return (Fixnum(i) << 1 ) | fix_tag;
+ return (ValueBits(i) << 1 ) | fix_tag;
}
- constexpr Fixnum fixnum_maximum = to_fixnum(~Value{ });
- constexpr Fixnum fixnum_minimum = -fixnum_maximum - 1;
-
// ------------
// -- String --
// ------------
@@ -262,7 +265,7 @@ namespace OpenAxiom {
inline Fixnum count_nodes(Value v) {
if (auto p = to_pair_if_can(v))
return count_nodes(p);
- return 0;
+ return Fixnum::zero;
}
// ---------------