diff options
| -rw-r--r-- | MITL | 2 | ||||
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | doc/guides/debugger.md | 2 | ||||
| -rw-r--r-- | doc/limitations.md | 14 | ||||
| -rw-r--r-- | include/mruby.h | 2 | ||||
| -rw-r--r-- | include/mruby/version.h | 8 | ||||
| -rw-r--r-- | lib/mruby/build.rb | 22 | ||||
| -rw-r--r-- | mrbgems/mruby-compiler/core/codegen.c | 8 | ||||
| -rw-r--r-- | mrbgems/mruby-compiler/core/parse.y | 2 | ||||
| -rw-r--r-- | mrbgems/mruby-time/src/time.c | 10 | ||||
| -rw-r--r-- | mrbgems/mruby-time/test/time.rb | 4 | ||||
| -rw-r--r-- | src/class.c | 2 | ||||
| -rw-r--r-- | src/variable.c | 48 |
13 files changed, 99 insertions, 27 deletions
@@ -1,4 +1,4 @@ -Copyright (c) 2017 mruby developers +Copyright (c) 2018 mruby developers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -17,7 +17,7 @@ of the Ministry of Economy, Trade and Industry of Japan. ## How to get mruby -The stable version 1.3.0 of mruby can be downloaded via the following URL: [https://github.com/mruby/mruby/archive/1.3.0.zip](https://github.com/mruby/mruby/archive/1.3.0.zip) +The stable version 1.4.0 of mruby can be downloaded via the following URL: [https://github.com/mruby/mruby/archive/1.4.0.zip](https://github.com/mruby/mruby/archive/1.4.0.zip) The latest development version of mruby can be downloaded via the following URL: [https://github.com/mruby/mruby/zipball/master](https://github.com/mruby/mruby/zipball/master) diff --git a/doc/guides/debugger.md b/doc/guides/debugger.md index 72f2c2b32..a41b6ce45 100644 --- a/doc/guides/debugger.md +++ b/doc/guides/debugger.md @@ -38,7 +38,7 @@ To confirm mrdb was installed properly, run mrdb with the `--version` option: ```bash $ mrdb --version -mruby 1.3.0 (2017-7-4) +mruby 1.4.0 (2018-1-16) ``` ## 2.2 Basic Operation diff --git a/doc/limitations.md b/doc/limitations.md index 134ff6e26..855ae16ee 100644 --- a/doc/limitations.md +++ b/doc/limitations.md @@ -38,7 +38,7 @@ puts [1,2,3] 3 ``` -#### mruby [1.3.0 (2017-7-4)] +#### mruby [1.4.0 (2018-1-16)] ``` [1, 2, 3] @@ -61,7 +61,7 @@ end ```ZeroDivisionError``` is raised. -#### mruby [1.3.0 (2017-7-4)] +#### mruby [1.4.0 (2018-1-16)] No exception is raised. @@ -89,7 +89,7 @@ p Liste.new "foobar" ``` [] ``` -#### mruby [1.3.0 (2017-7-4)] +#### mruby [1.4.0 (2018-1-16)] ```ArgumentError``` is raised. @@ -119,7 +119,7 @@ false true ``` -#### mruby [1.3.0 (2017-7-4)] +#### mruby [1.4.0 (2018-1-16)] ``` true @@ -142,7 +142,7 @@ defined?(Foo) nil ``` -#### mruby [1.3.0 (2017-7-4)] +#### mruby [1.4.0 (2018-1-16)] ```NameError``` is raised. @@ -159,7 +159,7 @@ alias $a $__a__ ``` nil ``` -#### mruby [1.3.0 (2017-7-4)] +#### mruby [1.4.0 (2018-1-16)] Syntax error @@ -181,7 +181,7 @@ end ```ArgumentError``` is raised. The re-defined ```+``` operator does not accept any arguments. -#### mruby [1.3.0 (2017-7-4)] +#### mruby [1.4.0 (2018-1-16)] ``` 'ab' ``` Behavior of the operator wasn't changed. diff --git a/include/mruby.h b/include/mruby.h index d93874dfa..f4d8e229a 100644 --- a/include/mruby.h +++ b/include/mruby.h @@ -1,7 +1,7 @@ /* ** mruby - An embeddable Ruby implementation ** -** Copyright (c) mruby developers 2010-2017 +** Copyright (c) mruby developers 2010-2018 ** ** Permission is hereby granted, free of charge, to any person obtaining ** a copy of this software and associated documentation files (the diff --git a/include/mruby/version.h b/include/mruby/version.h index 8414bf204..3ba2db031 100644 --- a/include/mruby/version.h +++ b/include/mruby/version.h @@ -42,7 +42,7 @@ MRB_BEGIN_DECL /* * Minor release version number. */ -#define MRUBY_RELEASE_MINOR 3 +#define MRUBY_RELEASE_MINOR 4 /* * Tiny release version number. @@ -62,17 +62,17 @@ MRB_BEGIN_DECL /* * Release year. */ -#define MRUBY_RELEASE_YEAR 2017 +#define MRUBY_RELEASE_YEAR 2018 /* * Release month. */ -#define MRUBY_RELEASE_MONTH 7 +#define MRUBY_RELEASE_MONTH 1 /* * Release day. */ -#define MRUBY_RELEASE_DAY 4 +#define MRUBY_RELEASE_DAY 16 /* * Release date as a string. diff --git a/lib/mruby/build.rb b/lib/mruby/build.rb index 7d6aa49e1..c06a62282 100644 --- a/lib/mruby/build.rb +++ b/lib/mruby/build.rb @@ -334,6 +334,7 @@ EOS attr_accessor :host_target, :build_target def initialize(name, build_dir=nil, &block) + @endian = nil @test_runner = Command::CrossTestRunner.new(self) super end @@ -351,5 +352,26 @@ EOS @test_runner.run(mrbtest) end end + + def big_endian + if @endian + puts "Endian has already specified as #{@endian}." + return + end + @endian = :big + @mrbc.compile_options += ' -E' + compilers.each do |c| + c.defines += %w(MRB_ENDIAN_BIG) + end + end + + def little_endian + if @endian + puts "Endian has already specified as #{@endian}." + return + end + @endian = :little + @mrbc.compile_options += ' -e' + end end # CrossBuild end # MRuby diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c index c4227ca8e..eb82110b8 100644 --- a/mrbgems/mruby-compiler/core/codegen.c +++ b/mrbgems/mruby-compiler/core/codegen.c @@ -149,8 +149,14 @@ new_label(codegen_scope *s) static inline int genop(codegen_scope *s, mrb_code i) { - if (s->pc == s->icapa) { + if (s->pc >= s->icapa) { s->icapa *= 2; + if (s->pc >= MAXARG_sBx) { + codegen_error(s, "too big code block"); + } + if (s->icapa > MAXARG_sBx) { + s->icapa = MAXARG_sBx; + } s->iseq = (mrb_code *)codegen_realloc(s, s->iseq, sizeof(mrb_code)*s->icapa); if (s->lines) { s->lines = (uint16_t*)codegen_realloc(s, s->lines, sizeof(short)*s->icapa); diff --git a/mrbgems/mruby-compiler/core/parse.y b/mrbgems/mruby-compiler/core/parse.y index 01269d8da..e4c258368 100644 --- a/mrbgems/mruby-compiler/core/parse.y +++ b/mrbgems/mruby-compiler/core/parse.y @@ -2568,7 +2568,7 @@ lambda_body : tLAMBEG compstmt '}' { $$ = $2; } - | keyword_do_LAMBDA compstmt keyword_end + | keyword_do_LAMBDA bodystmt keyword_end { $$ = $2; } diff --git a/mrbgems/mruby-time/src/time.c b/mrbgems/mruby-time/src/time.c index e6c6b9904..98198083b 100644 --- a/mrbgems/mruby-time/src/time.c +++ b/mrbgems/mruby-time/src/time.c @@ -138,8 +138,14 @@ timegm(struct tm *tm) int i; unsigned int *nday = (unsigned int*) ndays[is_leapyear(tm->tm_year+1900)]; - for (i = 70; i < tm->tm_year; ++i) - r += is_leapyear(i+1900) ? 366*24*60*60 : 365*24*60*60; + static const int epoch_year = 70; + if(tm->tm_year >= epoch_year) { + for (i = epoch_year; i < tm->tm_year; ++i) + r += is_leapyear(i+1900) ? 366*24*60*60 : 365*24*60*60; + } else { + for (i = tm->tm_year; i < epoch_year; ++i) + r -= is_leapyear(i+1900) ? 366*24*60*60 : 365*24*60*60; + } for (i = 0; i < tm->tm_mon; ++i) r += nday[i] * 24 * 60 * 60; r += (tm->tm_mday - 1) * 24 * 60 * 60; diff --git a/mrbgems/mruby-time/test/time.rb b/mrbgems/mruby-time/test/time.rb index 52b931177..54c446ca3 100644 --- a/mrbgems/mruby-time/test/time.rb +++ b/mrbgems/mruby-time/test/time.rb @@ -226,3 +226,7 @@ assert('2000 times 500us make a second') do end t.usec == 0 end + +assert('Time.gm with Dec 31 23:59:59 1969 raise ArgumentError') do + assert_raise(ArgumentError) {Time.gm(1969, 12, 31, 23, 59, 59)} +end diff --git a/src/class.c b/src/class.c index 132cf0176..3f24528ca 100644 --- a/src/class.c +++ b/src/class.c @@ -1744,7 +1744,7 @@ mrb_class_path(mrb_state *mrb, struct RClass *c) return mrb_class_find_path(mrb, c); } else if (mrb_symbol_p(path)) { - /* topleve class/module */ + /* toplevel class/module */ const char *str; mrb_int len; diff --git a/src/variable.c b/src/variable.c index 968fc2fc1..de36efac6 100644 --- a/src/variable.c +++ b/src/variable.c @@ -955,27 +955,61 @@ find_class_sym(mrb_state *mrb, struct RClass *outer, struct RClass *c) return arg.sym; } +static struct RClass* +outer_class(mrb_state *mrb, struct RClass *c) +{ + mrb_value ov; + + ov = mrb_obj_iv_get(mrb, (struct RObject*)c, mrb_intern_lit(mrb, "__outer__")); + if (mrb_nil_p(ov)) return NULL; + switch (mrb_type(ov)) { + case MRB_TT_CLASS: + case MRB_TT_MODULE: + return mrb_class_ptr(ov); + default: + break; + } + return NULL; +} + +static mrb_bool +detect_outer_loop(mrb_state *mrb, struct RClass *c) +{ + struct RClass *t = c; /* tortoise */ + struct RClass *h = c; /* hare */ + + for (;;) { + if (h == NULL) return FALSE; + h = outer_class(mrb, h); + if (h == NULL) return FALSE; + h = outer_class(mrb, h); + t = outer_class(mrb, t); + if (t == h) return TRUE; + } +} + mrb_value mrb_class_find_path(mrb_state *mrb, struct RClass *c) { - mrb_value outer, path; + struct RClass *outer; + mrb_value path; mrb_sym name; const char *str; mrb_int len; - mrb_sym osym = mrb_intern_lit(mrb, "__outer__"); - outer = mrb_obj_iv_get(mrb, (struct RObject*)c, osym); - if (mrb_nil_p(outer)) return outer; - name = find_class_sym(mrb, mrb_class_ptr(outer), c); + if (detect_outer_loop(mrb, c)) return mrb_nil_value(); + outer = outer_class(mrb, c); + if (outer == NULL) return mrb_nil_value(); + name = find_class_sym(mrb, outer, c); if (name == 0) return mrb_nil_value(); - str = mrb_class_name(mrb, mrb_class_ptr(outer)); + str = mrb_class_name(mrb, outer); path = mrb_str_new_capa(mrb, 40); mrb_str_cat_cstr(mrb, path, str); mrb_str_cat_cstr(mrb, path, "::"); str = mrb_sym2name_len(mrb, name, &len); mrb_str_cat(mrb, path, str, len); - iv_del(mrb, c->iv, osym, NULL); + iv_del(mrb, c->iv, mrb_intern_lit(mrb, "__outer__"), NULL); iv_put(mrb, c->iv, mrb_intern_lit(mrb, "__classname__"), path); mrb_field_write_barrier_value(mrb, (struct RBasic*)c, path); return path; |
