Skip to content

Commit

Permalink
merging with trunk
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/branches/testing@68 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information
lrz committed Mar 11, 2008
1 parent ada253c commit 6537c7a
Show file tree
Hide file tree
Showing 81 changed files with 2,478 additions and 679 deletions.
555 changes: 553 additions & 2 deletions ChangeLog

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions Makefile.in
Expand Up @@ -197,11 +197,10 @@ lex.c: keywords
$(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -S $<

clean-local::
@$(RM) ext/extinit.c ext/extinit.$(OBJEXT)
@$(RM) ext/extinit.c ext/extinit.$(OBJEXT) ext/ripper/y.output

distclean-local::
@$(RM) ext/config.cache $(RBCONFIG)
@-$(RM) ext/ripper/y.output

ext/extinit.$(OBJEXT): ext/extinit.c $(SETUP)
$(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -c ext/extinit.c
69 changes: 52 additions & 17 deletions array.c
Expand Up @@ -2,7 +2,7 @@
array.c -
$Author: naruse $
$Author: nobu $
created at: Fri Aug 6 09:46:12 JST 1993
Copyright (C) 1993-2007 Yukihiro Matsumoto
Expand Down Expand Up @@ -604,12 +604,12 @@ rb_ary_shift_m(int argc, VALUE *argv, VALUE ary)
static VALUE
rb_ary_unshift_m(int argc, VALUE *argv, VALUE ary)
{
long len = RARRAY(ary)->len;
long len;

if (argc == 0) return ary;
rb_ary_modify(ary);
if (RARRAY(ary)->aux.capa <= RARRAY_LEN(ary)+argc) {
RESIZE_CAPA(ary, RARRAY(ary)->aux.capa + ARY_DEFAULT_SIZE);
if (RARRAY(ary)->aux.capa <= (len = RARRAY(ary)->len) + argc) {
RESIZE_CAPA(ary, len + argc + ARY_DEFAULT_SIZE);
}

/* sliding items */
Expand Down Expand Up @@ -2349,6 +2349,19 @@ rb_ary_equal(VALUE ary1, VALUE ary2)
return rb_exec_recursive(recursive_equal, ary1, ary2);
}

static VALUE
recursive_eql(VALUE ary1, VALUE ary2, int recur)
{
long i;

if (recur) return Qfalse;
for (i=0; i<RARRAY_LEN(ary1); i++) {
if (!rb_eql(rb_ary_elt(ary1, i), rb_ary_elt(ary2, i)))
return Qfalse;
}
return Qtrue;
}

/*
* call-seq:
* array.eql?(other) -> true or false
Expand Down Expand Up @@ -2431,6 +2444,26 @@ rb_ary_includes(VALUE ary, VALUE item)
}


static VALUE
recursive_cmp(VALUE ary1, VALUE ary2, int recur)
{
long i, len;

if (recur) return Qnil;
len = RARRAY_LEN(ary1);
if (len > RARRAY_LEN(ary2)) {
len = RARRAY_LEN(ary2);
}
for (i=0; i<len; i++) {
VALUE v = rb_funcall(rb_ary_elt(ary1, i), id_cmp, 1, rb_ary_elt(ary2, i));
if (v != INT2FIX(0)) {
return v;
}
}
return Qundef;
}


/*
* call-seq:
* array <=> other_array -> -1, 0, +1
Expand All @@ -2454,19 +2487,13 @@ rb_ary_includes(VALUE ary, VALUE item)
VALUE
rb_ary_cmp(VALUE ary1, VALUE ary2)
{
long i, len;
long len;
VALUE v;

ary2 = to_ary(ary2);
len = RARRAY_LEN(ary1);
if (len > RARRAY_LEN(ary2)) {
len = RARRAY_LEN(ary2);
}
for (i=0; i<len; i++) {
VALUE v = rb_funcall(rb_ary_elt(ary1, i), id_cmp, 1, rb_ary_elt(ary2, i));
if (v != INT2FIX(0)) {
return v;
}
}
if (ary1 == ary2) return INT2FIX(0);
v = rb_exec_recursive(recursive_cmp, ary1, ary2);
if (v != Qundef) return v;
len = RARRAY_LEN(ary1) - RARRAY_LEN(ary2);
if (len == 0) return INT2FIX(0);
if (len > 0) return INT2FIX(1);
Expand Down Expand Up @@ -3058,7 +3085,11 @@ combi_len(long n, long k)
if (k < 0) return 0;
val = 1;
for (i=1; i <= k; i++,n--) {
long m = val;
val *= n;
if (val < m) {
rb_raise(rb_eRangeError, "too big for combination");
}
val /= i;
}
return val;
Expand Down Expand Up @@ -3171,8 +3202,12 @@ rb_ary_product(int argc, VALUE *argv, VALUE ary)

/* Compute the length of the result array; return [] if any is empty */
for (i = 0; i < n; i++) {
resultlen *= RARRAY_LEN(arrays[i]);
if (resultlen == 0) return rb_ary_new2(0);
long k = RARRAY_LEN(arrays[i]), l = resultlen;
if (k == 0) return rb_ary_new2(0);
resultlen *= k;
if (resultlen < k || resultlen < l || resultlen / k != l) {
rb_raise(rb_eRangeError, "too big to product");
}
}

/* Otherwise, allocate and fill in an array of results */
Expand Down
3 changes: 1 addition & 2 deletions bcc32/Makefile.sub
Expand Up @@ -517,12 +517,11 @@ post-install-doc::
clean-local::
@$(RM) ext\extinit.c ext\extinit.$(OBJEXT) *.tds *.il? $(RUBY_SO_NAME).lib
@$(RM) $(RUBY_INSTALL_NAME).res $(RUBYW_INSTALL_NAME).res $(RUBY_SO_NAME).res
@$(RM) *.map *.pdb *.ilk *.exp $(RUBYDEF) ext\ripper\y.output

distclean-local::
@$(RM) ext\config.cache $(RBCONFIG:/=\)
@$(RM) *.map *.pdb *.ilk *.exp $(RUBYDEF)
@$(RM) $(RUBY_INSTALL_NAME).rc $(RUBYW_INSTALL_NAME).rc $(RUBY_SO_NAME).rc
@-$(RM) ext\ripper\y.output

ext/extinit.obj: ext/extinit.c $(SETUP)
$(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -c ext/extinit.c
Expand Down
24 changes: 22 additions & 2 deletions bignum.c
Expand Up @@ -2,7 +2,7 @@
bignum.c -
$Author: matz $
$Author: nobu $
created at: Fri Jun 10 00:48:55 JST 1994
Copyright (C) 1993-2007 Yukihiro Matsumoto
Expand Down Expand Up @@ -36,7 +36,19 @@ VALUE rb_cBignum;
#define BIGLO(x) ((BDIGIT)((x) & (BIGRAD-1)))
#define BDIGMAX ((BDIGIT)-1)

#define BIGZEROP(x) (RBIGNUM_LEN(x) == 0 || (RBIGNUM_LEN(x) == 1 && BDIGITS(x)[0] == 0))
#define BIGZEROP(x) (RBIGNUM_LEN(x) == 0 || \
(BDIGITS(x)[0] == 0 && \
(RBIGNUM_LEN(x) == 1 || bigzero_p(x))))

static int
bigzero_p(VALUE x)
{
long i;
for (i = 0; i < RBIGNUM_LEN(x); ++i) {
if (BDIGITS(x)[i]) return 0;
}
return 1;
}

#define RBIGNUM_SET_LEN(b,l) \
((RBASIC(b)->flags & RBIGNUM_EMBED_FLAG) ? \
Expand Down Expand Up @@ -725,6 +737,7 @@ ceil_log2(register unsigned long x)
#define MAX_BIG2STR_TABLE_ENTRIES 64

static VALUE big2str_power_cache[35][MAX_BIG2STR_TABLE_ENTRIES];
static int power_cache_initialized = 0;

static void
power_cache_init(void)
Expand Down Expand Up @@ -816,6 +829,9 @@ big2str_find_n1(VALUE x, int base)
else if (BIGZEROP(x)) {
return 0;
}
else if (RBIGNUM_LEN(x) >= LONG_MAX/BITSPERDIG) {
rb_raise(rb_eRangeError, "bignum too big to convert into `string'");
}
else {
bits = BITSPERDIG*RBIGNUM_LEN(x);
}
Expand Down Expand Up @@ -889,6 +905,10 @@ big2str_karatsuba(VALUE x, int base, char* ptr,
return big2str_orig(x, base, ptr, len, hbase, trim);
}

if (!power_cache_initialized) {
power_cache_init();
power_cache_initialized = 1;
}
b = power_cache_get_power(base, n1, &m1);
bigdivmod(x, b, &q, &r);
lh = big2str_karatsuba(q, base, ptr, (len - m1)/2,
Expand Down
4 changes: 4 additions & 0 deletions bootstraptest/test_io.rb
Expand Up @@ -69,3 +69,7 @@
File.unlink(tmpname)
:ok
}

assert_normal_exit %q{
ARGF.set_encoding "foo"
}
11 changes: 0 additions & 11 deletions bootstraptest/test_knownbug.rb
Expand Up @@ -31,11 +31,6 @@ class C
C.new.foo
}, '[ruby-core:14813]'
# test is not written...
flunk '[ruby-dev:31819] rb_clear_cache_by_class'
flunk '[ruby-dev:31820] valgrind set_trace_func'
flunk '[ruby-dev:32746] Invalid read of size 1'
assert_equal 'ok', %q{
class X < RuntimeError;end
x = [X]
Expand All @@ -46,12 +41,6 @@ class X < RuntimeError;end
end
}, '[ruby-core:14537]'
assert_valid_syntax('1.times {|i|print (42),1;}', '[ruby-list:44479]')
assert_normal_exit %q{
File.read("empty", nil, nil, {})
}, '[ruby-dev:33072]'
assert_normal_exit %q{
"abc".gsub(/./, "a" => "z")
}
Expand Down
2 changes: 1 addition & 1 deletion bootstraptest/test_marshal.rb
@@ -1,5 +1,5 @@

assert_normal_exit %q{
Marshal.load(Marshal.dump({"k"=>"v"}), lambda {|v| })
Marshal.load(Marshal.dump({"k"=>"v"}), lambda {|v| v})
}

2 changes: 2 additions & 0 deletions bootstraptest/test_syntax.rb
Expand Up @@ -765,3 +765,5 @@ def foo
next p(i)
end
}

assert_valid_syntax('1.times {|i|print (42),1;}', '[ruby-list:44479]')
23 changes: 2 additions & 21 deletions class.c
Expand Up @@ -20,7 +20,7 @@ extern st_table *rb_class_tbl;
#define VISI(x) ((x)&NOEX_MASK)
#define VISI_CHECK(x,f) (VISI(x) == (f))

static VALUE
static VALUE
class_init(VALUE obj)
{
RCLASS(obj)->ptr = ALLOC(rb_classext_t);
Expand Down Expand Up @@ -585,10 +585,6 @@ include_class_new(VALUE module, VALUE super)
RCLASS_IV_TBL(klass) = RCLASS_IV_TBL(module);
RCLASS_M_TBL(klass) = RCLASS_M_TBL(module);
RCLASS_SUPER(klass) = super;
#if WITH_OBJC
//printf("klass %p super %p\n", RCLASS(klass)->ocklass, RCLASS(super)->ocklass);
// class_setSuperclass(RCLASS(klass)->ocklass, RCLASS(super)->ocklass);
#endif
if (TYPE(module) == T_ICLASS) {
RBASIC(klass)->klass = RBASIC(module)->klass;
}
Expand Down Expand Up @@ -643,17 +639,7 @@ rb_include_module(VALUE klass, VALUE module)
break;
}
}
#if WITH_OBJC
{
VALUE c2 = include_class_new(module, RCLASS_SUPER(c));
//class_setSuperclass(RCLASS(c)->ocklass, RCLASS(c2)->ocklass);
//class_setSuperclass(RCLASS(c2)->ocklass, RCLASS(RCLASS_SUPER(c2))->ocklass);
//OCCLASS_WEAK_COPY_METHODS(RCLASS(c2)->ocklass, RCLASS(module)->ocklass);
c = RCLASS_SUPER(c) = c2;
}
#else
c = RCLASS_SUPER(c) = include_class_new(module, RCLASS_SUPER(c));
#endif
changed = 1;
skip:
module = RCLASS_SUPER(module);
Expand Down Expand Up @@ -981,15 +967,14 @@ rb_class_public_instance_methods(int argc, VALUE *argv, VALUE mod)
VALUE
rb_obj_singleton_methods(int argc, VALUE *argv, VALUE obj)
{
VALUE recur, ary, klass, klass_orig;
VALUE recur, ary, klass;
st_table *list;

rb_scan_args(argc, argv, "01", &recur);
if (argc == 0) {
recur = Qtrue;
}
klass = CLASS_OF(obj);
klass_orig = rb_obj_class(obj);
list = st_init_numtable();
if (klass && FL_TEST(klass, FL_SINGLETON)) {
st_foreach(RCLASS_M_TBL(klass), method_entry, (st_data_t)list);
Expand All @@ -1005,10 +990,6 @@ rb_obj_singleton_methods(int argc, VALUE *argv, VALUE obj)
st_foreach(list, ins_methods_i, ary);
st_free_table(list);

#if WITH_OBJC
//rb_objc_methods(ary, RCLASS(obj)->ocklass);
#endif

return ary;
}

Expand Down
7 changes: 2 additions & 5 deletions common.mk
Expand Up @@ -300,9 +300,6 @@ dont-install-doc::
post-no-install-doc::
@$(NULLCMD)

install-xcode-templates:
$(MINIRUBY) $(srcdir)/misc/xcode-templates/install.rb

CLEAR_INSTALLED_LIST = clear-installed-list

install-prereq: $(CLEAR_INSTALLED_LIST)
Expand All @@ -314,7 +311,7 @@ clean: clean-ext clean-local clean-enc
clean-local::
@$(RM) $(OBJS) $(MINIOBJS) $(MAINOBJ) $(WINMAINOBJ) $(LIBRUBY_A) $(LIBRUBY_SO) $(LIBRUBY) $(LIBRUBY_ALIASES)
@$(RM) $(PROGRAM) $(WPROGRAM) miniruby$(EXEEXT) dmyext.$(OBJEXT) $(ARCHFILE) .*.time
@$(RM) *.inc $(GOLFOBJS)
@$(RM) *.inc $(GOLFOBJS) y.tab.c y.output
clean-ext:
@-$(MINIRUBY) $(srcdir)/ext/extmk.rb --make="$(MAKE)" $(EXTMK_ARGS) clean
clean-enc:
Expand All @@ -324,7 +321,7 @@ distclean: distclean-ext distclean-local distclean-enc
distclean-local:: clean-local
@$(RM) $(MKFILES) config.h rbconfig.rb yasmdata.rb encdb.h
@$(RM) config.cache config.log config.status config.status.lineno $(PRELUDES)
@$(RM) *~ *.bak *.stackdump core *.core gmon.out y.tab.c y.output $(PREP)
@$(RM) *~ *.bak *.stackdump core *.core gmon.out $(PREP)
distclean-ext:
@-$(MINIRUBY) $(srcdir)/ext/extmk.rb --make="$(MAKE)" $(EXTMK_ARGS) distclean
# -$(RM) $(INSTALLED_LIST) $(arch_hdrdir)/ruby/config.h
Expand Down
2 changes: 1 addition & 1 deletion compile.c
Expand Up @@ -1997,7 +1997,7 @@ compile_array_(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE* node_root,
ADD_INSN1(anchor, line, newarray_named_args, INT2FIX(len));
else
#endif
ADD_INSN1(anchor, line, newarray, INT2FIX(len));
ADD_INSN1(anchor, line, newarray, INT2FIX(len));
}
APPEND_LIST(ret, anchor);
}
Expand Down

0 comments on commit 6537c7a

Please sign in to comment.