diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-03-17 10:12:23 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-03-17 10:12:23 -0700 |
commit | 5f0e4762468c412d57fb54236a0ee90e23a2cb14 (patch) | |
tree | cb9d16c8ed78f9b6ead9efc65437f0fddcbebd73 /cpp/020array | |
parent | cf1eb60b592c5e924c0f31851d01da79acc25533 (diff) | |
download | mu-5f0e4762468c412d57fb54236a0ee90e23a2cb14.tar.gz |
948
Diffstat (limited to 'cpp/020array')
-rw-r--r-- | cpp/020array | 36 |
1 files changed, 10 insertions, 26 deletions
diff --git a/cpp/020array b/cpp/020array index 8a9af8c4..f76342c9 100644 --- a/cpp/020array +++ b/cpp/020array @@ -27,32 +27,16 @@ recipe main [ +mem: storing in location 7 +mem: storing in location 8 -:(replace{} "size_t size_of(reagent r)") -size_t size_of(reagent r) { - type_info t = Type[r.types[0]]; - if (t.is_record) { - int result = 0; - for (size_t i = 0; i < t.size; ++i) { - ostringstream out; - out << result; - reagent x(out.str()); - copy(t.elements[i].begin(), t.elements[i].end(), inserter(x.types, x.types.begin())); - result += size_of(x); - } - return result; - } - if (t.is_array) { - assert(!r.name.empty()); - int base = to_int(r.name); - if (Memory[base] == 0) return 0; - ostringstream out; - out << base+1; - reagent x(out.str()); - x.types.push_back(t.element[0]); - return 1 + Memory[base]*size_of(x); - } - // scalar - return t.size; +:(before "End size_of Cases") +if (t.is_array) { + assert(!r.name.empty()); + int base = to_int(r.name); + if (Memory[base] == 0) return 0; + ostringstream out; + out << base+1; + reagent x(out.str()); + x.types.push_back(t.element[0]); + return 1 + Memory[base]*size_of(x); } :(before "End Globals") |