ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> tcljava-user
tcljava-user
[tcljava-user] A new Tcl to Java compiler for Xmas
by Mo DeJong other posts by this author
Dec 21 2005 11:45AM messages near this date
[tcljava-user] java.lang.NullPointerException: Invalid interpreter. | Re: [tcljava-user] A new Tcl to Java compiler for Xmas
Ho Ho Ho!

Tis the season for giving and because Jacl users have been
very good this year, the gift of a shiny new compiler is
now available via the tcljava CVS. The compiler is
named TJC, which stands for Tcl to Java Compiler.
The TJC compiler accepts Tcl source code as input and
compiles Tcl procs into executable Java code stored in a
Jar file. The compiler is accessed via a startup script
named tjc.

The TJC compiler is ready for evaluation by early adopters
looking for significant performance improvements for
Jacl scripts. Currently, scripts can be compiled ahead
of time but there is no support for compilation of
Tcl procs at runtime.

A simple example showing how to use the TJC compiler
is appended to this email. Many thanks got to AMD,
New Iron Systems, and One Moon Scientific for funding
this project.

cheers
Mo DeJong



SIMPLE TJC EXAMPLE:

In the following example, a TJC module containing a single
Tcl script file and a single compiled proc will be created
and loaded into the Jacl shell. This example makes use of
the tjc executable and the TJC::package command.

In this example, the Tcl source file used as input to the
TJC compiler is defined as follows:

$ cat simple.tcl
proc simple {} {
    return "SIMPLE"
}

The user will now need to create a TJC module file for the
TJC package. The name of the module file will be simple.tjc.
The name of the Java package will also be "simple", this is the
same package name that will later be passed to the TJC::package
command. The SOURCE and INIT_SOURCE declarations will list
only the simple.tcl file.

$ cat simple.tjc
PACKAGE simple

SOURCE simple.tcl
INIT_SOURCE simple.tcl

OPTIONS

Assuming that the tjc executable is already on the PATH, the TJC
compiler is invoke via:

$ tjc simple.tjc

If no error is generated, then nothing is printed and the files
simple.jar and simplesrc.jar are created in the current directory.

Note that simple.jar contains both the compiled version of the
proc simple and the script simple.tcl.

This TJC package can be loaded into a Jacl shell by adding
simple.jar to the CLASSPATH and invoking Jacl.

$ export CLASSPATH=${CLASSPATH}:`pwd`/simple.jar
$ java tcl.lang.Shell

At the Jacl shell prompt the following Tcl commands would be entered
to load the TJC package and init the simple package.

% package require TJC
1.0
% TJC::package simple
% simple
SIMPLE


The example above shows how a compiled version of the Tcl proc
named "simple" is loaded into the Jacl shell and executed.
The results returned by the compiled "simple" command are
the same as would be returned by the Tcl version of the command.


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
tcljava-user mailing list
tcljava-user@[...].net
https://lists.sourceforge.net/lists/listinfo/tcljava-user
Thread:
Mo DeJong
Tom Poindexter

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved