Classes in $root scope up to elaboration.
This commit is contained in:
parent
98799ff7fa
commit
fa21527e9f
|
|
@ -416,6 +416,7 @@ static void elaborate_scope_class(Design*des, NetScope*scope, PClass*pclass)
|
||||||
|
|
||||||
netclass_t*use_base_class = 0;
|
netclass_t*use_base_class = 0;
|
||||||
if (base_class) {
|
if (base_class) {
|
||||||
|
ivl_assert(*pclass, scope);
|
||||||
use_base_class = scope->find_class(base_class->name);
|
use_base_class = scope->find_class(base_class->name);
|
||||||
if (use_base_class == 0) {
|
if (use_base_class == 0) {
|
||||||
cerr << pclass->get_fileline() << ": error: "
|
cerr << pclass->get_fileline() << ": error: "
|
||||||
|
|
@ -440,14 +441,22 @@ static void elaborate_scope_class(Design*des, NetScope*scope, PClass*pclass)
|
||||||
// elaborated class definition.
|
// elaborated class definition.
|
||||||
for (map<perm_string, class_type_t::prop_info_t>::iterator cur = use_type->properties.begin()
|
for (map<perm_string, class_type_t::prop_info_t>::iterator cur = use_type->properties.begin()
|
||||||
; cur != use_type->properties.end() ; ++ cur) {
|
; cur != use_type->properties.end() ; ++ cur) {
|
||||||
ivl_type_s*tmp = cur->second.type->elaborate_type(des, scope);
|
|
||||||
ivl_assert(*pclass, tmp);
|
if (scope) {
|
||||||
if (debug_scopes) {
|
ivl_type_s*tmp = cur->second.type->elaborate_type(des, scope);
|
||||||
cerr << pclass->get_fileline() << ": elaborate_scope_class: "
|
ivl_assert(*pclass, tmp);
|
||||||
<< " Property " << cur->first
|
if (debug_scopes) {
|
||||||
<< " type=" << *tmp << endl;
|
cerr << pclass->get_fileline() << ": elaborate_scope_class: "
|
||||||
|
<< " Property " << cur->first
|
||||||
|
<< " type=" << *tmp << endl;
|
||||||
|
}
|
||||||
|
use_class->set_property(cur->first, cur->second.qual, tmp);
|
||||||
|
} else {
|
||||||
|
cerr << pclass->get_fileline() << ": sorry: Don't know how to elaborate "
|
||||||
|
<< "property " << cur->first
|
||||||
|
<< " for class type in $root scope," << endl;
|
||||||
|
des->errors += 1;
|
||||||
}
|
}
|
||||||
use_class->set_property(cur->first, cur->second.qual, tmp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (map<perm_string,PTask*>::iterator cur = pclass->tasks.begin()
|
for (map<perm_string,PTask*>::iterator cur = pclass->tasks.begin()
|
||||||
|
|
@ -486,7 +495,14 @@ static void elaborate_scope_class(Design*des, NetScope*scope, PClass*pclass)
|
||||||
cur->second->elaborate_scope(des, method_scope);
|
cur->second->elaborate_scope(des, method_scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
scope->add_class(use_class);
|
if (scope) {
|
||||||
|
scope->add_class(use_class);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
cerr << pclass->get_fileline() << ": sorry: "
|
||||||
|
<< "Don't know how to elaborate class in $root scope." << endl;
|
||||||
|
des->errors += 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void elaborate_scope_classes(Design*des, NetScope*scope,
|
static void elaborate_scope_classes(Design*des, NetScope*scope,
|
||||||
|
|
@ -498,6 +514,18 @@ static void elaborate_scope_classes(Design*des, NetScope*scope,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void elaborate_rootscope_classes(Design*des)
|
||||||
|
{
|
||||||
|
if (pform_classes.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (map<perm_string,PClass*>::iterator cur = pform_classes.begin()
|
||||||
|
; cur != pform_classes.end() ; ++ cur) {
|
||||||
|
blend_class_constructors(cur->second);
|
||||||
|
elaborate_scope_class(des, 0, cur->second);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void replace_scope_parameters_(NetScope*scope, const LineInfo&loc,
|
static void replace_scope_parameters_(NetScope*scope, const LineInfo&loc,
|
||||||
const Module::replace_t&replacements)
|
const Module::replace_t&replacements)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -5993,6 +5993,9 @@ Design* elaborate(list<perm_string>roots)
|
||||||
// Elaborate enum sets in $root scope.
|
// Elaborate enum sets in $root scope.
|
||||||
elaborate_rootscope_enumerations(des);
|
elaborate_rootscope_enumerations(des);
|
||||||
|
|
||||||
|
// Elaborate classes in $root scope.
|
||||||
|
elaborate_rootscope_classes(des);
|
||||||
|
|
||||||
// Elaborate the packages. Package elaboration is simpler
|
// Elaborate the packages. Package elaboration is simpler
|
||||||
// because there are fewer sub-scopes involved.
|
// because there are fewer sub-scopes involved.
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
class Design;
|
class Design;
|
||||||
class Module;
|
class Module;
|
||||||
|
class PClass;
|
||||||
class PPackage;
|
class PPackage;
|
||||||
class PUdp;
|
class PUdp;
|
||||||
class data_type_t;
|
class data_type_t;
|
||||||
|
|
@ -42,11 +43,13 @@ extern std::map<perm_string,Module*> pform_modules;
|
||||||
extern std::map<perm_string,PUdp*> pform_primitives;
|
extern std::map<perm_string,PUdp*> pform_primitives;
|
||||||
extern std::map<perm_string,data_type_t*> pform_typedefs;
|
extern std::map<perm_string,data_type_t*> pform_typedefs;
|
||||||
extern std::set<enum_type_t*> pform_enum_sets;
|
extern std::set<enum_type_t*> pform_enum_sets;
|
||||||
|
extern std::map<perm_string,PClass*> pform_classes;
|
||||||
extern std::map<perm_string,PPackage*> pform_packages;
|
extern std::map<perm_string,PPackage*> pform_packages;
|
||||||
|
|
||||||
extern void pform_dump(std::ostream&out, const PPackage*pac);
|
extern void pform_dump(std::ostream&out, const PPackage*pac);
|
||||||
|
|
||||||
extern void elaborate_rootscope_enumerations(Design*des);
|
extern void elaborate_rootscope_enumerations(Design*des);
|
||||||
|
extern void elaborate_rootscope_classes(Design*des);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This code actually invokes the parser to make modules. The first
|
* This code actually invokes the parser to make modules. The first
|
||||||
|
|
|
||||||
10
pform.cc
10
pform.cc
|
|
@ -66,6 +66,11 @@ map<perm_string,PUdp*> pform_primitives;
|
||||||
map<perm_string,data_type_t*>pform_typedefs;
|
map<perm_string,data_type_t*>pform_typedefs;
|
||||||
set<enum_type_t*>pform_enum_sets;
|
set<enum_type_t*>pform_enum_sets;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class definitions in the $root scope go here.
|
||||||
|
*/
|
||||||
|
map<perm_string,PClass*> pform_classes;
|
||||||
|
|
||||||
std::string vlltype::get_fileline() const
|
std::string vlltype::get_fileline() const
|
||||||
{
|
{
|
||||||
ostringstream buf;
|
ostringstream buf;
|
||||||
|
|
@ -331,10 +336,7 @@ PClass* pform_push_class_scope(const struct vlltype&loc, perm_string name)
|
||||||
/* If no scope was found then this is being defined in the
|
/* If no scope was found then this is being defined in the
|
||||||
* compilation unit scope. */
|
* compilation unit scope. */
|
||||||
if (scopex == 0) {
|
if (scopex == 0) {
|
||||||
cerr << class_scope->get_fileline() << ": sorry: class "
|
pform_classes[name] = class_scope;
|
||||||
"declarations in the compilation unit scope are not yet "
|
|
||||||
"supported." << endl;
|
|
||||||
error_count += 1;
|
|
||||||
lexical_scope = class_scope;
|
lexical_scope = class_scope;
|
||||||
return class_scope;
|
return class_scope;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue