| Age | Commit message (Collapse) | Author |
|
|
|
|
|
|
|
|
|
|
|
- `mrb_check_intern()` to return `mrb_value`
- `mrb_intern_check()` to return `mrb_sym` [NEW]
Other new functions:
- `mrb_intern_check_cstr()`
- `mrb_intern_check_str()`
|
|
Rename new functions:
- `mrb_convert_type(mrb,val,type,tname,method)`
=> `mrb_type_convert(mrb,val,type,tname,method)`
- `mrb_check_convert_type(mrb,val,type,tname,method)`
=> `mrb_type_convert_check(mrb,val,type,tname,method)`
Old names are defined by macros (support `tname` drop and
`char*` => `mrb_sym` conversion).
|
|
|
|
- Implement `Rational()` in `C`.
- Use `float` to `rational` conversion function taken from:
https://rosettacode.org/wiki/Convert_decimal_number_to_rational#C
|
|
|
|
|
|
Linux `atan2(3)` man page says:
```
If y is positive infinity (negative infinity) and x is positive infinity,
+pi/4 (-pi/4) is re‐ turned.
```
But on Microsoft VC/MinGW, `atan2()` returns `NaN` if either of
arguments is infinite. So we skip those tests on the platforms.
|
|
|
|
`mrb_int()` includes implicit integer conversion, where `mrb_integer()`
does not. In this case, we know `obj` is an integer before hand.
|
|
Caused from combination of `mrb_int`, `int` and `size_t`..
|
|
Implements `catch`/`throw` non-local jump inherited from Lisp.
`catch([tag]) {|tag| block } -> obj`
Example:
```
catch(:foo) { 123 } # => 123
catch(:foo) { throw(:foo, 456) } # => 456
catch(:foo) { throw(:foo) } # => nil
```
|
|
From human readable (ASCII) string representation to binary dump of
IEEE754 in little endian.
|
|
They are basically the copy of instance variable tables. On my Linux
box, memory consumption of `mrbtest` measured by `valgrind` is:
- old: 17,683,830 bytes
- new: 14,283,749 bytes
|
|
It uses `mrb_str_new_lit()` internally, but it doesn't need to express
it in the name of the function (macro).
|
|
|
|
Where fixnum overflow can happen.
|
|
`sizeof(rand_state)` had been bigger than `sizeof(void*)*3`. Changed
random number generator to `Xorshift96` on 32 bit platforms.
|
|
- Integrate `Fixnum` and `Integer`
- Remove `Integral`
- `int / int -> int`
- Replace `mrb_fixnum()` to `mrb_int()`
- Replace `mrb_fixnum_value()` to `mrb_int_value()`.
- Use `mrb_integer_p()` instead of `mrb_fixnum_p()`
|
|
Co-authored-by: taiyoslime <[email protected]>
Co-authored-by: smallkirby <[email protected]>
|
|
|
|
|
|
Based on cremno/mruby@6bd0119
|
|
They used to return `mrb_value` but now return `mrb_sym` for consistency
with other `intern` functions. If symbols are not defined, `check`
functions return `0`, instead of `nil` in the past.
It causes API incompatibility but I believe few people use those
functions out of the core, and those changes are very easy to handle,
hopefully.
|
|
We call `mrb_intern_str()` later anyway, so there's no need to avoid
defining a new symbol here.
|
|
Based on cremno/mruby@d446192
|
|
|
|
We still have `#define MRB_TT_FIXNUM MRB_TT_INTEGER` for compatibility.
|
|
|
|
|
|
Also remove some unnecessary code.
|
|
https://bugs.ruby-lang.org/issues/9982
|
|
* The `Fixnum` constant is now an alias for the `Integer` class.
* Remove `struct mrb_state::fixnum_class` member.
If necessary, use `struct mrb_state::integer_class` instead.
|
|
|
|
TODO: Unlike CRuby, mruby's `Proc#parameters` does not distinguish
required keyword arguments and optional keyword arguments currently.
|
|
|
|
|
|
- `MRB_WITHOUT_FLOAT` => `MRB_NO_FLOAT`
- `MRB_USE_FLOAT` => `MRB_USE_FLOAT32`
The former is to use `USE_XXX` naming convention. The latter is to make
sure `float` is 32bit float and not floating point number in general.
|
|
|
|
On platforms where `time_t` is unsigned, negative time can be a result
of integer casting. Out-of-range error is too strict for those cases.
This fix does not address wrong time value in `MRB_WORD_BOXING`. It will
be addressed later (by introducing "big" integers).
|
|
|
|
|
|
When a global jump occurs, look at the catch handler table to determine where to jump.
In that case, `pc` already shows the following instruction, but since the table shows `begin_offset ... end_offset`, the comparison is done with `begin_offset < pc && pc <= end_offset`.
If there is a corresponding handler, move `pc` to `handler.target_offset` and continue running the VM.
When a global jump across `ensure` is made by `return`, `break`, `next`, `redo` and `retry`, the extended `RBreak` object saves and restores the C-level execution position.
This extended `RBreak` can have tag information, which makes it a pseudo coroutine (the "tag" mimics CRuby).
The implementation of pseudo coroutines by `RBreak` is summarized by `CHECKPOINT_RESTORE ... CHECKPOINT_MAIN ... CHECKPOINT_END` and `throw_tagged_break` / `unwind_ensure` macros.
The restart of processing is branched by `RBREAK_TAG_FOREACH(DISPATCH_CHECKPOINTS)`.
- Not only `rescue` blocks but also `ensure` blocks are now sandwiched between `OP_EXCEPT` and `OP_RAISEIF`.
- Remove the function `ecall()`.
It is no longer necessary to re-enter the VM to perform an "ensure block".
This will resolves #1888.
- Added instruction `OP_JUW` (Jump while UnWind).
It jumps unconditionally like `OP_JMP`, but searches the catch handler table and executes the ensure block.
Since it searches the catch handler table, it is much heavier than `OP_JMP`.
|
|
- `OP_EXCEPT` checks if `mrb->exc` is `NULL`, `MRB_TT_EXCEPTION` or
`MRB_TT_BREAK`.
If `mrb->exc` is `NULL`, it will be replaced with `nil`.
- If `OP_RAISE` is `nil`, it does nothing and the immediately
following instruction is executed (like `OP_NOP`).
Also, in case of `RBreak` object, it moves to the processing for
`break`.
With this change, the instruction name is changed from
`OP_RAISE` to `OP_RAISEIF`.
|
|
The catch handler table is combined with iseq block.
This is to prevent the structure from growing by adding a field for the
catch handler table to the `mrb_irep` structure.
"iseq block" and "catch handler table":
[number of catch handler table (2 bytes)]
[number of byte code (4 bytes)]
[iseq (any bytes)]
[catch handlers (multiple of 7 bytes)]
catch handler:
[catch type (1 byte)]
[begin offset (2 bytes)]
[end offset (2 bytes)]
[target offset (2 bytes)]
catch type: enum mrb_catch_type (0 = rescue, 1 = ensure)
begin offset: Includes the specified instruction address
end offset: Does not include the specified instruction address
target offset: replaces pc with the specified instruction address
This table is not expanded by `read_irep_record_1()`.
The necessary elements are expanded one by one when used.
|
|
|