Recent changes to tcl:
2004-05-28 * put all user-visible procs into "Tcl" namespace, especially user-defined procedures. * put all interpreter-only procs into "_Tcl" namespace * factor out non-tclsh-specific setup into lib/tcllib.imc * first cut at: $P1 = compreg "TCL" * switch all procs in the "Tcl" namespace to use normal calling conventions. (That is, don't foldup arguments before calling, pass in variable arguments where necessary for interoperability) * [expr sqrt()] now uses the (new) sqrt op.
So, now the following PIR code to call a Tcl proc works:
.sub main @MAIN load_bytecode "languages/tcl/lib/tcllib.imc"
$P1 = find_global "Tcl", "_puts" $P2 = new PerlString $P2 = "-nonewline" $P3 = new PerlString $P3 = "foo"
$P1($P2,$P3)
end .end
And this code, to compile Tcl code, mostly works:
.sub main @MAIN load_bytecode "languages/tcl/lib/tcllib.imc"
$P1 = new PerlString $P1 = "whee" new_pad 0 store_lex 0, "a", $P1
.local pmc tcl_compiler tcl_compiler = compreg "TCL"
$P1 = compile tcl_compiler, "set a 5" $P1()
$P2 = find_lex 0, "a" print $P2 print "\n"
end .end
If you run this, the tcl compiler sets the value of the lexical "a" to 5, which the PIR code then prints out. There is an issue with the way the tcl_compiler constructs the sub we then call. Here's the end of the trace:
98 invoke P16 - P16=RetContinuation=PMC(0x154ea70 Adr:0xd08e04)
*** switching to BYTECODE_tcllib.imc
41 restoretop
42 find_lex P16, 0, "a" - P16=Eval=PMC(0x154f7c0), , 46 print P16 - P16=PerlString=PMC(0x154dde0 Str:"5")
5 48 print "\n"
50 end *** back from BYTECODE_EVAL_1 *** switching to BYTECODE_languages/tcl/lib/tcllib.imc PC=-8111231; OP=<err>
You can see that the end isn't really the end, as it tries to resume somewhere inside tcl before barfing. Patches welcome. =-)