about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-03-12 19:52:10 -0800
committerKartik K. Agaram <vc@akkartik.com>2016-03-12 19:52:10 -0800
commit6700f9f2044b51e76868764f451ede7b1cb24b2d (patch)
tree34c2db9fc39b2384abc8e92bedb6444bac28999c
parent12f99381c2323841c63a4ea7709bfdb5ed8e0447 (diff)
downloadmu-6700f9f2044b51e76868764f451ede7b1cb24b2d.tar.gz
2765
Get rid of a local variable that was only serving to render unreadable
the code for reclaiming allocated memory.
-rw-r--r--020run.cc18
-rw-r--r--031address.cc4
-rw-r--r--037new.cc6
3 files changed, 14 insertions, 14 deletions
diff --git a/020run.cc b/020run.cc
index cdf265e9..baf64863 100644
--- a/020run.cc
+++ b/020run.cc
@@ -252,11 +252,11 @@ vector<double> read_memory(reagent x) {
     result.push_back(x.value);
     return result;
   }
-  long long int base = x.value;
+  // End Preprocess read_memory(x)
   long long int size = size_of(x);
   for (long long int offset = 0; offset < size; ++offset) {
-    double val = get_or_insert(Memory, base+offset);
-    trace(9999, "mem") << "location " << base+offset << " is " << no_scientific(val) << end();
+    double val = get_or_insert(Memory, x.value+offset);
+    trace(9999, "mem") << "location " << x.value+offset << " is " << no_scientific(val) << end();
     result.push_back(val);
   }
   return result;
@@ -269,17 +269,17 @@ void write_memory(reagent x, const vector<double>& data) {
   }
   if (is_dummy(x)) return;
   if (is_literal(x)) return;
-  long long int base = x.value;
-  if (base == 0) return;
+  // End Preprocess write_memory(x)
+  if (x.value == 0) return;
   if (size_mismatch(x, data)) {
     raise << maybe(current_recipe_name()) << "size mismatch in storing to " << x.original_string << " (" << size_of(x.type) << " vs " << SIZE(data) << ") at '" << to_string(current_instruction()) << "'\n" << end();
     return;
   }
-  // End write_memory(reagent x, long long int base) Special-cases
+  // End write_memory(reagent x) Special-cases
   for (long long int offset = 0; offset < SIZE(data); ++offset) {
-    assert(base+offset > 0);
-    trace(9999, "mem") << "storing " << no_scientific(data.at(offset)) << " in location " << base+offset << end();
-    put(Memory, base+offset, data.at(offset));
+    assert(x.value+offset > 0);
+    trace(9999, "mem") << "storing " << no_scientific(data.at(offset)) << " in location " << x.value+offset << end();
+    put(Memory, x.value+offset, data.at(offset));
   }
 }
 
diff --git a/031address.cc b/031address.cc
index c4228fdc..bdce2fe8 100644
--- a/031address.cc
+++ b/031address.cc
@@ -10,7 +10,7 @@ def main [
 ]
 +mem: storing 34 in location 3
 
-:(before "long long int base = x.value" following "vector<double> read_memory(reagent x)")
+:(before "End Preprocess read_memory(x)")
 canonize(x);
 
 //: similarly, write to addresses pointing at other locations using the
@@ -22,7 +22,7 @@ def main [
 ]
 +mem: storing 34 in location 2
 
-:(before "long long int base = x.value" following "void write_memory(reagent x, const vector<double>& data)")
+:(before "End Preprocess write_memory(x)")
 canonize(x);
 if (x.value == 0) {
   raise << "can't write to location 0 in '" << to_string(current_instruction()) << "'\n" << end();
diff --git a/037new.cc b/037new.cc
index 04780edc..f6b5c744 100644
--- a/037new.cc
+++ b/037new.cc
@@ -417,7 +417,7 @@ def main [
 # the /unsafe corrupts memory but fortunately we won't be running any more 'new' in this scenario
 +mem: automatically abandoning 1000
 
-:(before "End write_memory(reagent x, long long int base) Special-cases")
+:(before "End write_memory(reagent x) Special-cases")
 if (x.type->value == get(Type_ordinal, "address")
     && x.type->right
     && x.type->right->value == get(Type_ordinal, "shared")) {
@@ -432,8 +432,8 @@ if (x.type->value == get(Type_ordinal, "address")
     put(Memory, old_address, old_refcount-1);
   }
   // perform the write
-  trace(9999, "mem") << "storing " << no_scientific(data.at(0)) << " in location " << base << end();
-  put(Memory, base, new_address);
+  trace(9999, "mem") << "storing " << no_scientific(data.at(0)) << " in location " << x.value << end();
+  put(Memory, x.value, new_address);
   // increment refcount of new address
   if (new_address) {
     long long int new_refcount = get_or_insert(Memory, new_address);