about summary refs log tree commit diff stats
path: root/034exclusive_container.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 /034exclusive_container.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 '034exclusive_container.cc')
-rw-r--r--034exclusive_container.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/034exclusive_container.cc b/034exclusive_container.cc
index b2855f79..5b849916 100644
--- a/034exclusive_container.cc
+++ b/034exclusive_container.cc
@@ -89,19 +89,20 @@ Recipe_number["maybe-convert"] = MAYBE_CONVERT;
 :(before "End Primitive Recipe Implementations")
 case MAYBE_CONVERT: {
   reagent base = canonize(current_instruction().ingredients.at(0));
-  index_t base_address = base.value;
+  assert(!is_negative(base.value));
+  index_t base_address = value(base.value);
   type_number base_type = base.types.at(0);
   assert(Type[base_type].kind == exclusive_container);
   assert(isa_literal(current_instruction().ingredients.at(1)));
   index_t tag = current_instruction().ingredients.at(1).value;
   long long int result;
-  if (tag == static_cast<index_t>(Memory[base_address])) {
+  if (tag == static_cast<index_t>(value(Memory[base_address]))) {
     result = base_address+1;
   }
   else {
     result = 0;
   }
   products.resize(1);
-  products.at(0).push_back(result);
+  products.at(0).push_back(mu_integer(result));  // address must be a positive integer
   break;
 }