48 #include <boost/algorithm/string/case_conv.hpp> 49 #include <boost/algorithm/string/trim.hpp> 52 #include <boost/algorithm/string/predicate.hpp> 64 std::string name = element->
get_name();
75 return NODE_PARAMETER;
87 return NODE_ITE_BLOCK;
102 std::string name = element->
get_name();
145 if(condition->length() == 0)
150 std::string trimmed = *condition;
151 boost::algorithm::trim(trimmed);
153 if(trimmed ==
"\"\"")
164 auto length =
static_cast<unsigned int>(trimmed.length());
171 if(std::stoull(trimmed) == 0)
175 else if(std::stoull(trimmed) == 1)
180 catch(
const std::exception& ex)
184 std::string lowered = trimmed;
185 boost::algorithm::to_lower(lowered);
186 return lowered !=
"false";
195 std::string trimmed = *condition;
196 boost::algorithm::trim(trimmed);
198 if(trimmed[0] ==
'!')
200 trimmed = trimmed.substr(1, trimmed.length());
203 if(trimmed[0] ==
'$')
206 std::string::size_type length = trimmed.length();
207 if(length > 7 && trimmed[1] ==
'{' && trimmed[length - 1] ==
'}')
209 var = trimmed.substr(4, length - 7);
213 var = trimmed.substr(3, length - 4);
219 if(map.find(var) == map.end())
221 THROW_ERROR(
"variable " + var +
" not configured");
223 for(
const auto& it : map)
225 const std::string& name = it.first;
226 const std::string&
value = it.second;
242 condition = _condition ?
new std::string(*_condition) :
nullptr;
258 THROW_ERROR(
"Attribute \"value\" required for entry");
288 node->set_attribute(
"value",
value);
291 node->set_attribute(
"condition", *
condition);
293 return xml_nodeRef(node);
302 const std::string* _condition)
305 singleValue = _singleValue ?
new std::string(*_singleValue) :
nullptr;
307 condition = _condition ?
new std::string(*_condition) :
nullptr;
335 for(
const auto& l : list)
337 const xml_element* child = GetPointer<xml_element>(l);
346 THROW_ERROR(
"Only one between \"value\" and <entry> children can be defined");
379 node->set_attribute(
"name",
name);
386 node->set_attribute(
"condition", *
condition);
390 node->add_child_element(child->create_xml_node());
392 return xml_nodeRef(node);
401 const std::string* _condition,
const std::string& _separator,
bool _curlyBrackets)
404 name =
name ?
new std::string(*_name) :
nullptr;
405 singleValue = _singleValue ?
new std::string(*_singleValue) :
nullptr;
407 condition = _condition ?
new std::string(*_condition) :
nullptr;
436 for(
const auto& l : list)
438 const xml_element* child = GetPointer<xml_element>(l);
447 THROW_ERROR(
"Only one between \"value\" and <entry> children can be defined");
451 THROW_ERROR(
"At least one among \"name\", \"value\" or <entry> children must be defined");
457 condition =
new std::string(a->get_value());
499 node->set_attribute(
"name", *
name);
507 node->set_attribute(
"condition", *
condition);
511 node->set_attribute(
"curly",
"true");
515 node->add_child_element(child->create_xml_node());
517 return xml_nodeRef(node);
526 const std::string* _output)
529 name = _name ?
new std::string(*_name) :
nullptr;
530 value = _value ?
new std::string(*_value) :
nullptr;
532 condition = _condition ?
new std::string(*_condition) :
nullptr;
533 output = _output ?
new std::string(*_output) :
nullptr;
555 value =
new std::string(a->get_value());
559 for(
const auto& l : list)
561 const xml_element* child = GetPointer<xml_element>(l);
572 condition =
new std::string(a->get_value());
578 output =
new std::string(a->get_value());
611 node->set_attribute(
"name", *
name);
615 node->set_attribute(
"value", *
value);
619 node->set_attribute(
"condition", *
condition);
623 node->set_attribute(
"output", *
output);
627 node->add_child_element(child->create_xml_node());
629 return xml_nodeRef(node);
638 const std::string* _output)
641 name = _name ?
new std::string(*_name) :
nullptr;
642 value = _value ?
new std::string(*_value) :
nullptr;
644 condition = _condition ?
new std::string(*_condition) :
nullptr;
645 output = _output ?
new std::string(*_output) :
nullptr;
667 value =
new std::string(a->get_value());
671 for(
const auto& l : list)
673 const xml_element* child = GetPointer<xml_element>(l);
684 condition =
new std::string(a->get_value());
690 output =
new std::string(a->get_value());
723 node->set_attribute(
"name", *
name);
727 node->set_attribute(
"value", *
value);
731 node->set_attribute(
"condition", *
condition);
735 node->set_attribute(
"output", *
output);
739 node->add_child_element(child->create_xml_node());
741 return xml_nodeRef(node);
758 condition(element->get_attribute(
"condition") ? element->get_attribute(
"condition")->get_value() :
"")
763 bool thenFound =
false, elseFound =
false;
766 for(
const auto& l : list)
768 const xml_element* child = GetPointer<xml_element>(l);
775 if(!thenFound && !elseFound)
791 THROW_ERROR(
"<then> already defined, or found after <else>");
794 else if(child->
get_name() ==
"else")
837 node->set_attribute(
"condition",
condition);
848 return xml_nodeRef(node);
865 THROW_ASSERT(a,
"Error: the \"foreach\" block requires the definition of the variable");
868 for(
const auto& l : list)
870 const xml_element* child = GetPointer<xml_element>(l);
877 for(
const auto& s : subscript)
887 Nodes.push_back(node);
911 return xml_nodeRef(node);
std::string get_value() const
Get the value of this attribute.
virtual ~xml_script_node_t()
xml_parameter_t(const std::string *_name, const std::string *_singleValue, const std::string *_condition, const std::string &_separator, bool _curlyBrackets)
refcount< xml_set_entry_t > xml_set_entry_tRef
void clean() override
Cleans object attributes.
xml_nodeRef create_xml_node() const override
Creates an XML node for polixml data structures.
std::string get_xml_name() const override
Gets the XML element name of this node type.
void clean() override
Cleans object attributes.
xml_set_entry_t(std::string _value, const std::string *_condition)
std::map< std::string, std::string > map_t
Parameters map type.
void clean() override
Cleans object attributes.
xml_nodeRef create_xml_node() const override
Creates an XML node for polixml data structures.
std::string get_xml_name() const override
Gets the XML element name of this node type.
std::vector< xml_parameter_tRef > parameters
~xml_command_t() override
xml_shell_t(const std::string *_name, const std::string *_value, const std::string *_condition, const std::string *_output)
xml_ite_block_t(const std::string *_condition)
exceptions managed by PandA
xml_nodeRef create_xml_node() const override
Creates an XML node for polixml data structures.
void clean() override
Cleans object attributes.
Definition of hash function for EdgeDescriptor.
xml_nodeRef create_xml_node() const override
Creates an XML node for polixml data structures.
~xml_foreach_t() override
std::vector< xml_script_node_tRef > Nodes
bool checkCondition(const DesignParametersRef &dp) const override
If the node has a compile-time condition, this method evaluates it.
std::vector< xml_script_node_tRef > elseNodes
void clean() override
Cleans object attributes.
static bool evaluate_condition(const std::string *condition)
Evaluates a string condition.
void clean() override
Cleans object attributes.
If/Then/Else block, evaluated at compile-time.
bool starts_with(const std::string &str, const std::string &pattern)
map_t parameter_values
Map between the name of the parameter and the corresponding string-based value.
#define NOT_YET_IMPLEMENTED()
helper function to mark points not yet implemented
xml_nodeRef create_xml_node() const override
Creates an XML node for polixml data structures.
~xml_set_entry_t() override
~xml_parameter_t() override
unsigned map[NUM_VERTICES]
std::string get_name() const
Get the name of this node.
~xml_ite_block_t() override
bool checkCondition(const DesignParametersRef &dp) const override
If the node has a compile-time condition, this method evaluates it.
This file contains the definition of the parameters for the synthesis tools.
xml_foreach_t(std::string _variable)
std::string get_xml_name() const override
Gets the XML element name of this node type.
~xml_set_variable_t() override
bool checkCondition(const DesignParametersRef &dp) const override
If the node has a compile-time condition, this method evaluates it.
void clean() override
Cleans object attributes.
std::string get_xml_name() const override
Gets the XML element name of this node type.
bool checkCondition(const DesignParametersRef &dp) const override
If the node has a compile-time condition, this method evaluates it.
refcount< xml_script_node_t > xml_script_node_tRef
xml_attribute * get_attribute(const std::string &name) const
Obtain the attribute with this name.
std::list< xml_nodeRef > node_list
type for list of xml nodes
#define THROW_ERROR(str_expr)
helper function used to throw an error in a standard way
static xml_script_node_t * create(const xml_element *element)
Creates a script node by parsing the XML element.
std::vector< xml_parameter_tRef > parameters
Classes for handling configuration files.
bool checkCondition(const DesignParametersRef &dp) const override
If the node has a compile-time condition, this method evaluates it.
This is the abstract class which describes a generic synthesis script node, and some static helper me...
bool checkCondition(const DesignParametersRef &dp) const override
If the node has a compile-time condition, this method evaluates it.
std::string get_xml_name() const override
Gets the XML element name of this node type.
std::string * singleValue
std::string get_xml_name() const override
Gets the XML element name of this node type.
refcount< xml_parameter_t > xml_parameter_tRef
std::string * singleValue
xml_set_variable_t(std::string _name, const std::string *_singleValue, const std::string *_condition)
std::vector< xml_set_entry_tRef > multiValues
std::vector< xml_set_entry_tRef > multiValues
Variable assignment, either single value or multiple entries set.
xml_nodeRef create_xml_node() const override
Creates an XML node for polixml data structures.
xml_nodeRef create_xml_node() const override
Creates an XML node for polixml data structures.
Command line of the synthesis tool.
node_list const & get_children()
Obtain the list of child nodes.
Command line of the native shell.
virtual bool checkCondition(const DesignParametersRef &dp) const
If the node has a compile-time condition, this method evaluates it.
Foreach block, where the set of script nodes is applied to each parameter.
std::string get_xml_name() const override
Gets the XML element name of this node type.
xml_command_t(const std::string *_name, const std::string *_value, const std::string *_condition, const std::string *_output)
xml_element * add_child_element(const std::string &name)
Add a child element to this node.
std::vector< xml_script_node_tRef > thenNodes
static xml_script_node_enum_t find_type(const xml_element *element)
Finds the type of an XML element.
String entry of a multiple values variable (set).
enum xml_script_node_enum_t { NODE_UNKNOWN=0, NODE_ENTRY=1, NODE_VARIABLE=2, NODE_PARAMETER=3, NODE_COMMAND=4, NODE_SHELL=5, NODE_ITE_BLOCK=6, NODE_FOREACH=7 } xml_script_node_enum_t
Node types.
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...