Remove C++ string from variable lists.
This commit is contained in:
parent
d92ac5772c
commit
88c8547486
74
parse.y
74
parse.y
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT) && !defined(macintosh)
|
||||
#ident "$Id: parse.y,v 1.107 2000/10/14 02:23:02 steve Exp $"
|
||||
#ident "$Id: parse.y,v 1.108 2000/10/31 17:00:04 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "parse_misc.h"
|
||||
|
|
@ -38,7 +38,11 @@ static struct str_pair_t decl_strength = { PGate::STRONG, PGate::STRONG };
|
|||
|
||||
%union {
|
||||
char letter;
|
||||
/* text items are C strings allocated by the lexor using
|
||||
strdup. They can be put into lists with the texts type. */
|
||||
char*text;
|
||||
list<char*>*texts;
|
||||
|
||||
list<string>*strings;
|
||||
|
||||
struct str_pair_t drive;
|
||||
|
|
@ -115,11 +119,10 @@ static struct str_pair_t decl_strength = { PGate::STRONG, PGate::STRONG };
|
|||
%type <statement> udp_initial udp_init_opt
|
||||
|
||||
%type <text> identifier register_variable
|
||||
%type <strings> register_variable_list
|
||||
%type <strings> list_of_variables
|
||||
%type <texts> register_variable_list list_of_variables
|
||||
|
||||
%type <text> net_decl_assign
|
||||
%type <strings> net_decl_assigns
|
||||
%type <texts> net_decl_assigns
|
||||
|
||||
%type <mport> port port_opt port_reference port_reference_list
|
||||
%type <mports> list_of_ports list_of_ports_opt
|
||||
|
|
@ -193,15 +196,11 @@ source_file
|
|||
block_item_decl
|
||||
: K_reg range register_variable_list ';'
|
||||
{ pform_set_net_range($3, $2);
|
||||
delete $2;
|
||||
delete $3;
|
||||
}
|
||||
| K_reg register_variable_list ';'
|
||||
{ delete $2; }
|
||||
| K_reg K_signed range register_variable_list ';'
|
||||
{ pform_set_net_range($4, $3);
|
||||
delete $3;
|
||||
delete $4;
|
||||
yyerror(@2, "sorry: signed reg not supported.");
|
||||
}
|
||||
| K_reg K_signed register_variable_list ';'
|
||||
|
|
@ -210,7 +209,6 @@ block_item_decl
|
|||
}
|
||||
| K_integer list_of_variables ';'
|
||||
{ pform_set_reg_integer($2);
|
||||
delete $2;
|
||||
}
|
||||
;
|
||||
|
||||
|
|
@ -843,8 +841,6 @@ function_item
|
|||
{ svector<PWire*>*tmp
|
||||
= pform_make_task_ports(NetNet::PINPUT, $2, $3,
|
||||
@1.text, @1.first_line);
|
||||
delete $2;
|
||||
delete $3;
|
||||
$$ = tmp;
|
||||
}
|
||||
| block_item_decl
|
||||
|
|
@ -994,15 +990,13 @@ list_of_ports_opt
|
|||
|
||||
list_of_variables
|
||||
: IDENTIFIER
|
||||
{ list<string>*tmp = new list<string>;
|
||||
{ list<char*>*tmp = new list<char*>;
|
||||
tmp->push_back($1);
|
||||
delete $1;
|
||||
$$ = tmp;
|
||||
}
|
||||
| list_of_variables ',' IDENTIFIER
|
||||
{ list<string>*tmp = $1;
|
||||
{ list<char*>*tmp = $1;
|
||||
tmp->push_back($3);
|
||||
delete $3;
|
||||
$$ = tmp;
|
||||
}
|
||||
;
|
||||
|
|
@ -1130,30 +1124,19 @@ module
|
|||
|
||||
module_item
|
||||
: net_type range_opt list_of_variables ';'
|
||||
{ pform_makewire(@1, $3, $1);
|
||||
if ($2) {
|
||||
pform_set_net_range($3, $2);
|
||||
delete $2;
|
||||
}
|
||||
delete $3;
|
||||
{ pform_makewire(@1, $2, $3, $1);
|
||||
}
|
||||
| net_type range_opt net_decl_assigns ';'
|
||||
{ pform_makewire(@1, $3, $1);
|
||||
if ($2) {
|
||||
pform_set_net_range($3, $2);
|
||||
delete $2;
|
||||
}
|
||||
delete $3;
|
||||
{ pform_makewire(@1, $2, $3, $1);
|
||||
}
|
||||
| net_type drive_strength { decl_strength = $2;} net_decl_assigns ';'
|
||||
{ pform_makewire(@1, $4, $1);
|
||||
{ pform_makewire(@1, 0, $4, $1);
|
||||
/* The strengths are handled in the
|
||||
net_decl_assigns using the decl_strength that I
|
||||
set in the rule. Right here, just restore the
|
||||
defaults for other rules. */
|
||||
decl_strength.str0 = PGate::STRONG;
|
||||
decl_strength.str1 = PGate::STRONG;
|
||||
delete $4;
|
||||
}
|
||||
| K_trireg charge_strength_opt range_opt delay3_opt list_of_variables ';'
|
||||
{ yyerror(@1, "sorry: trireg nets not supported.");
|
||||
|
|
@ -1161,12 +1144,7 @@ module_item
|
|||
}
|
||||
|
||||
| port_type range_opt list_of_variables ';'
|
||||
{ pform_set_port_type($3, $1);
|
||||
if ($2) {
|
||||
pform_set_net_range($3, $2);
|
||||
delete $2;
|
||||
}
|
||||
delete $3;
|
||||
{ pform_set_port_type($3, $2, $1);
|
||||
}
|
||||
| port_type range_opt error ';'
|
||||
{ yyerror(@3, "error: Invalid variable list"
|
||||
|
|
@ -1178,7 +1156,6 @@ module_item
|
|||
| K_defparam defparam_assign_list ';'
|
||||
| K_event list_of_variables ';'
|
||||
{ pform_make_events($2, @1.text, @1.first_line);
|
||||
delete $2;
|
||||
}
|
||||
| K_parameter parameter_assign_list ';'
|
||||
| K_localparam localparam_assign_list ';' { }
|
||||
|
|
@ -1299,9 +1276,14 @@ module_item_list
|
|||
| module_item
|
||||
;
|
||||
|
||||
|
||||
/* A net declaration assignment allows the programmer to combine the
|
||||
net declaration and the continuous assignment into a single
|
||||
statement. */
|
||||
statement.
|
||||
|
||||
Note that the continuous assignment statement is generated as a
|
||||
side effect, and all I pass up is the name of the l-value. */
|
||||
|
||||
net_decl_assign
|
||||
: IDENTIFIER '=' expression
|
||||
{ PEIdent*id = new PEIdent($1);
|
||||
|
|
@ -1322,15 +1304,13 @@ net_decl_assign
|
|||
|
||||
net_decl_assigns
|
||||
: net_decl_assigns ',' net_decl_assign
|
||||
{ list<string>*tmp = $1;
|
||||
{ list<char*>*tmp = $1;
|
||||
tmp->push_back($3);
|
||||
delete $3;
|
||||
$$ = tmp;
|
||||
}
|
||||
| net_decl_assign
|
||||
{ list<string>*tmp = new list<string>;
|
||||
{ list<char*>*tmp = new list<char*>;
|
||||
tmp->push_back($1);
|
||||
delete $1;
|
||||
$$ = tmp;
|
||||
}
|
||||
;
|
||||
|
|
@ -1738,15 +1718,13 @@ register_variable
|
|||
|
||||
register_variable_list
|
||||
: register_variable
|
||||
{ list<string>*tmp = new list<string>;
|
||||
{ list<char*>*tmp = new list<char*>;
|
||||
tmp->push_back($1);
|
||||
delete $1;
|
||||
$$ = tmp;
|
||||
}
|
||||
| register_variable_list ',' register_variable
|
||||
{ list<string>*tmp = $1;
|
||||
{ list<char*>*tmp = $1;
|
||||
tmp->push_back($3);
|
||||
delete $3;
|
||||
$$ = tmp;
|
||||
}
|
||||
;
|
||||
|
|
@ -2160,24 +2138,18 @@ task_item
|
|||
{ svector<PWire*>*tmp
|
||||
= pform_make_task_ports(NetNet::PINPUT, $2,
|
||||
$3, @1.text, @1.first_line);
|
||||
delete $2;
|
||||
delete $3;
|
||||
$$ = tmp;
|
||||
}
|
||||
| K_output range_opt list_of_variables ';'
|
||||
{ svector<PWire*>*tmp
|
||||
= pform_make_task_ports(NetNet::POUTPUT, $2, $3,
|
||||
@1.text, @1.first_line);
|
||||
delete $2;
|
||||
delete $3;
|
||||
$$ = tmp;
|
||||
}
|
||||
| K_inout range_opt list_of_variables ';'
|
||||
{ svector<PWire*>*tmp
|
||||
= pform_make_task_ports(NetNet::PINOUT, $2, $3,
|
||||
@1.text, @1.first_line);
|
||||
delete $2;
|
||||
delete $3;
|
||||
$$ = tmp;
|
||||
}
|
||||
;
|
||||
|
|
|
|||
156
pform.cc
156
pform.cc
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT) && !defined(macintosh)
|
||||
#ident "$Id: pform.cc,v 1.64 2000/09/13 16:32:26 steve Exp $"
|
||||
#ident "$Id: pform.cc,v 1.65 2000/10/31 17:00:04 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "compiler.h"
|
||||
|
|
@ -323,11 +323,48 @@ void pform_make_udp(const char*name, list<string>*parms,
|
|||
delete init_expr;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function attaches a range to a given name. The function is
|
||||
* only called by the parser within the scope of the net declaration,
|
||||
* and the name that I receive only has the tail component.
|
||||
*/
|
||||
static void pform_set_net_range(const char*name, const svector<PExpr*>*range)
|
||||
{
|
||||
assert(range);
|
||||
assert(range->count() == 2);
|
||||
|
||||
PWire*cur = pform_cur_module->get_wire(scoped_name(name));
|
||||
if (cur == 0) {
|
||||
VLerror(" error: name is not a valid net.");
|
||||
return;
|
||||
}
|
||||
|
||||
assert((*range)[0]);
|
||||
assert((*range)[1]);
|
||||
cur->set_range((*range)[0], (*range)[1]);
|
||||
}
|
||||
|
||||
void pform_set_net_range(list<char*>*names, svector<PExpr*>*range)
|
||||
{
|
||||
assert(range->count() == 2);
|
||||
|
||||
for (list<char*>::iterator cur = names->begin()
|
||||
; cur != names->end()
|
||||
; cur ++ ) {
|
||||
char*txt = *cur;
|
||||
pform_set_net_range(txt, range);
|
||||
free(txt);
|
||||
}
|
||||
|
||||
delete names;
|
||||
delete range;
|
||||
}
|
||||
|
||||
/*
|
||||
* This is invoked to make a named event. This is the declaration of
|
||||
* the event, and not necessarily the use of it.
|
||||
*/
|
||||
static void pform_make_event(const string&name, const string&fn, unsigned ln)
|
||||
static void pform_make_event(const char*name, const string&fn, unsigned ln)
|
||||
{
|
||||
PEvent*event = new PEvent(name);
|
||||
event->set_file(fn);
|
||||
|
|
@ -335,11 +372,16 @@ static void pform_make_event(const string&name, const string&fn, unsigned ln)
|
|||
pform_cur_module->events[name] = event;
|
||||
}
|
||||
|
||||
void pform_make_events(const list<string>*names, const string&fn, unsigned ln)
|
||||
void pform_make_events(list<char*>*names, const string&fn, unsigned ln)
|
||||
{
|
||||
list<string>::const_iterator cur;
|
||||
for (cur = names->begin() ; cur != names->end() ; cur++)
|
||||
pform_make_event(*cur, fn, ln);
|
||||
list<char*>::iterator cur;
|
||||
for (cur = names->begin() ; cur != names->end() ; cur++) {
|
||||
char*txt = *cur;
|
||||
pform_make_event(txt, fn, ln);
|
||||
free(txt);
|
||||
}
|
||||
|
||||
delete names;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -623,14 +665,24 @@ void pform_makewire(const vlltype&li, const string&nm,
|
|||
pform_cur_module->add_wire(cur);
|
||||
}
|
||||
|
||||
void pform_makewire(const vlltype&li, const list<string>*names,
|
||||
void pform_makewire(const vlltype&li,
|
||||
svector<PExpr*>*range,
|
||||
list<char*>*names,
|
||||
NetNet::Type type)
|
||||
{
|
||||
for (list<string>::const_iterator cur = names->begin()
|
||||
for (list<char*>::iterator cur = names->begin()
|
||||
; cur != names->end()
|
||||
; cur ++ )
|
||||
pform_makewire(li, *cur, type);
|
||||
; cur ++ ) {
|
||||
char*txt = *cur;
|
||||
pform_makewire(li, txt, type);
|
||||
if (range)
|
||||
pform_set_net_range(txt, range);
|
||||
free(txt);
|
||||
}
|
||||
|
||||
delete names;
|
||||
if (range)
|
||||
delete range;
|
||||
}
|
||||
|
||||
void pform_set_port_type(const string&nm, NetNet::PortType pt)
|
||||
|
|
@ -686,17 +738,18 @@ void pform_set_port_type(const string&nm, NetNet::PortType pt)
|
|||
* no output or inout ports.
|
||||
*/
|
||||
svector<PWire*>*pform_make_task_ports(NetNet::PortType pt,
|
||||
const svector<PExpr*>*range,
|
||||
const list<string>*names,
|
||||
svector<PExpr*>*range,
|
||||
list<char*>*names,
|
||||
const string& file,
|
||||
unsigned lineno)
|
||||
{
|
||||
assert(names);
|
||||
svector<PWire*>*res = new svector<PWire*>(0);
|
||||
for (list<string>::const_iterator cur = names->begin()
|
||||
for (list<char*>::iterator cur = names->begin()
|
||||
; cur != names->end() ; cur ++ ) {
|
||||
|
||||
string name = scoped_name(*cur);
|
||||
char*txt = *cur;
|
||||
string name = scoped_name(txt);
|
||||
|
||||
/* Look for a preexisting wire. If it exists, set the
|
||||
port direction. If not, create it. */
|
||||
|
|
@ -715,10 +768,15 @@ svector<PWire*>*pform_make_task_ports(NetNet::PortType pt,
|
|||
curw->set_range((*range)[0], (*range)[1]);
|
||||
|
||||
svector<PWire*>*tmp = new svector<PWire*>(*res, curw);
|
||||
|
||||
free(txt);
|
||||
delete res;
|
||||
res = tmp;
|
||||
}
|
||||
|
||||
if (range)
|
||||
delete range;
|
||||
delete names;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
@ -791,38 +849,6 @@ void pform_set_reg_idx(const string&name, PExpr*l, PExpr*r)
|
|||
cur->set_memory_idx(l, r);
|
||||
}
|
||||
|
||||
/*
|
||||
* This function attaches a range to a given name. The function is
|
||||
* only called by the parser within the scope of the net declaration,
|
||||
* and the name that I receive only has the tail component.
|
||||
*/
|
||||
static void pform_set_net_range(const string&name, const svector<PExpr*>*range)
|
||||
{
|
||||
assert(range);
|
||||
assert(range->count() == 2);
|
||||
|
||||
PWire*cur = pform_cur_module->get_wire(scoped_name(name));
|
||||
if (cur == 0) {
|
||||
VLerror(" error: name is not a valid net.");
|
||||
return;
|
||||
}
|
||||
|
||||
assert((*range)[0]);
|
||||
assert((*range)[1]);
|
||||
cur->set_range((*range)[0], (*range)[1]);
|
||||
}
|
||||
|
||||
void pform_set_net_range(list<string>*names, const svector<PExpr*>*range)
|
||||
{
|
||||
assert(range->count() == 2);
|
||||
|
||||
for (list<string>::const_iterator cur = names->begin()
|
||||
; cur != names->end()
|
||||
; cur ++ ) {
|
||||
pform_set_net_range(*cur, range);
|
||||
}
|
||||
}
|
||||
|
||||
void pform_set_parameter(const string&name, PExpr*expr)
|
||||
{
|
||||
assert(expr);
|
||||
|
|
@ -842,16 +868,26 @@ void pform_set_defparam(const string&name, PExpr*expr)
|
|||
pform_cur_module->defparms[name] = expr;
|
||||
}
|
||||
|
||||
void pform_set_port_type(list<string>*names, NetNet::PortType pt)
|
||||
void pform_set_port_type(list<char*>*names,
|
||||
svector<PExpr*>*range,
|
||||
NetNet::PortType pt)
|
||||
{
|
||||
for (list<string>::const_iterator cur = names->begin()
|
||||
for (list<char*>::iterator cur = names->begin()
|
||||
; cur != names->end()
|
||||
; cur ++ ) {
|
||||
pform_set_port_type(*cur, pt);
|
||||
char*txt = *cur;
|
||||
pform_set_port_type(txt, pt);
|
||||
if (range)
|
||||
pform_set_net_range(txt, range);
|
||||
free(txt);
|
||||
}
|
||||
|
||||
delete names;
|
||||
if (range)
|
||||
delete range;
|
||||
}
|
||||
|
||||
static void pform_set_reg_integer(const string&nm)
|
||||
static void pform_set_reg_integer(const char*nm)
|
||||
{
|
||||
string name = scoped_name(nm);
|
||||
PWire*cur = pform_cur_module->get_wire(name);
|
||||
|
|
@ -868,26 +904,31 @@ static void pform_set_reg_integer(const string&nm)
|
|||
new PENumber(new verinum(0UL, INTEGER_WIDTH)));
|
||||
}
|
||||
|
||||
void pform_set_reg_integer(list<string>*names)
|
||||
void pform_set_reg_integer(list<char*>*names)
|
||||
{
|
||||
for (list<string>::const_iterator cur = names->begin()
|
||||
for (list<char*>::iterator cur = names->begin()
|
||||
; cur != names->end()
|
||||
; cur ++ ) {
|
||||
pform_set_reg_integer(*cur);
|
||||
char*txt = *cur;
|
||||
pform_set_reg_integer(txt);
|
||||
free(txt);
|
||||
}
|
||||
delete names;
|
||||
}
|
||||
|
||||
svector<PWire*>* pform_make_udp_input_ports(list<string>*names)
|
||||
svector<PWire*>* pform_make_udp_input_ports(list<char*>*names)
|
||||
{
|
||||
svector<PWire*>*out = new svector<PWire*>(names->size());
|
||||
|
||||
unsigned idx = 0;
|
||||
for (list<string>::const_iterator cur = names->begin()
|
||||
for (list<char*>::iterator cur = names->begin()
|
||||
; cur != names->end()
|
||||
; cur ++ ) {
|
||||
PWire*pp = new PWire(*cur, NetNet::IMPLICIT, NetNet::PINPUT);
|
||||
char*txt = *cur;
|
||||
PWire*pp = new PWire(txt, NetNet::IMPLICIT, NetNet::PINPUT);
|
||||
(*out)[idx] = pp;
|
||||
idx += 1;
|
||||
free(txt);
|
||||
}
|
||||
|
||||
delete names;
|
||||
|
|
@ -932,6 +973,9 @@ int pform_parse(const char*path, map<string,Module*>&modules,
|
|||
|
||||
/*
|
||||
* $Log: pform.cc,v $
|
||||
* Revision 1.65 2000/10/31 17:00:04 steve
|
||||
* Remove C++ string from variable lists.
|
||||
*
|
||||
* Revision 1.64 2000/09/13 16:32:26 steve
|
||||
* Error message for invalid variable list.
|
||||
*
|
||||
|
|
|
|||
24
pform.h
24
pform.h
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT) && !defined(macintosh)
|
||||
#ident "$Id: pform.h,v 1.41 2000/07/29 17:58:21 steve Exp $"
|
||||
#ident "$Id: pform.h,v 1.42 2000/10/31 17:00:05 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "netlist.h"
|
||||
|
|
@ -129,14 +129,17 @@ extern void pform_pop_scope();
|
|||
*/
|
||||
extern void pform_makewire(const struct vlltype&li, const string&name,
|
||||
NetNet::Type type = NetNet::IMPLICIT);
|
||||
extern void pform_makewire(const struct vlltype&li, const list<string>*names,
|
||||
extern void pform_makewire(const struct vlltype&li,
|
||||
svector<PExpr*>*range,
|
||||
list<char*>*names,
|
||||
NetNet::Type type);
|
||||
extern void pform_make_reginit(const struct vlltype&li,
|
||||
const string&name, PExpr*expr);
|
||||
extern void pform_set_port_type(list<string>*names, NetNet::PortType);
|
||||
extern void pform_set_net_range(list<string>*names, const svector<PExpr*>*);
|
||||
extern void pform_set_port_type(list<char*>*names, svector<PExpr*>*,
|
||||
NetNet::PortType);
|
||||
extern void pform_set_net_range(list<char*>*names, svector<PExpr*>*);
|
||||
extern void pform_set_reg_idx(const string&name, PExpr*l, PExpr*r);
|
||||
extern void pform_set_reg_integer(list<string>*names);
|
||||
extern void pform_set_reg_integer(list<char*>*names);
|
||||
extern void pform_set_task(const string&, PTask*);
|
||||
extern void pform_set_function(const string&, svector<PExpr*>*, PFunction*);
|
||||
extern void pform_set_attrib(const string&name, const string&key,
|
||||
|
|
@ -148,11 +151,11 @@ extern void pform_set_localparam(const string&name, PExpr*expr);
|
|||
extern void pform_set_defparam(const string&name, PExpr*expr);
|
||||
extern PProcess* pform_make_behavior(PProcess::Type, Statement*);
|
||||
|
||||
extern svector<PWire*>* pform_make_udp_input_ports(list<string>*);
|
||||
extern svector<PWire*>* pform_make_udp_input_ports(list<char*>*);
|
||||
|
||||
extern bool pform_expression_is_constant(const PExpr*);
|
||||
|
||||
extern void pform_make_events(const list<string>*names,
|
||||
extern void pform_make_events(list<char*>*names,
|
||||
const string&file, unsigned lineno);
|
||||
|
||||
/*
|
||||
|
|
@ -181,8 +184,8 @@ extern void pform_make_pgassign_list(svector<PExpr*>*alist,
|
|||
/* Given a port type and a list of names, make a list of wires that
|
||||
can be used as task port information. */
|
||||
extern svector<PWire*>*pform_make_task_ports(NetNet::PortType pt,
|
||||
const svector<PExpr*>*range,
|
||||
const list<string>*names,
|
||||
svector<PExpr*>*range,
|
||||
list<char*>*names,
|
||||
const string& file,
|
||||
unsigned lineno);
|
||||
|
||||
|
|
@ -199,6 +202,9 @@ extern void pform_dump(ostream&out, Module*mod);
|
|||
|
||||
/*
|
||||
* $Log: pform.h,v $
|
||||
* Revision 1.42 2000/10/31 17:00:05 steve
|
||||
* Remove C++ string from variable lists.
|
||||
*
|
||||
* Revision 1.41 2000/07/29 17:58:21 steve
|
||||
* Introduce min:typ:max support.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue