[avida-cvs] avida(kaben) CVS commits: /current/source/cpu hardware_cpu.cc hardware_util.cc hardware_util.hh /current/source/main avida.cc
kaben
avida-cvs at alife.org
Fri May 23 12:07:43 PDT 2003
kaben Fri May 23 04:07:43 2003 EDT
Modified files: (Branch: kaben)
/avida/current/source/cpu hardware_cpu.cc hardware_util.cc
hardware_util.hh
/avida/current/source/main avida.cc
Log:
Merge against main branch.
-------------- next part --------------
Index: avida/current/source/cpu/hardware_cpu.cc
diff -u avida/current/source/cpu/hardware_cpu.cc:1.34.2.5 avida/current/source/cpu/hardware_cpu.cc:1.34.2.6
--- avida/current/source/cpu/hardware_cpu.cc:1.34.2.5 Fri May 23 03:17:41 2003
+++ avida/current/source/cpu/hardware_cpu.cc Fri May 23 04:07:40 2003
@@ -1013,7 +1013,8 @@
// direction which the heads[HEAD_IP] should progress through a creature.
cCPUHead cHardwareCPU::FindFullLabel(const cCodeLabel & in_label)
{
- // cout << "Running FindFullLabel with " << in_label.AsString() << endl;
+ // cout << "Running FindFullLabel with " << in_label.AsString() <<
+ // endl;
assert(in_label.GetSize() > 0); // Trying to find label of 0 size!
@@ -1043,7 +1044,8 @@
continue;
}
- // cout << "Testing label at line " << temp_head.GetPosition() << endl;
+ // cout << "Testing label at line " << temp_head.GetPosition() <<
+ // endl;
// ...and do the comparison...
Index: avida/current/source/cpu/hardware_util.cc
diff -u avida/current/source/cpu/hardware_util.cc:1.12.2.5 avida/current/source/cpu/hardware_util.cc:1.12.2.6
--- avida/current/source/cpu/hardware_util.cc:1.12.2.5 Fri May 23 02:36:34 2003
+++ avida/current/source/cpu/hardware_util.cc Fri May 23 04:07:41 2003
@@ -5,9 +5,6 @@
// before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. //
//////////////////////////////////////////////////////////////////////////////
-#include "hardware_method.hh"
-#include "hardware_util.hh"
-
#include "../tools/string.hh"
#include "../tools/file.hh"
@@ -15,6 +12,9 @@
#include "../main/inst_util.hh"
#include "../main/config.hh"
+#include "hardware_method.hh"
+#include "hardware_util.hh"
+
#include "hardware_base.hh"
#include "hardware_cpu.hh"
#include "hardware_4stack.hh"
@@ -22,14 +22,17 @@
using namespace std;
+#ifdef USE_INST_SET_CODE
void cHardwareUtil::LoadInstSet(const cString & filename, cInstSet & inst_set,
tDictionary<int> & nop_dict,
- tDictionary<tHardwareMethod> & inst_dict,
- /* XXX start -- kgn */
- tDictionary<int> & nop_dict_2,
- tDictionary<int> & inst_dict_2)
- /* XXX end */
-{
+ tDictionary<int> & inst_dict
+){
+#else /* USE_INST_SET_CODE */
+void cHardwareUtil::LoadInstSet(const cString & filename, cInstSet & inst_set,
+ tDictionary<int> & nop_dict,
+ tDictionary<tHardwareMethod> & inst_dict
+){
+#endif /* USE_INST_SET_CODE */
cInitFile file(filename);
file.Load();
file.Compress();
@@ -54,9 +57,9 @@
// First, determine if it is a nop...
#ifdef USE_INST_SET_CODE
/* XXX start -- kgn */
- int nop_mod_2 = -1;
- if(nop_dict_2.Find(inst_name, nop_mod_2) == true) {
- inst_set.AddNop2(nop_mod_2, redundancy, ft_cost, cost, prob_fail);
+ int nop_mod = -1;
+ if(nop_dict.Find(inst_name, nop_mod) == true) {
+ inst_set.AddNop2(nop_mod, redundancy, ft_cost, cost, prob_fail);
continue;
}
/* XXX end */
@@ -64,7 +67,7 @@
int nop_mod = -1;
if (nop_dict.Find(inst_name, nop_mod) == true) {
inst_set.AddNop(inst_name, &cHardwareBase::Inst_Nop, nop_mod,
- redundancy, ft_cost, cost, prob_fail);
+ redundancy, ft_cost, cost, prob_fail);
continue;
}
#endif /* USE_INST_SET_CODE */
@@ -73,7 +76,7 @@
#ifdef USE_INST_SET_CODE
/* XXX start -- kgn */
int fun_id = -1;
- if(inst_dict_2.Find(inst_name, fun_id) == true){
+ if(inst_dict.Find(inst_name, fun_id) == true){
inst_set.Add2(fun_id, redundancy, ft_cost, cost, prob_fail);
continue;
}
@@ -102,17 +105,17 @@
{
// Nops (or other modifying-instructions...) Note: Nops must be the
// first instructions added to the set.
- tDictionary< int > nop_dict;
#ifndef USE_INST_SET_CODE
+ tDictionary< int > nop_dict;
nop_dict.Add("nop-A", REG_AX);
nop_dict.Add("nop-B", REG_BX);
nop_dict.Add("nop-C", REG_CX);
#endif /* !USE_INST_SET_CODE */
// Build a dictionary of instructions and their corresponding methods...
+#ifndef USE_INST_SET_CODE
tDictionary< tHardwareMethod > inst_dict;
-#ifndef USE_INST_SET_CODE
// Remaining instructions.
inst_dict.Add("nop-X", (tHardwareMethod) &cHardwareCPU::Inst_Nop);
inst_dict.Add("if-equ-0", (tHardwareMethod) &cHardwareCPU::Inst_If0);
@@ -315,39 +318,37 @@
inst_dict.Add("skip", (tHardwareMethod) &cHardwareCPU::Inst_Skip);
#endif /* !USE_INST_SET_CODE */
- /* XXX start -- kgn */
- tDictionary<int> nop_dict_2;
#ifdef USE_INST_SET_CODE
+ /* XXX start -- kgn */
+ tDictionary<int> nop_dict;
for(int i=0; i<inst_set.GetInstLib()->GetNumNops(); i++)
- nop_dict_2.Add(inst_set.GetInstLib()->GetNopName(i), i);
-#endif /* USE_INST_SET_CODE */
+ nop_dict.Add(inst_set.GetInstLib()->GetNopName(i), i);
- tDictionary<int> inst_dict_2;
-#ifdef USE_INST_SET_CODE
+ tDictionary<int> inst_dict;
for(int i=0; i<inst_set.GetInstLib()->GetSize(); i++)
- inst_dict_2.Add(inst_set.GetInstLib()->GetName(i), i);
-#endif /* USE_INST_SET_CODE */
+ inst_dict.Add(inst_set.GetInstLib()->GetName(i), i);
/* XXX end */
+#endif /* USE_INST_SET_CODE */
// And load it on up!
- LoadInstSet(filename, inst_set, nop_dict, inst_dict, nop_dict_2, inst_dict_2);
+ LoadInstSet(filename, inst_set, nop_dict, inst_dict);
}
void cHardwareUtil::LoadInstSet_CPU4Stack(const cString & filename, cInstSet & inst_set)
{
// Nops (or other modifying-instructions...) Note: Nops must be the
// first instructions added to the set.
- tDictionary< int > nop_dict;
#ifndef USE_INST_SET_CODE
+ tDictionary< int > nop_dict;
nop_dict.Add("nop-A", REG_AX);
nop_dict.Add("nop-B", REG_BX);
nop_dict.Add("nop-C", REG_CX);
#endif /* !USE_INST_SET_CODE */
// Build a dictionary of instructions and their corresponding methods...
+#ifndef USE_INST_SET_CODE
tDictionary< tHardwareMethod > inst_dict;
-#ifndef USE_INST_SET_CODE
// Remaining instructions.
inst_dict.Add("nop-X", (tHardwareMethod) &cHardware4Stack::Inst_Nop);
inst_dict.Add("if-equ-0", (tHardwareMethod) &cHardware4Stack::Inst_If0);
@@ -550,25 +551,24 @@
inst_dict.Add("skip", (tHardwareMethod) &cHardware4Stack::Inst_Skip);
#endif /* !USE_INST_SET_CODE */
- cout << "Instruction Library in util has " << inst_dict.GetSize()
- << " instructions." << endl;
-
- /* XXX start -- kgn */
- tDictionary<int> nop_dict_2;
#ifdef USE_INST_SET_CODE
+ /* XXX start -- kgn */
+ tDictionary<int> nop_dict;
for(int i=0; i<inst_set.GetInstLib()->GetNumNops(); i++)
- nop_dict_2.Add(inst_set.GetInstLib()->GetNopName(i), i);
-#endif /* USE_INST_SET_CODE */
+ nop_dict.Add(inst_set.GetInstLib()->GetNopName(i), i);
- tDictionary<int> inst_dict_2;
-#ifdef USE_INST_SET_CODE
+ tDictionary<int> inst_dict;
for(int i=0; i<inst_set.GetInstLib()->GetSize(); i++)
- inst_dict_2.Add(inst_set.GetInstLib()->GetName(i), i);
-#endif /* USE_INST_SET_CODE */
+ inst_dict.Add(inst_set.GetInstLib()->GetName(i), i);
/* XXX end */
+#endif /* USE_INST_SET_CODE */
+
+ cout << "Instruction Library in util has " << inst_dict.GetSize()
+ << " instructions." << endl;
+
// And load it on up!
- LoadInstSet(filename, inst_set, nop_dict, inst_dict, nop_dict_2, inst_dict_2);
+ LoadInstSet(filename, inst_set, nop_dict, inst_dict);
}
cInstSet & cHardwareUtil::DefaultInstSet(const cString & inst_filename)
Index: avida/current/source/cpu/hardware_util.hh
diff -u avida/current/source/cpu/hardware_util.hh:1.2.2.2 avida/current/source/cpu/hardware_util.hh:1.2.2.3
--- avida/current/source/cpu/hardware_util.hh:1.2.2.2 Tue May 20 05:12:19 2003
+++ avida/current/source/cpu/hardware_util.hh Fri May 23 04:07:41 2003
@@ -19,14 +19,21 @@
class cHardwareUtil {
public:
+#ifdef USE_INST_SET_CODE
static void LoadInstSet(
const cString & filename,
cInstSet & inst_set,
tDictionary<int> & nop_dict,
- tDictionary<tHardwareMethod> & inst_dict,
- tDictionary<int> & nop_dict_2,
- tDictionary<int> & inst_dict_2
+ tDictionary<int> & inst_dict
);
+#else /* USE_INST_SET_CODE */
+ static void LoadInstSet(
+ const cString & filename,
+ cInstSet & inst_set,
+ tDictionary<int> & nop_dict,
+ tDictionary<tHardwareMethod> & inst_dict
+ );
+#endif /* USE_INST_SET_CODE */
static void LoadInstSet_CPUOriginal(const cString & filename,
cInstSet & inst_set);
static void LoadInstSet_CPU4Stack(const cString & filename,
Index: avida/current/source/main/avida.cc
diff -u avida/current/source/main/avida.cc:1.34.2.4 avida/current/source/main/avida.cc:1.34.2.5
--- avida/current/source/main/avida.cc:1.34.2.4 Fri May 23 02:36:35 2003
+++ avida/current/source/main/avida.cc Fri May 23 04:07:41 2003
@@ -79,6 +79,7 @@
cerr << "Unable to load environment... aborting!" << endl;
ExitAvida(-1);
}
+
if (cConfig::GetHardwareType() == HARDWARE_TYPE_CPU_ORIGINAL) {
#ifdef USE_INST_SET_CODE
More information about the Avida-cvs
mailing list