るりまサーチ

最速Rubyリファレンスマニュアル検索!
119件ヒット [1-100件を表示] (0.089秒)
トップページ > クエリ:>[x] > 種類:インスタンスメソッド[x] > クラス:RubyVM::InstructionSequence[x]

別のキーワード

  1. _builtin >
  2. bigdecimal >
  3. float >
  4. module >
  5. complex >

ライブラリ

キーワード

検索結果

<< 1 2 > >>

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

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

...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 (114.0)

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

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

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

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

# irb
>
is...
...eq = 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#label -> String (114.0)

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

..."<main>" を返します。self を文字列から作成していた場合
は "<compiled>" を返します。

例1:irb で実行した場合

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

...
...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 (114.0)

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

...ていた
場合は "<compiled>" を返します。

例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#disasm -> String (108.0)

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

...s 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 (108.0)

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

...s 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 (102.0)

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

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

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

RubyVM::InstructionSequence#first_lineno -> Integer (102.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 (102.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#to_a -> Array (102.0)

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

...シーケンスのラ
ベル。トップレベルでは "<main>"。文字列から作成していた場合は
"<compiled>"。

: #path

命令シーケンスの相対パス。文字列から作成していた場合は "<compiled>"。

: #absolute_path

命令シーケンスの絶対パス。...
...[ruby]{
require 'pp'

iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
pp iseq.to_a
# ※ Ruby 2.5.0 での実行結果
# => ["YARVInstructionSequence/SimpleDataFormat",
# 2,
# 0,
# 1,
# {:arg_size=>0, :local_size=>2, :stack_max=>2},
# "<compiled>",
# "<compiled>",
# nil,
# 1,
# :top,
# [:n...
...um],
# 0,
# [],
# [1,
# [:trace, 1],
# [:putobject_OP_INT2FIX_O_1_C_],
# [:putobject, 2],
# [:opt_plus, {:mid=>:+, :flag=>256, :orig_argc=>1, :blockptr=>nil}],
# [:dup],
# [:setlocal_OP__WC__0, 2],
# [:leave]]]
//}...

絞り込み条件を変える

<< 1 2 > >>