Elaborate implicit chaining of constructors in class new.
This commit is contained in:
parent
9f83882bcc
commit
0157a156fb
5
PExpr.h
5
PExpr.h
|
|
@ -555,6 +555,11 @@ class PENewClass : public PExpr {
|
||||||
virtual NetExpr*elaborate_expr(Design*des, NetScope*scope,
|
virtual NetExpr*elaborate_expr(Design*des, NetScope*scope,
|
||||||
ivl_type_t type, unsigned flags) const;
|
ivl_type_t type, unsigned flags) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
NetExpr* elaborate_expr_constructor_(Design*des, NetScope*scope,
|
||||||
|
const netclass_t*ctype,
|
||||||
|
NetExpr*obj, unsigned flags) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<PExpr*>parms_;
|
std::vector<PExpr*>parms_;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
35
elab_expr.cc
35
elab_expr.cc
|
|
@ -4675,16 +4675,19 @@ unsigned PENewClass::test_width(Design*, NetScope*, width_mode_t&)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetExpr* PENewClass::elaborate_expr(Design*des, NetScope*scope,
|
/*
|
||||||
ivl_type_t ntype, unsigned) const
|
* This elaborates the constructor for a class. This arranges for the
|
||||||
|
* call of parent class constructors, if present, and also
|
||||||
|
* initializers in front of an explicit constructor.
|
||||||
|
*/
|
||||||
|
NetExpr* PENewClass::elaborate_expr_constructor_(Design*des, NetScope*scope,
|
||||||
|
const netclass_t*ctype,
|
||||||
|
NetExpr*obj, unsigned flags) const
|
||||||
{
|
{
|
||||||
NetExpr*obj = new NetENew(ntype);
|
if (const netclass_t*super_class = ctype->get_super()) {
|
||||||
obj->set_line(*this);
|
obj = elaborate_expr_constructor_(des, scope, super_class, obj, flags);
|
||||||
|
}
|
||||||
|
|
||||||
// Find the constructor for the class. If there is no
|
|
||||||
// constructor then the result of this expression is the
|
|
||||||
// allocation alone.
|
|
||||||
const netclass_t*ctype = dynamic_cast<const netclass_t*> (ntype);
|
|
||||||
|
|
||||||
// If there is an initializer function, then pass the object
|
// If there is an initializer function, then pass the object
|
||||||
// through that function first. Note tha the initializer
|
// through that function first. Note tha the initializer
|
||||||
|
|
@ -4720,6 +4723,7 @@ NetExpr* PENewClass::elaborate_expr(Design*des, NetScope*scope,
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NetFuncDef*def = new_scope->func_def();
|
NetFuncDef*def = new_scope->func_def();
|
||||||
ivl_assert(*this, def);
|
ivl_assert(*this, def);
|
||||||
|
|
||||||
|
|
@ -4786,6 +4790,21 @@ NetExpr* PENewClass::elaborate_expr(Design*des, NetScope*scope,
|
||||||
return con;
|
return con;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NetExpr* PENewClass::elaborate_expr(Design*des, NetScope*scope,
|
||||||
|
ivl_type_t ntype, unsigned flags) const
|
||||||
|
{
|
||||||
|
NetExpr*obj = new NetENew(ntype);
|
||||||
|
obj->set_line(*this);
|
||||||
|
|
||||||
|
// Find the constructor for the class. If there is no
|
||||||
|
// constructor then the result of this expression is the
|
||||||
|
// allocation alone.
|
||||||
|
const netclass_t*ctype = dynamic_cast<const netclass_t*> (ntype);
|
||||||
|
|
||||||
|
obj = elaborate_expr_constructor_(des, scope, ctype, obj, flags);
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned PENewCopy::test_width(Design*, NetScope*, width_mode_t&)
|
unsigned PENewCopy::test_width(Design*, NetScope*, width_mode_t&)
|
||||||
{
|
{
|
||||||
expr_type_ = IVL_VT_CLASS;
|
expr_type_ = IVL_VT_CLASS;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue