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

singleton method RubyVM::InstructionSequence.compile_file_prism

compile_file_prism(file, options = nil) -> RubyVM::InstructionSequenceRuby 3.3 から[permalink][rdoc][edit]

引数 file で指定した Ruby のソースコードを構文解析器 Prism でパースしてコンパイルし、 RubyVM::InstructionSequence オブジェクトを作成して返します。

RubyVM::InstructionSequence.compile_file とは異なり、常に Prism でパースします。

[PARAM] file:
ファイル名を文字列で指定します。
[PARAM] options:
コンパイル時のオプションを true、false、Hash オブジェクトのいずれかで指定します。詳細は RubyVM::InstructionSequence.compile_option= を参照してください。
# /tmp/hello.rb
puts "Hello, world!"

iseq = RubyVM::InstructionSequence.compile_file_prism("/tmp/hello.rb")
iseq.eval
# => Hello, world!

[SEE_ALSO] RubyVM::InstructionSequence.compile_file