mirror of https://github.com/YosysHQ/yosys.git
Move source_location to register.h
Revert `PrettyHelp::get_current()` for no args since we can use `Pass::location` instead.
This commit is contained in:
parent
c874abf1e2
commit
1a2acd8765
|
@ -84,12 +84,10 @@ PrettyHelp::~PrettyHelp()
|
|||
current_help = _prior;
|
||||
}
|
||||
|
||||
PrettyHelp *PrettyHelp::get_current(source_location location)
|
||||
PrettyHelp *PrettyHelp::get_current()
|
||||
{
|
||||
if (current_help == nullptr)
|
||||
new PrettyHelp();
|
||||
current_help->_root_listing.source_file = location.file_name();
|
||||
current_help->_root_listing.source_line = location.line();
|
||||
return current_help;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,19 +23,6 @@
|
|||
#include "kernel/yosys_common.h"
|
||||
#include "kernel/json.h"
|
||||
|
||||
#ifdef YOSYS_ENABLE_SOURCE_LOCATION
|
||||
#include <experimental/source_location>
|
||||
using std::experimental::source_location;
|
||||
#else
|
||||
struct source_location { // dummy placeholder
|
||||
int line() const { return 0; }
|
||||
int column() const { return 0; }
|
||||
const char* file_name() const { return "unknown"; }
|
||||
const char* function_name() const { return "unknown"; }
|
||||
static const source_location current(...) { return source_location(); }
|
||||
};
|
||||
#endif
|
||||
|
||||
YOSYS_NAMESPACE_BEGIN
|
||||
|
||||
struct ContentListing {
|
||||
|
@ -94,7 +81,7 @@ public:
|
|||
PrettyHelp(Mode mode = LOG);
|
||||
~PrettyHelp();
|
||||
|
||||
static PrettyHelp *get_current(source_location location = source_location::current());
|
||||
static PrettyHelp *get_current();
|
||||
|
||||
bool has_content() { return _root_listing.content.size();}
|
||||
const vector<ContentListing *> get_content() {
|
||||
|
@ -102,8 +89,6 @@ public:
|
|||
return content;
|
||||
}
|
||||
|
||||
const char* source_file() const { return _root_listing.source_file; }
|
||||
|
||||
void usage(
|
||||
const string &usage,
|
||||
const source_location location = source_location::current()
|
||||
|
|
|
@ -100,7 +100,8 @@ std::map<std::string, Backend*> backend_register;
|
|||
|
||||
std::vector<std::string> Frontend::next_args;
|
||||
|
||||
Pass::Pass(std::string name, std::string short_help) : pass_name(name), short_help(short_help)
|
||||
Pass::Pass(std::string name, std::string short_help, source_location location) :
|
||||
pass_name(name), short_help(short_help), location(location)
|
||||
{
|
||||
next_queued_pass = first_queued_pass;
|
||||
first_queued_pass = this;
|
||||
|
@ -447,8 +448,8 @@ void ScriptPass::help_script()
|
|||
script();
|
||||
}
|
||||
|
||||
Frontend::Frontend(std::string name, std::string short_help) :
|
||||
Pass(name.rfind("=", 0) == 0 ? name.substr(1) : "read_" + name, short_help),
|
||||
Frontend::Frontend(std::string name, std::string short_help, source_location location) :
|
||||
Pass(name.rfind("=", 0) == 0 ? name.substr(1) : "read_" + name, short_help, location),
|
||||
frontend_name(name.rfind("=", 0) == 0 ? name.substr(1) : name)
|
||||
{
|
||||
}
|
||||
|
@ -631,8 +632,8 @@ void Frontend::frontend_call(RTLIL::Design *design, std::istream *f, std::string
|
|||
}
|
||||
}
|
||||
|
||||
Backend::Backend(std::string name, std::string short_help) :
|
||||
Pass(name.rfind("=", 0) == 0 ? name.substr(1) : "write_" + name, short_help),
|
||||
Backend::Backend(std::string name, std::string short_help, source_location location) :
|
||||
Pass(name.rfind("=", 0) == 0 ? name.substr(1) : "write_" + name, short_help, location),
|
||||
backend_name(name.rfind("=", 0) == 0 ? name.substr(1) : name)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -23,12 +23,27 @@
|
|||
#include "kernel/yosys_common.h"
|
||||
#include "kernel/yosys.h"
|
||||
|
||||
#ifdef YOSYS_ENABLE_SOURCE_LOCATION
|
||||
#include <experimental/source_location>
|
||||
using std::experimental::source_location;
|
||||
#else
|
||||
struct source_location { // dummy placeholder
|
||||
int line() const { return 0; }
|
||||
int column() const { return 0; }
|
||||
const char* file_name() const { return "unknown"; }
|
||||
const char* function_name() const { return "unknown"; }
|
||||
static const source_location current(...) { return source_location(); }
|
||||
};
|
||||
#endif
|
||||
|
||||
YOSYS_NAMESPACE_BEGIN
|
||||
|
||||
struct Pass
|
||||
{
|
||||
std::string pass_name, short_help;
|
||||
Pass(std::string name, std::string short_help = "** document me **");
|
||||
source_location location;
|
||||
Pass(std::string name, std::string short_help = "** document me **",
|
||||
source_location location = source_location::current());
|
||||
virtual ~Pass();
|
||||
|
||||
virtual void help();
|
||||
|
@ -81,7 +96,8 @@ struct ScriptPass : Pass
|
|||
RTLIL::Design *active_design;
|
||||
std::string active_run_from, active_run_to;
|
||||
|
||||
ScriptPass(std::string name, std::string short_help = "** document me **") : Pass(name, short_help) { }
|
||||
ScriptPass(std::string name, std::string short_help = "** document me **", source_location location = source_location::current()) :
|
||||
Pass(name, short_help, location) { }
|
||||
|
||||
virtual void script() = 0;
|
||||
|
||||
|
@ -99,7 +115,8 @@ struct Frontend : Pass
|
|||
static std::string last_here_document;
|
||||
|
||||
std::string frontend_name;
|
||||
Frontend(std::string name, std::string short_help = "** document me **");
|
||||
Frontend(std::string name, std::string short_help = "** document me **",
|
||||
source_location location = source_location::current());
|
||||
void run_register() override;
|
||||
~Frontend() override;
|
||||
void execute(std::vector<std::string> args, RTLIL::Design *design) override final;
|
||||
|
@ -115,7 +132,8 @@ struct Frontend : Pass
|
|||
struct Backend : Pass
|
||||
{
|
||||
std::string backend_name;
|
||||
Backend(std::string name, std::string short_help = "** document me **");
|
||||
Backend(std::string name, std::string short_help = "** document me **",
|
||||
source_location location = source_location::current());
|
||||
void run_register() override;
|
||||
~Backend() override;
|
||||
void execute(std::vector<std::string> args, RTLIL::Design *design) override final;
|
||||
|
|
Loading…
Reference in New Issue