diff options
-rw-r--r-- | 042new.cc | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/042new.cc b/042new.cc index a4e00490..68ae1949 100644 --- a/042new.cc +++ b/042new.cc @@ -76,7 +76,10 @@ case NEW: { // save result products.resize(1); products.at(0).push_back(result); - // initialize array if necessary + // initialize allocated space + for (index_t address = result; address < result+size; ++address) { + Memory[address] = 0; + } if (current_instruction().ingredients.size() > 1) { Memory[result] = array_length; } @@ -100,6 +103,15 @@ void ensure_space(size_t size) { } } +:(scenario new_initializes) +% Memory_allocated_until = 10; +% Memory[Memory_allocated_until] = 1; +recipe main [ + 1:address:number <- new number:type + 2:number <- copy 1:address:number/deref +] ++mem: storing 0 in location 2 + :(scenario new_array) recipe main [ 1:address:array:number/raw <- new number:type, 5:literal |