Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
flavio committed Nov 17, 2011
2 parents ba593d2 + 4f6ff1c commit af68520
Show file tree
Hide file tree
Showing 433 changed files with 23,038 additions and 2,695 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Expand Up @@ -33,7 +33,7 @@ end
require config_rb
BUILD_CONFIG = Rubinius::BUILD_CONFIG

unless BUILD_CONFIG[:config_version] == 140
unless BUILD_CONFIG[:config_version] == 144
STDERR.puts "Your configuration is outdated, please run ./configure first"
exit 1
end
Expand Down
88 changes: 86 additions & 2 deletions configure
Expand Up @@ -109,12 +109,13 @@ class Configure
# Library configuration
@rb_readline = false
@vendor_zlib = false
@libyaml = false

# Essential settings (modify these for creating releases)
@libversion = "2.0"
@version = "#{@libversion}.0dev"
@release_date = "yyyy-mm-dd"
@config_version = 140
@config_version = 144

# TODO: add conditionals for platforms
if RbConfig::CONFIG["build_os"] =~ /darwin/
Expand Down Expand Up @@ -820,6 +821,64 @@ int main() { return tgetnum(""); }
@log.write @curses ? @curses : "not found"
end

def has_struct_member(struct, member, includes = [])
@log.print "Checking whether struct #{struct} has member #{member}: "
tf = Tempfile.new("rbx-test")
includes.each do |i|
src = "#include <#{i}>"
tf.puts src
@log.log src
end

src = "int main() { struct #{struct} st; st.#{member}; }"
tf.puts src
@log.log src

tf.close

system "#{@cxx} -S -o - -x c #{c_includes} #{env('CFLAGS')} #{tf.path} >>#{@log.path} 2>&1"
status = ($?.exitstatus == 0)

tf.unlink

if status
@log.write "found!"
else
@log.write "not found."
end

return status
end

def has_global(name, includes=[])
@log.print "Checking for global '#{name}': "
tf = Tempfile.new("rbx-test")
includes.each do |i|
src = "#include <#{i}>"
tf.puts src
@log.log src
end

src = "int main() { #{name}; }"
tf.puts src
@log.log src

tf.close

system "#{@cxx} -S -o - -x c #{c_includes} #{env('CFLAGS')} #{tf.path} >>#{@log.path} 2>&1"
status = ($?.exitstatus == 0)

tf.unlink

if status
@log.write "found!"
else
@log.write "not found."
end

return status
end

def has_function(name, includes=[])
@log.print "Checking for function '#{name}': "
tf = Tempfile.new("rbx-test")
Expand Down Expand Up @@ -862,6 +921,30 @@ int main() { return tgetnum(""); }
@rb_readline = true
end

if has_function("yaml_parser_initialize", ["yaml.h"])
@libyaml = true
end

if has_struct_member("tm", "tm_gmtoff", ["time.h"])
@defines << "HAVE_TM_GMTOFF"
end

if has_struct_member("tm", "tm_zone", ["time.h"])
@defines << "HAVE_TM_ZONE"
end

if has_global("timezone", ["time.h"])
@defines << "HAVE_TIMEZONE"
end

if has_global("tzname", ["time.h"])
@defines << "HAVE_TZNAME"
end

if has_global("daylight", ["time.h"])
@defines << "HAVE_DAYLIGHT"
end

@vendor_zlib = true if @features["vendor-zlib"]
end

Expand Down Expand Up @@ -996,7 +1079,8 @@ module Rubinius
:version_list => #{@version_list.inspect},
:default_version => "#{@default_version}",
:vendor_zlib => #{@vendor_zlib},
:readline => :#{@rb_readline ? :rb_readline : :c_readline}
:readline => :#{@rb_readline ? :rb_readline : :c_readline},
:libyaml => #{@libyaml}
}
end
EOC
Expand Down
5 changes: 5 additions & 0 deletions kernel/bootstrap/variable_scope.rb
Expand Up @@ -10,6 +10,11 @@ def self.current
raise PrimitiveFailure, "Unable to get current VariableScope"
end

def self.synthesize(method, module_, parent, self_, block, locals)
Rubinius.primitive :variable_scope_synthesize
raise PrimitiveFailure, "Unable to create a new VariableScope object"
end

def locals
Rubinius.primitive :variable_scope_locals
raise PrimitiveFailure, "Unable to get VariableScope locals"
Expand Down
3 changes: 2 additions & 1 deletion kernel/common/complex.rb
Expand Up @@ -251,7 +251,8 @@ def abs2
def arg
Math.atan2(@imag, @real)
end
alias angle arg
alias_method :angle, :arg
alias_method :phase, :arg

#
# Returns the absolute value _and_ the argument.
Expand Down
5 changes: 5 additions & 0 deletions kernel/common/eval18.rb
Expand Up @@ -86,6 +86,11 @@ def instance_eval(string=nil, filename="(eval)", line=1, &prc)

def instance_exec(*args, &prc)
raise LocalJumpError, "Missing block" unless block_given?

if prc.kind_of? Proc::Method
return prc.bound_method.call(*args)
end

env = prc.block

static_scope = env.static_scope
Expand Down
4 changes: 4 additions & 0 deletions kernel/common/eval19.rb
Expand Up @@ -88,6 +88,10 @@ def instance_exec(*args, &prc)
raise LocalJumpError, "Missing block" unless block_given?
env = prc.block

if prc.kind_of? Proc::Method
return prc.bound_method.call(*args)
end

static_scope = env.static_scope
if ImmediateValue === self
static_scope = static_scope.using_disabled_scope
Expand Down
7 changes: 7 additions & 0 deletions kernel/common/float19.rb
Expand Up @@ -33,4 +33,11 @@ def to_r

(f * (RADIX ** e)).to_r
end

def arg
return self if nan?
super
end
alias_method :angle, :arg
alias_method :phase, :arg
end
30 changes: 0 additions & 30 deletions kernel/common/integer.rb
Expand Up @@ -65,36 +65,6 @@ def integer?
true
end

##
# Returns the minimum number of bits required for integer in (signed int)
# binary format
#--
# NOTE: rshift would probably be slightly more efficient but since i'm
# probably going to use this to simplify the complex behavior of
# ruby's << and >> it would defeat the purpose by creating a circular
# dependency.
#
# TODO: convert algorithm to primitive so no circular dependency?
#++

def bits(int = self)
num_bits = 1 # sign bit storage

if int < 0
int = ~int

num_bits += 1
int /= 2 # could use >> in primitive
end

while int != 0
num_bits += 1
int /= 2 # could use >> in primitive
end

num_bits
end

# Returns true if int is an even number.
def even?
self & 1 == 0
Expand Down
2 changes: 1 addition & 1 deletion kernel/common/marshal.rb
Expand Up @@ -970,7 +970,7 @@ def self.load(obj, prc = nil)

ms.construct
rescue NameError => e
raise ArgumentError, e.message
raise ArgumentError, e.message, e
end

class << self
Expand Down
4 changes: 2 additions & 2 deletions kernel/common/struct.rb
Expand Up @@ -76,7 +76,7 @@ def self.[](*args)
end

const_set :STRUCT_ATTRS, attrs
specialize_initialize
_specialize attrs
end

Struct.const_set klass_name, klass if klass_name
Expand All @@ -88,7 +88,7 @@ def self.[](*args)

# Don't specialize any thing created in the kernel. We hook up
# better form of this in delta.
def self.specialize_initialize
def self._specialize(attrs)
end

def self.make_struct(name, attrs)
Expand Down
2 changes: 1 addition & 1 deletion kernel/common/thread.rb
Expand Up @@ -95,7 +95,7 @@ def self.detect_outermost_recursion(obj, paired_obj=undefined, &block)

if rec[:__detect_outermost_recursion__]
if detect_recursion(obj, paired_obj, &block)
raise InnerRecursionDetected.new
raise InnerRecursionDetected
end
false
else
Expand Down
32 changes: 28 additions & 4 deletions kernel/delta/struct.rb
Expand Up @@ -13,7 +13,7 @@ def initialize(utime=nil, stime=nil, cutime=nil, cstime=nil,
end
end

def self.specialize_initialize
def self._specialize(attrs)
# Because people are crazy, they subclass Struct directly, ie.
# class Craptastic < Struct
#
Expand All @@ -29,9 +29,7 @@ def self.specialize_initialize
# the specialize if we're trying new Struct's directly from Struct itself,
# not a craptastic Struct subclass.

return unless self.equal? Struct

attrs = self::STRUCT_ATTRS
return unless superclass.equal? Struct

args = []
0.upto(attrs.size-1) do |i|
Expand All @@ -43,11 +41,37 @@ def self.specialize_initialize
assigns << "@#{attrs[i]} = a#{i}"
end

hashes = []
vars = []

0.upto(attrs.size-1) do |i|
hashes << "@#{attrs[i]}.hash"
vars << "@#{attrs[i]}"
end

code = <<-CODE
def initialize(#{args.join(", ")})
#{assigns.join(';')}
self
end
def hash
hash = #{hashes.size}
return hash if Thread.detect_outermost_recursion(self) do
hash = hash ^ #{hashes.join(' ^ ')}
end
hash
end
def to_a
[#{vars.join(', ')}]
end
def length
#{vars.size}
end
CODE

begin
Expand Down
10 changes: 9 additions & 1 deletion kernel/loader.rb
Expand Up @@ -20,6 +20,8 @@ def initialize
@simple_options = false
@early_option_stop = false

@enable_gems = Rubinius.ruby19?

@gem_bin = File.join Rubinius::GEMS_PATH, "bin"
end

Expand Down Expand Up @@ -285,6 +287,12 @@ def options(argv=ARGV)
$DEBUG = true
end

if Rubinius.ruby19?
options.on "--disable-gems", "Do not automatically load rubygems on startup" do
@enable_gems = false
end
end

options.on "-e", "CODE", "Compile and execute CODE" do |code|
@run_irb = false
$0 = "(eval)"
Expand Down Expand Up @@ -569,7 +577,7 @@ def agent
def rubygems
@stage = "loading Rubygems"

require "rubygems" if Rubinius.ruby19?
require "rubygems" if @enable_gems
end

# Require any -r arguments
Expand Down

0 comments on commit af68520

Please sign in to comment.