Commit Graph

5129 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto 4260ce83a9 vm.c: avoid bare macro constant reference. wrap it by defined(). 2022-04-09 23:43:03 +09:00
Yukihiro "Matz" Matsumoto bbf4423f4c bigint.c: y->sz > 2 can be fit in mrb_int. 2022-04-09 18:21:45 +09:00
Yukihiro "Matz" Matsumoto 88e0c64ffc class.c: fix bugs in inline method cache. 2022-04-09 17:16:12 +09:00
Yukihiro "Matz" Matsumoto b1d0296a93 class.c: clear method cache after remove_method. 2022-04-09 17:16:12 +09:00
Yukihiro "Matz" Matsumoto c30e6ebe12 gc.c: add red (persistent no scan) color in the comment [ci skip] 2022-04-09 17:16:12 +09:00
Yukihiro "Matz" Matsumoto f33537f4fd dump.c: fix a bug in dump data size of BIGINT pool.
Was dumping extra NUL (\0) after the data.
2022-04-09 17:16:11 +09:00
Yukihiro "Matz" Matsumoto a252893292 load.c: should not skip bigint literal length. 2022-04-09 17:16:11 +09:00
Yukihiro "Matz" Matsumoto dcaf4083d5 src/bigint.c: implement multi-precision integer.
To enable multi-precision integer support, you need to link
`mruby-bigint` mrbgem. The gem itself is empty but it turns on
the "bigint" support.
2022-04-09 17:16:10 +09:00
Yukihiro "Matz" Matsumoto 5a27b69aa6 numeric.c: remove duplicated code in int_divmod. 2022-04-06 17:04:40 +09:00
Yukihiro "Matz" Matsumoto 5bef8e4135 numeric.c: the result of -5.div(2) should be -3 as CRuby does. 2022-04-06 17:04:40 +09:00
Yukihiro "Matz" Matsumoto 6ed21ead21 Merge pull request #5682 from dearblue/heap_p
Fixed bounds check for `heap_p()` function in `src/gc.c`
2022-04-06 17:04:32 +09:00
Yukihiro "Matz" Matsumoto 3cf291f722 vm.c: create break object before clearing GC arena.
Otherwise it possibly cause use-after-free.
2022-04-04 12:26:52 +09:00
dearblue 87c9bd0754 Fixed bounds check for heap_p() function in src/gc.c
One extra element was included.
2022-04-03 22:14:42 +09:00
Yukihiro "Matz" Matsumoto 8aec568fc5 range.c: detect integer overflow. 2022-04-03 18:39:40 +09:00
Yukihiro "Matz" Matsumoto b99c389ec3 internal.h: aggregate internal functions.
Internal functions can only be called from within the library.
Functions listed in `mruby/internal.h` can be called from:

* core (src/*.c)
* gems (mrbgems/**/*.c)

But not from the application linked with `libmruby`.
2022-04-02 18:25:13 +09:00
Yukihiro "Matz" Matsumoto 00acae117d vm.c: target class may be NULL. 2022-04-01 16:40:06 +09:00
Yukihiro "Matz" Matsumoto d1f1b4ea38 cdump.c: add const qualifier for line number arrays. 2022-04-01 15:02:39 +09:00
Yukihiro "Matz" Matsumoto 7f5a490d09 vm.c: vm.c: stack may be reallocated in functions calls; aaa28a5
`mrb_range_new()` also calls VM recursively.
2022-03-26 21:06:02 +09:00
Yukihiro "Matz" Matsumoto aaa28a5089 vm.c: stack may be reallocated in functions calls.
Probably due to recursive VM calls via `mrb_funcall()`.
2022-03-25 12:54:45 +09:00
Yukihiro "Matz" Matsumoto d53a991b07 Merge pull request #5668 from dearblue/gcred
No need to protect red objects
2022-03-24 10:33:40 +09:00
Yukihiro "Matz" Matsumoto 74597c6159 numeric.c: fix compile errors with MRB_NO_FLOAT; fix #5672 2022-03-20 19:04:00 +09:00
Yukihiro "Matz" Matsumoto 4f869f3367 numeric.c: enhance float division to support Complex. 2022-03-18 14:23:17 +09:00
Yukihiro "Matz" Matsumoto fe03e01078 numeric.c: enhance integer division to support Rational and Complex.
No longer need to override division methods in mrbgems.
2022-03-18 12:27:46 +09:00
Yukihiro "Matz" Matsumoto 4dcdf78f8a numeric_ext.c: add Integer#pow() method.
Which takes optional second argument of modulo.
2022-03-17 23:25:50 +09:00
Yukihiro "Matz" Matsumoto 6b2f08d933 Merge pull request #5670 from dearblue/exc-message
Reimplement `Exception#message` in Ruby
2022-03-16 22:17:55 +09:00
Yukihiro "Matz" Matsumoto 4e1cf3293b string.h: replace obsolete functions with macros.
- mrb_string_value_ptr()
- mrb_string_value_len()
2022-03-15 19:08:25 +09:00
Yukihiro "Matz" Matsumoto 6aa5d53867 numeric.c: avoid mrb_float with MRB_NO_FLOAT; fix #5671
`MRB_USE_COMPLEX` is exclusive with `MRB_NO_FLOAT`, so we only need to
check the former.
2022-03-15 19:07:28 +09:00
Yukihiro "Matz" Matsumoto 37d6506972 string.c: remove unused API mrb_str_strlen().
Compatibility macro is provided for safety.
2022-03-14 14:11:25 +09:00
Yukihiro "Matz" Matsumoto c5f2ac896c array.c: refactoring allocation size error. 2022-03-13 19:58:57 +09:00
dearblue 75371b8831 Reimplement Exception#message in Ruby
Suppresses the possibility of `mrb_vm_exec()` being called recursively.
2022-03-13 18:56:23 +09:00
dearblue 98d90d83cc Change function name mrb_bob_init to mrb_do_nothing
This is because it is not limited to the `BasicObject#initialize` method.
2022-03-13 16:45:20 +09:00
dearblue c3eac4fe5c No need to protect red objects
The object in `GC_RED` does not need to be marked, and the objects connected to this object should also not need to be marked.
2022-03-13 16:28:43 +09:00
Yukihiro "Matz" Matsumoto 062c2128a3 numops.c: avoid mrb_funcall; call functions directly. 2022-03-12 13:31:38 +09:00
Yukihiro "Matz" Matsumoto 7659b3b271 numeric.c: avoid mrb_funcall; call functions directly.
When you try to call functions defined in mrbgems, you need to add the
names of functions to `mrbc.c`, since `mrbc` does not link any mrbgem
regardless of the configuration.
2022-03-12 13:31:38 +09:00
Yukihiro "Matz" Matsumoto b0d6413f2d numops.c: rename functions for addition and subtraction.
To more consistent names.

* mrb_num_plus() -> mrb_num_add()
* mrb_num_minus() -> mrb_num_sub()

Since no one seems to use those functions, there should be no problem.
We added migration macros for compatibility for safety.
2022-03-12 10:54:11 +09:00
Yukihiro "Matz" Matsumoto a20064bcb7 numops.c: separate API functions not used from mruby.
* mrb_num_plus()
* mrb_num_minus()
* mrb_num_mul()
2022-03-12 10:53:59 +09:00
Yukihiro "Matz" Matsumoto 5636e6ab54 numeric.c: rename and expose integer arithmetic functions.
* mrb_int_add()
* mrb_int_sub()
* mrb_int_mul()
2022-03-12 08:44:04 +09:00
Yukihiro "Matz" Matsumoto 55476efb62 error.c: use mrb_funcall_id and presym to call _sys_fail method. 2022-03-11 10:25:32 +09:00
Yukihiro "Matz" Matsumoto b3416832f4 vm.c: refactor block type checking. 2022-03-10 10:43:51 +09:00
Yukihiro "Matz" Matsumoto 0293037b21 proc.c: refactor proc type checking. 2022-03-10 10:43:22 +09:00
Yukihiro "Matz" Matsumoto 6ca1e5c8e0 kernel.c: use preallocated symbol. 2022-03-09 17:14:57 +09:00
Yukihiro "Matz" Matsumoto 6e964bd1c6 array.c: check size bound by ARY_MAX_SIZE not MRB_INT_MAX. 2022-03-09 15:21:15 +09:00
Yukihiro "Matz" Matsumoto 19b9184aa3 string.c: remove unnecessary goto. 2022-03-09 15:21:13 +09:00
Yukihiro "Matz" Matsumoto 2f8eba325a Merge pull request #5664 from dearblue/extend
Reimplement `Kernel.extend` in Ruby
2022-03-07 11:21:59 +09:00
Yukihiro "Matz" Matsumoto dc98988482 string.c: small refactoring regarding check_null_byte. 2022-03-06 23:49:40 +09:00
dearblue ac0d27d1a9 Reimplement Kernel.extend in Ruby 2022-03-06 13:48:04 +09:00
Yukihiro "Matz" Matsumoto 7528c25aae string.c: remove unnecessary mrb_assert_int_fit(). 2022-03-05 08:04:33 +09:00
Yukihiro "Matz" Matsumoto 31d4bbcfea string.c: improve size/capacity check before allocations. 2022-03-04 14:17:21 +09:00
Yukihiro "Matz" Matsumoto 876bcba694 string.c: avoid integer type mixture in mrb_str_cat(). 2022-03-03 16:29:54 +09:00
Yukihiro "Matz" Matsumoto ef3a56c92b error.c: (mrb_exc_new) use mrb_int instead of size_t. 2022-03-03 14:48:39 +09:00