From c5ffb6e1cc9c5ff880d037c53b8ebc8562be0008 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Mon, 25 May 2015 22:27:19 -0700 Subject: 1459 --- html/023jump.cc.html | 84 ++++++++++++++++++++++++++-------------------------- 1 file changed, 42 insertions(+), 42 deletions(-) (limited to 'html/023jump.cc.html') diff --git a/html/023jump.cc.html b/html/023jump.cc.html index b572fa90..e26bd7db 100644 --- a/html/023jump.cc.html +++ b/html/023jump.cc.html @@ -2,7 +2,7 @@ -~/Desktop/s/mu/023jump.cc +023jump.cc @@ -33,6 +33,15 @@ body { font-family: monospace; color: #d0d0d0; background-color: #000000; }
 //: Jump primitives
 
+:(scenario jump_can_skip_instructions)
+recipe main [
+  jump 1:offset
+  1:number <- copy 1:literal
+]
++run: jump 1:offset
+-run: 1:number <- copy 1:literal
+-mem: storing 1 in location 1
+
 :(before "End Primitive Recipe Declarations")
 JUMP,
 :(before "End Primitive Recipe Numbers")
@@ -40,33 +49,27 @@ Recipe_number["jump"] = JUMP:(before "End Primitive Recipe Implementations")
 case JUMP: {
   assert(current_instruction().ingredients.at(0).initialized);
-  assert(ingredients.size() == 1);
-  assert(ingredients.at(0).size() == 1);  // scalar
+  assert(SIZE(ingredients) == 1);
+  assert(scalar(ingredients.at(0)));
   instruction_counter += ingredients.at(0).at(0);
-  trace("run") << "jumping to instruction " << instruction_counter+1;
+  trace(Primitive_recipe_depth, "run") << "jumping to instruction " << instruction_counter+1;
   break;
 }
 
-:(scenario jump_can_skip_instructions)
-recipe main [
-  jump 1:offset
-  1:number <- copy 1:literal
-]
-+run: instruction main/0
-+run: ingredient 0 is 1
--run: instruction main/1
--mem: storing 1 in location 1
+//: special type to designate jump targets
+:(before "End Mu Types Initialization")
+Type_number["offset"] = 0;
 
 :(scenario jump_backward)
 recipe main [
   jump 1:offset  # 0 -+
-  jump 1:offset  #    |   +-+ 1
+  jump 3:offset  #    |   +-+ 1
                  #   \/  /\ |
   jump -2:offset #  2 +-->+ |
 ]                #         \/ 3
-+run: instruction main/0
-+run: instruction main/2
-+run: instruction main/1
++run: jump 1:offset
++run: jump -2:offset
++run: jump 3:offset
 
 :(before "End Primitive Recipe Declarations")
 JUMP_IF,
@@ -75,37 +78,36 @@ Recipe_number["jump-if"] = JUMP_IF:(before "End Primitive Recipe Implementations")
 case JUMP_IF: {
   assert(current_instruction().ingredients.at(1).initialized);
-  assert(ingredients.size() == 2);
-  assert(ingredients.at(0).size() == 1);  // scalar
+  assert(SIZE(ingredients) == 2);
+  assert(scalar(ingredients.at(0)));
   if (!ingredients.at(0).at(0)) {
-    trace("run") << "jump-if fell through";
+    trace(Primitive_recipe_depth, "run") << "jump-if fell through";
     break;
   }
-  assert(ingredients.at(1).size() == 1);  // scalar
+  assert(scalar(ingredients.at(1)));
   instruction_counter += ingredients.at(1).at(0);
-  trace("run") << "jumping to instruction " << instruction_counter+1;
+  trace(Primitive_recipe_depth, "run") << "jumping to instruction " << instruction_counter+1;
   break;
 }
 
 :(scenario jump_if)
 recipe main [
   jump-if 999:literal, 1:offset
-  1:number <- copy 1:literal
+  123:number <- copy 1:literal
 ]
-+run: instruction main/0
-+run: ingredient 1 is 1
++run: jump-if 999:literal, 1:offset
 +run: jumping to instruction 2
--run: instruction main/1
--mem: storing 1 in location 1
+-run: 1:number <- copy 1:literal
+-mem: storing 1 in location 123
 
 :(scenario jump_if_fallthrough)
 recipe main [
   jump-if 0:literal, 1:offset
   123:number <- copy 1:literal
 ]
-+run: instruction main/0
++run: jump-if 0:literal, 1:offset
 +run: jump-if fell through
-+run: instruction main/1
++run: 123:number <- copy 1:literal
 +mem: storing 1 in location 123
 
 :(before "End Primitive Recipe Declarations")
@@ -115,38 +117,36 @@ Recipe_number["jump-unless"] = JUMP_UNLE
 :(before "End Primitive Recipe Implementations")
 case JUMP_UNLESS: {
   assert(current_instruction().ingredients.at(1).initialized);
-  assert(ingredients.size() == 2);
-  assert(ingredients.at(0).size() == 1);  // scalar
+  assert(SIZE(ingredients) == 2);
+  assert(scalar(ingredients.at(0)));
   if (ingredients.at(0).at(0)) {
-    trace("run") << "jump-unless fell through";
+    trace(Primitive_recipe_depth, "run") << "jump-unless fell through";
     break;
   }
-  assert(ingredients.at(1).size() == 1);  // scalar
+  assert(scalar(ingredients.at(1)));
   instruction_counter += ingredients.at(1).at(0);
-  trace("run") << "jumping to instruction " << instruction_counter+1;
+  trace(Primitive_recipe_depth, "run") << "jumping to instruction " << instruction_counter+1;
   break;
 }
 
 :(scenario jump_unless)
 recipe main [
   jump-unless 0:literal, 1:offset
-  1:number <- copy 1:literal
+  123:number <- copy 1:literal
 ]
-+run: instruction main/0
-+run: ingredient 1 is 1
++run: jump-unless 0:literal, 1:offset
 +run: jumping to instruction 2
--run: instruction main/1
--mem: storing 1 in location 1
+-run: 123:number <- copy 1:literal
+-mem: storing 1 in location 123
 
 :(scenario jump_unless_fallthrough)
 recipe main [
   jump-unless 999:literal, 1:offset
   123:number <- copy 1:literal
 ]
-+run: instruction main/0
-+run: ingredient 0 is 999
++run: jump-unless 999:literal, 1:offset
 +run: jump-unless fell through
-+run: instruction main/1
++run: 123:number <- copy 1:literal
 +mem: storing 1 in location 123
 
-- cgit 1.4.1-2-gfad0