perlintern.html
来自「perl教程」· HTML 代码 · 共 986 行 · 第 1/3 页
HTML
986 行
<dd>
<p>Lightweight and lvalue version of <a href="#item_pad_sv"><code>PAD_SV</code></a>.
Get or set the value at offset <code>po</code> in the current pad.
Unlike <a href="#item_pad_sv"><code>PAD_SV</code></a>, does not print diagnostics with -DX.
For internal use only.</p>
</dd>
<dd>
<pre>
SV * PAD_SVl(PADOFFSET po)</pre>
</dd>
</li>
<dt><strong><a name="item_saveclearsv">SAVECLEARSV</a></strong>
<dd>
<p>Clear the pointed to pad value on scope exit. (i.e. the runtime action of 'my')</p>
</dd>
<dd>
<pre>
void SAVECLEARSV(SV **svp)</pre>
</dd>
</li>
<dt><strong><a name="item_savecomppad">SAVECOMPPAD</a></strong>
<dd>
<p>save PL_comppad and PL_curpad</p>
</dd>
<dd>
<pre>
void SAVECOMPPAD()</pre>
</dd>
</li>
<dt><strong><a name="item_savepadsv">SAVEPADSV</a></strong>
<dd>
<p>Save a pad slot (used to restore after an iteration)</p>
</dd>
<dd>
<p><table cellspacing="0" cellpadding="0"><tr><td>XXX DAPM it would make more sense to make the arg a PADOFFSET
<tr><td><td>void<td>SAVEPADSV(PADOFFSET po)</table></p>
</dd>
</li>
</dl>
<p>
</p>
<hr />
<h1><a name="functions_in_file_pp_ctl_c">Functions in file pp_ctl.c</a></h1>
<dl>
<dt><strong><a name="item_find_runcv">find_runcv</a></strong>
<dd>
<p>Locate the CV corresponding to the currently executing sub or eval.
If db_seqp is non_null, skip CVs that are in the DB package and populate
*db_seqp with the cop sequence number at the point that the DB:: code was
entered. (allows debuggers to eval in the scope of the breakpoint rather
than in the scope of the debugger itself).</p>
</dd>
<dd>
<pre>
CV* find_runcv(U32 *db_seqp)</pre>
</dd>
</li>
</dl>
<p>
</p>
<hr />
<h1><a name="global_variables">Global Variables</a></h1>
<dl>
<dt><strong><a name="item_pl_dbsingle">PL_DBsingle</a></strong>
<dd>
<p>When Perl is run in debugging mode, with the <strong>-d</strong> switch, this SV is a
boolean which indicates whether subs are being single-stepped.
Single-stepping is automatically turned on after every step. This is the C
variable which corresponds to Perl's $DB::single variable. See
<a href="#item_pl_dbsub"><code>PL_DBsub</code></a>.</p>
</dd>
<dd>
<pre>
SV * PL_DBsingle</pre>
</dd>
</li>
<dt><strong><a name="item_pl_dbsub">PL_DBsub</a></strong>
<dd>
<p>When Perl is run in debugging mode, with the <strong>-d</strong> switch, this GV contains
the SV which holds the name of the sub being debugged. This is the C
variable which corresponds to Perl's $DB::sub variable. See
<a href="#item_pl_dbsingle"><code>PL_DBsingle</code></a>.</p>
</dd>
<dd>
<pre>
GV * PL_DBsub</pre>
</dd>
</li>
<dt><strong><a name="item_pl_dbtrace">PL_DBtrace</a></strong>
<dd>
<p>Trace variable used when Perl is run in debugging mode, with the <strong>-d</strong>
switch. This is the C variable which corresponds to Perl's $DB::trace
variable. See <a href="#item_pl_dbsingle"><code>PL_DBsingle</code></a>.</p>
</dd>
<dd>
<pre>
SV * PL_DBtrace</pre>
</dd>
</li>
<dt><strong><a name="item_pl_dowarn">PL_dowarn</a></strong>
<dd>
<p>The C variable which corresponds to Perl's $^W warning variable.</p>
</dd>
<dd>
<pre>
bool PL_dowarn</pre>
</dd>
</li>
<dt><strong><a name="item_pl_last_in_gv">PL_last_in_gv</a></strong>
<dd>
<p>The GV which was last used for a filehandle input operation. (<code><FH></code>)</p>
</dd>
<dd>
<pre>
GV* PL_last_in_gv</pre>
</dd>
</li>
<dt><strong><a name="item_pl_ofs_sv">PL_ofs_sv</a></strong>
<dd>
<p>The output field separator - <a href="../../lib/Pod/perlvar.html#item___"><code>$,</code></a> in Perl space.</p>
</dd>
<dd>
<pre>
SV* PL_ofs_sv</pre>
</dd>
</li>
<dt><strong><a name="item_pl_rs">PL_rs</a></strong>
<dd>
<p>The input record separator - <a href="../../lib/Pod/perlvar.html#item___"><code>$/</code></a> in Perl space.</p>
</dd>
<dd>
<pre>
SV* PL_rs</pre>
</dd>
</li>
</dl>
<p>
</p>
<hr />
<h1><a name="gv_functions">GV Functions</a></h1>
<dl>
<dt><strong><a name="item_is_gv_magical">is_gv_magical</a></strong>
<dd>
<p>Returns <code>TRUE</code> if given the name of a magical GV.</p>
</dd>
<dd>
<p>Currently only useful internally when determining if a GV should be
created even in rvalue contexts.</p>
</dd>
<dd>
<p><a href="../../lib/Pod/perlfunc.html#item_flags"><code>flags</code></a> is not used at present but available for future extension to
allow selecting particular classes of magical variable.</p>
</dd>
<dd>
<p>Currently assumes that <code>name</code> is NUL terminated (as well as len being valid).
This assumption is met by all callers within the perl core, which all pass
pointers returned by SvPV.</p>
</dd>
<dd>
<pre>
bool is_gv_magical(char *name, STRLEN len, U32 flags)</pre>
</dd>
</li>
</dl>
<p>
</p>
<hr />
<h1><a name="io_functions">IO Functions</a></h1>
<dl>
<dt><strong><a name="item_start_glob">start_glob</a></strong>
<dd>
<p>Function called by <code>do_readline</code> to spawn a glob (or do the glob inside
perl on VMS). This code used to be inline, but now perl uses <code>File::Glob</code>
this glob starter is only used by miniperl during the build process.
Moving it away shrinks pp_hot.c; shrinking pp_hot.c helps speed perl up.</p>
</dd>
<dd>
<pre>
PerlIO* start_glob(SV* pattern, IO *io)</pre>
</dd>
</li>
</dl>
<p>
</p>
<hr />
<h1><a name="pad_data_structures">Pad Data Structures</a></h1>
<dl>
<dt><strong><a name="item_cvpadlist">CvPADLIST</a></strong>
<dd>
<p>CV's can have <a href="#item_cvpadlist"><code>CvPADLIST(cv)</code></a> set to point to an AV.</p>
</dd>
<dd>
<p>For these purposes "forms" are a kind-of CV, eval""s are too (except they're
not callable at will and are always thrown away after the eval"" is done
executing).</p>
</dd>
<dd>
<p>XSUBs don't have CvPADLIST set - dXSTARG fetches values from PL_curpad,
but that is really the callers pad (a slot of which is allocated by
every entersub).</p>
</dd>
<dd>
<p>The CvPADLIST AV has does not have AvREAL set, so REFCNT of component items
is managed "manual" (mostly in pad.c) rather than normal av.c rules.
The items in the AV are not SVs as for a normal AV, but other AVs:</p>
</dd>
<dd>
<p>0'th Entry of the CvPADLIST is an AV which represents the "names" or rather
the "static type information" for lexicals.</p>
</dd>
<dd>
<p>The CvDEPTH'th entry of CvPADLIST AV is an AV which is the stack frame at that
depth of recursion into the CV.
The 0'th slot of a frame AV is an AV which is @_.
other entries are storage for variables and op targets.</p>
</dd>
<dd>
<p>During compilation:
<code>PL_comppad_name</code> is set to the names AV.
<code>PL_comppad</code> is set to the frame AV for the frame CvDEPTH == 1.
<code>PL_curpad</code> is set to the body of the frame AV (i.e. AvARRAY(PL_comppad)).</p>
</dd>
<dd>
<p>During execution, <code>PL_comppad</code> and <code>PL_curpad</code> refer to the live
frame of the currently executing sub.</p>
</dd>
<dd>
<p>Iterating over the names AV iterates over all possible pad
items. Pad slots that are SVs_PADTMP (targets/GVs/constants) end up having
&PL_sv_undef "names" (see pad_alloc()).</p>
</dd>
<dd>
<p>Only my/our variable (SVs_PADMY/SVs_PADOUR) slots get valid names.
The rest are op targets/GVs/constants which are statically allocated
or resolved at compile time. These don't have names by which they
can be looked up from Perl code at run time through eval"" like
my/our variables can be. Since they can't be looked up by "name"
but only by their index allocated at compile time (which is usually
in PL_op->op_targ), wasting a name SV for them doesn't make sense.</p>
</dd>
<dd>
<p>The SVs in the names AV have their PV being the name of the variable.
NV+1..IV inclusive is a range of cop_seq numbers for which the name is
valid. For typed lexicals name SV is SVt_PVMG and SvSTASH points at the
type. For <a href="../../lib/Pod/perlfunc.html#item_our"><code>our</code></a> lexicals, the type is SVt_PVGV, and GvSTASH points at the
stash of the associated global (so that duplicate <a href="../../lib/Pod/perlfunc.html#item_our"><code>our</code></a> declarations in the
same package can be detected). SvCUR is sometimes hijacked to
store the generation number during compilation.</p>
</dd>
<dd>
<p>If SvFAKE is set on the name SV then slot in the frame AVs are
a REFCNT'ed references to a lexical from "outside". In this case,
the name SV does not have a cop_seq range, since it is in scope
throughout.</p>
</dd>
<dd>
<p>If the 'name' is '&' the corresponding entry in frame AV
is a CV representing a possible closure.
(SvFAKE and name of '&' is not a meaningful combination currently but could
become so if <code>my sub foo {}</code> is implemented.)</p>
</dd>
<dd>
<p>The flag SVf_PADSTALE is cleared on lexicals each time the <a href="../../lib/Pod/perlfunc.html#item_my"><code>my()</code></a> is executed,
and set on scope exit. This allows the 'Variable $x is not available' warning
to be generated in evals, such as</p>
</dd>
<dd>
<pre>
<span class="operator">{</span> <span class="keyword">my</span> <span class="variable">$x</span> <span class="operator">=</span> <span class="number">1</span><span class="operator">;</span> <span class="keyword">sub</span><span class="variable"> f </span><span class="operator">{</span> <span class="keyword">eval</span> <span class="string">'$x'</span><span class="operator">}</span> <span class="operator">}</span> <span class="variable">f</span><span class="operator">();</span>
</pre>
</dd>
<dd>
<pre>
AV * CvPADLIST(CV *cv)</pre>
</dd>
</li>
<dt><strong><a name="item_cv_clone">cv_clone</a></strong>
<dd>
<p>Clone a CV: make a new CV which points to the same code etc, but which
has a newly-created pad built by copying the prototype pad and capturing
any outer lexicals.</p>
</dd>
<dd>
<pre>
CV* cv_clone(CV* proto)</pre>
</dd>
</li>
<dt><strong><a name="item_cv_dump">cv_dump</a></strong>
<dd>
<p>dump the contents of a CV</p>
</dd>
<dd>
<pre>
void cv_dump(const CV *cv, const char *title)</pre>
</dd>
</li>
<dt><strong><a name="item_do_dump_pad">do_dump_pad</a></strong>
<dd>
<p>Dump the contents of a padlist</p>
</dd>
<dd>
<pre>
void do_dump_pad(I32 level, PerlIO *file, PADLIST *padlist, int full)</pre>
</dd>
</li>
<dt><strong><a name="item_intro_my">intro_my</a></strong>
<dd>
<p>"Introduce" my variables to visible status.</p>
</dd>
<dd>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?