Ruby 4.1 リファレンスマニュアル

instance method RubyVM::InstructionSequence#source_hash

source_hash -> Integer | nilRuby 4.1 から[permalink][rdoc][edit]

self のコンパイル元になったソースのハッシュ値を返します。

ソースが不明な場合は nil を返します。

RubyVM::InstructionSequence#syntax_tree は、この値を使って、再度パースし直したソースが元のソースから変わっていないかどうかを確認します。

iseq = RubyVM::InstructionSequence.compile("x = 1")
p iseq.source_hash.is_a?(Integer) # => true

[SEE_ALSO] RubyVM::InstructionSequence#node_id, RubyVM::InstructionSequence#syntax_tree