Permalink
Browse files

Merge remote-tracking branch 'upstream/master'

  • Loading branch information...
2 parents ba593d2 + 4f6ff1c commit af68520fab88e7abd1e35d50107035d44d8081d7 @flavio flavio committed Nov 17, 2011
Showing 433 changed files with 23,038 additions and 2,695 deletions.
View
@@ -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
View
@@ -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/
@@ -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")
@@ -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
@@ -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
@@ -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"
@@ -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.
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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)
@@ -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
@@ -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
#
@@ -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|
@@ -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
View
@@ -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
@@ -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)"
@@ -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
Oops, something went wrong.

0 comments on commit af68520

Please sign in to comment.