Skip to content
Permalink
Browse files
cleanup Method#for_define_method and UnboundMethod#for_define_method,…
… delegate responsibility further to executables
  • Loading branch information
tak1n committed Feb 5, 2016
1 parent 510919d commit 7cd43157d6efe0a4b4a534ef944df8563a062979
Showing with 24 additions and 31 deletions.
  1. +6 −0 core/block_environment.rb
  2. +6 −0 core/compiled_code.rb
  3. +4 −0 core/delegated_method.rb
  4. +2 −31 core/method.rb
  5. +6 −0 core/native_method.rb
@@ -102,6 +102,12 @@ def file
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]
end
end

def from_proc?
@@ -212,6 +212,12 @@ 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
@@ -31,5 +31,9 @@ def parameters
def source_location
@receiver.source_location
end

def for_define_method(name, meth)
[self, nil]
end
end
end
@@ -175,25 +175,8 @@ def super_method
def for_define_method(name, klass)
Rubinius::Type.bindable_method? self.defined_in, klass

# We see through delegated methods because code creates these crazy calls
# to define_method over and over again and if we don't check, we create
# a huge delegated method chain. So instead, just see through them at one
# level always.
if @executable.kind_of? Rubinius::DelegatedMethod
code = @executable
scope = nil
else
code = Rubinius::DelegatedMethod.new(name, :call_on_instance, self.unbind, true)
if @executable.kind_of? Rubinius::CompiledCode
scope = @executable.scope
else
scope = nil
end
end

[code, scope]
@executable.for_define_method(name, self.unbind)
end

end

##
@@ -342,18 +325,6 @@ def super_method
def for_define_method(name, klass)
Rubinius::Type.bindable_method? self.defined_in, klass

if @executable.kind_of? Rubinius::DelegatedMethod
code = @executable
scope = nil
else
code = Rubinius::DelegatedMethod.new(name, :call_on_instance, self, true)
if @executable.kind_of? Rubinius::CompiledCode
scope = @executable.scope
else
scope = nil
end
end

[code, scope]
@executable.for_define_method(name, self)
end
end
@@ -78,5 +78,11 @@ def defined_line
def active_path
@file
end

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

[code, nil]
end
end
end

0 comments on commit 7cd4315

Please sign in to comment.