about summary refs log tree commit diff stats
path: root/020run.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-09-06 11:21:50 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-09-06 11:21:50 -0700
commite5e9f7db1c5cab6c05c9881fae1fc78259ed4143 (patch)
treee7f39149a2491fe53a3197274734f5f5bd70d9ae /020run.cc
parentf37eacc948e3867c3a387dbbfad7ab9c0d5fdbef (diff)
downloadmu-e5e9f7db1c5cab6c05c9881fae1fc78259ed4143.tar.gz
2170
Diffstat (limited to '020run.cc')
-rw-r--r--020run.cc37
1 files changed, 22 insertions, 15 deletions
diff --git a/020run.cc b/020run.cc
index 4d10cdef..b280901e 100644
--- a/020run.cc
+++ b/020run.cc
@@ -145,6 +145,14 @@ inline bool routine::completed() const {
   return running_step_index >= SIZE(Recipe[running_recipe].steps);
 }
 
+//:: Startup flow
+
+//: Step 1: load all .mu files with numeric prefixes (in order)
+:(before "End Load Recipes")
+load_permanently("core.mu");
+transform_all();
+
+//: Step 2: load any .mu files provided at the commandline
 :(before "End Commandline Parsing")
 // Loading Commandline Files
 if (argc > 1) {
@@ -155,6 +163,8 @@ if (argc > 1) {
   if (Run_tests) Recipe.erase(Recipe_ordinal[string("main")]);
 }
 
+//: Step 3: if we aren't running tests, locate a recipe called 'main' and
+//: start running it.
 :(before "End Main")
 if (!Run_tests) {
   setup();
@@ -162,7 +172,6 @@ if (!Run_tests) {
 //?   START_TRACING_UNTIL_END_OF_SCOPE;
 //?   Trace_stream->collect_layers.insert("app");
   recipe_ordinal r = Recipe_ordinal[string("main")];
-//?   atexit(dump_profile);
   if (r) run(r);
   teardown();
 }
@@ -181,6 +190,8 @@ void dump_profile() {
     cerr << p->first << ": " << p->second << '\n';
   }
 }
+:(before "End One-time Setup")
+//? atexit(dump_profile);
 
 :(code)
 void cleanup_main() {
@@ -234,22 +245,9 @@ void load_all_permanently(string dir) {
 :(before "End Includes")
 #include<dirent.h>
 
-//:: On startup, load everything in core.mu
-:(before "End Load Recipes")
-load_permanently("core.mu");
-transform_all();
-
-:(code)
-// helper for tests
-void run(string form) {
-  vector<recipe_ordinal> tmp = load(form);
-  transform_all();
-  if (tmp.empty()) return;
-  run(tmp.front());
-}
-
 //:: Reading from memory, writing to memory.
 
+:(code)
 vector<double> read_memory(reagent x) {
   vector<double> result;
   if (is_literal(x)) {
@@ -311,6 +309,15 @@ bool is_mu_array(reagent r) {
   return !r.types.empty() && r.types.at(0) == Type_ordinal["array"];
 }
 
+:(code)
+// helper for tests
+void run(string form) {
+  vector<recipe_ordinal> tmp = load(form);
+  transform_all();
+  if (tmp.empty()) return;
+  run(tmp.front());
+}
+
 :(scenario run_label)
 recipe main [
   +foo