I'm thinking of 2 new ops:
deref Px, Py # set Px to what Ref Py refers to
ref S0, Py # := typeof S0, Py->referee
ref I0, Py # := typeof I0, Py->referee
The "deref" opocde could call vtable->get_pmc, which isn't covered by
any opcode yet (assign does a set_pmc - but we don't have the opposite).
This could be also useful for Keys. We can do:
new P0, .Key
new P1, .PerlString
set P1, "key"
assign P0, P1
But there is no opcode to get the PerlString out of the key.
Comments welcome,
leo
[1]
new P1, .PerlString
set P1, 42
new P0, .Ref, P1
print P0
print "\n"
inc P1 # or inc PO
print P0
print "\n"
typeof S0, P0
print S0
print "\n"
typeof S0, P1
print S0
print "\n"
end
42
43
Ref
PerlInt
> I think if you have the op for dereferencing, you don't need the
> additional ops for
> getting the type of the reference.
Too true, thanks
leo
Yes, but if you have to go via another PMC register then you may spill.
Whereas it seemed that the type retrieval ops went direct to S and I
registers, which may save spillage. (at a cost of more ops)
Nicholas Clark
Well, 1 extra register is required which shouldn't be enough to worry
about. Spillage is pretty rare with the number of registers we have
so I doubt it will make a difference.
-Melvin