Class new expressions, down to the ivl_target.h API.

This commit is contained in:
Stephen Williams 2012-11-17 09:20:13 -08:00
parent 3e7adbeda0
commit 7a2ad01f2e
13 changed files with 85 additions and 2 deletions

View File

@ -1509,6 +1509,11 @@ void NetENetenum::dump(ostream&o) const
o << "<netenum=" << netenum_ << ">";
}
void NetENew::dump(ostream&o) const
{
o << "new <type>";
}
void NetENull::dump(ostream&o) const
{
o << "<null>";

View File

@ -177,6 +177,12 @@ NetENetenum* NetENetenum::dup_expr() const
return 0;
}
NetENew* NetENew::dup_expr() const
{
ivl_assert(*this, 0);
return 0;
}
NetENull* NetENull::dup_expr() const
{
ivl_assert(*this, 0);

View File

@ -4041,7 +4041,7 @@ unsigned PENewClass::test_width(Design*, NetScope*, width_mode_t&)
NetExpr* PENewClass::elaborate_expr(Design*, NetScope*,
ivl_type_t ntype, unsigned) const
{
NetESFunc*tmp = new NetESFunc("$ivl_class_method$new", ntype, 0);
NetENew*tmp = new NetENew(ntype);
tmp->set_line(*this);
return tmp;
}

View File

@ -551,6 +551,11 @@ void NetENetenum::expr_scan(struct expr_scan_t*tgt) const
tgt->expr_netenum(this);
}
void NetENew::expr_scan(struct expr_scan_t*tgt) const
{
tgt->expr_new(this);
}
void NetENull::expr_scan(struct expr_scan_t*tgt) const
{
tgt->expr_null(this);

View File

@ -224,6 +224,7 @@ typedef enum ivl_expr_type_e {
IVL_EX_ENUMTYPE = 21,
IVL_EX_EVENT = 17,
IVL_EX_MEMORY = 4,
IVL_EX_NEW = 23,
IVL_EX_NULL = 22,
IVL_EX_NUMBER = 5,
IVL_EX_REALNUM = 16,

View File

@ -321,6 +321,15 @@ netenum_t* NetENetenum::netenum() const
return netenum_;
}
NetENew::NetENew(ivl_type_t t)
: obj_type_(t)
{
}
NetENew::~NetENew()
{
}
NetENull::NetENull()
{
}

View File

@ -96,6 +96,11 @@ NexusSet* NetENetenum::nex_input(bool)
return new NexusSet;
}
NexusSet* NetENew::nex_input(bool)
{
return new NexusSet;
}
NexusSet* NetENull::nex_input(bool)
{
return new NexusSet;

View File

@ -3877,6 +3877,23 @@ class NetENetenum : public NetExpr {
netenum_t*netenum_;
};
class NetENew : public NetExpr {
public:
explicit NetENew(ivl_type_t);
~NetENew();
inline ivl_type_t get_type() const { return obj_type_; }
virtual void expr_scan(struct expr_scan_t*) const;
virtual NetENew* dup_expr() const;
virtual NexusSet* nex_input(bool rem_out = true);
virtual void dump(ostream&os) const;
private:
ivl_type_t obj_type_;
};
/*
* The NetENull node represents the SystemVerilog (null)
* expression. This is always a null class handle.

View File

@ -316,6 +316,19 @@ void dll_target::expr_creal(const NetECReal*net)
expr_->u_.real_.value = net->value().as_double();
}
void dll_target::expr_new(const NetENew*net)
{
assert(expr_ == 0);
expr_ = (ivl_expr_t)calloc(1, sizeof(struct ivl_expr_s));
expr_->width_ = net->expr_width();
expr_->signed_ = 0;
expr_->sized_ = 1;
expr_->type_ = IVL_EX_NEW;
FILE_NAME(expr_, net);
expr_->value_ = IVL_VT_CLASS;
expr_->net_type= net->get_type();
}
void dll_target::expr_null(const NetENull*net)
{
assert(expr_ == 0);
@ -328,7 +341,7 @@ void dll_target::expr_null(const NetENull*net)
expr_->value_ = IVL_VT_CLASS;
expr_->net_type= 0;
}
void dll_target::expr_event(const NetEEvent*net)
{
assert(expr_ == 0);

View File

@ -137,6 +137,7 @@ struct dll_target : public target_t, public expr_scan_t {
void expr_concat(const NetEConcat*);
void expr_const(const NetEConst*);
void expr_creal(const NetECReal*);
void expr_new(const NetENew*);
void expr_null(const NetENull*);
void expr_param(const NetEConstParam*);
void expr_rparam(const NetECRealParam*);

View File

@ -444,6 +444,12 @@ void expr_scan_t::expr_const(const NetEConst*)
"unhandled expr_const." << endl;
}
void expr_scan_t::expr_new(const NetENew*)
{
cerr << "expr_scan_t (" << typeid(*this).name() << "): "
"unhandled expr_new." << endl;
}
void expr_scan_t::expr_null(const NetENull*)
{
cerr << "expr_scan_t (" << typeid(*this).name() << "): "

View File

@ -150,6 +150,7 @@ struct expr_scan_t {
virtual ~expr_scan_t();
virtual void expr_access_func(const NetEAccess*);
virtual void expr_const(const NetEConst*);
virtual void expr_new(const NetENew*);
virtual void expr_null(const NetENull*);
virtual void expr_param(const NetEConstParam*);
virtual void expr_rparam(const NetECRealParam*);

View File

@ -165,6 +165,16 @@ static void show_memory_expression(ivl_expr_t net, unsigned ind)
width);
}
static void show_new_expression(ivl_expr_t net, unsigned ind)
{
fprintf(out, "%*snew <type>\n", ind, "");
if (ivl_expr_value(net) != IVL_VT_CLASS) {
fprintf(out, "%sERROR: new expression must be IVL_VT_CLASS, got %s.\n",
ind+3, "", vt_type_string(net));
stub_errors += 1;
}
}
static void show_null_expression(ivl_expr_t net, unsigned ind)
{
fprintf(out, "%*s<null>\n", ind, "");
@ -361,6 +371,10 @@ void show_expression(ivl_expr_t net, unsigned ind)
show_memory_expression(net, ind);
break;
case IVL_EX_NEW:
show_new_expression(net, ind);
break;
case IVL_EX_NULL:
show_null_expression(net, ind);
break;