mirror of
https://github.com/YosysHQ/yosys
synced 2025-06-03 04:41:22 +00:00
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
431cb2d1b9
commit
1efd3aeb7d
4 changed files with 30 additions and 28 deletions
|
@ -84,12 +84,10 @@ PrettyHelp::~PrettyHelp()
|
||||||
current_help = _prior;
|
current_help = _prior;
|
||||||
}
|
}
|
||||||
|
|
||||||
PrettyHelp *PrettyHelp::get_current(source_location location)
|
PrettyHelp *PrettyHelp::get_current()
|
||||||
{
|
{
|
||||||
if (current_help == nullptr)
|
if (current_help == nullptr)
|
||||||
new PrettyHelp();
|
new PrettyHelp();
|
||||||
current_help->_root_listing.source_file = location.file_name();
|
|
||||||
current_help->_root_listing.source_line = location.line();
|
|
||||||
return current_help;
|
return current_help;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,19 +23,6 @@
|
||||||
#include "kernel/yosys_common.h"
|
#include "kernel/yosys_common.h"
|
||||||
#include "kernel/json.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
|
YOSYS_NAMESPACE_BEGIN
|
||||||
|
|
||||||
struct ContentListing {
|
struct ContentListing {
|
||||||
|
@ -94,7 +81,7 @@ public:
|
||||||
PrettyHelp(Mode mode = LOG);
|
PrettyHelp(Mode mode = LOG);
|
||||||
~PrettyHelp();
|
~PrettyHelp();
|
||||||
|
|
||||||
static PrettyHelp *get_current(source_location location = source_location::current());
|
static PrettyHelp *get_current();
|
||||||
|
|
||||||
bool has_content() { return _root_listing.content.size();}
|
bool has_content() { return _root_listing.content.size();}
|
||||||
const vector<ContentListing *> get_content() {
|
const vector<ContentListing *> get_content() {
|
||||||
|
@ -102,8 +89,6 @@ public:
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* source_file() const { return _root_listing.source_file; }
|
|
||||||
|
|
||||||
void usage(
|
void usage(
|
||||||
const string &usage,
|
const string &usage,
|
||||||
const source_location location = source_location::current()
|
const source_location location = source_location::current()
|
||||||
|
|
|
@ -42,7 +42,8 @@ std::map<std::string, Backend*> backend_register;
|
||||||
|
|
||||||
std::vector<std::string> Frontend::next_args;
|
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;
|
next_queued_pass = first_queued_pass;
|
||||||
first_queued_pass = this;
|
first_queued_pass = this;
|
||||||
|
@ -389,8 +390,8 @@ void ScriptPass::help_script()
|
||||||
script();
|
script();
|
||||||
}
|
}
|
||||||
|
|
||||||
Frontend::Frontend(std::string name, std::string 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),
|
Pass(name.rfind("=", 0) == 0 ? name.substr(1) : "read_" + name, short_help, location),
|
||||||
frontend_name(name.rfind("=", 0) == 0 ? name.substr(1) : name)
|
frontend_name(name.rfind("=", 0) == 0 ? name.substr(1) : name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -537,8 +538,8 @@ void Frontend::frontend_call(RTLIL::Design *design, std::istream *f, std::string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Backend::Backend(std::string name, std::string 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),
|
Pass(name.rfind("=", 0) == 0 ? name.substr(1) : "write_" + name, short_help, location),
|
||||||
backend_name(name.rfind("=", 0) == 0 ? name.substr(1) : name)
|
backend_name(name.rfind("=", 0) == 0 ? name.substr(1) : name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,12 +23,27 @@
|
||||||
#include "kernel/yosys_common.h"
|
#include "kernel/yosys_common.h"
|
||||||
#include "kernel/yosys.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
|
YOSYS_NAMESPACE_BEGIN
|
||||||
|
|
||||||
struct Pass
|
struct Pass
|
||||||
{
|
{
|
||||||
std::string pass_name, short_help;
|
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 ~Pass();
|
||||||
|
|
||||||
virtual void help();
|
virtual void help();
|
||||||
|
@ -81,7 +96,8 @@ struct ScriptPass : Pass
|
||||||
RTLIL::Design *active_design;
|
RTLIL::Design *active_design;
|
||||||
std::string active_run_from, active_run_to;
|
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;
|
virtual void script() = 0;
|
||||||
|
|
||||||
|
@ -99,7 +115,8 @@ struct Frontend : Pass
|
||||||
static std::string last_here_document;
|
static std::string last_here_document;
|
||||||
|
|
||||||
std::string frontend_name;
|
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;
|
void run_register() override;
|
||||||
~Frontend() override;
|
~Frontend() override;
|
||||||
void execute(std::vector<std::string> args, RTLIL::Design *design) override final;
|
void execute(std::vector<std::string> args, RTLIL::Design *design) override final;
|
||||||
|
@ -115,7 +132,8 @@ struct Frontend : Pass
|
||||||
struct Backend : Pass
|
struct Backend : Pass
|
||||||
{
|
{
|
||||||
std::string backend_name;
|
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;
|
void run_register() override;
|
||||||
~Backend() override;
|
~Backend() override;
|
||||||
void execute(std::vector<std::string> args, RTLIL::Design *design) override final;
|
void execute(std::vector<std::string> args, RTLIL::Design *design) override final;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue