summaryrefslogtreecommitdiffhomepage
path: root/src
AgeCommit message (Collapse)Author
2021-07-28debug.c: uses most space efficient packed map for line information.Yukihiro "Matz" Matsumoto
2021-07-26debug.c: small refactoring.Yukihiro "Matz" Matsumoto
2021-07-26debug.c: remove type cast warnings.Yukihiro "Matz" Matsumoto
2021-07-26fmt_fp.c: add implicit cast from `mrb_float` to `int8_t`.Yukihiro "Matz" Matsumoto
2021-07-26vm.c: fix integer type error in `mrb_protect_error`.Yukihiro "Matz" Matsumoto
2021-07-25Remove redundant include headers.Yukihiro "Matz" Matsumoto
- stdlib.h - stddef.h - stdint.h - stdarg.h - limits.h - float.h
2021-07-17Explicit write barrier for bindingdearblue
2021-07-17codedump.c: update some instructions.Yukihiro "Matz" Matsumoto
- OP_GETGV - OP_SETGV - OP_GETSV - OP_SETSV - OP_GETIV - OP_SETIV - OP_GETCV - OP_SETCV - OP_GETCONST - OP_SETCONST - OP_GETMCNST - OP_SETMCNST - OP_GETUPVAR - OP_SETUPVAR
2021-07-12load.c: call `mrb_top_run()` from `mrb_load_proc()`; fix #5504Yukihiro "Matz" Matsumoto
So that the function behave consistently with `mrb_load_proc()`.
2021-07-10numeric.c: `self` should always be an integer in `__coerce_step_counter`.Yukihiro "Matz" Matsumoto
2021-07-10Update internal methods not to be listed in backtraces.Yukihiro "Matz" Matsumoto
- String#__lines - Array#__ary_eq - Array#__ary_cmp - Hash#__delete - Kernel#__case_eqq - Integer#__coerce_step_counter
2021-07-09Do not include `stdint.h` before `mruby.h`dearblue
2021-07-09debug.h: use `uint8_t` instead of `char` for BER compressed binary.Yukihiro "Matz" Matsumoto
A change in `load.c` is left uncommitted.
2021-07-09debug.h: use `uint8_t` instead of `char` for BER compressed binary.Yukihiro "Matz" Matsumoto
2021-07-09cdump.c: avoid uninitialized local variable.Yukihiro "Matz" Matsumoto
2021-07-09range.c: avoid implicit conversion from `mrb_float` to `mrb_int`.Yukihiro "Matz" Matsumoto
2021-07-08range.c: should not include internal `__num_to_a` in the backtrace.Yukihiro "Matz" Matsumoto
2021-07-08backtrace.c: skip C method without `mid` set.Yukihiro "Matz" Matsumoto
That means it's a method not to be included in the backtrace, for example `raise`.
2021-07-08debug.c: new debug line information format `mrb_debug_line_packed_map`.Yukihiro "Matz" Matsumoto
It uses BER number compression of delta of instruction positions and line numbers. BER compression is a variable length number representation. * `mrb_debug_line_ary`: array of line numbers represented in `uint16_t`. `[lineno, lineno, ...]` * `mrb_debug_line_flat_map`: array of `mrb_irep_debug_info_line`, which is `struct {uint32_t pos; uint16_t lineno}`, for each line. * `mrb_debug_line_packed_map` [new]: sequence of BER compressed 2 numbers, `pos_delta, lineno_delta`. Deltas are differences from previous values (starting `0`). `line_entry_counts` represents total length of a packed map string for this type.
2021-07-03vm.c: `OP_DEF` to push a symbol to `a` register.Yukihiro "Matz" Matsumoto
The code generator no longer need to emit `OP_LOADSYM` after `OP_DEF`. `doc/opcode.md` is also updated.
2021-07-02vm.c: need to adjust `pc` for `OP_EXT[123]`.Yukihiro "Matz" Matsumoto
2021-07-02error.c: `mrb_obj_as_string` and `mrb_inspect` may return non-object (`undef`).Yukihiro "Matz" Matsumoto
2021-06-30Revert "Remove `OP_EXT[123]` from operands."Yukihiro "Matz" Matsumoto
This reverts commit fd10c7231906ca48cb35892d2a86460004b62249. I thought it was OK to restrict index value within 1 byte, but in some cases index value could be 16 bits (2 bytes). I had several ideas to address the issue, but reverting `fd10c72` is the easiest way. The biggest reason is `mruby/c` still supports `OP_EXT[123]`, so that they don't need any additional work.
2021-06-28Drop unnecessary upper procs linked from class/module/def syntaxdearblue
It does not need to hold an anonymous proc for constant search. Also, this change can be expected to cause an anonymous proc to be GC'd. This is useful for metaprogramming that makes heavy use of the `class`/`module`/`def` syntax in the `class_eval`/`eval` method. Example: - code ```ruby p ObjectSpace.count_objects String.class_eval do def a end end p ObjectSpace.count_objects String.class_eval do eval <<~CODE def b end CODE end p ObjectSpace.count_objects ``` - result of building mruby-head (d63c0df6b) with `build_config/default.rb` ``` {:TOTAL=>1024, :FREE=>262, :T_PROC=>495, :T_ENV=>61, ...} {:TOTAL=>1024, :FREE=>259, :T_PROC=>497, :T_ENV=>62, ...} {:TOTAL=>1024, :FREE=>255, :T_PROC=>500, :T_ENV=>63, ...} ``` - result of building mruby with this patch and `build_config/default.rb` ``` {:TOTAL=>1024, :FREE=>264, :T_PROC=>494, :T_ENV=>60, ...} {:TOTAL=>1024, :FREE=>262, :T_PROC=>495, :T_ENV=>61, ...} {:TOTAL=>1024, :FREE=>261, :T_PROC=>496, :T_ENV=>61, ...} ```
2021-06-26Fixed finding variables from `proc` in `binding.eval` faileddearblue
Previously the following code did not produce the expected results: ```ruby bx = binding block = bx.eval("a = 1; proc { a }") bx.eval("a = 2") p block.call # Expect 2 but return 1 due to a bug ``` The previous implementation of `Binding#eval` evaluated the code and then merged the top layer variables. This patch will parse and expand the variable space before making a call to `eval`. This means that the call to `Binding#eval` will do the parsing twice. In addition, the following changes will be made: - Make `mrb_parser_foreach_top_variable()`, `mrb_binding_extract_proc()` and `mrb_binding_extract_env()` functions private global functions. - Remove the `posthook` argument from `mrb_exec_irep()`. The `posthook` argument was introduced to implement the `binding` method. This patch is unnecessary because it uses a different implementation method. ref #5362 fixed #5491
2021-06-25class.c: call `method_added` hooks on alias definitions; #2339Yukihiro "Matz" Matsumoto
2021-06-24class.c: call hook methods on method definitions; close #2339Yukihiro "Matz" Matsumoto
- `Module#method_added` - `BasicObject#singleton_method_added`
2021-06-21numeric.c: add optional `ndigits` argument to rounding methods.Yukihiro "Matz" Matsumoto
- `truncate` - `floor` - `ceil` `round` already takes `ndigits`.
2021-06-20Use `MRB_VTYPE_FOREACH()` in `src/object.c`dearblue
2021-06-20Added `MRB_OBJ_ALLOC()` macro that does not require a castdearblue
The `MRB_OBJ_ALLOC()` macro function returns a pointer of the type corresponding to the constant literal defined in `enum mrb_vtype`.
2021-06-19Added `MRB_API` function to get block arguments info.dearblue
- ` mrb_block_given_p()` -- The name comes from CRuby's `rb_block_given_p ()` At the same time, it applies to `f_instance_eval()` and `f_class_eval()` of `mruby-eval`.
2021-06-17variable.c: add `skip` argument to skip `base` class in lookup.Yukihiro "Matz" Matsumoto
`mrb_vm_const_get` function looks up the constant first in the base class, so that fallback `const_get` need not to search from the base.
2021-06-17variable.c: refactor `mrb_vm_const_get` function.Yukihiro "Matz" Matsumoto
2021-06-17variable.c: skip prepended module for constant lookup.Yukihiro "Matz" Matsumoto
```ruby module M FOO = 'm' end class A FOO = 'a' prepend M end class B < A def foo p FOO end end B.new.foo # should print `m` not `a` ```
2021-06-17class.c: use `MRB_FLAG_TEST()` macro.Yukihiro "Matz" Matsumoto
2021-06-17Revert "`instance_eval` for classes and modules should behave as `class_eval`."Yukihiro "Matz" Matsumoto
This reverts commit ee3017496ba60ca418b5e54c1f8f5d8b38524a52. I misunderstood something and the new behavior was different from CRuby. The issue was reported by @dearblue, regarding #5478
2021-06-16Merge pull request #5445 from jbampton/add-codespell-pre-commit-hookYukihiro "Matz" Matsumoto
Run pre-commit with GitHub Actions
2021-06-16Run pre-commit with GitHub ActionsJohn Bampton
Running pre-commit with GitHub Actions now gives us more tests and coverage Remove duplicate GitHub Actions for merge conflicts and trailing whitespace Remove duplicate checks for markdownlint and yamllint from the GitHub Super-Linter Add new custom pre-commit hook running with a shell script to sort alphabetically and uniquify codespell.txt Add new pre-commit hook to check spelling with codespell https://github.com/codespell-project/codespell Fix spelling
2021-06-15numeric.c: restore `fmt` argument for backward compatibility.Yukihiro "Matz" Matsumoto
`mrb_float_to_str()` used to take `fmt` argument. We thought no one used the function, and OK to remove the argument. But at least `mruby-redis` gem used the function.
2021-06-12readint.c: fixed typo.Yukihiro "Matz" Matsumoto
2021-06-12Raise `TypeError` with `super` inside `instance_eval` / `class_eval`dearblue
Commit d0f60182af9114f6840d993d74f492e483302805 introduced an exception as a limitation of mruby. Subsequent CRuby-2.7 has changed its behavior to raise an exception. ref: https://github.com/ruby/ruby/commit/55b7ba368696033f2e89b77cbcd4a05dec97b139
2021-06-11readint.c: add new function `mrb_int_read`.Yukihiro "Matz" Matsumoto
Difference from `strtoul(3)`: * reads `mrb_int` based on configuration * specifies the end of the string * no sign interpretation * base 10 only
2021-06-10readflt.c: renamed from `strtod.c`Yukihiro "Matz" Matsumoto
The file provides `mrb_read_float()` renamed from `vim_strtod()`.
2021-06-08string.c: make `mrb_str_len_{inum,dbl}()` static.Yukihiro "Matz" Matsumoto
2021-06-08string.c: remove two unused functions.Yukihiro "Matz" Matsumoto
* `mrb_cstr_to_inum()` * `mrb_cstr_to_dbl()`
2021-06-08string.c: add `base>36` check to `String#to_i`.Yukihiro "Matz" Matsumoto
2021-06-05codedump.c: fix a compiler condition bug with `MRB_NO_FLOAT`.Yukihiro "Matz" Matsumoto
2021-06-02vm.c: unify `JUMP` instructions in `OP_SEND`.Yukihiro "Matz" Matsumoto
2021-06-01cdump.c: rename `dump_` prefix to `cdump` for static functions.Yukihiro "Matz" Matsumoto
2021-06-01cdump.c: separate irep dump in C feature.Yukihiro "Matz" Matsumoto