Skip to content

Commit

Permalink
Showing 5 changed files with 59 additions and 36 deletions.
2 changes: 1 addition & 1 deletion truffle/src/main/ruby/core/rubinius/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
`bootstrap`, `common`, `delta` and `platform` contains the Ruby component of the
Rubinius kernel (core library) implementation, in some cases modified. We have
taken files from version 2.7 of Rubinius. This code was written by Evan
taken files from version 2.11 of Rubinius. This code was written by Evan
Phoenix, Brian Shirai, et al.

https://github.com/rubinius/rubinius
28 changes: 19 additions & 9 deletions truffle/src/main/ruby/core/rubinius/common/array.rb
Original file line number Diff line number Diff line change
@@ -1395,28 +1395,38 @@ def sample(count=undefined, options=undefined)
else
if size / count > 3
abandon = false
spin = 0

result = Array.new count
i = 1

result[0] = rng.rand(size)
while i < count
k = rng.rand(size)
j = 0

while j < i
while k == result[j]
spin += 1
if spin > 100
spin = false
spin_count = 0

while true
j = 0
while j < i
if k == result[j]
spin = true
break
end

j += 1
end

if spin
if (spin_count += 1) > 100
abandon = true
break
end

k = rng.rand(size)
else
break
end
break if abandon

j += 1
end

break if abandon
16 changes: 16 additions & 0 deletions truffle/src/main/ruby/core/rubinius/common/io.rb
Original file line number Diff line number Diff line change
@@ -40,6 +40,22 @@ class EAGAINWaitWritable < Errno::EAGAIN
include ::IO::WaitWritable
end

class EWOULDBLOCKWaitReadable < Errno::EAGAIN
include WaitReadable
end

class EWOULDBLOCKWaitWritable < Errno::EAGAIN
include WaitWritable
end

class EINPROGRESSWaitReadable < Errno::EINPROGRESS
include WaitReadable
end

class EINPROGRESSWaitWritable < Errno::EINPROGRESS
include WaitWritable
end

# Import platform constants

SEEK_SET = Rubinius::Config['rbx.platform.io.SEEK_SET']
18 changes: 8 additions & 10 deletions truffle/src/main/ruby/core/rubinius/common/regexp.rb
Original file line number Diff line number Diff line change
@@ -401,20 +401,18 @@ def parts

# TODO: audit specs for this method when specs are running
def create_parts
return unless @index < @source.size
char = @source[@index].chr
case char
when '('
idx = @index + 1
if idx < @source.size and @source[idx].chr == '?'
process_group
while @index < @source.size
if @source[@index].chr == '('
idx = @index + 1
if idx < @source.size and @source[idx].chr == '?'
process_group
else
push_current_character!
end
else
push_current_character!
end
else
push_current_character!
end
create_parts
end

def process_group
31 changes: 15 additions & 16 deletions truffle/src/main/ruby/core/rubinius/platform/pointer.rb
Original file line number Diff line number Diff line change
@@ -279,6 +279,21 @@ def primitive_write_pointer(obj)
raise PrimitiveFailure, "FFI::Pointer#primitive_write_pointer primitive failed"
end

##
# If +val+ is true, this Pointer object will call
# free() on it's address when it is garbage collected.
def autorelease=(val)
Rubinius.primitive :pointer_set_autorelease
raise PrimitiveFailure, "FFI::Pointer#autorelease= primitive failed"
end

##
# Returns true if autorelease is enabled, otherwise false.
def autorelease?
Rubinius.primitive :pointer_autorelease_p
raise PrimitiveFailure, "FFI::Pointer#pointer_autorelease_p primitive failed"
end

NULL = Pointer.new(0x0)
end

@@ -396,22 +411,6 @@ def free
Rubinius.primitive :pointer_free
raise PrimitiveFailure, "FFI::MemoryPointer#free primitive failed"
end

##
# If +val+ is true, this MemoryPointer object will call
# free() on it's address when it is garbage collected.
def autorelease=(val)
Rubinius.primitive :pointer_set_autorelease
raise PrimitiveFailure, "FFI::MemoryPointer#autorelease= primitive failed"
end

##
# Returns true if autorelease is enabled, otherwise false.
def autorelease?
Rubinius.primitive :pointer_autorelease_p
raise PrimitiveFailure, "FFI::MemoryPointer#pointer_autorelease_p primitive failed"
end

end

class DynamicLibrary::Symbol < Pointer

0 comments on commit e2f9cdc

Please sign in to comment.