diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-09-17 13:00:39 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-09-17 13:00:39 -0700 |
commit | a0331a9b0eab63a000dcd022fe605d124c573b8d (patch) | |
tree | 5c7403d16fd8c9d31ead65495eae84edf9cfc2e4 | |
parent | 760f683f2755038a1b0c16522f5001b889096aa5 (diff) | |
download | mu-a0331a9b0eab63a000dcd022fe605d124c573b8d.tar.gz |
3390
-rw-r--r-- | 042name.cc | 2 | ||||
-rw-r--r-- | 043space.cc | 32 | ||||
-rw-r--r-- | 044space_surround.cc | 8 | ||||
-rw-r--r-- | 045closure_name.cc | 28 | ||||
-rw-r--r-- | 046global.cc | 12 | ||||
-rw-r--r-- | 047check_type_by_name.cc | 4 | ||||
-rw-r--r-- | 053recipe_header.cc | 2 | ||||
-rw-r--r-- | 054static_dispatch.cc | 2 | ||||
-rw-r--r-- | 055shape_shifting_container.cc | 4 | ||||
-rw-r--r-- | 056shape_shifting_recipe.cc | 8 | ||||
-rw-r--r-- | 057immutable.cc | 28 | ||||
-rw-r--r-- | 059to_text.mu | 6 | ||||
-rw-r--r-- | 061text.mu | 82 | ||||
-rw-r--r-- | 062convert_ingredients_to_text.cc | 4 | ||||
-rw-r--r-- | 063array.mu | 2 | ||||
-rw-r--r-- | 066stream.mu | 10 | ||||
-rw-r--r-- | 068random.mu | 2 | ||||
-rw-r--r-- | 069hash.cc | 4 | ||||
-rw-r--r-- | 070table.mu | 8 | ||||
-rw-r--r-- | 072scheduler.cc | 6 | ||||
-rw-r--r-- | 074deep_copy.cc | 20 | ||||
-rw-r--r-- | 075channel.mu | 10 | ||||
-rw-r--r-- | 081print.mu | 46 | ||||
-rw-r--r-- | 082scenario_screen.cc | 4 | ||||
-rw-r--r-- | 084console.mu | 6 | ||||
-rw-r--r-- | 088file.mu | 8 | ||||
-rw-r--r-- | 089scenario_filesystem.cc | 20 | ||||
-rw-r--r-- | 101run_sandboxed.cc | 10 | ||||
-rw-r--r-- | 102persist.cc | 2 | ||||
-rw-r--r-- | chessboard.mu | 16 | ||||
-rw-r--r-- | counters.mu | 10 | ||||
-rw-r--r-- | global.mu | 2 | ||||
-rw-r--r-- | lambda_to_mu.mu | 72 |
33 files changed, 240 insertions, 240 deletions
diff --git a/042name.cc b/042name.cc index c6e049d4..a9f05d5e 100644 --- a/042name.cc +++ b/042name.cc @@ -164,7 +164,7 @@ def main [ :(scenario transform_names_supports_static_arrays) def main [ - x:array:num:3 <- create-array + x:@:num:3 <- create-array y:num <- copy 3 ] +name: assign x 1 diff --git a/043space.cc b/043space.cc index 0e2b1656..114d5268 100644 --- a/043space.cc +++ b/043space.cc @@ -6,10 +6,10 @@ # if default-space is 10, and if an array of 5 locals lies from location 12 to 16 (inclusive), # then local 0 is really location 12, local 1 is really location 13, and so on. def main [ - # pretend address:array:location; in practice we'll use new + # pretend address:@:location; in practice we'll use new 10:num <- copy 0 # refcount 11:num <- copy 5 # length - default-space:&:array:location <- copy 10/unsafe + default-space:&:@:location <- copy 10/unsafe 1:num <- copy 23 ] +mem: storing 23 in location 13 @@ -18,11 +18,11 @@ def main [ def main [ # pretend pointer from outside (2000 reserved for refcount) 2001:num <- copy 34 - # pretend address:array:location; in practice we'll use new + # pretend address:@:location; in practice we'll use new 1000:num <- copy 0 # refcount 1001:num <- copy 5 # length # actual start of this recipe - default-space:&:array:location <- copy 1000/unsafe + default-space:&:@:location <- copy 1000/unsafe 1:&:num <- copy 2000/unsafe # even local variables always contain raw addresses 8:num/raw <- copy *1:&:num ] @@ -84,7 +84,7 @@ int address(int offset, int base) { :(after "Begin Preprocess write_memory(x, data)") if (x.name == "default-space") { if (!scalar(data) || !is_space(x)) - raise << maybe(current_recipe_name()) << "'default-space' should be of type address:array:location, but is " << to_string(x.type) << '\n' << end(); + raise << maybe(current_recipe_name()) << "'default-space' should be of type address:@:location, but is " << to_string(x.type) << '\n' << end(); current_call().default_space = data.at(0); return; } @@ -95,8 +95,8 @@ bool is_space(const reagent& r) { :(scenario get_default_space) def main [ - default-space:&:array:location <- copy 10/unsafe - 1:&:array:location/raw <- copy default-space:&:array:location + default-space:&:@:location <- copy 10/unsafe + 1:&:@:location/raw <- copy default-space:&:@:location ] +mem: storing 10 in location 1 @@ -114,11 +114,11 @@ def main [ # pretend pointer to container from outside (2000 reserved for refcount) 2001:num <- copy 34 2002:num <- copy 35 - # pretend address:array:location; in practice we'll use new + # pretend address:@:location; in practice we'll use new 1000:num <- copy 0 # refcount 1001:num <- copy 5 # length # actual start of this recipe - default-space:&:array:location <- copy 1000/unsafe + default-space:&:@:location <- copy 1000/unsafe 1:&:point <- copy 2000/unsafe 9:num/raw <- get *1:&:point, 1:offset ] @@ -135,13 +135,13 @@ def main [ 2001:num <- copy 2 # length 2002:num <- copy 34 2003:num <- copy 35 - # pretend address:array:location; in practice we'll use new + # pretend address:@:location; in practice we'll use new 1000:num <- copy 0 # refcount 1001:num <- copy 5 # length # actual start of this recipe - default-space:&:array:location <- copy 1000/unsafe - 1:&:array:num <- copy 2000/unsafe - 9:num/raw <- index *1:&:array:num, 1 + default-space:&:@:location <- copy 1000/unsafe + 1:&:@:num <- copy 2000/unsafe + 9:num/raw <- index *1:&:@:num, 1 ] +mem: storing 35 in location 9 @@ -168,7 +168,7 @@ if (s == "number-of-locals") return true; :(before "End Rewrite Instruction(curr, recipe result)") // rewrite `new-default-space` to -// `default-space:&:array:location <- new location:type, number-of-locals:literal` +// `default-space:&:@:location <- new location:type, number-of-locals:literal` // where N is Name[recipe][""] if (curr.name == "new-default-space") { rewrite_default_space_instruction(curr); @@ -199,7 +199,7 @@ def main [ def foo [ local-scope x:num <- copy 34 - return default-space:&:array:location + return default-space:&:@:location ] # both calls to foo should have received the same default-space +mem: storing 1 in location 3 @@ -304,7 +304,7 @@ void rewrite_default_space_instruction(instruction& curr) { curr.ingredients.push_back(reagent("number-of-locals:literal")); if (!curr.products.empty()) raise << "new-default-space can't take any results\n" << end(); - curr.products.push_back(reagent("default-space:&:array:location")); + curr.products.push_back(reagent("default-space:&:@:location")); } :(scenario local_scope_frees_up_addresses_inside_containers) diff --git a/044space_surround.cc b/044space_surround.cc index 1bfba1ee..261249d3 100644 --- a/044space_surround.cc +++ b/044space_surround.cc @@ -7,15 +7,15 @@ :(scenario surrounding_space) # location 1 in space 1 refers to the space surrounding the default space, here 20. def main [ - # pretend address:array:location; in practice we'll use new + # pretend address:@:location; in practice we'll use new 10:num <- copy 0 # refcount 11:num <- copy 5 # length - # pretend address:array:location; in practice we'll use new + # pretend address:@:location; in practice we'll use new 20:num <- copy 0 # refcount 21:num <- copy 5 # length # actual start of this recipe - default-space:&:array:location <- copy 10/unsafe - 0:&:array:location/names:dummy <- copy 20/unsafe # later layers will explain the /names: property + default-space:&:@:location <- copy 10/unsafe + 0:&:@:location/names:dummy <- copy 20/unsafe # later layers will explain the /names: property 1:num <- copy 32 1:num/space:1 <- copy 33 ] diff --git a/045closure_name.cc b/045closure_name.cc index e050f17b..5b057068 100644 --- a/045closure_name.cc +++ b/045closure_name.cc @@ -5,20 +5,20 @@ :(scenario closure) def main [ - default-space:&:array:location <- new location:type, 30 - 1:&:array:location/names:new-counter <- new-counter - 2:num/raw <- increment-counter 1:&:array:location/names:new-counter - 3:num/raw <- increment-counter 1:&:array:location/names:new-counter + default-space:&:@:location <- new location:type, 30 + 1:&:@:location/names:new-counter <- new-counter + 2:num/raw <- increment-counter 1:&:@:location/names:new-counter + 3:num/raw <- increment-counter 1:&:@:location/names:new-counter ] def new-counter [ - default-space:&:array:location <- new location:type, 30 + default-space:&:@:location <- new location:type, 30 x:num <- copy 23 y:num <- copy 3 # variable that will be incremented - return default-space:&:array:location + return default-space:&:@:location ] def increment-counter [ - default-space:&:array:location <- new location:type, 30 - 0:&:array:location/names:new-counter <- next-ingredient # outer space must be created by 'new-counter' above + default-space:&:@:location <- new location:type, 30 + 0:&:@:location/names:new-counter <- next-ingredient # outer space must be created by 'new-counter' above y:num/space:1 <- add y:num/space:1, 1 # increment y:num <- copy 234 # dummy return y:num/space:1 @@ -46,7 +46,7 @@ void collect_surrounding_spaces(const recipe_ordinal r) { if (is_literal(inst.products.at(j))) continue; if (inst.products.at(j).name != "0") continue; if (!is_space(inst.products.at(j))) { - raise << "slot 0 should always have type address:array:location, but is '" << to_string(inst.products.at(j)) << "'\n" << end(); + raise << "slot 0 should always have type address:@:location, but is '" << to_string(inst.products.at(j)) << "'\n" << end(); continue; } string_tree* s = property(inst.products.at(j), "names"); @@ -153,16 +153,16 @@ def new-scope [ new-default-space x:&:num <- new number:type *x:&:num <- copy 34 - return default-space:&:array:location + return default-space:&:@:location ] def use-scope [ local-scope - outer:&:array:location <- next-ingredient - 0:&:array:location/names:new-scope <- copy outer:&:array:location + outer:&:@:location <- next-ingredient + 0:&:@:location/names:new-scope <- copy outer:&:@:location return *x:&:num/space:1 ] def main [ - 1:&:array:location/raw <- new-scope - 2:num/raw <- use-scope 1:&:array:location/raw + 1:&:@:location/raw <- new-scope + 2:num/raw <- use-scope 1:&:@:location/raw ] +mem: storing 34 in location 2 diff --git a/046global.cc b/046global.cc index f85611e1..652d025f 100644 --- a/046global.cc +++ b/046global.cc @@ -11,15 +11,15 @@ :(scenario global_space) def main [ - # pretend address:array:location; in practice we'll use new + # pretend address:@:location; in practice we'll use new 10:num <- copy 0 # refcount 11:num <- copy 5 # length - # pretend address:array:location; in practice we'll use new + # pretend address:@:location; in practice we'll use new 20:num <- copy 0 # refcount 21:num <- copy 5 # length # actual start of this recipe - global-space:&:array:location <- copy 20/unsafe - default-space:&:array:location <- copy 10/unsafe + global-space:&:@:location <- copy 20/unsafe + default-space:&:@:location <- copy 10/unsafe 1:num <- copy 23 1:num/space:global <- copy 24 ] @@ -43,7 +43,7 @@ global_space = 0; :(after "Begin Preprocess write_memory(x, data)") if (x.name == "global-space") { if (!scalar(data) || !is_space(x)) - raise << maybe(current_recipe_name()) << "'global-space' should be of type address:array:location, but tried to write '" << to_string(x.type) << "'\n" << end(); + raise << maybe(current_recipe_name()) << "'global-space' should be of type address:@:location, but tried to write '" << to_string(x.type) << "'\n" << end(); if (Current_routine->global_space) raise << "routine already has a global-space; you can't over-write your globals" << end(); Current_routine->global_space = data.at(0); @@ -63,7 +63,7 @@ if (x.name == "global-space") { :(scenario global_space_with_names) def main [ - global-space:&:array:location <- new location:type, 10 + global-space:&:@:location <- new location:type, 10 x:num <- copy 23 1:num/space:global <- copy 24 ] diff --git a/047check_type_by_name.cc b/047check_type_by_name.cc index 44fc8ddb..e4f70eac 100644 --- a/047check_type_by_name.cc +++ b/047check_type_by_name.cc @@ -109,7 +109,7 @@ def main [ :(scenario array_type_without_size_fails) % Hide_errors = true; def main [ - x:array:num <- merge 2, 12, 13 + x:@:num <- merge 2, 12, 13 ] +error: main can't determine the size of array variable 'x'. Either allocate it separately and make the type of 'x' an address, or specify the length of the array in the type of 'x'. @@ -119,7 +119,7 @@ def foo [ # dummy ] def main [ local-scope - 0:&:array:location/names:foo <- copy 0 # specify surrounding space + 0:&:@:location/names:foo <- copy 0 # specify surrounding space x:bool <- copy 1/true x:num/space:1 <- copy 34 x/space:1 <- copy 35 diff --git a/053recipe_header.cc b/053recipe_header.cc index 40fd4684..a9cd5ca4 100644 --- a/053recipe_header.cc +++ b/053recipe_header.cc @@ -145,7 +145,7 @@ if (result.has_header) { //: Support type abbreviations in headers. :(scenario type_abbreviations_in_recipe_headers) -type string = address:array:char +type string = address:@:char def main [ local-scope a:string <- foo diff --git a/054static_dispatch.cc b/054static_dispatch.cc index 18774602..3f08f6b5 100644 --- a/054static_dispatch.cc +++ b/054static_dispatch.cc @@ -614,7 +614,7 @@ def foo a:bool -> b:num [ +error: main: failed to find a matching call for 'y:num <- foo x' :(scenario override_methods_with_type_abbreviations) -type string = address:array:char +type string = address:@:char def main [ local-scope s:text <- new [abc] diff --git a/055shape_shifting_container.cc b/055shape_shifting_container.cc index c6f3c128..f0a3924f 100644 --- a/055shape_shifting_container.cc +++ b/055shape_shifting_container.cc @@ -69,7 +69,7 @@ container bar:_a:_b [ ] def main [ 1:text <- new [abc] - 2:bar:num:array:char <- merge 34/x, 1:text/y + 2:bar:num:@:char <- merge 34/x, 1:text/y ] $error: 0 @@ -449,7 +449,7 @@ void test_replace_middle_type_ingredient_with_multiple2() { void test_replace_middle_type_ingredient_with_multiple3() { run("container foo_table:_key:_value [\n" - " data:&:array:foo_table_row:_key:_value\n" + " data:&:@:foo_table_row:_key:_value\n" "]\n" "\n" "container foo_table_row:_key:_value [\n" diff --git a/056shape_shifting_recipe.cc b/056shape_shifting_recipe.cc index c4cf17fc..2a91723c 100644 --- a/056shape_shifting_recipe.cc +++ b/056shape_shifting_recipe.cc @@ -905,17 +905,17 @@ def foo x:&:_elem -> y:num [ # version with headers padded with lots of unrelated concrete types def main [ 1:num <- copy 23 - 2:&:array:num <- copy 0 - 3:num <- foo 2:&:array:num, 1:num + 2:&:@:num <- copy 0 + 3:num <- foo 2:&:@:num, 1:num ] # variant with concrete type -def foo dummy:&:array:num, x:num -> y:num, dummy:&:array:num [ +def foo dummy:&:@:num, x:num -> y:num, dummy:&:@:num [ local-scope load-ingredients return 34 ] # shape-shifting variant -def foo dummy:&:array:num, x:_elem -> y:num, dummy:&:array:num [ +def foo dummy:&:@:num, x:_elem -> y:num, dummy:&:@:num [ local-scope load-ingredients return 35 diff --git a/057immutable.cc b/057immutable.cc index 2cf66655..9d9f71d4 100644 --- a/057immutable.cc +++ b/057immutable.cc @@ -34,11 +34,11 @@ $error: 0 :(scenario can_modify_ingredients_that_are_also_products_3) def main [ local-scope - p:&:array:num <- new number:type, 3 + p:&:@:num <- new number:type, 3 p <- foo p ] # mutable address -def foo p:&:array:num -> p:&:array:num [ +def foo p:&:@:num -> p:&:@:num [ local-scope load-ingredients *p <- put-index *p, 0, 34 @@ -183,7 +183,7 @@ $error: 0 :(scenario cannot_modify_address_inside_immutable_ingredients) % Hide_errors = true; container foo [ - x:&:array:num # contains an address + x:&:@:num # contains an address ] def main [ # don't run anything @@ -191,14 +191,14 @@ def main [ def foo a:&:foo [ local-scope load-ingredients - x:&:array:num <- get *a, x:offset # just a regular get of the container + x:&:@:num <- get *a, x:offset # just a regular get of the container *x <- put-index *x, 0, 34 # but then a put-index on the result ] +error: foo: cannot modify 'x' in instruction '*x <- put-index *x, 0, 34' because that would modify a which is an ingredient of recipe foo but not also a product :(scenario cannot_modify_address_inside_immutable_ingredients_2) container foo [ - x:&:array:num # contains an address + x:&:@:num # contains an address ] def main [ # don't run anything @@ -208,7 +208,7 @@ def foo a:&:foo [ load-ingredients b:foo <- merge 0 # modify b, completely unrelated to immutable ingredient a - x:&:array:num <- get b, x:offset + x:&:@:num <- get b, x:offset *x <- put-index *x, 0, 34 ] $error: 0 @@ -221,7 +221,7 @@ container foo [ def main [ # don't run anything ] -def foo a:&:array:&:num [ +def foo a:&:@:&:num [ local-scope load-ingredients x:&:num <- index *a, 0 # just a regular index of the array @@ -231,15 +231,15 @@ def foo a:&:array:&:num [ :(scenario cannot_modify_address_inside_immutable_ingredients_4) container foo [ - x:&:array:num # contains an address + x:&:@:num # contains an address ] def main [ # don't run anything ] -def foo a:&:array:&:num [ +def foo a:&:@:&:num [ local-scope load-ingredients - b:&:array:&:num <- new {(address number): type}, 3 + b:&:@:&:num <- new {(address number): type}, 3 # modify b, completely unrelated to immutable ingredient a x:&:num <- index *b, 0 *x <- copy 34 @@ -309,19 +309,19 @@ def bar [ //: when checking for immutable ingredients, remember to take space into account :(scenario check_space_of_reagents_in_immutability_checks) def main [ - a:&:array:location <- new-closure + a:&:@:location <- new-closure b:&:num <- new number:type - run-closure b:&:num, a:&:array:location + run-closure b:&:num, a:&:@:location ] def new-closure [ new-default-space x:&:num <- new number:type return default-space ] -def run-closure x:&:num, s:&:array:location [ +def run-closure x:&:num, s:&:@:location [ local-scope load-ingredients - 0:&:array:location/names:new-closure <- copy s + 0:&:@:location/names:new-closure <- copy s # different space; always mutable *x:&:num/space:1 <- copy 34 ] diff --git a/059to_text.mu b/059to_text.mu index 678abbe7..66cced73 100644 --- a/059to_text.mu +++ b/059to_text.mu @@ -13,7 +13,7 @@ def to-text-line x:_elem -> y:text [ ] # variant for arrays (since we can't pass them around otherwise) -def array-to-text-line x:&:array:_elem -> y:text [ +def array-to-text-line x:&:@:_elem -> y:text [ local-scope load-ingredients y <- to-text *x @@ -25,7 +25,7 @@ scenario to-text-line-early-warning-for-static-dispatch [ ] scenario array-to-text-line-early-warning-for-static-dispatch [ - n:&:array:num <- new number:type, 3 + n:&:@:num <- new number:type, 3 x:text <- array-to-text-line n # just ensure there were no errors ] @@ -41,7 +41,7 @@ def to-text c:char -> y:text [ scenario character-to-text [ 1:char <- copy 111/o 2:text <- to-text 1:char - 3:array:char <- copy *2:text + 3:@:char <- copy *2:text memory-should-contain [ 3:array:character <- [o] ] diff --git a/061text.mu b/061text.mu index 07964011..21d9f98d 100644 --- a/061text.mu +++ b/061text.mu @@ -218,14 +218,14 @@ scenario buffer-append-works [ x <- append x, c s2:text <- get *x, data:offset 10:bool/raw <- equal s1, s2 - 11:array:char/raw <- copy *s2 + 11:@:char/raw <- copy *s2 +buffer-filled c:char <- copy 100/d x <- append x, c s3:text <- get *x, data:offset 20:bool/raw <- equal s1, s3 21:num/raw <- get *x, length:offset - 30:array:char/raw <- copy *s3 + 30:@:char/raw <- copy *s3 ] memory-should-contain [ # before +buffer-filled @@ -267,7 +267,7 @@ scenario buffer-append-handles-backspace [ c:char <- copy 8/backspace x <- append x, c s:text <- buffer-to-array x - 10:array:char/raw <- copy *s + 10:@:char/raw <- copy *s ] memory-should-contain [ 10 <- 1 # length @@ -333,7 +333,7 @@ scenario text-append-1 [ x:text <- new [hello,] y:text <- new [ world!] z:text <- append x, y - 10:array:char/raw <- copy *z + 10:@:char/raw <- copy *z ] memory-should-contain [ 10:array:character <- [hello, world!] @@ -346,7 +346,7 @@ scenario text-append-null [ x:text <- copy 0 y:text <- new [ world!] z:text <- append x, y - 10:array:char/raw <- copy *z + 10:@:char/raw <- copy *z ] memory-should-contain [ 10:array:character <- [ world!] @@ -359,7 +359,7 @@ scenario text-append-null-2 [ x:text <- new [hello,] y:text <- copy 0 z:text <- append x, y - 10:array:char/raw <- copy *z + 10:@:char/raw <- copy *z ] memory-should-contain [ 10:array:character <- [hello,] @@ -373,7 +373,7 @@ scenario text-append-multiary [ y:text <- new [world] z:text <- new [!] z:text <- append x, y, z - 10:array:char/raw <- copy *z + 10:@:char/raw <- copy *z ] memory-should-contain [ 10:array:character <- [hello, world!] @@ -385,7 +385,7 @@ scenario replace-character-in-text [ local-scope x:text <- new [abc] x <- replace x, 98/b, 122/z - 10:array:char/raw <- copy *x + 10:@:char/raw <- copy *x ] memory-should-contain [ 10:array:character <- [azc] @@ -409,7 +409,7 @@ scenario replace-character-at-start [ local-scope x:text <- new [abc] x <- replace x, 97/a, 122/z - 10:array:char/raw <- copy *x + 10:@:char/raw <- copy *x ] memory-should-contain [ 10:array:character <- [zbc] @@ -421,7 +421,7 @@ scenario replace-character-at-end [ local-scope x:text <- new [abc] x <- replace x, 99/c, 122/z - 10:array:char/raw <- copy *x + 10:@:char/raw <- copy *x ] memory-should-contain [ 10:array:character <- [abz] @@ -433,7 +433,7 @@ scenario replace-character-missing [ local-scope x:text <- new [abc] x <- replace x, 100/d, 122/z - 10:array:char/raw <- copy *x + 10:@:char/raw <- copy *x ] memory-should-contain [ 10:array:character <- [abc] @@ -445,7 +445,7 @@ scenario replace-all-characters [ local-scope x:text <- new [banana] x <- replace x, 97/a, 122/z - 10:array:char/raw <- copy *x + 10:@:char/raw <- copy *x ] memory-should-contain [ 10:array:character <- [bznznz] @@ -532,7 +532,7 @@ scenario interpolate-works [ x:text <- new [abc_ghi] y:text <- new [def] z:text <- interpolate x, y - 10:array:char/raw <- copy *z + 10:@:char/raw <- copy *z ] memory-should-contain [ 10:array:character <- [abcdefghi] @@ -545,7 +545,7 @@ scenario interpolate-at-start [ x:text <- new [_, hello!] y:text <- new [abc] z:text <- interpolate x, y - 10:array:char/raw <- copy *z + 10:@:char/raw <- copy *z ] memory-should-contain [ 10:array:character <- [abc, hello!] @@ -558,7 +558,7 @@ scenario interpolate-at-end [ x:text <- new [hello, _] y:text <- new [abc] z:text <- interpolate x, y - 10:array:char/raw <- copy *z + 10:@:char/raw <- copy *z ] memory-should-contain [ 10:array:character <- [hello, abc] @@ -681,7 +681,7 @@ scenario trim-unmodified [ local-scope x:text <- new [abc] y:text <- trim x - 1:array:char/raw <- copy *y + 1:@:char/raw <- copy *y ] memory-should-contain [ 1:array:character <- [abc] @@ -693,7 +693,7 @@ scenario trim-left [ local-scope x:text <- new [ abc] y:text <- trim x - 1:array:char/raw <- copy *y + 1:@:char/raw <- copy *y ] memory-should-contain [ 1:array:character <- [abc] @@ -705,7 +705,7 @@ scenario trim-right [ local-scope x:text <- new [abc ] y:text <- trim x - 1:array:char/raw <- copy *y + 1:@:char/raw <- copy *y ] memory-should-contain [ 1:array:character <- [abc] @@ -717,7 +717,7 @@ scenario trim-left-right [ local-scope x:text <- new [ abc ] y:text <- trim x - 1:array:char/raw <- copy *y + 1:@:char/raw <- copy *y ] memory-should-contain [ 1:array:character <- [abc] @@ -730,7 +730,7 @@ scenario trim-newline-tab [ x:text <- new [ abc ] y:text <- trim x - 1:array:char/raw <- copy *y + 1:@:char/raw <- copy *y ] memory-should-contain [ 1:array:character <- [abc] @@ -1061,7 +1061,7 @@ scenario match-at-inside-bounds-2 [ ] ] -def split s:text, delim:char -> result:&:array:text [ +def split s:text, delim:char -> result:&:@:text [ local-scope load-ingredients # empty text? return empty array @@ -1107,12 +1107,12 @@ scenario text-split-1 [ run [ local-scope x:text <- new [a/b] - y:&:array:text <- split x, 47/slash + y:&:@:text <- split x, 47/slash 10:num/raw <- length *y a:text <- index *y, 0 b:text <- index *y, 1 - 20:array:char/raw <- copy *a - 30:array:char/raw <- copy *b + 20:@:char/raw <- copy *a + 30:@:char/raw <- copy *b ] memory-should-contain [ 10 <- 2 # length of result @@ -1125,14 +1125,14 @@ scenario text-split-2 [ run [ local-scope x:text <- new [a/b/c] - y:&:array:text <- split x, 47/slash + y:&:@:text <- split x, 47/slash 10:num/raw <- length *y a:text <- index *y, 0 b:text <- index *y, 1 c:text <- index *y, 2 - 20:array:char/raw <- copy *a - 30:array:char/raw <- copy *b - 40:array:char/raw <- copy *c + 20:@:char/raw <- copy *a + 30:@:char/raw <- copy *b + 40:@:char/raw <- copy *c ] memory-should-contain [ 10 <- 3 # length of result @@ -1146,10 +1146,10 @@ scenario text-split-missing [ run [ local-scope x:text <- new [abc] - y:&:array:text <- split x, 47/slash + y:&:@:text <- split x, 47/slash 10:num/raw <- length *y a:text <- index *y, 0 - 20:array:char/raw <- copy *a + 20:@:char/raw <- copy *a ] memory-should-contain [ 10 <- 1 # length of result @@ -1161,7 +1161,7 @@ scenario text-split-empty [ run [ local-scope x:text <- new [] - y:&:array:text <- split x, 47/slash + y:&:@:text <- split x, 47/slash 10:num/raw <- length *y ] memory-should-contain [ @@ -1173,16 +1173,16 @@ scenario text-split-empty-piece [ run [ local-scope x:text <- new [a/b//c] - y:&:array:text <- split x:text, 47/slash + y:&:@:text <- split x:text, 47/slash 10:num/raw <- length *y a:text <- index *y, 0 b:text <- index *y, 1 c:text <- index *y, 2 d:text <- index *y, 3 - 20:array:char/raw <- copy *a - 30:array:char/raw <- copy *b - 40:array:char/raw <- copy *c - 50:array:char/raw <- copy *d + 20:@:char/raw <- copy *a + 30:@:char/raw <- copy *b + 40:@:char/raw <- copy *c + 50:@:char/raw <- copy *d ] memory-should-contain [ 10 <- 4 # length of result @@ -1216,8 +1216,8 @@ scenario text-split-first [ local-scope x:text <- new [a/b] y:text, z:text <- split-first x, 47/slash - 10:array:char/raw <- copy *y - 20:array:char/raw <- copy *z + 10:@:char/raw <- copy *y + 20:@:char/raw <- copy *z ] memory-should-contain [ 10:array:character <- [a] @@ -1253,7 +1253,7 @@ scenario text-copy-copies-partial-text [ local-scope x:text <- new [abc] y:text <- copy-range x, 1, 3 - 1:array:char/raw <- copy *y + 1:@:char/raw <- copy *y ] memory-should-contain [ 1:array:character <- [bc] @@ -1265,7 +1265,7 @@ scenario text-copy-out-of-bounds [ local-scope x:text <- new [abc] y:text <- copy-range x, 2, 4 - 1:array:char/raw <- copy *y + 1:@:char/raw <- copy *y ] memory-should-contain [ 1:array:character <- [c] @@ -1277,7 +1277,7 @@ scenario text-copy-out-of-bounds-2 [ local-scope x:text <- new [abc] y:text <- copy-range x, 3, 3 - 1:array:char/raw <- copy *y + 1:@:char/raw <- copy *y ] memory-should-contain [ 1:array:character <- [] diff --git a/062convert_ingredients_to_text.cc b/062convert_ingredients_to_text.cc index 3fbd6bb0..222203a8 100644 --- a/062convert_ingredients_to_text.cc +++ b/062convert_ingredients_to_text.cc @@ -25,7 +25,7 @@ def main [ :(scenario rewrite_stashes_of_arrays) def main [ local-scope - n:&:array:num <- new number:type, 3 + n:&:@:num <- new number:type, 3 stash *n ] +transform: {stash_2_0: ("address" "array" "character")} <- array-to-text-line {n: ("address" "array" "number")} @@ -34,7 +34,7 @@ def main [ :(scenario ignore_stashes_of_static_arrays) def main [ local-scope - n:array:num:3 <- create-array + n:@:num:3 <- create-array stash n ] +transform: stash {n: ("array" "number" "3")} diff --git a/063array.mu b/063array.mu index 2f859203..d6dac148 100644 --- a/063array.mu +++ b/063array.mu @@ -2,7 +2,7 @@ scenario array-from-args [ run [ local-scope x:text <- new-array 0, 1, 2 - 10:array:char/raw <- copy *x + 10:@:char/raw <- copy *x ] memory-should-contain [ 10 <- 3 # array length diff --git a/066stream.mu b/066stream.mu index e19e09a1..007fbdb3 100644 --- a/066stream.mu +++ b/066stream.mu @@ -1,10 +1,10 @@ # new type to help incrementally scan arrays container stream:_elem [ index:num - data:&:array:_elem + data:&:@:_elem ] -def new-stream s:&:array:_elem -> result:&:stream:_elem [ +def new-stream s:&:@:_elem -> result:&:stream:_elem [ local-scope load-ingredients result <- new {(stream _elem): type} @@ -23,7 +23,7 @@ def read in:&:stream:_elem -> result:_elem, empty?:bool, in:&:stream:_elem [ load-ingredients empty? <- copy 0/false idx:num <- get *in, index:offset - s:&:array:_elem <- get *in, data:offset + s:&:@:_elem <- get *in, data:offset len:num <- length *s at-end?:bool <- greater-or-equal idx len { @@ -41,7 +41,7 @@ def peek in:&:stream:_elem -> result:_elem, empty?:bool [ load-ingredients empty?:bool <- copy 0/false idx:num <- get *in, index:offset - s:&:array:_elem <- get *in, data:offset + s:&:@:_elem <- get *in, data:offset len:num <- length *s at-end?:bool <- greater-or-equal idx len { @@ -68,7 +68,7 @@ def end-of-stream? in:&:stream:_elem -> result:bool [ local-scope load-ingredients idx:num <- get *in, index:offset - s:&:array:_elem <- get *in, data:offset + s:&:@:_elem <- get *in, data:offset len:num <- length *s result <- greater-or-equal idx, len ] diff --git a/068random.mu b/068random.mu index 168b32cb..d22d453f 100644 --- a/068random.mu +++ b/068random.mu @@ -23,7 +23,7 @@ def assume-random-numbers -> result:&:stream:num [ loop } rewind-ingredients - result-data:&:array:num <- new number:type, result-len + result-data:&:@:num <- new number:type, result-len idx:num <- copy 0 { curr:num, arg-received?:bool <- next-ingredient diff --git a/069hash.cc b/069hash.cc index a24ba39c..0ced51ed 100644 --- a/069hash.cc +++ b/069hash.cc @@ -208,7 +208,7 @@ def main [ 11:num <- copy 97 12:num <- copy 98 13:num <- copy 99 - 2:num <- hash 10:array:num/unsafe + 2:num <- hash 10:@:num/unsafe return-unless 2:num 3:text <- new [abc] 4:num <- hash 3:text @@ -355,7 +355,7 @@ case HASH_OLD: { break; } if (!is_mu_text(inst.ingredients.at(0))) { - raise << maybe(get(Recipe, r).name) << "'hash_old' currently only supports strings (address:array:char), but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); + raise << maybe(get(Recipe, r).name) << "'hash_old' currently only supports strings (address:@:char), but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); break; } break; diff --git a/070table.mu b/070table.mu index 0b2b0232..0efaadf0 100644 --- a/070table.mu +++ b/070table.mu @@ -29,7 +29,7 @@ scenario table-read-write-non-integer [ container table:_key:_value [ length:num capacity:num - data:&:array:table_row:_key:_value + data:&:@:table_row:_key:_value ] container table_row:_key:_value [ @@ -42,7 +42,7 @@ def new-table capacity:num -> result:&:table:_key:_value [ local-scope load-ingredients result <- new {(table _key _value): type} - data:&:array:table_row:_key:_value <- new {(table_row _key _value): type}, capacity + data:&:@:table_row:_key:_value <- new {(table_row _key _value): type}, capacity *result <- merge 0/length, capacity, data ] @@ -54,7 +54,7 @@ def put-index table:&:table:_key:_value, key:_key, value:_value -> table:&:table capacity:num <- get *table, capacity:offset _, hash <- divide-with-remainder hash, capacity hash <- abs hash # in case hash overflows into a negative integer - table-data:&:array:table_row:_key:_value <- get *table, data:offset + table-data:&:@:table_row:_key:_value <- get *table, data:offset x:table_row:_key:_value <- index *table-data, hash occupied?:bool <- get x, occupied?:offset not-occupied?:bool <- not occupied?:bool @@ -79,7 +79,7 @@ def index table:&:table:_key:_value, key:_key -> result:_value [ capacity:num <- get *table, capacity:offset _, hash <- divide-with-remainder hash, capacity hash <- abs hash # in case hash overflows into a negative integer - table-data:&:array:table_row:_key:_value <- get *table, data:offset + table-data:&:@:table_row:_key:_value <- get *table, data:offset x:table_row:_key:_value <- index *table-data, hash occupied?:bool <- get x, occupied?:offset assert occupied?, [can't handle missing elements yet] diff --git a/072scheduler.cc b/072scheduler.cc index 232fa0e5..c5e6ac95 100644 --- a/072scheduler.cc +++ b/072scheduler.cc @@ -281,13 +281,13 @@ if (inst.operation == NEXT_INGREDIENT || inst.operation == NEXT_INGREDIENT_WITHO } :(scenario next_ingredient_never_leaks_refcounts) -def create-scope n:&:num -> default-space:&:array:location [ +def create-scope n:&:num -> default-space:&:@:location [ default-space <- new location:type, 2 load-ingredients ] def use-scope [ local-scope - 0:&:array:location/names:create-scope <- next-ingredient + 0:&:@:location/names:create-scope <- next-ingredient n:&:num/space:1 <- next-ingredient # should decrement refcount *n/space:1 <- copy 34 n2:num <- add *n/space:1, 1 @@ -297,7 +297,7 @@ def main [ local-scope n:&:num <- copy 12000/unsafe # pretend allocation with a known address *n <- copy 23 - scope:&:array:location <- create-scope n + scope:&:@:location <- create-scope n n2:&:num <- copy 13000/unsafe n3:num <- use-scope scope, n2 ] diff --git a/074deep_copy.cc b/074deep_copy.cc index 345d84a6..d0670870 100644 --- a/074deep_copy.cc +++ b/074deep_copy.cc @@ -99,16 +99,16 @@ def main [ # that the result is deterministic 100:num <- copy 1 # pretend refcount 101:num <- copy 3 # pretend array length - 1:&:array:num <- copy 100/unsafe # pretend allocation - put-index *1:&:array:num, 0, 34 - put-index *1:&:array:num, 1, 35 - put-index *1:&:array:num, 2, 36 - stash [old:], *1:&:array:num - 2:&:array:num <- deep-copy 1:&:array:num - stash 2:&:array:num - stash [new:], *2:&:array:num - 10:bool <- equal 1:&:array:num, 2:&:array:num - 11:bool <- equal *1:&:array:num, *2:&:array:num + 1:&:@:num <- copy 100/unsafe # pretend allocation + put-index *1:&:@:num, 0, 34 + put-index *1:&:@:num, 1, 35 + put-index *1:&:@:num, 2, 36 + stash [old:], *1:&:@:num + 2:&:@:num <- deep-copy 1:&:@:num + stash 2:&:@:num + stash [new:], *2:&:@:num + 10:bool <- equal 1:&:@:num, 2:&:@:num + 11:bool <- equal *1:&:@:num, *2:&:@:num ] +app: old: 3 34 35 36 +app: new: 3 34 35 36 diff --git a/075channel.mu b/075channel.mu index ed3dee3b..6aae8b87 100644 --- a/075channel.mu +++ b/075channel.mu @@ -30,7 +30,7 @@ container channel:_elem [ # A circular buffer contains values from index first-full up to (but not # including) index first-empty. The reader always modifies it at first-full, # while the writer always modifies it at first-empty. - data:&:array:_elem + data:&:@:_elem ] # Since channels have two ends, and since it's an error to use either end from @@ -51,7 +51,7 @@ def new-channel capacity:num -> in:&:source:_elem, out:&:sink:_elem [ *result <- put *result, first-full:offset, 0 *result <- put *result, first-free:offset, 0 capacity <- add capacity, 1 # unused slot for 'full?' below - data:&:array:_elem <- new _elem:type, capacity + data:&:@:_elem <- new _elem:type, capacity *result <- put *result, data:offset, data in <- new {(source _elem): type} *in <- put *in, chan:offset, result @@ -85,7 +85,7 @@ def write out:&:sink:_elem, val:_elem -> out:&:sink:_elem [ current-routine-is-unblocked #? $print [performing write], 10/newline # store a deep copy of val - circular-buffer:&:array:_elem <- get *chan, data:offset + circular-buffer:&:@:_elem <- get *chan, data:offset free:num <- get *chan, first-free:offset val-copy:_elem <- deep-copy val # on this instruction rests all Mu's concurrency-safety *circular-buffer <- put-index *circular-buffer, free, val-copy @@ -131,7 +131,7 @@ def read in:&:source:_elem -> result:_elem, eof?:bool, in:&:source:_elem [ current-routine-is-unblocked # pull result off full:num <- get *chan, first-full:offset - circular-buffer:&:array:_elem <- get *chan, data:offset + circular-buffer:&:@:_elem <- get *chan, data:offset result <- index *circular-buffer, full # clear the slot empty:&:_elem <- new _elem:type @@ -371,7 +371,7 @@ def channel-full? chan:&:channel:_elem -> result:bool [ def capacity chan:&:channel:_elem -> result:num [ local-scope load-ingredients - q:&:array:_elem <- get *chan, data:offset + q:&:@:_elem <- get *chan, data:offset result <- length *q ] diff --git a/081print.mu b/081print.mu index ea740337..1c42828b 100644 --- a/081print.mu +++ b/081print.mu @@ -6,7 +6,7 @@ container screen [ num-columns:num cursor-row:num cursor-column:num - data:&:array:screen-cell + data:&:@:screen-cell ] container screen-cell [ @@ -19,7 +19,7 @@ def new-fake-screen w:num, h:num -> result:&:screen [ load-ingredients result <- new screen:type bufsize:num <- multiply w, h - data:&:array:screen-cell <- new screen-cell:type, bufsize + data:&:@:screen-cell <- new screen-cell:type, bufsize *result <- merge h/num-rows, w/num-columns, 0/cursor-row, 0/cursor-column, data result <- clear-screen result ] @@ -31,7 +31,7 @@ def clear-screen screen:&:screen -> screen:&:screen [ { break-unless screen # clear fake screen - buf:&:array:screen-cell <- get *screen, data:offset + buf:&:@:screen-cell <- get *screen, data:offset max:num <- length *buf i:num <- copy 0 { @@ -65,7 +65,7 @@ def fake-screen-is-empty? screen:&:screen -> result:bool [ local-scope load-ingredients return-unless screen, 1/true - buf:&:array:screen-cell <- get *screen, data:offset + buf:&:@:screen-cell <- get *screen, data:offset i:num <- copy 0 len:num <- length *buf { @@ -136,7 +136,7 @@ def print screen:&:screen, c:char -> screen:&:screen [ # save character in fake screen index:num <- multiply row, width index <- add index, column - buf:&:array:screen-cell <- get *screen, data:offset + buf:&:@:screen-cell <- get *screen, data:offset len:num <- length *buf # special-case: backspace { @@ -177,8 +177,8 @@ scenario print-character-at-top-left [ fake-screen:&:screen <- new-fake-screen 3/width, 2/height a:char <- copy 97/a fake-screen <- print fake-screen, a:char - cell:&:array:screen-cell <- get *fake-screen, data:offset - 1:array:screen-cell/raw <- copy *cell + cell:&:@:screen-cell <- get *fake-screen, data:offset + 1:@:screen-cell/raw <- copy *cell ] memory-should-contain [ 1 <- 6 # width*height @@ -195,8 +195,8 @@ scenario print-character-in-color [ fake-screen:&:screen <- new-fake-screen 3/width, 2/height a:char <- copy 97/a fake-screen <- print fake-screen, a:char, 1/red - cell:&:array:screen-cell <- get *fake-screen, data:offset - 1:array:screen-cell/raw <- copy *cell + cell:&:@:screen-cell <- get *fake-screen, data:offset + 1:@:screen-cell/raw <- copy *cell ] memory-should-contain [ 1 <- 6 # width*height @@ -216,8 +216,8 @@ scenario print-backspace-character [ backspace:char <- copy 8/backspace fake-screen <- print fake-screen, backspace 10:num/raw <- get *fake-screen, cursor-column:offset - cell:&:array:screen-cell <- get *fake-screen, data:offset - 11:array:screen-cell/raw <- copy *cell + cell:&:@:screen-cell <- get *fake-screen, data:offset + 11:@:screen-cell/raw <- copy *cell ] memory-should-contain [ 10 <- 0 # cursor column @@ -239,8 +239,8 @@ scenario print-extra-backspace-character [ fake-screen <- print fake-screen, backspace fake-screen <- print fake-screen, backspace 1:num/raw <- get *fake-screen, cursor-column:offset - cell:&:array:screen-cell <- get *fake-screen, data:offset - 3:array:screen-cell/raw <- copy *cell + cell:&:@:screen-cell <- get *fake-screen, data:offset + 3:@:screen-cell/raw <- copy *cell ] memory-should-contain [ 1 <- 0 # cursor column @@ -263,8 +263,8 @@ scenario print-character-at-right-margin [ c:char <- copy 99/c fake-screen <- print fake-screen, c 10:num/raw <- get *fake-screen, cursor-column:offset - cell:&:array:screen-cell <- get *fake-screen, data:offset - 11:array:screen-cell/raw <- copy *cell + cell:&:@:screen-cell <- get *fake-screen, data:offset + 11:@:screen-cell/raw <- copy *cell ] memory-should-contain [ 10 <- 1 # cursor column @@ -288,8 +288,8 @@ scenario print-newline-character [ fake-screen <- print fake-screen, newline 10:num/raw <- get *fake-screen, cursor-row:offset 11:num/raw <- get *fake-screen, cursor-column:offset - cell:&:array:screen-cell <- get *fake-screen, data:offset - 12:array:screen-cell/raw <- copy *cell + cell:&:@:screen-cell <- get *fake-screen, data:offset + 12:@:screen-cell/raw <- copy *cell ] memory-should-contain [ 10 <- 1 # cursor row @@ -336,8 +336,8 @@ scenario print-character-at-bottom-right [ fake-screen <- print fake-screen, d 10:num/raw <- get *fake-screen, cursor-row:offset 11:num/raw <- get *fake-screen, cursor-column:offset - cell:&:array:screen-cell <- get *fake-screen, data:offset - 20:array:screen-cell/raw <- copy *cell + cell:&:@:screen-cell <- get *fake-screen, data:offset + 20:@:screen-cell/raw <- copy *cell ] memory-should-contain [ 10 <- 1 # cursor row @@ -441,8 +441,8 @@ scenario clear-line-erases-printed-characters [ fake-screen <- move-cursor fake-screen, 0/row, 0/column # clear line fake-screen <- clear-line fake-screen - cell:&:array:screen-cell <- get *fake-screen, data:offset - 10:array:screen-cell/raw <- copy *cell + cell:&:@:screen-cell <- get *fake-screen, data:offset + 10:@:screen-cell/raw <- copy *cell ] # screen should be blank memory-should-contain [ @@ -677,8 +677,8 @@ scenario print-text-stops-at-right-margin [ fake-screen:&:screen <- new-fake-screen 3/width, 2/height s:text <- new [abcd] fake-screen <- print fake-screen, s:text - cell:&:array:screen-cell <- get *fake-screen, data:offset - 10:array:screen-cell/raw <- copy *cell + cell:&:@:screen-cell <- get *fake-screen, data:offset + 10:@:screen-cell/raw <- copy *cell ] memory-should-contain [ 10 <- 6 # width*height diff --git a/082scenario_screen.cc b/082scenario_screen.cc index 44259cb4..a657627f 100644 --- a/082scenario_screen.cc +++ b/082scenario_screen.cc @@ -253,7 +253,7 @@ void check_screen(const string& expected_contents, const int color) { int screen_location = get_or_insert(Memory, SCREEN)+/*skip refcount*/1; int data_offset = find_element_name(get(Type_ordinal, "screen"), "data", ""); assert(data_offset >= 0); - int screen_data_location = screen_location+data_offset; // type: address:array:char + int screen_data_location = screen_location+data_offset; // type: address:@:char int screen_data_start = get_or_insert(Memory, screen_data_location) + /*skip refcount*/1; // type: array:char int width_offset = find_element_name(get(Type_ordinal, "screen"), "num-columns", ""); int screen_width = get_or_insert(Memory, screen_location+width_offset); @@ -397,7 +397,7 @@ void dump_screen() { 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); - int screen_data_location = screen_location+data_offset; // type: address:array:char + int screen_data_location = screen_location+data_offset; // type: address:@:char int screen_data_start = get_or_insert(Memory, screen_data_location) + /*skip refcount*/1; // type: array:char assert(get_or_insert(Memory, screen_data_start) == screen_width*screen_height); int curr = screen_data_start+1; // skip length diff --git a/084console.mu b/084console.mu index 9923e0bc..0ae0f610 100644 --- a/084console.mu +++ b/084console.mu @@ -22,10 +22,10 @@ container resize-event [ container console [ current-event-index:num - events:&:array:event + events:&:@:event ] -def new-fake-console events:&:array:event -> result:&:console [ +def new-fake-console events:&:@:event -> result:&:console [ local-scope load-ingredients result:&:console <- new console:type @@ -38,7 +38,7 @@ def read-event console:&:console -> result:event, console:&:console, found?:bool { break-unless console current-event-index:num <- get *console, current-event-index:offset - buf:&:array:event <- get *console, events:offset + buf:&:@:event <- get *console, events:offset { max:num <- length *buf done?:bool <- greater-or-equal current-event-index, max diff --git a/088file.mu b/088file.mu index 91dee8de..b0a9b785 100644 --- a/088file.mu +++ b/088file.mu @@ -2,7 +2,7 @@ # are thus easier to test. container filesystem [ - data:&:array:file-mapping + data:&:@:file-mapping ] container file-mapping [ @@ -24,7 +24,7 @@ def start-reading fs:&:filesystem, filename:text -> contents:&:source:char [ } # fake file system i:num <- copy 0 - data:&:array:file-mapping <- get *fs, data:offset + data:&:@:file-mapping <- get *fs, data:offset len:num <- length *data { done?:bool <- greater-or-equal i, len @@ -115,7 +115,7 @@ def transmit-to-fake-file fs:&:filesystem, filename:text, source:&:source:char - new-file-mapping:file-mapping <- merge filename, contents # write to filesystem curr-filename:text <- copy 0 - data:&:array:file-mapping <- get *fs, data:offset + data:&:@:file-mapping <- get *fs, data:offset # replace file contents if it already exists i:num <- copy 0 len:num <- length *data @@ -131,7 +131,7 @@ def transmit-to-fake-file fs:&:filesystem, filename:text, source:&:source:char - } # if file didn't already exist, make room for it new-len:num <- add len, 1 - new-data:&:array:file-mapping <- new file-mapping:type, new-len + new-data:&:@:file-mapping <- new file-mapping:type, new-len put *fs, data:offset, new-data # copy over old files i:num <- copy 0 diff --git a/089scenario_filesystem.cc b/089scenario_filesystem.cc index 26024bc1..1abdf5ea 100644 --- a/089scenario_filesystem.cc +++ b/089scenario_filesystem.cc @@ -20,22 +20,22 @@ scenario assume-filesystem [ |xyz| ] ] - data:&:array:file-mapping <- get *filesystem:&:filesystem, data:offset + data:&:@:file-mapping <- get *filesystem:&:filesystem, data:offset file1:file-mapping <- index *data, 0 file1-name:text <- get file1, name:offset - 10:array:char/raw <- copy *file1-name + 10:@:char/raw <- copy *file1-name file1-contents:text <- get file1, contents:offset - 100:array:char/raw <- copy *file1-contents + 100:@:char/raw <- copy *file1-contents file2:file-mapping <- index *data, 1 file2-name:text <- get file2, name:offset - 30:array:char/raw <- copy *file2-name + 30:@:char/raw <- copy *file2-name file2-contents:text <- get file2, contents:offset - 40:array:char/raw <- copy *file2-contents + 40:@:char/raw <- copy *file2-contents file3:file-mapping <- index *data, 2 file3-name:text <- get file3, name:offset - 50:array:char/raw <- copy *file3-name + 50:@:char/raw <- copy *file3-name file3-contents:text <- get file3, contents:offset - 60:array:char/raw <- copy *file3-contents + 60:@:char/raw <- copy *file3-contents memory-should-contain [ 10:array:character <- [a] 100:array:character <- [a bc @@ -59,12 +59,12 @@ scenario assume-filesystem [ |x\\\\|yz| ] ] - data:&:array:file-mapping <- get *filesystem:&:filesystem, data:offset + data:&:@:file-mapping <- get *filesystem:&:filesystem, data:offset file1:file-mapping <- index *data, 0 file1-name:text <- get file1, name:offset - 10:array:char/raw <- copy *file1-name + 10:@:char/raw <- copy *file1-name file1-contents:text <- get file1, contents:offset - 20:array:char/raw <- copy *file1-contents + 20:@:char/raw <- copy *file1-contents memory-should-contain [ 10:array:character <- [a] 20:array:character <- [x|yz diff --git a/101run_sandboxed.cc b/101run_sandboxed.cc index 3cf0972f..46331b49 100644 --- a/101run_sandboxed.cc +++ b/101run_sandboxed.cc @@ -218,7 +218,7 @@ def main [ 1:text <- new [# ab add 2, 2] 2:text <- run-sandboxed 1:text - 3:array:char <- copy *2:text + 3:@:char <- copy *2:text ] +mem: storing 52 in location 4 @@ -314,7 +314,7 @@ def main [ # try to interactively add 2 and 2 1:text <- new [add 2, 2] 2:text <- run-sandboxed 1:text - 10:array:char <- copy 2:text/lookup + 10:@:char <- copy 2:text/lookup ] # first letter in the output should be '4' in unicode +mem: storing 52 in location 11 @@ -328,7 +328,7 @@ def main [ z:text <- append x:text, y:text ] 2:text <- run-sandboxed 1:text - 10:array:char <- copy 2:text/lookup + 10:@:char <- copy 2:text/lookup ] # output contains "ab" +mem: storing 97 in location 11 @@ -340,7 +340,7 @@ def main [ 1:text <- new [x:num <- copy 34 get x:num, foo:offset] 2:text, 3:text <- run-sandboxed 1:text - 10:array:char <- copy 3:text/lookup + 10:@:char <- copy 3:text/lookup ] # error should be "unknown element foo in container number" +mem: storing 117 in location 11 @@ -352,7 +352,7 @@ get x:num, foo:offset] :(scenario run_interactive_with_comment) def main [ # 2 instructions, with a comment after the first - 1:&:array:num <- new [a:num <- copy 0 # abc + 1:&:@:num <- new [a:num <- copy 0 # abc b:num <- copy 0 ] 2:text, 3:text <- run-sandboxed 1:text diff --git a/102persist.cc b/102persist.cc index b1097d34..abefeda6 100644 --- a/102persist.cc +++ b/102persist.cc @@ -82,7 +82,7 @@ case SAVE: { break; } if (!is_mu_text(inst.ingredients.at(1))) { - raise << maybe(get(Recipe, r).name) << "second ingredient of 'save' should be an address:array:char, but got '" << to_string(inst.ingredients.at(1)) << "'\n" << end(); + raise << maybe(get(Recipe, r).name) << "second ingredient of 'save' should be an address:@:char, but got '" << to_string(inst.ingredients.at(1)) << "'\n" << end(); break; } break; diff --git a/chessboard.mu b/chessboard.mu index d1e5de6f..ea6273cf 100644 --- a/chessboard.mu +++ b/chessboard.mu @@ -62,7 +62,7 @@ scenario print-board-and-read-move [ ## Here's how 'chessboard' is implemented. -type board = address:array:&:array:char +type board = address:@:&:@:char def chessboard screen:&:screen, console:&:console -> screen:&:screen, console:&:console [ local-scope @@ -102,7 +102,7 @@ def chessboard screen:&:screen, console:&:console -> screen:&:screen, console:&: ## a board is an array of files, a file is an array of characters (squares) -def new-board initial-position:&:array:char -> board:board [ +def new-board initial-position:&:@:char -> board:board [ local-scope load-ingredients # assert(length(initial-position) == 64) @@ -115,14 +115,14 @@ def new-board initial-position:&:array:char -> board:board [ { done?:boolean <- equal col, 8 break-if done? - file:&:array:char <- new-file initial-position, col + file:&:@:char <- new-file initial-position, col *board <- put-index *board, col, file col <- add col, 1 loop } ] -def new-file position:&:array:char, index:num -> result:&:array:char [ +def new-file position:&:@:char, index:num -> result:&:@:char [ local-scope load-ingredients index <- multiply index, 8 @@ -157,7 +157,7 @@ def print-board screen:&:screen, board:board -> screen:&:screen [ { done?:boolean <- equal col:num, 8 break-if done?:boolean - f:&:array:char <- index *board, col + f:&:@:char <- index *board, col c:char <- index *f, row print screen, c print screen, space @@ -186,7 +186,7 @@ def initial-position -> board:board [ # B P _ _ _ _ p B # N P _ _ _ _ p n # R P _ _ _ _ p r - initial-position:&:array:char <- new-array 82/R, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 114/r, 78/N, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 110/n, 66/B, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 98/b, 81/Q, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 113/q, 75/K, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 107/k, 66/B, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 98/b, 78/N, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 110/n, 82/R, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 114/r + initial-position:&:@:char <- new-array 82/R, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 114/r, 78/N, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 110/n, 66/B, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 98/b, 81/Q, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 113/q, 75/K, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 107/k, 66/B, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 98/b, 78/N, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 110/n, 82/R, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 114/r #? 82/R, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 114/r, #? 78/N, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 110/n, #? 66/B, 80/P, 32/blank, 32/blank, 32/blank, 32/blank, 112/p, 98/b, @@ -539,8 +539,8 @@ def make-move board:board, m:&:move -> board:board [ from-rank:num <- get *m, from-rank:offset to-file:num <- get *m, to-file:offset to-rank:num <- get *m, to-rank:offset - from-f:&:array:char <- index *board, from-file - to-f:&:array:char <- index *board, to-file + from-f:&:@:char <- index *board, from-file + to-f:&:@:char <- index *board, to-file src:char/square <- index *from-f, from-rank *to-f <- put-index *to-f, to-rank, src *from-f <- put-index *from-f, from-rank, 32/space diff --git a/counters.mu b/counters.mu index 1d959f6d..f45ea095 100644 --- a/counters.mu +++ b/counters.mu @@ -1,24 +1,24 @@ # example program: maintain multiple counters with isolated lexical scopes # (spaces) -def new-counter n:num -> default-space:&:array:location [ +def new-counter n:num -> default-space:&:@:location [ default-space <- new location:type, 30 load-ingredients ] -def increment-counter outer:&:array:location/names:new-counter, x:num -> n:num/space:1 [ +def increment-counter outer:&:@:location/names:new-counter, x:num -> n:num/space:1 [ local-scope load-ingredients - 0:&:array:location/names:new-counter <- copy outer # setup outer space; it *must* come from 'new-counter' + 0:&:@:location/names:new-counter <- copy outer # setup outer space; it *must* come from 'new-counter' n/space:1 <- add n/space:1, x ] def main [ local-scope # counter A - a:&:array:location <- new-counter 34 + a:&:@:location <- new-counter 34 # counter B - b:&:array:location <- new-counter 23 + b:&:@:location <- new-counter 23 # increment both by 2 but in different ways increment-counter a, 1 b-value:num <- increment-counter b, 2 diff --git a/global.mu b/global.mu index 963d04c1..b186fb8d 100644 --- a/global.mu +++ b/global.mu @@ -2,7 +2,7 @@ def main [ # allocate 5 locations for globals - global-space:&:array:location <- new location:type, 5 + global-space:&:@:location <- new location:type, 5 # read to globals by using /space:global 1:num/space:global <- copy 3 foo diff --git a/lambda_to_mu.mu b/lambda_to_mu.mu index 80cfda73..0bdeb43f 100644 --- a/lambda_to_mu.mu +++ b/lambda_to_mu.mu @@ -5,10 +5,10 @@ scenario convert-lambda [ run [ local-scope 1:text/raw <- lambda-to-mu [(add a (multiply b c))] - 2:array:char/raw <- copy *1:text/raw + 2:@:char/raw <- copy *1:text/raw ] memory-should-contain [ - 2:array:char <- [t1 <- multiply b c + 2:@:char <- [t1 <- multiply b c result <- add a t1] ] ] @@ -318,10 +318,10 @@ scenario parse-single-letter-atom [ s:text <- new [a] x:&:cell <- parse s s2:text, 10:boolean/raw <- maybe-convert *x, atom:variant - 11:array:char/raw <- copy *s2 + 11:@:char/raw <- copy *s2 memory-should-contain [ 10 <- 1 # parse result is an atom - 11:array:char <- [a] + 11:@:char <- [a] ] ] @@ -330,10 +330,10 @@ scenario parse-atom [ s:text <- new [abc] x:&:cell <- parse s s2:text, 10:boolean/raw <- maybe-convert *x, atom:variant - 11:array:char/raw <- copy *s2 + 11:@:char/raw <- copy *s2 memory-should-contain [ 10 <- 1 # parse result is an atom - 11:array:char <- [abc] + 11:@:char <- [abc] ] ] @@ -352,16 +352,16 @@ scenario parse-list-of-two-atoms [ x3:&:cell <- first x2 s2:text, 13:boolean/raw <- maybe-convert *x3, atom:variant 14:&:cell/raw <- rest x2 - 20:array:char/raw <- copy *s1 - 30:array:char/raw <- copy *s2 + 20:@:char/raw <- copy *s1 + 30:@:char/raw <- copy *s2 memory-should-contain [ 10 <- 1 # parse result is a pair 11 <- 1 # result.first is an atom 12 <- 1 # result.rest is a pair 13 <- 1 # result.rest.first is an atom 14 <- 0 # result.rest.rest is nil - 20:array:char <- [abc] # result.first - 30:array:char <- [def] # result.rest.first + 20:@:char <- [abc] # result.first + 30:@:char <- [def] # result.rest.first ] ] @@ -380,16 +380,16 @@ scenario parse-list-with-extra-spaces [ x3:&:cell <- first x2 s2:text, 13:boolean/raw <- maybe-convert *x3, atom:variant 14:&:cell/raw <- rest x2 - 20:array:char/raw <- copy *s1 - 30:array:char/raw <- copy *s2 + 20:@:char/raw <- copy *s1 + 30:@:char/raw <- copy *s2 memory-should-contain [ 10 <- 1 # parse result is a pair 11 <- 1 # result.first is an atom 12 <- 1 # result.rest is a pair 13 <- 1 # result.rest.first is an atom 14 <- 0 # result.rest.rest is nil - 20:array:char <- [abc] # result.first - 30:array:char <- [def] # result.rest.first + 20:@:char <- [abc] # result.first + 30:@:char <- [def] # result.rest.first ] ] @@ -412,9 +412,9 @@ scenario parse-list-of-more-than-two-atoms [ x5:&:cell <- first x4 s3:text, 15:boolean/raw <- maybe-convert *x5, atom:variant 16:&:cell/raw <- rest x4 - 20:array:char/raw <- copy *s1 - 30:array:char/raw <- copy *s2 - 40:array:char/raw <- copy *s3 + 20:@:char/raw <- copy *s1 + 30:@:char/raw <- copy *s2 + 40:@:char/raw <- copy *s3 memory-should-contain [ 10 <- 1 # parse result is a pair 11 <- 1 # result.first is an atom @@ -423,9 +423,9 @@ scenario parse-list-of-more-than-two-atoms [ 14 <- 1 # result.rest.rest is a pair 15 <- 1 # result.rest.rest.first is an atom 16 <- 0 # result.rest.rest.rest is nil - 20:array:char <- [abc] # result.first - 30:array:char <- [def] # result.rest.first - 40:array:char <- [ghi] # result.rest.rest + 20:@:char <- [abc] # result.first + 30:@:char <- [def] # result.rest.first + 40:@:char <- [ghi] # result.rest.rest ] ] @@ -443,14 +443,14 @@ scenario parse-nested-list [ s1:text, 12:boolean/raw <- maybe-convert *x2, atom:variant 13:&:cell/raw <- rest x1 14:&:cell/raw <- rest x - 20:array:char/raw <- copy *s1 + 20:@:char/raw <- copy *s1 memory-should-contain [ 10 <- 1 # parse result is a pair 11 <- 1 # result.first is a pair 12 <- 1 # result.first.first is an atom 13 <- 0 # result.first.rest is nil 14 <- 0 # result.rest is nil - 20:array:char <- [abc] # result.first.first + 20:@:char <- [abc] # result.first.first ] ] @@ -471,8 +471,8 @@ scenario parse-nested-list-2 [ x4:&:cell <- first x3 s2:text, 14:boolean/raw <- maybe-convert *x4, atom:variant 15:&:cell/raw <- rest x3 - 20:array:char/raw <- copy *s1 - 30:array:char/raw <- copy *s2 + 20:@:char/raw <- copy *s1 + 30:@:char/raw <- copy *s2 memory-should-contain [ 10 <- 1 # parse result is a pair 11 <- 1 # result.first is a pair @@ -480,8 +480,8 @@ scenario parse-nested-list-2 [ 13 <- 0 # result.first.rest is nil 14 <- 1 # result.rest.first is an atom 15 <- 0 # result.rest.rest is nil - 20:array:char <- [abc] # result.first.first - 30:array:char <- [def] # result.rest.first + 20:@:char <- [abc] # result.first.first + 30:@:char <- [def] # result.rest.first ] ] @@ -521,15 +521,15 @@ scenario parse-dotted-list-of-two-atoms [ x2:&:cell <- rest x s1:text, 11:boolean/raw <- maybe-convert *x1, atom:variant s2:text, 12:boolean/raw <- maybe-convert *x2, atom:variant - 20:array:char/raw <- copy *s1 - 30:array:char/raw <- copy *s2 + 20:@:char/raw <- copy *s1 + 30:@:char/raw <- copy *s2 memory-should-contain [ # parses to < abc | def > 10 <- 1 # parse result is a pair 11 <- 1 # result.first is an atom 12 <- 1 # result.rest is an atom - 20:array:char <- [abc] # result.first - 30:array:char <- [def] # result.rest + 20:@:char <- [abc] # result.first + 30:@:char <- [def] # result.rest ] ] @@ -549,18 +549,18 @@ scenario parse-dotted-list-of-more-than-two-atoms [ s2:text, 13:boolean/raw <- maybe-convert *x3, atom:variant x4:&:cell <- rest x2 s3:text, 14:boolean/raw <- maybe-convert *x4, atom:variant - 20:array:char/raw <- copy *s1 - 30:array:char/raw <- copy *s2 - 40:array:char/raw <- copy *s3 + 20:@:char/raw <- copy *s1 + 30:@:char/raw <- copy *s2 + 40:@:char/raw <- copy *s3 memory-should-contain [ 10 <- 1 # parse result is a pair 11 <- 1 # result.first is an atom 12 <- 1 # result.rest is a pair 13 <- 1 # result.rest.first is an atom 14 <- 1 # result.rest.rest is an atom - 20:array:char <- [abc] # result.first - 30:array:char <- [def] # result.rest.first - 40:array:char <- [ghi] # result.rest.rest + 20:@:char <- [abc] # result.first + 30:@:char <- [def] # result.rest.first + 40:@:char <- [ghi] # result.rest.rest ] ] |