内容

名称

B::Op_private - OP op_private 标志定义

概要

use B::Op_private;

# flag details for bit 7 of OP_AELEM's op_private:
my $name  = $B::Op_private::bits{aelem}{7}; # OPpLVAL_INTRO
my $value = $B::Op_private::defines{$name}; # 128
my $label = $B::Op_private::labels{$name};  # LVINTRO

# the bit field at bits 5..6 of OP_AELEM's op_private:
my $bf  = $B::Op_private::bits{aelem}{6};
my $mask = $bf->{bitmask}; # etc

描述

此模块提供四个全局哈希

%B::Op_private::bits
%B::Op_private::defines
%B::Op_private::labels
%B::Op_private::ops_using

它们包含有关 op_private 字段中每个操作位含义的信息。

%bits

它以操作名称和位号 (0..7) 为索引。对于单个位标志,它返回该位的定义名称(如果有)。

$B::Op_private::bits{aelem}{7} eq 'OPpLVAL_INTRO';

对于位域,它返回一个包含位域详细信息的哈希引用。对于构成位域的所有位位置,将返回相同的引用;例如,以下两者都返回相同的哈希引用

$bitfield = $B::Op_private::bits{aelem}{5};
$bitfield = $B::Op_private::bits{aelem}{6};

此哈希引用的常规格式为

{
    # The bit range and mask; these are always present.
    bitmin        => 5,
    bitmax        => 6,
    bitmask       => 0x60,

    # (The remaining keys are optional)

    # The names of any defines that were requested:
    mask_def      => 'OPpFOO_MASK',
    baseshift_def => 'OPpFOO_SHIFT',
    bitcount_def  => 'OPpFOO_BITS',

    # If present, Concise etc will display the value with a 'FOO='
    # prefix. If it equals '-', then Concise will treat the bit
    # field as raw bits and not try to interpret it.
    label         => 'FOO',

    # If present, specifies the names of some defines and the
    # display labels that are used to assign meaning to particu-
    # lar integer values within the bit field; e.g. 3 is dis-
    # played as 'C'.
    enum          => [ qw(
                         1   OPpFOO_A  A
                         2   OPpFOO_B  B
                         3   OPpFOO_C  C
                     )],

};

%defines

这将给出每个 OPp 定义的值,例如:

$B::Op_private::defines{OPpLVAL_INTRO} == 128;

%labels

这将给出每个定义的简短显示标签,如 B::Conciseperl -Dx 所使用,例如:

$B::Op_private::labels{OPpLVAL_INTRO} eq 'LVINTRO';

如果标签等于 '-',则 Concise 将把该位视为原始位,而不是尝试以符号方式显示它。

%ops_using

对于每个定义,这将给出对使用该标志的操作符名称数组的引用。

@ops_using_lvintro = @{ $B::Op_private::ops_using{OPp_LVAL_INTRO} };