Dan Sugalski <[EMAIL PROTECTED]> wrote:
get_sub Px, foo # find the PMC with label "foo" in constants
Yeah, but I think I've a better approach. Instead of doing this, let's just get PMC constants implemented.
Well, they are implemented, at least partly. Sub PMCs are in the constant table. The funny C<get_sub> "opcode" is actually a ...
set_p_pc op.
... with the small difference, that at compile time, the integer argument is a label (offset).
Then we should toss the difference and have a single op to access the PMC constant table. We're going to need to do this for real PMC constants, and I don't see any point to have two ways to do the identical same thing.
What about the other part: closures - should they be created via "new" always?
Yeah, I think so. They always need to capture a lexical scope, so I think they're going to have to.
> While we're at it we should see about adding in an integer constanttable that can be fixed up on load (to take care of those pesky "what number did my PMC class map to" problems more quickly than the hash lookup) but we can put that off a bit.
You are thinking of a 2-stage lookup?
I1 = dynamic_type I0 # lookup runtime type mapping $P0 = new I1
More like what we do right now with all the other constant types. Integers aren't in a constant table since we just inline them, but the nice thing about a constant table is you can do fixups on it while not touching the actual bytecode, leaving it readonly and mmapped and all that.
While I'd prefer to leave integers inlined in general, having an integer section of the constant table that can be accessed when necessary makes the things that need integer fixup easier.
And yeah, this imples that our constant table isn't necesasrily constant. I'm OK with that, though. :)
A normal IntList Array can do that too.
Sure, it could. But we're trying to make sure we provide all the standard facilities in one place so all the different compiler writers don't have to bother. Fixed-up integer constants is a reasonable foundation piece for us to provide.
--
Dan
--------------------------------------it's like this------------------- Dan Sugalski even samurai [EMAIL PROTECTED] have teddy bears and even teddy bears get drunk