From a66c9ae68122e04637d65c7f3aedcd96012c8cb6 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Mon, 4 May 2015 11:02:56 -0700 Subject: 1249 - new type: index_t It will always be identical to size_t, just more readable, like recipe_number, etc. The various unsigned types are sizes, indices (which often compare with sizes for bounds checking), numbers which are canonical elements of a specific space (like recipes or mu types), and ids which I haven't introduced yet. --- cpp/030container.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'cpp/030container.cc') diff --git a/cpp/030container.cc b/cpp/030container.cc index 1741af1b..51d2fdde 100644 --- a/cpp/030container.cc +++ b/cpp/030container.cc @@ -53,7 +53,7 @@ type_info t = Type[types[0]]; if (t.kind == container) { // size of a container is the sum of the sizes of its elements size_t result = 0; - for (size_t i = 0; i < t.elements.size(); ++i) { + for (index_t i = 0; i < t.elements.size(); ++i) { result += size_of(t.elements[i]); } return result; @@ -88,9 +88,9 @@ case GET: { assert(Type[base_type].kind == container); trace("run") << "ingredient 1 is " << current_instruction().ingredients[1].name; assert(isa_literal(current_instruction().ingredients[1])); - size_t offset = current_instruction().ingredients[1].value; + index_t offset = current_instruction().ingredients[1].value; int src = base_address; - for (size_t i = 0; i < offset; ++i) { + for (index_t i = 0; i < offset; ++i) { src += size_of(Type[base_type].elements[i]); } trace("run") << "address to copy is " << src; @@ -155,9 +155,9 @@ case GET_ADDRESS: { assert(Type[base_type].kind == container); trace("run") << "ingredient 1 is " << current_instruction().ingredients[1].name; assert(isa_literal(current_instruction().ingredients[1])); - size_t offset = current_instruction().ingredients[1].value; + index_t offset = current_instruction().ingredients[1].value; int src = base_address; - for (size_t i = 0; i < offset; ++i) { + for (index_t i = 0; i < offset; ++i) { src += size_of(Type[base_type].elements[i]); } trace("run") << "address to copy is " << src; -- cgit 1.4.1-2-gfad0