るりまサーチ (Ruby 2.6.0)

最速Rubyリファレンスマニュアル検索!
21件ヒット [1-21件を表示] (0.196秒)
トップページ > ライブラリ:ビルトイン[x] > バージョン:2.6.0[x] > クエリ:_builtin[x] > クラス:RubyVM::InstructionSequence[x]

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

検索結果

RubyVM::InstructionSequence#absolute_path -> String | nil (24010.0)

self が表す命令シーケンスの絶対パスを返します。

...l を返します。

例1:irb で実行した場合

iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
# => <RubyVM::InstructionSequence:<compiled>@<compiled>>
iseq.absolute_path
# => nil

例2: RubyVM::InstructionSequence.compile_file を使用した場合

# /tmp/method.rb
def...
...hello
puts "hello, world"
end

# irb
> iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb')
> iseq.absolute_path # => "/tmp/method.rb"

@see RubyVM::InstructionSequence#path...

RubyVM::InstructionSequence#base_label -> String (24010.0)

self が表す命令シーケンスの基本ラベルを返します。

...返します。

例1:irb で実行した場合

iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
# => <RubyVM::InstructionSequence:<compiled>@<compiled>>
iseq.base_label
# => "<compiled>"

例2: RubyVM::InstructionSequence.compile_file を使用した場合

# /tmp/method.rb
de...
...# irb
> iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb')
> iseq.base_label # => "<main>"

例3:

# /tmp/method2.rb
def hello
puts "hello, world"
end

RubyVM::InstructionSequence
.of(method(:hello)).base_label
# => "hello"

@see RubyVM::InstructionSequence#label...

RubyVM::InstructionSequence#disasm -> String (24010.0)

self が表す命令シーケンスを人間が読める形式の文字列に変換して返します。

...命令シーケンスを人間が読める形式の文字列に変換して返します。

puts RubyVM::InstructionSequence.compile('1 + 2').disasm

出力:

== disasm: <RubyVM::InstructionSequence:<compiled>@<compiled>>==========
0000 trace 1...
...( 1)
0002 putobject 1
0004 putobject 2
0006 opt_plus <ic:1>
0008 leave

@see RubyVM::InstructionSequence.disasm...

RubyVM::InstructionSequence#disassemble -> String (24010.0)

self が表す命令シーケンスを人間が読める形式の文字列に変換して返します。

...命令シーケンスを人間が読める形式の文字列に変換して返します。

puts RubyVM::InstructionSequence.compile('1 + 2').disasm

出力:

== disasm: <RubyVM::InstructionSequence:<compiled>@<compiled>>==========
0000 trace 1...
...( 1)
0002 putobject 1
0004 putobject 2
0006 opt_plus <ic:1>
0008 leave

@see RubyVM::InstructionSequence.disasm...

RubyVM::InstructionSequence#eval -> object (24010.0)

self の命令シーケンスを評価してその結果を返します。

...self の命令シーケンスを評価してその結果を返します。

RubyVM::InstructionSequence
.compile("1 + 2").eval # => 3...

絞り込み条件を変える

RubyVM::InstructionSequence#first_lineno -> Integer (24010.0)

self が表す命令シーケンスの 1 行目の行番号を返します。

...の 1 行目の行番号を返します。

例1:irb で実行した場合

RubyVM::InstructionSequence
.compile('num = 1 + 2').first_lineno
# => 1

例2:

# /tmp/method.rb
require "foo-library"
def foo
p :foo
end

RubyVM::InstructionSequence
.of(method(:foo)).first_lineno
# => 2...

RubyVM::InstructionSequence#inspect -> String (24010.0)

self の情報をラベルとパスを含んだ人間に読みやすい文字列にして返します。

...んだ人間に読みやすい文字列にして返します。

//emlist[例][ruby]{
iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
iseq.inspect # => "<RubyVM::InstructionSequence:<compiled>@<compiled>>"
//}

@see RubyVM::InstructionSequence#label,
RubyVM::InstructionSequence
#path...

RubyVM::InstructionSequence#label -> String (24010.0)

self が表す命令シーケンスのラベルを返します。通常、メソッド名、クラス名、 モジュール名などで構成されます。

...を返します。

例1:irb で実行した場合

iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
# => <RubyVM::InstructionSequence:<compiled>@<compiled>>
iseq.label
# => "<compiled>"

例2: RubyVM::InstructionSequence.compile_file を使用した場合

# /tmp/method.rb
def...
...end

# irb
> iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb')
> iseq.label # => "<main>"

例3:

# /tmp/method2.rb
def hello
puts "hello, world"
end

RubyVM::InstructionSequence
.of(method(:hello)).label
# => "hello"

@see RubyVM::InstructionSequence#base_label...

RubyVM::InstructionSequence#path -> String (24010.0)

self が表す命令シーケンスの相対パスを返します。

..." を返します。

例1:irb で実行した場合

iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
# => <RubyVM::InstructionSequence:<compiled>@<compiled>>
iseq.path
# => "<compiled>"

例2: RubyVM::InstructionSequence.compile_file を使用した場合

# /tmp/method.rb
def...
...hello
puts "hello, world"
end

# irb
> iseq = RubyVM::InstructionSequence.compile_file('method.rb')
> iseq.path # => "method.rb"

@see RubyVM::InstructionSequence#absolute_path...

RubyVM::InstructionSequence#to_a -> Array (24010.0)

self の情報を 14 要素の配列にして返します。

...ytecode

命令シーケンスを構成する命令とオペランドの配列の配列。


//emlist[例][ruby]{
require 'pp'

iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
pp iseq.to_a
# ※ Ruby 2.5.0 での実行結果
# => ["YARVInstructionSequence/SimpleDataFormat",
# 2,
# 0,
# 1...

絞り込み条件を変える

RubyVM::InstructionSequence#to_binary(extra_data = nil) -> String (24010.0)

バイナリフォーマットでシリアライズされたiseqのデータを文字列として返します。 RubyVM::InstructionSequence.load_from_binary メソッドでバイナリデータに対応するiseqオブジェクトを作れます。

...列として返します。
RubyVM::InstructionSequence
.load_from_binary メソッドでバイナリデータに対応するiseqオブジェクトを作れます。

引数の extra_data はバイナリデータと共に保存されます。
RubyVM::InstructionSequence
.load_from_binary_extra_data...
...ョンや他のアーキテクチャのRubyで作られたバイナリデータは使用できません。

//emlist[例][ruby]{
iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
iseq.to_binary("extra_data")

# ※表示の都合上改行しているが実際は改行はない
# => "YARB\x02...
...0\x00numE\x7F\x00\x00\x02\x00\x00\x00\x00
# \x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00+\xA0\x01\x00\x00\xAC\x01\x00
# \x00\xCA\x01\x00\x00\xD6\x01\x00\x00\xED\x01\x00\x00extra_data"
//}

@see RubyVM::InstructionSequence.load_from_binary
@see RubyVM::InstructionSequence.load_from_binary_extra_data...

RubyVM::InstructionSequence.compile(source, file = nil, path = nil, line = 1, options = nil) -> RubyVM::InstructionSequence (24010.0)

引数 source で指定した Ruby のソースコードを元にコンパイル済みの RubyVM::InstructionSequence オブジェクトを作成して返します。

...引数 source で指定した Ruby のソースコードを元にコンパイル済みの
RubyVM::InstructionSequence
オブジェクトを作成して返します。

@param source Ruby のソースコードを文字列で指定します。

@param file ファイル名を文字列で指定しま...
...かで指定します。詳細は
RubyVM::InstructionSequence
.compile_option= を参照
してください。

RubyVM::InstructionSequence
.compile("a = 1 + 2")
# => <RubyVM::InstructionSequence:<compiled>@<compiled>>

@see RubyVM::InstructionSequence.compile_file...

RubyVM::InstructionSequence.compile_file(file, options = nil) -> RubyVM::InstructionSequence (24010.0)

引数 file で指定した Ruby のソースコードを元にコンパイル済みの RubyVM::InstructionSequence オブジェクトを作成して返します。

...引数 file で指定した Ruby のソースコードを元にコンパイル済みの
RubyVM::InstructionSequence
オブジェクトを作成して返します。

RubyVM::InstructionSequence
.compile とは異なり、file、path などの
メタデータは自動的に取得します。

@param...
...定します。詳細は
RubyVM::InstructionSequence
.compile_option= を参照
してください。

# /tmp/hello.rb
puts "Hello, world!"

# irb
RubyVM::InstructionSequence
.compile_file("/tmp/hello.rb")
# => <RubyVM::InstructionSequence:<main>@/tmp/hello.rb>...

RubyVM::InstructionSequence.compile_option -> Hash (24010.0)

命令シーケンスのコンパイル時のデフォルトの最適化オプションを Hash で返 します。

...スのコンパイル時のデフォルトの最適化オプションを Hash で返
します。

//emlist[例][ruby]{
require "pp"
pp RubyVM::InstructionSequence.compile_option

# => {:inline_const_cache=>true,
# :peephole_optimization=>true,
# :tailcall_optimization=>false,
# :specialized_instruc...
...>true,
# :operands_unification=>true,
# :instructions_unification=>false,
# :stack_caching=>false,
# :trace_instruction=>true,
# :frozen_string_literal=>false,
# :debug_frozen_string_literal=>false,
# :coverage_enabled=>true,
# :debug_level=>0}
//}

@see RubyVM::InstructionSequence.compile_option=...

RubyVM::InstructionSequence.compile_option=(options) (24010.0)

命令シーケンスのコンパイル時のデフォルトの最適化オプションを引数 options で指定します。

...compile、.compile_file メソッドの実行の際に option 引数を指定し
た場合はその実行のみ最適化オプションを変更する事もできます。

@see RubyVM::InstructionSequence.new,
RubyVM::InstructionSequence
.compile,
RubyVM::InstructionSequence
.compile_file...

絞り込み条件を変える

RubyVM::InstructionSequence.disasm(body) -> String (24010.0)

引数 body で指定したオブジェクトから作成した RubyVM::InstructionSequence オブジェクトを人間が読める形式の文字 列に変換して返します。

...引数 body で指定したオブジェクトから作成した
RubyVM::InstructionSequence
オブジェクトを人間が読める形式の文字
列に変換して返します。

@param body Proc、Method オブジェクトを指定します。

例1:Proc オブジェクトを指定した場合...
...# /tmp/proc.rb
p = proc { num = 1 + 2 }
puts RubyVM::InstructionSequence.disasm(p)

出力:

== disasm: <RubyVM::InstructionSequence:block in <main>@/tmp/proc.rb>===
== catch table
| catch type: redo st: 0000 ed: 0012 sp: 0000 cont: 0000
| catch type: next st: 0000 ed: 0012 sp: 00...
...クトを指定した場合

# /tmp/method.rb
def hello
puts "hello, world"
end

puts RubyVM::InstructionSequence.disasm(method(:hello))

出力:

== disasm: <RubyVM::InstructionSequence:hello@/tmp/method.rb>============
0000 trace 8...

RubyVM::InstructionSequence.disassemble(body) -> String (24010.0)

引数 body で指定したオブジェクトから作成した RubyVM::InstructionSequence オブジェクトを人間が読める形式の文字 列に変換して返します。

...引数 body で指定したオブジェクトから作成した
RubyVM::InstructionSequence
オブジェクトを人間が読める形式の文字
列に変換して返します。

@param body Proc、Method オブジェクトを指定します。

例1:Proc オブジェクトを指定した場合...
...# /tmp/proc.rb
p = proc { num = 1 + 2 }
puts RubyVM::InstructionSequence.disasm(p)

出力:

== disasm: <RubyVM::InstructionSequence:block in <main>@/tmp/proc.rb>===
== catch table
| catch type: redo st: 0000 ed: 0012 sp: 0000 cont: 0000
| catch type: next st: 0000 ed: 0012 sp: 00...
...クトを指定した場合

# /tmp/method.rb
def hello
puts "hello, world"
end

puts RubyVM::InstructionSequence.disasm(method(:hello))

出力:

== disasm: <RubyVM::InstructionSequence:hello@/tmp/method.rb>============
0000 trace 8...

RubyVM::InstructionSequence.load_from_binary(binary) -> RubyVM::InstructionSequence (24010.0)

RubyVM::InstructionSequence#to_binaryにより作られたバイナリフォーマットの文字列からiseqのオブジェクトをロードします。

...
RubyVM::InstructionSequence
#to_binaryにより作られたバイナリフォーマットの文字列からiseqのオブジェクトをロードします。

このローダーは検証機構をもっておらず、壊れたり改変されたバイナリを読み込むと深刻な問題を引き起...
...りません。自分が変換したバイナリデータを使うべきです。

//emlist[例][ruby]{
iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
binary = iseq.to_binary
RubyVM::InstructionSequence
.load_from_binary(binary).eval # => 3
//}

@see RubyVM::InstructionSequence#to_binary...

RubyVM::InstructionSequence.load_from_binary_extra_data(binary) -> String (24010.0)

バイナリフォーマットの文字列から埋め込まれたextra_dataを取り出します。

...埋め込まれたextra_dataを取り出します。

//emlist[例][ruby]{
iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
binary = iseq.to_binary("extra_data")
RubyVM::InstructionSequence
.load_from_binary_extra_data(binary) # => extra_data
//}

@see RubyVM::InstructionSequence#to_binary...

RubyVM::InstructionSequence.new(source, file = nil, path = nil, line = 1, options = nil) -> RubyVM::InstructionSequence (24010.0)

引数 source で指定した Ruby のソースコードを元にコンパイル済みの RubyVM::InstructionSequence オブジェクトを作成して返します。

...引数 source で指定した Ruby のソースコードを元にコンパイル済みの
RubyVM::InstructionSequence
オブジェクトを作成して返します。

@param source Ruby のソースコードを文字列で指定します。

@param file ファイル名を文字列で指定しま...
...かで指定します。詳細は
RubyVM::InstructionSequence
.compile_option= を参照
してください。

RubyVM::InstructionSequence
.compile("a = 1 + 2")
# => <RubyVM::InstructionSequence:<compiled>@<compiled>>

@see RubyVM::InstructionSequence.compile_file...

絞り込み条件を変える

RubyVM::InstructionSequence.of(body) -> RubyVM::InstructionSequence (24010.0)

引数 body で指定した Proc、Method オブジェクトを元に RubyVM::InstructionSequence オブジェクトを作成して返します。

...
RubyVM::InstructionSequence
オブジェクトを作成して返します。

@param body Proc、Method オブジェクトを指定します。

例1:irb で実行した場合

# proc
> p = proc { num = 1 + 2 }
> RubyVM::InstructionSequence.of(p)
> # => <RubyVM::InstructionSequence:block...
...in irb_binding@(irb)>

# method
> def foo(bar); puts bar; end
> RubyVM::InstructionSequence.of(method(:foo))
> # => <RubyVM::InstructionSequence:foo@(irb)>

例2: RubyVM::InstructionSequence.compile_file を使用した場合

# /tmp/iseq_of.rb
def hello
puts "hello, world"
end...
...irb
> require '/tmp/iseq_of.rb'

# hello メソッド
> RubyVM::InstructionSequence.of(method(:hello))
> # => #<RubyVM::InstructionSequence:0x007fb73d7cb1d0>

# グローバル proc
> RubyVM::InstructionSequence.of($a_global_proc)
> # => #<RubyVM::InstructionSequence:0x007fb73d7caf78>...