about summary refs log tree commit diff stats
path: root/cpp/042new.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/042new.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/042new.cc')
-rw-r--r--cpp/042new.cc8
1 files changed, 4 insertions, 4 deletions
diff --git a/cpp/042new.cc b/cpp/042new.cc
index e901b2a9..ea05a3ed 100644
--- a/cpp/042new.cc
+++ b/cpp/042new.cc
@@ -12,13 +12,13 @@ recipe main [
 
 :(before "End Globals")
 size_t Reserved_for_tests = 1000;
-size_t Memory_allocated_until = Reserved_for_tests;
+index_t Memory_allocated_until = Reserved_for_tests;
 size_t Initial_memory_per_routine = 100000;
 :(before "End Setup")
 Memory_allocated_until = Reserved_for_tests;
 Initial_memory_per_routine = 100000;
 :(before "End routine Fields")
-size_t alloc, alloc_max;
+index_t alloc, alloc_max;
 :(before "End routine Constructor")
 alloc = Memory_allocated_until;
 Memory_allocated_until += Initial_memory_per_routine;
@@ -78,7 +78,7 @@ case NEW: {
     Current_routine->alloc_max = Memory_allocated_until;
     trace("new") << "routine allocated memory from " << Current_routine->alloc << " to " << Current_routine->alloc_max;
   }
-  const size_t result = Current_routine->alloc;
+  const index_t result = Current_routine->alloc;
   trace("mem") << "new alloc: " << result;
   if (current_instruction().ingredients.size() > 1) {
     // initialize array
@@ -149,7 +149,7 @@ if (current_instruction().ingredients[0].properties[0].second[0] == "literal-str
   // assume that all characters fit in a single location
 //?   cout << "new string literal: " << current_instruction().ingredients[0].name << '\n'; //? 1
   Memory[Current_routine->alloc++] = current_instruction().ingredients[0].name.size();
-  for (size_t i = 0; i < current_instruction().ingredients[0].name.size(); ++i) {
+  for (index_t i = 0; i < current_instruction().ingredients[0].name.size(); ++i) {
     Memory[Current_routine->alloc++] = current_instruction().ingredients[0].name[i];
   }
   // mu strings are not null-terminated in memory