Sunday, June 13, 2010

tbcload and tclcompiler

On my journey to implement a bytecode assembler for Tcl, I found out that my work is not going to be lonely. tbcload and tclcompiler are some Tcl tools that are used for producing and loading Tcl bytecode files (if you haven't already guessed from the names). They do some obfuscation and deobfuscation also. That part I am not really interested in. For me the important part is tclcompiler is writing a compiled Tcl script to a file in a certain format and the tbcload is reading this file format and "source"ing it into the Tcl interpreter even though the script source is non-existent. So my next step is understanding how tbcload and tclcompiler work. Luckily these tools have gotten opensource with TclPro. Even though the project has not been maintained since early 2003, for me that is not a problem... The problem is even though I downloaded the Mac version when I try to use the package in Tcl, I am getting wrong architecture error :).. and trying to compile it didn't really work since a header file is missing in the source :).. This actually inspired me to look for newer versions of these tools. I realized my Mac had tbcload 1.7 but a Google search for it won't get you anywhere. The best place to look for is the Apple Opensource. They have the latest version and the source.. For the tclcompiler, I don't know what to do yet, I downloaded the Activestate Tcl Dev Kit Trial, so I can compile and analyze the compiled files but for compiling source I guess I'll go with the tclcompile.c which comes with the Tcl source.. Will be back later..

Tcl bytecode assembler..`

An alternative solution to producing a Tcl target for XMLVM was to translate JVM bytecode to Tcl bytecode. For this, naturally one would need a tool to construct, manipulate Tcl bytecode files. Currently Tcl has a tool for producing obfuscated bytecode files in order to protect the source, but that help quite a lot since what I would need here would be mostly the bytecode manipulation. My mentor and I decided starting out working on a tool like that would make a bigger project Tcl for XMLVM possible. So that's what I am going with at this point.. Bytecode Assembler (manipulator) for Tcl. What I have in mind is actually something like byteplay for Python.. Let's see how it'll go..

It takes more than a simple JVM stack machine to execute Java..

My Tcl target for XMLVM project which would virtually translate Java to Tcl turned out to be a bigger project than it seemed at the first glance. A simple and straight-forward looking solution was to just implement a stack machine which would simulate a JVM in Tcl. Theoretically that would make it possible to execute JVM bytecodes in Tcl. However, my mentor pointed out that even to execute a HelloWorld Java program class loading and certain fundamental Java classes have to be brought to the target language, which is Tcl in our case.. That definitely is not a very realistic goal for this summer..

Thursday, June 3, 2010

Understanding XMLVM..

Today I found out that, the Python output for XMLVM is in early experimental state. This is bad news. I am working on producing a Tcl target for XMLVM and was planing to understand the Python and kinda go from there. But seeing that the Python output doesn't execute, kinda freaked me out :)..

I guess, this project will teach me more than I was expecting. :))