Commit 3dbafb46 authored by Robert Ricci's avatar Robert Ricci

Add a type-checking prepass for vclasses.

parent d2666ba7
......@@ -57,6 +57,7 @@ name_count_map ptypes;
// List of virtual types by name.
name_count_map vtypes;
name_list_map vclasses;
// A list of all pclasses.
pclass_list pclasses;
......@@ -322,6 +323,7 @@ int type_precheck() {
bool ok = true;
// First, check the regular types
for (name_count_map::iterator vtype_it=vtypes.begin();
vtype_it != vtypes.end();++vtype_it) {
......@@ -341,6 +343,26 @@ int type_precheck() {
}
}
}
// Check the vclasses, too
for (name_list_map::iterator vclass_it = vclasses.begin();
vclass_it != vclasses.end(); ++vclass_it) {
bool found_match = false;
for (vector<crope>::iterator vtype_it = vclass_it->second.begin();
vtype_it != vclass_it->second.end(); vtype_it++) {
if (ptypes.find(*vtype_it) != ptypes.end()) {
found_match = true;
break;
}
}
if (!found_match) {
cout << " *** No physical nodes can satisfy vclass " <<
vclass_it->first << endl;
ok = false;
}
}
if (ok) {
cout << "Type preecheck passed." << endl;
return 1;
......
......@@ -150,6 +150,7 @@ typedef slist<crope> name_slist;
* Used to count the number of nodes in each ptype and vtype
*/
typedef hash_map<crope,int> name_count_map;
typedef hash_map<crope,vector<crope> > name_list_map;
/*
* A hash function for pointers
......
......@@ -31,6 +31,7 @@ using namespace boost;
extern name_vvertex_map vname2vertex;
extern name_name_map fixed_nodes;
extern name_count_map vtypes;
extern name_list_map vclasses;
extern vvertex_vector virtual_nodes;
#define top_error(s) errors++;cerr << "TOP:" << line << ": " << s << endl
......@@ -236,10 +237,7 @@ int parse_top(tb_vgraph &VG, istream& i)
vclass_map[name] = v;
for (unsigned int i = 3;i<parsed_line.size();++i) {
v->add_type(parsed_line[i]);
// XXX - in order not to break vtypes, we don't put them in the
// vtypes map (otherwise, the type precheck would complain, but the
// top may still be mappable).
//vtypes.push_front(parsed_line[i]);
vclasses[name].push_back(parsed_line[i]);
}
}
} else if (command.compare("fix-node") == 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment