parent
f5ee2463d0
commit
377b00b045
|
@ -67,17 +67,17 @@ def main [
|
|||
:(scenario write_scalar_to_address_disallowed)
|
||||
% Hide_errors = true;
|
||||
def main [
|
||||
1:address:num <- copy 34
|
||||
1:&:num <- copy 34
|
||||
]
|
||||
+error: main: can't copy '34' to '1:address:num'; types don't match
|
||||
+error: main: can't copy '34' to '1:&:num'; types don't match
|
||||
|
||||
:(scenario write_address_to_character_disallowed)
|
||||
% Hide_errors = true;
|
||||
def main [
|
||||
1:address:num <- copy 12/unsafe
|
||||
2:char <- copy 1:address:num
|
||||
1:&:num <- copy 12/unsafe
|
||||
2:char <- copy 1:&:num
|
||||
]
|
||||
+error: main: can't copy '1:address:num' to '2:char'; types don't match
|
||||
+error: main: can't copy '1:&:num' to '2:char'; types don't match
|
||||
|
||||
:(scenario write_number_to_character_allowed)
|
||||
def main [
|
||||
|
|
|
@ -64,9 +64,9 @@ def main [
|
|||
:(scenario add_checks_return_type)
|
||||
% Hide_errors = true;
|
||||
def main [
|
||||
1:address:num <- add 2, 2
|
||||
1:&:num <- add 2, 2
|
||||
]
|
||||
+error: main: 'add' should yield a number, but got '1:address:num'
|
||||
+error: main: 'add' should yield a number, but got '1:&:num'
|
||||
|
||||
:(before "End Primitive Recipe Declarations")
|
||||
SUBTRACT,
|
||||
|
|
|
@ -258,7 +258,7 @@ def main [
|
|||
12:num <- copy 34
|
||||
13:num <- copy 35
|
||||
14:num <- copy 36
|
||||
15:address:num <- get 12:point-number/raw, 1:offset
|
||||
15:&:num <- get 12:point-number/raw, 1:offset
|
||||
]
|
||||
+error: main: 'get 12:point-number/raw, 1:offset' should write to number but '15' has type (address number)
|
||||
|
||||
|
|
|
@ -218,7 +218,7 @@ def main [
|
|||
2:num <- copy 14
|
||||
3:num <- copy 15
|
||||
4:num <- copy 16
|
||||
5:address:num <- index {1: (array (address number) 3)}, 0
|
||||
5:&:num <- index {1: (array (address number) 3)}, 0
|
||||
]
|
||||
+mem: storing 14 in location 5
|
||||
|
||||
|
@ -330,7 +330,7 @@ void test_array_length_compound() {
|
|||
put(Memory, 2, 14);
|
||||
put(Memory, 3, 15);
|
||||
put(Memory, 4, 16);
|
||||
reagent x("1:array:address:num"); // 3 types, but not a static array
|
||||
reagent x("1:array:&:num"); // 3 types, but not a static array
|
||||
populate_value(x);
|
||||
CHECK_EQ(array_length(x), 3);
|
||||
}
|
||||
|
|
|
@ -225,14 +225,14 @@ else if (command == "exclusive-container") {
|
|||
|
||||
:(scenario exclusive_container_contains_array)
|
||||
exclusive-container foo [
|
||||
x:array:num:3
|
||||
x:@:num:3
|
||||
]
|
||||
$error: 0
|
||||
|
||||
:(scenario exclusive_container_disallows_dynamic_array_element)
|
||||
% Hide_errors = true;
|
||||
exclusive-container foo [
|
||||
x:array:num
|
||||
x:@:num
|
||||
]
|
||||
+error: container 'foo' cannot determine size of element 'x'
|
||||
|
||||
|
|
|
@ -25,29 +25,29 @@
|
|||
# call 'new' two times with identical types without modifying the results; you
|
||||
# should get back different results
|
||||
def main [
|
||||
1:address:num/raw <- new number:type
|
||||
2:address:num/raw <- new number:type
|
||||
3:bool/raw <- equal 1:address:num/raw, 2:address:num/raw
|
||||
1:&:num/raw <- new num:type
|
||||
2:&:num/raw <- new num:type
|
||||
3:bool/raw <- equal 1:&:num/raw, 2:&:num/raw
|
||||
]
|
||||
+mem: storing 0 in location 3
|
||||
|
||||
:(scenario new_array)
|
||||
# call 'new' with a second ingredient to allocate an array of some type rather than a single copy
|
||||
def main [
|
||||
1:address:array:num/raw <- new number:type, 5
|
||||
2:address:num/raw <- new number:type
|
||||
3:num/raw <- subtract 2:address:num/raw, 1:address:array:num/raw
|
||||
1:&:@:num/raw <- new num:type, 5
|
||||
2:&:num/raw <- new num:type
|
||||
3:num/raw <- subtract 2:&:num/raw, 1:&:@:num/raw
|
||||
]
|
||||
+run: {1: ("address" "array" "number"), "raw": ()} <- new {number: "type"}, {5: "literal"}
|
||||
+run: {1: ("address" "array" "number"), "raw": ()} <- new {num: "type"}, {5: "literal"}
|
||||
+mem: array length is 5
|
||||
# don't forget the extra location for array length
|
||||
+mem: storing 6 in location 3
|
||||
|
||||
:(scenario dilated_reagent_with_new)
|
||||
def main [
|
||||
1:address:address:num <- new {(address number): type}
|
||||
1:&:&:num <- new {(& num): type}
|
||||
]
|
||||
+new: size of '(address number)' is 1
|
||||
+new: size of '(& num)' is 1
|
||||
|
||||
//: 'new' takes a weird 'type' as its first ingredient; don't error on it
|
||||
:(before "End Mu Types Initialization")
|
||||
|
@ -135,19 +135,19 @@ def main [
|
|||
:(scenario new_discerns_singleton_list_from_atom_container)
|
||||
% Hide_errors = true;
|
||||
def main [
|
||||
1:address:num/raw <- new {(num): type} # should be '{num: type}'
|
||||
1:&:num/raw <- new {(num): type} # should be '{num: type}'
|
||||
]
|
||||
+error: main: product of 'new' has incorrect type: '1:address:num/raw <- new {(num): type}'
|
||||
+error: main: product of 'new' has incorrect type: '1:&:num/raw <- new {(num): type}'
|
||||
|
||||
:(scenario new_with_type_abbreviation)
|
||||
def main [
|
||||
1:address:num/raw <- new num:type
|
||||
1:&:num/raw <- new num:type
|
||||
]
|
||||
$error: 0
|
||||
|
||||
:(scenario new_with_type_abbreviation_inside_compound)
|
||||
def main [
|
||||
{1: (address address number), raw: ()} <- new {(& num): type}
|
||||
{1: (& & num), raw: ()} <- new {(& num): type}
|
||||
]
|
||||
$error: 0
|
||||
|
||||
|
@ -283,35 +283,35 @@ void ensure_space(int size) {
|
|||
% Memory_allocated_until = 10;
|
||||
% put(Memory, Memory_allocated_until, 1);
|
||||
def main [
|
||||
1:address:num <- new number:type
|
||||
1:&:num <- new num:type
|
||||
]
|
||||
+mem: storing 0 in location 10
|
||||
|
||||
:(scenario new_size)
|
||||
def main [
|
||||
11:address:num/raw <- new number:type
|
||||
12:address:num/raw <- new number:type
|
||||
13:num/raw <- subtract 12:address:num/raw, 11:address:num/raw
|
||||
11:&:num/raw <- new num:type
|
||||
12:&:num/raw <- new num:type
|
||||
13:num/raw <- subtract 12:&:num/raw, 11:&:num/raw
|
||||
]
|
||||
# size of number
|
||||
+mem: storing 1 in location 13
|
||||
|
||||
:(scenario new_array_size)
|
||||
def main [
|
||||
1:address:array:num/raw <- new number:type, 5
|
||||
2:address:num/raw <- new number:type
|
||||
3:num/raw <- subtract 2:address:num/raw, 1:address:array:num/raw
|
||||
1:&:@:num/raw <- new num:type, 5
|
||||
2:&:num/raw <- new num:type
|
||||
3:num/raw <- subtract 2:&:num/raw, 1:&:@:num/raw
|
||||
]
|
||||
# 5 locations for array contents + array length
|
||||
+mem: storing 6 in location 3
|
||||
|
||||
:(scenario new_empty_array)
|
||||
def main [
|
||||
1:address:array:num/raw <- new number:type, 0
|
||||
2:address:num/raw <- new number:type
|
||||
3:num/raw <- subtract 2:address:num/raw, 1:address:array:num/raw
|
||||
1:&:@:num/raw <- new num:type, 0
|
||||
2:&:num/raw <- new num:type
|
||||
3:num/raw <- subtract 2:&:num/raw, 1:&:@:num/raw
|
||||
]
|
||||
+run: {1: ("address" "array" "number"), "raw": ()} <- new {number: "type"}, {0: "literal"}
|
||||
+run: {1: ("address" "array" "number"), "raw": ()} <- new {num: "type"}, {0: "literal"}
|
||||
+mem: array length is 0
|
||||
# one location for array length
|
||||
+mem: storing 1 in location 3
|
||||
|
@ -320,8 +320,8 @@ def main [
|
|||
:(scenario new_overflow)
|
||||
% Initial_memory_per_routine = 2; // barely enough room for point allocation below
|
||||
def main [
|
||||
1:address:num/raw <- new number:type
|
||||
2:address:point/raw <- new point:type # not enough room in initial page
|
||||
1:&:num/raw <- new num:type
|
||||
2:&:point/raw <- new point:type # not enough room in initial page
|
||||
]
|
||||
+new: routine allocated memory from 1000 to 1002
|
||||
+new: routine allocated memory from 1002 to 1004
|
||||
|
@ -329,6 +329,6 @@ def main [
|
|||
:(scenario new_without_ingredient)
|
||||
% Hide_errors = true;
|
||||
def main [
|
||||
1:address:number <- new # missing ingredient
|
||||
1:&:num <- new # missing ingredient
|
||||
]
|
||||
+error: main: 'new' requires one or two ingredients, but got '1:address:number <- new'
|
||||
+error: main: 'new' requires one or two ingredients, but got '1:&:num <- new'
|
||||
|
|
134
035lookup.cc
134
035lookup.cc
|
@ -5,10 +5,10 @@
|
|||
|
||||
:(scenario copy_indirect)
|
||||
def main [
|
||||
1:address:num <- copy 10/unsafe
|
||||
1:&:num <- copy 10/unsafe
|
||||
10:num <- copy 34
|
||||
# This loads location 1 as an address and looks up *that* location.
|
||||
2:num <- copy 1:address:num/lookup
|
||||
2:num <- copy 1:&:num/lookup
|
||||
]
|
||||
+mem: storing 34 in location 2
|
||||
|
||||
|
@ -19,8 +19,8 @@ canonize(x);
|
|||
//: 'lookup' property
|
||||
:(scenario store_indirect)
|
||||
def main [
|
||||
1:address:num <- copy 10/unsafe
|
||||
1:address:num/lookup <- copy 34
|
||||
1:&:num <- copy 10/unsafe
|
||||
1:&:num/lookup <- copy 34
|
||||
]
|
||||
+mem: storing 34 in location 10
|
||||
|
||||
|
@ -31,20 +31,20 @@ canonize(x);
|
|||
:(scenario store_to_0_fails)
|
||||
% Hide_errors = true;
|
||||
def main [
|
||||
1:address:num <- copy null
|
||||
1:address:num/lookup <- copy 34
|
||||
1:&:num <- copy null
|
||||
1:&:num/lookup <- copy 34
|
||||
]
|
||||
-mem: storing 34 in location 0
|
||||
+error: can't write to location 0 in '1:address:num/lookup <- copy 34'
|
||||
+error: can't write to location 0 in '1:&:num/lookup <- copy 34'
|
||||
|
||||
//: attempts to /lookup address 0 always loudly fail
|
||||
:(scenario lookup_0_fails)
|
||||
% Hide_errors = true;
|
||||
def main [
|
||||
1:address:num <- copy null
|
||||
2:num <- copy 1:address:num/lookup
|
||||
1:&:num <- copy null
|
||||
2:num <- copy 1:&:num/lookup
|
||||
]
|
||||
+error: main: tried to lookup 0 in '2:num <- copy 1:address:num/lookup'
|
||||
+error: main: tried to lookup 0 in '2:num <- copy 1:&:num/lookup'
|
||||
|
||||
:(scenario lookup_0_dumps_callstack)
|
||||
% Hide_errors = true;
|
||||
|
@ -52,10 +52,10 @@ def main [
|
|||
foo null
|
||||
]
|
||||
def foo [
|
||||
1:address:num <- next-input
|
||||
2:num <- copy 1:address:num/lookup
|
||||
1:&:num <- next-input
|
||||
2:num <- copy 1:&:num/lookup
|
||||
]
|
||||
+error: foo: tried to lookup 0 in '2:num <- copy 1:address:num/lookup'
|
||||
+error: foo: tried to lookup 0 in '2:num <- copy 1:&:num/lookup'
|
||||
+error: called from main: foo null
|
||||
|
||||
:(code)
|
||||
|
@ -156,29 +156,29 @@ void drop_one_lookup(reagent& r) {
|
|||
|
||||
:(scenario get_indirect)
|
||||
def main [
|
||||
1:address:point <- copy 10/unsafe
|
||||
1:&:point <- copy 10/unsafe
|
||||
10:num <- copy 34
|
||||
11:num <- copy 35
|
||||
2:num <- get 1:address:point/lookup, 0:offset
|
||||
2:num <- get 1:&:point/lookup, 0:offset
|
||||
]
|
||||
+mem: storing 34 in location 2
|
||||
|
||||
:(scenario get_indirect2)
|
||||
def main [
|
||||
1:address:point <- copy 10/unsafe
|
||||
1:&:point <- copy 10/unsafe
|
||||
10:num <- copy 34
|
||||
11:num <- copy 35
|
||||
2:address:num <- copy 20/unsafe
|
||||
2:address:num/lookup <- get 1:address:point/lookup, 0:offset
|
||||
2:&:num <- copy 20/unsafe
|
||||
2:&:num/lookup <- get 1:&:point/lookup, 0:offset
|
||||
]
|
||||
+mem: storing 34 in location 20
|
||||
|
||||
:(scenario include_nonlookup_properties)
|
||||
def main [
|
||||
1:address:point <- copy 10/unsafe
|
||||
1:&:point <- copy 10/unsafe
|
||||
10:num <- copy 34
|
||||
11:num <- copy 35
|
||||
2:num <- get 1:address:point/lookup/foo, 0:offset
|
||||
2:num <- get 1:&:point/lookup/foo, 0:offset
|
||||
]
|
||||
+mem: storing 34 in location 2
|
||||
|
||||
|
@ -191,10 +191,10 @@ canonize(base);
|
|||
|
||||
:(scenario put_indirect)
|
||||
def main [
|
||||
1:address:point <- copy 10/unsafe
|
||||
1:&:point <- copy 10/unsafe
|
||||
10:num <- copy 34
|
||||
11:num <- copy 35
|
||||
1:address:point/lookup <- put 1:address:point/lookup, 0:offset, 36
|
||||
1:&:point/lookup <- put 1:&:point/lookup, 0:offset, 36
|
||||
]
|
||||
+mem: storing 36 in location 10
|
||||
|
||||
|
@ -208,12 +208,12 @@ canonize(base);
|
|||
:(scenario put_product_error_with_lookup)
|
||||
% Hide_errors = true;
|
||||
def main [
|
||||
1:address:point <- copy 10/unsafe
|
||||
1:&:point <- copy 10/unsafe
|
||||
10:num <- copy 34
|
||||
11:num <- copy 35
|
||||
1:address:point <- put 1:address:point/lookup, x:offset, 36
|
||||
1:&:point <- put 1:&:point/lookup, x:offset, 36
|
||||
]
|
||||
+error: main: product of 'put' must be first ingredient '1:address:point/lookup', but got '1:address:point'
|
||||
+error: main: product of 'put' must be first ingredient '1:&:point/lookup', but got '1:&:point'
|
||||
|
||||
:(before "End PUT Product Checks")
|
||||
reagent/*copy*/ p = inst.products.at(0);
|
||||
|
@ -228,21 +228,21 @@ if (!types_strictly_match(p, i)) {
|
|||
:(scenario new_error)
|
||||
% Hide_errors = true;
|
||||
def main [
|
||||
1:num/raw <- new number:type
|
||||
1:num/raw <- new num:type
|
||||
]
|
||||
+error: main: product of 'new' has incorrect type: '1:num/raw <- new number:type'
|
||||
+error: main: product of 'new' has incorrect type: '1:num/raw <- new num:type'
|
||||
|
||||
:(after "Update NEW product in Check")
|
||||
canonize_type(product);
|
||||
|
||||
:(scenario copy_array_indirect)
|
||||
def main [
|
||||
10:array:num:3 <- create-array
|
||||
10:@:num:3 <- create-array
|
||||
11:num <- copy 14
|
||||
12:num <- copy 15
|
||||
13:num <- copy 16
|
||||
1:address:array:num <- copy 10/unsafe
|
||||
2:array:num <- copy 1:address:array:num/lookup
|
||||
1:&:@:num <- copy 10/unsafe
|
||||
2:@:num <- copy 1:&:@:num/lookup
|
||||
]
|
||||
+mem: storing 3 in location 2
|
||||
+mem: storing 14 in location 3
|
||||
|
@ -251,8 +251,8 @@ def main [
|
|||
|
||||
:(scenario create_array_indirect)
|
||||
def main [
|
||||
1:address:array:num:3 <- copy 1000/unsafe # pretend allocation
|
||||
1:address:array:num:3/lookup <- create-array
|
||||
1:&:@:num:3 <- copy 1000/unsafe # pretend allocation
|
||||
1:&:@:num:3/lookup <- create-array
|
||||
]
|
||||
+mem: storing 3 in location 1000
|
||||
|
||||
|
@ -263,12 +263,12 @@ canonize(product);
|
|||
|
||||
:(scenario index_indirect)
|
||||
def main [
|
||||
10:array:num:3 <- create-array
|
||||
10:@:num:3 <- create-array
|
||||
11:num <- copy 14
|
||||
12:num <- copy 15
|
||||
13:num <- copy 16
|
||||
1:address:array:num <- copy 10/unsafe
|
||||
2:num <- index 1:address:array:num/lookup, 1
|
||||
1:&:@:num <- copy 10/unsafe
|
||||
2:num <- index 1:&:@:num/lookup, 1
|
||||
]
|
||||
+mem: storing 15 in location 2
|
||||
|
||||
|
@ -286,38 +286,38 @@ canonize(index);
|
|||
|
||||
:(scenario put_index_indirect)
|
||||
def main [
|
||||
10:array:num:3 <- create-array
|
||||
10:@:num:3 <- create-array
|
||||
11:num <- copy 14
|
||||
12:num <- copy 15
|
||||
13:num <- copy 16
|
||||
1:address:array:num <- copy 10/unsafe
|
||||
1:address:array:num/lookup <- put-index 1:address:array:num/lookup, 1, 34
|
||||
1:&:@:num <- copy 10/unsafe
|
||||
1:&:@:num/lookup <- put-index 1:&:@:num/lookup, 1, 34
|
||||
]
|
||||
+mem: storing 34 in location 12
|
||||
|
||||
:(scenario put_index_indirect_2)
|
||||
def main [
|
||||
1:array:num:3 <- create-array
|
||||
1:@:num:3 <- create-array
|
||||
2:num <- copy 14
|
||||
3:num <- copy 15
|
||||
4:num <- copy 16
|
||||
5:address:num <- copy 10/unsafe
|
||||
5:&:num <- copy 10/unsafe
|
||||
10:num <- copy 1
|
||||
1:array:num:3 <- put-index 1:array:num:3, 5:address:num/lookup, 34
|
||||
1:@:num:3 <- put-index 1:@:num:3, 5:&:num/lookup, 34
|
||||
]
|
||||
+mem: storing 34 in location 3
|
||||
|
||||
:(scenario put_index_product_error_with_lookup)
|
||||
% Hide_errors = true;
|
||||
def main [
|
||||
10:array:num:3 <- create-array
|
||||
10:@:num:3 <- create-array
|
||||
11:num <- copy 14
|
||||
12:num <- copy 15
|
||||
13:num <- copy 16
|
||||
1:address:array:num <- copy 10/unsafe
|
||||
1:address:array:num <- put-index 1:address:array:num/lookup, 1, 34
|
||||
1:&:@:num <- copy 10/unsafe
|
||||
1:&:@:num <- put-index 1:&:@:num/lookup, 1, 34
|
||||
]
|
||||
+error: main: product of 'put-index' must be first ingredient '1:address:array:num/lookup', but got '1:address:array:num'
|
||||
+error: main: product of 'put-index' must be first ingredient '1:&:@:num/lookup', but got '1:&:@:num'
|
||||
|
||||
:(before "End PUT_INDEX Product Checks")
|
||||
reagent/*copy*/ p = inst.products.at(0);
|
||||
|
@ -331,11 +331,11 @@ if (!types_strictly_match(p, i)) {
|
|||
|
||||
:(scenario dilated_reagent_in_static_array)
|
||||
def main [
|
||||
{1: (array (address number) 3)} <- create-array
|
||||
5:address:num <- new number:type
|
||||
{1: (array (address number) 3)} <- put-index {1: (array (address number) 3)}, 0, 5:address:num
|
||||
*5:address:num <- copy 34
|
||||
6:num <- copy *5:address:num
|
||||
{1: (@ (& num) 3)} <- create-array
|
||||
5:&:num <- new num:type
|
||||
{1: (@ (& num) 3)} <- put-index {1: (@ (& num) 3)}, 0, 5:&:num
|
||||
*5:&:num <- copy 34
|
||||
6:num <- copy *5:&:num
|
||||
]
|
||||
+run: creating array of size 4
|
||||
+mem: storing 34 in location 6
|
||||
|
@ -354,12 +354,12 @@ canonize(index);
|
|||
|
||||
:(scenario length_indirect)
|
||||
def main [
|
||||
10:array:num:3 <- create-array
|
||||
10:@:num:3 <- create-array
|
||||
11:num <- copy 14
|
||||
12:num <- copy 15
|
||||
13:num <- copy 16
|
||||
1:address:array:num <- copy 10/unsafe
|
||||
2:num <- length 1:address:array:num/lookup
|
||||
1:&:@:num <- copy 10/unsafe
|
||||
2:num <- length 1:&:@:num/lookup
|
||||
]
|
||||
+mem: storing 3 in location 2
|
||||
|
||||
|
@ -371,8 +371,8 @@ canonize(array);
|
|||
:(scenario maybe_convert_indirect)
|
||||
def main [
|
||||
10:number-or-point <- merge 0/number, 34
|
||||
1:address:number-or-point <- copy 10/unsafe
|
||||
2:num, 3:bool <- maybe-convert 1:address:number-or-point/lookup, i:variant
|
||||
1:&:number-or-point <- copy 10/unsafe
|
||||
2:num, 3:bool <- maybe-convert 1:&:number-or-point/lookup, i:variant
|
||||
]
|
||||
+mem: storing 1 in location 3
|
||||
+mem: storing 34 in location 2
|
||||
|
@ -380,9 +380,9 @@ def main [
|
|||
:(scenario maybe_convert_indirect_2)
|
||||
def main [
|
||||
10:number-or-point <- merge 0/number, 34
|
||||
1:address:number-or-point <- copy 10/unsafe
|
||||
2:address:num <- copy 20/unsafe
|
||||
2:address:num/lookup, 3:bool <- maybe-convert 1:address:number-or-point/lookup, i:variant
|
||||
1:&:number-or-point <- copy 10/unsafe
|
||||
2:&:num <- copy 20/unsafe
|
||||
2:&:num/lookup, 3:bool <- maybe-convert 1:&:number-or-point/lookup, i:variant
|
||||
]
|
||||
+mem: storing 1 in location 3
|
||||
+mem: storing 34 in location 20
|
||||
|
@ -390,9 +390,9 @@ def main [
|
|||
:(scenario maybe_convert_indirect_3)
|
||||
def main [
|
||||
10:number-or-point <- merge 0/number, 34
|
||||
1:address:number-or-point <- copy 10/unsafe
|
||||
2:address:bool <- copy 20/unsafe
|
||||
3:num, 2:address:bool/lookup <- maybe-convert 1:address:number-or-point/lookup, i:variant
|
||||
1:&:number-or-point <- copy 10/unsafe
|
||||
2:&:bool <- copy 20/unsafe
|
||||
3:num, 2:&:bool/lookup <- maybe-convert 1:&:number-or-point/lookup, i:variant
|
||||
]
|
||||
+mem: storing 1 in location 20
|
||||
+mem: storing 34 in location 3
|
||||
|
@ -413,8 +413,8 @@ canonize(status);
|
|||
|
||||
:(scenario merge_exclusive_container_indirect)
|
||||
def main [
|
||||
1:address:number-or-point <- copy 10/unsafe
|
||||
1:address:number-or-point/lookup <- merge 0/number, 34
|
||||
1:&:number-or-point <- copy 10/unsafe
|
||||
1:&:number-or-point/lookup <- merge 0/number, 34
|
||||
]
|
||||
+mem: storing 0 in location 10
|
||||
+mem: storing 34 in location 11
|
||||
|
@ -426,11 +426,11 @@ canonize(x);
|
|||
|
||||
:(scenario lookup_abbreviation)
|
||||
def main [
|
||||
1:address:number <- copy 10/unsafe
|
||||
10:number <- copy 34
|
||||
3:number <- copy *1:address:number
|
||||
1:&:num <- copy 10/unsafe
|
||||
10:num <- copy 34
|
||||
3:num <- copy *1:&:num
|
||||
]
|
||||
+parse: ingredient: {1: ("address" "number"), "lookup": ()}
|
||||
+parse: ingredient: {1: ("&" "num"), "lookup": ()}
|
||||
+mem: storing 34 in location 3
|
||||
|
||||
:(before "End Parsing reagent")
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
:(scenario new_reclaim)
|
||||
def main [
|
||||
1:address:num <- new number:type
|
||||
2:num <- deaddress 1:address:num # because 1 will get reset during abandon below
|
||||
abandon 1:address:num
|
||||
3:address:num <- new number:type # must be same size as abandoned memory to reuse
|
||||
4:num <- deaddress 3:address:num
|
||||
1:&:num <- new number:type
|
||||
2:num <- deaddress 1:&:num # because 1 will get reset during abandon below
|
||||
abandon 1:&:num
|
||||
3:&:num <- new number:type # must be same size as abandoned memory to reuse
|
||||
4:num <- deaddress 3:&:num
|
||||
5:bool <- equal 2:num, 4:num
|
||||
]
|
||||
# both allocations should have returned the same address
|
||||
|
@ -79,11 +79,11 @@ if (get_or_insert(Current_routine->free_list, size)) {
|
|||
|
||||
:(scenario new_differing_size_no_reclaim)
|
||||
def main [
|
||||
1:address:num <- new number:type
|
||||
2:num <- deaddress 1:address:num
|
||||
abandon 1:address:num
|
||||
3:address:array:num <- new number:type, 2 # different size
|
||||
4:num <- deaddress 3:address:array:num
|
||||
1:&:num <- new number:type
|
||||
2:num <- deaddress 1:&:num
|
||||
abandon 1:&:num
|
||||
3:&:@:num <- new number:type, 2 # different size
|
||||
4:num <- deaddress 3:&:@:num
|
||||
5:bool <- equal 2:num, 4:num
|
||||
]
|
||||
# no reuse
|
||||
|
@ -91,11 +91,11 @@ def main [
|
|||
|
||||
:(scenario new_reclaim_array)
|
||||
def main [
|
||||
1:address:array:num <- new number:type, 2
|
||||
2:num <- deaddress 1:address:array:num
|
||||
abandon 1:address:array:num
|
||||
3:address:array:num <- new number:type, 2 # same size
|
||||
4:num <- deaddress 3:address:array:num
|
||||
1:&:@:num <- new number:type, 2
|
||||
2:num <- deaddress 1:&:@:num
|
||||
abandon 1:&:@:num
|
||||
3:&:@:num <- new number:type, 2 # same size
|
||||
4:num <- deaddress 3:&:@:num
|
||||
5:bool <- equal 2:num, 4:num
|
||||
]
|
||||
# both calls to new returned identical addresses
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
//: A Mu text is an address to an array of characters.
|
||||
:(before "End Mu Types Initialization")
|
||||
put(Type_abbreviations, "text", new_type_tree("address:array:character"));
|
||||
put(Type_abbreviations, "text", new_type_tree("&:@:character"));
|
||||
|
||||
:(scenario new_string)
|
||||
def main [
|
||||
|
@ -118,7 +118,7 @@ if (!canonize_type(x)) return false;
|
|||
:(scenario new_string_overflow)
|
||||
% Initial_memory_per_routine = 2;
|
||||
def main [
|
||||
1:address:num/raw <- new number:type
|
||||
1:&:num/raw <- new number:type
|
||||
2:text/raw <- new [a] # not enough room in initial page, if you take the array length into account
|
||||
]
|
||||
+new: routine allocated memory from 1000 to 1002
|
||||
|
|
|
@ -157,7 +157,7 @@ curr->name_before_rewrite = curr->name;
|
|||
def main [
|
||||
local-scope
|
||||
n:num <- copy 11
|
||||
c:character <- copy 111/o
|
||||
c:char <- copy 111/o
|
||||
a:text <- append [abc], 10, n, c
|
||||
expected:text <- new [abc1011o]
|
||||
10:bool/raw <- equal a, expected
|
||||
|
|
|
@ -70,24 +70,24 @@ if (r.type->atom && r.type->name == "continuation") {
|
|||
:(scenario delimited_continuation)
|
||||
recipe main [
|
||||
1:continuation <- call-with-continuation-mark 233/mark, f, 77 # 77 is an argument to f
|
||||
2:number <- copy 5
|
||||
2:num <- copy 5
|
||||
{
|
||||
2:number <- call 1:continuation, 2:number # jump to 'return-continuation-until-mark' below
|
||||
3:boolean <- greater-or-equal 2:number, 8
|
||||
break-if 3:boolean
|
||||
2:num <- call 1:continuation, 2:num # jump to 'return-continuation-until-mark' below
|
||||
3:bool <- greater-or-equal 2:num, 8
|
||||
break-if 3:bool
|
||||
loop
|
||||
}
|
||||
]
|
||||
recipe f [
|
||||
11:number <- next-ingredient
|
||||
12:number <- g 11:number
|
||||
return 12:number
|
||||
11:num <- next-ingredient
|
||||
12:num <- g 11:num
|
||||
return 12:num
|
||||
]
|
||||
recipe g [
|
||||
21:number <- next-ingredient
|
||||
22:number <- return-continuation-until-mark 233/mark
|
||||
23:number <- add 22:number, 1
|
||||
return 23:number
|
||||
21:num <- next-ingredient
|
||||
22:num <- return-continuation-until-mark 233/mark
|
||||
23:num <- add 22:num, 1
|
||||
return 23:num
|
||||
]
|
||||
# first call of 'g' executes the part before return-continuation-until-mark
|
||||
+mem: storing 77 in location 21
|
||||
|
|
Loading…
Reference in New Issue