From fe67d47aa4598497e295510cf27f702a3e118632 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 21 Feb 2015 21:53:41 -0800 Subject: 810 --- cpp/010vm | 3 ++- cpp/012run | 6 +++--- cpp/018address | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) (limited to 'cpp') diff --git a/cpp/010vm b/cpp/010vm index cf064581..2f2268ba 100644 --- a/cpp/010vm +++ b/cpp/010vm @@ -99,7 +99,8 @@ struct type_info { bool is_record; bool is_array; vector target; // only if is_address - vector > elements; // only if is_record or is_array + vector > elements; // only if is_record + vector element; // only if is_array type_info() :size(0), is_address(false), is_record(false), is_array(false) {} }; diff --git a/cpp/012run b/cpp/012run index 63ffdff1..946b01d1 100644 --- a/cpp/012run +++ b/cpp/012run @@ -59,7 +59,7 @@ vector read_memory(reagent x) { void write_memory(reagent x, vector data) { int base = to_int(x.name); - size_t size = size_of(x.types[0]); + size_t size = size_of(x); if (size != data.size()) raise << "size mismatch in storing to " << x.to_string(); for (size_t offset = 0; offset < size; ++offset) { trace("mem") << "storing in location " << base+offset; @@ -75,8 +75,8 @@ int to_int(string n) { return result; } -int size_of(type_number x) { - type_info t = Type[x]; +int 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 } diff --git a/cpp/018address b/cpp/018address index bb173f94..32214761 100644 --- a/cpp/018address +++ b/cpp/018address @@ -20,7 +20,7 @@ vector read_memory(reagent x) { } x = canonize(x); int base = to_int(x.name); - size_t size = size_of(x.types[0]); + size_t size = size_of(x); for (size_t offset = 0; offset < size; ++offset) { int val = Memory[base+offset]; trace("mem") << "location " << base+offset << " is " << val; @@ -43,7 +43,7 @@ recipe main [ void write_memory(reagent x, vector data) { x = canonize(x); int base = to_int(x.name); - size_t size = size_of(x.types[0]); + size_t size = size_of(x); if (size != data.size()) raise << "size mismatch in storing to " << x.to_string(); for (size_t offset = 0; offset < size; ++offset) { trace("mem") << "storing in location " << base+offset; -- cgit 1.4.1-2-gfad0