This patch implements a typeof op which returns the integer type or string type of a PMC.
The test I used is: new P0,.PerlInt typeof S0,P0 eq S0,"PerlInt",OK_1 print "not " OK_1: print "ok 1\\n" typeof I0,P0 eq I0,.PerlInt,OK_2 print "not " OK_2: print "ok 2\\n" end This should allow a program to know what kind of PMC they're playing with. Brian diff -u -r1.174 core.ops --- core.ops 28 Jun 2002 18:50:05 -0000 1.174 +++ core.ops 29 Jun 2002 18:49:32 -0000 @@ -3884,6 +3884,27 @@ goto NEXT(); } + +=item B<typeof>(out STR, in PMC) + +=item B<typeof>(out INT, in PMC) + +Return the type of PMC in $2. + +=cut + +inline op typeof (out STR, in PMC) { + PMC *p = $2; + $1 = (p->vtable->name(interpreter, p)); + goto NEXT(); +} + +inline op typeof (out INT, in PMC) { + PMC *p = $2; + $1 = (p->vtable->type(interpreter, p)); + goto NEXT(); +} + ######################################## =item B<find_type>(out INT, in STR)