| Age | Commit message (Collapse) | Author |
|
In the ancient Ruby, symbols are represented by integers. In that era,
to get string representation from integers, we used `Integer#id2sym`
method. Later, `Symbol` was introduced, and `id2sym` was used for
compatibility. Today, no one uses `id2sym` any longer. It is described
in ISO 30170:2012 standard but I consider it as a mistake.
|
|
Enclose the table contents of `opcode.md` as code
|
|
|
|
|
|
This gem contains only tests.
|
|
|
|
Previously, the task was executed as many times as there were targets, including `mruby-compiler`.
```console
% rm mrbgems/mruby-compiler/core/y.tab.c
% rake `pwd`/mrbgems/mruby-compiler/core/y.tab.c
YACC mrbgems/mruby-compiler/core/parse.y -> mrbgems/mruby-compiler/core/y.tab.c
YACC mrbgems/mruby-compiler/core/parse.y -> mrbgems/mruby-compiler/core/y.tab.c
```
|
|
As CRuby behaves.
|
|
Fix typo in `mrbgems/mruby-io/mrblib/io.rb`; ref cb55e7eca
|
|
|
|
|
|
When the receiver is the instance of subclass of `String`.
- `String#each_char`
- `String#each_line`
- `String#partition`
|
|
|
|
It used to be an alias to `IO#each_byte` but those methods should have
behave differently.
|
|
Even called for subclass of `Array`, according to new Ruby3.0 behavior.
Other methods of `Array` behave as Ruby3.0 from the first hand.
|
|
|
|
Fix symbol leak in `exc_to_s()`
|
|
|
|
|
|
Fix annotations for inline iseq of `Class.new` [ci skip]
|
|
Introduce `MRB_GC_RED`
|
|
- stop cross building
- add more gems for tests
- add `bintest`
|
|
Avoid ill-advised `goto`
|
|
|
|
|
|
|
|
Following functions are defined in `mrblib/numeric.c`:
- `Integer#ceil`
- `Integer#floor`
- `Integer#round`
- `Integer#truncate`
|
|
|
|
- `Random.rand` with `MRB_NO_FLOAT` behaves as `Random.rand(100)`
- `Random.rand(i)` where `i<0` raises `ArgumentError`
|
|
|
|
Replaces the magic number `7` except in `src/gc.c`.
|
|
|
|
ref #5362
|
|
|
|
|
|
- `_raw` does not describe the nature of the function
- the function protect errors during C function execution
|
|
|
|
|
|
|
|
shuujii/remove-unused-struct-in-include-mruby-variable.h
Remove unused struct in `include/mruby/variable.h`
|
|
shuujii/remove-unused--include-in-complex.c-and-rational.c
Remove unused `#include` in `complex.c` and `rational.c`
|
|
shuujii/remove-MRB_API-from-mrb_get_backtrace-definition
Remove `MRB_API` from `mrb_get_backtrace` definition
|
|
|
|
|
|
|
|
Introducing the `mrb_protect_raw()` API function
|
|
The purpose is two-fold:
1. to be able to specify a pointer directly when user data is used
When using `mrb_protect()`, it is necessary to allocate objects by `mrb_obj_cptr()` function when using user data.
Adding `mrb_protect_raw()` will make it simpler to reimplement `mrbgems/mruby-error`.
2. to correctly unwind callinfo when an exception is raised from a C function defined as a method (the main topic)
If a method call is made directly under `mrb_protect()` and a C function is called, control is returned from `mrb_protect()` if an exception occurs there.
In this case, callinfo is not restored, so it is out of sync.
Moreover, returning to mruby VM (`mrb_vm_exec()` function) in this state will indicate `ci->pc` of C function which is equal to `NULL`, and subsequent `JUMP` will cause `SIGSEGV`.
Following is an example that actually causes `SIGSEGV`:
- `crash.c`
```c
#include <mruby.h>
#include <mruby/compile.h>
#include <mruby/error.h>
static mrb_value
level1_body(mrb_state *mrb, mrb_value self)
{
return mrb_funcall(mrb, self, "level2", 0);
}
static mrb_value
level1(mrb_state *mrb, mrb_value self)
{
return mrb_protect(mrb, level1_body, self, NULL);
}
static mrb_value
level2(mrb_state *mrb, mrb_value self)
{
mrb_raise(mrb, E_RUNTIME_ERROR, "error!");
return mrb_nil_value();
}
int
main(int argc, char *argv[])
{
mrb_state *mrb = mrb_open();
mrb_define_method(mrb, mrb->object_class, "level1", level1, MRB_ARGS_NONE());
mrb_define_method(mrb, mrb->object_class, "level2", level2, MRB_ARGS_NONE());
mrb_p(mrb, mrb_load_string(mrb, "p level1"));
mrb_close(mrb);
return 0;
}
```
- compile & run
```console
% `bin/mruby-config --cc --cflags --ldflags` crash.c `bin/mruby-config --libs`
% ./a.out
zsh: segmentation fault (core dumped) ./a.out
```
After applying this patch, it will print exception object and exit normally.
The `mrb_protect()`, `mrb_ensure()` and `mrb_rescue_exceptions()` in `mrbgems/mruby-error` have been rewritten using `mrb_protect_raw()`.
|
|
- `mrb_exc_backtrace` to implement `Exception#backtrace`
- `mrb_get_backtrace` to implement `#caller`
|
|
- add comment for unpacking
- avoid saving the symbol in a local variable
|
|
|