about summary refs log tree commit diff stats
path: root/cpp/030container.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-05-04 11:02:56 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-05-04 11:02:56 -0700
commita66c9ae68122e04637d65c7f3aedcd96012c8cb6 (patch)
treeceddf9f22c55621be86768a0aeedc927495e62d6 /cpp/030container.cc
parentde49fb426aa44984d308f5856ec836360ba0bdce (diff)
downloadmu-a66c9ae68122e04637d65c7f3aedcd96012c8cb6.tar.gz
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.
Diffstat (limited to 'cpp/030container.cc')
-rw-r--r--cpp/030container.cc10
1 files changed, 5 insertions, 5 deletions
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;