about summary refs log tree commit diff stats
path: root/043space.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-05-12 13:10:23 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-05-12 17:00:19 -0700
commit3663ca6c2d4c42c4a7bf6af4b2edf71dd8d10dd7 (patch)
tree330d04974b9d30bff1b16adc8d14a3d9fd77643d /043space.cc
parenta70d593dfb8eea87a898a69adeb9689a21199edf (diff)
downloadmu-3663ca6c2d4c42c4a7bf6af4b2edf71dd8d10dd7.tar.gz
1356 - snapshot #2: floating point support
I added one test to check that divide can return a float, then hacked at
the rippling failures across the entire entire codebase until all tests
pass. Now I need to look at the changes I made and see if there's a
system to them, identify other places that I missed, and figure out the
best way to cover all cases. I also need to show real rather than
encoded values in the traces, but I can't use value() inside reagent
methods because of the name clash with the member variable. So let's
take a snapshot before we attempt any refactoring. This was non-trivial
to get right.

Even if I convince myself that I've gotten it right, I might back this
all out if I can't easily *persuade others* that I've gotten it right.
Diffstat (limited to '043space.cc')
-rw-r--r--043space.cc8
1 files changed, 4 insertions, 4 deletions
diff --git a/043space.cc b/043space.cc
index b0ee7f85..24d63505 100644
--- a/043space.cc
+++ b/043space.cc
@@ -42,7 +42,7 @@ reagent absolutize(reagent x) {
 //?   cout << "not raw: " << x.to_string() << '\n'; //? 1
   assert(x.initialized);
   reagent r = x;
-  r.set_value(address(r.value, space_base(r)));
+  r.set_value(mu_integer(address(r.value, space_base(r))));  // must be a positive integer
 //?   cout << "after absolutize: " << r.value << '\n'; //? 1
   r.properties.push_back(pair<string, vector<string> >("raw", vector<string>()));
   assert(is_raw(r));
@@ -100,11 +100,11 @@ index_t space_base(const reagent& x) {
 index_t address(index_t offset, index_t base) {
   if (base == 0) return offset;  // raw
 //?   cout << base << '\n'; //? 2
-  if (offset >= static_cast<index_t>(Memory[base])) {
+  if (value(offset) >= value(Memory[base])) {
     // todo: test
-    raise << "location " << offset << " is out of bounds " << Memory[base] << '\n';
+    raise << "location " << value(offset) << " is out of bounds " << value(Memory[base]) << '\n';
   }
-  return base+1 + offset;
+  return value(base)+1 + value(offset);
 }
 
 :(after "void write_memory(reagent x, vector<long long int> data)")