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 | |
parent | cf1eb60b592c5e924c0f31851d01da79acc25533 (diff) | |
download | mu-5f0e4762468c412d57fb54236a0ee90e23a2cb14.tar.gz |
948
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/013run | 4 | ||||
-rw-r--r-- | cpp/020array | 36 |
2 files changed, 12 insertions, 28 deletions
diff --git a/cpp/013run b/cpp/013run index cd0a08a6..1fc6ded8 100644 --- a/cpp/013run +++ b/cpp/013run @@ -139,8 +139,8 @@ void write_memory(reagent x, vector<int> data) { :(code) size_t size_of(reagent r) { type_info t = Type[r.types[0]]; - if (!t.is_record && !t.is_array) return t.size; - return t.size; // TODO + // End size_of Cases. + return t.size; } :(scenario run_label) 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") |