summaryrefslogtreecommitdiffhomepage
path: root/include
AgeCommit message (Collapse)Author
2021-07-26irep.h: operand c should be fit in `uint8_t`.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-17Output an error if the `INTPTR_MAX` macro is undefined in C++dearblue
When doing `conf.enable_cxx_abi` and compiling with FreeBSD + clang or MinGW, such as `INTPTR_MAX` constant macro is not defined if `#include <stdint.h>` precedes `#include <mruby.h>`. Currently I get a warning when I use an undefined macro, but if I don't notice it I get confused in a link error. It can be expected that the problem will be easier to understand by making a clear error. Adding `-Werror=undef` as a compiler flag can also result in an error, but this can be a problem if the system header file itself uses undefined macros, for example. This patch does minimal confirmation only, but has no side effects.
2021-07-09debug.h: use `uint8_t` instead of `char` for BER compressed binary.Yukihiro "Matz" Matsumoto
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-03ops.h: made terms consistent.Yukihiro "Matz" Matsumoto
- `Lit` -> `Pool` - `SEQ` -> `Irep`
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-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-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-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-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-08string.c: remove two unused functions.Yukihiro "Matz" Matsumoto
* `mrb_cstr_to_inum()` * `mrb_cstr_to_dbl()`
2021-06-05ops.h: fix term consistency. `Lit` -> `Pool`.Yukihiro "Matz" Matsumoto
2021-05-30numeric.c: introduce `mrb_int_to_cstr()` to dump `mrb_int`.Yukihiro "Matz" Matsumoto
* refactor `mrb_integer_to_str()` * refactor `mrb_str_format()`
2021-05-27array.c: unify `mrb_ary_ref` and `mrb_ary_entry`Yukihiro "Matz" Matsumoto
Use only `mrb_ary_entry` hereafter.
2021-05-22fp_fmt.c: remove `mrb_float_to_cstr()`.Yukihiro "Matz" Matsumoto
The function was intended to be a utility function for `mruby-sprintf`. The functionality was integrated into `sprintf.c`.
2021-05-22fmt_fp.c: replace with public domain float format routine; ref #5448Yukihiro "Matz" Matsumoto
The original code can be found in `https://github.com/dhylands/format-float`. Changes: - support `double` - support `#` (alt_form) modifier - small refactoring
2021-05-21numeric.h: remove 2 functions from `MRB_API`Yukihiro "Matz" Matsumoto
- `mrb_float_to_str()` - `mrb_float_to_cstr()` Both functions will be replaced to support new coming `format-float.c`.
2021-05-17Global renaming regarding `integer` and `float`.Yukihiro "Matz" Matsumoto
Consistent number conversion function names: * `mrb_value` to immediate (C) value * `mrb_int()` -> `mrb_as_int()` * `mrb_to_flo()` -> `mrb_as_float()` * `mrb_value` to `mrb_value` (converted) * `mrb_to_int()' * `mrb_Integer()` - removed * `mrb_Float()` -> `mrb_to_float` Consistent function name (avoid `_flo` suffix): * `mrb_div_flo()` -> `mrb_div_float`
2021-05-17Rename `mrb_fixnum_to_str` to `mrb_integer_to_str`.Yukihiro "Matz" Matsumoto
2021-05-17Rename `mrb_flo_to_fixnum` to `mrb_float_to_integer`.Yukihiro "Matz" Matsumoto
2021-05-16numeric.h: reduce conditional compilation branch on `MRB_NO_FLOAT`.Yukihiro "Matz" Matsumoto
2021-05-13Update `mrb_bool` definition; close #2385Yukihiro "Matz" Matsumoto
- move `TRUE/FALSE` definition from `mrbconf.h` (not configurable) - use C/C++ definition of boolean type for `mrb_bool` The fix is originally written by @take-cheeze.
2021-04-24Introduce `MRB_GC_RED`dearblue
Replaces the magic number `7` except in `src/gc.c`.
2021-04-22error.h: rename `mrb_protect_raw` to `mrb_protect_error`; #5415Yukihiro "Matz" Matsumoto
- `_raw` does not describe the nature of the function - the function protect errors during C function execution
2021-04-20Remove unused struct in `include/mruby/variable.h`KOBAYASHI Shuji
2021-04-19Merge pull request #5415 from dearblue/unwind-mrb_protectYukihiro "Matz" Matsumoto
Introducing the `mrb_protect_raw()` API function
2021-04-19Introducing the `mrb_protect_raw()` API functiondearblue
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()`.
2021-04-19backtrace.c: remove `MRB_API` from internal functions.Yukihiro "Matz" Matsumoto
- `mrb_exc_backtrace` to implement `Exception#backtrace` - `mrb_get_backtrace` to implement `#caller`
2021-04-16feat(CI): add the GitHub Super LinterJohn Bampton
The GitHub Super Linter is a more robust and better supported tool than the current GitHub Actions we are using. Running these checks: ERROR_ON_MISSING_EXEC_BIT: true VALIDATE_BASH: true VALIDATE_BASH_EXEC: true VALIDATE_EDITORCONFIG: true VALIDATE_MARKDOWN: true VALIDATE_SHELL_SHFMT: true VALIDATE_YAML: true https://github.com/marketplace/actions/super-linter https://github.com/github/super-linter Added the GitHub Super Linter badge to the README. Also updated the pre-commit framework and added more documentation on pre-commit. Added one more pre-commit check: check-executables-have-shebangs Added one extra check for merge conflicts to our GitHub Actions. EditorConfig and Markdown linting. Minor grammar and spelling fixes. Update linter.yml
2021-04-12proc.h: add type cast to silence warning; ref #5402Yukihiro "Matz" Matsumoto
2021-04-03chore: fix spellingJohn Bampton
2021-03-19rational.c: overhaul rational operators.Yukihiro "Matz" Matsumoto
- 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-12codegen.c: no integer overflow error in `codegen`; close #5376Yukihiro "Matz" Matsumoto
Add new pool value type `IREP_TT_BIGINT` and generate integer overflow error in the VM. In the future, `mruby` will support `Bignum` for integers bigger than `mrb_int` (probably using `mpz`).
2021-03-08ISO C99 doesn't support unnamed unions; fix #5354Yukihiro "Matz" Matsumoto
2021-03-05Merge pull request #5373 from mruby/stableYukihiro "Matz" Matsumoto
Merge mruby 3.0.0
2021-03-05Update version and release date. (mruby 3.0.0 (2021-03-05))3.0.0mimaki
2021-03-04Fix `mrb_pool_value` to keep `int64` on 32 bit platforms; fix #5366Yukihiro "Matz" Matsumoto
2021-02-19mruby/value.h: `MRB_TT_CPTR` is immediate with `MRB_NO_BOXING`.Yukihiro "Matz" Matsumoto
The issue is reported by @shuujii.
2021-02-19Fix `mrb_immediate_p()` definition for `MRB_NO_BOXING`; ref #5352Yukihiro "Matz" Matsumoto
2021-02-19Check `MRB_TT_*` before object allocation; ref #5352Yukihiro "Matz" Matsumoto
2021-02-14Add `-s` option to `mrbc` for make variable staticKOBAYASHI Shuji
2021-02-13chore: fix spellingJohn Bampton
Normally a single spell checker can't find all the mistakes or check all types of code. These mistakes were found by another spell checker inside my editor with a more manual sift / find.
2021-02-12include/mruby/array.h: `ARY_LEN()` should return `mrb_int`.Yukihiro "Matz" Matsumoto
It used to return `mrb_ssize` but its size may differ from `mrb_int`, e.g. `MRB_INT64` on `MRB_32BIT` architecture.
2021-02-08Allow the case `MRB_32BIT` and `MRB_NO_BOXING` and `MRB_USE_FLOAT32`; #4382Yukihiro "Matz" Matsumoto
2021-02-03Update version to `3.0.0RC`.3.0.0-rcmimaki
2021-02-01Allow more than 256 child `irep`; fix #5310Yukihiro "Matz" Matsumoto
We have introduced following new instructions. * `OP_LAMBDA16` * `OP_BLOCK16` * `OP_METHOD16` * `OP_EXEC16` Each instruction uses 16 bits operand for `reps` index. Since new instructions are added, `mruby/c` VM should be updated. Due to new instructions, dump format compatibility is lost, we have increased `RITE_BINARY_MAJOR_VER`. In addition, we have decreased the size of `refcnt` in `mrb_irep` from `uint32_t` to `uint16_t`, which is reasonably big enough.