Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rubinius/rubinius
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: e3cf7d9b3307
Choose a base ref
...
head repository: rubinius/rubinius
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 29ad4f66816d
Choose a head ref

Commits on Feb 5, 2016

  1. Moved ARGF.read encoding specs to shared spec file

    Yorick Peterse committed Feb 5, 2016
    Copy the full SHA
    cb7ee92 View commit details
  2. ARGF.read should use ASCII 8BIT, not US_ASCII

    Yorick Peterse committed Feb 5, 2016
    Copy the full SHA
    05f2a7e View commit details
  3. Added specs for ARGF.read_nonblock

    Yorick Peterse committed Feb 5, 2016
    Copy the full SHA
    68ab57c View commit details
  4. Added ARGF.read_nonblock

    Fixes #3594
    Yorick Peterse committed Feb 5, 2016
    Copy the full SHA
    391db8d View commit details
  5. Added local variable methods to Binding

    This adds the following methods:
    
    * Binding#local_variable_set
    * Binding#local_variable_get
    * Binding#local_variable_defined?
    
    Fixes #2992
    Closes #3372
    Yorick Peterse committed Feb 5, 2016
    Copy the full SHA
    40f04c1 View commit details
  6. Fix Module#define_method

    When defining a method through a proc which gets created out of a method
    which is defined in a C-ext, `meth.ruby_method.executable` is a instance of
    Rubinius::NativeCode and not Rubinius::CompiledCode which does not
    respond to #scope.
    
    This is used for example in pg gem:
    https://github.com/ged/ruby-pg/blob/bb4693e811f9348f202835e701e6509d15685b0a/lib/pg/connection.rb#L187
    tak1n committed Feb 5, 2016
    Copy the full SHA
    d436251 View commit details
  7. Copy the full SHA
    040c726 View commit details
  8. implement Method#for_define_method, add second argument klass to for_…

    …define_method which is needed by Method and UnboundMethod
    tak1n committed Feb 5, 2016
    Copy the full SHA
    2e501b5 View commit details
  9. Copy the full SHA
    3f9756b View commit details
  10. Copy the full SHA
    510919d View commit details
  11. cleanup Method#for_define_method and UnboundMethod#for_define_method,…

    … delegate responsibility further to executables
    tak1n committed Feb 5, 2016
    Copy the full SHA
    7cd4315 View commit details
  12. 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
    tak1n committed Feb 5, 2016
    Copy the full SHA
    5d2f054 View commit details
  13. Copy the full SHA
    1a68fda View commit details

Commits on Feb 6, 2016

  1. Proc#for_define_method get the scope through the newly created BlockE…

    …nvironment::AsMethod
    tak1n committed Feb 6, 2016
    Copy the full SHA
    21bede5 View commit details
  2. add example which specs behavior of Proc#for_define_method when procs…

    … @ruby_method is set
    tak1n committed Feb 6, 2016
    Copy the full SHA
    7a8f1dc View commit details
  3. Copy the full SHA
    161a787 View commit details
  4. Copy the full SHA
    d59ca90 View commit details

Commits on Feb 7, 2016

  1. Implement Proc#for_define_method when @ruby_method is nil like in the…

    … old impl to ensure the same behavior
    tak1n committed Feb 7, 2016
    Copy the full SHA
    eb465ca View commit details

Commits on Feb 8, 2016

  1. Merge pull request #3617 from rubinius/clean_up_define_method

    Clean up define method
    tak1n committed Feb 8, 2016
    Copy the full SHA
    e2d1437 View commit details

Commits on Feb 9, 2016

  1. Copy the full SHA
    f9589ca View commit details
  2. Copy the full SHA
    61127a5 View commit details
  3. 2
    Copy the full SHA
    ca3bfcd View commit details
  4. Copy the full SHA
    6e9bf80 View commit details

Commits on Feb 10, 2016

  1. Copy the full SHA
    750dea0 View commit details

Commits on Feb 11, 2016

  1. Copy the full SHA
    df6783d View commit details
  2. Copy the full SHA
    c700fb3 View commit details

Commits on Feb 12, 2016

  1. Added NameError#receiver

    MRI seems to handle this within C and doesn't define any way of setting
    the receiver from Ruby. As a result of this we'll just use a keyword
    argument.
    
    Fixes #3607
    Yorick Peterse committed Feb 12, 2016
    Copy the full SHA
    b372185 View commit details
  2. Added String#-@ and String#+@

    Fixes #3608
    Yorick Peterse committed Feb 12, 2016
    Copy the full SHA
    0d7dd0c View commit details
  3. Fixed NameError#receiver for BasicObject instances

    Yorick Peterse committed Feb 12, 2016
    Copy the full SHA
    8b7d91b View commit details
  4. ObjectSpace._id2ref raises for invalid ID values

    Fixes #3504
    Yorick Peterse committed Feb 12, 2016
    Copy the full SHA
    89cf641 View commit details
  5. Copy the full SHA
    9429ac3 View commit details
  6. Updated list of Gems to install

    In particular this includes rubysl-stringio 2.1.0
    Yorick Peterse committed Feb 12, 2016
    Copy the full SHA
    9765ca9 View commit details

Commits on Feb 15, 2016

  1. Use ascii_only_p() instead of ascii_only_

    ascii_only_ does not usually have a correct value, so we ascii_only_p()
    to make sure it does.
    
    Related to #3531
    ahmadsherif committed Feb 15, 2016
    Copy the full SHA
    cdc89a9 View commit details
  2. Copy the full SHA
    ca72c65 View commit details
  3. Copy the full SHA
    6592ea6 View commit details

Commits on Feb 16, 2016

  1. Removed legacy reference.

    brixen committed Feb 16, 2016
    Copy the full SHA
    9d268d0 View commit details
  2. Removed debugging.

    brixen committed Feb 16, 2016
    Copy the full SHA
    29ad4f6 View commit details
Showing with 668 additions and 391 deletions.
  1. +23 −0 core/argf.rb
  2. +4 −1 core/basic_object.rb
  3. +55 −0 core/binding.rb
  4. +4 −0 core/block_environment.rb
  5. +4 −0 core/delegated_method.rb
  6. +13 −3 core/exception.rb
  7. +35 −0 core/method.rb
  8. +2 −48 core/module.rb
  9. +4 −0 core/native_method.rb
  10. +2 −1 core/object_space.rb
  11. +17 −0 core/proc.rb
  12. +8 −0 core/string.rb
  13. +2 −0 core/variable_scope.rb
  14. +1 −1 core/zed.rb
  15. +3 −3 gems_list.txt
  16. +6 −6 machine/builtin/string.cpp
  17. +6 −4 machine/capi/class.cpp
  18. +19 −0 machine/capi/time.cpp
  19. +6 −0 machine/include/capi/ruby/ruby.h
  20. +3 −0 machine/memory.cpp
  21. +0 −87 machine/memory/heap.cpp
  22. +0 −204 machine/memory/heap.hpp
  23. +0 −5 machine/memory/immix_collector.cpp
  24. +6 −0 machine/metrics.cpp
  25. +9 −0 machine/metrics.hpp
  26. +0 −2 machine/vm.hpp
  27. +74 −0 spec/ruby/core/argf/read_nonblock_spec.rb
  28. +1 −24 spec/ruby/core/argf/read_spec.rb
  29. +23 −0 spec/ruby/core/argf/shared/read.rb
  30. +50 −0 spec/ruby/core/binding/local_variable_defined_p_spec.rb
  31. +34 −0 spec/ruby/core/binding/local_variable_get_spec.rb
  32. +54 −0 spec/ruby/core/binding/local_variable_set_spec.rb
  33. +18 −0 spec/ruby/core/exception/name_error_spec.rb
  34. +20 −0 spec/ruby/core/module/define_method_spec.rb
  35. +4 −0 spec/ruby/core/objectspace/_id2ref_spec.rb
  36. +19 −0 spec/ruby/core/string/minus_prefix_spec.rb
  37. +18 −0 spec/ruby/core/string/plus_prefix_spec.rb
  38. +10 −2 spec/ruby/language/send_spec.rb
  39. +38 −0 spec/ruby/optional/capi/class_spec.rb
  40. +5 −0 spec/ruby/optional/capi/ext/class_id_under_autoload_spec.c
  41. +12 −0 spec/ruby/optional/capi/ext/class_spec.c
  42. +2 −0 spec/ruby/optional/capi/ext/rubyspec.h
  43. +14 −0 spec/ruby/optional/capi/ext/time_spec.c
  44. +30 −0 spec/ruby/optional/capi/time_spec.rb
  45. +10 −0 spec/ruby/shared/kernel/method_missing.rb
23 changes: 23 additions & 0 deletions core/argf.rb
Original file line number Diff line number Diff line change
@@ -363,6 +363,29 @@ def read(bytes=nil, output=nil)
output
end

def read_nonblock(maxlen, output = nil, exception: true)
output ||= default_value

unless advance!
output.clear
raise EOFError, "ARGF at end"
end

begin
out = @stream.read_nonblock(maxlen, output, exception: exception)

return out if out == :wait_readable
rescue EOFError => e
raise e if @use_stdin_only

@stream.close
@advance = true
advance! or raise e
end

return output
end

#
# Read next line of text.
#
5 changes: 4 additions & 1 deletion core/basic_object.rb
Original file line number Diff line number Diff line change
@@ -39,7 +39,10 @@ def __id__
end

def method_missing(meth, *args)
::Kernel.raise ::NoMethodError, "Unable to send '#{meth}' on instance of BasicObject"
error = ::NoMethodError
.new("Unable to send '#{meth}' on instance of BasicObject", receiver: self)

::Kernel.raise(error)
end
private :method_missing

55 changes: 55 additions & 0 deletions core/binding.rb
Original file line number Diff line number Diff line change
@@ -58,4 +58,59 @@ def eval(expr, filename=nil, lineno=nil)
def local_variables
variables.local_variables
end

def local_variable_set(name, value)
unless name.is_a?(Symbol)
name = Rubinius::Type.coerce_to(name, String, :to_str).to_sym
end

vars = variables

# If a local variable is defined in a parent scope we should update the
# variable in said scope and all child scopes, instead of _only_ setting it
# in the current scope.
while vars
meth = vars.method

if meth.local_names.include?(name)
return vars.set_local(meth.local_slot(name), value)
elsif vars.eval_local_defined?(name)
return vars.set_eval_local(name, value)
end

vars = vars.parent
end

variables.set_eval_local(name, value)
end

def local_variable_get(name)
unless name.is_a?(Symbol)
name = Rubinius::Type.coerce_to(name, String, :to_str).to_sym
end

vars = variables

while vars
meth = vars.method

if meth.local_names.include?(name)
return vars.locals[meth.local_slot(name)]
elsif vars.eval_local_defined?(name)
return vars.get_eval_local(name)
end

vars = vars.parent
end

raise NameErrror, "local variable #{name.inspect} not defined for #{inspect}"
end

def local_variable_defined?(name)
unless name.is_a?(Symbol)
name = Rubinius::Type.coerce_to(name, String, :to_str).to_sym
end

variables.local_defined?(name)
end
end
4 changes: 4 additions & 0 deletions core/block_environment.rb
Original file line number Diff line number Diff line change
@@ -102,6 +102,10 @@ def file
def defined_line
@block_env.line
end

def scope
@block_env.scope
end
end

def from_proc?
4 changes: 4 additions & 0 deletions core/delegated_method.rb
Original file line number Diff line number Diff line change
@@ -31,5 +31,9 @@ def parameters
def source_location
@receiver.source_location
end

def scope
nil
end
end
end
16 changes: 13 additions & 3 deletions core/exception.rb
Original file line number Diff line number Diff line change
@@ -237,18 +237,28 @@ class LocalJumpError < StandardError
class NameError < StandardError
attr_reader :name

def initialize(*args)
def initialize(*args, receiver: nil)
super(args.shift)

@name = args.shift
@receiver = receiver
end

def receiver
if @receiver
@receiver
else
raise ArgumentError, 'no receiver is available'
end
end
end

class NoMethodError < NameError
attr_reader :name
attr_reader :args

def initialize(*arguments)
super(arguments.shift)
def initialize(*arguments, **options)
super(arguments.shift, **options)
@name = arguments.shift
@args = arguments.shift
end
35 changes: 35 additions & 0 deletions core/method.rb
Original file line number Diff line number Diff line change
@@ -172,6 +172,23 @@ def super_method
return nil
end

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

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

##
@@ -316,4 +333,22 @@ def super_method

return nil
end

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

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
50 changes: 2 additions & 48 deletions core/module.rb
Original file line number Diff line number Diff line change
@@ -442,54 +442,8 @@ def define_method(name, meth = undefined, &prc)

name = Rubinius::Type.coerce_to_symbol name

case meth
when Proc
if meth.ruby_method
code = Rubinius::DelegatedMethod.new(name, :call, meth, false)
scope = meth.ruby_method.executable.scope
else
be = meth.block.dup
be.change_name name
code = Rubinius::BlockEnvironment::AsMethod.new(be)
meth = meth.dup
meth.lambda_style!
scope = meth.block.scope
end
when Method
Rubinius::Type.bindable_method? meth.defined_in, self.class

exec = meth.executable
# 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 exec.kind_of? Rubinius::DelegatedMethod
code = exec
scope = nil
else
code = Rubinius::DelegatedMethod.new(name, :call_on_instance, meth.unbind, true)
if exec.kind_of? Rubinius::CompiledCode
scope = exec.scope
else
scope = nil
end
end
when UnboundMethod
Rubinius::Type.bindable_method? meth.defined_in, self.class

exec = meth.executable
# Same reasoning as above.
if exec.kind_of? Rubinius::DelegatedMethod
code = exec
scope = nil
else
code = Rubinius::DelegatedMethod.new(name, :call_on_instance, meth, true)
if exec.kind_of? Rubinius::CompiledCode
scope = exec.scope
else
scope = nil
end
end
if meth.respond_to?(:for_define_method)
code, scope = meth.for_define_method(name, self.class)
else
raise TypeError, "wrong argument type #{meth.class} (expected Proc/Method)"
end
4 changes: 4 additions & 0 deletions core/native_method.rb
Original file line number Diff line number Diff line change
@@ -78,5 +78,9 @@ def defined_line
def active_path
@file
end

def scope
nil
end
end
end
3 changes: 2 additions & 1 deletion core/object_space.rb
Original file line number Diff line number Diff line change
@@ -6,11 +6,12 @@ def self.find_object(query, callable)

def self._id2ref(id)
ary = []

if find_object([:object_id, Integer(id)], ary) > 0
return ary.first
end

return nil
raise RangeError, "#{id} is not a valid ID value"
end

def self.find_references(obj)
17 changes: 17 additions & 0 deletions core/proc.rb
Original file line number Diff line number Diff line change
@@ -244,6 +244,23 @@ def dup
copy
end

def for_define_method(name, klass)
if @ruby_method
code, scope = @ruby_method.for_define_method(name, klass, self)
else
be = @block.dup
be.change_name name

duped_proc = self.dup
duped_proc.lambda_style!

code = Rubinius::BlockEnvironment::AsMethod.new(be)
scope = duped_proc.block.scope
end

[code, scope]
end

def self.from_method(meth)
if meth.kind_of? Method
return __from_method__(meth)
8 changes: 8 additions & 0 deletions core/string.rb
Original file line number Diff line number Diff line change
@@ -2680,4 +2680,12 @@ def dump
str += ".force_encoding(\"#{encoding}\")" unless encoding.ascii_compatible?
s.replace(str)
end

def -@
frozen? ? self : dup.freeze
end

def +@
frozen? ? dup : self
end
end
2 changes: 2 additions & 0 deletions core/variable_scope.rb
Original file line number Diff line number Diff line change
@@ -136,6 +136,8 @@ def local_defined?(name)
return true if vars.eval_local_defined?(name, false)
vars = vars.parent
end

false
end

def local_layout
2 changes: 1 addition & 1 deletion core/zed.rb
Original file line number Diff line number Diff line change
@@ -1367,7 +1367,7 @@ def method_missing(meth, *args)
msg << " on an instance of #{object_class}."
end

Kernel.raise cls.new(msg, meth, args)
Kernel.raise(cls.new(msg, meth, args, receiver: self))
end

private :method_missing
6 changes: 3 additions & 3 deletions gems_list.txt
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ psych-2.0.17.gem
racc-1.4.14.gem
rake-10.5.0.gem
rb-readline-0.5.3.gem
rdoc-4.2.1.gem
rdoc-4.2.2.gem
redcard-1.1.0.gem
rubinius-ast-3.0.gem
rubinius-bridge-1.1.0.gem
@@ -71,9 +71,9 @@ rubysl-net-smtp-2.0.1.gem
rubysl-net-telnet-2.0.0.gem
rubysl-nkf-2.0.1.gem
rubysl-observer-2.0.0.gem
rubysl-open-uri-2.0.0.gem
rubysl-open3-2.0.0.gem
rubysl-openssl-2.8.0.gem
rubysl-open-uri-2.0.0.gem
rubysl-optparse-2.0.1.gem
rubysl-ostruct-2.1.0.gem
rubysl-pathname-2.1.0.gem
@@ -95,7 +95,7 @@ rubysl-set-2.0.1.gem
rubysl-shellwords-2.0.0.gem
rubysl-singleton-2.0.0.gem
rubysl-socket-2.1.1.gem
rubysl-stringio-2.0.0.gem
rubysl-stringio-2.1.0.gem
rubysl-strscan-2.0.0.gem
rubysl-sync-2.0.0.gem
rubysl-syslog-2.1.0.gem
Loading