diff options
-rw-r--r-- | 001help.cc | 2 | ||||
-rw-r--r-- | 011load.cc | 3 | ||||
-rw-r--r-- | 013update_operation.cc | 2 | ||||
-rw-r--r-- | 020run.cc | 12 | ||||
-rw-r--r-- | 021check_instruction.cc | 3 | ||||
-rw-r--r-- | 030container.cc | 15 | ||||
-rw-r--r-- | 031merge.cc | 4 | ||||
-rw-r--r-- | 036refcount.cc | 3 | ||||
-rw-r--r-- | 037abandon.cc | 3 | ||||
-rw-r--r-- | 043space.cc | 7 | ||||
-rw-r--r-- | 044space_surround.cc | 3 | ||||
-rw-r--r-- | 050scenario.cc | 6 | ||||
-rw-r--r-- | 073wait.cc | 3 | ||||
-rw-r--r-- | html/001help.cc.html | 2 | ||||
-rw-r--r-- | html/011load.cc.html | 3 | ||||
-rw-r--r-- | html/013update_operation.cc.html | 2 | ||||
-rw-r--r-- | html/020run.cc.html | 12 | ||||
-rw-r--r-- | html/021check_instruction.cc.html | 3 | ||||
-rw-r--r-- | html/030container.cc.html | 15 | ||||
-rw-r--r-- | html/031merge.cc.html | 4 | ||||
-rw-r--r-- | html/036refcount.cc.html | 3 | ||||
-rw-r--r-- | html/037abandon.cc.html | 3 | ||||
-rw-r--r-- | html/043space.cc.html | 7 | ||||
-rw-r--r-- | html/044space_surround.cc.html | 3 | ||||
-rw-r--r-- | html/050scenario.cc.html | 6 | ||||
-rw-r--r-- | html/073wait.cc.html | 3 | ||||
-rw-r--r-- | vimrc.vim | 4 |
27 files changed, 81 insertions, 55 deletions
diff --git a/001help.cc b/001help.cc index 15ebffa6..b7088957 100644 --- a/001help.cc +++ b/001help.cc @@ -3,7 +3,7 @@ :(before "End Commandline Parsing") if (argc <= 1 || is_equal(argv[1], "--help")) { - // this is the functionality later layers will provide + //: this is the functionality later layers will provide // currently no automated tests for commandline arg parsing if (argc <= 1) { cerr << "Please provide a Mu program to run.\n" diff --git a/011load.cc b/011load.cc index 451521f4..0a473394 100644 --- a/011load.cc +++ b/011load.cc @@ -50,7 +50,6 @@ vector<recipe_ordinal> load(istream& in) { } // return the recipe ordinal slurped, or -1 if it failed -// (later layers will cause failures) int slurp_recipe(istream& in) { recipe result; result.name = next_word(in); @@ -145,7 +144,7 @@ bool next_instruction(istream& in, instruction* curr) { return false; } curr->old_name = curr->name = *p; ++p; - // curr->operation will be set in a later layer + // curr->operation will be set at transform time for (; p != words.end(); ++p) curr->ingredients.push_back(reagent(*p)); diff --git a/013update_operation.cc b/013update_operation.cc index 6f98dc6e..806f69c2 100644 --- a/013update_operation.cc +++ b/013update_operation.cc @@ -21,7 +21,7 @@ void update_instruction_operations(const recipe_ordinal r) { } } -// hook to suppress inserting recipe name into errors (for later layers) +// hook to suppress inserting recipe name into errors string maybe(string s) { return s + ": "; } diff --git a/020run.cc b/020run.cc index 54b19c98..82cba458 100644 --- a/020run.cc +++ b/020run.cc @@ -63,7 +63,7 @@ void run(const recipe_ordinal r) { } void run_current_routine() { - while (should_continue_running(Current_routine)) { // beware: later layers modify Current_routine here + while (should_continue_running(Current_routine)) { // beware: may modify Current_routine // Running One Instruction if (current_instruction().is_label) { ++current_step_index(); continue; } trace(Initial_callstack_depth + Trace_stream->callstack_depth, "run") << to_string(current_instruction()) << end(); @@ -106,6 +106,7 @@ void run_current_routine() { stop_running_current_routine:; } +//: hook replaced in a later layer bool should_continue_running(const routine* current_routine) { assert(current_routine == Current_routine); // argument passed in just to make caller readable above return !Current_routine->completed(); @@ -117,29 +118,34 @@ bool should_copy_ingredients() { } //: Some helpers. -//: We'll need to override these later as we change the definition of routine. -//: Important that they return referrences into the routine. +//: Important that they return references into the current routine. +//: hook replaced in a later layer int& current_step_index() { return Current_routine->running_step_index; } +//: hook replaced in a later layer const string& current_recipe_name() { return get(Recipe, Current_routine->running_recipe).name; } +//: hook replaced in a later layer const recipe& current_recipe() { return get(Recipe, Current_routine->running_recipe); } +//: hook replaced in a later layer const instruction& current_instruction() { return get(Recipe, Current_routine->running_recipe).steps.at(Current_routine->running_step_index); } +//: hook replaced in a later layer bool routine::completed() const { return running_step_index >= SIZE(get(Recipe, running_recipe).steps); } +//: hook replaced in a later layer const vector<instruction>& routine::steps() const { return get(Recipe, running_recipe).steps; } diff --git a/021check_instruction.cc b/021check_instruction.cc index 2a8ef70f..089033dc 100644 --- a/021check_instruction.cc +++ b/021check_instruction.cc @@ -123,8 +123,7 @@ bool types_match(const reagent& to, const reagent& from) { return types_strictly_match(to, from); } -// copy arguments because later layers will want to make changes to them -// without perturbing the caller +//: copy arguments for later layers bool types_strictly_match(reagent/*copy*/ to, reagent/*copy*/ from) { // End Preprocess types_strictly_match(reagent to, reagent from) if (is_literal(from) && to.type->value == get(Type_ordinal, "number")) return true; diff --git a/030container.cc b/030container.cc index 3e09fec5..4d5399c3 100644 --- a/030container.cc +++ b/030container.cc @@ -382,7 +382,8 @@ case GET: { break; } int offset_value = 0; - if (is_integer(offset.name)) // later layers permit non-integer offsets + //: later layers will permit non-integer offsets + if (is_integer(offset.name)) offset_value = to_integer(offset.name); else offset_value = offset.value; @@ -393,7 +394,8 @@ case GET: { if (inst.products.empty()) break; reagent/*copy*/ product = inst.products.at(0); // Update GET product in Check - const reagent/*copy*/ element = element_type(base.type, offset_value); // not just base_type because later layers will introduce compound types + //: use base.type rather than base_type because later layers will introduce compound types + const reagent/*copy*/ element = element_type(base.type, offset_value); if (!types_coercible(product, element)) { raise << maybe(get(Recipe, r).name) << "'get " << base.original_string << ", " << offset.original_string << "' should write to " << names_to_string_without_quotes(element.type) << " but '" << product.name << "' has type " << names_to_string_without_quotes(product.type) << '\n' << end(); break; @@ -416,7 +418,8 @@ case GET: { assert(base.metadata.size); int src = base_address + base.metadata.offset.at(offset); trace(9998, "run") << "address to copy is " << src << end(); - reagent/*copy*/ element = element_type(base.type, offset); // not just base_type because later layers will introduce compound types + //: use base.type rather than base_type because later layers will introduce compound types + reagent/*copy*/ element = element_type(base.type, offset); element.set_value(src); trace(9998, "run") << "its type is " << names_to_string(element.type) << end(); // Read element @@ -529,7 +532,8 @@ case PUT: { break; } int offset_value = 0; - if (is_integer(offset.name)) { // later layers permit non-integer offsets + //: later layers will permit non-integer offsets + if (is_integer(offset.name)) { offset_value = to_integer(offset.name); if (offset_value < 0 || offset_value >= SIZE(get(Type, base_type->value).elements)) { raise << maybe(get(Recipe, r).name) << "invalid offset '" << offset_value << "' for '" << get(Type, base_type->value).name << "'\n" << end(); @@ -540,7 +544,8 @@ case PUT: { offset_value = offset.value; } const reagent& value = inst.ingredients.at(2); - const reagent& element = element_type(base.type, offset_value); // not just base_type because later layers will introduce compound types + //: use base.type rather than base_type because later layers will introduce compound types + const reagent& element = element_type(base.type, offset_value); if (!types_coercible(element, value)) { raise << maybe(get(Recipe, r).name) << "'put " << base.original_string << ", " << offset.original_string << "' should write to " << names_to_string_without_quotes(element.type) << " but '" << value.name << "' has type " << names_to_string_without_quotes(value.type) << '\n' << end(); break; diff --git a/031merge.cc b/031merge.cc index 14999123..3faee8d8 100644 --- a/031merge.cc +++ b/031merge.cc @@ -209,8 +209,8 @@ void check_merge_call(const vector<reagent>& ingredients, const reagent& product assert(false); } -// replaced in a later layer -// todo: find some clean way to take this call completely out of this layer +//: replaced in a later layer +//: todo: find some clean way to take this call completely out of this layer const type_tree* get_base_type(const type_tree* t) { return t; } diff --git a/036refcount.cc b/036refcount.cc index 6786c1bf..b8b5a84a 100644 --- a/036refcount.cc +++ b/036refcount.cc @@ -111,8 +111,7 @@ def foo [ +run: {1: ("address" "number")} <- new {number: "type"} +mem: incrementing refcount of 1000: 0 -> 1 +run: foo {1: ("address" "number")} -# leave ambiguous precisely when the next increment happens; a later layer -# will mess with that +# leave ambiguous precisely when the next increment happens +mem: incrementing refcount of 1000: 1 -> 2 +run: {1: ("address" "number")} <- new {number: "type"} +mem: decrementing refcount of 1000: 2 -> 1 diff --git a/037abandon.cc b/037abandon.cc index fee39b96..1f9e7c06 100644 --- a/037abandon.cc +++ b/037abandon.cc @@ -124,8 +124,7 @@ def foo [ +run: {1: ("address" "number")} <- new {number: "type"} +mem: incrementing refcount of 1000: 0 -> 1 +run: foo {1: ("address" "number")} -# leave ambiguous precisely when the next increment happens; a later layer -# will mess with that +# leave ambiguous precisely when the next increment happens +mem: incrementing refcount of 1000: 1 -> 2 +run: {2: ("address" "number")} <- copy {0: "literal"} +mem: decrementing refcount of 1000: 2 -> 1 diff --git a/043space.cc b/043space.cc index 4dee0027..5b3c6084 100644 --- a/043space.cc +++ b/043space.cc @@ -68,8 +68,8 @@ void absolutize(reagent& x) { assert(is_raw(x)); } +//: hook replaced in a later layer int space_base(const reagent& x) { - // temporary stub; will be replaced in a later layer return current_call().default_space ? (current_call().default_space+/*skip refcount*/1) : 0; } @@ -390,10 +390,7 @@ Transform.push_back(check_default_space); // idempotent void check_default_space(const recipe_ordinal r) { if (Hide_missing_default_space_errors) return; // skip previous core tests; this is only for Mu code const recipe& caller = get(Recipe, r); - // skip scenarios (later layer) - // user code should never create recipes with underscores in their names - if (caller.name.find("scenario_") == 0) return; // skip Mu scenarios which will use raw memory locations - if (caller.name.find("run_") == 0) return; // skip calls to 'run', which should be in scenarios and will also use raw memory locations + // End check_default_space Special-cases // assume recipes with only numeric addresses know what they're doing (usually tests) if (!contains_non_special_name(r)) return; trace(9991, "transform") << "--- check that recipe " << caller.name << " sets default-space" << end(); diff --git a/044space_surround.cc b/044space_surround.cc index 8f05b80c..f274f2d0 100644 --- a/044space_surround.cc +++ b/044space_surround.cc @@ -15,7 +15,8 @@ def main [ 21:num <- copy 5 # length # actual start of this recipe default-space:space <- copy 10/unsafe - 0:space/names:dummy <- copy 20/unsafe # later layers will explain the /names: property + #: later layers will explain the /names: property + 0:space/names:dummy <- copy 20/unsafe 1:num <- copy 32 1:num/space:1 <- copy 33 ] diff --git a/050scenario.cc b/050scenario.cc index d67b51e0..5e19c5db 100644 --- a/050scenario.cc +++ b/050scenario.cc @@ -220,6 +220,12 @@ void run_mu_scenario(const scenario& s) { Current_scenario = NULL; } +//: Permit numeric locations to be accessed in scenarios. +:(before "End check_default_space Special-cases") +// user code should never create recipes with underscores in their names +if (caller.name.find("scenario_") == 0) return; // skip Mu scenarios which will use raw memory locations +if (caller.name.find("run_") == 0) return; // skip calls to 'run', which should be in scenarios and will also use raw memory locations + //: Some variables for fake resources always get special /raw addresses in scenarios. // Should contain everything passed by is_special_name but failed by is_disqualified. diff --git a/073wait.cc b/073wait.cc index 917a7a03..99f56976 100644 --- a/073wait.cc +++ b/073wait.cc @@ -179,7 +179,8 @@ case GET_LOCATION: { break; } int offset_value = 0; - if (is_integer(offset.name)) { // later layers permit non-integer offsets + //: later layers will permit non-integer offsets + if (is_integer(offset.name)) { offset_value = to_integer(offset.name); if (offset_value < 0 || offset_value >= SIZE(get(Type, base_type).elements)) { raise << maybe(get(Recipe, r).name) << "invalid offset " << offset_value << " for '" << get(Type, base_type).name << "'\n" << end(); diff --git a/html/001help.cc.html b/html/001help.cc.html index 7d999033..cded9054 100644 --- a/html/001help.cc.html +++ b/html/001help.cc.html @@ -38,7 +38,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">:(before "End Commandline Parsing")</span> <span class="Normal">if</span> <span class="Delimiter">(</span>argc <= <span class="Constant">1</span> || is_equal<span class="Delimiter">(</span>argv[<span class="Constant">1</span>]<span class="Delimiter">,</span> <span class="Constant">"--help"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> - <span class="Comment">// this is the functionality later layers will provide</span> + <span class="Comment">//: this is the functionality later layers will provide</span> <span class="Comment">// currently no automated tests for commandline arg parsing</span> <span class="Normal">if</span> <span class="Delimiter">(</span>argc <= <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> cerr << <span class="Constant">"Please provide a Mu program to run.</span><span class="cSpecial">\n</span><span class="Constant">"</span> diff --git a/html/011load.cc.html b/html/011load.cc.html index b154f820..ee518186 100644 --- a/html/011load.cc.html +++ b/html/011load.cc.html @@ -86,7 +86,6 @@ vector<recipe_ordinal> load<span class="Delimiter">(</span>istream& in <span class="Delimiter">}</span> <span class="Comment">// return the recipe ordinal slurped, or -1 if it failed</span> -<span class="Comment">// (later layers will cause failures)</span> <span class="Normal">int</span> slurp_recipe<span class="Delimiter">(</span>istream& in<span class="Delimiter">)</span> <span class="Delimiter">{</span> recipe result<span class="Delimiter">;</span> result<span class="Delimiter">.</span>name = next_word<span class="Delimiter">(</span>in<span class="Delimiter">);</span> @@ -181,7 +180,7 @@ vector<recipe_ordinal> load<span class="Delimiter">(</span>istream& in <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> curr<span class="Delimiter">-></span>old_name = curr<span class="Delimiter">-></span>name = *p<span class="Delimiter">;</span> ++p<span class="Delimiter">;</span> - <span class="Comment">// curr->operation will be set in a later layer</span> + <span class="Comment">// curr->operation will be set at transform time</span> <span class="Normal">for</span> <span class="Delimiter">(;</span> p != words<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> curr<span class="Delimiter">-></span>ingredients<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>reagent<span class="Delimiter">(</span>*p<span class="Delimiter">));</span> diff --git a/html/013update_operation.cc.html b/html/013update_operation.cc.html index 7dd7e69f..d13f248b 100644 --- a/html/013update_operation.cc.html +++ b/html/013update_operation.cc.html @@ -57,7 +57,7 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Delimiter">}</span> <span class="Delimiter">}</span> -<span class="Comment">// hook to suppress inserting recipe name into errors (for later layers)</span> +<span class="Comment">// hook to suppress inserting recipe name into errors</span> string maybe<span class="Delimiter">(</span>string s<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Identifier">return</span> s + <span class="Constant">": "</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> diff --git a/html/020run.cc.html b/html/020run.cc.html index cd31ef09..e8c4d98e 100644 --- a/html/020run.cc.html +++ b/html/020run.cc.html @@ -102,7 +102,7 @@ Current_routine = <span class="Constant">NULL</span><span class="Delimiter">;</s <span class="Delimiter">}</span> <span class="Normal">void</span> run_current_routine<span class="Delimiter">()</span> <span class="Delimiter">{</span> - <span class="Normal">while</span> <span class="Delimiter">(</span>should_continue_running<span class="Delimiter">(</span>Current_routine<span class="Delimiter">))</span> <span class="Delimiter">{</span> <span class="Comment">// beware: later layers modify Current_routine here</span> + <span class="Normal">while</span> <span class="Delimiter">(</span>should_continue_running<span class="Delimiter">(</span>Current_routine<span class="Delimiter">))</span> <span class="Delimiter">{</span> <span class="Comment">// beware: may modify Current_routine</span> <span class="Comment">// Running One Instruction</span> <span class="Normal">if</span> <span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>is_label<span class="Delimiter">)</span> <span class="Delimiter">{</span> ++current_step_index<span class="Delimiter">();</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> trace<span class="Delimiter">(</span>Initial_callstack_depth + Trace_stream<span class="Delimiter">-></span>callstack_depth<span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << to_string<span class="Delimiter">(</span>current_instruction<span class="Delimiter">())</span> << end<span class="Delimiter">();</span> @@ -145,6 +145,7 @@ Current_routine = <span class="Constant">NULL</span><span class="Delimiter">;</s <span class="Normal">stop_running_current_routine</span>:<span class="Delimiter">;</span> <span class="Delimiter">}</span> +<span class="Comment">//: hook replaced in a later layer</span> <span class="Normal">bool</span> should_continue_running<span class="Delimiter">(</span><span class="Normal">const</span> routine* current_routine<span class="Delimiter">)</span> <span class="Delimiter">{</span> assert<span class="Delimiter">(</span>current_routine == Current_routine<span class="Delimiter">);</span> <span class="Comment">// argument passed in just to make caller readable above</span> <span class="Identifier">return</span> !Current_routine<span class="Delimiter">-></span>completed<span class="Delimiter">();</span> @@ -156,29 +157,34 @@ Current_routine = <span class="Constant">NULL</span><span class="Delimiter">;</s <span class="Delimiter">}</span> <span class="Comment">//: Some helpers.</span> -<span class="Comment">//: We'll need to override these later as we change the definition of routine.</span> -<span class="Comment">//: Important that they return referrences into the routine.</span> +<span class="Comment">//: Important that they return references into the current routine.</span> +<span class="Comment">//: hook replaced in a later layer</span> <span class="Normal">int</span>& current_step_index<span class="Delimiter">()</span> <span class="Delimiter">{</span> <span class="Identifier">return</span> Current_routine<span class="Delimiter">-></span>running_step_index<span class="Delimiter">;</span> <span class="Delimiter">}</span> +<span class="Comment">//: hook replaced in a later layer</span> <span class="Normal">const</span> string& current_recipe_name<span class="Delimiter">()</span> <span class="Delimiter">{</span> <span class="Identifier">return</span> get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> Current_routine<span class="Delimiter">-></span>running_recipe<span class="Delimiter">).</span>name<span class="Delimiter">;</span> <span class="Delimiter">}</span> +<span class="Comment">//: hook replaced in a later layer</span> <span class="Normal">const</span> recipe& current_recipe<span class="Delimiter">()</span> <span class="Delimiter">{</span> <span class="Identifier">return</span> get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> Current_routine<span class="Delimiter">-></span>running_recipe<span class="Delimiter">);</span> <span class="Delimiter">}</span> +<span class="Comment">//: hook replaced in a later layer</span> <span class="Normal">const</span> instruction& current_instruction<span class="Delimiter">()</span> <span class="Delimiter">{</span> <span class="Identifier">return</span> get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> Current_routine<span class="Delimiter">-></span>running_recipe<span class="Delimiter">).</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>Current_routine<span class="Delimiter">-></span>running_step_index<span class="Delimiter">);</span> <span class="Delimiter">}</span> +<span class="Comment">//: hook replaced in a later layer</span> <span class="Normal">bool</span> routine::completed<span class="Delimiter">()</span> <span class="Normal">const</span> <span class="Delimiter">{</span> <span class="Identifier">return</span> running_step_index >= SIZE<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> running_recipe<span class="Delimiter">).</span>steps<span class="Delimiter">);</span> <span class="Delimiter">}</span> +<span class="Comment">//: hook replaced in a later layer</span> <span class="Normal">const</span> vector<instruction>& routine::steps<span class="Delimiter">()</span> <span class="Normal">const</span> <span class="Delimiter">{</span> <span class="Identifier">return</span> get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> running_recipe<span class="Delimiter">).</span>steps<span class="Delimiter">;</span> <span class="Delimiter">}</span> diff --git a/html/021check_instruction.cc.html b/html/021check_instruction.cc.html index e24fd4a9..119ae459 100644 --- a/html/021check_instruction.cc.html +++ b/html/021check_instruction.cc.html @@ -158,8 +158,7 @@ $error: <span class="Constant">0</span> <span class="Identifier">return</span> types_strictly_match<span class="Delimiter">(</span>to<span class="Delimiter">,</span> from<span class="Delimiter">);</span> <span class="Delimiter">}</span> -<span class="Comment">// copy arguments because later layers will want to make changes to them</span> -<span class="Comment">// without perturbing the caller</span> +<span class="Comment">//: copy arguments for later layers</span> <span class="Normal">bool</span> types_strictly_match<span class="Delimiter">(</span>reagent<span class="Comment">/*</span><span class="Comment">copy</span><span class="Comment">*/</span> to<span class="Delimiter">,</span> reagent<span class="Comment">/*</span><span class="Comment">copy</span><span class="Comment">*/</span> from<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// End Preprocess types_strictly_match(reagent to, reagent from)</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_literal<span class="Delimiter">(</span>from<span class="Delimiter">)</span> && to<span class="Delimiter">.</span>type<span class="Delimiter">-></span>value == get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"number"</span><span class="Delimiter">))</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> diff --git a/html/030container.cc.html b/html/030container.cc.html index f474b8b8..edf98ada 100644 --- a/html/030container.cc.html +++ b/html/030container.cc.html @@ -421,7 +421,8 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">int</span> offset_value = <span class="Constant">0</span><span class="Delimiter">;</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>is_integer<span class="Delimiter">(</span>offset<span class="Delimiter">.</span>name<span class="Delimiter">))</span> <span class="Comment">// later layers permit non-integer offsets</span> + <span class="Comment">//: later layers will permit non-integer offsets</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>is_integer<span class="Delimiter">(</span>offset<span class="Delimiter">.</span>name<span class="Delimiter">))</span> offset_value = to_integer<span class="Delimiter">(</span>offset<span class="Delimiter">.</span>name<span class="Delimiter">);</span> <span class="Normal">else</span> offset_value = offset<span class="Delimiter">.</span>value<span class="Delimiter">;</span> @@ -432,7 +433,8 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">break</span><span class="Delimiter">;</span> reagent<span class="Comment">/*</span><span class="Comment">copy</span><span class="Comment">*/</span> product = inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> <span class="Comment">// Update GET product in Check</span> - <span class="Normal">const</span> reagent<span class="Comment">/*</span><span class="Comment">copy</span><span class="Comment">*/</span> element = element_type<span class="Delimiter">(</span>base<span class="Delimiter">.</span>type<span class="Delimiter">,</span> offset_value<span class="Delimiter">);</span> <span class="Comment">// not just base_type because later layers will introduce compound types</span> + <span class="Comment">//: use base.type rather than base_type because later layers will introduce compound types</span> + <span class="Normal">const</span> reagent<span class="Comment">/*</span><span class="Comment">copy</span><span class="Comment">*/</span> element = element_type<span class="Delimiter">(</span>base<span class="Delimiter">.</span>type<span class="Delimiter">,</span> offset_value<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!types_coercible<span class="Delimiter">(</span>product<span class="Delimiter">,</span> element<span class="Delimiter">))</span> <span class="Delimiter">{</span> raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'get "</span> << base<span class="Delimiter">.</span>original_string << <span class="Constant">", "</span> << offset<span class="Delimiter">.</span>original_string << <span class="Constant">"' should write to "</span> << names_to_string_without_quotes<span class="Delimiter">(</span>element<span class="Delimiter">.</span>type<span class="Delimiter">)</span> << <span class="Constant">" but '"</span> << product<span class="Delimiter">.</span>name << <span class="Constant">"' has type "</span> << names_to_string_without_quotes<span class="Delimiter">(</span>product<span class="Delimiter">.</span>type<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> @@ -455,7 +457,8 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span assert<span class="Delimiter">(</span>base<span class="Delimiter">.</span>metadata<span class="Delimiter">.</span>size<span class="Delimiter">);</span> <span class="Normal">int</span> src = base_address + base<span class="Delimiter">.</span>metadata<span class="Delimiter">.</span>offset<span class="Delimiter">.</span>at<span class="Delimiter">(</span>offset<span class="Delimiter">);</span> trace<span class="Delimiter">(</span><span class="Constant">9998</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"address to copy is "</span> << src << end<span class="Delimiter">();</span> - reagent<span class="Comment">/*</span><span class="Comment">copy</span><span class="Comment">*/</span> element = element_type<span class="Delimiter">(</span>base<span class="Delimiter">.</span>type<span class="Delimiter">,</span> offset<span class="Delimiter">);</span> <span class="Comment">// not just base_type because later layers will introduce compound types</span> + <span class="Comment">//: use base.type rather than base_type because later layers will introduce compound types</span> + reagent<span class="Comment">/*</span><span class="Comment">copy</span><span class="Comment">*/</span> element = element_type<span class="Delimiter">(</span>base<span class="Delimiter">.</span>type<span class="Delimiter">,</span> offset<span class="Delimiter">);</span> element<span class="Delimiter">.</span>set_value<span class="Delimiter">(</span>src<span class="Delimiter">);</span> trace<span class="Delimiter">(</span><span class="Constant">9998</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"its type is "</span> << names_to_string<span class="Delimiter">(</span>element<span class="Delimiter">.</span>type<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> <span class="Comment">// Read element</span> @@ -568,7 +571,8 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">int</span> offset_value = <span class="Constant">0</span><span class="Delimiter">;</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>is_integer<span class="Delimiter">(</span>offset<span class="Delimiter">.</span>name<span class="Delimiter">))</span> <span class="Delimiter">{</span> <span class="Comment">// later layers permit non-integer offsets</span> + <span class="Comment">//: later layers will permit non-integer offsets</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>is_integer<span class="Delimiter">(</span>offset<span class="Delimiter">.</span>name<span class="Delimiter">))</span> <span class="Delimiter">{</span> offset_value = to_integer<span class="Delimiter">(</span>offset<span class="Delimiter">.</span>name<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>offset_value < <span class="Constant">0</span> || offset_value >= SIZE<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base_type<span class="Delimiter">-></span>value<span class="Delimiter">).</span>elements<span class="Delimiter">))</span> <span class="Delimiter">{</span> raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"invalid offset '"</span> << offset_value << <span class="Constant">"' for '"</span> << get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base_type<span class="Delimiter">-></span>value<span class="Delimiter">).</span>name << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> @@ -579,7 +583,8 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span offset_value = offset<span class="Delimiter">.</span>value<span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">const</span> reagent& value = inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">);</span> - <span class="Normal">const</span> reagent& element = element_type<span class="Delimiter">(</span>base<span class="Delimiter">.</span>type<span class="Delimiter">,</span> offset_value<span class="Delimiter">);</span> <span class="Comment">// not just base_type because later layers will introduce compound types</span> + <span class="Comment">//: use base.type rather than base_type because later layers will introduce compound types</span> + <span class="Normal">const</span> reagent& element = element_type<span class="Delimiter">(</span>base<span class="Delimiter">.</span>type<span class="Delimiter">,</span> offset_value<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!types_coercible<span class="Delimiter">(</span>element<span class="Delimiter">,</span> value<span class="Delimiter">))</span> <span class="Delimiter">{</span> raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'put "</span> << base<span class="Delimiter">.</span>original_string << <span class="Constant">", "</span> << offset<span class="Delimiter">.</span>original_string << <span class="Constant">"' should write to "</span> << names_to_string_without_quotes<span class="Delimiter">(</span>element<span class="Delimiter">.</span>type<span class="Delimiter">)</span> << <span class="Constant">" but '"</span> << value<span class="Delimiter">.</span>name << <span class="Constant">"' has type "</span> << names_to_string_without_quotes<span class="Delimiter">(</span>value<span class="Delimiter">.</span>type<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> diff --git a/html/031merge.cc.html b/html/031merge.cc.html index c565c37b..0a606853 100644 --- a/html/031merge.cc.html +++ b/html/031merge.cc.html @@ -246,8 +246,8 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa assert<span class="Delimiter">(</span><span class="Constant">false</span><span class="Delimiter">);</span> <span class="Delimiter">}</span> -<span class="Comment">// replaced in a later layer</span> -<span class="Comment">// todo: find some clean way to take this call completely out of this layer</span> +<span class="Comment">//: replaced in a later layer</span> +<span class="Comment">//: todo: find some clean way to take this call completely out of this layer</span> <span class="Normal">const</span> type_tree* get_base_type<span class="Delimiter">(</span><span class="Normal">const</span> type_tree* t<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Identifier">return</span> t<span class="Delimiter">;</span> <span class="Delimiter">}</span> diff --git a/html/036refcount.cc.html b/html/036refcount.cc.html index dda4e250..1d02a4ad 100644 --- a/html/036refcount.cc.html +++ b/html/036refcount.cc.html @@ -148,8 +148,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="traceContains">+run: {1: ("address" "number")} <- new {number: "type"}</span> <span class="traceContains">+mem: incrementing refcount of 1000: 0 -> 1</span> <span class="traceContains">+run: foo {1: ("address" "number")}</span> -<span class="Comment"># leave ambiguous precisely when the next increment happens; a later layer</span> -<span class="Comment"># will mess with that</span> +<span class="Comment"># leave ambiguous precisely when the next increment happens</span> <span class="traceContains">+mem: incrementing refcount of 1000: 1 -> 2</span> <span class="traceContains">+run: {1: ("address" "number")} <- new {number: "type"}</span> <span class="traceContains">+mem: decrementing refcount of 1000: 2 -> 1</span> diff --git a/html/037abandon.cc.html b/html/037abandon.cc.html index a11ba8cf..1ef3ac3a 100644 --- a/html/037abandon.cc.html +++ b/html/037abandon.cc.html @@ -161,8 +161,7 @@ map<<span class="Normal">int</span><span class="Delimiter">,</span> <span cla <span class="traceContains">+run: {1: ("address" "number")} <- new {number: "type"}</span> <span class="traceContains">+mem: incrementing refcount of 1000: 0 -> 1</span> <span class="traceContains">+run: foo {1: ("address" "number")}</span> -<span class="Comment"># leave ambiguous precisely when the next increment happens; a later layer</span> -<span class="Comment"># will mess with that</span> +<span class="Comment"># leave ambiguous precisely when the next increment happens</span> <span class="traceContains">+mem: incrementing refcount of 1000: 1 -> 2</span> <span class="traceContains">+run: {2: ("address" "number")} <- copy {0: "literal"}</span> <span class="traceContains">+mem: decrementing refcount of 1000: 2 -> 1</span> diff --git a/html/043space.cc.html b/html/043space.cc.html index 5de969b0..617bd873 100644 --- a/html/043space.cc.html +++ b/html/043space.cc.html @@ -106,8 +106,8 @@ absolutize<span class="Delimiter">(</span>x<span class="Delimiter">);</span> assert<span class="Delimiter">(</span>is_raw<span class="Delimiter">(</span>x<span class="Delimiter">));</span> <span class="Delimiter">}</span> +<span class="Comment">//: hook replaced in a later layer</span> <span class="Normal">int</span> space_base<span class="Delimiter">(</span><span class="Normal">const</span> reagent& x<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Comment">// temporary stub; will be replaced in a later layer</span> <span class="Identifier">return</span> current_call<span class="Delimiter">().</span>default_space ? <span class="Delimiter">(</span>current_call<span class="Delimiter">().</span>default_space+<span class="Comment">/*</span><span class="Comment">skip refcount</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">)</span> : <span class="Constant">0</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -428,10 +428,7 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Normal">void</span> check_default_space<span class="Delimiter">(</span><span class="Normal">const</span> recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>Hide_missing_default_space_errors<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// skip previous core tests; this is only for Mu code</span> <span class="Normal">const</span> recipe& caller = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">);</span> - <span class="Comment">// skip scenarios (later layer)</span> - <span class="Comment">// user code should never create recipes with underscores in their names</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">.</span>find<span class="Delimiter">(</span><span class="Constant">"scenario_"</span><span class="Delimiter">)</span> == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// skip Mu scenarios which will use raw memory locations</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">.</span>find<span class="Delimiter">(</span><span class="Constant">"run_"</span><span class="Delimiter">)</span> == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// skip calls to 'run', which should be in scenarios and will also use raw memory locations</span> + <span class="Comment">// End check_default_space Special-cases</span> <span class="Comment">// assume recipes with only numeric addresses know what they're doing (usually tests)</span> <span class="Normal">if</span> <span class="Delimiter">(</span>!contains_non_special_name<span class="Delimiter">(</span>r<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span> trace<span class="Delimiter">(</span><span class="Constant">9991</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"--- check that recipe "</span> << caller<span class="Delimiter">.</span>name << <span class="Constant">" sets default-space"</span> << end<span class="Delimiter">();</span> diff --git a/html/044space_surround.cc.html b/html/044space_surround.cc.html index 6ea1ccca..dfa5bc11 100644 --- a/html/044space_surround.cc.html +++ b/html/044space_surround.cc.html @@ -50,7 +50,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">21</span>:num<span class="Special"> <- </span>copy <span class="Constant">5</span> <span class="Comment"># length</span> <span class="Comment"># actual start of this recipe</span> <span class="Normal">default</span>-space:space<span class="Special"> <- </span>copy <span class="Constant">10</span>/unsafe - <span class="Constant">0</span>:space/names:dummy<span class="Special"> <- </span>copy <span class="Constant">20</span>/unsafe <span class="Comment"># later layers will explain the /names: property</span> + <span class="Comment">#: later layers will explain the /names: property</span> + <span class="Constant">0</span>:space/names:dummy<span class="Special"> <- </span>copy <span class="Constant">20</span>/unsafe <span class="Constant">1</span>:num<span class="Special"> <- </span>copy <span class="Constant">32</span> <span class="Constant">1</span>:num/space:<span class="Constant">1</span><span class="Special"> <- </span>copy <span class="Constant">33</span> ] diff --git a/html/050scenario.cc.html b/html/050scenario.cc.html index c93d68a9..a4faa1af 100644 --- a/html/050scenario.cc.html +++ b/html/050scenario.cc.html @@ -259,6 +259,12 @@ Hide_missing_default_space_errors = <span class="Constant">false</span><span cla Current_scenario = <span class="Constant">NULL</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> +<span class="Comment">//: Permit numeric locations to be accessed in scenarios.</span> +<span class="Delimiter">:(before "End check_default_space Special-cases")</span> +<span class="Comment">// user code should never create recipes with underscores in their names</span> +<span class="Normal">if</span> <span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">.</span>find<span class="Delimiter">(</span><span class="Constant">"scenario_"</span><span class="Delimiter">)</span> == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// skip Mu scenarios which will use raw memory locations</span> +<span class="Normal">if</span> <span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">.</span>find<span class="Delimiter">(</span><span class="Constant">"run_"</span><span class="Delimiter">)</span> == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// skip calls to 'run', which should be in scenarios and will also use raw memory locations</span> + <span class="Comment">//: Some variables for fake resources always get special /raw addresses in scenarios.</span> <span class="Comment">// Should contain everything passed by is_special_name but failed by is_disqualified.</span> diff --git a/html/073wait.cc.html b/html/073wait.cc.html index 7f11c328..e607588e 100644 --- a/html/073wait.cc.html +++ b/html/073wait.cc.html @@ -216,7 +216,8 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Normal">int</span> offset_value = <span class="Constant">0</span><span class="Delimiter">;</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>is_integer<span class="Delimiter">(</span>offset<span class="Delimiter">.</span>name<span class="Delimiter">))</span> <span class="Delimiter">{</span> <span class="Comment">// later layers permit non-integer offsets</span> + <span class="Comment">//: later layers will permit non-integer offsets</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>is_integer<span class="Delimiter">(</span>offset<span class="Delimiter">.</span>name<span class="Delimiter">))</span> <span class="Delimiter">{</span> offset_value = to_integer<span class="Delimiter">(</span>offset<span class="Delimiter">.</span>name<span class="Delimiter">);</span> <span class="Normal">if</span> <span class="Delimiter">(</span>offset_value < <span class="Constant">0</span> || offset_value >= SIZE<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base_type<span class="Delimiter">).</span>elements<span class="Delimiter">))</span> <span class="Delimiter">{</span> raise << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"invalid offset "</span> << offset_value << <span class="Constant">" for '"</span> << get<span class="Delimiter">(</span>Type<span class="Delimiter">,</span> base_type<span class="Delimiter">).</span>name << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> diff --git a/vimrc.vim b/vimrc.vim index 83cc29b8..5587637e 100644 --- a/vimrc.vim +++ b/vimrc.vim @@ -19,7 +19,9 @@ function! HighlightTangledFile() " Our C++ files can have Mu code in scenarios, so highlight Mu comments like " regular comments. - syntax match muComment /# .*$/ | highlight link muComment Comment + syntax match muComment /# .*$/ + syntax match muComment /#: .*$/ + highlight link muComment Comment syntax match muSalientComment /##.*$/ | highlight link muSalientComment SalientComment syntax match muCommentedCode /#? .*$/ | highlight link muCommentedCode CommentedCode set comments+=n:# |