diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-11-06 01:01:58 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-11-06 01:01:58 -0800 |
commit | 26f2e8f5ab1e7d22c2e262f0e4cc1a360d7d3b07 (patch) | |
tree | 083c9703a6b89f01f1b65886a3ffa4967d77e3d4 /034address.cc | |
parent | 2e51e060e2319944b10ddcfb47fb913d7b554056 (diff) | |
download | mu-26f2e8f5ab1e7d22c2e262f0e4cc1a360d7d3b07.tar.gz |
3635 - show the array variant of 'new' earlier
Diffstat (limited to '034address.cc')
-rw-r--r-- | 034address.cc | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/034address.cc b/034address.cc index d1977bd2..5d453684 100644 --- a/034address.cc +++ b/034address.cc @@ -129,6 +129,18 @@ def main [ ] +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 +] ++run: {1: ("address" "array" "number"), "raw": ()} <- new {number: "type"}, {5: "literal"} ++mem: array length is 5 +# don't forget the extra location for array length, and the second extra location for the refcount ++mem: storing 7 in location 3 + :(scenario dilated_reagent_with_new) def main [ 1:address:address:num <- new {(address number): type} @@ -360,15 +372,22 @@ def main [ ] +mem: storing 0 in location 10 -:(scenario new_array) +:(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 +] +# size of number + refcount ++mem: storing 2 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 ] -+run: {1: ("address" "array" "number"), "raw": ()} <- new {number: "type"}, {5: "literal"} -+mem: array length is 5 -# don't forget the extra location for array length, and the second extra location for the refcount +# 5 locations for array contents + array length + refcount +mem: storing 7 in location 3 :(scenario new_empty_array) |