Yukihiro "Matz" Matsumoto
a963e29b67
src/vm.c: calling C function may raise global jumps; fix #5391
2021-03-29 17:28:32 +09:00
Yukihiro "Matz" Matsumoto
3c2186f050
Merge pull request #5392 from mruby/revert-5391-throw
...
Revert "Fix `SIGSEGV` with mruby-method + mruby-catch"
2021-03-29 17:27:17 +09:00
Yukihiro "Matz" Matsumoto
4d3a1198f8
Revert "Fix SIGSEGV with mruby-method + mruby-catch"
2021-03-29 17:26:42 +09:00
Yukihiro "Matz" Matsumoto
76e4de7486
Merge pull request #5391 from dearblue/throw
...
Fix `SIGSEGV` with mruby-method + mruby-catch
2021-03-29 17:11:21 +09:00
Yukihiro "Matz" Matsumoto
a5244b02c5
numeric.c: function renaming.
...
- `mrb_num_div_int(mrb,x,y)` -> `mrb_div_int(mrb,x,y)`
- `mrb_num_div_flo(mrb,x,y)` -> `mrb_div_flo(x,y)`
They are internal function not supposed to be used outside of the core.
2021-03-28 08:35:29 +09:00
dearblue
6c097c7113
Fix SIGSEGV with mruby-method + mruby-catch
...
Previously, the following code would cause a `SIGSEGV`.
```ruby
mm = method(:throw)
define_method(:throw, ->(*args) { mm.call(*args) })
catch { |tag| throw tag }
```
I think the reason is in the `mrb_yield_with_class()` function:
- Even if a C function is called, `CI_ACC_SKIP` is used
- `cipop()` is not done if globally jumping from a C function
2021-03-27 17:35:02 +09:00
Yukihiro "Matz" Matsumoto
c2f929ad0f
Move default Integer#/ from rational.c to complex.c.
2021-03-27 12:38:16 +09:00
Yukihiro "Matz" Matsumoto
01a8edea35
complex.rb: add test for arithmetic operators. [ci skip]
...
Tests for (`Float` or `Integer`) `op` `Complex`. Also added test
dependency to `mruby-rational` since `int_div` definition relies on
`Rational` when `MRB_USE_RATIONAL` is defined.
2021-03-26 17:20:25 +09:00
Yukihiro "Matz" Matsumoto
9492e389b8
rational.rb: add test for arithmetic operators.
...
Tests for (`Float` or `Integer`) `op` `Rational`.
2021-03-26 07:37:50 +09:00
Yukihiro "Matz" Matsumoto
6d89047637
rational.c: fix wrong funcall method in rational_mul.
2021-03-25 22:31:32 +09:00
Yukihiro "Matz" Matsumoto
0aff83dcdc
rational.c: inline mrb_rational_eq().
...
It removes non-static function, so that strictly saying, it's
an incompatible change. But the function was added recently and I am
sure no one uses it yet.
2021-03-25 08:28:41 +09:00
Yukihiro "Matz" Matsumoto
4a0c14e3bd
rational.c: implement Rational#<=> in C.
2021-03-24 19:49:20 +09:00
Yukihiro "Matz" Matsumoto
3a2075343c
rational.c: implement Rational#/ and #quo in C.
2021-03-24 19:21:38 +09:00
Yukihiro "Matz" Matsumoto
f05f6f4d11
rational.c: implement Rational#* in C.
2021-03-24 19:11:02 +09:00
Yukihiro "Matz" Matsumoto
9d058342a5
rational.c: implement Rational#- in C.
2021-03-24 19:01:58 +09:00
Yukihiro "Matz" Matsumoto
7a35b64251
fixup! rational.c: prepare utility function rat_to_flo().
2021-03-24 19:01:38 +09:00
Yukihiro "Matz" Matsumoto
ac4fe26fbb
rational.c: prepare utility function rat_to_flo().
...
This function takes `struct mrb_rational*` and returns converted
`mrb_float` value.
2021-03-24 18:59:35 +09:00
Yukihiro "Matz" Matsumoto
7ca7bee9b3
rational.c: implement Rational#+ in C.
2021-03-24 13:57:49 +09:00
Yukihiro "Matz" Matsumoto
5a4958af26
complex.c: use mrb_num_div_flo to avoid copying function.
...
This change relies that `mrb_num_div_flo` does not use `mrb` inside.
2021-03-24 13:56:08 +09:00
Yukihiro "Matz" Matsumoto
092bba64e7
rational.c: check integer overflow in rational_minus.
2021-03-24 13:28:01 +09:00
Yukihiro "Matz" Matsumoto
49f75703cc
complex.rb: unary plus (+@) to return self avoiding copying.
2021-03-24 11:06:48 +09:00
Yukihiro "Matz" Matsumoto
9ed212ef9e
complex.c: implement Complex addition and subtraction in C.
2021-03-24 11:06:14 +09:00
Yukihiro "Matz" Matsumoto
fa3ac351ff
complex.c: override float division to support Complex.
2021-03-24 11:04:58 +09:00
Yukihiro "Matz" Matsumoto
afb3c00e8c
Use div_flo (copy of mrb_num_div_flo) for float division.
2021-03-24 10:56:01 +09:00
Yukihiro "Matz" Matsumoto
ec456e5b18
Use mrb_num_div_flo for float division.
...
This function handles zero division properly. Also fixed bugs that multiply
numbers instead of division.
2021-03-24 10:54:24 +09:00
Yukihiro "Matz" Matsumoto
98799aa6b8
Fix infinite recursive call bugs in integer division.
2021-03-24 10:52:31 +09:00
Yukihiro "Matz" Matsumoto
3deb62d653
complex.c: implement Complex#/ and #quo in C.
2021-03-24 10:27:49 +09:00
Yukihiro "Matz" Matsumoto
5573707d7f
complex.c: implement Complex#* in C.
2021-03-24 09:53:39 +09:00
Yukihiro "Matz" Matsumoto
dc5d74dda8
rational.rb: avoid 'NaNi` representation.
...
Use `NaN*i` as CRuby does.
2021-03-24 09:52:15 +09:00
Yukihiro "Matz" Matsumoto
6e1a13360f
Add `timeout-minutes' to GitHub workflow. [ci skip]
2021-03-23 15:02:48 +09:00
Yukihiro "Matz" Matsumoto
30576bf3c6
Merge pull request #5387 from shuujii/use-global-defines-for-mruby-bin-debugger
...
Use global defines for `mruby-bin-debugger`
2021-03-22 12:43:58 +09:00
Yukihiro "Matz" Matsumoto
2e87d83d8d
Merge pull request #5388 from shuujii/reorganize-types-for-ObjectSpace.count_objects
...
Reorganize types for `ObjectSpace.count_objects`
2021-03-22 12:43:13 +09:00
Yukihiro "Matz" Matsumoto
7479ae307b
nintendo_switch.rb: remove trailing white spaces; #5386
2021-03-22 12:39:48 +09:00
KOBAYASHI Shuji
c0fb675526
Reorganize types for ObjectSpace.count_objects
...
#### Addition
- T_COMPLEX
- T_RATIONAL
#### Deletion
- T_FALSE
- T_FREE
- T_TRUE
- T_SYMBOL
- T_UNDEF
2021-03-22 12:24:42 +09:00
Yukihiro "Matz" Matsumoto
dc6e7d5414
Merge pull request #5386 from LanzaSchneider/master
...
Add example for cross-compiling to Nintendo Switch
2021-03-22 12:06:59 +09:00
Yukihiro "Matz" Matsumoto
cd047b2989
Merge pull request #5385 from shuujii/add-configuration-for-MinGW-cross-compilation
...
Add configuration for MinGW cross compilation [ci skip]
2021-03-22 12:05:03 +09:00
KOBAYASHI Shuji
00a13e22dd
Use global defines for mruby-bin-debugger
2021-03-22 12:02:26 +09:00
Yukihiro "Matz" Matsumoto
68cf8346cd
Use global defines for Rational and Complex.
2021-03-22 10:59:35 +09:00
Yukihiro "Matz" Matsumoto
384865997d
build: provide global defines by build.defines.
2021-03-22 10:58:47 +09:00
Yukihiro "Matz" Matsumoto
fbc629c56f
codegen.c: fix integer size warnings.
...
along with repeated calls of `strlen()`.
2021-03-22 10:57:36 +09:00
Lanza
ad09c39514
Add example for cross-compiling to Nintendo Switch
...
Cross Compiling configuration for the Nintendo Switch, it requires Nintendo SDK
2021-03-21 16:58:42 +08:00
KOBAYASHI Shuji
b2c3ab8f3f
Add configuration for MinGW cross compilation [ci skip]
...
With this cross compiler configuration, all tests for full-core gembox on
Windows on GitHub Actions were successful.
2021-03-21 16:43:04 +09:00
Yukihiro "Matz" Matsumoto
5764ff0740
command.rb: replace %w() to plain [].
2021-03-21 13:23:35 +09:00
Yukihiro "Matz" Matsumoto
73056aeb2b
complex.c: define Complex#== in C.
...
This change also fixes the error caused by `rational.c` that calls
`mrb_complex_eq()`, which had been undefined.
2021-03-21 08:30:52 +09:00
Yukihiro "Matz" Matsumoto
a6d4477a09
memsize.c: handle MRB_TT_RATIONAL and MRB_TT_COMPLEX.
2021-03-21 08:29:05 +09:00
Yukihiro "Matz" Matsumoto
e21f293de5
rational.c: fix MRB_TT_RATIONAL and MRB_TT_COMPLEX confusion.
2021-03-20 18:03:11 +09:00
Yukihiro "Matz" Matsumoto
98821d2725
random.c: fixed seed underflow bug.
...
`MRB_INT_MIN` does not have a corresponding positive value.
2021-03-20 14:40:54 +09:00
Yukihiro "Matz" Matsumoto
d3184e4a6d
complex.c: overhaul complex operators.
...
- define `MRB_TT_COMPLEX`
- change object structure (`struct RComplex`)
- add memory management for `MRB_TT_COMPLEX`
- avoid operator overloading as much as possible
- as a result, performance improved a log
- should work with and without `Rational` defined
2021-03-19 10:37:10 +09:00
Yukihiro "Matz" Matsumoto
08f9d5bab5
rational.c: overhaul rational operators.
...
- define `MRB_TT_RATIONAL`
- change object structure (`struct RRational`)
- add memory management for `MRB_TT_RATIONAL`
- avoid operator overloading as much as possible
- implement division overloading in C
- as a result, performance improved a lot
2021-03-19 10:37:10 +09:00
Yukihiro "Matz" Matsumoto
eb07030308
numeric.c: avoid integer overflow; close #5384
...
Since `mruby` does not have `Bignum`, `Float#divmod` could overflow, so
it will return `Float` values when the divided value does not fit in
`mrb_int`. This behavior will be changed when `Bignum` is introduced to
`mruby` in the future.
2021-03-19 07:15:05 +09:00