From 5f0e4762468c412d57fb54236a0ee90e23a2cb14 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 17 Mar 2015 10:12:23 -0700 Subject: 948 --- cpp/013run | 4 ++-- cpp/020array | 36 ++++++++++-------------------------- 2 files changed, 12 insertions(+), 28 deletions(-) (limited to 'cpp') 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 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") -- cgit 1.4.1-2-gfad0