about summary refs log tree commit diff stats
path: root/030container.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-08-02 22:18:19 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-08-02 22:18:19 -0700
commitcfb142b9601cc648f15bf5738a3df09a23835e41 (patch)
tree670f168fbbf2693b17d679939bd1c203de1c3837 /030container.cc
parent37900254f083364dcfbb80cf7119c230a0b603d6 (diff)
downloadmu-cfb142b9601cc648f15bf5738a3df09a23835e41.tar.gz
1923
Still iterating on the right way to handle incorrect number of
ingredients. My first idea of creating null results doesn't really work
once they're used in later instructions. Just add a warning at one place
in the run loop, but otherwise only add products when there's something
to save in them.

Undoes some work around commit 1886.
Diffstat (limited to '030container.cc')
-rw-r--r--030container.cc5
1 files changed, 2 insertions, 3 deletions
diff --git a/030container.cc b/030container.cc
index 55de2a2d..6159f3a0 100644
--- a/030container.cc
+++ b/030container.cc
@@ -107,7 +107,6 @@ GET,
 Recipe_ordinal["get"] = GET;
 :(before "End Primitive Recipe Implementations")
 case GET: {
-  products.resize(1);
   if (SIZE(ingredients) != 2) {
     raise << current_recipe_name() << ": 'get' expects exactly 2 ingredients in '" << current_instruction().to_string() << "'\n" << end();
     break;
@@ -143,7 +142,7 @@ case GET: {
   reagent tmp;
   tmp.set_value(src);
   tmp.types.push_back(src_type);
-  products.at(0) = read_memory(tmp);
+  products.push_back(read_memory(tmp));
   break;
 }
 
@@ -192,7 +191,6 @@ GET_ADDRESS,
 Recipe_ordinal["get-address"] = GET_ADDRESS;
 :(before "End Primitive Recipe Implementations")
 case GET_ADDRESS: {
-  products.resize(1);
   reagent base = current_instruction().ingredients.at(0);
   long long int base_address = base.value;
   if (base_address == 0) {
@@ -219,6 +217,7 @@ case GET_ADDRESS: {
     result += size_of(Type[base_type].elements.at(i));
   }
   trace(Primitive_recipe_depth, "run") << "address to copy is " << result << end();
+  products.resize(1);
   products.at(0).push_back(result);
   break;
 }