如何找到TCL程序的位置? [英] How to find the location of TCL procedure?

查看:169
本文介绍了如何找到TCL程序的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在TCL中找到程序(功能)的位置.在位置下,我的意思是在其中声明该文件的源文件.

How can be find the location of procedure (function) in TCL. Under location I mean the source file in which it is declared.

我正在尝试读取外部源代码,并且找不到单个过程的声明,例如:

I'm trying to read foreign source-code and can not find the declaration of a single procedure, example:

set MSISDNElement [regexp -all -inline {ISDN +[0-9]+} $Command]

if { $MSISDNElement != "" } {
    foreach elm $MSISDNElement {
        set MSISDNValue [list ISDN [getInternationalFormat [lindex $elm 1]]]
    }
}

set EptData [list [lindex $Command 1]]

InitEptData 3
foreach Element $EptData {
    SetEptData [lindex $Element 0] [lindex $Element 1]
}

对于功能 InitEptData & SetEptData 我找不到任何声明.有人可以更深入地了解TCL,以解释如何解决我所面临的问题吗?预先感谢!

For the functions InitEptData & SetEptData I can't find any declaration. Could someone familiar much more in deep with TCL, to explain how to solve that issue which I'm facing? Thanks in advance!

推荐答案

对此没有通用的答案,因为Tcl允许您动态声明过程,因此它们可能没有实际的文件引用.

There is no generic answer to this, as Tcl allows you to declare procedures on the fly, so they could have no actual file reference.

有一些尝试可以改善具有定义文件的proc的情况,例如 TIP280 (实际上在最近的8.5版本中是info frame可用的)和TIP 86(仅在讨论中).

There are some attempts to improve the situation for procs that have a defining file, for example TIP280, which is actually available as info framein recent 8.5 versions, and TIP 86, which is only in discussion.

但是,如果简单的grep不起作用,则可以跟踪创建过程或命令的时间.

But if a simple grepdoes not work, you could track the moment a procedure or command gets created.

这在不同的地方发生(Tcl OO可能还会增加一些,但不确定):

This happens in various places (Tcl OO might add a few more, not sure):

  • load命令期间,二进制扩展名通过
  • During a load command when a binary extension registers its command handler functions with Tcl_CreateCommand or the more modern Tcl_CreateObjCommand.
  • During a source command when a file with proc definitions is loaded
  • While running the proc command itself to define a new procedure

使用命令info commandsnamespace children,您可以遍历整个名称空间树,以获取已执行命令前后的已定义命令列表.因此,您可以创建一个跟踪所有新命令的包装器.有关某些提示,请参见 http://wiki.tcl.tk/1489 .

Using the commands info commands and namespace children you can walk the whole namespace tree to get a list of defined commands before and after the executed command. So you can create a wrapper that tracks any new commands. See http://wiki.tcl.tk/1489 for some hints how to do it.

或者,只需使用RamDebugger之类的调试器 http://www.compassis.com/ramdebugger/Intro 或ActiveStates商业调试器.

Or, simply use a debugger like RamDebugger http://www.compassis.com/ramdebugger/Intro, or ActiveStates commercial debugger.

这篇关于如何找到TCL程序的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆