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

New pmc syntax for HLLs.

0 views
Skip to first unread message

Will Coleda

unread,
Nov 18, 2005, 10:23:24 AM11/18/05
to Internals List
In trying to bring Tcl up to date with PDD20 and avoid the
deprecation of newsub, that led me to having to implement TclLexPad
(which would correspond to the new LexPad base type. The PDD says
this happens automatically, but:

Leo pointed out that while Tcl is using the '.HLL' directive, ...
nothing was actually being autoboxed to the various Tcl types, as tcl
has not been registering each type we care about.

I saw that Roger had implemented this for Amber, so I borrowed his
implementation, and added it as new syntax to the PMC declarations.
'pmclass' now takes two additional flags:

"hll HLL"
The High level language this PMC corresponds to.

"maps Type"
The basic parrot PMC type that this PMC correspond to
for
".HLL" usage. For example:

pmcclass TclInt hll Tcl maps Integer

allows this PMC to automatically be used when
autoboxing "I"
registers to PMCs.

Requires the "hll" flag.

This makes the generated .c file contain the appropriate code
for .HLL registration.

So, for TclString, we now define our pmc as:

pmclass TclString extends TclObject extends String dynpmc group
tcl_group hll Tcl maps String { ... }

and now this code:

.HLL 'Tcl', 'tcl_group'
.sub ''
$P1 = test()
$S1 = typeof $P1
print $S1
print_newline
.end
.sub test
.return ("coke")
.end

prints "TclString" instead of "String". (presuming you've built Tcl,
of course)

(Roger: you should steal this syntax for your Amber PMCs. =-)

Chip Salzenberg

unread,
Nov 18, 2005, 1:41:29 PM11/18/05
to Will Coleda, Internals List
On Fri, Nov 18, 2005 at 10:23:24AM -0500, Will Coleda wrote:
> pmclass TclString extends TclObject extends String dynpmc group
> tcl_group hll Tcl maps String { ... }

Nice improvisation on an existing theme. One of these months I'll get
around to making op and pmc definitions less clunky. Meantime, I'm
glad the fix was so straightforward.
--
Chip Salzenberg <ch...@pobox.com>

Roger Browne

unread,
Nov 19, 2005, 3:55:44 PM11/19/05
to perl6-i...@perl.org
Will Coleda wrote:

> 'pmclass' now takes two additional flags ...


> (Roger: you should steal this syntax for your Amber PMCs. =-)

Thanks Will. Consider it stolen!

I see that you only handle one 'maps' directive per PMC. I think some
PMCs will use more. Consider a HLL that doesn't have any special Boolean
type. It's likely that its integer type will map both Integer and
Boolean.

My current PMCs map only one type each, so it's not an issue for me.

Regards,
Roger Browne

0 new messages