
nick at ccl4
Nov 14, 2006, 2:30 AM
Post #2 of 2
(207 views)
Permalink
|
On Mon, Nov 13, 2006 at 09:31:19PM -0600, Steve Peters wrote: > So what I'm wondering is whether there is a way to detect constant subs, > especially imported ones to prevent failing tests like what's above. It's not possible to detect if they've been imported, simply because they are so memory frugal that they don't store that information anywhere: $ ./perl -Ilib -MPOSIX -MDevel::Peek -e 'Dump $POSIX::{EOF}' SV = RV(0x183b76c) at 0x183b760 REFCNT = 1 FLAGS = (ROK) RV = 0x183b750 SV = IV(0x183b74c) at 0x183b750 REFCNT = 2 FLAGS = (IOK,READONLY,pIOK) IV = -1 $ ./perl -Ilib -MPOSIX -MDevel::Peek -e 'Dump $::{EOF}' SV = RV(0x18640ec) at 0x18640e0 REFCNT = 1 FLAGS = (ROK) RV = 0x183b750 SV = IV(0x183b74c) at 0x183b750 REFCNT = 2 FLAGS = (IOK,READONLY,pIOK) IV = -1 It might be possible to add something to the flags on the RV stored in the symbol table of the imported package, so that if it's turned into a more regular PVCV by taking a reference: $ ./perl -Ilib -MPOSIX -MDevel::Peek -e 'Dump $::{EOF}; eval "\&EOF"; Dump $::{EOF}' SV = RV(0x18640ec) at 0x18640e0 REFCNT = 1 FLAGS = (ROK) RV = 0x183b750 SV = IV(0x183b74c) at 0x183b750 REFCNT = 2 FLAGS = (IOK,READONLY,pIOK) IV = -1 SV = PVGV(0x186a7e8) at 0x18640e0 REFCNT = 1 FLAGS = (SCREAM,MULTI,IN_PAD) NAME = "EOF" NAMELEN = 3 GvSTASH = 0x1800ee0 "main" GP = 0x1105e30 SV = 0x0 REFCNT = 1 IO = 0x0 FORM = 0x0 AV = 0x0 HV = 0x0 CV = 0x18010c0 CVGEN = 0x0 LINE = 1 FILE = "(eval 3)" FLAGS = 0xa EGV = 0x18640e0 "EOF" then the exported-ness is added in. Nicholas Clark
|