From f4647409b5fa658e463424c0a8249a4d72405d59 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 8 Nov 2016 10:20:49 -0800 Subject: 3652 size_of(type_tree*) is a mess; clean it up with an eye to the final tangled version. --- 032array.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to '032array.cc') 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") -- cgit 1.4.1-2-gfad0