diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/class.c | 10 | ||||
| -rw-r--r-- | src/mruby_core.rake | 17 | ||||
| -rw-r--r-- | src/numeric.c | 64 | ||||
| -rw-r--r-- | src/vm.c | 9 |
4 files changed, 32 insertions, 68 deletions
diff --git a/src/class.c b/src/class.c index 26366aeb9..e28951499 100644 --- a/src/class.c +++ b/src/class.c @@ -1375,8 +1375,10 @@ include_module_at(mrb_state *mrb, struct RClass *c, struct RClass *ins_pos, stru void *klass_mt = find_origin(c)->mt; while (m) { - int superclass_seen = 0; + int original_seen = FALSE; + int superclass_seen = FALSE; + if (c == ins_pos) original_seen = TRUE; if (m->flags & MRB_FL_CLASS_IS_PREPENDED) goto skip; @@ -1385,16 +1387,17 @@ include_module_at(mrb_state *mrb, struct RClass *c, struct RClass *ins_pos, stru p = c->super; while (p) { + if (c == p) original_seen = TRUE; if (p->tt == MRB_TT_ICLASS) { if (p->mt == m->mt) { - if (!superclass_seen) { + if (!superclass_seen && original_seen) { ins_pos = p; /* move insert point */ } goto skip; } } else if (p->tt == MRB_TT_CLASS) { if (!search_super) break; - superclass_seen = 1; + superclass_seen = TRUE; } p = p->super; } @@ -1569,7 +1572,6 @@ mrb_singleton_class_ptr(mrb_state *mrb, mrb_value v) case MRB_TT_TRUE: return mrb->true_class; case MRB_TT_CPTR: - return mrb->object_class; case MRB_TT_SYMBOL: case MRB_TT_INTEGER: #ifndef MRB_NO_FLOAT diff --git a/src/mruby_core.rake b/src/mruby_core.rake deleted file mode 100644 index c4816d4ce..000000000 --- a/src/mruby_core.rake +++ /dev/null @@ -1,17 +0,0 @@ -as_cxx_srcs = %w[vm error gc].map{|name| "#{MRUBY_ROOT}/src/#{name}.c"} - -MRuby.each_target do - objs = Dir.glob("#{MRUBY_ROOT}/src/*.c").map do |src| - dst = src.pathmap("#{build_dir}/src/%n") - if cxx_exception_enabled? && as_cxx_srcs.include?(src) - compile_as_cxx(src, "#{dst}.cxx") - else - objfile(dst) - end - end - self.libmruby_objs << objs - - file libmruby_core_static => objs do |t| - archiver.run t.name, t.prerequisites - end -end diff --git a/src/numeric.c b/src/numeric.c index fec79ffd1..a16b57dc9 100644 --- a/src/numeric.c +++ b/src/numeric.c @@ -249,8 +249,23 @@ flo_div(mrb_state *mrb, mrb_value xv) return mrb_float_value(mrb, x); } +/* 15.2.9.3.16(x) */ +/* + * call-seq: + * flt.to_s -> string + * flt.inspect -> string + * + * Returns a string containing a representation of self. As well as a + * fixed or exponential form of the number, the call may return + * "<code>NaN</code>", "<code>Infinity</code>", and + * "<code>-Infinity</code>". + * + * 3.0.to_s #=> 3.0 + * 3.25.to_s #=> 3.25 + */ + static mrb_value -flo_to_str(mrb_state *mrb, mrb_value flt, mrb_bool add_dot_zero) +flo_to_s(mrb_state *mrb, mrb_value flt) { mrb_float f = mrb_float(flt); mrb_value str; @@ -293,7 +308,7 @@ flo_to_str(mrb_state *mrb, mrb_value flt, mrb_bool add_dot_zero) str = mrb_float_to_str(mrb, flt, fmt); goto insert_dot_zero; } - else if (add_dot_zero) { + else { mrb_str_cat(mrb, str, ".0", 2); } @@ -305,49 +320,6 @@ flo_to_str(mrb_state *mrb, mrb_value flt, mrb_bool add_dot_zero) return str; } -/* 15.2.9.3.16(x) */ -/* - * call-seq: - * flt.to_s -> string - * - * Returns a string containing a representation of self. As well as a - * fixed or exponential form of the number, the call may return - * "<code>NaN</code>", "<code>Infinity</code>", and - * "<code>-Infinity</code>". - * - * Trailing <code>.0</code> is removed. - * - * 3.0.to_s #=> 3 - * 3.25.to_s #=> 3.25 - */ - -static mrb_value -flo_to_s(mrb_state *mrb, mrb_value flt) -{ - return flo_to_str(mrb, flt, FALSE); -} - -/* - * call-seq: - * flt.inspect -> string - * - * Returns a string containing a representation of self. As well as a - * fixed or exponential form of the number, the call may return - * "<code>NaN</code>", "<code>Infinity</code>", and - * "<code>-Infinity</code>". - * - * Trailing <code>.0</code> is added. - * - * 3.0.to_s #=> 3.0 - * 3.25.to_s #=> 3.25 - */ - -static mrb_value -flo_inspect(mrb_state *mrb, mrb_value flt) -{ - return flo_to_str(mrb, flt, TRUE); -} - /* 15.2.9.3.2 */ /* * call-seq: @@ -1725,7 +1697,7 @@ mrb_init_numeric(mrb_state *mrb) mrb_define_method(mrb, fl, "eql?", flo_eql, MRB_ARGS_REQ(1)); /* 15.2.8.3.16 */ mrb_define_method(mrb, fl, "to_s", flo_to_s, MRB_ARGS_NONE()); /* 15.2.9.3.16(x) */ - mrb_define_method(mrb, fl, "inspect", flo_inspect, MRB_ARGS_NONE()); + mrb_define_method(mrb, fl, "inspect", flo_to_s , MRB_ARGS_NONE()); mrb_define_method(mrb, fl, "nan?", flo_nan_p, MRB_ARGS_NONE()); #ifdef INFINITY @@ -1590,7 +1590,10 @@ RETRY_TRY_BLOCK: mrb_exc_set(mrb, exc); goto L_RAISE; } - if (target_class->tt == MRB_TT_MODULE) { + if (target_class->flags & MRB_FL_CLASS_IS_PREPENDED) { + target_class = ci->target_class; + } + else if (target_class->tt == MRB_TT_MODULE) { target_class = ci->target_class; if (target_class->tt != MRB_TT_ICLASS) { mrb_value exc = mrb_exc_new_lit(mrb, E_RUNTIME_ERROR, "superclass info lost [mruby limitations]"); @@ -2817,6 +2820,10 @@ RETRY_TRY_BLOCK: goto L_RAISE; } + CASE(OP_SENDVK, BB) { /* not yet implemented */ + NEXT; + } + CASE(OP_STOP, Z) { /* stop VM */ CHECKPOINT_RESTORE(RBREAK_TAG_STOP) { |
