mirror of
https://github.com/YosysHQ/yosys
synced 2025-08-11 21:50:54 +00:00
ast: refactor
This commit is contained in:
parent
90e3579820
commit
d49546b36e
1 changed files with 8 additions and 8 deletions
|
@ -191,11 +191,11 @@ bool AstNode::get_bool_attribute(RTLIL::IdString id)
|
||||||
if (attributes.count(id) == 0)
|
if (attributes.count(id) == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
AstNode& attr = *(attributes.at(id));
|
auto& attr = attributes.at(id);
|
||||||
if (attr.type != AST_CONSTANT)
|
if (attr->type != AST_CONSTANT)
|
||||||
attr.input_error("Attribute `%s' with non-constant value!\n", id.c_str());
|
attr->input_error("Attribute `%s' with non-constant value!\n", id.c_str());
|
||||||
|
|
||||||
return attr.integer != 0;
|
return attr->integer != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create new node (AstNode constructor)
|
// create new node (AstNode constructor)
|
||||||
|
@ -1094,7 +1094,7 @@ void AST::set_src_attr(RTLIL::AttrObject *obj, const AstNode *ast)
|
||||||
obj->attributes[ID::src] = ast->loc_string();
|
obj->attributes[ID::src] = ast->loc_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool param_has_no_default(const std::unique_ptr<AstNode> ¶m) {
|
static bool param_has_no_default(const AstNode* param) {
|
||||||
const auto &children = param->children;
|
const auto &children = param->children;
|
||||||
log_assert(param->type == AST_PARAMETER);
|
log_assert(param->type == AST_PARAMETER);
|
||||||
log_assert(children.size() <= 2);
|
log_assert(children.size() <= 2);
|
||||||
|
@ -1142,7 +1142,7 @@ static RTLIL::Module *process_module(RTLIL::Design *design, AstNode *ast, bool d
|
||||||
if (!defer)
|
if (!defer)
|
||||||
{
|
{
|
||||||
for (auto& node : ast->children)
|
for (auto& node : ast->children)
|
||||||
if (node->type == AST_PARAMETER && param_has_no_default(node))
|
if (node->type == AST_PARAMETER && param_has_no_default(node.get()))
|
||||||
node->input_error("Parameter `%s' has no default value and has not been overridden!\n", node->str.c_str());
|
node->input_error("Parameter `%s' has no default value and has not been overridden!\n", node->str.c_str());
|
||||||
|
|
||||||
bool blackbox_module = flag_lib;
|
bool blackbox_module = flag_lib;
|
||||||
|
@ -1430,7 +1430,7 @@ void AST::process(RTLIL::Design *design, AstNode *ast, bool nodisplay, bool dump
|
||||||
bool defer_local = defer;
|
bool defer_local = defer;
|
||||||
if (!defer_local)
|
if (!defer_local)
|
||||||
for (const auto& node : child->children)
|
for (const auto& node : child->children)
|
||||||
if (node->type == AST_PARAMETER && param_has_no_default(node))
|
if (node->type == AST_PARAMETER && param_has_no_default(node.get()))
|
||||||
{
|
{
|
||||||
log("Deferring `%s' because it contains parameter(s) without defaults.\n", child->str.c_str());
|
log("Deferring `%s' because it contains parameter(s) without defaults.\n", child->str.c_str());
|
||||||
defer_local = true;
|
defer_local = true;
|
||||||
|
@ -1850,7 +1850,7 @@ std::string AstModule::derive_common(RTLIL::Design *design, const dict<RTLIL::Id
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
rewrite_parameter:
|
rewrite_parameter:
|
||||||
if (param_has_no_default(child))
|
if (param_has_no_default(child.get()))
|
||||||
child->children.insert(child->children.begin(), nullptr);
|
child->children.insert(child->children.begin(), nullptr);
|
||||||
if ((it->second.flags & RTLIL::CONST_FLAG_REAL) != 0) {
|
if ((it->second.flags & RTLIL::CONST_FLAG_REAL) != 0) {
|
||||||
child->children[0] = std::make_unique<AstNode>(loc, AST_REALVALUE);
|
child->children[0] = std::make_unique<AstNode>(loc, AST_REALVALUE);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue