MCPcopy Create free account
hub / github.com/devosoft/avida / LoadInstSets

Method LoadInstSets

avida-core/source/cpu/cHardwareManager.cc:59–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57
58
59bool cHardwareManager::LoadInstSets(cUserFeedback* feedback)
60{
61 const cStringList& cfg_list = m_world->GetConfig().INSTSETS.Get();
62 cStringList* cur_list = NULL;
63 cString name;
64
65 // Build up schema to process instruction set parameters
66 cArgSchema is_schema(':');
67 is_schema.AddEntry("hw_type", 0, cArgSchema::SCHEMA_INT);
68 is_schema.AddEntry("stack_size", 1, 10);
69 is_schema.AddEntry("uops_per_cycle", 2, 20);
70
71 cArgContainer* args = NULL;
72
73 bool success = true;
74 for (int line_id = 0; line_id < cfg_list.GetSize(); line_id++) {
75 cString line_type = cfg_list.GetLine(line_id).PopWord();
76 if (line_type == "INST") {
77 if (cur_list) {
78 cur_list->PushRear(cfg_list.GetLine(line_id));
79 } else {
80 if (feedback) feedback->Error("disassociated INST definition, no INSTSET defined");
81 success = false;
82 }
83 } else if (line_type == "INSTSET") {
84 if (cur_list) {
85 if (!loadInstSet(args->GetInt(0), (const char*)name, args->GetInt(1), args->GetInt(2), *cur_list, feedback)) success = false;
86 delete cur_list;
87 delete args;
88 cur_list = NULL;
89 args = NULL;
90 }
91
92
93 // Process the INSTSET line
94 cString is_def_str = cfg_list.GetLine(line_id);
95 is_def_str.PopWord(); // Pop off "INSTSET"
96 name = is_def_str.Pop(':');
97 name.Trim();
98 if (!name.GetSize()) {
99 if (feedback) feedback->Error("instruction set name not found");
100 success = false;
101 continue;
102 }
103
104 // Process arguments on the INSTSET line
105 args = cArgContainer::Load(is_def_str, is_schema, *feedback);
106 if (!args) {
107 success = false;
108 continue;
109 }
110
111 cur_list = new cStringList;
112 }
113 }
114
115 if (cur_list) {
116 if (!loadInstSet(args->GetInt(0), (const char*)name, args->GetInt(1), args->GetInt(2), *cur_list, feedback)) success = false;

Callers 1

setupMethod · 0.80

Calls 11

GetConfigMethod · 0.80
PopWordMethod · 0.80
GetIntMethod · 0.80
TrimMethod · 0.80
GetMethod · 0.45
AddEntryMethod · 0.45
GetSizeMethod · 0.45
GetLineMethod · 0.45
PushRearMethod · 0.45
ErrorMethod · 0.45
PopMethod · 0.45

Tested by

no test coverage detected