about summary refs log tree commit diff stats
path: root/038scheduler.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-10-01 17:30:14 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-10-01 17:30:14 -0700
commit166e3c0d407a967d25d793b6a9db56ffd7a03727 (patch)
tree73b18adca78fda2a4b1ef5a65fe3851e77248d93 /038scheduler.cc
parent16386f766ec1e347db8a19ebfd9cedaa9b281a5f (diff)
downloadmu-166e3c0d407a967d25d793b6a9db56ffd7a03727.tar.gz
2232
Diffstat (limited to '038scheduler.cc')
-rw-r--r--038scheduler.cc82
1 files changed, 51 insertions, 31 deletions
diff --git a/038scheduler.cc b/038scheduler.cc
index 2ae1b3b3..6158ab41 100644
--- a/038scheduler.cc
+++ b/038scheduler.cc
@@ -144,20 +144,20 @@ parent_index = -1;
 START_RUNNING,
 :(before "End Primitive Recipe Numbers")
 Recipe_ordinal["start-running"] = START_RUNNING;
-:(before "End Primitive Recipe Implementations")
+:(before "End Primitive Recipe Checks")
 case START_RUNNING: {
-  if (ingredients.empty()) {
-    raise << "'start-running' requires at least one ingredient: the recipe to start running\n" << end();
-    break;
-  }
-  if (!scalar(ingredients.at(0))) {
-    raise << "first ingredient of 'start-running' should be a recipe, but got " << current_instruction().ingredients.at(0).original_string << '\n' << end();
+  if (inst.ingredients.empty()) {
+    raise << maybe(Recipe[r].name) << "'start-running' requires at least one ingredient: the recipe to start running\n" << end();
     break;
   }
-  if (!ingredients.at(0).at(0)) {
-    raise << "'start-running' received non-existent recipe: '" << current_instruction().to_string() << "'\n" << end();
+  if (!is_mu_scalar(inst.ingredients.at(0))) {
+    raise << maybe(Recipe[r].name) << "first ingredient of 'start-running' should be a recipe, but got " << inst.ingredients.at(0).original_string << '\n' << end();
     break;
   }
+  break;
+}
+:(before "End Primitive Recipe Implementations")
+case START_RUNNING: {
   routine* new_routine = new routine(ingredients.at(0).at(0));
   new_routine->parent_index = Current_routine_index;
   // populate ingredients
@@ -330,16 +330,20 @@ recipe f2 [
 ROUTINE_STATE,
 :(before "End Primitive Recipe Numbers")
 Recipe_ordinal["routine-state"] = ROUTINE_STATE;
-:(before "End Primitive Recipe Implementations")
+:(before "End Primitive Recipe Checks")
 case ROUTINE_STATE: {
-  if (SIZE(ingredients) != 1) {
-    raise << maybe(current_recipe_name()) << "'routine-state' requires exactly one ingredient, but got " << current_instruction().to_string() << '\n' << end();
+  if (SIZE(inst.ingredients) != 1) {
+    raise << maybe(Recipe[r].name) << "'routine-state' requires exactly one ingredient, but got " << inst.to_string() << '\n' << end();
     break;
   }
-  if (!scalar(ingredients.at(0))) {
-    raise << maybe(current_recipe_name()) << "first ingredient of 'routine-state' should be a routine id generated by 'start-running', but got " << current_instruction().ingredients.at(0).original_string << '\n' << end();
+  if (!is_mu_scalar(inst.ingredients.at(0))) {
+    raise << maybe(Recipe[r].name) << "first ingredient of 'routine-state' should be a routine id generated by 'start-running', but got " << inst.ingredients.at(0).original_string << '\n' << end();
     break;
   }
+  break;
+}
+:(before "End Primitive Recipe Implementations")
+case ROUTINE_STATE: {
   long long int id = ingredients.at(0).at(0);
   long long int result = -1;
   for (long long int i = 0; i < SIZE(Routines); ++i) {
@@ -359,16 +363,20 @@ case ROUTINE_STATE: {
 RESTART,
 :(before "End Primitive Recipe Numbers")
 Recipe_ordinal["restart"] = RESTART;
-:(before "End Primitive Recipe Implementations")
+:(before "End Primitive Recipe Checks")
 case RESTART: {
-  if (SIZE(ingredients) != 1) {
-    raise << maybe(current_recipe_name()) << "'restart' requires exactly one ingredient, but got " << current_instruction().to_string() << '\n' << end();
+  if (SIZE(inst.ingredients) != 1) {
+    raise << maybe(Recipe[r].name) << "'restart' requires exactly one ingredient, but got " << inst.to_string() << '\n' << end();
     break;
   }
-  if (!scalar(ingredients.at(0))) {
-    raise << maybe(current_recipe_name()) << "first ingredient of 'restart' should be a routine id generated by 'start-running', but got " << current_instruction().ingredients.at(0).original_string << '\n' << end();
+  if (!is_mu_scalar(inst.ingredients.at(0))) {
+    raise << maybe(Recipe[r].name) << "first ingredient of 'restart' should be a routine id generated by 'start-running', but got " << inst.ingredients.at(0).original_string << '\n' << end();
     break;
   }
+  break;
+}
+:(before "End Primitive Recipe Implementations")
+case RESTART: {
   long long int id = ingredients.at(0).at(0);
   for (long long int i = 0; i < SIZE(Routines); ++i) {
     if (Routines.at(i)->id == id) {
@@ -383,16 +391,20 @@ case RESTART: {
 STOP,
 :(before "End Primitive Recipe Numbers")
 Recipe_ordinal["stop"] = STOP;
-:(before "End Primitive Recipe Implementations")
+:(before "End Primitive Recipe Checks")
 case STOP: {
-  if (SIZE(ingredients) != 1) {
-    raise << maybe(current_recipe_name()) << "'stop' requires exactly one ingredient, but got " << current_instruction().to_string() << '\n' << end();
+  if (SIZE(inst.ingredients) != 1) {
+    raise << maybe(Recipe[r].name) << "'stop' requires exactly one ingredient, but got " << inst.to_string() << '\n' << end();
     break;
   }
-  if (!scalar(ingredients.at(0))) {
-    raise << maybe(current_recipe_name()) << "first ingredient of 'stop' should be a routine id generated by 'start-running', but got " << current_instruction().ingredients.at(0).original_string << '\n' << end();
+  if (!is_mu_scalar(inst.ingredients.at(0))) {
+    raise << maybe(Recipe[r].name) << "first ingredient of 'stop' should be a routine id generated by 'start-running', but got " << inst.ingredients.at(0).original_string << '\n' << end();
     break;
   }
+  break;
+}
+:(before "End Primitive Recipe Implementations")
+case STOP: {
   long long int id = ingredients.at(0).at(0);
   for (long long int i = 0; i < SIZE(Routines); ++i) {
     if (Routines.at(i)->id == id) {
@@ -407,6 +419,10 @@ case STOP: {
 _DUMP_ROUTINES,
 :(before "End Primitive Recipe Numbers")
 Recipe_ordinal["$dump-routines"] = _DUMP_ROUTINES;
+:(before "End Primitive Recipe Checks")
+case _DUMP_ROUTINES: {
+  break;
+}
 :(before "End Primitive Recipe Implementations")
 case _DUMP_ROUTINES: {
   for (long long int i = 0; i < SIZE(Routines); ++i) {
@@ -457,20 +473,24 @@ limit = -1;  /* no limit */
 LIMIT_TIME,
 :(before "End Primitive Recipe Numbers")
 Recipe_ordinal["limit-time"] = LIMIT_TIME;
-:(before "End Primitive Recipe Implementations")
+:(before "End Primitive Recipe Checks")
 case LIMIT_TIME: {
-  if (SIZE(ingredients) != 2) {
-    raise << maybe(current_recipe_name()) << "'limit-time' requires exactly two ingredient, but got " << current_instruction().to_string() << '\n' << end();
+  if (SIZE(inst.ingredients) != 2) {
+    raise << maybe(Recipe[r].name) << "'limit-time' requires exactly two ingredient, but got " << inst.to_string() << '\n' << end();
     break;
   }
-  if (!scalar(ingredients.at(0))) {
-    raise << maybe(current_recipe_name()) << "first ingredient of 'limit-time' should be a routine id generated by 'start-running', but got " << current_instruction().ingredients.at(0).original_string << '\n' << end();
+  if (!is_mu_scalar(inst.ingredients.at(0))) {
+    raise << maybe(Recipe[r].name) << "first ingredient of 'limit-time' should be a routine id generated by 'start-running', but got " << inst.ingredients.at(0).original_string << '\n' << end();
     break;
   }
-  if (!scalar(ingredients.at(1))) {
-    raise << maybe(current_recipe_name()) << "second ingredient of 'limit-time' should be a number (of instructions to run for), but got " << current_instruction().ingredients.at(1).original_string << '\n' << end();
+  if (!is_mu_scalar(inst.ingredients.at(1))) {
+    raise << maybe(Recipe[r].name) << "second ingredient of 'limit-time' should be a number (of instructions to run for), but got " << inst.ingredients.at(1).original_string << '\n' << end();
     break;
   }
+  break;
+}
+:(before "End Primitive Recipe Implementations")
+case LIMIT_TIME: {
   long long int id = ingredients.at(0).at(0);
   for (long long int i = 0; i < SIZE(Routines); ++i) {
     if (Routines.at(i)->id == id) {