This commit is contained in:
Kartik K. Agaram 2016-02-25 20:47:42 -08:00
parent dcc060c7d4
commit d0e29245f9
19 changed files with 3 additions and 63 deletions

View File

@ -151,7 +151,6 @@ if (argc > 1) {
argc--;
}
transform_all();
//? dump_recipe("handle-keyboard-event"), exit(0);
if (Run_tests) Recipe.erase(get(Recipe_ordinal, "main"));
// End Loading .mu Files
}

View File

@ -112,7 +112,6 @@ if (r.type && r.type->value == get(Type_ordinal, "array")) {
raise_error << maybe(current_recipe_name()) << "'" << r.original_string << "' is an array of what?\n" << end();
return 1;
}
//? trace(9999, "mem") << "computing size of array starting at " << r.value << end();
return 1 + get_or_insert(Memory, r.value)*size_of(array_element(r.type));
}

View File

@ -265,7 +265,6 @@ void check_default_space(const recipe_ordinal r) {
if (caller.steps.at(0).products.empty()
|| caller.steps.at(0).products.at(0).name != "default-space") {
raise_error << maybe(caller.name) << " does not seem to start with default-space or local-scope\n" << end();
//? cerr << maybe(caller.name) << " does not seem to start with default-space or local-scope\n" << '\n';
}
}
:(after "Load .mu Core")
@ -280,10 +279,8 @@ bool contains_non_special_name(const recipe_ordinal r) {
for (map<string, long long int>::iterator p = Name[r].begin(); p != Name[r].end(); ++p) {
if (p->first.empty()) continue;
if (p->first.find("stash_") == 0) continue; // generated by rewrite_stashes_to_text (cross-layer)
if (!is_special_name(p->first)) {
//? cerr << " " << get(Recipe, r).name << ": " << p->first << '\n';
if (!is_special_name(p->first))
return true;
}
}
return false;
}

View File

@ -39,12 +39,9 @@ long long int space_base(const reagent& x) {
}
long long int space_base(const reagent& x, long long int space_index, long long int base) {
//? trace(9999, "space") << "space-base: " << space_index << " " << base << end();
if (space_index == 0) {
if (space_index == 0)
return base;
}
long long int result = space_base(x, space_index-1, get_or_insert(Memory, base+/*skip length*/1))+/*skip refcount*/1;
//? trace(9999, "space") << "space-base: " << space_index << " " << base << " => " << result << end();
return result;
}

View File

@ -78,7 +78,6 @@ void collect_surrounding_spaces(const recipe_ordinal r) {
continue;
}
trace(9993, "name") << "lexically surrounding space for recipe " << get(Recipe, r).name << " comes from " << surrounding_recipe_name << end();
//? cerr << "lexically surrounding space for recipe " << get(Recipe, r).name << " comes from " << surrounding_recipe_name << '\n';
if (!contains_key(Recipe_ordinal, surrounding_recipe_name)) {
raise_error << "can't find recipe providing surrounding space for " << get(Recipe, r).name << ": " << surrounding_recipe_name << '\n' << end();
continue;

View File

@ -210,14 +210,9 @@ case RUN: {
assert(Name[Next_recipe_ordinal].empty());
ostringstream tmp;
tmp << "recipe run_" << Next_recipe_ordinal << " [ " << current_instruction().ingredients.at(0).name << " ]";
//? cerr << tmp.str() << '\n';
//? cerr << "before load\n";
vector<recipe_ordinal> tmp_recipe = load(tmp.str());
//? cerr << "before bind\n";
bind_special_scenario_names(tmp_recipe.at(0));
//? cerr << "before transform\n";
transform_all();
//? cerr << "end\n";
if (Trace_stream) {
++Trace_stream->callstack_depth;
trace(9998, "trace") << "run: incrementing callstack depth to " << Trace_stream->callstack_depth << end();

View File

@ -33,7 +33,6 @@ for (map<string, vector<recipe_ordinal> >::iterator p = Recipe_variants.begin();
// there can only ever be one variant for main
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) {
string new_name = matching_variant_name(result);
if (new_name.empty()) {
@ -44,7 +43,6 @@ if (result.name != "main" && contains_key(Recipe_ordinal, result.name)) {
}
trace(9999, "load") << "switching " << result.name << " to " << new_name << end();
result.name = new_name;
//? cerr << "=> " << new_name << '\n';
}
}
else {

View File

@ -12,7 +12,6 @@ recipe to-text-line x:_elem -> y:address:shared:array:character [
recipe to-text x:address:shared:array:character -> y:address:shared:array:character [
local-scope
load-ingredients
#? $print [to-text text], 10/newline
reply x
]
@ -163,7 +162,6 @@ recipe buffer-full? in:address:shared:buffer -> result:boolean [
# most broadly applicable definition of append to a buffer: just call to-text
recipe append buf:address:shared:buffer, x:_elem -> buf:address:shared:buffer [
local-scope
#? $print [append _elem to buffer], 10/newline
load-ingredients
text:address:shared:array:character <- to-text x
len:number <- length *text
@ -180,7 +178,6 @@ recipe append buf:address:shared:buffer, x:_elem -> buf:address:shared:buffer [
recipe append in:address:shared:buffer, c:character -> in:address:shared:buffer [
local-scope
#? $print [append character to buffer], 10/newline
load-ingredients
len:address:number <- get-address *in, length:offset
{
@ -392,7 +389,6 @@ scenario integer-to-decimal-digit-negative [
recipe append a:address:shared:array:character, b:address:shared:array:character -> result:address:shared:array:character [
local-scope
#? $print [append text to text], 10/newline
load-ingredients
# result = new character[a.length + b.length]
a-len:number <- length *a

View File

@ -53,7 +53,6 @@ scenario list-handling [
recipe to-text in:address:shared:list:_elem -> result:address:shared:array:character [
local-scope
#? $print [to text: list], 10/newline
load-ingredients
buf:address:shared:buffer <- new-buffer 80
buf <- to-buffer in, buf
@ -63,7 +62,6 @@ recipe to-text in:address:shared:list:_elem -> result:address:shared:array:chara
# variant of 'to-text' which stops printing after a few elements (and so is robust to cycles)
recipe to-text-line in:address:shared:list:_elem -> result:address:shared:array:character [
local-scope
#? $print [to text line: list], 10/newline
load-ingredients
buf:address:shared:buffer <- new-buffer 80
buf <- to-buffer in, buf, 6 # max elements to display
@ -72,7 +70,6 @@ recipe to-text-line in:address:shared:list:_elem -> result:address:shared:array:
recipe to-buffer in:address:shared:list:_elem, buf:address:shared:buffer -> buf:address:shared:buffer [
local-scope
#? $print [to buffer: list], 10/newline
load-ingredients
{
break-if in
@ -85,7 +82,6 @@ recipe to-buffer in:address:shared:list:_elem, buf:address:shared:buffer -> buf:
# now prepare next
next:address:shared:list:_elem <- rest in
nextn:number <- copy next
#? buf <- append buf, nextn
reply-unless next
space:character <- copy 32/space
buf <- append buf, space:character

View File

@ -32,7 +32,6 @@ case HASH: {
:(code)
size_t hash(size_t h, reagent& r) {
//? cerr << debug_string(r) << '\n';
canonize(r);
if (is_mu_string(r)) // optimization
return hash_mu_string(h, r);

View File

@ -165,8 +165,6 @@ case SCREEN_SHOULD_CONTAIN: {
}
:(before "End Primitive Recipe Implementations")
case SCREEN_SHOULD_CONTAIN: {
//? cerr << SIZE(get(Recipe_variants, "insert")) << '\n';
//? cerr << debug_string(get(Recipe, get(Recipe_ordinal, "insert_4"))) << '\n';
if (!Passed) break;
assert(scalar(ingredients.at(0)));
check_screen(current_instruction().ingredients.at(0).name, -1);

View File

@ -23,8 +23,3 @@ scenario read-key-in-mu [
8 <- 1
]
]
#? recipe foo-editor [
#? local-scope
#? init:address:shared:list:character <- push 97/a, 0
#? ]

View File

@ -109,7 +109,6 @@ bool run_interactive(long long int address) {
}
void run_code_begin(bool snapshot_recently_added_recipes) {
//? cerr << "loading new trace\n";
// stuff to undo later, in run_code_end()
Hide_errors = true;
Disable_redefine_checks = true;
@ -127,7 +126,6 @@ void run_code_begin(bool snapshot_recently_added_recipes) {
}
void run_code_end() {
//? cerr << "back to old trace\n";
Hide_errors = false;
Disable_redefine_checks = false;
delete Trace_stream;
@ -458,7 +456,6 @@ case RELOAD: {
}
:(before "End Primitive Recipe Implementations")
case RELOAD: {
//? cerr << "== reload\n";
// clear any containers in advance
for (long long int i = 0; i < SIZE(Recently_added_types); ++i) {
if (!contains_key(Type, Recently_added_types.at(i))) continue;
@ -466,14 +463,11 @@ case RELOAD: {
Type.erase(Recently_added_types.at(i));
}
for (map<string, vector<recipe_ordinal> >::iterator p = Recipe_variants.begin(); p != Recipe_variants.end(); ++p) {
//? cerr << p->first << ":\n";
vector<recipe_ordinal>& variants = p->second;
for (long long int i = 0; i < SIZE(p->second); ++i) {
if (variants.at(i) == -1) continue;
if (find(Recently_added_shape_shifting_recipes.begin(), Recently_added_shape_shifting_recipes.end(), variants.at(i)) != Recently_added_shape_shifting_recipes.end()) {
//? cerr << " " << variants.at(i) << ' ' << get(Recipe, variants.at(i)).name << '\n';
if (find(Recently_added_shape_shifting_recipes.begin(), Recently_added_shape_shifting_recipes.end(), variants.at(i)) != Recently_added_shape_shifting_recipes.end())
variants.at(i) = -1; // ghost
}
}
}
for (long long int i = 0; i < SIZE(Recently_added_shape_shifting_recipes); ++i) {
@ -496,7 +490,6 @@ case RELOAD: {
products.resize(1);
products.at(0).push_back(trace_error_contents());
run_code_end(); // wait until we're done with the trace contents
//? cerr << "reload done\n";
break;
}

View File

@ -380,9 +380,7 @@ recipe render-all screen:address:shared:screen, env:address:shared:programming-e
# top menu
trace 11, [app], [render top menu]
width:number <- screen-width screen
#? $print [draw menu], 10/newline
draw-horizontal screen, 0, 0/left, width, 32/space, 0/black, 238/grey
#? $print [draw menu end], 10/newline
button-start:number <- subtract width, 20
button-on-screen?:boolean <- greater-or-equal button-start, 0
assert button-on-screen?, [screen too narrow for menu]

View File

@ -127,14 +127,11 @@ after <global-keypress> [
{
do-run?:boolean <- equal *k, 65532/F4
break-unless do-run?
#? $log [F4 pressed]
status:address:shared:array:character <- new [running... ]
screen <- update-status screen, status, 245/grey
error?:boolean, env, screen <- run-sandboxes env, screen
# F4 might update warnings and results on both sides
#? $print [render-all begin], 10/newline
screen <- render-all screen, env
#? $print [render-all end], 10/newline
{
break-if error?
status:address:shared:array:character <- new [ ]
@ -243,7 +240,6 @@ recipe save-sandboxes env:address:shared:programming-environment-data [
recipe! render-sandbox-side screen:address:shared:screen, env:address:shared:programming-environment-data -> screen:address:shared:screen [
local-scope
load-ingredients
#? $log [render sandbox side]
trace 11, [app], [render sandbox side]
current-sandbox:address:shared:editor-data <- get *env, current-sandbox:offset
row:number, column:number <- copy 1, 0
@ -268,7 +264,6 @@ recipe! render-sandbox-side screen:address:shared:screen, env:address:shared:pro
recipe render-sandboxes screen:address:shared:screen, sandbox:address:shared:sandbox-data, left:number, right:number, row:number, render-from:number, idx:number -> row:number, screen:address:shared:screen, sandbox:address:shared:sandbox-data [
local-scope
load-ingredients
#? $log [render sandbox]
reply-unless sandbox
screen-height:number <- screen-height screen
at-bottom?:boolean <- greater-or-equal row, screen-height

View File

@ -8,7 +8,6 @@ container programming-environment-data [
recipe! update-recipes env:address:shared:programming-environment-data, screen:address:shared:screen -> errors-found?:boolean, env:address:shared:programming-environment-data, screen:address:shared:screen [
local-scope
load-ingredients
#? $log [update recipes]
recipes:address:shared:editor-data <- get *env, recipes:offset
in:address:shared:array:character <- editor-contents recipes
save [recipes.mu], in
@ -74,9 +73,7 @@ before <render-components-end> [
status-template:address:shared:array:character <- new [errors found (_) ]
error-index-text:address:shared:array:character <- to-text error-index
status:address:shared:array:character <- interpolate status-template, error-index-text
#? $print [update-status: sandbox error], 10/newline
update-status screen, status, 1/red
#? $print [run sandboxes end], 10/newline
}
]
@ -87,13 +84,11 @@ container sandbox-data [
recipe! update-sandbox sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data, idx:number -> sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data [
local-scope
load-ingredients
#? $log [update sandbox]
data:address:shared:array:character <- get *sandbox, data:offset
response:address:address:shared:array:character <- get-address *sandbox, response:offset
errors:address:address:shared:array:character <- get-address *sandbox, errors:offset
trace:address:address:shared:array:character <- get-address *sandbox, trace:offset
fake-screen:address:address:shared:screen <- get-address *sandbox, screen:offset
#? $print [run-interactive], 10/newline
*response, *errors, *fake-screen, *trace, completed?:boolean <- run-interactive data
{
break-if *errors
@ -103,13 +98,11 @@ recipe! update-sandbox sandbox:address:shared:sandbox-data, env:address:shared:p
}
{
break-unless *errors
#? $print [setting error-index to ], idx, 10/newline
error-index:address:number <- get-address *env, error-index:offset
error-not-set?:boolean <- equal *error-index, -1
break-unless error-not-set?
*error-index <- copy idx
}
#? $print [done with run-interactive], 10/newline
]
# make sure we render any trace

View File

@ -160,9 +160,7 @@ recipe render-all screen:address:shared:screen, env:address:shared:programming-e
# top menu
trace 11, [app], [render top menu]
width:number <- screen-width screen
#? $print [draw menu], 10/newline
draw-horizontal screen, 0, 0/left, width, 32/space, 0/black, 238/grey
#? $print [draw menu end], 10/newline
button-start:number <- subtract width, 20
button-on-screen?:boolean <- greater-or-equal button-start, 0
assert button-on-screen?, [screen too narrow for menu]

View File

@ -121,7 +121,6 @@ after <global-keypress> [
screen <- render-all screen, env
{
break-if error?
#? $print [update-status: clearing], 10/newline
status:address:shared:array:character <- new [ ]
screen <- update-status screen, status, 245/grey
}

View File

@ -71,9 +71,7 @@ before <render-components-end> [
status-template:address:shared:array:character <- new [errors found (_) ]
error-index-text:address:shared:array:character <- to-text error-index
status:address:shared:array:character <- interpolate status-template, error-index-text
#? $print [update-status: sandbox error], 10/newline
update-status screen, status, 1/red
#? $print [run sandboxes end], 10/newline
}
]
@ -104,13 +102,11 @@ recipe! update-sandbox sandbox:address:shared:sandbox-data, env:address:shared:p
}
{
break-unless *errors
#? $print [setting error-index to ], idx, 10/newline
error-index:address:number <- get-address *env, error-index:offset
error-not-set?:boolean <- equal *error-index, -1
break-unless error-not-set?
*error-index <- copy idx
}
#? $print [done with run-interactive], 10/newline
]
# make sure we render any trace