diff options
-rw-r--r-- | 030container.cc | 24 | ||||
-rw-r--r-- | 031address.cc | 2 | ||||
-rw-r--r-- | 065duplex_list.mu | 12 | ||||
-rw-r--r-- | 074console.mu | 2 | ||||
-rw-r--r-- | 075scenario_console.cc | 2 |
5 files changed, 32 insertions, 10 deletions
diff --git a/030container.cc b/030container.cc index 1f62fe58..529ec7c3 100644 --- a/030container.cc +++ b/030container.cc @@ -267,13 +267,25 @@ case GET_ADDRESS: { raise << maybe(Recipe[r].name) << "second ingredient of 'get' should have type 'offset', but got " << inst.ingredients.at(1).original_string << '\n' << end(); break; } + long long int offset_value = 0; if (is_integer(offset.name)) { // later layers permit non-integer offsets - long long int offset_value = to_integer(offset.name); + offset_value = to_integer(offset.name); if (offset_value < 0 || offset_value >= SIZE(Type[base_type].elements)) { raise << maybe(Recipe[r].name) << "invalid offset " << offset_value << " for " << Type[base_type].name << '\n' << end(); break; } } + else { + offset_value = offset.value; + } + reagent product = inst.products.at(0); + canonize_type(product); + reagent element; + element.types = Type[base_type].elements.at(offset_value); + element.types.insert(element.types.begin(), Type_ordinal["address"]); + if (!types_match(product, element)) { + raise << maybe(Recipe[r].name) << "'get-address' " << offset.original_string << " (" << offset_value << ") on " << Type[base_type].name << " can't be saved in " << product.original_string << "; type should be " << dump_types(element) << '\n' << end(); + } break; } :(before "End Primitive Recipe Implementations") @@ -318,6 +330,16 @@ recipe main [ ] +warn: main: invalid offset -1 for point-number +:(scenario get_address_product_type_mismatch) +% Hide_warnings = true; +recipe main [ + 12:number <- copy 34 + 13:number <- copy 35 + 14:number <- copy 36 + 15:number <- get-address 12:point-number/raw, 1:offset +] ++warn: main: 'get-address' 1:offset (1) on point-number can't be saved in 15:number; type should be address:number + //:: Allow containers to be defined in mu code. :(scenarios load) diff --git a/031address.cc b/031address.cc index 4f5b307a..50c9c446 100644 --- a/031address.cc +++ b/031address.cc @@ -152,7 +152,7 @@ recipe main [ 1:number <- copy 2 2:number <- copy 34 3:number <- copy 35 - 4:number <- get-address 1:address:point/lookup, 0:offset + 4:address:number <- get-address 1:address:point/lookup, 0:offset ] +mem: storing 2 in location 4 diff --git a/065duplex_list.mu b/065duplex_list.mu index 3cf01c47..15aa6a71 100644 --- a/065duplex_list.mu +++ b/065duplex_list.mu @@ -6,13 +6,13 @@ container duplex-list [ prev:address:duplex-list ] -# result:address:duplex-list <- push-duplex x:location, in:address:duplex-list +# result:address:duplex-list <- push-duplex x:character , in:address:duplex-list recipe push-duplex [ local-scope - x:location <- next-ingredient + x:character <- next-ingredient in:address:duplex-list <- next-ingredient result:address:duplex-list <- new duplex-list:type - val:address:location <- get-address *result, value:offset + val:address:character <- get-address *result, value:offset *val <- copy x next:address:address:duplex-list <- get-address *result, next:offset *next <- copy in @@ -91,14 +91,14 @@ scenario duplex-list-handling [ ] ] -# l:address:duplex-list <- insert-duplex x:location, in:address:duplex-list +# l:address:duplex-list <- insert-duplex x:character, in:address:duplex-list # Inserts 'x' after 'in'. Returns some pointer into the list. recipe insert-duplex [ local-scope - x:location <- next-ingredient + x:character <- next-ingredient in:address:duplex-list <- next-ingredient new-node:address:duplex-list <- new duplex-list:type - val:address:location <- get-address *new-node, value:offset + val:address:character <- get-address *new-node, value:offset *val <- copy x next-node:address:duplex-list <- get *in, next:offset # in.next = new-node diff --git a/074console.mu b/074console.mu index 29945850..e346f990 100644 --- a/074console.mu +++ b/074console.mu @@ -28,7 +28,7 @@ container console [ recipe new-fake-console [ local-scope result:address:console <- new console:type - buf:address:address:array:character <- get-address *result, data:offset + buf:address:address:array:event <- get-address *result, data:offset *buf <- next-ingredient idx:address:number <- get-address *result, index:offset *idx <- copy 0 diff --git a/075scenario_console.cc b/075scenario_console.cc index 06bf7d63..44bed831 100644 --- a/075scenario_console.cc +++ b/075scenario_console.cc @@ -52,7 +52,7 @@ case ASSUME_CONSOLE: { istringstream in("[" + current_instruction().ingredients.at(0).name + "]"); recipe r = slurp_body(in); long long int num_events = count_events(r); - // initialize the events + // initialize the events like in new-fake-console long long int size = num_events*size_of_event() + /*space for length*/1; ensure_space(size); long long int event_data_address = Current_routine->alloc; |