Skip to content
Permalink
Browse files
implement Executable#scope, retrieving proper code part is responsibi…
…lity of Method,UnboundMethod #for_define_method, add 3rd arg callabale_proc to Method,UnboundMethod #for_define_method
  • Loading branch information
tak1n committed Feb 5, 2016
1 parent 7cd4315 commit 5d2f0542a78db70c6cdf08a9080d2caf9f234954
Showing with 34 additions and 20 deletions.
  1. +2 −4 core/block_environment.rb
  2. +0 −6 core/compiled_code.rb
  3. +2 −2 core/delegated_method.rb
  4. +28 −4 core/method.rb
  5. +2 −4 core/native_method.rb
@@ -103,10 +103,8 @@ def defined_line
@block_env.line
end

def for_define_method(name, meth)
code = Rubinius::DelegatedMethod.new(name, :call_on_instance, meth, true)

[code, nil]
def scope
nil
end
end

@@ -212,12 +212,6 @@ def breakpoint?(ip)
raise ArgumentError, "Unable to retrieve breakpoint status on #{inspect} at bytecode address #{ip}"
end

def for_define_method(name, meth)
code = Rubinius::DelegatedMethod.new(name, :call_on_instance, meth, true)

[code, @scope]
end

class Script
attr_accessor :compiled_code
attr_accessor :file_path
@@ -32,8 +32,8 @@ def source_location
@receiver.source_location
end

def for_define_method(name, meth)
[self, nil]
def scope
nil
end
end
end
@@ -172,10 +172,22 @@ def super_method
return nil
end

def for_define_method(name, klass)
def for_define_method(name, klass, callable_proc = nil)
Rubinius::Type.bindable_method? self.defined_in, klass

@executable.for_define_method(name, self.unbind)
scope = @executable.scope

if @executable.is_a? Rubinius::DelegatedMethod
code = @executable
else
if callable_proc
code = Rubinius::DelegatedMethod.new(name, :call, callable_proc, false)
else
code = Rubinius::DelegatedMethod.new(name, :call_on_instance, self.unbind, true)
end
end

[code, scope]
end
end

@@ -322,9 +334,21 @@ def super_method
return nil
end

def for_define_method(name, klass)
def for_define_method(name, klass, callable_proc = nil)
Rubinius::Type.bindable_method? self.defined_in, klass

@executable.for_define_method(name, self)
scope = @executable.scope

if @executable.is_a? Rubinius::DelegatedMethod
code = @executable
else
if callable_proc
code = Rubinius::DelegatedMethod.new(name, :call, callable_proc, false)
else
code = Rubinius::DelegatedMethod.new(name, :call_on_instance, self, true)
end
end

[code, scope]
end
end
@@ -79,10 +79,8 @@ def active_path
@file
end

def for_define_method(name, meth)
code = Rubinius::DelegatedMethod.new(name, :call_on_instance, meth, true)

[code, nil]
def scope
nil
end
end
end

0 comments on commit 5d2f054

Please sign in to comment.