diff options
author | Clifford Wolf <clifford@clifford.at> | 2013-10-24 11:20:13 +0200 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2013-10-24 11:20:13 +0200 |
commit | 23cf23418cd28b98c11a1ed3fb45dbb927f48e65 (patch) | |
tree | 27042b15ed64cb2a438c97b4eaeb23a681cffa0d /frontends/ast/ast.cc | |
parent | eae43e2db430c951018b5cb70f047de84ad010b0 (diff) | |
download | yosys-23cf23418cd28b98c11a1ed3fb45dbb927f48e65.tar.gz yosys-23cf23418cd28b98c11a1ed3fb45dbb927f48e65.tar.bz2 yosys-23cf23418cd28b98c11a1ed3fb45dbb927f48e65.zip |
Fixed handling of boolean attributes (frontends)
Diffstat (limited to 'frontends/ast/ast.cc')
-rw-r--r-- | frontends/ast/ast.cc | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/frontends/ast/ast.cc b/frontends/ast/ast.cc index f589f0c17..df30c6d95 100644 --- a/frontends/ast/ast.cc +++ b/frontends/ast/ast.cc @@ -145,6 +145,20 @@ std::string AST::type2str(AstNodeType type) } } +// check if attribute exists and has non-zero value +bool AstNode::get_bool_attribute(RTLIL::IdString id) +{ + if (attributes.count(id) == 0) + return false; + + AstNode *attr = attributes.at(id); + if (attr->type != AST_CONSTANT) + log_error("Attribute `%s' with non-constant value at %s:%d!\n", + id.c_str(), attr->filename.c_str(), attr->linenum); + + return attr->integer != 0; +} + // create new node (AstNode constructor) // (the optional child arguments make it easier to create AST trees) AstNode::AstNode(AstNodeType type, AstNode *child1, AstNode *child2) @@ -670,7 +684,7 @@ static AstModule* process_module(AstNode *ast) delete child; } ast->children.swap(new_children); - ast->attributes["\\placeholder"] = AstNode::mkconst_int(0, false, 0); + ast->attributes["\\placeholder"] = AstNode::mkconst_int(1, false); } current_module = new AstModule; |