From 455fbac64f101b05f7eaca89b84470569e4df3fd Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 19 Jan 2016 23:18:03 -0800 Subject: 2576 - distinguish allocated addresses from others This is the one major refinement on the C programming model I'm planning to introduce in mu. Instead of Rust's menagerie of pointer types and static checking, I want to introduce just one new type, and use it to perform ref-counting at runtime. So far all we're doing is updating new's interface. The actual ref-counting implementation is next. One implication: I might sometimes need duplicate implementations for a recipe with allocated vs vanilla addresses of the same type. So far it seems I can get away with just always passing in allocated addresses; the situations when you want to pass an unallocated address to a recipe should be few and far between. --- 082scenario_screen.cc | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to '082scenario_screen.cc') diff --git a/082scenario_screen.cc b/082scenario_screen.cc index fc667311..362c73f1 100644 --- a/082scenario_screen.cc +++ b/082scenario_screen.cc @@ -10,7 +10,7 @@ scenario screen-in-scenario [ assume-screen 5/width, 3/height run [ 1:character <- copy 97/a - screen:address:screen <- print screen:address:screen, 1:character/a + screen:address:shared:screen <- print screen:address:shared:screen, 1:character/a ] screen-should-contain [ # 01234 @@ -25,9 +25,9 @@ scenario screen-in-scenario-unicode-color [ assume-screen 5/width, 3/height run [ 1:character <- copy 955/greek-small-lambda - screen:address:screen <- print screen:address:screen, 1:character/lambda, 1/red + screen:address:shared:screen <- print screen:address:shared:screen, 1:character/lambda, 1/red 2:character <- copy 97/a - screen:address:screen <- print screen:address:screen, 2:character/a + screen:address:shared:screen <- print screen:address:shared:screen, 2:character/a ] screen-should-contain [ # 01234 @@ -43,9 +43,9 @@ scenario screen-in-scenario-color [ assume-screen 5/width, 3/height run [ 1:character <- copy 955/greek-small-lambda - screen:address:screen <- print screen:address:screen, 1:character/lambda, 1/red + screen:address:shared:screen <- print screen:address:shared:screen, 1:character/lambda, 1/red 2:character <- copy 97/a - screen:address:screen <- print screen:address:screen, 2:character/a, 7/white + screen:address:shared:screen <- print screen:address:shared:screen, 2:character/a, 7/white ] # screen-should-contain shows everything screen-should-contain [ @@ -78,7 +78,7 @@ scenario screen-in-scenario-error [ assume-screen 5/width, 3/height run [ 1:character <- copy 97/a - screen:address:screen <- print screen:address:screen, 1:character/a + screen:address:shared:screen <- print screen:address:shared:screen, 1:character/a ] screen-should-contain [ # 01234 @@ -97,7 +97,7 @@ scenario screen-in-scenario-color [ assume-screen 5/width, 3/height run [ 1:character <- copy 97/a - screen:address:screen <- print screen:address:screen, 1:character/a, 1/red + screen:address:shared:screen <- print screen:address:shared:screen, 1:character/a, 1/red ] screen-should-contain-in-color 2/green, [ # 01234 @@ -146,11 +146,11 @@ Name[r]["screen"] = SCREEN; :(before "End Rewrite Instruction(curr, recipe result)") // rewrite `assume-screen width, height` to -// `screen:address:screen <- new-fake-screen width, height` +// `screen:address:shared:screen <- new-fake-screen width, height` if (curr.name == "assume-screen") { curr.name = "new-fake-screen"; assert(curr.products.empty()); - curr.products.push_back(reagent("screen:address:screen")); + curr.products.push_back(reagent("screen:address:shared:screen")); curr.products.at(0).set_value(SCREEN); } @@ -210,7 +210,7 @@ void check_screen(const string& expected_contents, const int color) { long long int screen_location = get_or_insert(Memory, SCREEN); int data_offset = find_element_name(get(Type_ordinal, "screen"), "data", ""); assert(data_offset >= 0); - long long int screen_data_location = screen_location+data_offset; // type: address:array:character + long long int screen_data_location = screen_location+data_offset; // type: address:shared:array:character long long int screen_data_start = get_or_insert(Memory, screen_data_location); // type: array:character int width_offset = find_element_name(get(Type_ordinal, "screen"), "num-columns", ""); long long int screen_width = get_or_insert(Memory, screen_location+width_offset); @@ -349,7 +349,7 @@ void dump_screen() { long long int screen_height = get_or_insert(Memory, screen_location+height_offset); int data_offset = find_element_name(get(Type_ordinal, "screen"), "data", ""); assert(data_offset >= 0); - long long int screen_data_location = screen_location+data_offset; // type: address:array:character + long long int screen_data_location = screen_location+data_offset; // type: address:shared:array:character long long int screen_data_start = get_or_insert(Memory, screen_data_location); // type: array:character assert(get_or_insert(Memory, screen_data_start) == screen_width*screen_height); long long int curr = screen_data_start+1; // skip length -- cgit 1.4.1-2-gfad0