Parse to pform shallow copy "new" expressions.
This commit is contained in:
parent
8994ef1483
commit
eff6e7a441
9
PExpr.cc
9
PExpr.cc
|
|
@ -440,6 +440,15 @@ PENewClass::~PENewClass()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PENewCopy::PENewCopy(PExpr*src)
|
||||||
|
: src_(src)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
PENewCopy::~PENewCopy()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
PENumber::PENumber(verinum*vp)
|
PENumber::PENumber(verinum*vp)
|
||||||
: value_(vp)
|
: value_(vp)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
23
PExpr.h
23
PExpr.h
|
|
@ -488,8 +488,11 @@ class PENew : public PExpr {
|
||||||
class PENewClass : public PExpr {
|
class PENewClass : public PExpr {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
// New without (or with default) constructor
|
||||||
explicit PENewClass ();
|
explicit PENewClass ();
|
||||||
|
// New with constructor arguments
|
||||||
explicit PENewClass (const std::list<PExpr*>&p);
|
explicit PENewClass (const std::list<PExpr*>&p);
|
||||||
|
|
||||||
~PENewClass();
|
~PENewClass();
|
||||||
|
|
||||||
virtual void dump(ostream&) const;
|
virtual void dump(ostream&) const;
|
||||||
|
|
@ -507,6 +510,26 @@ class PENewClass : public PExpr {
|
||||||
std::vector<PExpr*>parms_;
|
std::vector<PExpr*>parms_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class PENewCopy : public PExpr {
|
||||||
|
public:
|
||||||
|
explicit PENewCopy(PExpr*src);
|
||||||
|
~PENewCopy();
|
||||||
|
|
||||||
|
virtual void dump(ostream&) const;
|
||||||
|
// Class objects don't have a useful width, but the expression
|
||||||
|
// is IVL_VT_CLASS.
|
||||||
|
virtual unsigned test_width(Design*des, NetScope*scope,
|
||||||
|
width_mode_t&mode);
|
||||||
|
// Note that class (new) expressions only appear in context
|
||||||
|
// that uses this form of the elaborate_expr method. In fact,
|
||||||
|
// the type argument is going to be a netclas_t object.
|
||||||
|
virtual NetExpr*elaborate_expr(Design*des, NetScope*scope,
|
||||||
|
ivl_type_t type, unsigned flags) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
PExpr*src_;
|
||||||
|
};
|
||||||
|
|
||||||
class PENull : public PExpr {
|
class PENull : public PExpr {
|
||||||
public:
|
public:
|
||||||
explicit PENull();
|
explicit PENull();
|
||||||
|
|
|
||||||
16
elab_expr.cc
16
elab_expr.cc
|
|
@ -4526,6 +4526,22 @@ NetExpr* PENewClass::elaborate_expr(Design*des, NetScope*scope,
|
||||||
return con;
|
return con;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned PENewCopy::test_width(Design*, NetScope*, width_mode_t&)
|
||||||
|
{
|
||||||
|
expr_type_ = IVL_VT_CLASS;
|
||||||
|
expr_width_ = 1;
|
||||||
|
min_width_ = 1;
|
||||||
|
signed_flag_= false;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
NetExpr* PENewCopy::elaborate_expr(Design*des, NetScope*, ivl_type_t, unsigned) const
|
||||||
|
{
|
||||||
|
cerr << get_fileline() << ": sorry: Shallow copy \"new\" not implemented." << endl;
|
||||||
|
des->errors += 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A "null" expression represents class objects/handles. This brings
|
* A "null" expression represents class objects/handles. This brings
|
||||||
* up a ton of special cases, but we handle it here bu setting the
|
* up a ton of special cases, but we handle it here bu setting the
|
||||||
|
|
|
||||||
8
parse.y
8
parse.y
|
|
@ -849,6 +849,14 @@ class_new /* IEEE1800-2005 A.2.4 */
|
||||||
delete $3;
|
delete $3;
|
||||||
$$ = tmp;
|
$$ = tmp;
|
||||||
}
|
}
|
||||||
|
| K_new hierarchy_identifier
|
||||||
|
{ PEIdent*tmpi = new PEIdent(*$2);
|
||||||
|
FILE_NAME(tmpi, @2);
|
||||||
|
PENewCopy*tmp = new PENewCopy(tmpi);
|
||||||
|
FILE_NAME(tmp, @1);
|
||||||
|
delete $2;
|
||||||
|
$$ = tmp;
|
||||||
|
}
|
||||||
| K_new
|
| K_new
|
||||||
{ PENewClass*tmp = new PENewClass;
|
{ PENewClass*tmp = new PENewClass;
|
||||||
FILE_NAME(tmp, @1);
|
FILE_NAME(tmp, @1);
|
||||||
|
|
|
||||||
|
|
@ -302,6 +302,13 @@ void PENewClass::dump(ostream&out) const
|
||||||
out << ")";
|
out << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PENewCopy::dump(ostream&out) const
|
||||||
|
{
|
||||||
|
out << "copy_new(";
|
||||||
|
src_->dump(out);
|
||||||
|
out << ")";
|
||||||
|
}
|
||||||
|
|
||||||
void PENull::dump(ostream&out) const
|
void PENull::dump(ostream&out) const
|
||||||
{
|
{
|
||||||
out << "null";
|
out << "null";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue