about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--020run.cc10
-rw-r--r--030container.cc4
-rw-r--r--032array.cc13
-rw-r--r--036refcount.cc10
4 files changed, 23 insertions, 14 deletions
diff --git a/020run.cc b/020run.cc
index 746bc9cd..de957dbb 100644
--- a/020run.cc
+++ b/020run.cc
@@ -329,6 +329,16 @@ int size_of(const reagent& r) {
 }
 int size_of(const type_tree* type) {
   if (!type) return 0;
+  if (type->atom) {
+    if (type->value == -1) return 1;  // error value, but we'll raise it elsewhere
+    if (type->value == 0) return 1;
+    // End size_of(type) Atom Special-cases
+  }
+  else {
+    assert(type->left->atom);
+    if (type->left->name == "address") return 1;
+    // End size_of(type) Non-atom Special-cases
+  }
   // End size_of(type) Special-cases
   return 1;
 }
diff --git a/030container.cc b/030container.cc
index 626587f8..53efc857 100644
--- a/030container.cc
+++ b/030container.cc
@@ -148,10 +148,6 @@ void clear_container_metadata() {
 if (r.metadata.size) return r.metadata.size;
 
 :(before "End size_of(type) Special-cases")
-if (type->atom) {
-  if (type->value == -1) return 1;  // error value, but we'll raise it elsewhere
-  if (type->value == 0) return 1;
-}
 const type_tree* root = root_type(type);
 if (!contains_key(Type, root->value)) {
   raise << "no such type " << root->value << '\n' << end();
diff --git a/032array.cc b/032array.cc
index 7d189749..4e233bff 100644
--- a/032array.cc
+++ b/032array.cc
@@ -107,6 +107,19 @@ if (!r.type->atom && r.type->left->atom && r.type->left->value == get(Type_ordin
   return /*space for length*/1 + array_length(r)*size_of(array_element(r.type));
 }
 
+:(before "End size_of(type) Non-atom Special-cases")
+if (type->left->value == get(Type_ordinal, "array")) return static_array_length(type);
+:(code)
+int static_array_length(const type_tree* type) {
+  if (!type->atom && !type->right->atom && type->right->right->atom  // exactly 3 types
+      && is_integer(type->right->right->name)) {  // third 'type' is a number
+    // get size from type
+    return to_integer(type->right->right->name);
+  }
+  cerr << to_string(type) << '\n';
+  assert(false);
+}
+
 //: disable the size mismatch check for arrays since the destination array
 //: need not be initialized
 :(before "End size_mismatch(x) Special-cases")
diff --git a/036refcount.cc b/036refcount.cc
index 765efba7..36aea6c0 100644
--- a/036refcount.cc
+++ b/036refcount.cc
@@ -402,16 +402,6 @@ void append_addresses(int base_offset, const type_tree* type, map<set<tag_condit
   }
 }
 
-int static_array_length(const type_tree* type) {
-  if (!type->atom && !type->right->atom && type->right->right->atom  // exactly 3 types
-      && is_integer(type->right->right->name)) {  // third 'type' is a number
-    // get size from type
-    return to_integer(type->right->right->name);
-  }
-  cerr << to_string(type) << '\n';
-  assert(false);
-}
-
 //: for the following unit tests we'll do the work of the transform by hand
 
 :(before "End Unit Tests")