about summary refs log tree commit diff stats
ModeNameSize
-rw-r--r--000organization.cc5283log stats plain blame
-rw-r--r--001help.cc3983log stats plain blame
-rw-r--r--002test.cc2778log stats plain blame
-rw-r--r--003trace.cc13996log stats plain blame
-rw-r--r--003trace.test.cc3488log stats plain blame
-rw-r--r--010vm.cc9466log stats plain blame
-rw-r--r--011load.cc10096log stats plain blame
-rw-r--r--012transform.cc1707log stats plain blame
-rw-r--r--013literal_string.cc5962log stats plain blame
-rw-r--r--014literal_noninteger.cc927log stats plain blame
-rw-r--r--020run.cc7796log stats plain blame
-rw-r--r--021arithmetic.cc4955log stats plain blame
-rw-r--r--022boolean.cc2604log stats plain blame
-rw-r--r--023jump.cc3476log stats plain blame
-rw-r--r--024compare.cc6539log stats plain blame
-rw-r--r--027trace.cc923log stats plain blame
-rw-r--r--028assert.cc728log stats plain blame
-rw-r--r--029debug.cc4063log stats plain blame
-rw-r--r--030container.cc14162log stats plain blame
-rw-r--r--031address.cc3292log stats plain blame
-rw-r--r--032array.cc8387log stats plain blame
-rw-r--r--033exclusive_container.cc4853log stats plain blame
-rw-r--r--034call.cc3690log stats plain blame
-rw-r--r--035call_ingredient.cc3766log stats plain blame
-rw-r--r--036call_reply.cc6159log stats plain blame
-rw-r--r--037recipe.cc1590log stats plain blame
-rw-r--r--038scheduler.cc11288log stats plain blame
-rw-r--r--039wait.cc5614log stats plain blame
-rw-r--r--040brace.cc9116log stats plain blame
-rw-r--r--041jump_label.cc3294log stats plain blame
-rw-r--r--042name.cc9762log stats plain blame
-rw-r--r--043new.cc12927log stats plain blame
-rw-r--r--044space.cc7688log stats plain blame
-rw-r--r--045space_surround.cc1876log stats plain blame
-rw-r--r--046closure_name.cc6011log stats plain blame
-rw-r--r--047global.cc2557log stats plain blame
-rw-r--r--048tangle.cc4834log stats plain blame
-rw-r--r--049continuation.cc8696log stats plain blame
-rw-r--r--050scenario.cc15888log stats plain blame
-rw-r--r--051scenario_test.mu1164log stats plain blame
-rw-r--r--060string.mu42997log stats plain blame
-rw-r--r--061channel.mu14219log stats plain blame
-rw-r--r--062array.mu1191log stats plain blame
-rw-r--r--063list.mu1804log stats plain blame
-rw-r--r--064random.cc1174log stats plain blame
-rw-r--r--065duplex_list.mu15553log stats plain blame
-rw-r--r--066stream.mu1634log stats plain blame
-rw-r--r--070display.cc10699log stats plain blame
-rw-r--r--071print.mu23951log stats plain blame
-rw-r--r--072scenario_screen.cc13622log stats plain blame
-rw-r--r--073scenario_screen_test.mu762log stats plain blame
-rw-r--r--074console.mu4052log stats plain blame
-rw-r--r--075scenario_console.cc8178log stats plain blame
-rw-r--r--076scenario_console_test.mu638log stats plain blame
-rw-r--r--080trace_browser.cc8190log stats plain blame
-rw-r--r--081run_interactive.cc9851log stats plain blame
-rw-r--r--082persist.cc1707log stats plain blame
-rw-r--r--999spaces.cc1404log stats plain blame
-rw-r--r--Readme.md14858log stats plain blame
d---------arc1164log stats plain
-rwxr-xr-xbuild_and_test_until425log stats plain blame
-rw-r--r--callcc.mu408log stats plain blame
-rw-r--r--channel.mu1212log stats plain blame
-rw-r--r--chessboard.mu30192log stats plain blame
-rw-r--r--console.mu324log stats plain blame
-rw-r--r--counters.mu1124log stats plain blame
-rw-r--r--display.mu729log stats plain blame
-rw-r--r--edit.mu136896log stats plain blame
d---------enumerate76log stats plain
-rw-r--r--factorial.mu664log stats plain blame
-rw-r--r--fork.mu191log stats plain blame
-rw-r--r--global.mu350log stats plain blame
d---------html3391log stats plain
-rw-r--r--index.html10977log stats plain blame
-rw-r--r--makefile2527log stats plain blame
-rwxr-xr-xmu162log stats plain blame
-rw-r--r--mu.vim2442log stats plain blame
-rwxr-xr-xrelayout1053log stats plain blame
-rw-r--r--screen.mu933log stats plain blame
-rw-r--r--tangle.mu790log stats plain blame
d---------tangle315log stats plain
d---------termbox394log stats plain
-rwxr-xr-xtest_all_layers190log stats plain blame
-rwxr-xr-xupdate_github_page251log stats plain blame
-rwxr-xr-xupdate_html575log stats plain blame
-rw-r--r--vimrc.vim1950log stats plain blame
-rw-r--r--x.mu167log stats plain blame
class="w"> index, const list<pair<int, int> >& braces, recipe_ordinal r) { int stacksize = 0; for (list<pair<int, int> >::const_iterator p = braces.begin(); p != braces.end(); ++p) { if (p->second < index) continue; stacksize += (p->first ? 1 : -1); if (stacksize == 0) return p->second; } raise << maybe(get(Recipe, r).name) << "unbalanced '{'\n" << end(); return SIZE(get(Recipe, r).steps); // exit current routine } :(scenario loop) def main [ 1:num <- copy 0 2:num <- copy 0 { 3:num <- copy 0 loop } ] +transform: --- transform braces for recipe main +transform: copy ... +transform: copy ... +transform: copy ... +transform: jump -2:offset :(scenario break_empty_block) def main [ 1:num <- copy 0 { break } ] +transform: --- transform braces for recipe main +transform: copy ... +transform: jump 0:offset :(scenario break_cascading) def main [ 1:num <- copy 0 { break } { break } ] +transform: --- transform braces for recipe main +transform: copy ... +transform: jump 0:offset +transform: jump 0:offset :(scenario break_cascading_2) def main [ 1:num <- copy 0 2:num <- copy 0 { break 3:num <- copy 0 } { break } ] +transform: --- transform braces for recipe main +transform: copy ... +transform: copy ... +transform: jump 1:offset +transform: copy ... +transform: jump 0:offset :(scenario break_if) def main [ 1:num <- copy 0 2:num <- copy 0 { break-if 2:num 3:num <- copy 0 } { break } ] +transform: --- transform braces for recipe main +transform: copy ... +transform: copy ... +transform: jump-if 2, 1:offset +transform: copy ... +transform: jump 0:offset :(scenario break_nested) def main [ 1:num <- copy 0 { 2:num <- copy 0 break { 3:num <- copy 0 } 4:num <- copy 0 } ] +transform: jump 4:offset :(scenario break_nested_degenerate) def main [ 1:num <- copy 0 { 2:num <- copy 0 break { } 4:num <- copy 0 } ] +transform: jump 3:offset :(scenario break_nested_degenerate_2) def main [ 1:num <- copy 0 { 2:num <- copy 0 break { } } ] +transform: jump 2:offset :(scenario break_label) % Hide_errors = true; def main [ 1:num <- copy 0 { break +foo:offset } ] +transform: jump +foo:offset :(scenario break_unless) def main [ 1:num <- copy 0 2:num <- copy 0 { break-unless 2:num 3:num <- copy 0 } ] +transform: --- transform braces for recipe main +transform: copy ... +transform: copy ... +transform: jump-unless 2, 1:offset +transform: copy ... :(scenario loop_unless) def main [ 1:num <- copy 0 2:num <- copy 0 { loop-unless 2:num 3:num <- copy 0 } ] +transform: --- transform braces for recipe main +transform: copy ... +transform: copy ... +transform: jump-unless 2, -1:offset +transform: copy ... :(scenario loop_nested) def main [ 1:num <- copy 0 { 2:num <- copy 0 { 3:num <- copy 0 } loop-if 4:bool 5:num <- copy 0 } ] +transform: --- transform braces for recipe main +transform: jump-if 4, -5:offset :(scenario loop_label) def main [ 1:num <- copy 0 +foo 2:num <- copy 0 ] +transform: --- transform braces for recipe main +transform: copy ... +transform: copy ... //: test how things actually run :(scenarios run) :(scenario brace_conversion_and_run) def test-factorial [ 1:num <- copy 5 2:num <- copy 1 { 3:bool <- equal 1:num, 1 break-if 3:bool # $print 1:num 2:num <- multiply 2:num, 1:num 1:num <- subtract 1:num, 1 loop } 4:num <- copy 2:num # trigger a read ] +mem: location 2 is 120 :(scenario break_outside_braces_fails) % Hide_errors = true; def main [ break ] +error: main: 'break' needs a '{' before :(scenario break_conditional_without_ingredient_fails) % Hide_errors = true; def main [ { break-if } ] +error: main: 'break-if' expects 1 or 2 ingredients, but got none //: Using break we can now implement conditional returns. :(scenario return_if) def main [ 1:num <- test1 ] def test1 [ return-if 0, 34 return 35 ] +mem: storing 35 in location 1 :(scenario return_if_2) def main [ 1:num <- test1 ] def test1 [ return-if 1, 34 return 35 ] +mem: storing 34 in location 1 :(before "End Rewrite Instruction(curr, recipe result)") // rewrite `return-if a, b, c, ...` to // ``` // { // break-unless a // return b, c, ... // } // ``` if (curr.name == "return-if" || curr.name == "reply-if") { if (curr.products.empty()) { emit_return_block(result, "break-unless", curr); curr.clear(); } else { raise << "'" << curr.name << "' never yields any products\n" << end(); } } // rewrite `return-unless a, b, c, ...` to // ``` // { // break-if a // return b, c, ... // } // ``` if (curr.name == "return-unless" || curr.name == "reply-unless") { if (curr.products.empty()) { emit_return_block(result, "break-if", curr); curr.clear(); } else { raise << "'" << curr.name << "' never yields any products\n" << end(); } } :(code) void emit_return_block(recipe& out, const string& break_command, const instruction& inst) { const vector<reagent>& ingredients = inst.ingredients; reagent/*copy*/ condition = ingredients.at(0); vector<reagent> return_ingredients; copy(++ingredients.begin(), ingredients.end(), inserter(return_ingredients, return_ingredients.end())); // { instruction open_label; open_label.is_label=true; open_label.label = "{"; out.steps.push_back(open_label); // <break command> <condition> instruction break_inst; break_inst.operation = get(Recipe_ordinal, break_command); break_inst.name = break_command; break_inst.ingredients.push_back(condition); out.steps.push_back(break_inst); // return <return ingredients> instruction return_inst; return_inst.operation = get(Recipe_ordinal, "return"); return_inst.name = "return"; return_inst.ingredients.swap(return_ingredients); return_inst.original_string = inst.original_string; out.steps.push_back(return_inst); // } instruction close_label; close_label.is_label=true; close_label.label = "}"; out.steps.push_back(close_label); } //: Make sure these pseudo recipes get consistent numbers in all tests, even //: though they aren't implemented. Allows greater flexibility in ordering //: transforms. :(before "End Primitive Recipe Declarations") BREAK, BREAK_IF, BREAK_UNLESS, LOOP, LOOP_IF, LOOP_UNLESS, :(before "End Primitive Recipe Numbers") put(Recipe_ordinal, "break", BREAK); put(Recipe_ordinal, "break-if", BREAK_IF); put(Recipe_ordinal, "break-unless", BREAK_UNLESS); put(Recipe_ordinal, "loop", LOOP); put(Recipe_ordinal, "loop-if", LOOP_IF); put(Recipe_ordinal, "loop-unless", LOOP_UNLESS); :(before "End Primitive Recipe Checks") case BREAK: break; case BREAK_IF: break; case BREAK_UNLESS: break; case LOOP: break; case LOOP_IF: break; case LOOP_UNLESS: break;