Add support for getting the original port names of a UDP definition.

This patch adds support to the compiler/ivl interface for getting the
original UDP definition port names. ivl_udp_port() was added to get
this information.
This commit is contained in:
Cary R 2011-02-20 10:57:27 -08:00 committed by Stephen Williams
parent 757611b8e9
commit 53abd7a5b2
7 changed files with 55 additions and 32 deletions

View File

@ -288,6 +288,7 @@ ivl_udp_file
ivl_udp_lineno
ivl_udp_name
ivl_udp_nin
ivl_udp_port
ivl_udp_row
ivl_udp_rows
ivl_udp_sequ

View File

@ -1040,6 +1040,7 @@ extern unsigned ivl_udp_rows(ivl_udp_t net);
extern const char* ivl_udp_name(ivl_udp_t net);
extern const char* ivl_udp_file(ivl_udp_t net);
extern unsigned ivl_udp_lineno(ivl_udp_t net);
extern const char* ivl_udp_port(ivl_udp_t net, unsigned idx);
extern const char* ivl_lpm_file(ivl_lpm_t net);
extern unsigned ivl_lpm_lineno(ivl_lpm_t net);

View File

@ -79,3 +79,14 @@ char NetUDP::get_initial() const
assert(0);
return 'x';
}
unsigned NetUDP::port_count() const
{
return udp->ports.count();
}
string NetUDP::port_name(unsigned idx) const
{
assert(idx < udp->ports.count());
return udp->ports[idx];
}

View File

@ -42,6 +42,7 @@
# include "LineInfo.h"
# include "svector.h"
# include "Attrib.h"
# include "PUdp.h"
#ifdef HAVE_IOSFWD
# include <iosfwd>
@ -2144,7 +2145,6 @@ class NetUReduce : public NetNode {
* 1 are listed.
*
*/
#include "PUdp.h"
class NetUDP : public NetNode {
@ -2169,6 +2169,9 @@ class NetUDP : public NetNode {
unsigned udp_lineno() const { return udp->get_lineno(); }
char get_initial() const;
unsigned port_count() const;
string port_name(unsigned idx) const;
private:
mutable unsigned table_idx;
PUdp *udp;

View File

@ -867,6 +867,14 @@ extern "C" char ivl_udp_init(ivl_udp_t net)
return net->init;
}
extern "C" const char* ivl_udp_port(ivl_udp_t net, unsigned idx)
{
assert(idx <= net->nin);
assert(net->ports);
assert(net->ports[idx].c_str());
return net->ports[idx].c_str();
}
extern "C" const char* ivl_udp_row(ivl_udp_t net, unsigned idx)
{
assert(idx < net->nrows);

View File

@ -1270,38 +1270,36 @@ void dll_target::udp(const NetUDP*net)
static map<perm_string,ivl_udp_t> udps;
ivl_udp_t u;
if (udps.find(net->udp_name()) != udps.end())
{
u = udps[net->udp_name()];
}
else
{
u = new struct ivl_udp_s;
u->nrows = net->rows();
u->table = (ivl_udp_s::ccharp_t*)malloc((u->nrows+1)*sizeof(char*));
u->table[u->nrows] = 0x0;
u->nin = net->nin();
u->sequ = net->is_sequential();
u->file = net->udp_file();
u->lineno = net->udp_lineno();
if (u->sequ)
u->init = net->get_initial();
else
u->init = 'x';
u->name = net->udp_name();
string inp;
char out;
unsigned int i = 0;
if (net->first(inp, out))
do
{
string tt = inp+out;
u->table[i++] = strings_.add(tt.c_str());
} while (net->next(inp, out));
assert(i==u->nrows);
if (udps.find(net->udp_name()) != udps.end()) {
u = udps[net->udp_name()];
} else {
u = new struct ivl_udp_s;
u->nrows = net->rows();
u->table = (ivl_udp_s::ccharp_t*)malloc((u->nrows+1)*sizeof(char*));
u->table[u->nrows] = 0x0;
u->nin = net->nin();
u->sequ = net->is_sequential();
u->file = net->udp_file();
u->lineno = net->udp_lineno();
if (u->sequ) u->init = net->get_initial();
else u->init = 'x';
u->name = net->udp_name();
string inp;
char out;
unsigned int i = 0;
if (net->first(inp, out)) do {
string tt = inp+out;
u->table[i++] = strings_.add(tt.c_str());
} while (net->next(inp, out));
assert(i==u->nrows);
assert((u->nin + 1) == net->port_count());
u->ports = new string [u->nin + 1];
for(unsigned idx = 0; idx <= u->nin; idx += 1) {
u->ports[idx] = net->port_name(idx);
}
udps[net->udp_name()] = u;
}
udps[net->udp_name()] = u;
}
obj->udp = u;

View File

@ -517,6 +517,7 @@ struct ivl_udp_s {
ccharp_t*table; // zero terminated array of pointers
perm_string file;
unsigned lineno;
string*ports;
};
/*