Collect initializer statements in the pform.
This commit is contained in:
parent
633360a0f9
commit
d346fb098f
|
|
@ -304,6 +304,12 @@ static void elaborate_scope_class(Design*des, NetScope*scope,
|
||||||
<< "Elaborate scope class " << pclass->pscope_name() << endl;
|
<< "Elaborate scope class " << pclass->pscope_name() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! use_type->initialize.empty()) {
|
||||||
|
cerr << pclass->get_fileline() << ": sorry: "
|
||||||
|
<< "Class property initializers not supported." << endl;
|
||||||
|
des->errors += 1;
|
||||||
|
}
|
||||||
|
|
||||||
// Class scopes have no parent scope, because references are
|
// Class scopes have no parent scope, because references are
|
||||||
// not allowed to escape a class method.
|
// not allowed to escape a class method.
|
||||||
NetScope*class_scope = new NetScope(0, hname_t(pclass->pscope_name()),
|
NetScope*class_scope = new NetScope(0, hname_t(pclass->pscope_name()),
|
||||||
|
|
|
||||||
|
|
@ -181,9 +181,19 @@ void class_type_t::pform_dump(ostream&out, unsigned indent) const
|
||||||
; cur != properties.end() ; ++cur) {
|
; cur != properties.end() ; ++cur) {
|
||||||
out << " " << cur->first;
|
out << " " << cur->first;
|
||||||
}
|
}
|
||||||
|
|
||||||
out << " }" << endl;
|
out << " }" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void class_type_t::pform_dump_init(ostream&out, unsigned indent) const
|
||||||
|
{
|
||||||
|
for (vector<Statement*>::const_iterator cur = initialize.begin()
|
||||||
|
; cur != initialize.end() ; ++cur) {
|
||||||
|
Statement*curp = *cur;
|
||||||
|
curp->dump(out,indent+4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void struct_member_t::pform_dump(ostream&out, unsigned indent) const
|
void struct_member_t::pform_dump(ostream&out, unsigned indent) const
|
||||||
{
|
{
|
||||||
out << setw(indent) << "" << type;
|
out << setw(indent) << "" << type;
|
||||||
|
|
@ -1315,6 +1325,7 @@ void PClass::dump(ostream&out, unsigned indent) const
|
||||||
{
|
{
|
||||||
out << setw(indent) << "" << "class " << type->name << ";" << endl;
|
out << setw(indent) << "" << "class " << type->name << ";" << endl;
|
||||||
type->pform_dump(out, indent+2);
|
type->pform_dump(out, indent+2);
|
||||||
|
type->pform_dump_init(out, indent+2);
|
||||||
dump_tasks_(out, indent+2);
|
dump_tasks_(out, indent+2);
|
||||||
dump_funcs_(out, indent+2);
|
dump_funcs_(out, indent+2);
|
||||||
out << setw(indent) << "" << "endclass" << endl;
|
out << setw(indent) << "" << "endclass" << endl;
|
||||||
|
|
|
||||||
|
|
@ -64,11 +64,15 @@ void pform_class_property(const struct vlltype&loc,
|
||||||
use_type = new uarray_type_t(use_type, pd);
|
use_type = new uarray_type_t(use_type, pd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (curp->expr.get()) {
|
|
||||||
VLerror(loc, "sorry: Initialization expressions for properties not implemented.");
|
|
||||||
}
|
|
||||||
|
|
||||||
pform_cur_class->type->properties[curp->name] = use_type;
|
pform_cur_class->type->properties[curp->name] = use_type;
|
||||||
|
|
||||||
|
if (PExpr*rval = curp->expr.release()) {
|
||||||
|
PExpr*lval = new PEIdent(curp->name);
|
||||||
|
FILE_NAME(lval, loc);
|
||||||
|
PAssign*tmp = new PAssign(lval, rval);
|
||||||
|
FILE_NAME(tmp, loc);
|
||||||
|
pform_cur_class->type->initialize.push_back(tmp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@
|
||||||
# include "ivl_target.h"
|
# include "ivl_target.h"
|
||||||
# include <iostream>
|
# include <iostream>
|
||||||
# include <list>
|
# include <list>
|
||||||
|
# include <vector>
|
||||||
# include <map>
|
# include <map>
|
||||||
# include <memory>
|
# include <memory>
|
||||||
|
|
||||||
|
|
@ -37,6 +38,7 @@
|
||||||
class Design;
|
class Design;
|
||||||
class NetScope;
|
class NetScope;
|
||||||
class PExpr;
|
class PExpr;
|
||||||
|
class Statement;
|
||||||
class ivl_type_s;
|
class ivl_type_s;
|
||||||
typedef named<verinum> named_number_t;
|
typedef named<verinum> named_number_t;
|
||||||
typedef named<PExpr*> named_pexpr_t;
|
typedef named<PExpr*> named_pexpr_t;
|
||||||
|
|
@ -212,10 +214,18 @@ struct class_type_t : public data_type_t {
|
||||||
: name(n) { }
|
: name(n) { }
|
||||||
|
|
||||||
void pform_dump(std::ostream&out, unsigned indent) const;
|
void pform_dump(std::ostream&out, unsigned indent) const;
|
||||||
|
void pform_dump_init(std::ostream&out, unsigned indent) const;
|
||||||
|
|
||||||
|
// This is the name of the class type.
|
||||||
perm_string name;
|
perm_string name;
|
||||||
|
// This is a map of the properties. Map the name to the type.
|
||||||
std::map<perm_string, data_type_t*> properties;
|
std::map<perm_string, data_type_t*> properties;
|
||||||
|
|
||||||
|
// This is an ordered list of property initializers. The name
|
||||||
|
// is the name of the property to be assigned, and the val is
|
||||||
|
// the expression that is assigned.
|
||||||
|
std::vector<Statement*> initialize;
|
||||||
|
|
||||||
ivl_type_s* elaborate_type(Design*, NetScope*) const;
|
ivl_type_s* elaborate_type(Design*, NetScope*) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue