From e22831553da7b7eca60ccc642007ebbfec1c7376 Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Sun, 18 Feb 2024 22:34:48 +0000 Subject: [PATCH] Improve identifier lexical position accuracy in declarations. Enhance the lists of identifiers and declaration assignments generated by the parser to associate each identifier with its lexical_pos. Also do this for single items in complex parser rules where the location passed to the pform is not the location of the identifier. --- elab_type.cc | 4 +- parse.y | 92 ++++++++++++++++++++----------------------- pform.cc | 94 +++++++++++++++++++++----------------------- pform.h | 22 ++++++----- pform_disciplines.cc | 8 ++-- pform_dump.cc | 4 +- pform_pclass.cc | 8 ++-- pform_types.h | 12 ++++-- 8 files changed, 121 insertions(+), 123 deletions(-) diff --git a/elab_type.cc b/elab_type.cc index 7ae224836..9048e3afc 100644 --- a/elab_type.cc +++ b/elab_type.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2020 Stephen Williams (steve@icarus.com) + * Copyright (c) 2012-2024 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 @@ -250,7 +250,7 @@ ivl_type_t struct_type_t::elaborate_type_raw(Design*des, NetScope*scope) const } netstruct_t::member_t memb; - memb.name = namep->name; + memb.name = namep->name.first; memb.net_type = elaborate_array_type(des, scope, *this, mem_vec, namep->index); res->append_member(des, memb); diff --git a/parse.y b/parse.y index 47a356098..9128f29e5 100644 --- a/parse.y +++ b/parse.y @@ -135,32 +135,39 @@ static std::list*attributes_in_context = 0; static const struct str_pair_t pull_strength = { IVL_DR_PULL, IVL_DR_PULL }; static const struct str_pair_t str_strength = { IVL_DR_STRONG, IVL_DR_STRONG }; -static std::list* make_port_list(char*id, std::list*udims, PExpr*expr) +static std::list* make_port_list(char*id, unsigned idn, + std::list*udims, + PExpr*expr) { std::list*tmp = new std::list; - tmp->push_back(pform_port_t(lex_strings.make(id), udims, expr)); + pform_ident_t tmp_name = { lex_strings.make(id), idn }; + tmp->push_back(pform_port_t(tmp_name, udims, expr)); delete[]id; return tmp; } static std::list* make_port_list(list*tmp, - char*id, std::list*udims, PExpr*expr) + char*id, unsigned idn, + std::list*udims, + PExpr*expr) { - tmp->push_back(pform_port_t(lex_strings.make(id), udims, expr)); + pform_ident_t tmp_name = { lex_strings.make(id), idn }; + tmp->push_back(pform_port_t(tmp_name, udims, expr)); delete[]id; return tmp; } -static std::list* list_from_identifier(char*id) +static std::list* list_from_identifier(char*id, unsigned idn) { - std::list*tmp = new std::list; - tmp->push_back(lex_strings.make(id)); + std::list*tmp = new std::list; + tmp->push_back({ lex_strings.make(id), idn }); delete[]id; return tmp; } -static std::list* list_from_identifier(list*tmp, char*id) +static std::list* list_from_identifier(list*tmp, + char*id, unsigned idn) { - tmp->push_back(lex_strings.make(id)); + tmp->push_back({ lex_strings.make(id), idn }); delete[]id; return tmp; } @@ -376,10 +383,10 @@ Module::port_t *module_declare_port(const YYLTYPE&loc, char *id, PExpr *default_value, std::list *attributes) { - perm_string name = lex_strings.make(id); + pform_ident_t name = { lex_strings.make(id), loc.lexical_pos }; delete[] id; - Module::port_t *port = pform_module_port_reference(loc, name); + Module::port_t *port = pform_module_port_reference(loc, name.first); switch (port_type) { case NetNet::PINOUT: @@ -442,6 +449,8 @@ Module::port_t *module_declare_port(const YYLTYPE&loc, char *id, char*text; std::list*perm_strings; + std::list*identifiers; + std::list*port_list; std::vector* tf_ports; @@ -655,10 +664,10 @@ Module::port_t *module_declare_port(const YYLTYPE&loc, char *id, %type drive_strength drive_strength_opt dr_strength0 dr_strength1 %type udp_input_sym udp_output_sym %type udp_input_list udp_sequ_entry udp_comb_entry -%type udp_input_declaration_list +%type udp_input_declaration_list %type udp_entry_list udp_comb_entry_list udp_sequ_entry_list %type udp_body -%type udp_port_list +%type udp_port_list %type udp_port_decl udp_port_decls %type udp_initial udp_init_opt @@ -668,8 +677,9 @@ Module::port_t *module_declare_port(const YYLTYPE&loc, char *id, %type event_variable label_opt class_declaration_endlabel_opt %type block_identifier_opt %type identifier_name -%type event_variable_list -%type list_of_identifiers loop_variables +%type event_variable_list +%type list_of_identifiers +%type loop_variables %type list_of_port_identifiers list_of_variable_port_identifiers %type net_decl_assigns @@ -1773,7 +1783,7 @@ loop_statement /* IEEE1800-2005: A.6.8 */ listassign_list; decl_assignment_t*tmp_assign = new decl_assignment_t; - tmp_assign->name = lex_strings.make($5); + tmp_assign->name = { lex_strings.make($5), @5.lexical_pos }; assign_list.push_back(tmp_assign); pform_make_var(@5, &assign_list, $4); } @@ -1916,7 +1926,7 @@ variable_decl_assignment /* IEEE1800-2005 A.2.3 */ } decl_assignment_t*tmp = new decl_assignment_t; - tmp->name = lex_strings.make($1); + tmp->name = { lex_strings.make($1), @1.lexical_pos }; if ($2) { tmp->index = *$2; delete $2; @@ -2500,7 +2510,7 @@ tf_port_item /* IEEE1800-2005: A.2.7 */ NetNet::PortType use_port_type = $1; if ((use_port_type == NetNet::PIMPLICIT) && (gn_system_verilog() || ($3 == 0))) use_port_type = port_declaration_context.port_type; - list* port_list = make_port_list($4, $5, 0); + list* port_list = make_port_list($4, @4.lexical_pos, $5, 0); if (use_port_type == NetNet::PIMPLICIT) { yyerror(@1, "error: Missing task/function port direction."); @@ -4486,23 +4496,23 @@ hierarchy_identifier non-hierarchical names separated by ',' characters. */ list_of_identifiers : IDENTIFIER - { $$ = list_from_identifier($1); } + { $$ = list_from_identifier($1, @1.lexical_pos); } | list_of_identifiers ',' IDENTIFIER - { $$ = list_from_identifier($1, $3); } + { $$ = list_from_identifier($1, $3, @3.lexical_pos); } ; list_of_port_identifiers : IDENTIFIER dimensions_opt - { $$ = make_port_list($1, $2, 0); } + { $$ = make_port_list($1, @1.lexical_pos, $2, 0); } | list_of_port_identifiers ',' IDENTIFIER dimensions_opt - { $$ = make_port_list($1, $3, $4, 0); } + { $$ = make_port_list($1, $3, @3.lexical_pos, $4, 0); } ; list_of_variable_port_identifiers : IDENTIFIER dimensions_opt initializer_opt - { $$ = make_port_list($1, $2, $3); } + { $$ = make_port_list($1, @1.lexical_pos, $2, $3); } | list_of_variable_port_identifiers ',' IDENTIFIER dimensions_opt initializer_opt - { $$ = make_port_list($1, $3, $4, $5); } + { $$ = make_port_list($1, $3, @3.lexical_pos, $4, $5); } ; @@ -5421,7 +5431,7 @@ generate_block net_decl_assign : IDENTIFIER '=' expression { decl_assignment_t*tmp = new decl_assignment_t; - tmp->name = lex_strings.make($1); + tmp->name = { lex_strings.make($1), @1.lexical_pos }; tmp->expr.reset($3); delete[]$1; $$ = tmp; @@ -5894,7 +5904,7 @@ dimensions net_variable : IDENTIFIER dimensions_opt - { perm_string name = lex_strings.make($1); + { pform_ident_t name = { lex_strings.make($1), @1.lexical_pos }; $$ = pform_makewire(@1, name, NetNet::IMPLICIT, $2); delete [] $1; } @@ -5924,9 +5934,9 @@ event_variable event_variable_list : event_variable - { $$ = list_from_identifier($1); } + { $$ = list_from_identifier($1, @1.lexical_pos); } | event_variable_list ',' event_variable - { $$ = list_from_identifier($1, $3); } + { $$ = list_from_identifier($1, $3, @3.lexical_pos); } ; specify_item @@ -7289,17 +7299,9 @@ udp_port_decls udp_port_list : IDENTIFIER - { std::list*tmp = new std::list; - tmp->push_back(lex_strings.make($1)); - delete[]$1; - $$ = tmp; - } + { $$ = list_from_identifier($1, @1.lexical_pos); } | udp_port_list ',' IDENTIFIER - { std::list*tmp = $1; - tmp->push_back(lex_strings.make($3)); - delete[]$3; - $$ = tmp; - } + { $$ = list_from_identifier($1, $3, @3.lexical_pos); } ; udp_reg_opt @@ -7308,17 +7310,9 @@ udp_reg_opt udp_input_declaration_list : K_input IDENTIFIER - { std::list*tmp = new std::list; - tmp->push_back(lex_strings.make($2)); - $$ = tmp; - delete[]$2; - } + { $$ = list_from_identifier($2, @2.lexical_pos); } | udp_input_declaration_list ',' K_input IDENTIFIER - { std::list*tmp = $1; - tmp->push_back(lex_strings.make($4)); - $$ = tmp; - delete[]$4; - } + { $$ = list_from_identifier($1, $4, @4.lexical_pos); } ; udp_primitive @@ -7346,7 +7340,7 @@ udp_primitive udp_body K_endprimitive label_opt { perm_string tmp2 = lex_strings.make($2); - perm_string tmp6 = lex_strings.make($6); + pform_ident_t tmp6 = { lex_strings.make($6) , @6.lexical_pos }; pform_make_udp(@2, tmp2, $5, tmp6, $7, $9, $12); check_end_label(@14, "primitive", $2, $14); delete[]$2; diff --git a/pform.cc b/pform.cc index 0311ad731..2678163f5 100644 --- a/pform.cc +++ b/pform.cc @@ -969,7 +969,7 @@ void pform_make_foreach_declarations(const struct vlltype&loc, if (cur->nil()) continue; decl_assignment_t*tmp_assign = new decl_assignment_t; - tmp_assign->name = lex_strings.make(*cur); + tmp_assign->name = { lex_strings.make(*cur), 0 }; assign_list.push_back(tmp_assign); } @@ -1478,19 +1478,19 @@ void pform_endmodule(const char*name, bool inside_celldefine, pform_pop_scope(); } -void pform_genvars(const struct vlltype&li, list*names) +void pform_genvars(const struct vlltype&li, list*names) { - list::const_iterator cur; + list::const_iterator cur; for (cur = names->begin(); cur != names->end() ; *cur++) { PGenvar*genvar = new PGenvar(); FILE_NAME(genvar, li); if (pform_cur_generate) { - add_local_symbol(pform_cur_generate, *cur, genvar); - pform_cur_generate->genvars[*cur] = genvar; + add_local_symbol(pform_cur_generate, cur->first, genvar); + pform_cur_generate->genvars[cur->first] = genvar; } else { - add_local_symbol(pform_cur_module.front(), *cur, genvar); - pform_cur_module.front()->genvars[*cur] = genvar; + add_local_symbol(pform_cur_module.front(), cur->first, genvar); + pform_cur_module.front()->genvars[cur->first] = genvar; } } @@ -1855,7 +1855,7 @@ static void process_udp_table(PUdp*udp, list*table, } void pform_make_udp(const struct vlltype&loc, perm_string name, - list*parms, vector*decl, + list*parms, vector*decl, list*table, Statement*init_expr) { unsigned local_errors = 0; @@ -1896,13 +1896,13 @@ void pform_make_udp(const struct vlltype&loc, perm_string name, PWire* created by an input or output declaration. */ std::vector pins(parms->size()); std::vector pin_names(parms->size()); - { list::iterator cur; + { list::iterator cur; unsigned idx; for (cur = parms->begin(), idx = 0 ; cur != parms->end() ; ++ idx, ++ cur) { - pins[idx] = defs[*cur]; - pin_names[idx] = *cur; + pins[idx] = defs[cur->first]; + pin_names[idx] = cur->first; } } @@ -2048,27 +2048,27 @@ void pform_make_udp(const struct vlltype&loc, perm_string name, } void pform_make_udp(const struct vlltype&loc, perm_string name, - bool synchronous_flag, perm_string out_name, - PExpr*init_expr, list*parms, + bool synchronous_flag, const pform_ident_t&out_name, + PExpr*init_expr, list*parms, list*table) { std::vector pins(parms->size() + 1); /* Make the PWire for the output port. */ - pins[0] = new PWire(out_name, loc.lexical_pos, + pins[0] = new PWire(out_name.first, out_name.second, synchronous_flag? NetNet::REG : NetNet::WIRE, NetNet::POUTPUT); FILE_NAME(pins[0], loc); /* Make the PWire objects for the input ports. */ - { list::iterator cur; + { list::iterator cur; unsigned idx; for (cur = parms->begin(), idx = 1 ; cur != parms->end() ; idx += 1, ++ cur) { ivl_assert(loc, idx < pins.size()); - pins[idx] = new PWire(*cur, loc.lexical_pos, NetNet::WIRE, + pins[idx] = new PWire(cur->first, cur->second, NetNet::WIRE, NetNet::PINPUT); FILE_NAME(pins[idx], loc); } @@ -2151,21 +2151,19 @@ static void pform_set_net_range(PWire *wire, * 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 struct vlltype&loc, perm_string name) +static void pform_make_event(const struct vlltype&loc, const pform_ident_t&name) { - PEvent*event = new PEvent(name, loc.lexical_pos); + PEvent*event = new PEvent(name.first, name.second); FILE_NAME(event, loc); - add_local_symbol(lexical_scope, name, event); - lexical_scope->events[name] = event; + add_local_symbol(lexical_scope, name.first, event); + lexical_scope->events[name.first] = event; } -void pform_make_events(const struct vlltype&loc, list*names) +void pform_make_events(const struct vlltype&loc, const list*names) { - list::iterator cur; - for (cur = names->begin() ; cur != names->end() ; ++ cur ) { - perm_string txt = *cur; - pform_make_event(loc, txt); + for (auto cur = names->begin() ; cur != names->end() ; ++ cur ) { + pform_make_event(loc, *cur); } delete names; @@ -2476,8 +2474,8 @@ void pform_make_pgassign_list(const struct vlltype&loc, * This syntax is not part of the IEEE1364-1995 standard, but is * approved by OVI as enhancement BTF-B14. */ -void pform_make_var_init(const struct vlltype&li, - perm_string name, PExpr*expr) +void pform_make_var_init(const struct vlltype&li, const pform_ident_t&name, + PExpr*expr) { if (! pform_at_module_level() && !gn_system_verilog()) { VLerror(li, "error: Variable declaration assignments are only " @@ -2486,7 +2484,7 @@ void pform_make_var_init(const struct vlltype&li, return; } - PEIdent*lval = new PEIdent(name, li.lexical_pos); + PEIdent*lval = new PEIdent(name.first, name.second); FILE_NAME(lval, li); PAssign*ass = new PAssign(lval, expr, !gn_system_verilog(), true); FILE_NAME(ass, li); @@ -2514,8 +2512,10 @@ void pform_make_var_init(const struct vlltype&li, */ -static PWire* pform_get_or_make_wire(const struct vlltype&li, perm_string name, - NetNet::Type type, NetNet::PortType ptype, +static PWire* pform_get_or_make_wire(const struct vlltype&li, + const pform_ident_t&name, + NetNet::Type type, + NetNet::PortType ptype, PWSRType rt) { PWire *cur = 0; @@ -2523,7 +2523,7 @@ static PWire* pform_get_or_make_wire(const struct vlltype&li, perm_string name, // If this is not a full declaration check if there is already a signal // with the same name that can be extended. if (rt != SR_BOTH) - cur = pform_get_wire_in_scope(name); + cur = pform_get_wire_in_scope(name.first); // If the wire already exists but isn't yet fully defined, // carry on adding details. @@ -2547,10 +2547,10 @@ static PWire* pform_get_or_make_wire(const struct vlltype&li, perm_string name, // to the scope. Do not delete the old wire - it will // remain in the local symbol map. - cur = new PWire(name, li.lexical_pos, type, ptype, rt); + cur = new PWire(name.first, name.second, type, ptype, rt); FILE_NAME(cur, li); - pform_put_wire_in_scope(name, cur); + pform_put_wire_in_scope(name.first, cur); return cur; } @@ -2567,7 +2567,7 @@ static PWire* pform_get_or_make_wire(const struct vlltype&li, perm_string name, * as is done for the old method. */ void pform_module_define_port(const struct vlltype&li, - perm_string name, + const pform_ident_t&name, NetNet::PortType port_kind, NetNet::Type type, data_type_t*vtype, @@ -2621,11 +2621,10 @@ void pform_module_define_port(const struct vlltype&li, * the variable/net. Other forms of pform_makewire ultimately call * this one to create the wire and stash it. */ -PWire *pform_makewire(const vlltype&li, perm_string name, NetNet::Type type, - std::list *indices) +PWire *pform_makewire(const vlltype&li, const pform_ident_t&name, + NetNet::Type type, std::list *indices) { - PWire*cur = pform_get_or_make_wire(li, name, type, NetNet::NOT_A_PORT, - SR_NET); + PWire*cur = pform_get_or_make_wire(li, name, type, NetNet::NOT_A_PORT, SR_NET); ivl_assert(li, cur); if (indices && !indices->empty()) @@ -2666,7 +2665,8 @@ void pform_makewire(const struct vlltype&li, if (type == NetNet::REG || type == NetNet::IMPLICIT_REG) { pform_make_var_init(li, first->name, expr); } else { - PEIdent*lval = new PEIdent(first->name, li.lexical_pos); + PEIdent*lval = new PEIdent(first->name.first, + first->name.second); FILE_NAME(lval, li); PGAssign*ass = pform_make_pgassign(lval, expr, delay, str); FILE_NAME(ass, li); @@ -2735,10 +2735,8 @@ vector*pform_make_task_ports(const struct vlltype&loc, for (list::iterator cur = ports->begin(); cur != ports->end(); ++cur) { - const perm_string &name = cur->name; - - PWire*curw = pform_get_or_make_wire(loc, name, NetNet::IMPLICIT_REG, - pt, rt); + PWire*curw = pform_get_or_make_wire(loc, cur->name, + NetNet::IMPLICIT_REG, pt, rt); if (rt == SR_BOTH) curw->set_data_type(vtype); @@ -3170,8 +3168,7 @@ void pform_set_port_type(const struct vlltype&li, ; cur != ports->end() ; ++ cur ) { PWire *wire = pform_get_or_make_wire(li, cur->name, - NetNet::IMPLICIT, pt, - SR_PORT); + NetNet::IMPLICIT, pt, SR_PORT); pform_set_net_range(wire, vt, SR_PORT, attr); if (cur->udims) { @@ -3235,15 +3232,14 @@ void pform_set_data_type(const struct vlltype&li, data_type_t*data_type, delete wires; } -vector* pform_make_udp_input_ports(list*names) +vector* pform_make_udp_input_ports(list*names) { vector*out = new vector(names->size()); unsigned idx = 0; - for (list::iterator cur = names->begin() + for (list::iterator cur = names->begin() ; cur != names->end() ; ++ cur ) { - perm_string txt = *cur; - PWire*pp = new PWire(txt, /* FIXME */ 0, + PWire*pp = new PWire(cur->first, cur->second, NetNet::IMPLICIT, NetNet::PINPUT); (*out)[idx] = pp; diff --git a/pform.h b/pform.h index bb3dabfef..f0bbd63f6 100644 --- a/pform.h +++ b/pform.h @@ -151,7 +151,7 @@ extern void pform_set_scope_timescale(const struct vlltype&loc); in an ansi style or non-ansi style declaration. In this case, we have everything needed to define the port, all in one place. */ extern void pform_module_define_port(const struct vlltype&li, - perm_string name, + const pform_ident_t&name, NetNet::PortType, NetNet::Type type, data_type_t*vtype, @@ -186,14 +186,14 @@ extern void pform_end_class_declaration(const struct vlltype&loc); extern bool pform_in_class(); extern void pform_make_udp(const struct vlltype&loc, perm_string name, - std::list*parms, + std::list*parms, std::vector*decl, std::list*table, Statement*init); extern void pform_make_udp(const struct vlltype&loc, perm_string name, - bool sync_flag, perm_string out_name, + bool sync_flag, const pform_ident_t&out_name, PExpr*sync_init, - std::list*parms, + std::list*parms, std::list*table); /* * Package related functions. @@ -272,7 +272,7 @@ extern verinum* pform_verinum_with_size(verinum*s, verinum*val, * This function takes the list of names as new genvars to declare in * the current module or generate scope. */ -extern void pform_genvars(const struct vlltype&li, std::list*names); +extern void pform_genvars(const struct vlltype&li, std::list*names); /* * This flag is set by the parser to indicate the current generate block @@ -338,7 +338,8 @@ extern PForeach* pform_make_foreach(const struct vlltype&loc, * The makewire functions announce to the pform code new wires. These * go into a module that is currently opened. */ -extern PWire *pform_makewire(const struct vlltype&li, perm_string name, +extern PWire *pform_makewire(const struct vlltype&li, + const pform_ident_t&name, NetNet::Type type, std::list *indices); @@ -360,7 +361,8 @@ extern void pform_make_var(const struct vlltype&loc, bool is_const = false); extern void pform_make_var_init(const struct vlltype&li, - perm_string name, PExpr*expr); + const pform_ident_t&name, + PExpr*expr); /* This function is used when we have an incomplete port definition in a non-ansi style declaration. Look up the names of the wires, and set @@ -460,10 +462,10 @@ extern PProcess* pform_make_behavior(ivl_process_type_t, Statement*, std::list*attr); extern void pform_mc_translate_on(bool flag); -extern std::vector* pform_make_udp_input_ports(std::list*); +extern std::vector* pform_make_udp_input_ports(std::list*); extern void pform_make_events(const struct vlltype&loc, - std::list*names); + const std::list*names); /* * The makegate function creates a new gate (which need not have a * name) and connects it to the specified wires. @@ -537,7 +539,7 @@ extern void pform_discipline_potential(const struct vlltype&loc, const char*name extern void pform_discipline_flow(const struct vlltype&loc, const char*name); extern void pform_attach_discipline(const struct vlltype&loc, - ivl_discipline_t discipline, std::list*names); + ivl_discipline_t discipline, std::list*names); extern void pform_dump(std::ostream&out, const ivl_nature_s*); extern void pform_dump(std::ostream&out, const ivl_discipline_s*); diff --git a/pform_disciplines.cc b/pform_disciplines.cc index 830222ab4..19cef6aa3 100644 --- a/pform_disciplines.cc +++ b/pform_disciplines.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2021 Stephen Williams (steve@icarus.com) + * Copyright (c) 2008-2024 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 @@ -189,12 +189,12 @@ void pform_end_discipline(const struct vlltype&loc) * in the current lexical scope. */ void pform_attach_discipline(const struct vlltype&loc, - ivl_discipline_t discipline, list*names) + ivl_discipline_t discipline, list*names) { - for (list::iterator cur = names->begin() + for (list::iterator cur = names->begin() ; cur != names->end() ; ++ cur ) { - PWire* cur_net = pform_get_wire_in_scope(*cur); + PWire* cur_net = pform_get_wire_in_scope(cur->first); if (cur_net == 0) { /* Not declared yet, declare it now. */ cur_net = pform_makewire(loc, *cur, NetNet::WIRE, 0); diff --git a/pform_dump.cc b/pform_dump.cc index 1a43caaa5..9d714c3b6 100644 --- a/pform_dump.cc +++ b/pform_dump.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998-2023 Stephen Williams (steve@icarus.com) + * Copyright (c) 1998-2024 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 @@ -374,7 +374,7 @@ void struct_member_t::pform_dump(ostream&out, unsigned indent) const for (list::iterator cur = names->begin() ; cur != names->end() ; ++cur) { decl_assignment_t*curp = *cur; - out << " " << curp->name; + out << " " << curp->name.first; } out << ";" << endl; } diff --git a/pform_pclass.cc b/pform_pclass.cc index fc3c19709..e9276a49a 100644 --- a/pform_pclass.cc +++ b/pform_pclass.cc @@ -86,12 +86,12 @@ void pform_class_property(const struct vlltype&loc, FILE_NAME(use_type, loc); } - pform_cur_class->type->properties[curp->name] + pform_cur_class->type->properties[curp->name.first] = class_type_t::prop_info_t(property_qual,use_type); - FILE_NAME(&pform_cur_class->type->properties[curp->name], loc); + FILE_NAME(&pform_cur_class->type->properties[curp->name.first], loc); if (PExpr*rval = curp->expr.release()) { - PExpr*lval = new PEIdent(curp->name, loc.lexical_pos); + PExpr*lval = new PEIdent(curp->name.first, curp->name.second); FILE_NAME(lval, loc); PAssign*tmp = new PAssign(lval, rval); FILE_NAME(tmp, loc); @@ -110,7 +110,7 @@ void pform_set_this_class(const struct vlltype&loc, PTaskFunc*net) return; list*this_name = new list; - this_name->push_back(pform_port_t(perm_string::literal(THIS_TOKEN), 0, 0)); + this_name->push_back(pform_port_t({ perm_string::literal(THIS_TOKEN), 0 }, 0, 0)); vector*this_port = pform_make_task_ports(loc, NetNet::PINPUT, pform_cur_class->type, diff --git a/pform_types.h b/pform_types.h index fb7a03f8a..c35926662 100644 --- a/pform_types.h +++ b/pform_types.h @@ -49,6 +49,12 @@ class netclass_t; class netenum_t; typedef named named_pexpr_t; +/* + * The pform_ident_t holds the identifier name and its lexical position + * (the lexical_pos supplied by the scanner). + */ +typedef std::pair pform_ident_t; + /* * The pform_range_t holds variable dimensions for type * declarations. The two expressions are interpreted as the first and @@ -89,11 +95,11 @@ struct lgate : public LineInfo { * declarations. */ struct pform_port_t { - pform_port_t(perm_string n, std::list*ud, PExpr*e) + pform_port_t(pform_ident_t n, std::list*ud, PExpr*e) : name(n), udims(ud), expr(e) { } ~pform_port_t() { } - perm_string name; + pform_ident_t name; std::list*udims; PExpr*expr; }; @@ -130,7 +136,7 @@ struct name_component_t { }; struct decl_assignment_t { - perm_string name; + pform_ident_t name; std::listindex; std::unique_ptr expr; };