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

[RfC] new PMC compiler

5 views
Skip to first unread message

Leopold Toetsch

unread,
Oct 6, 2003, 5:23:22 AM10/6/03
to P6I
The current classes/pmc2c.pl PMC compiler has some drawbacks:
- does multiple scanning of source files
- a lot of code duplication
- no multiple PMC inheritance
- hard to hack and expand

So I started to reimplement it with a new scheme:
* parse files only once:
A Makefile rule creates classes/foo.dump from classes/foo.pmc
with the help of Data::Dumper[1]
* Generating foo.{c.h} uses these dumps

Dump of classes and $default (vtable.tbl) is already working.

Comments welcome
leo

[1] snipped from orderedhash.dump
$OrderedHash = {
'flags' => {
'need_ext' => 1,
'does' => {
'hash' => 1,
'array' => 1
},
'extends' => {
'PerlArray' => 1
}
},
'post' => '

/*
* Local variables:
* c-indentation-style: bsd
* c-basic-offset: 4
* indent-tabs-mode: nil
* End:
*
* vim: expandtab shiftwidth=4:
*/

',
'methods' => [
{
'parameters' => '',
'body' => '{
SUPER();
PerlHash.SUPER();
}',
'meth' => 'init',
'type' => 'void',
'line' => 32
},
...

Dan Sugalski

unread,
Oct 6, 2003, 8:41:10 AM10/6/03
to Leopold Toetsch, P6I
On Mon, 6 Oct 2003, Leopold Toetsch wrote:

> The current classes/pmc2c.pl PMC compiler has some drawbacks:
> - does multiple scanning of source files
> - a lot of code duplication
> - no multiple PMC inheritance
> - hard to hack and expand
>
> So I started to reimplement it with a new scheme:
> * parse files only once:
> A Makefile rule creates classes/foo.dump from classes/foo.pmc
> with the help of Data::Dumper[1]
> * Generating foo.{c.h} uses these dumps
>
> Dump of classes and $default (vtable.tbl) is already working.

If it's clearer to read than pmc2c.pl, sure, go for it. That code's been
stretched well beyond what it it it was originally intended to do and is
getting kind of crufty.

Dan

Leopold Toetsch

unread,
Oct 7, 2003, 12:24:40 PM10/7/03
to Dan Sugalski, perl6-i...@perl.org
Dan Sugalski <d...@sidhe.org> wrote:

> If it's clearer to read than pmc2c.pl, sure, go for it. That code's been
> stretched well beyond what it it it was originally intended to do and is
> getting kind of crufty.

Ok, checked in.

Almost all of the exceptions to code generation are handled in separate
(Pmc2c::)classes. It for sure needs some cleanup but should be much more
maintanable then the old one.

$ perl classes/pmc2c2.pl --vtable # => vtable.dump
$ perl classes/pmc2c2.pl --dump classes/*.pmc # => *.dump
$ perl classes/pmc2c2.pl --c classes/*.pmc # => *.c *.h

Then the rules from classes/Makefile (*.o depend on generated *.h)
interfer, so disabling PMC2C in the classes/Makefile helps for testing.

> Dan

leo

0 new messages