better partcl compilation framework

coke on 2006-01-06T17:25:45

partcl is still failing a few tests, but things are looking up. Fixed a bug that was bringing down our tcl test suite numbers, added regression tests to tcl to track them. Also did some expr cleanup (octal, ~ operator, more tests.)

In the past few days, added a build tool that lets us declare inline'd tcl builtins (originally, everything was interpreted. Now several commands have a version that generates PIR), rather than hand rolling them. this lets you declare the argument types (and whether they are optional, default values, etc.) and have them compiled automatically, and just define the small bit of PIR code that you need to process the arguments. It also automatically generates errors for bad calls, etc.

By moving all this setup code into the build script, we should lower the bar for implementing the builtins. as of this writing, six builtins have been converted to the new template style. Here's a sample:

{
  command => 'join',
  args =>
  [
    {
      name     => 'list',
      type     => 'list',
    },
    {
      name     => 'joinString',
      type     => 'string',
      optional => 1,
      default  => " ",
    }
  ],
  code => <<'END_PIR',

$S{register_joinString} = $P{register_joinString} $S{register_num} = join $S{register_joinString}, $P{register_list} $P{register_num} = new .TclString $P{register_num} = $S{register_num} END_PIR }


Most of the declaration is pulled right from the manpage, as far as arguments go. The actual PIR code that does the work is actually a bit longer than it needs to be, due to boxing. (The compiler currently assumes that the result of the compilation is always a PMC - being able to specify a specific register as opposed to a PMC will let us reduce the amount of code even further.)