Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ANN: TclDis, a tcl bytecode decompiler

416 views
Skip to first unread message

Aidan Hobson Sayers

unread,
Apr 7, 2015, 7:13:46 AM4/7/15
to
TclDis is a Python(!) program to take Tcl bytecode and turn it back into the
original Tcl code. It's a helpful learning tool, especially with the use of the
web interface to follow the decompilation process.

You can
- see the code at https://github.com/aidanhs/tcldis
- view the web interface at http://aidanhs.github.io/tcldis/

WARNING: the web interface may take up to a minute to load and requires a modern
browser - the latest versions of Chrome and Firefox have been tested. Mobile
browsers not recommended!

The reason for this is that it uses some of my other projects [1] [2] [3]
with Emscripten to provide a completely client-side experience - nothing is sent
to a remote server, it's all handled by a Python and Tcl interpreter running
inside your browser.

There are more details in the web interface itself, but here are some notes:

- decompilation is done by ~1k lines of Python - it's not big, and could be
easily ported to tcl by a motivated person
- pattern-matching is used to decompile - this is bad for being future-proof,
especially when optimisations are involved (as introduced in 8.6)
- the ~3.5MB gzipped .js file includes a Python interpreter, the Python stdlib,
a Tcl interpreter and a C extension to let them talk to each other - there are
instructions on how to explore this combination in the web interface 'more
details'

I could sink much more time into improving this, but I've reached a point where
I'm happy to leave it now - hopefully you find it interesting.

Aidan

[1] libtclpy - https://github.com/aidanhs/libtclpy
[2] empython - https://github.com/aidanhs/empython
[3] emtcl - https://github.com/aidanhs/emtcl

Donal K. Fellows

unread,
Apr 7, 2015, 10:28:46 AM4/7/15
to
On 07/04/2015 12:13, Aidan Hobson Sayers wrote:
> TclDis is a Python(!) program to take Tcl bytecode and turn it back into the
> original Tcl code. It's a helpful learning tool, especially with the use of the
> web interface to follow the decompilation process.
>
> You can
> - see the code at https://github.com/aidanhs/tcldis
> - view the web interface at http://aidanhs.github.io/tcldis/

Very neat! It doesn't handle everything (e.g., [switch] seems to be good
at confusing it) but it does a very creditable job.

Donal.
--
Donal Fellows — Tcl user, Tcl maintainer, TIP editor.
0 new messages