about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-04-23 22:11:48 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-04-24 00:35:50 -0700
commitc9a5a7badacd8dba9b5d7cf683301c8ead4b1f12 (patch)
tree3062a12c4fda9757ef633e56f0abc8b8efbe594b
parent7bf9212fd47e505711cc0873d30456e3d793034d (diff)
downloadmu-c9a5a7badacd8dba9b5d7cf683301c8ead4b1f12.tar.gz
2862
Layers 0-29 are now a complete rudimentary platform except for pointers
and indirection.
-rw-r--r--020run.cc2
-rw-r--r--026call.cc (renamed from 034call.cc)0
-rw-r--r--027call_ingredient.cc (renamed from 035call_ingredient.cc)18
-rw-r--r--028call_reply.cc (renamed from 036call_reply.cc)17
-rw-r--r--030address.cc8
-rw-r--r--031container.cc14
-rw-r--r--032array.cc14
7 files changed, 40 insertions, 33 deletions
diff --git a/020run.cc b/020run.cc
index 1bc4f0bc..fbe53f15 100644
--- a/020run.cc
+++ b/020run.cc
@@ -34,7 +34,7 @@ def main [
 
 :(before "End Types")
 // Book-keeping while running a recipe.
-//: Later layers will change this.
+//: Later layers will replace this.
 struct routine {
   recipe_ordinal running_recipe;
   int running_step_index;
diff --git a/034call.cc b/026call.cc
index dd240936..dd240936 100644
--- a/034call.cc
+++ b/026call.cc
diff --git a/035call_ingredient.cc b/027call_ingredient.cc
index 4feaeed8..f109076b 100644
--- a/035call_ingredient.cc
+++ b/027call_ingredient.cc
@@ -31,7 +31,7 @@ next_ingredient_to_process = 0;
 for (int i = 0; i < SIZE(ingredients); ++i) {
   current_call().ingredient_atoms.push_back(ingredients.at(i));
   reagent ingredient = call_instruction.ingredients.at(i);
-  canonize_type(ingredient);
+  // End Compute Call Ingredient
   current_call().ingredients.push_back(ingredient);
 }
 
@@ -52,7 +52,7 @@ case NEXT_INGREDIENT: {
   assert(!Current_routine->calls.empty());
   if (current_call().next_ingredient_to_process < SIZE(current_call().ingredient_atoms)) {
     reagent product = current_instruction().products.at(0);
-    canonize_type(product);
+    // End Preprocess NEXT_INGREDIENT product
     if (current_recipe_name() == "main") {
       // no ingredient types since the call might be implicit; assume ingredients are always strings
       // todo: how to test this?
@@ -169,3 +169,17 @@ case INGREDIENT: {
   }
   break;
 }
+
+//: a particularly common array type is the string, or address:array:character
+:(code)
+bool is_mu_string(const reagent& x) {
+  return x.type
+    && x.type->value == get(Type_ordinal, "address")
+    && x.type->right
+    && x.type->right->value == get(Type_ordinal, "shared")
+    && x.type->right->right
+    && x.type->right->right->value == get(Type_ordinal, "array")
+    && x.type->right->right->right
+    && x.type->right->right->right->value == get(Type_ordinal, "character")
+    && x.type->right->right->right->right == NULL;
+}
diff --git a/036call_reply.cc b/028call_reply.cc
index 9f6718c2..df5fa557 100644
--- a/036call_reply.cc
+++ b/028call_reply.cc
@@ -45,20 +45,6 @@ case REPLY: {
   break;  // continue to process rest of *caller* instruction
 }
 
-//: Products can include containers and exclusive containers, addresses and arrays.
-:(scenario reply_container)
-def main [
-  3:point <- f 2
-]
-def f [
-  12:number <- next-ingredient
-  13:number <- copy 35
-  return 12:point/raw
-]
-+run: result 0 is [2, 35]
-+mem: storing 2 in location 3
-+mem: storing 35 in location 4
-
 //: Types in reply instructions are checked ahead of time.
 
 :(before "End Checks")
@@ -83,9 +69,8 @@ void check_types_of_reply_instructions(recipe_ordinal r) {
       }
       for (int i = 0; i < SIZE(caller_instruction.products); ++i) {
         reagent lhs = reply_inst.ingredients.at(i);
-        canonize_type(lhs);
         reagent rhs = caller_instruction.products.at(i);
-        canonize_type(rhs);
+        // End Check REPLY Copy(lhs, rhs)
         if (!types_coercible(rhs, lhs)) {
           raise << maybe(callee.name) << reply_inst.name << " ingredient " << lhs.original_string << " can't be saved in " << rhs.original_string << '\n' << end();
           raise << to_string(lhs.type) << " vs " << to_string(rhs.type) << '\n' << end();
diff --git a/030address.cc b/030address.cc
index 47431b63..5f86b30a 100644
--- a/030address.cc
+++ b/030address.cc
@@ -79,6 +79,14 @@ void lookup_memory(reagent& x) {
 :(after "bool is_mu_boolean(reagent r)")
   if (!canonize_type(r)) return false;
 
+:(before "End Compute Call Ingredient")
+canonize_type(ingredient);
+:(before "End Preprocess NEXT_INGREDIENT product")
+canonize_type(product);
+:(before "End Check REPLY Copy(lhs, rhs)
+canonize_type(lhs);
+canonize_type(rhs);
+
 :(code)
 bool canonize_type(reagent& r) {
   while (has_property(r, "lookup")) {
diff --git a/031container.cc b/031container.cc
index 32b38bc7..963afb68 100644
--- a/031container.cc
+++ b/031container.cc
@@ -51,6 +51,20 @@ def main [
 ]
 +mem: storing 36 in location 17
 
+//: Products of recipes can include containers and exclusive containers, addresses and arrays.
+:(scenario reply_container)
+def main [
+  3:point <- f 2
+]
+def f [
+  12:number <- next-ingredient
+  13:number <- copy 35
+  return 12:point/raw
+]
++run: result 0 is [2, 35]
++mem: storing 2 in location 3
++mem: storing 35 in location 4
+
 //: Containers can be checked for equality with a single instruction just like
 //: numbers, no matter how large they are.
 
diff --git a/032array.cc b/032array.cc
index e54b7ea6..44d063d9 100644
--- a/032array.cc
+++ b/032array.cc
@@ -465,17 +465,3 @@ case LENGTH: {
 recipe_ordinal r = current_instruction().operation;
 if (r == CREATE_ARRAY || r == INDEX || r == PUT_INDEX || r == LENGTH)
   return false;
-
-//: a particularly common array type is the string, or address:array:character
-:(code)
-bool is_mu_string(const reagent& x) {
-  return x.type
-    && x.type->value == get(Type_ordinal, "address")
-    && x.type->right
-    && x.type->right->value == get(Type_ordinal, "shared")
-    && x.type->right->right
-    && x.type->right->right->value == get(Type_ordinal, "array")
-    && x.type->right->right->right
-    && x.type->right->right->right->value == get(Type_ordinal, "character")
-    && x.type->right->right->right->right == NULL;
-}