about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-01-25 19:32:03 -0800
committerKartik K. Agaram <vc@akkartik.com>2016-01-25 19:32:03 -0800
commit8f0a9149536d951fc9d18e473d57a39efe3d9b7d (patch)
tree9f8a0e548639a39c555570a3744fea8a5bcbdb08
parent50c4ac802eec5730d9dedc73fb51a34b73063f71 (diff)
downloadmu-8f0a9149536d951fc9d18e473d57a39efe3d9b7d.tar.gz
2603 - bugfix: defining main with commandline args
Pretty hacky fix: we simply suppress static dispatch for main.
-rw-r--r--011load.cc2
-rw-r--r--057static_dispatch.cc2
-rw-r--r--062scheduler.cc21
3 files changed, 12 insertions, 13 deletions
diff --git a/011load.cc b/011load.cc
index 95631151..2c99bfff 100644
--- a/011load.cc
+++ b/011load.cc
@@ -59,7 +59,7 @@ long long int slurp_recipe(istream& in) {
   }
   slurp_body(in, result);
   // End recipe Body(result)
-  get_or_insert(Recipe, get(Recipe_ordinal, result.name)) = result;
+  put(Recipe, get(Recipe_ordinal, result.name), result);
   // track added recipes because we may need to undo them in tests; see below
   Recently_added_recipes.push_back(get(Recipe_ordinal, result.name));
   return get(Recipe_ordinal, result.name);
diff --git a/057static_dispatch.cc b/057static_dispatch.cc
index 1034dc90..4e0cb76a 100644
--- a/057static_dispatch.cc
+++ b/057static_dispatch.cc
@@ -30,7 +30,7 @@ for (map<string, vector<recipe_ordinal> >::iterator p = Recipe_variants.begin();
 }
 
 :(before "End Load Recipe Header(result)")
-if (contains_key(Recipe_ordinal, result.name)) {
+if (result.name != "main" && contains_key(Recipe_ordinal, result.name)) {
   const recipe_ordinal r = get(Recipe_ordinal, result.name);
 //?   cerr << result.name << ": " << contains_key(Recipe, r) << (contains_key(Recipe, r) ? get(Recipe, r).has_header : 0) << matching_variant_name(result) << '\n';
   if (!contains_key(Recipe, r) || get(Recipe, r).has_header) {
diff --git a/062scheduler.cc b/062scheduler.cc
index a68646d7..ca22caae 100644
--- a/062scheduler.cc
+++ b/062scheduler.cc
@@ -112,18 +112,17 @@ Current_routine = NULL;
 :(replace{} "void run_main(int argc, char* argv[])")
 void run_main(int argc, char* argv[]) {
   recipe_ordinal r = get(Recipe_ordinal, "main");
-  if (r) {
-    routine* main_routine = new routine(r);
-    // 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);
+  assert(r);
+  routine* main_routine = new routine(r);
+  // 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);
 }
 
 //:: To schedule new routines to run, call 'start-running'.