about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-01-17 21:20:05 -0800
committerKartik K. Agaram <vc@akkartik.com>2016-01-17 22:27:20 -0800
commit94fed2020040cf469bd47c8890ed4e609e3ed561 (patch)
tree670e2145ff2478e6859bca5b9cb0bf997539cd93
parent3063b2393aa1f76acdf59736649997da8a21bd84 (diff)
downloadmu-94fed2020040cf469bd47c8890ed4e609e3ed561.tar.gz
2561
Reorganize layers in preparation for a better, more type-safe
implementation of first-class and higher-order recipes.
-rw-r--r--043new.cc30
-rw-r--r--050scenario.cc1
-rw-r--r--057static_dispatch.cc5
-rw-r--r--061recipe.cc (renamed from 037recipe.cc)0
-rw-r--r--062scheduler.cc (renamed from 038scheduler.cc)29
-rw-r--r--063wait.cc (renamed from 039wait.cc)0
6 files changed, 33 insertions, 32 deletions
diff --git a/043new.cc b/043new.cc
index e57c6a4d..b0942397 100644
--- a/043new.cc
+++ b/043new.cc
@@ -182,25 +182,6 @@ recipe main [
 +mem: array size is 0
 +mem: storing 1 in location 3
 
-//: Make sure that each routine gets a different alloc to start.
-:(scenario new_concurrent)
-recipe f1 [
-  start-running f2:recipe
-  1:address:number/raw <- new number:type
-  # wait for f2 to complete
-  {
-    loop-unless 4:number/raw
-  }
-]
-recipe f2 [
-  2:address:number/raw <- new number:type
-  # hack: assumes scheduler implementation
-  3:boolean/raw <- equal 1:address:number/raw, 2:address:number/raw
-  # signal f2 complete
-  4:number/raw <- copy 1
-]
-+mem: storing 0 in location 3
-
 //: If a routine runs out of its initial allocation, it should allocate more.
 :(scenario new_overflow)
 % Initial_memory_per_routine = 2;
@@ -367,17 +348,6 @@ long long int new_mu_string(const string& contents) {
   return result;
 }
 
-//: pass in commandline args as ingredients to main
-//: todo: test this
-
-:(after "Update main_routine")
-Current_routine = main_routine;
-for (long long int i = 1; i < argc; ++i) {
-  vector<double> arg;
-  arg.push_back(new_mu_string(argv[i]));
-  current_call().ingredient_atoms.push_back(arg);
-}
-
 //: stash recognizes strings
 
 :(scenario stash_string)
diff --git a/050scenario.cc b/050scenario.cc
index 10c65e21..5753be73 100644
--- a/050scenario.cc
+++ b/050scenario.cc
@@ -137,7 +137,6 @@ void run_mu_scenario(const scenario& s) {
     Trace_stream = new trace_stream;
     setup();
   }
-  assert(Routines.empty());
   vector<recipe_ordinal> tmp = load("recipe scenario-"+s.name+" [ "+s.to_run+" ]");
   bind_special_scenario_names(tmp.at(0));
   transform_all();
diff --git a/057static_dispatch.cc b/057static_dispatch.cc
index bc699bcb..dc2e4cb5 100644
--- a/057static_dispatch.cc
+++ b/057static_dispatch.cc
@@ -457,3 +457,8 @@ recipe foo a:boolean -> b:number [
 ]
 +error: main: missing type for x in 'y:number <- foo x'
 +error: main: failed to find a matching call for 'y:number <- foo x'
+
+:(before "End Includes")
+using std::min;
+using std::max;
+using std::abs;
diff --git a/037recipe.cc b/061recipe.cc
index 42cc2279..42cc2279 100644
--- a/037recipe.cc
+++ b/061recipe.cc
diff --git a/038scheduler.cc b/062scheduler.cc
index 7d8127a1..39568072 100644
--- a/038scheduler.cc
+++ b/062scheduler.cc
@@ -114,7 +114,14 @@ void run_main(int argc, char* argv[]) {
   recipe_ordinal r = get(Recipe_ordinal, "main");
   if (r) {
     routine* main_routine = new routine(r);
-    // Update main_routine
+    // pass in commandline args as ingredients to main
+    // todo: test this
+    Current_routine = main_routine;
+    for (long long int i = 1; i < argc; ++i) {
+      vector<double> arg;
+      arg.push_back(new_mu_string(argv[i]));
+      current_call().ingredient_atoms.push_back(arg);
+    }
     run(main_routine);
   }
 }
@@ -504,3 +511,23 @@ case LIMIT_TIME: {
   }
   break;
 }
+
+//:: make sure that each routine gets a different alloc to start
+
+:(scenario new_concurrent)
+recipe f1 [
+  start-running f2:recipe
+  1:address:number/raw <- new number:type
+  # wait for f2 to complete
+  {
+    loop-unless 4:number/raw
+  }
+]
+recipe f2 [
+  2:address:number/raw <- new number:type
+  # hack: assumes scheduler implementation
+  3:boolean/raw <- equal 1:address:number/raw, 2:address:number/raw
+  # signal f2 complete
+  4:number/raw <- copy 1
+]
++mem: storing 0 in location 3
diff --git a/039wait.cc b/063wait.cc
index ef3d30e5..ef3d30e5 100644
--- a/039wait.cc
+++ b/063wait.cc