269 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto c022e4643f Avoid assignments from type checking String#__to_str. 2018-11-19 12:08:28 +09:00
Yukihiro "Matz" Matsumoto 610bcc88c2 Removed to_hash conversion method. 2018-11-19 12:08:28 +09:00
Yukihiro "Matz" Matsumoto ff08856fe3 Remove implicit conversion using to_str method; fix #3854
We have added internal convenience method `__to_str` which
does string type check.

The issue #3854 was fixed but fundamental flaw of lack of stack
depth check along with fibers still remains. Use `MRB_GC_FIXED_ARENA`
for workaround.
2018-11-19 12:05:46 +09:00
Yukihiro "Matz" Matsumoto afca99a40b Remove implicit conversion using to_int method.
The ISO standard does not include implicit type conversion using
`to_int`. This implicit conversion often causes vulnerability.
There will be no more attacks like #4120.

In addition, we have added internal convenience method `__to_int` which
does type check and conversion (from floats).
2018-11-19 11:28:51 +09:00
take-cheeze b37b312081 Rename libmruby stuff to avoid confusion 2018-10-29 14:07:16 +09:00
Yukihiro "Matz" Matsumoto 34872e90d4 Re-implement Array#_inspect and Hash#_inspect without blocks.
To reduce the env object allocation; ref #4143
2018-10-29 11:55:49 +09:00
Tomoyuki Sahara 91444c4747 replace quicksort with mergesort. 2018-10-18 13:07:47 +09:00
Yukihiro "Matz" Matsumoto 54ec08c7f1 Implement Hash#rehash in C using sg_compact(). 2018-09-26 23:09:48 +09:00
Yukihiro "Matz" Matsumoto d78acc7afe Add index to larger segment lists for performance 2018-09-26 23:09:48 +09:00
Yukihiro "Matz" Matsumoto 8ffd4e47fb Use mrb_undef_value for delete mark instead of shifting Hash entry table.
That means entry table should be compacted periodically by `sg_compact()`.
2018-09-26 23:09:48 +09:00
Yukihiro "Matz" Matsumoto 3a9caad8eb Move Symbol#to_proc to the core from mruby-symbol-ext gem.
Even though `Symbol#to_proc` is not included in ISO standard, the
`some_method(&:method_name)` is used very widely and convenient.
So we moved it to the core.
2018-09-20 13:47:29 +09:00
Yukihiro "Matz" Matsumoto 2be42aef0f Fix ISO/JIS section numbers. 2018-09-01 09:35:46 +09:00
Yukihiro "Matz" Matsumoto a3fb80904d Remove unused Hash#__update method. 2018-08-25 09:41:21 +09:00
Yukihiro "Matz" Matsumoto b3a1d37926 Make Array.new to accept both integers and floats.
This time we used `Integral` module which is mruby specific.
2018-08-25 09:19:17 +09:00
Yukihiro "Matz" Matsumoto b083c1351f Fixed the corner case bug in String#{gsub!,sub!}.
`"a".sub!("a", "a")` should not return `nil`.
2018-08-25 09:17:46 +09:00
Ichito Nagata 4a2b055cdd let Hash#merge keep ifnone value 2018-06-01 12:48:17 +09:00
Yukihiro "Matz" Matsumoto 50a9c5d7c7 Update the patch to not use funcall in C; ref #4013 2018-04-28 11:26:23 +09:00
kimu_shu 4b29abc565 Fix Enumerable#hash on non 32-bit integer conf. 2018-04-28 11:26:23 +09:00
Tomoyuki Sahara f0e54df4fe sort method should not consume system stack. 2018-04-23 12:28:15 +09:00
Yukihiro "Matz" Matsumoto d88191e7e7 Implement Array#__svalue in C. 2018-04-17 11:32:31 +09:00
Yukihiro "Matz" Matsumoto 1a8483f17e __sort_sub__ is a method defined in Array; fix #3970
Reorganize `__sort_sub__` arguments.
2018-03-16 14:49:51 +09:00
Yukihiro "Matz" Matsumoto ceeb8c05df Needed to pass sort block. 2018-03-16 08:20:43 +09:00
Yukihiro "Matz" Matsumoto e647b16d1d Should not define Float class in mrblib/00class.rb; ref #3828
Unless it is defined in `numeric.c`.
2017-12-13 08:42:07 +09:00
Yukihiro "Matz" Matsumoto bbb0882343 Modifying frozen objects will raise FrozenError.
`FrozenError` is a subclass of `RuntimeError` which used to be
raised.  [Ruby2.5]
2017-12-12 18:41:18 +09:00
YAMAMOTO Masaya 625f9f6fa3 Merge branch 'master' of github.com:mruby/mruby 2017-11-04 01:23:12 +09:00
Yukihiro "Matz" Matsumoto 0cf5a0ee37 Use alias to implement attr method 2017-10-28 00:29:30 +09:00
YAMAMOTO Masaya acdc2d1f24 Add MRB_WITHOUT_FLOAT 2017-10-11 17:58:11 +09:00
Christopher Aue c956e17c02 Replaced Array#each with while loop for performance reasons
Example benchmark:
$ time build/bench/bin/mruby -e "Array.new(2_000_000){ |i| i }.index{ |i| i == 1_999_999 }"

Before:
real    0m0.934s
user    0m0.922s
sys     0m0.003s

After:
real    0m0.590s
user    0m0.583s
sys     0m0.007s
2017-08-26 15:57:25 +02:00
Christopher Aue 3359b86ec7 Improved speed of enumeration methods 2017-07-30 13:19:31 +02:00
Christopher Aue b499ad6749 Fixed return value of Module#include and #prepend 2017-07-28 17:38:40 +02:00
Yukihiro "Matz" Matsumoto 7b8d784040 Reimplement sort method to reduce array copying. 2017-07-25 14:42:38 +09:00
Yukihiro "Matz" Matsumoto b30eba6a13 Make LocalJumpError a subclass of ScriptError.
It's incompatible with CRuby, but it is required for mruby because
it cannot detect `break` outside of loops in the parsing time, but
in the code generation time where it cannot raise `SyntaxError`.
2017-06-23 18:08:38 +09:00
Yukihiro "Matz" Matsumoto 057be5ffb5 use unless instead of if not. 2017-06-21 11:13:33 +09:00
ksss 63c0044b11 Fix result if pattern is empty 2017-03-22 22:19:34 +09:00
ksss 7a74a617ea Callback should yield with pattern every time 2017-03-19 23:04:22 +09:00
ksss 67a6982710 Support to return Enumerator for String#gsub,gsub! 2017-03-19 22:45:14 +09:00
ksss 4ee79a8777 Support to return enumerator when no block given 2017-03-15 16:58:29 +09:00
ksss 673ce237c4 Suuport custom separator 2017-03-15 16:58:28 +09:00
ksss 6eb02a892d Use duplicated object for block args 2017-03-15 16:58:28 +09:00
Yukihiro "Matz" Matsumoto 7590482d48 Merge branch 'master' into string-gsub 2017-03-11 10:22:17 +09:00
ksss b56ad8d122 \1 sequences as empty strings 2017-03-10 22:22:06 +09:00
ksss 4b3e6cf169 Avoid infinity loop when empty string pattern 2017-03-10 13:26:15 +09:00
Yukihiro "Matz" Matsumoto c6e5659fec Use string#upto() if available; fix #3489
Terminate loop if the value is longer than the last otherwise.
2017-03-10 10:39:43 +09:00
ksss eba4b1fd76 Check modifiable for String `bang' methods 2017-03-05 23:04:22 +09:00
Yukihiro "Matz" Matsumoto b23fb45f9c Integral#step without arg should loop forever as CRuby does. 2017-01-20 17:58:29 +09:00
Yukihiro "Matz" Matsumoto efebbbbf26 Implement Float shift methods in C 2016-11-23 09:45:50 +09:00
Yukihiro "Matz" Matsumoto 1685eff2a5 Fixed off-by-one error in String#[]= with Ranges 2016-11-16 10:16:14 +09:00
Yukihiro "Matz" Matsumoto 92f72c7490 make String#[]= to take Ranges as position argument 2016-11-16 02:04:56 +09:00
Nobuyoshi Nakada 6511bfd79a Removed trailing spaces 2016-09-28 12:29:41 +09:00
Yukihiro "Matz" Matsumoto ff3e4b91f2 Move Module#include and #prepend to class.c; ref #3197
To avoid VM nesting with mrb_funcall()
2016-08-20 00:03:30 +09:00