Catch enumerations with the same name.

This commit is contained in:
Cary R 2014-10-31 20:05:22 -07:00
parent d4313dad75
commit 632e15a55c
4 changed files with 18 additions and 5 deletions

View File

@ -567,6 +567,9 @@ PWire*pform_get_make_wire_in_scope(perm_string name, NetNet::Type net_type, NetN
cur = new PWire(name, net_type, port_type, vt_type);
pform_put_wire_in_scope(name, cur);
} else {
// If this is a duplicate wire, the data type has already
// been set, then return NULL.
if (cur->get_data_type() != IVL_VT_NO_TYPE) return 0;
bool rc = cur->set_wire_type(net_type);
assert(rc);
rc = cur->set_data_type(vt_type);
@ -3144,6 +3147,7 @@ template <class T> static void pform_set2_data_type(const struct vlltype&li, T*d
}
PWire*net = pform_get_make_wire_in_scope(name, net_type, NetNet::NOT_A_PORT, base_type);
assert(net);
net->set_data_type(data_type);
pform_bind_attributes(net->attributes, attr, true);
}
@ -3160,9 +3164,14 @@ static void pform_set_enum(const struct vlltype&li, enum_type_t*enum_type,
perm_string name, NetNet::Type net_type,
std::list<named_pexpr_t>*attr)
{
(void) li; // The line information is not currently needed.
PWire*cur = pform_get_make_wire_in_scope(name, net_type, NetNet::NOT_A_PORT, enum_type->base_type);
assert(cur);
// A NULL is returned for a duplicate enumeration.
if (! cur) {
cerr << li.get_fileline() << ": error: Found duplicate "
<< "enumeration named " << name << "." << endl;
error_count += 1;
return;
}
cur->set_signed(enum_type->signed_flag);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012 Picture Elements, Inc.
* Copyright (c) 2012-2014 Picture Elements, Inc.
* Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
@ -25,6 +25,7 @@
static void pform_set_class_type(class_type_t*class_type, perm_string name, NetNet::Type net_type, list<named_pexpr_t>*attr)
{
PWire*net = pform_get_make_wire_in_scope(name, net_type, NetNet::NOT_A_PORT, IVL_VT_CLASS);
assert(net);
net->set_data_type(class_type);
pform_bind_attributes(net->attributes, attr, true);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012-2013 Stephen Williams (steve@icarus.com)
* Copyright (c) 2012-2014 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -24,6 +24,7 @@
static void pform_set_string_type(const string_type_t*, perm_string name, NetNet::Type net_type, list<named_pexpr_t>*attr)
{
PWire*net = pform_get_make_wire_in_scope(name, net_type, NetNet::NOT_A_PORT, IVL_VT_STRING);
assert(net);
pform_bind_attributes(net->attributes, attr, true);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2012 Stephen Williams (steve@icarus.com)
* Copyright (c) 2011-2014 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -67,6 +67,7 @@ static void pform_set_packed_struct(struct_type_t*struct_type, perm_string name,
ivl_variable_type_t base_type = struct_type->figure_packed_base_type();
PWire*net = pform_get_make_wire_in_scope(name, net_type, NetNet::NOT_A_PORT, base_type);
assert(net);
net->set_data_type(struct_type);
pform_bind_attributes(net->attributes, attr, true);
}
@ -99,6 +100,7 @@ static void pform_makewire(const struct vlltype&li,
ivl_variable_type_t base_type = struct_type->figure_packed_base_type();
PWire*cur = pform_get_make_wire_in_scope(name, NetNet::WIRE, ptype, base_type);
assert(cur);
FILE_NAME(cur, li);
cur->set_data_type(struct_type);
}