diff options
author | Keith Rothman <537074+litghost@users.noreply.github.com> | 2021-02-11 14:53:29 -0800 |
---|---|---|
committer | Keith Rothman <537074+litghost@users.noreply.github.com> | 2021-02-12 10:31:04 -0800 |
commit | d987bd2997e51e1cbe0681b791adfc685753955c (patch) | |
tree | b53393852c5e4896d96499ff8b75734cdeb8e2ba | |
parent | a0bd3131390567d1bd79c1ac19f663caff603445 (diff) | |
download | nextpnr-d987bd2997e51e1cbe0681b791adfc685753955c.tar.gz nextpnr-d987bd2997e51e1cbe0681b791adfc685753955c.tar.bz2 nextpnr-d987bd2997e51e1cbe0681b791adfc685753955c.zip |
Add unknown handles to convert [0] to "[0]".
Tcl reads something like "set port [get_ports x[0]]" as "invoke proc 0
with zero arguments", rather than just "[0]". To prevent exposing
non-Tcl users this, "[<number>]" just return themselves.
Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com>
-rw-r--r-- | fpga_interchange/xdc.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/fpga_interchange/xdc.cc b/fpga_interchange/xdc.cc index 64569dd2..ee1d1cab 100644 --- a/fpga_interchange/xdc.cc +++ b/fpga_interchange/xdc.cc @@ -21,6 +21,7 @@ #include "log.h" #include "nextpnr.h" #include <tcl.h> +#include <string> NEXTPNR_NAMESPACE_BEGIN @@ -144,6 +145,16 @@ void Arch::parse_xdc(const std::string &filename) { Tcl_RegisterObjType(&port_object); + NPNR_ASSERT(Tcl_Eval(interp, "rename unknown _original_unknown") == TCL_OK); + NPNR_ASSERT(Tcl_Eval(interp, + "proc unknown args {\n" + " set result [scan [lindex $args 0] \"%d\" value]\n" + " if { $result == 1 && [llength $args] == 1] } {\n" + " return \\[$value\\]\n" + " } else {\n" + " uplevel 1 [list _original_unknown {*}$args]\n" + " }\n" + "}") == TCL_OK); Tcl_CreateObjCommand(interp, "get_ports", get_ports, getCtx(), nullptr); Tcl_CreateObjCommand(interp, "set_property", set_property, getCtx(), nullptr); auto result = Tcl_EvalFile(interp, filename.c_str()); |