るりまサーチ

最速Rubyリファレンスマニュアル検索!
273件ヒット [1-100件を表示] (0.021秒)
トップページ > クラス:RubyVM::InstructionSequence[x]

ライブラリ

キーワード

検索結果

<< 1 2 3 > >>

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

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

...ます。

例1:irb で実行した場合

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

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

```console
# /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** [m:RubyVM::InstructionSequence#path]...

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

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

...す。

例1:irb で実行した場合

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

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

```console
# /t...
...seq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb')
> iseq.base_label # => "<main>"
```

```ruby title="例3"
# /tmp/method2.rb
def hello
puts "hello, world"
end

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

- **SEE** [m:RubyVM::InstructionSequence#lab...

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

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

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

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

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

- **SEE** [m:RubyVM::InstructionSequence.disasm]...

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

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

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

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

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

- **SEE** [m:RubyVM::InstructionSequence.disasm]...

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

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

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

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

絞り込み条件を変える

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

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

...番号を返します。

例1:irb で実行した場合

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

```ruby title="例2"
# /tmp/method.rb
require "foo-library"
def foo
p :foo
end

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

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

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

...読みやすい文字列にして返します。

```ruby title="例"
iseq = RubyVM::InstructionSequence.compile('num = 1 + 2')
p iseq.inspect # => "<RubyVM::InstructionSequence:<compiled>@<compiled>>"
```

- **SEE** [m:RubyVM::InstructionSequence#label],
[m:RubyVM::InstructionSequence#path]...

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

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

...す。

例1:irb で実行した場合

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

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

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

```ruby title="例3"
# /tmp/method2.rb
def hello
puts "hello, world"
end

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

- **SEE** [m:RubyVM::InstructionSequence#base_lab...
<< 1 2 3 > >>