| Age | Commit message (Collapse) | Author |
|
|
|
shuujii/add-mrb_num_args_error-for-wrong-number-of-arguments-error
Add `mrb_num_args_error()` for "wrong number of arguments" error
|
|
If `mrb_sym` is smaller than `int`, it is promoted to `int`.
|
|
|
|
shuujii/remove-location-info-from-Exception-inspect
Remove location info from `Exception#inspect`
|
|
The following improvements are made according to Ruby's behavior:
- Match location number to index.
- Remove duplicate most recent call output.
- Fix that first call is not output when array (unpacked) backtrace.
### Example
```ruby
def a; raise "error!" end
def b; a end
begin
b
rescue => e
e.backtrace if ARGV[0] == "unpack" # unpack backtrace
raise e
end
```
#### Before this patch:
```
$ bin/mruby example.rb unpack
trace (most recent call last):
[0] example.rb:2:in b
[1] example.rb:1:in a
example.rb:1: error! (RuntimeError)
```
#### After this patch:
```
$ bin/mruby example.rb unpack
trace (most recent call last):
[2] example.rb:4
[1] example.rb:2:in b
example.rb:1:in a: error! (RuntimeError)
```
|
|
Because location info (file name and line number) is kept in the backtrace,
it should not be kept in the result of `inspect` (and the exception object
itself), I think.
### Example
```ruby
# example.rb
begin
raise "err"
rescue => e
p e
end
```
#### Before this patch:
```
$ bin/mruby example.rb
example.rb:2: err (RuntimeError)
```
#### After this patch:
```
$ bin/mruby example.rb
err (RuntimeError)
```
|
|
To unify the style of messages.
|
|
|
|
|
|
|
|
|
|
If `MRB_INT16` is specified, the variable length argument `mrb_int` is
converted to `int`.
|
|
|
|
The binary sizes (gems are only `mruby-bin-mruby`) are reduced slightly in
my environment than before the introduction of new specifiers/modifiers
(5116789a) with this change.
------------+-------------------+-------------------+--------
BINARY | BEFORE (5116789a) | AFTER (This PR) | RATIO
------------+-------------------+-------------------+--------
mruby | 593416 bytes | 593208 bytes | -0.04%
libmruby.a | 769048 bytes | 767264 bytes | -0.23%
------------+-------------------+-------------------+--------
BTW, I accidentally changed `tasks/toolchains/visualcpp.rake` at #4613,
so I put it back.
|
|
- `size_t` is more commonly used.
- `len` argument of `mrb_str_new()` is `size_t`.
NOTE:
The test for `%l` is temporarily disabled because adding a new type to
`mrbgems/mruby-test/vformat.c` causes an error (memory error?) on Visual
Studio 2017 in AppVeyor.
|
|
It potentially not work when `mrb_float` is `float` because `float` variable
in variable length arguments is promoted to `double`.
Also I fixed build with `MRB_WITHOUT_FLOAT`.
|
|
It potentially breaks, for example, in the case of `mrb_int` is 64-bit
and more smaller type is passed by `%d`. In fact, the problem could
become apparent when I used `%d` to `backtrace_location::lineno` in
`src/backtrace.c:mrb_unpack_backtrace()` on AppVeyor.
Therefore, change `%d` for `int` (not `mrb_int`) so that it can be
used mostly without casting.
|
|
Format sequence syntax:
%[modifier]specifier
Modifiers:
----------+------------------------------------------------------------
Modifier | Meaning
----------+------------------------------------------------------------
! | Convert to string by corresponding `inspect` instead of
| corresponding `to_s`.
----------+------------------------------------------------------------
Specifiers:
----------+----------------+--------------------------------------------
Specifier | Argument Type | Note
----------+----------------+--------------------------------------------
c | char |
d,i | mrb_int |
f | mrb_float |
l | char*, mrb_int | Arguments are string and length.
n | mrb_sym |
s | char* | Argument is NUL terminated string.
t | mrb_value | Convert to type (class) of object.
v,S | mrb_value |
C | struct RClass* |
T | mrb_value | Convert to real type (class) of object.
Y | mrb_value | Same as `!v` if argument is `true`, `false`
| | or `nil`, otherwise same as `T`.
% | - | Convert to percent sign itself (no argument
| | taken).
----------+----------------+--------------------------------------------
This change will increase the binary size, but replacing all format strings
with new specifiers/modifiers will decrease the size because it reduces
inline expansion of `mrb_obj_value()`, etc. at the caller.
|
|
|
|
The addresses for packed inline symbols reference `mrb->symbuf` that
could be overridden by the later call of `mrb_sym2name_len`. Since
file names in call stack information are kept as symbols, keeping the
address in the C structures could cause problems like #4342.
This changes small incompatible changes in function prototypes:
* `mrb_parser_get_filename`: return value changed to `mrb_sym`.
* `mrb_debug_get_filename`: add `mrb_state*` as a first argument.
* `mrb_debug_get_line`: ditto.
I believe above functions are almost internal, and no third-party
mrbgem use them.
|
|
|
|
|
|
`exc_debug_info()` and `mrb_keep_backtrace()` raise `FrozenError`
if the exception is frozen and lead to infinite loop.
|
|
|
|
|
|
|
|
|
|
to 'int', possible loss of data
|
|
'int', possible loss of data
|
|
|
|
|
|
|
|
For readability's sake.
|
|
And arena-overflow error as well. They should not be caught by
`rescue` by default.
|
|
|
|
Instead of preserving a backtrace in `mrb_state`, `mrb_exc_set`
keeps packed backtrace in an exception object. `#backtrace` unpacks
it to an array of strings.
|
|
|
|
|
|
ref #3492 #3515 #3517
|
|
Otherwise line number information is lacked from exceptions
raised in VM, e.g. "super called outside of method".
|
|
|
|
|
|
|
|
|
|
|
|
The change may reduce flexibility, but I believe no one wants
that level of flexibility here.
|
|
|
|
This change reduce flexibility but makes mruby simpler and faster.
|
|
|