[Avida-cvs] [avida-svn] r938 - in development/source: classification cpu tools

brysonda at myxo.css.msu.edu brysonda at myxo.css.msu.edu
Sun Sep 10 13:07:11 PDT 2006


Author: brysonda
Date: 2006-09-10 16:07:11 -0400 (Sun, 10 Sep 2006)
New Revision: 938

Modified:
   development/source/classification/cGenotype.cc
   development/source/classification/cInjectGenotype.cc
   development/source/cpu/cHardwareCPU.cc
   development/source/cpu/cHardwareCPU.h
   development/source/tools/cUInt.h
Log:
Change head array in cHardwareCPU::cLocalThread to extend to the number of nops when greater than the minimum (4).

Update cHardwareCPU member variable naming.

Modified: development/source/classification/cGenotype.cc
===================================================================
--- development/source/classification/cGenotype.cc	2006-09-10 17:56:04 UTC (rev 937)
+++ development/source/classification/cGenotype.cc	2006-09-10 20:07:11 UTC (rev 938)
@@ -81,7 +81,7 @@
     cInstruction temp_inst;
     int inst_op;
     fp >> inst_op;
-    temp_inst.SetOp((unsigned char) inst_op);
+    temp_inst.SetOp(static_cast<unsigned char>(inst_op));
     ret->genome[i] = temp_inst;
     // @CAO add something here to load arguments for instructions.
   }

Modified: development/source/classification/cInjectGenotype.cc
===================================================================
--- development/source/classification/cInjectGenotype.cc	2006-09-10 17:56:04 UTC (rev 937)
+++ development/source/classification/cInjectGenotype.cc	2006-09-10 20:07:11 UTC (rev 938)
@@ -70,7 +70,7 @@
     cInstruction temp_inst;
     int inst_op;
     fp >> inst_op;
-    temp_inst.SetOp((unsigned char) inst_op);
+    temp_inst.SetOp(static_cast<unsigned char>(inst_op));
     genome[i] = temp_inst;
     // @CAO add something here to load arguments for instructions.
   }

Modified: development/source/cpu/cHardwareCPU.cc
===================================================================
--- development/source/cpu/cHardwareCPU.cc	2006-09-10 17:56:04 UTC (rev 937)
+++ development/source/cpu/cHardwareCPU.cc	2006-09-10 20:07:11 UTC (rev 938)
@@ -371,7 +371,7 @@
   /* FIXME:  reorganize storage of m_functions.  -- kgn */
   m_functions = s_inst_slib->GetFunctions();
   /**/
-  memory = in_organism->GetGenome();  // Initialize memory...
+  m_memory = in_organism->GetGenome();  // Initialize memory...
   Reset();                            // Setup the rest of the hardware...
 }
 
@@ -379,15 +379,14 @@
 cHardwareCPU::cHardwareCPU(const cHardwareCPU &hardware_cpu)
 : cHardwareBase(hardware_cpu.m_world, hardware_cpu.organism, hardware_cpu.m_inst_set)
 , m_functions(hardware_cpu.m_functions)
-, memory(hardware_cpu.memory)
-, global_stack(hardware_cpu.global_stack)
-, thread_time_used(hardware_cpu.thread_time_used)
-, threads(hardware_cpu.threads)
-, thread_id_chart(hardware_cpu.thread_id_chart)
-, cur_thread(hardware_cpu.cur_thread)
-, mal_active(hardware_cpu.mal_active)
-, advance_ip(hardware_cpu.advance_ip)
-, executedmatchstrings(hardware_cpu.executedmatchstrings)
+, m_memory(hardware_cpu.m_memory)
+, m_global_stack(hardware_cpu.m_global_stack)
+, m_threads(hardware_cpu.m_threads)
+, m_thread_id_chart(hardware_cpu.m_thread_id_chart)
+, m_cur_thread(hardware_cpu.m_cur_thread)
+, m_mal_active(hardware_cpu.m_mal_active)
+, m_advance_ip(hardware_cpu.m_advance_ip)
+, m_executedmatchstrings(hardware_cpu.m_executedmatchstrings)
 #if INSTRUCTION_COSTS
 , inst_cost(hardware_cpu.inst_cost)
 , inst_ft_cost(hardware_cpu.inst_ft_cost)
@@ -396,25 +395,20 @@
 }
 
 
-cHardwareCPU::~cHardwareCPU()
-{
-}
-
 void cHardwareCPU::Reset()
 {
-  global_stack.Clear();
-  thread_time_used = 0;
+  m_global_stack.Clear();
   
   // We want to reset to have a single thread.
-  threads.Resize(1);
+  m_threads.Resize(1);
   
   // Reset that single thread.
-  threads[0].Reset(this, 0);
-  thread_id_chart = 1; // Mark only the first thread as taken...
-  cur_thread = 0;
+  m_threads[0].Reset(this, 0);
+  m_thread_id_chart = 1; // Mark only the first thread as taken...
+  m_cur_thread = 0;
   
-  mal_active = false;
-  executedmatchstrings = false;
+  m_mal_active = false;
+  m_executedmatchstrings = false;
   
 #if INSTRUCTION_COSTS
   // instruction cost arrays
@@ -465,7 +459,6 @@
   cPhenotype & phenotype = organism->GetPhenotype();
   phenotype.IncTimeUsed();
   const int num_threads = GetNumThreads();
-  if (num_threads > 1) thread_time_used++;
   
   // If we have threads turned on and we executed each thread in a single
   // timestep, adjust the number of instructions executed accordingly.
@@ -475,7 +468,7 @@
   for (int i = 0; i < num_inst_exec; i++) {
     // Setup the hardware for the next instruction to be executed.
     ThreadNext();
-    advance_ip = true;
+    m_advance_ip = true;
     IP().Adjust();
     
 #if BREAKPOINTS
@@ -497,9 +490,9 @@
     if (exec == true) {
       SingleProcess_ExecuteInst(ctx, cur_inst);
       
-      // Some instruction (such as jump) may turn advance_ip off.  Ususally
+      // Some instruction (such as jump) may turn m_advance_ip off.  Ususally
       // we now want to move to the next instruction in the memory.
-      if (advance_ip == true) IP().Advance();
+      if (m_advance_ip == true) IP().Advance();
     } // if exec
     
   } // Previous was executed once for each thread...
@@ -603,11 +596,11 @@
 {
   bool result = true;
   
-  if (!memory.OK()) result = false;
+  if (!m_memory.OK()) result = false;
   
   for (int i = 0; i < GetNumThreads(); i++) {
-    if (threads[i].stack.OK() == false) result = false;
-    if (threads[i].next_label.OK() == false) result = false;
+    if (m_threads[i].stack.OK() == false) result = false;
+    if (m_threads[i].next_label.OK() == false) result = false;
   }
   
   return result;
@@ -907,16 +900,16 @@
 void cHardwareCPU::InjectCode(const cGenome & inject_code, const int line_num)
 {
   assert(line_num >= 0);
-  assert(line_num <= memory.GetSize());
-  assert(memory.GetSize() + inject_code.GetSize() < MAX_CREATURE_SIZE);
+  assert(line_num <= m_memory.GetSize());
+  assert(m_memory.GetSize() + inject_code.GetSize() < MAX_CREATURE_SIZE);
   
   // Inject the new code.
   const int inject_size = inject_code.GetSize();
-  memory.Insert(line_num, inject_code);
+  m_memory.Insert(line_num, inject_code);
   
   // Set instruction flags on the injected code
   for (int i = line_num; i < line_num + inject_size; i++) {
-    memory.SetFlagInjected(i);
+    m_memory.SetFlagInjected(i);
   }
   organism->GetPhenotype().IsModified() = true;
   
@@ -941,7 +934,7 @@
 {
   for (int i = 0; i < GetNumThreads(); i++) {
     for (int j = 0; j < nHardware::NUM_HEADS; j++) {
-      threads[i].heads[j].Adjust();
+      m_threads[i].heads[j].Adjust();
     }
   }
 }
@@ -979,17 +972,17 @@
   if (num_threads == m_world->GetConfig().MAX_CPU_THREADS.Get()) return false;
   
   // Make room for the new thread.
-  threads.Resize(num_threads + 1);
+  m_threads.Resize(num_threads + 1);
   
   // Initialize the new thread to the same values as the current one.
-  threads[num_threads] = threads[cur_thread];
+  m_threads[num_threads] = m_threads[m_cur_thread];
   
-  // Find the first free bit in thread_id_chart to determine the new
+  // Find the first free bit in m_thread_id_chart to determine the new
   // thread id.
   int new_id = 0;
-  while ( (thread_id_chart >> new_id) & 1 == 1) new_id++;
-  threads[num_threads].SetID(new_id);
-  thread_id_chart |= (1 << new_id);
+  while ( (m_thread_id_chart >> new_id) & 1 == 1) new_id++;
+  m_threads[num_threads].SetID(new_id);
+  m_thread_id_chart |= (1 << new_id);
   
   return true;
 }
@@ -1001,22 +994,22 @@
   if (GetNumThreads() == 1) return false;
   
   // Note the current thread and set the current back one.
-  const int kill_thread = cur_thread;
+  const int kill_thread = m_cur_thread;
   ThreadPrev();
   
-  // Turn off this bit in the thread_id_chart...
-  thread_id_chart ^= 1 << threads[kill_thread].GetID();
+  // Turn off this bit in the m_thread_id_chart...
+  m_thread_id_chart ^= 1 << m_threads[kill_thread].GetID();
   
   // Copy the last thread into the kill position
   const int last_thread = GetNumThreads() - 1;
   if (last_thread != kill_thread) {
-    threads[kill_thread] = threads[last_thread];
+    m_threads[kill_thread] = m_threads[last_thread];
   }
   
   // Kill the thread!
-  threads.Resize(GetNumThreads() - 1);
+  m_threads.Resize(GetNumThreads() - 1);
   
-  if (cur_thread > kill_thread) cur_thread--;
+  if (m_cur_thread > kill_thread) m_cur_thread--;
   
   return true;
 }
@@ -1086,7 +1079,7 @@
 bool cHardwareCPU::Allocate_Main(cAvidaContext& ctx, const int allocated_size)
 {
   // must do divide before second allocate & must allocate positive amount...
-  if (m_world->GetConfig().REQUIRE_ALLOCATE.Get() && mal_active == true) {
+  if (m_world->GetConfig().REQUIRE_ALLOCATE.Get() && m_mal_active == true) {
     organism->Fault(FAULT_LOC_ALLOC, FAULT_TYPE_ERROR, "Allocate already active");
     return false;
   }
@@ -1136,7 +1129,7 @@
       break;
   }
   
-  mal_active = true;
+  m_mal_active = true;
   
   return true;
 }
@@ -1164,7 +1157,7 @@
   // Since the divide will now succeed, set up the information to be sent
   // to the new organism
   cGenome & child_genome = organism->ChildGenome();
-  child_genome = cGenomeUtil::Crop(memory, div_point, div_point+child_size);
+  child_genome = cGenomeUtil::Crop(m_memory, div_point, div_point+child_size);
   
   // Cut off everything in this memory past the divide point.
   GetMemory().Resize(div_point);
@@ -1184,9 +1177,9 @@
   }
 #endif
   
-  mal_active = false;
+  m_mal_active = false;
   if (m_world->GetConfig().DIVIDE_METHOD.Get() == DIVIDE_METHOD_SPLIT) {
-    advance_ip = false;
+    m_advance_ip = false;
   }
   
   // Activate the child, and do more work if the parent lives through the
@@ -1220,7 +1213,7 @@
   // Since the divide will now succeed, set up the information to be sent
   // to the new organism
   cGenome & child_genome = organism->ChildGenome();
-  child_genome = cGenomeUtil::Crop(memory, div_point, div_point+child_size);
+  child_genome = cGenomeUtil::Crop(m_memory, div_point, div_point+child_size);
   
   // Cut off everything in this memory past the divide point.
   GetMemory().Resize(div_point);
@@ -1270,9 +1263,9 @@
   }
 #endif
   
-  mal_active = false;
+  m_mal_active = false;
   if (m_world->GetConfig().DIVIDE_METHOD.Get() == DIVIDE_METHOD_SPLIT) {
-    advance_ip = false;
+    m_advance_ip = false;
   }
   
   // Activate the child, and do more work if the parent lives through the
@@ -1587,7 +1580,7 @@
   StackPush(GetHead(head_used).GetPosition());
   if (head_used == nHardware::HEAD_IP) {
     GetHead(head_used).Set(GetHead(nHardware::HEAD_FLOW));
-    advance_ip = false;
+    m_advance_ip = false;
   }
   return true;
 }
@@ -2106,7 +2099,7 @@
   }
 #endif
   
-  if (m_world->GetConfig().DIVIDE_METHOD.Get() == DIVIDE_METHOD_SPLIT) advance_ip = false;
+  if (m_world->GetConfig().DIVIDE_METHOD.Get() == DIVIDE_METHOD_SPLIT) m_advance_ip = false;
   
   organism->ActivateDivide(ctx);
   
@@ -2309,10 +2302,10 @@
 
 bool cHardwareCPU::Inst_MatchStrings(cAvidaContext& ctx)
 {
-	if (executedmatchstrings)
+	if (m_executedmatchstrings)
 		return false;
 	organism->DoOutput(ctx, 357913941);
-	executedmatchstrings = true;
+	m_executedmatchstrings = true;
 	return true;
 }
 
@@ -2612,7 +2605,7 @@
 bool cHardwareCPU::Inst_KillThread(cAvidaContext& ctx)
 {
   if (!KillThread()) organism->Fault(FAULT_LOC_THREAD_KILL, FAULT_TYPE_KILL_TH);
-  else advance_ip = false;
+  else m_advance_ip = false;
   return true;
 }
 
@@ -2629,7 +2622,7 @@
 bool cHardwareCPU::Inst_SetHead(cAvidaContext& ctx)
 {
   const int head_used = FindModifiedHead(nHardware::HEAD_IP);
-  threads[cur_thread].cur_head = (unsigned char) head_used;
+  m_threads[m_cur_thread].cur_head = static_cast<unsigned char>(head_used);
   return true;
 }
 
@@ -2644,7 +2637,7 @@
 {
   const int head_used = FindModifiedHead(nHardware::HEAD_IP);
   GetHead(head_used).Set(GetHead(nHardware::HEAD_FLOW));
-  if (head_used == nHardware::HEAD_IP) advance_ip = false;
+  if (head_used == nHardware::HEAD_IP) m_advance_ip = false;
   return true;
 }
 

Modified: development/source/cpu/cHardwareCPU.h
===================================================================
--- development/source/cpu/cHardwareCPU.h	2006-09-10 17:56:04 UTC (rev 937)
+++ development/source/cpu/cHardwareCPU.h	2006-09-10 20:07:11 UTC (rev 938)
@@ -66,9 +66,9 @@
 
 protected:
   // --------  Structure Constants  --------
-  static const int NUM_REGISTERS = 3;  
+  static const int NUM_REGISTERS = 4;
   enum tRegisters { REG_AX = 0, REG_BX, REG_CX, REG_DX, REG_EX, REG_FX };
-  static const int NUM_NOPS = 3;
+  static const int NUM_NOPS = 4;
   
   // --------  Data Structures  --------
   struct cLocalThread
@@ -78,7 +78,7 @@
     
   public:
     int reg[NUM_REGISTERS];
-    cHeadCPU heads[nHardware::NUM_HEADS];
+    cHeadCPU heads[nHardware::NUM_HEADS >= NUM_REGISTERS ? nHardware::NUM_HEADS : NUM_REGISTERS];
     cCPUStack stack;
     unsigned char cur_stack;              // 0 = local stack, 1 = global stack.
     unsigned char cur_head;
@@ -106,18 +106,17 @@
   // --------  Member Variables  --------
   tHardwareCPUMethod* m_functions;
 
-  cCPUMemory memory;          // Memory...
-  cCPUStack global_stack;     // A stack that all threads share.
-  int thread_time_used;
+  cCPUMemory m_memory;          // Memory...
+  cCPUStack m_global_stack;     // A stack that all threads share.
 
-  tArray<cLocalThread> threads;
-  int thread_id_chart;
-  int cur_thread;
+  tArray<cLocalThread> m_threads;
+  int m_thread_id_chart;
+  int m_cur_thread;
 
   // Flags...
-  bool mal_active;         // Has an allocate occured since last divide?
-  bool advance_ip;         // Should the IP advance after this instruction?
-  bool executedmatchstrings;	// Have we already executed the match strings instruction?
+  bool m_mal_active;         // Has an allocate occured since last divide?
+  bool m_advance_ip;         // Should the IP advance after this instruction?
+  bool m_executedmatchstrings;	// Have we already executed the match strings instruction?
 
   // Instruction costs...
 #if INSTRUCTION_COSTS
@@ -138,7 +137,7 @@
   
   
   // --------  Head Manipulation (including IP)  --------
-  cHeadCPU& GetActiveHead() { return threads[cur_thread].heads[threads[cur_thread].cur_head]; }
+  cHeadCPU& GetActiveHead() { return m_threads[m_cur_thread].heads[m_threads[m_cur_thread].cur_head]; }
   void AdjustHeads();
   
   
@@ -148,12 +147,12 @@
   int FindLabel_Forward(const cCodeLabel & search_label, const cGenome& search_genome, int pos);
   int FindLabel_Backward(const cCodeLabel & search_label, const cGenome& search_genome, int pos);
   cHeadCPU FindLabel(const cCodeLabel & in_label, int direction);
-  const cCodeLabel& GetReadLabel() const { return threads[cur_thread].read_label; }
-  cCodeLabel& GetReadLabel() { return threads[cur_thread].read_label; }
+  const cCodeLabel& GetReadLabel() const { return m_threads[m_cur_thread].read_label; }
+  cCodeLabel& GetReadLabel() { return m_threads[m_cur_thread].read_label; }
   
   
   // --------  Thread Manipulation  -------
-  bool ForkThread(); // Adds a new thread based off of cur_thread.
+  bool ForkThread(); // Adds a new thread based off of m_cur_thread.
   bool KillThread(); // Kill the current thread!
   
   
@@ -186,7 +185,7 @@
 public:
   cHardwareCPU(cWorld* world, cOrganism* in_organism, cInstSet* in_inst_set);
   explicit cHardwareCPU(const cHardwareCPU&);
-  ~cHardwareCPU();
+  ~cHardwareCPU() { ; }
   static cInstLibCPU* GetInstLib() { return s_inst_slib; }
   static cString GetDefaultInstFilename() { return "instset-classic.cfg"; }
 
@@ -207,34 +206,34 @@
 
 
   // --------  Head Manipulation (including IP)  --------
-  const cHeadCPU& GetHead(int head_id) const { return threads[cur_thread].heads[head_id]; }
-  cHeadCPU& GetHead(int head_id) { return threads[cur_thread].heads[head_id];}
-  const cHeadCPU& GetHead(int head_id, int thread) const { return threads[thread].heads[head_id]; }
-  cHeadCPU& GetHead(int head_id, int thread) { return threads[thread].heads[head_id];}
+  const cHeadCPU& GetHead(int head_id) const { return m_threads[m_cur_thread].heads[head_id]; }
+  cHeadCPU& GetHead(int head_id) { return m_threads[m_cur_thread].heads[head_id];}
+  const cHeadCPU& GetHead(int head_id, int thread) const { return m_threads[thread].heads[head_id]; }
+  cHeadCPU& GetHead(int head_id, int thread) { return m_threads[thread].heads[head_id];}
   int GetNumHeads() const { return nHardware::NUM_HEADS; }
   
-  const cHeadCPU& IP() const { return threads[cur_thread].heads[nHardware::HEAD_IP]; }
-  cHeadCPU& IP() { return threads[cur_thread].heads[nHardware::HEAD_IP]; }
-  const cHeadCPU& IP(int thread) const { return threads[thread].heads[nHardware::HEAD_IP]; }
-  cHeadCPU& IP(int thread) { return threads[thread].heads[nHardware::HEAD_IP]; }
+  const cHeadCPU& IP() const { return m_threads[m_cur_thread].heads[nHardware::HEAD_IP]; }
+  cHeadCPU& IP() { return m_threads[m_cur_thread].heads[nHardware::HEAD_IP]; }
+  const cHeadCPU& IP(int thread) const { return m_threads[thread].heads[nHardware::HEAD_IP]; }
+  cHeadCPU& IP(int thread) { return m_threads[thread].heads[nHardware::HEAD_IP]; }
   
   
   // --------  Label Manipulation  -------
-  const cCodeLabel& GetLabel() const { return threads[cur_thread].next_label; }
-  cCodeLabel& GetLabel() { return threads[cur_thread].next_label; }
+  const cCodeLabel& GetLabel() const { return m_threads[m_cur_thread].next_label; }
+  cCodeLabel& GetLabel() { return m_threads[m_cur_thread].next_label; }
   
   
   // --------  Memory Manipulation  --------
-  const cCPUMemory& GetMemory() const { return memory; }
-  cCPUMemory& GetMemory() { return memory; }
-  const cCPUMemory& GetMemory(int value) const { return memory; }
-  cCPUMemory& GetMemory(int value) { return memory; }
+  const cCPUMemory& GetMemory() const { return m_memory; }
+  cCPUMemory& GetMemory() { return m_memory; }
+  const cCPUMemory& GetMemory(int value) const { return m_memory; }
+  cCPUMemory& GetMemory(int value) { return m_memory; }
   int GetNumMemSpaces() const { return 1; }
   
   
   // --------  Register Manipulation  --------
-  const int GetRegister(int reg_id) const { return threads[cur_thread].reg[reg_id]; }
-  int& GetRegister(int reg_id) { return threads[cur_thread].reg[reg_id]; }
+  const int GetRegister(int reg_id) const { return m_threads[m_cur_thread].reg[reg_id]; }
+  int& GetRegister(int reg_id) { return m_threads[m_cur_thread].reg[reg_id]; }
   int GetNumRegisters() const { return NUM_REGISTERS; }
 
   
@@ -246,9 +245,9 @@
   cInjectGenotype* ThreadGetOwner() { return NULL; } // @DMB - cHardwareCPU does not really implement cInjectGenotype yet
   void ThreadSetOwner(cInjectGenotype* in_genotype) { return; }
   
-  int GetNumThreads() const     { return threads.GetSize(); }
-  int GetCurThread() const      { return cur_thread; }
-  int GetCurThreadID() const    { return threads[cur_thread].GetID(); }
+  int GetNumThreads() const     { return m_threads.GetSize(); }
+  int GetCurThread() const      { return m_cur_thread; }
+  int GetCurThreadID() const    { return m_threads[m_cur_thread].GetID(); }
   
   
   // --------  Parasite Stuff  --------
@@ -257,8 +256,8 @@
   
   // Non-Standard Methods
   
-  int GetActiveStack() const { return threads[cur_thread].cur_stack; }
-  bool GetMalActive() const   { return mal_active; }
+  int GetActiveStack() const { return m_threads[m_cur_thread].cur_stack; }
+  bool GetMalActive() const   { return m_mal_active; }
   
 private:
   // ---------- Instruction Library -----------
@@ -479,8 +478,8 @@
 
 inline bool cHardwareCPU::ThreadSelect(const int thread_num)
 {
-  if (thread_num >= 0 && thread_num < threads.GetSize()) {
-    cur_thread = thread_num;
+  if (thread_num >= 0 && thread_num < m_threads.GetSize()) {
+    m_cur_thread = thread_num;
     return true;
   }
   
@@ -489,22 +488,22 @@
 
 inline void cHardwareCPU::ThreadNext()
 {
-  cur_thread++;
-  if (cur_thread >= GetNumThreads()) cur_thread = 0;
+  m_cur_thread++;
+  if (m_cur_thread >= GetNumThreads()) m_cur_thread = 0;
 }
 
 inline void cHardwareCPU::ThreadPrev()
 {
-  if (cur_thread == 0) cur_thread = GetNumThreads() - 1;
-  else cur_thread--;
+  if (m_cur_thread == 0) m_cur_thread = GetNumThreads() - 1;
+  else m_cur_thread--;
 }
 
 inline void cHardwareCPU::StackPush(int value)
 {
-  if (threads[cur_thread].cur_stack == 0) {
-    threads[cur_thread].stack.Push(value);
+  if (m_threads[m_cur_thread].cur_stack == 0) {
+    m_threads[m_cur_thread].stack.Push(value);
   } else {
-    global_stack.Push(value);
+    m_global_stack.Push(value);
   }
 }
 
@@ -512,10 +511,10 @@
 {
   int pop_value;
 
-  if (threads[cur_thread].cur_stack == 0) {
-    pop_value = threads[cur_thread].stack.Pop();
+  if (m_threads[m_cur_thread].cur_stack == 0) {
+    pop_value = m_threads[m_cur_thread].stack.Pop();
   } else {
-    pop_value = global_stack.Pop();
+    pop_value = m_global_stack.Pop();
   }
 
   return pop_value;
@@ -523,10 +522,10 @@
 
 inline void cHardwareCPU::StackFlip()
 {
-  if (threads[cur_thread].cur_stack == 0) {
-    threads[cur_thread].stack.Flip();
+  if (m_threads[m_cur_thread].cur_stack == 0) {
+    m_threads[m_cur_thread].stack.Flip();
   } else {
-    global_stack.Flip();
+    m_global_stack.Flip();
   }
 }
 
@@ -534,29 +533,29 @@
 {
   int value = 0;
 
-  if(in_thread >= threads.GetSize() || in_thread < 0) in_thread = cur_thread;
+  if(in_thread >= m_threads.GetSize() || in_thread < 0) in_thread = m_cur_thread;
 
-  if (stack_id == -1) stack_id = threads[in_thread].cur_stack;
+  if (stack_id == -1) stack_id = m_threads[in_thread].cur_stack;
 
-  if (stack_id == 0) value = threads[in_thread].stack.Get(depth);
-  else if (stack_id == 1) value = global_stack.Get(depth);
+  if (stack_id == 0) value = m_threads[in_thread].stack.Get(depth);
+  else if (stack_id == 1) value = m_global_stack.Get(depth);
 
   return value;
 }
 
 inline void cHardwareCPU::StackClear()
 {
-  if (threads[cur_thread].cur_stack == 0) {
-    threads[cur_thread].stack.Clear();
+  if (m_threads[m_cur_thread].cur_stack == 0) {
+    m_threads[m_cur_thread].stack.Clear();
   } else {
-    global_stack.Clear();
+    m_global_stack.Clear();
   }
 }
 
 inline void cHardwareCPU::SwitchStack()
 {
-  threads[cur_thread].cur_stack++;
-  if (threads[cur_thread].cur_stack > 1) threads[cur_thread].cur_stack = 0;
+  m_threads[m_cur_thread].cur_stack++;
+  if (m_threads[m_cur_thread].cur_stack > 1) m_threads[m_cur_thread].cur_stack = 0;
 }
 
 #endif

Modified: development/source/tools/cUInt.h
===================================================================
--- development/source/tools/cUInt.h	2006-09-10 17:56:04 UTC (rev 937)
+++ development/source/tools/cUInt.h	2006-09-10 20:07:11 UTC (rev 938)
@@ -337,7 +337,7 @@
   size = in_size;
   value = new unsigned char[size];
   for (i = 0; i < size && i < 4; i++) {
-    value[i] = (unsigned char) (in_value >> (8 * i));
+    value[i] = static_cast<unsigned char>(in_value >> (8 * i));
   }
   while (i < size) {
     value[i++] = 0;
@@ -476,7 +476,7 @@
 {
   int i;
   for (i = 0; i < 4 && i < size; i++) {
-    value[i] = (unsigned char) (in_int >> (8*i));
+    value[i] = static_cast<unsigned char>(in_int >> (8*i));
   }
   for (i = 4; i < size; i++) {
     value[i] = 0;
@@ -564,14 +564,14 @@
   for (i = 0; i < size && i < in_cUInt.GetSize(); i++) {
     cur_sum += value[i];
     cur_sum += in_cUInt.GetByte(i);
-    value[i] = (unsigned char) (cur_sum & 255);
+    value[i] = static_cast<unsigned char>(cur_sum & 255);
     cur_sum = cur_sum >> 8;
   }
 
   // If there is still a remainder, and room for it, continue.
 
   while (cur_sum && i < size) {
-    value[i++] = (unsigned char) (cur_sum & 255);
+    value[i++] = static_cast<unsigned char>(cur_sum & 255);
   }
 
   return *this;
@@ -586,11 +586,11 @@
     byte1 = (int) value[i];
     byte2 = (int) in_cUInt.GetByte(i);
     if (byte1 + next_byte >= byte2) {
-      value[i] = (unsigned char) (byte1 + next_byte - byte2);
+      value[i] = static_cast<unsigned char>(byte1 + next_byte - byte2);
       next_byte = 0;
     }
     else {
-      value[i] = (unsigned char) (256 + byte1 + next_byte - byte2);
+      value[i] = static_cast<unsigned char>(256 + byte1 + next_byte - byte2);
       next_byte = -1;
     }
   }
@@ -603,7 +603,7 @@
       next_byte = 0;
     }
     else {
-      value[i] = (unsigned char) (256 + next_byte + (int) value[i]);
+      value[i] = static_cast<unsigned char>(256 + next_byte + (int) value[i]);
       next_byte = -1;
     }
   }




More information about the Avida-cvs mailing list