Record data type for all pform "wires" added the new way.

For unpacked arrays, record both the array type and the base type.
This will be needed to elaborate typedefs in the correct scope.
This commit is contained in:
Martin Whitaker 2019-12-22 11:03:50 +00:00
parent 465e0d2710
commit 95147a2cc2
5 changed files with 15 additions and 18 deletions

View File

@ -29,7 +29,7 @@ PWire::PWire(perm_string n,
: name_(n), type_(t), port_type_(pt), data_type_(dt),
signed_(false), isint_(false),
port_set_(false), net_set_(false), is_scalar_(false),
error_cnt_(0), set_data_type_(0),
error_cnt_(0), uarray_type_(0), set_data_type_(0),
discipline_(0)
{
if (t == NetNet::INTEGER) {

View File

@ -80,6 +80,7 @@ class PWire : public PNamedItem {
void set_range(const std::list<pform_range_t>&ranges, PWSRType type);
void set_unpacked_idx(const std::list<pform_range_t>&ranges);
void set_uarray_type(uarray_type_t*type) { uarray_type_ = type; }
void set_data_type(data_type_t*type);
@ -119,6 +120,7 @@ class PWire : public PNamedItem {
// If this wire is actually a memory, these indices will give
// me the size and address ranges of the memory.
std::list<pform_range_t>unpacked_;
uarray_type_t*uarray_type_;
// This is the complex type of the wire. the data_type_ may
// modify how this is interpreted.

View File

@ -3474,7 +3474,6 @@ template <class T> static void pform_set2_data_type(const struct vlltype&li, T*d
PWire*net = pform_get_make_wire_in_scope(li, name, net_type, NetNet::NOT_A_PORT, base_type);
assert(net);
net->set_data_type(data_type);
pform_bind_attributes(net->attributes, attr, true);
}
@ -3498,7 +3497,6 @@ static void pform_set_enum(const struct vlltype&li, enum_type_t*enum_type,
assert(enum_type->range.get() != 0);
assert(enum_type->range->size() == 1);
//XXXXcur->set_range(*enum_type->range, SR_NET);
cur->set_data_type(enum_type);
// If this is an integer enumeration switch the wire to an integer.
if (enum_type->integer_flag) {
bool res = cur->set_wire_type(NetNet::INTEGER);
@ -3540,17 +3538,14 @@ static void pform_set_enum(const struct vlltype&li, enum_type_t*enum_type,
*/
void pform_set_data_type(const struct vlltype&li, data_type_t*data_type, list<perm_string>*names, NetNet::Type net_type, list<named_pexpr_t>*attr)
{
const std::list<pform_range_t>*unpacked_dims = NULL;
if (data_type == 0) {
VLerror(li, "internal error: data_type==0.");
assert(0);
}
if(uarray_type_t*uarray_type = dynamic_cast<uarray_type_t*> (data_type)) {
unpacked_dims = uarray_type->dims.get();
uarray_type_t*uarray_type = dynamic_cast<uarray_type_t*> (data_type);
if (uarray_type)
data_type = uarray_type->base_type;
}
if (atom2_type_t*atom2_type = dynamic_cast<atom2_type_t*> (data_type)) {
pform_set_integer_2atom(li, atom2_type->type_code, atom2_type->signed_flag, names, net_type, attr);
@ -3593,12 +3588,14 @@ void pform_set_data_type(const struct vlltype&li, data_type_t*data_type, list<pe
assert(0);
}
if(unpacked_dims) {
for (list<perm_string>::iterator cur = names->begin()
; cur != names->end() ; ++ cur ) {
PWire*wire = pform_get_wire_in_scope(*cur);
wire->set_unpacked_idx(*unpacked_dims);
for (list<perm_string>::iterator cur = names->begin()
; cur != names->end() ; ++ cur ) {
PWire*wire = pform_get_wire_in_scope(*cur);
if (uarray_type) {
wire->set_unpacked_idx(*uarray_type->dims.get());
wire->set_uarray_type(uarray_type);
}
wire->set_data_type(data_type);
}
delete names;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012-2014 Picture Elements, Inc.
* Copyright (c) 2012-2019 Picture Elements, Inc.
* Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
@ -22,11 +22,10 @@
# include "parse_misc.h"
# include "ivl_assert.h"
static void pform_set_class_type(const struct vlltype&li, class_type_t*class_type, perm_string name, NetNet::Type net_type, list<named_pexpr_t>*attr)
static void pform_set_class_type(const struct vlltype&li, class_type_t*, perm_string name, NetNet::Type net_type, list<named_pexpr_t>*attr)
{
PWire*net = pform_get_make_wire_in_scope(li, 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) 2011-2014 Stephen Williams (steve@icarus.com)
* Copyright (c) 2011-2019 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
@ -68,7 +68,6 @@ static void pform_set_packed_struct(const struct vlltype&li, struct_type_t*struc
PWire*net = pform_get_make_wire_in_scope(li, name, net_type, NetNet::NOT_A_PORT, base_type);
assert(net);
net->set_data_type(struct_type);
pform_bind_attributes(net->attributes, attr, true);
}