目錄

名稱

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

對於每個定義,這會提供對使用該標記的 op 名稱陣列的參考。

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