yosys-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Yosys::LibertyAst Struct Reference

#include <libparse.h>

Public Member Functions

 ~LibertyAst ()
 
LibertyAstfind (std::string name)
 
void dump (FILE *f, std::string indent="", std::string path="", bool path_ok=false)
 

Data Fields

std::string id
 
std::string value
 
std::vector< std::string > args
 
std::vector< LibertyAst * > children
 

Static Public Attributes

static std::set< std::string > blacklist
 
static std::set< std::string > whitelist
 

Detailed Description

Definition at line 30 of file libparse.h.

Constructor & Destructor Documentation

LibertyAst::~LibertyAst ( )

Definition at line 37 of file libparse.cc.

38 {
39  for (auto child : children)
40  delete child;
41  children.clear();
42 }
std::vector< LibertyAst * > children
Definition: libparse.h:34

Member Function Documentation

void LibertyAst::dump ( FILE *  f,
std::string  indent = "",
std::string  path = "",
bool  path_ok = false 
)

Definition at line 54 of file libparse.cc.

55 {
56  if (whitelist.count(path + "/*") > 0)
57  path_ok = true;
58 
59  path += "/" + id;
60 
61  if (blacklist.count(id) > 0 || blacklist.count(path) > 0)
62  return;
63  if (whitelist.size() > 0 && whitelist.count(id) == 0 && whitelist.count(path) == 0 && !path_ok) {
64  fprintf(stderr, "Automatically added to blacklist: %s\n", path.c_str());
65  blacklist.insert(id);
66  return;
67  }
68 
69  fprintf(f, "%s%s", indent.c_str(), id.c_str());
70  if (!args.empty() || !children.empty()) {
71  fprintf(f, "(");
72  for (size_t i = 0; i < args.size(); i++)
73  fprintf(f, "%s%s", i > 0 ? ", " : "", args[i].c_str());
74  fprintf(f, ")");
75  }
76  if (!value.empty())
77  fprintf(f, " : %s", value.c_str());
78  if (!children.empty()) {
79  fprintf(f, " {\n");
80  for (size_t i = 0; i < children.size(); i++)
81  children[i]->dump(f, indent + " ", path, path_ok);
82  fprintf(f, "%s}\n", indent.c_str());
83  } else
84  fprintf(f, " ;\n");
85 }
std::string id
Definition: libparse.h:32
std::vector< std::string > args
Definition: libparse.h:33
void dump(FILE *f, std::string indent="", std::string path="", bool path_ok=false)
Definition: libparse.cc:54
std::string value
Definition: libparse.h:32
static std::set< std::string > whitelist
Definition: libparse.h:39
std::vector< LibertyAst * > children
Definition: libparse.h:34
static std::set< std::string > blacklist
Definition: libparse.h:38
LibertyAst * LibertyAst::find ( std::string  name)

Definition at line 44 of file libparse.cc.

45 {
46  if (this == NULL)
47  return NULL;
48  for (auto child : children)
49  if (child->id == name)
50  return child;
51  return NULL;
52 }
#define NULL
std::vector< LibertyAst * > children
Definition: libparse.h:34

Field Documentation

std::vector<std::string> Yosys::LibertyAst::args

Definition at line 33 of file libparse.h.

std::set< std::string > LibertyAst::blacklist
static

Definition at line 38 of file libparse.h.

std::vector<LibertyAst*> Yosys::LibertyAst::children

Definition at line 34 of file libparse.h.

std::string Yosys::LibertyAst::id

Definition at line 32 of file libparse.h.

std::string Yosys::LibertyAst::value

Definition at line 32 of file libparse.h.

std::set< std::string > LibertyAst::whitelist
static

Definition at line 39 of file libparse.h.


The documentation for this struct was generated from the following files: