summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2013-03-03 10:05:37 +0100
committerClifford Wolf <clifford@clifford.at>2013-03-03 10:05:37 +0100
commit4fcb9a7b9907cd0242ce6f9c4a3855ba20ca9017 (patch)
tree3b15a9e704ca03e5bb0aceb306f4fe1c12dd61e5
parent5bed90ae3a83c6ff456607e1b5541308ce9bcab9 (diff)
Implemented general handler for selection arguments
-rw-r--r--kernel/driver.cc3
-rw-r--r--kernel/register.cc12
-rw-r--r--kernel/register.h2
-rw-r--r--kernel/select.cc16
-rw-r--r--passes/hierarchy/hierarchy.cc3
5 files changed, 31 insertions, 5 deletions
diff --git a/kernel/driver.cc b/kernel/driver.cc
index ce648d0a..8a5cb822 100644
--- a/kernel/driver.cc
+++ b/kernel/driver.cc
@@ -213,7 +213,8 @@ struct ShellPass : public Pass {
log("Press Ctrl-D to leave the interactive shell.\n");
log("\n");
}
- virtual void execute(std::vector<std::string>, RTLIL::Design *design) {
+ virtual void execute(std::vector<std::string> args, RTLIL::Design *design) {
+ extra_args(args, 1, design, false);
shell(design);
}
} ShellPass;
diff --git a/kernel/register.cc b/kernel/register.cc
index 7b670cce..0b0fb9f9 100644
--- a/kernel/register.cc
+++ b/kernel/register.cc
@@ -107,7 +107,10 @@ void Pass::cmd_error(const std::vector<std::string> &args, size_t argidx, std::s
msg.c_str(), command_text.c_str(), error_pos, "");
}
-void Pass::extra_args(std::vector<std::string> args, size_t argidx, RTLIL::Design *)
+// implemented in kernel/select.cc
+extern void handle_extra_select_args(Pass *pass, std::vector<std::string> args, size_t argidx, RTLIL::Design *design);
+
+void Pass::extra_args(std::vector<std::string> args, size_t argidx, RTLIL::Design *design, bool select)
{
for (; argidx < args.size(); argidx++)
{
@@ -115,7 +118,12 @@ void Pass::extra_args(std::vector<std::string> args, size_t argidx, RTLIL::Desig
if (arg.substr(0, 1) == "-")
cmd_error(args, argidx, "Unkown option or option in arguments.");
- cmd_error(args, argidx, "Extra argument.");
+
+ if (!select)
+ cmd_error(args, argidx, "Extra argument.");
+
+ handle_extra_select_args(this, args, argidx, design);
+ break;
}
cmd_log_args(args);
}
diff --git a/kernel/register.h b/kernel/register.h
index bfc1b4fc..a817d8c6 100644
--- a/kernel/register.h
+++ b/kernel/register.h
@@ -37,7 +37,7 @@ struct Pass
void cmd_log_args(const std::vector<std::string> &args);
void cmd_error(const std::vector<std::string> &args, size_t argidx, std::string msg);
- void extra_args(std::vector<std::string> args, size_t argidx, RTLIL::Design *design);
+ void extra_args(std::vector<std::string> args, size_t argidx, RTLIL::Design *design, bool select = true);
static void call(RTLIL::Design *design, std::string command);
static void call(RTLIL::Design *design, std::vector<std::string> args);
diff --git a/kernel/select.cc b/kernel/select.cc
index f43cc849..f75737ad 100644
--- a/kernel/select.cc
+++ b/kernel/select.cc
@@ -394,6 +394,22 @@ static void select_stmt(RTLIL::Design *design, std::string arg)
select_filter_active_mod(design, work_stack.back());
}
+// used in kernel/register.cc
+void handle_extra_select_args(Pass *pass, std::vector<std::string> args, size_t argidx, RTLIL::Design *design)
+{
+ work_stack.clear();
+ for (; argidx < args.size(); argidx++) {
+ if (args[argidx].substr(0, 1) == "-")
+ pass->cmd_error(args, argidx, "Unexpected option in selection arguments.");
+ select_stmt(design, args[argidx]);
+ }
+ while (work_stack.size() > 1) {
+ select_op_union(design, work_stack.front(), work_stack.back());
+ work_stack.pop_back();
+ }
+ design->selection_stack.push_back(work_stack.back());
+}
+
struct SelectPass : public Pass {
SelectPass() : Pass("select", "modify and view the list of selected objects") { }
virtual void help()
diff --git a/passes/hierarchy/hierarchy.cc b/passes/hierarchy/hierarchy.cc
index 9ba1594d..e6150af5 100644
--- a/passes/hierarchy/hierarchy.cc
+++ b/passes/hierarchy/hierarchy.cc
@@ -188,8 +188,9 @@ struct HierarchyPass : public Pass {
log_cmd_error("Module `%s' not found!\n", args[argidx].c_str());
continue;
}
- log_cmd_error("Unkown option %s.\n", args[argidx].c_str());
+ break;
}
+ extra_args(args, argidx, design, false);
if (top_mod != NULL)
hierarchy(design, top_mod);