Implemented general handler for selection arguments
authorClifford Wolf <clifford@clifford.at>
Sun, 3 Mar 2013 09:05:37 +0000 (10:05 +0100)
committerClifford Wolf <clifford@clifford.at>
Sun, 3 Mar 2013 09:05:37 +0000 (10:05 +0100)
kernel/driver.cc
kernel/register.cc
kernel/register.h
kernel/select.cc
passes/hierarchy/hierarchy.cc

index ce648d0ad6aee1d0201ab33368f5a1574e534b3d..8a5cb822332457737b962284aeea1bdc42390cc8 100644 (file)
@@ -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;
index 7b670cceaba676ad2044b3d04c97116c61ab16ad..0b0fb9f9c8109629e9eeb606cd556ac0ed4c5b3d 100644 (file)
@@ -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);
 }
index bfc1b4fce606b012672782e35f9be2a35130cdcc..a817d8c648595e95e11c5ece38c7e8f2f38dfe65 100644 (file)
@@ -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);
index f43cc8495a9d090c1373ea63dabe03efaebe2d1f..f75737ad83c5d16a0c948cc56c888bc622bb1415 100644 (file)
@@ -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()
index 9ba1594dfdfddbc488bd5706895df7943d0ffb74..e6150af54fc9ed4b76d5469db830af7b15cc860c 100644 (file)
@@ -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);