summaryrefslogtreecommitdiff
path: root/frontends/ast/ast.cc
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2013-10-24 11:20:13 +0200
committerClifford Wolf <clifford@clifford.at>2013-10-24 11:20:13 +0200
commit23cf23418cd28b98c11a1ed3fb45dbb927f48e65 (patch)
tree27042b15ed64cb2a438c97b4eaeb23a681cffa0d /frontends/ast/ast.cc
parenteae43e2db430c951018b5cb70f047de84ad010b0 (diff)
Fixed handling of boolean attributes (frontends)
Diffstat (limited to 'frontends/ast/ast.cc')
-rw-r--r--frontends/ast/ast.cc16
1 files changed, 15 insertions, 1 deletions
diff --git a/frontends/ast/ast.cc b/frontends/ast/ast.cc
index f589f0c1..df30c6d9 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;