From 9542bb112419d575190a72baf7f964c3e32df223 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 25 Jul 2015 22:15:51 -0700 Subject: 1853 --- html/034call.cc.html | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) (limited to 'html/034call.cc.html') diff --git a/html/034call.cc.html b/html/034call.cc.html index 97bd4039..9b978a5d 100644 --- a/html/034call.cc.html +++ b/html/034call.cc.html @@ -13,16 +13,17 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 1.05em; } -.traceContains { color: #008000; } .cSpecial { color: #008000; } -.Constant { color: #00a0a0; } .SalientComment { color: #00ffff; } +.Constant { color: #00a0a0; } +.CommentedCode { color: #6c6c6c; } +.PreProc { color: #c000c0; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } .Comment { color: #9090ff; } .Delimiter { color: #a04060; } .Special { color: #ff6060; } .Identifier { color: #804000; } -.PreProc { color: #c000c0; } -.CommentedCode { color: #6c6c6c; } +.traceContains { color: #008000; } --> @@ -69,9 +70,9 @@ recipe f [ // Everytime a recipe runs another, we interrupt it and start running the new // recipe. When that finishes, we continue this one where we left off. // This requires maintaining a 'stack' of interrupted recipes or 'calls'. -struct call { +struct call { recipe_ordinal running_recipe; - long long int running_step_index; + long long int running_step_index; // End call Fields call(recipe_ordinal r) { running_recipe = r; @@ -79,15 +80,15 @@ struct call { // End call Constructor } }; -typedef list<call> call_stack; +typedef list<call> call_stack; :(replace{} "struct routine") -struct routine { +struct routine { call_stack calls; // End routine Fields routine(recipe_ordinal r); - bool completed() const; - const vector<instruction>& steps() const; + bool completed() const; + const vector<instruction>& steps() const; }; :(code) routine::routine(recipe_ordinal r) { @@ -98,30 +99,30 @@ routine::routine(recipe_ordinal r//:: now update routine's helpers :(replace{} "inline long long int& current_step_index()") -inline long long int& current_step_index() { +inline long long int& current_step_index() { assert(!Current_routine->calls.empty()); return Current_routine->calls.front().running_step_index; } :(replace{} "inline const string& current_recipe_name()") -inline const string& current_recipe_name() { +inline const string& current_recipe_name() { assert(!Current_routine->calls.empty()); return Recipe[Current_routine->calls.front().running_recipe].name; } :(replace{} "inline const instruction& current_instruction()") -inline const instruction& current_instruction() { +inline const instruction& current_instruction() { assert(!Current_routine->calls.empty()); return Recipe[Current_routine->calls.front().running_recipe].steps.at(Current_routine->calls.front().running_step_index); } :(replace{} "default:" following "End Primitive Recipe Implementations") -default: { +default: { // not a primitive; try to look up the book of recipes - if (Recipe.find(current_instruction().operation) == Recipe.end()) { - raise << "undefined operation " << current_instruction().operation << ": " << current_instruction().to_string() << '\n'; + if (Recipe.find(current_instruction().operation) == Recipe.end()) { + raise << "undefined operation " << current_instruction().operation << ": " << current_instruction().to_string() << '\n' << end(); break; } Current_routine->calls.push_front(call(current_instruction().operation)); -complete_call: + call_housekeeping: ++Callstack_depth; assert(Callstack_depth < 9000); // 9998-101 plus cushion continue; // not done with caller; don't increment current_step_index() @@ -130,11 +131,11 @@ complete_call: //:: finally, we need to fix the termination conditions for the run loop :(replace{} "inline bool routine::completed() const") -inline bool routine::completed() const { +inline bool routine::completed() const { return calls.empty(); } -inline const vector<instruction>& routine::steps() const { +inline const vector<instruction>& routine::steps() const { assert(!calls.empty()); return Recipe[calls.front().running_recipe].steps; } @@ -142,12 +143,12 @@ inline const vector<instruction>& routine::steps:(before "Running One Instruction") // when we reach the end of one call, we may reach the end of the one below // it, and the one below that, and so on -while (current_step_index() >= SIZE(Current_routine->steps())) { +while (current_step_index() >= SIZE(Current_routine->steps())) { // Falling Through End Of Recipe --Callstack_depth; -//? cerr << "reply " << Current_routine->calls.size() << '\n'; //? 2 +//? cerr << "reply " << SIZE(Current_routine->calls) << '\n'; //? 2 Current_routine->calls.pop_front(); - if (Current_routine->calls.empty()) return; + if (Current_routine->calls.empty()) return; // Complete Call Fallthrough // todo: no products returned warning ++current_step_index(); @@ -155,7 +156,7 @@ while (current_step_index :(before "End Includes") #include <stack> -using std::stack; +using std::stack; -- cgit 1.4.1-2-gfad0