[Avida-SVN] r2754 - in branches/interrupt/source: cpu main

beckma24 at myxo.css.msu.edu beckma24 at myxo.css.msu.edu
Tue Aug 19 06:42:03 PDT 2008


Author: beckma24
Date: 2008-08-19 09:42:02 -0400 (Tue, 19 Aug 2008)
New Revision: 2754

Modified:
   branches/interrupt/source/cpu/cHardwareGX.cc
   branches/interrupt/source/main/cGenome.h
   branches/interrupt/source/main/cGenomeUtil.cc
Log:
Last commit for instruction protection within cGenome

Modified: branches/interrupt/source/cpu/cHardwareGX.cc
===================================================================
--- branches/interrupt/source/cpu/cHardwareGX.cc	2008-08-15 17:04:34 UTC (rev 2753)
+++ branches/interrupt/source/cpu/cHardwareGX.cc	2008-08-19 13:42:02 UTC (rev 2754)
@@ -346,7 +346,9 @@
     // These specify the range of instructions that will be used to create a new
     // programid.  The range of instructions used to create a programid is:
     // [begin, end), that is, the instruction pointed to by end is *not* copied.
-    cInstruction* begin=&genome[0];
+		
+		assert(false);  //commented out because of non-constaint reference into a cGenome instance, brakes instruction protection
+/*    cInstruction* begin=&genome[0];
     cInstruction* end=&begin[genome.GetSize()];
     cInstruction* i=0;
     // Find the first instance of a PROGRAMID instruction.
@@ -357,7 +359,7 @@
       AddProgramid(new cProgramid(cGenome(begin, i), this));
       begin = i;
     }
-    
+  */  
     assert(m_programids.size()>0);  
     
     // Sanity, oh, where is my sanity?

Modified: branches/interrupt/source/main/cGenome.h
===================================================================
--- branches/interrupt/source/main/cGenome.h	2008-08-15 17:04:34 UTC (rev 2753)
+++ branches/interrupt/source/main/cGenome.h	2008-08-19 13:42:02 UTC (rev 2754)
@@ -66,7 +66,10 @@
   virtual bool operator!=(const cGenome& other_genome) const { return !(this->operator==(other_genome)); }
   virtual bool operator<(const cGenome& other_genome) const { return AsString() < other_genome.AsString(); }
 
-  cInstruction& operator[](int index) { assert(index >= 0 && index < active_size);  return genome[index]; }
+	// this operator has been removed to protect the instructions in cGenome
+	//  cInstruction& operator[](int index)
+	// Do not overload the operator above.  Doing so will break instruction level protection
+	
   const cInstruction& operator[](int index) const { assert(index >= 0 && index < active_size);  return genome[index]; }
 
 	bool IsProtected(int index) const { assert(index >= 0 && index < active_size); return protected_sites[index]; }

Modified: branches/interrupt/source/main/cGenomeUtil.cc
===================================================================
--- branches/interrupt/source/main/cGenomeUtil.cc	2008-08-15 17:04:34 UTC (rev 2753)
+++ branches/interrupt/source/main/cGenomeUtil.cc	2008-08-19 13:42:02 UTC (rev 2754)
@@ -256,7 +256,14 @@
   
   for (int line_num = 0; line_num < new_genome.GetSize(); line_num++) {
     cString cur_line = input_file.GetLine(line_num);
-    new_genome[line_num] = inst_set.GetInst(cur_line);
+		
+		bool site_protected = false;
+		if(cur_line.GetWord(1) == "protected")
+			site_protected = true;
+		
+		cerr<< cur_line.GetWord(0) << " " << cur_line.GetWord(1) << " " << site_protected << endl;
+		
+    new_genome.SetInst(line_num, inst_set.GetInst(cur_line.GetWord(0)), site_protected);
     
     if (new_genome[line_num] == inst_set.GetInstError()) {
       // You're using the wrong instruction set!  YOU FOOL!
@@ -288,8 +295,15 @@
   
   for (int line_num = 0; line_num < new_genome.GetSize(); line_num++) {
     fp >> cur_line;
-    new_genome[line_num] = inst_set.GetInst(cur_line);
-    
+		
+		
+		bool site_protected = false;
+		if(cur_line.GetWord(1) == "protected")
+			site_protected = true;
+		
+		cerr<< cur_line.GetWord(0) << " " << cur_line.GetWord(1) << " " << site_protected << endl;
+    new_genome.SetInst(line_num, inst_set.GetInst(cur_line.GetWord(0)), site_protected);
+		 
     if (new_genome[line_num] == inst_set.GetInstError()) {
       // You're using the wrong instruction set!  YOU FOOL!
       cerr << "Cannot load creature from stream:" << endl




More information about the Avida-cvs mailing list