るりまサーチ

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

別のキーワード

  1. _builtin rubyvm
  2. rubyvm opts
  3. rubyvm default_params
  4. rubyvm instruction_names
  5. disasm rubyvm::instructionsequence

検索結果

<< 1 2 > >>

RubyVM.resolve_feature_path (21009.0)

require を呼んだときに読み込まれるファイルを特定します。 このメソッドはRuby 2.7 で $LOAD_PATH の特異メソッドに移動しました。

...require を呼んだときに読み込まれるファイルを特定します。
このメソッドはRuby 2.7 で $LOAD_PATH の特異メソッドに移動しました。

//emlist[][ruby]{
p RubyVM.resolve_feature_path('set')
# => [:rb, "/build-all-ruby/2.6.0/lib/ruby/2.6.0/set.rb"]
//}...

RubyVM::InstructionSequence.of(body) -> RubyVM::InstructionSequence (3174.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::InstructionSe...
...quence: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, wor...
...rb
> require '/tmp/iseq_of.rb'

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

# グローバル proc
> RubyVM::InstructionSequence.of($a_global_proc)
> # => #<RubyVM::InstructionSequence:0x007fb73d7caf78>...
...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>...

RubyVM::InstructionSequence.compile_file(file, options = nil) -> RubyVM::InstructionSequence (3150.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>

@see RubyVM::Inst...

RubyVM::InstructionSequence.compile(source, file = nil, path = nil, line = 1, options = nil) -> RubyVM::InstructionSequence (3145.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.new(source, file = nil, path = nil, line = 1, options = nil) -> RubyVM::InstructionSequence (3145.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.load_from_binary(binary) -> RubyVM::InstructionSequence (3138.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::AbstractSyntaxTree.of(proc) -> RubyVM::AbstractSyntaxTree::Node (3117.0)

引数 proc に渡したProcやメソッドオブジェクトの抽象構文木を返します。

...//emlist[][ruby]{
pp RubyVM::AbstractSyntaxTree.of(proc {1 + 2})
# => (SCOPE@2:38-2:45
# tbl: []
# args: nil
# body:
# (OPCALL@2:39-2:44 (LIT@2:39-2:40 1) :+
# (LIST@2:43-2:44 (LIT@2:43-2:44 2) nil)))

def hello
puts "hello, world"
end

pp RubyVM::AbstractSyntaxTree.of...

RubyVM::AbstractSyntaxTree.of(proc, keep_script_lines: false, error_tolerant: false, keep_tokens: false) -> RubyVM::AbstractSyntaxTree::Node (3117.0)

引数 proc に渡したProcやメソッドオブジェクトの抽象構文木を返します。

...//emlist[][ruby]{
pp RubyVM::AbstractSyntaxTree.of(proc {1 + 2})
# => (SCOPE@2:38-2:45
# tbl: []
# args: nil
# body:
# (OPCALL@2:39-2:44 (LIT@2:39-2:40 1) :+
# (LIST@2:43-2:44 (LIT@2:43-2:44 2) nil)))

def hello
puts "hello, world"
end

pp RubyVM::AbstractSyntaxTree.of...

RubyVM::AbstractSyntaxTree.parse(string) -> RubyVM::AbstractSyntaxTree::Node (3117.0)

文字列を抽象構文木にパースし、その木の根ノードを返します。

...します。

//emlist[][ruby]{
pp RubyVM::AbstractSyntaxTree.parse("x = 1 + 2")
# => (SCOPE@1:0-1:9
# tbl: [:x]
# args: nil
# body:
# (LASGN@1:0-1:9 :x
# (OPCALL@1:4-1:9 (LIT@1:4-1:5 1) :+ (LIST@1:8-1:9 (LIT@1:8-1:9 2) nil))))
pp RubyVM::AbstractSyntaxTree.parse("x = 1; p...

RubyVM::AbstractSyntaxTree.parse(string, keep_script_lines: false, error_tolerant: false, keep_tokens: false) -> RubyVM::AbstractSyntaxTree::Node (3117.0)

文字列を抽象構文木にパースし、その木の根ノードを返します。

...します。

//emlist[][ruby]{
pp RubyVM::AbstractSyntaxTree.parse("x = 1 + 2")
# => (SCOPE@1:0-1:9
# tbl: [:x]
# args: nil
# body:
# (LASGN@1:0-1:9 :x
# (OPCALL@1:4-1:9 (LIT@1:4-1:5 1) :+ (LIST@1:8-1:9 (LIT@1:8-1:9 2) nil))))
pp RubyVM::AbstractSyntaxTree.parse("x = 1; p...

絞り込み条件を変える

RubyVM::AbstractSyntaxTree.parse_file(pathname) -> RubyVM::AbstractSyntaxTree::Node (3117.0)

pathname のファイルを読み込み、その内容を抽象構文木にパースし、その木の根ノードを返します。

...

//emlist[][ruby]{
pp RubyVM::AbstractSyntaxTree.parse_file(__FILE__)
# => (SCOPE@1:0-1:50
# tbl: []
# args: nil
# body:
# (FCALL@1:0-1:50 :pp
# (LIST@1:3-1:50
# (CALL@1:3-1:50
# (COLON2@1:3-1:29 (CONST@1:3-1:9 :RubyVM) :AbstractSyntaxTree)
#...

RubyVM::AbstractSyntaxTree.parse_file(pathname, keep_script_lines: false, error_tolerant: false, keep_tokens: false) -> RubyVM::AbstractSyntaxTree::Node (3117.0)

pathname のファイルを読み込み、その内容を抽象構文木にパースし、その木の根ノードを返します。

...

//emlist[][ruby]{
pp RubyVM::AbstractSyntaxTree.parse_file(__FILE__)
# => (SCOPE@1:0-1:50
# tbl: []
# args: nil
# body:
# (FCALL@1:0-1:50 :pp
# (LIST@1:3-1:50
# (CALL@1:3-1:50
# (COLON2@1:3-1:29 (CONST@1:3-1:9 :RubyVM) :AbstractSyntaxTree)
#...

RubyVM::AbstractSyntaxTree.of(proc) -> RubyVM::AbstractSyntaxTree::Node (3116.0)

引数 proc に渡したProcやメソッドオブジェクトの抽象構文木を返します。

...//emlist[][ruby]{
pp RubyVM::AbstractSyntaxTree.of(proc {1 + 2})
# => (SCOPE@2:38-2:45
# tbl: []
# args: nil
# body:
# (OPCALL@2:39-2:44 (LIT@2:39-2:40 1) :+
# (LIST@2:43-2:44 (LIT@2:43-2:44 2) nil)))

def hello
puts "hello, world"
end

pp RubyVM::AbstractSyntaxTree.of...

RubyVM::AbstractSyntaxTree.parse_file(pathname) -> RubyVM::AbstractSyntaxTree::Node (3116.0)

pathname のファイルを読み込み、その内容を抽象構文木にパースし、その木の根ノードを返します。

...

//emlist[][ruby]{
pp RubyVM::AbstractSyntaxTree.parse_file(__FILE__)
# => (SCOPE@1:0-1:50
# tbl: []
# args: nil
# body:
# (FCALL@1:0-1:50 :pp
# (LIST@1:3-1:50
# (CALL@1:3-1:50
# (COLON2@1:3-1:29 (CONST@1:3-1:9 :RubyVM) :AbstractSyntaxTree)
#...

RubyVM::AbstractSyntaxTree.parse(string) -> RubyVM::AbstractSyntaxTree::Node (3110.0)

文字列を抽象構文木にパースし、その木の根ノードを返します。

...列で指定します。
@raise SyntaxError string が Ruby のコードとして正しくない場合に発生します。

//emlist[][ruby]{
pp RubyVM::AbstractSyntaxTree.parse("x = 1 + 2")
# => (SCOPE@1:0-1:9
# tbl: [:x]
# args: nil
# body:
# (LASGN@1:0-1:9 :x
# (OPCALL...

絞り込み条件を変える

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

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

...
RubyVM
::InstructionSequence オブジェクトを人間が読める形式の文字
列に変換して返します。

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

例1:Proc オブジェクトを指定した場合

# /tmp/proc.rb
p = proc { num = 1 + 2 }
puts RubyVM::I...
...nstructionSequence.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: 0000 cont: 0012
|--------------------------------------------...
...オブジェクトを指定した場合

# /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 (3049.0)

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

...
RubyVM
::InstructionSequence オブジェクトを人間が読める形式の文字
列に変換して返します。

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

例1:Proc オブジェクトを指定した場合

# /tmp/proc.rb
p = proc { num = 1 + 2 }
puts RubyVM::I...
...nstructionSequence.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: 0000 cont: 0012
|--------------------------------------------...
...オブジェクトを指定した場合

# /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...
<< 1 2 > >>