diff --git a/Makefile.in b/Makefile.in index fff9534e5..dd9448b03 100644 --- a/Makefile.in +++ b/Makefile.in @@ -118,9 +118,9 @@ O = main.o async.o design_dump.o discipline.o dup_expr.o elaborate.o \ pform_disciplines.o pform_dump.o pform_package.o pform_pclass.o \ pform_class_type.o pform_string_type.o pform_struct_type.o pform_types.o \ symbol_search.o sync.o sys_funcs.o verinum.o verireal.o target.o \ - Attrib.o HName.o Module.o PClass.o PDelays.o PEvent.o PExpr.o PGate.o \ - PGenerate.o PModport.o PPackage.o PScope.o PSpec.o PTask.o PUdp.o \ - PFunction.o PWire.o Statement.o AStatement.o $M $(FF) $(TT) + Attrib.o HName.o Module.o PClass.o PDelays.o PEvent.o PExpr.o PFunction.o \ + PGate.o PGenerate.o PModport.o PNamedItem.o PPackage.o PScope.o PSpec.o \ + PTask.o PUdp.o PWire.o Statement.o AStatement.o $M $(FF) $(TT) all: dep config.h _pli_types.h version_tag.h ivl@EXEEXT@ version.exe iverilog-vpi.man $(foreach dir,$(SUBDIRS),$(MAKE) -C $(dir) $@ && ) true diff --git a/Module.cc b/Module.cc index c5980637e..a7e5183bc 100644 --- a/Module.cc +++ b/Module.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998-2017 Stephen Williams (steve@icarus.com) + * Copyright (c) 1998-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 @@ -122,3 +122,13 @@ const list& Module::get_gates() const { return gates_; } + +PNamedItem::SymbolType Module::symbol_type() const +{ + if (program_block) + return PROGRAM; + if (is_interface) + return INTERFACE; + + return MODULE; +} diff --git a/Module.h b/Module.h index 411c99f9f..48c83af88 100644 --- a/Module.h +++ b/Module.h @@ -1,7 +1,7 @@ #ifndef IVL_Module_H #define IVL_Module_H /* - * Copyright (c) 1998-2017 Stephen Williams (steve@icarus.com) + * Copyright (c) 1998-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 @@ -28,7 +28,7 @@ # include "HName.h" # include "named.h" # include "PScope.h" -# include "LineInfo.h" +# include "PNamedItem.h" # include "netlist.h" # include "pform_types.h" class PExpr; @@ -54,7 +54,7 @@ class NetScope; * these containers as well. */ -class Module : public PScopeExtra, public LineInfo { +class Module : public PScopeExtra, public PNamedItem { /* The module ports are in general a vector of port_t objects. Each port has a name and an ordered list of @@ -160,6 +160,8 @@ class Module : public PScopeExtra, public LineInfo { bool elaborate_sig(Design*, NetScope*scope) const; + SymbolType symbol_type() const; + private: void dump_specparams_(ostream&out, unsigned indent) const; list gates_; diff --git a/PClass.cc b/PClass.cc index ba44d754a..0964e4951 100644 --- a/PClass.cc +++ b/PClass.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012 Stephen Williams (steve@icarus.com) + * Copyright (c) 2012-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 @@ -28,3 +28,8 @@ PClass::PClass(perm_string name, LexicalScope*parent) PClass::~PClass() { } + +PNamedItem::SymbolType PClass::symbol_type() const +{ + return CLASS; +} diff --git a/PClass.h b/PClass.h index e5dc1d8a2..55a3b7048 100644 --- a/PClass.h +++ b/PClass.h @@ -1,7 +1,7 @@ #ifndef IVL_PClass_H #define IVL_PClass_H /* - * Copyright (c) 2012-2014 Stephen Williams (steve@icarus.com) + * Copyright (c) 2012-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 @@ -20,7 +20,7 @@ */ # include "PScope.h" -# include "LineInfo.h" +# include "PNamedItem.h" # include "StringHeap.h" # include @@ -32,7 +32,7 @@ class PChainConstructor; * collected. */ -class PClass : public PScopeExtra, public LineInfo { +class PClass : public PScopeExtra, public PNamedItem { public: explicit PClass (perm_string name, LexicalScope*parent); @@ -40,6 +40,8 @@ class PClass : public PScopeExtra, public LineInfo { void dump(std::ostream&out, unsigned indent) const; + SymbolType symbol_type() const; + public: class_type_t*type; }; diff --git a/PEvent.cc b/PEvent.cc index 0f2426404..9bf56ea5b 100644 --- a/PEvent.cc +++ b/PEvent.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004 Stephen Williams (steve@icarus.com) + * Copyright (c) 2004-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 @@ -35,3 +35,7 @@ perm_string PEvent::name() const return name_; } +PNamedItem::SymbolType PEvent::symbol_type() const +{ + return EVENT; +} diff --git a/PEvent.h b/PEvent.h index 11836d295..ba5bb668b 100644 --- a/PEvent.h +++ b/PEvent.h @@ -1,7 +1,7 @@ #ifndef IVL_PEvent_H #define IVL_PEvent_H /* - * Copyright (c) 2000-2014 Stephen Williams (steve@icarus.com) + * Copyright (c) 2000-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 @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -# include "LineInfo.h" +# include "PNamedItem.h" # include "StringHeap.h" # include @@ -31,7 +31,7 @@ class NetScope; * are declared in Verilog as ``event foo;'' The name passed to the * constructor is the "foo" part of the declaration. */ -class PEvent : public LineInfo { +class PEvent : public PNamedItem { public: // The name is a perm-allocated string. It is the simple name @@ -43,6 +43,8 @@ class PEvent : public LineInfo { void elaborate_scope(Design*des, NetScope*scope) const; + SymbolType symbol_type() const; + private: perm_string name_; diff --git a/PFunction.cc b/PFunction.cc index a5dc8f351..215cc5170 100644 --- a/PFunction.cc +++ b/PFunction.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999-2013 Stephen Williams (steve@icarus.com) + * Copyright (c) 1999-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 @@ -83,3 +83,8 @@ PChainConstructor* PFunction::extract_chain_constructor() return res; } + +PNamedItem::SymbolType PFunction::symbol_type() const +{ + return FUNCTION; +} diff --git a/PGate.cc b/PGate.cc index 56fd7578c..0429b4690 100644 --- a/PGate.cc +++ b/PGate.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999-2013 Stephen Williams (steve@icarus.com) + * Copyright (c) 1999-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 @@ -117,6 +117,11 @@ unsigned PGate::delay_count() const return delay_.delay_count(); } +PNamedItem::SymbolType PGate::symbol_type() const +{ + return INSTANCE; +} + PGAssign::PGAssign(list*pins) : PGate(perm_string(), pins) { diff --git a/PGate.h b/PGate.h index ee6f10f79..1f5ce5752 100644 --- a/PGate.h +++ b/PGate.h @@ -1,7 +1,7 @@ #ifndef IVL_PGate_H #define IVL_PGate_H /* - * Copyright (c) 1998-2014 Stephen Williams (steve@icarus.com) + * Copyright (c) 1998-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 @@ -22,7 +22,7 @@ # include "svector.h" # include "StringHeap.h" # include "named.h" -# include "LineInfo.h" +# include "PNamedItem.h" # include "PDelays.h" # include "netlist.h" # include @@ -47,7 +47,7 @@ class Module; * single strength pair. There is a strength of the 0 drive, and a * strength of the 1 drive. */ -class PGate : public LineInfo { +class PGate : public PNamedItem { public: explicit PGate(perm_string name, list*pins, @@ -88,6 +88,8 @@ class PGate : public LineInfo { virtual void elaborate_scope(Design*des, NetScope*sc) const; virtual bool elaborate_sig(Design*des, NetScope*scope) const; + SymbolType symbol_type() const; + protected: const vector& get_pins() const { return pins_; } diff --git a/PGenerate.cc b/PGenerate.cc index 5e99f1a6e..919b74f87 100644 --- a/PGenerate.cc +++ b/PGenerate.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2011 Stephen Williams (steve@icarus.com) + * Copyright (c) 2006-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 @@ -112,3 +112,8 @@ ostream& operator << (ostream&out, PGenerate::scheme_t type) } return out; } + +PNamedItem::SymbolType PGenerate::symbol_type() const +{ + return GENBLOCK; +} diff --git a/PGenerate.h b/PGenerate.h index 45a37e13d..c08f9cb8b 100644 --- a/PGenerate.h +++ b/PGenerate.h @@ -1,7 +1,7 @@ #ifndef IVL_PGenerate_H #define IVL_PGenerate_H /* - * Copyright (c) 2006-2014 Stephen Williams (steve@icarus.com) + * Copyright (c) 2006-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 @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -# include "LineInfo.h" +# include "PNamedItem.h" # include "StringHeap.h" # include "HName.h" # include "PScope.h" @@ -50,7 +50,7 @@ class PWire; * The parent points to the GS_CASE that contains this item. * the loop_test is compared with the parent->loop_test expression. */ -class PGenerate : public LineInfo, public LexicalScope { +class PGenerate : public PNamedItem, public LexicalScope { public: explicit PGenerate(LexicalScope*parent, unsigned id_number); @@ -107,6 +107,8 @@ class PGenerate : public LineInfo, public LexicalScope { void dump(ostream&out, unsigned indent) const; + SymbolType symbol_type() const; + private: bool generate_scope_loop_(Design*des, NetScope*container); bool generate_scope_condit_(Design*des, NetScope*container, bool else_flag); diff --git a/PModport.cc b/PModport.cc index 8ce774088..969a49c09 100644 --- a/PModport.cc +++ b/PModport.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Stephen Williams (steve@icarus.com) + * Copyright (c) 2015-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 @@ -29,3 +29,8 @@ PModport::PModport(perm_string n) PModport::~PModport() { } + +PNamedItem::SymbolType PModport::symbol_type() const +{ + return MODPORT; +} diff --git a/PModport.h b/PModport.h index 339154784..417d0b523 100644 --- a/PModport.h +++ b/PModport.h @@ -1,7 +1,7 @@ #ifndef IVL_PModport_H #define IVL_PModport_H /* - * Copyright (c) 2015 Stephen Williams (steve@icarus.com) + * Copyright (c) 2015-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 @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -# include "LineInfo.h" +# include "PNamedItem.h" # include "PScope.h" # include "StringHeap.h" # include "netlist.h" @@ -28,7 +28,7 @@ /* * The PModport class represents a parsed SystemVerilog modport list. */ -class PModport : public LineInfo { +class PModport : public PNamedItem { public: // The name is a perm-allocated string. It is the simple name @@ -41,6 +41,8 @@ class PModport : public LineInfo { typedef pair simple_port_t; map simple_ports; + SymbolType symbol_type() const; + private: perm_string name_; diff --git a/PNamedItem.cc b/PNamedItem.cc new file mode 100644 index 000000000..70c33a7ca --- /dev/null +++ b/PNamedItem.cc @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2019 Martin Whitaker (icarus@martin-whitaker.me.uk) + * + * This source code is free software; you can redistribute it + * and/or modify it in source code form under the terms of the GNU + * General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +# include "PNamedItem.h" +# include + +PNamedItem::PNamedItem() +{ +} + +PNamedItem::~PNamedItem() +{ +} + +PNamedItem::SymbolType PNamedItem::symbol_type() const +{ + return ANY; +} + +std::ostream& operator << (std::ostream&o, PNamedItem::SymbolType st) +{ + switch (st) { + case PNamedItem::ANY: + o << "a symbol"; + break; + case PNamedItem::PARAM: + o << "a parameter"; + break; + case PNamedItem::NET: + o << "a net"; + break; + case PNamedItem::VAR: + o << "a variable"; + break; + case PNamedItem::GENVAR: + o << "a genvar"; + break; + case PNamedItem::EVENT: + o << "an event"; + break; + case PNamedItem::TYPE: + o << "a type"; + break; + case PNamedItem::ENUM: + o << "an enum type or value"; + break; + case PNamedItem::CLASS: + o << "a class"; + break; + case PNamedItem::FUNCTION: + o << "a function"; + break; + case PNamedItem::TASK: + o << "a task"; + break; + case PNamedItem::BLOCK: + o << "a named block"; + break; + case PNamedItem::GENBLOCK: + o << "a generate block"; + break; + case PNamedItem::MODPORT: + o << "a modport"; + break; + case PNamedItem::PACKAGE: + o << "a package"; + break; + case PNamedItem::MODULE: + o << "a module"; + break; + case PNamedItem::PROGRAM: + o << "a program"; + break; + case PNamedItem::INTERFACE: + o << "an interface"; + break; + case PNamedItem::PRIMITIVE: + o << "a primitive"; + break; + case PNamedItem::INSTANCE: + o << "an instance name"; + break; + default: + break; + } + return o; +} + +PGenvar::PGenvar() +{ +} + +PGenvar::~PGenvar() +{ +} + +PNamedItem::SymbolType PGenvar::symbol_type() const +{ + return GENVAR; +} diff --git a/PNamedItem.h b/PNamedItem.h new file mode 100644 index 000000000..0b6e791ea --- /dev/null +++ b/PNamedItem.h @@ -0,0 +1,57 @@ +#ifndef IVL_PNamedItem_H +#define IVL_PNamedItem_H +/* + * Copyright (c) 2019 Martin Whitaker (icarus@martin-whitaker.me.uk) + * + * This source code is free software; you can redistribute it + * and/or modify it in source code form under the terms of the GNU + * General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +# include "LineInfo.h" + +/* + * The PNamedItem class is the base class for all items that can be added + * to a scope's local symbol map. + */ +class PNamedItem : virtual public LineInfo { + + public: + enum SymbolType { ANY, PARAM, NET, VAR, GENVAR, EVENT, TYPE, ENUM, + CLASS, FUNCTION, TASK, BLOCK, GENBLOCK, MODPORT, + PACKAGE, MODULE, PROGRAM, INTERFACE, PRIMITIVE, + INSTANCE }; + + explicit PNamedItem(); + virtual ~PNamedItem(); + + virtual SymbolType symbol_type() const; +}; + +extern std::ostream& operator << (std::ostream&, PNamedItem::SymbolType); + +/* + * The PGenvar class represents a genvar. This is only used to represent + * genvar in a scope's local symbol map. + */ +class PGenvar : public PNamedItem { + + public: + explicit PGenvar(); + virtual ~PGenvar(); + + SymbolType symbol_type() const; +}; + +#endif /* IVL_PNamedItem_H */ diff --git a/PScope.cc b/PScope.cc index c0738cc29..787dbf88d 100644 --- a/PScope.cc +++ b/PScope.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2017 Stephen Williams (steve@icarus.com) + * Copyright (c) 2008-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 @@ -33,6 +33,11 @@ PWire* LexicalScope::wires_find(perm_string name) return (*cur).second; } +PNamedItem::SymbolType LexicalScope::param_expr_t::symbol_type() const +{ + return PARAM; +} + PScope::PScope(perm_string n, LexicalScope*parent) : LexicalScope(parent), name_(n) { diff --git a/PScope.h b/PScope.h index 24674d6df..9f339a5b2 100644 --- a/PScope.h +++ b/PScope.h @@ -1,7 +1,7 @@ #ifndef IVL_PScope_H #define IVL_PScope_H /* - * Copyright (c) 2008-2017 Stephen Williams (steve@icarus.com) + * Copyright (c) 2008-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 @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -# include "LineInfo.h" +# include "PNamedItem.h" # include "StringHeap.h" # include "pform_types.h" # include "ivl_target.h" @@ -79,7 +79,7 @@ class LexicalScope { /* The scope has parameters that are evaluated when the scope is elaborated. During parsing, I put the parameters into this map. */ - struct param_expr_t : public LineInfo { + struct param_expr_t : public PNamedItem { param_expr_t() : type(IVL_VT_NO_TYPE), msb(0), lsb(0), signed_flag(false), expr(0), range(0) { } // Type information ivl_variable_type_t type; @@ -90,6 +90,8 @@ class LexicalScope { PExpr*expr; // If there are range constraints, list them here range_t*range; + + SymbolType symbol_type() const; }; mapparameters; maplocalparams; diff --git a/PTask.cc b/PTask.cc index 93f8ba10f..bb008ad23 100644 --- a/PTask.cc +++ b/PTask.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999-2008,2010 Stephen Williams (steve@icarus.com) + * Copyright (c) 1999-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 @@ -73,3 +73,8 @@ void PTask::set_statement(Statement*s) assert(statement_ == 0); statement_ = s; } + +PNamedItem::SymbolType PTask::symbol_type() const +{ + return TASK; +} diff --git a/PTask.h b/PTask.h index 4c1899d04..1d328ed6c 100644 --- a/PTask.h +++ b/PTask.h @@ -1,7 +1,7 @@ #ifndef IVL_PTask_H #define IVL_PTask_H /* - * Copyright (c) 1999-2014 Stephen Williams (steve@icarus.com) + * Copyright (c) 1999-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 @@ -19,8 +19,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -# include "LineInfo.h" # include "PScope.h" +# include "PNamedItem.h" # include "StringHeap.h" # include # include @@ -35,7 +35,7 @@ class Statement; class PExpr; -class PTaskFunc : public PScope, public LineInfo { +class PTaskFunc : public PScope, public PNamedItem { public: PTaskFunc(perm_string name, LexicalScope*parent); @@ -99,6 +99,8 @@ class PTask : public PTaskFunc { void dump(ostream&, unsigned) const; + SymbolType symbol_type() const; + private: Statement*statement_; bool is_auto_; @@ -148,6 +150,8 @@ class PFunction : public PTaskFunc { void dump(ostream&, unsigned) const; + SymbolType symbol_type() const; + private: data_type_t* return_type_; Statement *statement_; diff --git a/PWire.cc b/PWire.cc index 79db562eb..524f18b44 100644 --- a/PWire.cc +++ b/PWire.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999-2012 Stephen Williams (steve@icarus.com) + * Copyright (c) 1999-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 @@ -283,3 +283,15 @@ ivl_discipline_t PWire::get_discipline(void) const { return discipline_; } + +PNamedItem::SymbolType PWire::symbol_type() const +{ + switch (type_) { + case NetNet::IMPLICIT_REG: + case NetNet::INTEGER: + case NetNet::REG: + return VAR; + default: + return NET; + } +} diff --git a/PWire.h b/PWire.h index d003d445b..a588797f8 100644 --- a/PWire.h +++ b/PWire.h @@ -1,7 +1,7 @@ #ifndef IVL_PWire_H #define IVL_PWire_H /* - * Copyright (c) 1998-2014 Stephen Williams (steve@icarus.com) + * Copyright (c) 1998-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 @@ -20,7 +20,7 @@ */ # include "netlist.h" -# include "LineInfo.h" +# include "PNamedItem.h" # include # include # include "StringHeap.h" @@ -51,7 +51,7 @@ enum PWSRType {SR_PORT, SR_NET, SR_BOTH}; * from that perspective, sub-scopes within the module are a part of * the wire name. */ -class PWire : public LineInfo { +class PWire : public PNamedItem { public: PWire(perm_string name, @@ -93,6 +93,8 @@ class PWire : public LineInfo { NetNet* elaborate_sig(Design*, NetScope*scope) const; + SymbolType symbol_type() const; + private: perm_string name_; NetNet::Type type_; diff --git a/Statement.cc b/Statement.cc index 92a87a12d..696ef44bd 100644 --- a/Statement.cc +++ b/Statement.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998-2017 Stephen Williams (steve@icarus.com) + * Copyright (c) 1998-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 @@ -158,6 +158,11 @@ void PBlock::push_statement_front(Statement*that) list_[0] = that; } +PNamedItem::SymbolType PBlock::symbol_type() const +{ + return BLOCK; +} + PCallTask::PCallTask(const pform_name_t&n, const list&p) : package_(0), path_(n), parms_(p.size()) { diff --git a/Statement.h b/Statement.h index 30f3b8229..91ed3828d 100644 --- a/Statement.h +++ b/Statement.h @@ -1,7 +1,7 @@ #ifndef IVL_Statement_H #define IVL_Statement_H /* - * Copyright (c) 1998-2017 Stephen Williams (steve@icarus.com) + * Copyright (c) 1998-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 @@ -75,7 +75,7 @@ class PProcess : public LineInfo { * fact, the Statement class is abstract and represents all the * possible kinds of statements that exist in Verilog. */ -class Statement : public LineInfo { +class Statement : virtual public LineInfo { public: Statement() { } @@ -170,7 +170,7 @@ class PAssignNB : public PAssign_ { * statements before constructing this object, so it knows a priori * what is contained. */ -class PBlock : public PScope, public Statement { +class PBlock : public PScope, public Statement, public PNamedItem { public: enum BL_TYPE { BL_SEQ, BL_PAR, BL_JOIN_NONE, BL_JOIN_ANY }; @@ -205,6 +205,8 @@ class PBlock : public PScope, public Statement { virtual void elaborate_scope(Design*des, NetScope*scope) const; virtual void elaborate_sig(Design*des, NetScope*scope) const; + SymbolType symbol_type() const; + private: BL_TYPE bl_type_; std::vectorlist_; diff --git a/pform_types.cc b/pform_types.cc index 8d8d430d0..72f312619 100644 --- a/pform_types.cc +++ b/pform_types.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2008 Stephen Williams (steve@icarus.com) + * Copyright (c) 2007-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 @@ -24,6 +24,11 @@ data_type_t::~data_type_t() { } +PNamedItem::SymbolType data_type_t::symbol_type() const +{ + return TYPE; +} + string_type_t::~string_type_t() { } @@ -44,3 +49,13 @@ ivl_variable_type_t vector_type_t::figure_packed_base_type(void) const } atom2_type_t size_type (32, true); + +PNamedItem::SymbolType enum_type_t::symbol_type() const +{ + return ENUM; +} + +PNamedItem::SymbolType class_type_t::symbol_type() const +{ + return CLASS; +} diff --git a/pform_types.h b/pform_types.h index 92061527e..a7aaaad13 100644 --- a/pform_types.h +++ b/pform_types.h @@ -1,7 +1,7 @@ #ifndef IVL_pform_types_H #define IVL_pform_types_H /* - * Copyright (c) 2007-2018 Stephen Williams (steve@icarus.com) + * Copyright (c) 2007-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 @@ -21,7 +21,7 @@ // This for the perm_string type. # include "StringHeap.h" -# include "LineInfo.h" +# include "PNamedItem.h" # include "verinum.h" # include "named.h" # include "netstruct.h" @@ -137,7 +137,7 @@ struct pform_tf_port_t { * "data_type" rule in the parse rule. We make the type virtual so * that dynamic types will work. */ -class data_type_t : public LineInfo { +class data_type_t : public PNamedItem { public: inline explicit data_type_t() { } virtual ~data_type_t() = 0; @@ -149,6 +149,8 @@ class data_type_t : public LineInfo { ivl_type_s* elaborate_type(Design*des, NetScope*scope); + virtual SymbolType symbol_type() const; + private: // Elaborate the type to an ivl_type_s type. virtual ivl_type_s* elaborate_type_raw(Design*des, NetScope*scope) const; @@ -171,6 +173,8 @@ struct enum_type_t : public data_type_t { // Return the elaborated version of the type. virtual ivl_type_s*elaborate_type_raw(Design*des, NetScope*scope) const; + SymbolType symbol_type() const; + ivl_variable_type_t base_type; bool signed_flag; bool integer_flag; // True if "integer" was used @@ -335,6 +339,8 @@ struct class_type_t : public data_type_t { // type. The elaborate_type_raw() method uses this pointer, // and it is used in some other situations as well. netclass_t* save_elaborated_type; + + virtual SymbolType symbol_type() const; }; /*