Compare commits

..

1239 Commits

Author SHA1 Message Date
mimaki b4f36b1ad9 Merge branch 'master' into stable 2023-01-18 10:45:35 +09:00
Yukihiro "Matz" Matsumoto 3a7e138c05 mruby/internal.h: add mrb_env_new to the internal function header 2023-01-18 10:37:48 +09:00
Yukihiro "Matz" Matsumoto e6cf932d38 fixup! mruby/internal.h: add codedump functions to the internal function header 2023-01-18 10:37:48 +09:00
Yukihiro "Matz" Matsumoto 55eea005c8 mruby/internal.h: add codedump functions to the internal function header
ref #5906
2023-01-18 10:37:48 +09:00
mimaki 23aa5f91bc Update version to 3.2.0RC2. 2023-01-18 10:26:58 +09:00
mimaki 830f88c5a0 Merge commit '9deb52c7b2ba6028d996172bfdd6cf8a0405ce1c' into stable 2023-01-18 09:45:23 +09:00
Yukihiro "Matz" Matsumoto 3639feb047 Merge pull request #5908 from dearblue/env-unshare.2
Make `mrb_env_unshare()` call in `mrb_vm_run()`
2023-01-18 08:05:00 +09:00
Yukihiro "Matz" Matsumoto 63597cbbd1 Merge pull request #5910 from mruby/dependabot/github_actions/github/super-linter-4.10.1
build(deps): bump github/super-linter from 4.10.0 to 4.10.1
2023-01-18 07:53:11 +09:00
Yukihiro "Matz" Matsumoto faa6a5cb4f Merge pull request #5906 from AlexDenisov/codedump-to-file
Add ability to dump bytecode into an arbitrary file
2023-01-18 07:37:12 +09:00
AlexDenisov e15288e460 Add ability to dump bytecode into an arbitrary file 2023-01-17 19:01:55 +01:00
dependabot[bot] 823b8e4148 build(deps): bump github/super-linter from 4.10.0 to 4.10.1
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.10.0 to 4.10.1.
- [Release notes](https://github.com/github/super-linter/releases)
- [Changelog](https://github.com/github/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/github/super-linter/compare/v4.10.0...v4.10.1)

---
updated-dependencies:
- dependency-name: github/super-linter
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-17 14:01:22 +00:00
Yukihiro "Matz" Matsumoto 9deb52c7b2 mruby-io/io.c: allow disabling popen
When `MRB_NO_IO_POPEN` is defined (or iPhone is target), `IO#popen`
will be disabled.
2023-01-17 18:25:23 +09:00
Yukihiro "Matz" Matsumoto 6b87aae757 doc/guides/compile.md: update compilation example
Show usage of multiple command-line options to `mruby-config`.
2023-01-17 18:23:29 +09:00
Yukihiro "Matz" Matsumoto 10768c1191 LEGAL: add entries for non-MIT licensed files. 2023-01-17 18:23:29 +09:00
Yukihiro "Matz" Matsumoto 2c261503b5 doc/internal/boxing.md: remove an extra double quote sign. 2023-01-16 19:01:11 +09:00
Yukihiro "Matz" Matsumoto 7a6d03f869 vm.c: transferred fiber termination should kick root fiber; fix #5907 2023-01-16 18:25:50 +09:00
Yukihiro "Matz" Matsumoto 3f6fd994f0 README.md: mruby is not Ruby 3.x compatible (for syntax at least)
With pattern matching as an exception.
2023-01-16 14:39:47 +09:00
dearblue 365c151df0 Make mrb_env_unshare() call in mrb_vm_run()
Move the detachment of the "env" object, now done by `mrb_top_run()` by #5904, to `mrb_vm_run()`.
This is because `mrb_vm_run()` can remove `mrb_env_unshare()` which is called from `bin/mirb`.

Also, even if the mruby VM is already running, either of the following conditions should be used to detach "env":
  - If the `stack_keep` variable is 0.
  - If the stack length of "env" is longer than `irep->nlocals`.

The reason for the change is that the stack beyond `irep->nlocals` is used inside the called method, and previously it was possible to reference and manipulate the state inside the method via "env".

    env stack       |                           |

    main stack      | top |  m1  |    m2    |
                          |<--------------->|
                            operable via env stack (including self)

If the problematic block is called from the `m2` method above, it is possible to replace `self` in `m1` and `m2` as well as the internal variables.

This change may cause compatibility problems, but I believe it is better to make `MRB_API`, `mrb_vm_run()` safe.
If a dangerous procedure is absolutely necessary, `mrb_vm_exec()` can still be called as before.
2023-01-15 18:16:42 +09:00
mimaki 7a0eabb574 Update version to 3.2.0RC. 2023-01-13 09:12:08 +09:00
Yukihiro "Matz" Matsumoto a96a9f2c2b mruby-fiber/fiber.c: detect resume/transfer mixture; fix #5905
Also, transferred fibers should kick the root fiber at termination.
2023-01-12 07:23:35 +09:00
Yukihiro "Matz" Matsumoto 9211bf0950 mruby-fiber/test: Fiber#transfer should not be mixed with Fiber#resume
ref #5905

The original tests failed with CRuby.
2023-01-11 18:19:07 +09:00
Yukihiro "Matz" Matsumoto d9145b8621 mruby-test/drive.c: add string type check 2023-01-11 10:43:11 +09:00
Yukihiro "Matz" Matsumoto 00339b3aa8 Merge pull request #5904 from dearblue/env-unshare-on-top-run
Call `mrb_env_unshare()` in `mrb_top_run()` if necessary
2023-01-10 18:22:43 +09:00
Yukihiro "Matz" Matsumoto 1bba8cf53b mruby-dir: remove files needed for an independent gem 2023-01-10 10:53:15 +09:00
Yukihiro "Matz" Matsumoto a800988239 mruby-set: remove files needed for an independent gem 2023-01-10 10:51:23 +09:00
dearblue c101261f45 Call mrb_env_unshare() in mrb_top_run() if necessary
This is to keep the local variables of the previously created blocks consistent in case the `mrbc_context` passed to `mrb_load_exec()` is `NULL` or different.
Switching between `mrbc_context` pointers that are non `NULL` can be done safely by calling `mrbc_cleanup_local_variables()`.

Before this patch, the result of the following code is not as expected.

```console
% cat loadstr.c
#include <mruby.h>
#include <mruby/compile.h>

int
main(int argc, char *argv[])
{
  mrb_state *mrb = mrb_open();

  mrb_load_string(
      mrb,
      "(a, b, c, d, e, f, g) = [1, 2, 3, 4, 5, 6, 7] \n"
      "$lambda = -> { p [a, b, c, d, e, f, g] }");
  mrb_load_string(mrb, "$lambda.call");

  mrb_close(mrb);

  return 0;
}

% $(bin/mruby-config --cc --cflags --ldflags) loadstr.c $(bin/mruby-config --libs) && ./a.out
[main, nil, nil, main, nil, nil, main]
```

Also, since `mrb_env_unshare()` was not used before, the internal stack of simply detached `env` objects could show invalid addresses by `stack_extend()`.
ref. https://github.com/kou/mruby-pp/commit/ef5951aca870183d8767cb61f6414240988ca35e
2023-01-09 22:47:37 +09:00
Yukihiro "Matz" Matsumoto e2ffcbab6e mruby-io/io.c: cast return pointer from malloc/realloc for C++ 2023-01-09 19:58:30 +09:00
Yukihiro "Matz" Matsumoto 8b7e240e67 mruby-io/io.c: improve code around io_cloexec_open() 2023-01-09 19:43:37 +09:00
Yukihiro "Matz" Matsumoto 91727f38de mruby-io/io.c: change the implementation of read buffers
The original implementations used plain Ruby strings referenced from
instance variable (`@buf`) as buffers. We replaced those buffers by C
structure (`struct mrb_io_buf`) referenced directly from `fptr`.

The result is significant improvement of both performance and memory
consumption. Our simple benchmarks (reading `README.md` 10,000 times)
runs 5+ times faster, and `mrbtest` test suites consumes 85% less
memory.

Recent changes on `mruby-io` is preparation for this improvement.
2023-01-09 10:18:35 +09:00
Yukihiro "Matz" Matsumoto 6bc44f8aa8 Remove non-existent ISO section numbers suffixed with "(x)" [ci skip]
We don't know how we introduced these section references.
Weak memories.
2023-01-08 22:32:16 +09:00
Yukihiro "Matz" Matsumoto 29fa3d9950 AUTHORS: update entries [ci skip] 2023-01-08 16:56:13 +09:00
Yukihiro "Matz" Matsumoto 4462e3d8b3 string.c: add assertion for positive length 2023-01-08 16:36:20 +09:00
Yukihiro "Matz" Matsumoto e45e57fe22 mruby-io: update ISO section numbers 2023-01-07 16:39:59 +09:00
Yukihiro "Matz" Matsumoto 6de5e00a6c pre-commit-config.yaml: update 2023-01-07 16:39:46 +09:00
Yukihiro "Matz" Matsumoto ad7802a3a0 Merge pull request #5901 from dearblue/doc/gem-block
Added tips for giving blocks to `MRuby::Build#gem`
2023-01-06 09:50:31 +09:00
Yukihiro "Matz" Matsumoto e7052f78b7 Merge pull request #5900 from dearblue/doc/dup-allsyms
Remove duplicate entry `MRB_USE_ALL_SYMBOLS`
2023-01-06 09:49:37 +09:00
Yukihiro "Matz" Matsumoto fadb39a096 mruby-io/io.c: remove unused method _bufread 2023-01-06 08:52:02 +09:00
Yukihiro "Matz" Matsumoto 412b1f0fb3 mruby-io/io.c: implement IO#readlines in C 2023-01-06 08:51:21 +09:00
Yukihiro "Matz" Matsumoto 7827808d3b mruby-io/io.c: remove Ruby implementation of IO#gets 2023-01-05 23:54:46 +09:00
dearblue 9016acf54e Added tips for giving blocks to MRuby::Build#gem
ref. #5860
2023-01-05 21:50:17 +09:00
dearblue c5163fe29f Remove duplicate entry MRB_USE_ALL_SYMBOLS 2023-01-05 21:50:17 +09:00
Yukihiro "Matz" Matsumoto 9797138aca mruby-io/io.c: rename io_read_buf_noraise to io_read_buf 2023-01-05 19:50:17 +09:00
Yukihiro "Matz" Matsumoto 714cc254c0 mruby-io/io.c: remove unused function io_read_buf() 2023-01-05 19:50:16 +09:00
Yukihiro "Matz" Matsumoto cd01f1173a mruby-io/io.c: implement IO#gets in C
In addition, reimplement `IO#readline` using `IO#gets`.
2023-01-05 19:50:16 +09:00
Yukihiro "Matz" Matsumoto b7147bbd8d mruby-io/io.c: implement IO#getbyte in C
In addition, reimplement `IO#readbyte` using `IO#getbyte`.
2023-01-05 19:50:16 +09:00
Yukihiro "Matz" Matsumoto eec546a9cf mruby-io/io.c: implement IO#getc in C
In addition, reimplement `IO#readchar` using `IO#getc`.
2023-01-05 19:50:16 +09:00
Yukihiro "Matz" Matsumoto 6e7322a3fe mruby-io/io.c (eof_error): a new function to raise EOFError exception 2023-01-05 19:50:15 +09:00
Yukihiro "Matz" Matsumoto 40039d93ab mruby-io/io.c: implement IO#getline in C 2023-01-05 19:50:15 +09:00
Yukihiro "Matz" Matsumoto a9c98ab855 mruby-io/io.c: implement IO#read in C 2023-01-05 19:50:15 +09:00
Yukihiro "Matz" Matsumoto 99dffb6daf mruby-io/io.c: use RSTR_SET_LEN() instead of mrb_str_resize()
since the latter may shrink allocated buffer, and may cause repeated
allocations.
2023-01-05 19:50:14 +09:00
Yukihiro "Matz" Matsumoto 1bc0be3e43 mruby-io/io.c: implement IO#eof? in C 2023-01-05 19:50:14 +09:00
Yukihiro "Matz" Matsumoto 9e808512d5 mruby-io/io.c: remove duplicated initializations after io_alloc() 2023-01-05 19:50:14 +09:00
Yukihiro "Matz" Matsumoto 2b90937a2e mruby-io/io.c: add ISO section comments 2023-01-05 19:50:14 +09:00
Yukihiro "Matz" Matsumoto d57540118b mruby-io/io.c: rename _common functions 2023-01-05 19:50:13 +09:00
Yukihiro "Matz" Matsumoto 64bf33adb4 Merge pull request #5899 from mruby/dependabot/github_actions/github/super-linter-4.10.0
build(deps): bump github/super-linter from 4.9.7 to 4.10.0
2023-01-05 09:15:06 +09:00
dependabot[bot] fd57c5284b build(deps): bump github/super-linter from 4.9.7 to 4.10.0
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.9.7 to 4.10.0.
- [Release notes](https://github.com/github/super-linter/releases)
- [Changelog](https://github.com/github/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/github/super-linter/compare/v4.9.7...v4.10.0)

---
updated-dependencies:
- dependency-name: github/super-linter
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-04 14:02:05 +00:00
Yukihiro "Matz" Matsumoto 51dca6eda8 mruby-io/io.c: rename receiver names from self to io in this file 2023-01-02 10:01:09 +09:00
Yukihiro "Matz" Matsumoto 0e25448a20 mruby-io/io.c (io_check_readable): hide internal method in backtraces 2023-01-02 10:01:08 +09:00
Yukihiro "Matz" Matsumoto 7cc6a720f3 mruby-io/io.c: implement IO#readchar in C 2023-01-02 10:01:08 +09:00
Yukihiro "Matz" Matsumoto 10a5edd978 mruby-io/io.c: implement IO#getbyte in C 2023-01-02 10:01:08 +09:00
Yukihiro "Matz" Matsumoto a117095ca1 Merge pull request #5897 from dearblue/doc/MRB_HEAP_PAGE_SIZE
Added more description of the `MRB_HEAP_PAGE_SIZE` configuration
2023-01-02 10:00:30 +09:00
dearblue 4a39a9f1c4 Added more description of the MRB_HEAP_PAGE_SIZE configuration 2023-01-01 21:59:24 +09:00
Yukihiro "Matz" Matsumoto 170326cb41 Merge pull request #5896 from dearblue/dir-open
Avoid `IOError` when returning from `Dir.open`
2023-01-01 19:27:45 +09:00
dearblue 72ab1821de Avoid IOError when returning from Dir.open
Ignore `IOError` if `Dir#close` was done in the block.
2023-01-01 17:40:50 +09:00
Yukihiro "Matz" Matsumoto 0c9798373a mruby-io/io.c (fptr_finalize): close stdin/out/err as well
if not during the termination process.
2022-12-31 17:53:20 +09:00
Yukihiro "Matz" Matsumoto 965997d91b mruby-io/io.c: implement IO#flush in C 2022-12-31 10:39:05 +09:00
Yukihiro "Matz" Matsumoto 0628669790 mruby-data/data.c (to_s): add class name in string representation 2022-12-31 07:51:09 +09:00
Yukihiro "Matz" Matsumoto b79563af60 mruby-io/test: remove test for internal IO#_read_buf 2022-12-30 13:59:21 +09:00
Yukihiro "Matz" Matsumoto a68b1200c2 mruby-io/test: test IO#ungetc 2022-12-30 13:59:01 +09:00
Yukihiro "Matz" Matsumoto 26f458baab mruby-io/io.c: implement IO#ungetc in C 2022-12-30 13:59:01 +09:00
Yukihiro "Matz" Matsumoto 99a4c1f703 mruby-io/io.c (io_buf): protect @buf from modification
Users may re-assign `@buf` using `instance_variable_set` for example.
2022-12-30 13:59:00 +09:00
Yukihiro "Matz" Matsumoto 9a6a251460 mruby-io/io.c (io_bufread_m): remove unnecessary checks 2022-12-30 13:59:00 +09:00
Yukihiro "Matz" Matsumoto af59e30710 mruby-io/io.c: implement IO#pos in C 2022-12-30 13:59:00 +09:00
Yukihiro "Matz" Matsumoto d0659b089f mruby-io/io.c: remove wrong ISO section comment 2022-12-30 13:58:59 +09:00
Yukihiro "Matz" Matsumoto d905746218 mruby-io/io.c: implement IO#seek in C 2022-12-30 13:58:59 +09:00
Yukihiro "Matz" Matsumoto 14a374c6bc mruby-io/io.c: implement IO#write in C
And now `write` takes multiple string arguments
2022-12-30 13:58:59 +09:00
Yukihiro "Matz" Matsumoto 663d5715bc mruby-io/io.c: new function io_get_write_fd 2022-12-30 13:58:59 +09:00
Yukihiro "Matz" Matsumoto 5732948108 mruby-io/io.c (io_init): check opt if it's a hash
But `opt` will be ignored anyway in mruby.
2022-12-30 13:58:58 +09:00
Yukihiro "Matz" Matsumoto 0cdecd2e9e mruby-io/io.c (io_init): remove redundant code 2022-12-30 13:58:58 +09:00
Yukihiro "Matz" Matsumoto ef0b43d9a1 mruby-io/test/io.rb: specify access mode for IO.{sysopen,open} in tests 2022-12-30 13:58:58 +09:00
Yukihiro "Matz" Matsumoto a9330dbc4b Merge pull request #5895 from jbampton/yardopts-add-pages
`.yardopts` add LEGAL, NEWS, TODO.md
2022-12-30 13:58:47 +09:00
John Bampton 6fe3e8dae3 .yardopts add LEGAL, NEWS, TODO.md 2022-12-30 14:05:16 +10:00
Yukihiro "Matz" Matsumoto 69791b1078 Merge pull request #5894 from jbampton/use-rubygems-org-links
Use rubygems.org links for yard-mruby and yard-coderay
2022-12-30 11:47:55 +09:00
John Bampton d318e992ea Use rubygems.org links for yard-mruby and yard-coderay
The RubyGems website gives a much better overview of both Gems

A lot more quick links and statistics.

https://rubygems.org/gems/yard-mruby

https://rubygems.org/gems/yard-coderay
2022-12-30 12:39:54 +10:00
Yukihiro "Matz" Matsumoto df35e36682 Merge pull request #5893 from jbampton/contributing-building-documentation
Add more building documentation
2022-12-30 11:26:53 +09:00
John Bampton 6da82230e8 Add more building documentation 2022-12-30 11:14:12 +10:00
Yukihiro "Matz" Matsumoto 7fab8275dc Merge pull request #5892 from jbampton/rake-doc-capi-graphviz
rake doc: C API needs both Doxygen and Graphviz
2022-12-30 09:15:51 +09:00
John Bampton e9b69c611d rake doc: C API needs both Doxygen and Graphviz
https://www.doxygen.nl/

https://graphviz.org/download/
2022-12-30 10:08:15 +10:00
Yukihiro "Matz" Matsumoto d437182f79 Merge pull request #5891 from jbampton/update-doxyfile
`Doxyfile` add `LEGAL`, `LICENSE`, `NEWS`
2022-12-30 08:01:02 +09:00
Yukihiro "Matz" Matsumoto 4d3cc0975a Merge pull request #5887 from rmalizia44/cdata-example
Add cdata example
2022-12-30 08:00:14 +09:00
Yukihiro "Matz" Matsumoto 618d8c6706 Merge pull request #5885 from FnControlOption/patch-2
Use `getsegmentdata` instead of deprecated `get_etext`/`get_edata`
2022-12-30 07:58:20 +09:00
fn ⌃ ⌥ 8c23385f62 Add reason for include 2022-12-29 08:08:55 -08:00
John Bampton ee61a1ebfe Doxyfile add LEGAL, LICENSE, NEWS 2022-12-30 01:40:34 +10:00
rmalizia44 e062af51f3 Add cdata example
Fix trailing-whitespace and tabs
2022-12-29 08:36:43 -03:00
Yukihiro "Matz" Matsumoto 9845872168 Merge pull request #5888 from jbampton/update-contributing-guide
CONTRIBUTING.md: update `pre-commit` info with `make` and `rake`
2022-12-29 14:47:49 +09:00
Yukihiro "Matz" Matsumoto b7552ece6e Merge pull request #5890 from jbampton/update-doxyfile
Update `Doxyfile` add `CONTRIBUTING.md` and `TODO.md`
2022-12-29 14:47:15 +09:00
Yukihiro "Matz" Matsumoto 6a062d79f1 Merge pull request #5889 from jbampton/remove-blank-lines
Remove blank line from the top of Ruby files
2022-12-29 14:46:00 +09:00
John Bampton d82ab7835e Update Doxyfile add CONTRIBUTING.md and TODO.md 2022-12-29 15:16:22 +10:00
John Bampton 42946fed8f CONTRIBUTING.md: update pre-commit info with make and rake 2022-12-29 14:46:58 +10:00
John Bampton 41572d71b6 Remove blank line from the top of Ruby files 2022-12-29 14:29:48 +10:00
Yukihiro "Matz" Matsumoto 9dbcdd51c2 mruby-io/io.c (io_sysseek): fixed wrong condition when off_t < mrb_int 2022-12-29 12:19:57 +09:00
Yukihiro "Matz" Matsumoto bc8d8da81a class.c (get_args_v): fixed integer type mismatch 2022-12-29 11:55:44 +09:00
Yukihiro "Matz" Matsumoto 142915acd6 mruby-io: mistakenly committed WIP code, sigh 2022-12-29 11:44:35 +09:00
Yukihiro "Matz" Matsumoto 80e5c8a90a mruby-io/io.c: forgot to rename mrb_io_pread on non-Unix platforms 2022-12-29 11:37:28 +09:00
Yukihiro "Matz" Matsumoto 5401d95017 mruby-io/ext/io.h: remove unused macros 2022-12-29 11:22:37 +09:00
Yukihiro "Matz" Matsumoto aa3005da02 mruby-io/io.c: remove mrb_ prefix from function names 2022-12-29 11:22:37 +09:00
Yukihiro "Matz" Matsumoto 0172388aa2 mruby-io/io.c: rename mrb_io_read_write_size to fssize_t 2022-12-29 11:22:36 +09:00
Yukihiro "Matz" Matsumoto c83b715f0c mruby-io/io.c: small format updates 2022-12-29 11:22:36 +09:00
Yukihiro "Matz" Matsumoto 8e1a82b424 mruby-io/io.c: raise error if seek position is too big 2022-12-29 11:22:36 +09:00
Yukihiro "Matz" Matsumoto f3a5f3ee1d mruby-io/io.c: define seek constants in C
From C macro definitions instead of literal integers (may differ from
the platform's definitions).

- SEEK_SET
- SEEK_CUR
- SEEK_END
2022-12-29 11:22:35 +09:00
Yukihiro "Matz" Matsumoto 830c882f06 mruby-io/io.rb (IO.read): should not allow path starting "|"
It was made obsolete long time ago.
2022-12-29 11:22:35 +09:00
Yukihiro "Matz" Matsumoto 20606c4455 mruby-io/io.rb: update a comment 2022-12-29 11:20:52 +09:00
Yukihiro "Matz" Matsumoto ba1b12948d mruby-io/io.c: implement _read_buf in C 2022-12-29 11:20:51 +09:00
Yukihiro "Matz" Matsumoto 1940bec0af mruby-io/io.c: rename mrb_dup to clearer sysdup 2022-12-29 11:20:51 +09:00
Yukihiro "Matz" Matsumoto 7ef0b6e66e mruby-io/io.c (mrb_io_initialize_copy): dupe the buffer 2022-12-29 11:20:51 +09:00
Yukihiro "Matz" Matsumoto 2d765bfa90 mruby-io/io.c: use MRB_IVSYM() instead of mrb_intern_lit() 2022-12-29 11:20:51 +09:00
Yukihiro "Matz" Matsumoto fb8cfa8a90 mruby-io/io.c: rename functions
Remove the word `dummy` from working function names.
2022-12-29 11:20:50 +09:00
Yukihiro "Matz" Matsumoto 7b130004da mruby-io/io.c: reorder functions to remove function prototype 2022-12-29 11:20:50 +09:00
Yukihiro "Matz" Matsumoto 8a6344b64f mruby-io/io.c (mrb_io_readchar): avoid redundant call to mrb_utf8len() 2022-12-29 11:20:50 +09:00
Yukihiro "Matz" Matsumoto 2970607267 mruby-io/io.c (mrb_io_readchar): RSTRING_PTR(buf) never be NULL 2022-12-29 11:20:50 +09:00
Yukihiro "Matz" Matsumoto 5c36a768f7 mruby-io/io.c (mrb_io_readchar): no need to pass @buf 2022-12-29 11:20:49 +09:00
Yukihiro "Matz" Matsumoto 134c9f3178 Merge pull request #5886 from jbampton/remove-coding-utf-8-ruby
Remove `# coding: utf-8` from Ruby file
2022-12-29 09:56:51 +09:00
John Bampton efd0e52cfd Remove # coding: utf-8 from Ruby file
The default script encoding is Encoding::UTF-8 after v2.0.

https://ruby-doc.org/core-2.1.2/Encoding.html#class-Encoding-label-Script+encoding
2022-12-29 10:15:48 +10:00
fn ⌃ ⌥ e6c0f324ae Use getsegmentdata instead of deprecated get_etext/get_edata 2022-12-28 08:50:59 -08:00
Yukihiro "Matz" Matsumoto 73fbc33596 Merge pull request #5884 from jbampton/remove-unneeded-return
Remove unneeded `return` keyword from last line in Ruby functions
2022-12-27 14:14:50 +09:00
Yukihiro "Matz" Matsumoto 54d408aa57 Merge pull request #5883 from jbampton/rakefile-remove-encoding-comment
Rakefile: remove unnecessary utf-8 encoding comment
2022-12-27 14:14:16 +09:00
John Bampton 3ba388fc78 Remove unneeded return keyword from last line in Ruby functions 2022-12-27 11:42:48 +10:00
John Bampton 0075b6f240 Rakefile: remove unnecessary utf-8 encoding comment 2022-12-27 11:20:29 +10:00
Yukihiro "Matz" Matsumoto 02c576accf Merge pull request #5882 from rmalizia44/master
Add code block in boxing docs to better spacing
2022-12-27 09:58:22 +09:00
Yukihiro "Matz" Matsumoto fb34d9ee17 Merge pull request #5881 from jbampton/fix-spelling
Fix spelling
2022-12-27 09:56:52 +09:00
Yukihiro "Matz" Matsumoto 4aad86a3e1 Merge pull request #5880 from jbampton/android-rake-style
style: pass `&:to_i` as an argument to collect instead of a block
2022-12-27 09:56:06 +09:00
Yukihiro "Matz" Matsumoto 1282527342 Merge pull request #5879 from jbampton/rake-task-generate-active-gems-txt 2022-12-27 09:12:31 +09:00
rmalizia44 1614a88cb7 Add code block in boxing docs to better spacing 2022-12-26 20:12:54 -03:00
John Bampton 1aa2fff1e8 Fix spelling
https://en.wikipedia.org/wiki/Single-precision_floating-point_format

https://en.wikipedia.org/wiki/Double-precision_floating-point_format
2022-12-26 20:50:35 +10:00
John Bampton 10250f835c style: pass &:to_i as an argument to collect instead of a block 2022-12-26 19:12:56 +10:00
John Bampton b5af16b93a Add generate_active_gems_txt to rake --tasks 2022-12-26 17:16:50 +10:00
Yukihiro "Matz" Matsumoto feb6164d8d Merge pull request #5878 from jbampton/rake-tasks-benchmark
Add `benchmark` to `rake --tasks`
2022-12-26 14:45:52 +09:00
John Bampton 6c10351c88 Add benchmark to rake --tasks 2022-12-26 15:41:37 +10:00
Yukihiro "Matz" Matsumoto bb3f403511 Merge pull request #5876 from dearblue/dir-foreach
Close the directory object with the `Dir.foreach` method
2022-12-26 13:27:53 +09:00
Yukihiro "Matz" Matsumoto 3518d15d04 Merge pull request #5875 from dearblue/dir-cstr
Get argument of the `Dir` method takes a C string directly
2022-12-26 13:26:56 +09:00
Yukihiro "Matz" Matsumoto 954a847141 Merge pull request #5877 from jbampton/update-rake-tasks
Add `check` and `checkupdate` to `rake --tasks`
2022-12-26 13:25:30 +09:00
John Bampton f5cd3bfa82 Add check and checkupdate to rake --tasks 2022-12-26 14:20:34 +10:00
Yukihiro "Matz" Matsumoto 2656a92380 Merge pull request #5874 from dearblue/dir-funcs
Hide substance functions of methods in `mruby-dir`
2022-12-26 12:58:44 +09:00
Yukihiro "Matz" Matsumoto 79f586d7b4 Merge pull request #5873 from dearblue/dir-ioerr
Define also the exception class `IOError` in `mruby-dir`
2022-12-26 12:48:43 +09:00
dearblue 50b24c124f Close the directory object with the Dir.foreach method 2022-12-25 21:25:30 +09:00
dearblue 1fb19ca046 Get argument of the Dir method takes a C string directly 2022-12-25 21:25:30 +09:00
dearblue 71df263bdf Hide substance functions of methods in mruby-dir 2022-12-25 21:25:30 +09:00
dearblue 35490c2c32 Define also the exception class IOError in mruby-dir
Since `IOError` is a standard exception class in Ruby, there is no need to assume different superclasses.
The Ruby specification allows repeated class definitions as long as the superclass is the same.

This also avoids using the `mruby/ext/io.h` file to reference `E_IO_ERROR`.
2022-12-25 21:25:21 +09:00
Yukihiro "Matz" Matsumoto a6e456e72e Merge pull request #5872 from dearblue/src-headers
Avoid uses `mruby/src/error.h` file
2022-12-25 18:10:59 +09:00
Yukihiro "Matz" Matsumoto fbc4730cf7 doc/mruby3.2.md: update CVE-2022 entries 2022-12-25 18:00:11 +09:00
Yukihiro "Matz" Matsumoto a082c5d61e doc/mruby3.2.md: update entries for new gems 2022-12-25 18:00:11 +09:00
Yukihiro "Matz" Matsumoto 684ca72439 Merge pull request #5871 from ukrainskiysergey/fix_nil_redefinition_limitation_type
Fix typo in doc/limitations.md
2022-12-25 17:56:34 +09:00
dearblue fec74cd040 Avoid uses mruby/src/error.h file 2022-12-25 17:31:53 +09:00
Sergey Ukrainskiy 872f01ddef Fix typo in doc/limitations.md 2022-12-25 13:33:11 +09:00
Yukihiro "Matz" Matsumoto 89830296eb numeric.c (int_round): n may not be a bigint
`mrb_bint_add()` expects its first operand to be a bigint.
2022-12-24 19:20:37 +09:00
Yukihiro "Matz" Matsumoto 48e5ca4802 include/value.h (mrb_float_p): define always
even when `MRB_NO_FLOAT` is set. In that case, it is FALSE always.
2022-12-24 19:05:41 +09:00
Yukihiro "Matz" Matsumoto 14f8cf040e mruby-string-ext: add unary +/- for strings to freeze/unfreeze 2022-12-24 10:42:28 +09:00
Yukihiro "Matz" Matsumoto 4288ee39b3 doc/mruby3.2.md: update - add mruby-dir entry 2022-12-23 14:17:18 +09:00
Yukihiro "Matz" Matsumoto 7821462571 mruby-dir/dirtest.c: need to include <io.h> for mktemp() on Windows 2022-12-22 22:07:07 +09:00
Yukihiro "Matz" Matsumoto e6544e44f7 class.c (mrb_get_args_a): avoid an uninitialized warning from VC. 2022-12-22 15:13:08 +09:00
Yukihiro "Matz" Matsumoto 67addd7da3 mruby-dir/dirtest.c: avoid string allocations for mrb_raisef 2022-12-22 11:36:03 +09:00
Yukihiro "Matz" Matsumoto 1d174404b3 mruby-dir/dirtest.c: refactor mkdir in mrb_dirtest_setup 2022-12-22 11:33:44 +09:00
Yukihiro "Matz" Matsumoto d51d5825ad mruby-dir/dir.c: update compatibility macros for Windows 2022-12-22 11:13:50 +09:00
Yukihiro "Matz" Matsumoto 084871abf3 mruby-dir/dirtest.c: use _mktemp instead of mktemp for Windows 2022-12-22 11:12:32 +09:00
Yukihiro "Matz" Matsumoto c737519d02 mruby-dir/dirtest.c: add compatibility macro for getcwd 2022-12-22 11:11:49 +09:00
Yukihiro "Matz" Matsumoto 4cbcf743a7 mruby-dir/dirtest.c: wrap function prototypes by extern "C" 2022-12-22 11:11:18 +09:00
Yukihiro "Matz" Matsumoto 783e62e582 mruby-dir/dirtest.c: copy some of dirent header information
Instead of including whole "dirent.c" file.
2022-12-22 09:53:16 +09:00
Yukihiro "Matz" Matsumoto 965d1d1554 mruby-dir/dirtest.c: should not include <unistd.h> 2022-12-22 09:27:13 +09:00
Yukihiro "Matz" Matsumoto 0aa8ce5c57 mruby-dir/dirtest.c: did not work for Windows 2022-12-22 09:10:40 +09:00
Yukihiro "Matz" Matsumoto cfb2d3e888 mruby-dir: include Enumerable module 2022-12-22 00:03:28 +09:00
Yukihiro "Matz" Matsumoto ca3b694efe mruby-dir/dir.rb: make each_child as an alias to each 2022-12-22 00:02:33 +09:00
Yukihiro "Matz" Matsumoto 3d6a4c39bf mruby-dir: reformat 2022-12-21 15:18:09 +09:00
Yukihiro "Matz" Matsumoto d656ea87c6 mruby-dir: add compatibility macro 2022-12-21 15:15:10 +09:00
Yukihiro "Matz" Matsumoto b93a624b5f mruby-dir/dir.c: add new method Dir.empty?(path) 2022-12-21 15:11:37 +09:00
Yukihiro "Matz" Matsumoto e4b80cc282 mruby-dir/dir.rb: add new method children as an alias to entries 2022-12-21 14:48:22 +09:00
Yukihiro "Matz" Matsumoto 818212b5db mruby-dir/dir.rb: rename each to each_child 2022-12-21 14:44:24 +09:00
Yukihiro "Matz" Matsumoto afcdf5e803 mruby-dir/dir.rb: simplify loop delegation 2022-12-21 14:42:50 +09:00
Yukihiro "Matz" Matsumoto d0af9e9863 README.md: update the simplest build instruction 2022-12-20 22:14:34 +09:00
Yukihiro "Matz" Matsumoto d3e997f4f9 mruby-dir: remove run_test.rb that is no longer used 2022-12-20 22:13:34 +09:00
Yukihiro "Matz" Matsumoto 4b48c86103 mruby-dir: extra spaces and typos are removed 2022-12-20 22:12:21 +09:00
Yukihiro "Matz" Matsumoto e3589bf001 AUTHORS: update "as of" info
Forgot to update last time.
2022-12-20 21:57:53 +09:00
Yukihiro "Matz" Matsumoto f486069a94 mruby-dir/test: reformat 2022-12-20 21:56:52 +09:00
Yukihiro "Matz" Matsumoto 869a2778a9 mruby-dir/test: remove warnings from lacked assertions 2022-12-20 20:24:28 +09:00
Yukihiro "Matz" Matsumoto fbf04c6ec3 mruby-dir/dir.rb: removed work around for old mruby bug 2022-12-20 20:13:04 +09:00
Yukihiro "Matz" Matsumoto e6a2f0b98e mruby-dir/dir.rb: reformat according to coding standard 2022-12-20 19:51:18 +09:00
Yukihiro "Matz" Matsumoto d46bbb72ac mrbgems/stdlib-io.gembox: add mruby-dir gem 2022-12-20 18:49:29 +09:00
Yukihiro "Matz" Matsumoto 277341f694 Add 'mrbgems/mruby-dir/' from commit '89dceefa1250fb1ae868d4cb52498e9e24293cd1'
git-subtree-dir: mrbgems/mruby-dir
git-subtree-mainline: f2d43069f0
git-subtree-split: 89dceefa12
2022-12-20 18:06:36 +09:00
Yukihiro "Matz" Matsumoto f2d43069f0 mruby-socet: add socket constants
Introduced in Ruby3.2:

- SO_INCOMING_CPU
- SO_INCOMING_NAPI_ID
- SO_RTABLE
- SO_SETFIB
- SO_USER_COOKIE
- TCP_KEEPALIVE
- TCP_CONNECTION_INFO
2022-12-19 18:59:10 +09:00
Yukihiro "Matz" Matsumoto 772bf559ef codedump.c: print embedded operands
- LOADNIL  (nil)
- LOADSELF (R0)
- LOADT    (true)
- LOADF    (false)
2022-12-18 19:08:28 +09:00
Yukihiro "Matz" Matsumoto f7a8a42521 mruby-compiler/parse.y: allow multiple anonymous splat in args rule
For example, this should be allowed:

```ruby
def f(*)
  p(*,*)
end
```
2022-12-17 09:37:44 +09:00
Yukihiro "Matz" Matsumoto 6d01c5b56c codedump.c: print embedded operands (with parentheses) 2022-12-16 07:51:31 +09:00
Yukihiro "Matz" Matsumoto b18a267709 codedump.c: print LOADINEG for the instruction; close #5869
Stopped unifying LOADI and LOAINEG in instruction printing.
The issue is reported by @NaokiM03.
2022-12-15 18:35:14 +09:00
Yukihiro "Matz" Matsumoto 8819183088 gc.c (mrb_field_write_barrier): value may be NULL
Especially when called from MRB_PROC_SET_TARGET_CLASS() from
f_instance_eval().
2022-12-15 07:50:11 +09:00
Yukihiro "Matz" Matsumoto d6dc9caa02 mruby-hash-ext/hash.rb: make transform_keys! to keep old keys
```ruby
h={1=>2,2=>3}
h.transform_keys!{_1.succ}
```

used to make `h` to `{2=>2}` (duplicated keys were squashed), but now
makes it `{2=>2,3=>3}`.
2022-12-14 07:39:10 +09:00
Yukihiro "Matz" Matsumoto ba3541bbc4 mruby-set/set.rb (reset): add reset method defined in Ruby 2.5 2022-12-14 07:38:38 +09:00
Yukihiro "Matz" Matsumoto ddefcea151 mruby-eval/eval.c (f_instance_eval): skip mrb_value to get singleton
Use mrb_singleton_class_ptr() instead of mrb_instance_class(), because
the former returns NULL, when the latter raises error for immediate
objects.

```
1.instance_eval <<END
  def foo
    :foo
  end
END
```
2022-12-13 10:51:44 +09:00
Yukihiro "Matz" Matsumoto 3bd2c56dae vm.c (check_target_class): raise error if target_class is NULL
It fixes a bug that instance_eval for immediate objects defines methods
in Object, instead of raising error.

```ruby
1.instance_eval do
  def foo
    p :foo
  end
end
```
2022-12-13 10:49:14 +09:00
Yukihiro "Matz" Matsumoto 7ad657b532 mrb_kwargs numbers changed to mrb_int from uint32_t
They are unsigned but `mrb_int` is more common among mruby
implementation, e.g. length of strings and arrays.
2022-12-12 14:42:38 +09:00
Yukihiro "Matz" Matsumoto cc8ce1b5c7 Merge pull request #5868 from boatrite/2022-12-10-path-with-spaces-fix
Fix cloning gem when destination path contains spaces
2022-12-12 14:42:26 +09:00
Gwendolyn Boatrite 8b728e4056 Fix cloning gem when destination path contains spaces
This was how clone command was previously being generated, for example:

```
git clone  --recursive --branch "master" --depth 1 https://github.com/mattn/mruby-onig-regexp.git /path/to mruby with spaces/mruby-3.1.0/build/repos/wasm/mruby-onig-regexp
```

Now it's changed so the path is quoted and will work when containing
spaces:

```
git clone  --recursive --branch "master" --depth 1 https://github.com/mattn/mruby-onig-regexp.git "/path/to mruby with spaces/mruby-3.1.0/build/repos/wasm/mruby-onig-regexp"
```

Similar for the other commands.
2022-12-11 17:18:29 -06:00
Yukihiro "Matz" Matsumoto dc508eafe8 Merge pull request #5867 from dearblue/gha-ci
Combine gcc/clang jobs with matrix
2022-12-11 15:14:05 +09:00
dearblue 9068a157c7 Combine gcc/clang jobs with matrix 2022-12-10 23:37:52 +09:00
Yukihiro "Matz" Matsumoto 38c50b3094 mruby-struct (struct_index): avoid direct array indexing
Caused crash probably due to the combination of C++ UB & optimizer.
2022-12-10 08:00:31 +09:00
Yukihiro "Matz" Matsumoto 990d41f9f7 mruby-class-ext: new method attached_object introduced in Ruby3.2 2022-12-09 17:30:17 +09:00
Yukihiro "Matz" Matsumoto 6fecea1a7d AUTHORS: update entries [ci skip] 2022-12-09 07:38:42 +09:00
Yukihiro "Matz" Matsumoto a7e304a51c mruby-struct (struct_index): unify indexing access code 2022-12-08 08:01:53 +09:00
Yukihiro "Matz" Matsumoto de0ed25fbf mruby-struct (struct_corrupted): unify error raising code 2022-12-07 17:07:33 +09:00
Yukihiro "Matz" Matsumoto 0c1d6c5d1b Merge pull request #5866 from jbampton/md-fix-c-code-block
docs: fix start of `C` code block
2022-12-07 08:01:13 +09:00
Yukihiro "Matz" Matsumoto 672495555b mruby-data (mrb_data_init_copy): use data_corrupted() for errors 2022-12-07 07:49:19 +09:00
John Bampton 8eee3ce150 docs: fix start of C code block 2022-12-06 21:48:28 +10:00
Yukihiro "Matz" Matsumoto 38098ddf2a class.c (prepare_singleton_class): remove unnecessary write barrier
Since sc (singleton class) is a newly created object so it's not needed
to call write barrier.
2022-12-06 15:45:39 +09:00
Yukihiro "Matz" Matsumoto 375d22b412 gc.c (clear_all_old): avoid calling GC twice in the function 2022-12-06 15:26:24 +09:00
Yukihiro "Matz" Matsumoto b3c95f3851 Merge pull request #5863 from dearblue/doc/OP_CALL
Update semantics comment for `OP_CALL`
2022-12-06 14:20:16 +09:00
Yukihiro "Matz" Matsumoto 94b3d48df2 Merge pull request #5862 from dearblue/doc/update-opcode.md
Update `opcode.md` to match the latest implementation
2022-12-06 14:20:03 +09:00
Yukihiro "Matz" Matsumoto a7232ecf8d mruby-sprintf (mrb_str_format): fixed integer size confusion
Declared as int, checked as mrb_int.
2022-12-06 08:31:30 +09:00
Yukihiro "Matz" Matsumoto 4295a8c560 gc.c (final_marking_phase): mark gray objects after marking
If pre-allocate object is modified (e.g. singleton class added) in
certain timing, some objects may be swept even if it's alive.
The problem was reported by Denis Kasak via private communication.
2022-12-05 22:34:15 +09:00
Yukihiro "Matz" Matsumoto d4fb67a1a0 Merge pull request #5864 from dearblue/doc/escape-pipe
Escaping pipes in the code of table elements
2022-12-05 10:51:51 +09:00
Yukihiro "Matz" Matsumoto 841bf6a270 mruby-data: update a comment (there's no Data.new) [ci skip] 2022-12-05 10:49:40 +09:00
Yukihiro "Matz" Matsumoto 0d261aff6b mruby-data: freeze Data object after initialize 2022-12-04 22:45:36 +09:00
Yukihiro "Matz" Matsumoto 9992de5a4f Rename MRB_TT_DATA to MRB_TT_CDATA
`TT_DATA` is too confusing with `Data` objects (which is immutable
Struct like objects introduced in Ruby 3.2).
2022-12-04 22:45:36 +09:00
Yukihiro "Matz" Matsumoto 0ef4796dfb mruby-data: improve comment description 2022-12-04 22:45:35 +09:00
Yukihiro "Matz" Matsumoto 951caa8f42 mruby-data: rename some internal functions and a macro 2022-12-04 22:45:35 +09:00
Yukihiro "Matz" Matsumoto 25faa74d23 array.c (mrb_ary_unshift_m): small refactoring
Unify size error by `ary_too_big()` function.
2022-12-04 22:45:35 +09:00
Yukihiro "Matz" Matsumoto 6d8e025901 Merge pull request #5865 from dearblue/errno-to-stdlib-io
Move `mruby-errno` to `stdlib-io.gembox`
2022-12-04 22:45:24 +09:00
dearblue 392033fb6b Move mruby-errno to stdlib-io.gembox
This is because GEMs that use errno are currently limited to `mruby-io` and `mruby-socket`.
2022-12-04 18:33:12 +09:00
Yukihiro "Matz" Matsumoto 5deb8c7894 Merge pull request #5861 from dearblue/doc/addfiles.2
Additional document files for doxygen
2022-12-03 15:27:04 +09:00
dearblue 32d48a5f0e Escaping pipes in the code of table elements
ref. https://github.github.com/gfm/#example-200
2022-12-03 14:40:30 +09:00
dearblue 478fd615af Update semantics comment for OP_CALL 2022-12-03 14:26:05 +09:00
dearblue 13d8804d88 Update opcode.md to match the latest implementation 2022-12-03 13:59:35 +09:00
dearblue 4bd3e0e20b Additional document files for doxygen
Complements #5802.
2022-12-03 13:37:32 +09:00
Yukihiro "Matz" Matsumoto 5f3aed7413 mruby-data (mrb_data_new): Data#new to accept keyword arguments 2022-12-01 15:38:06 +09:00
Yukihiro "Matz" Matsumoto a40fdfde5c mruby-data: cosmetic changes regarding for loop variables 2022-11-30 21:51:52 +09:00
Yukihiro "Matz" Matsumoto c7f1195ccb mruby-random: fix size of kw symbol arrays 2022-11-30 21:50:08 +09:00
Yukihiro "Matz" Matsumoto 138adbe282 mruby-data (mrb_data_initialize): update argument error conditions
- raise ArgumentError if arguments size differs from data size.
  Previously it accepted smaller argument size.

- the message is updated to "wrong number of arguments". It's not
  "struct" any longer.
2022-11-30 21:47:31 +09:00
Yukihiro "Matz" Matsumoto fce2c5131f mruby-data: new gem for Data class introduced in Ruby 3.2 2022-11-29 15:58:05 +09:00
Yukihiro "Matz" Matsumoto 3fa029b079 mruby-io (mrb_fd_cloexec): instead of assertion call mrb_sys_fail()
Should provide system call failure information to the user.
2022-11-29 08:16:22 +09:00
Yukihiro "Matz" Matsumoto 551d603d9c mruby-sprintf: remove unnecessary format specifier 2022-11-26 23:22:50 +09:00
Yukihiro "Matz" Matsumoto 16ed467266 mruby-struct: avoid using mrb_bug(); ref #5852
Use mrb_assert() instead.
2022-11-25 16:17:29 +09:00
Yukihiro "Matz" Matsumoto 855e63e17c parse.y: avoid using mrb_bug(); ref #5852 2022-11-25 16:17:29 +09:00
Yukihiro "Matz" Matsumoto eb988c9025 cdump.c (cdump_pool): simplify IREP_TT_FLOAT dump. 2022-11-25 16:17:29 +09:00
Yukihiro "Matz" Matsumoto c39ee489e1 Remove non formatting fprintf(). 2022-11-25 16:17:29 +09:00
Yukihiro "Matz" Matsumoto 260c2b60df Merge pull request #5859 from dearblue/rake/opcode.md
Add task `rake doc:update-opcode.md`
2022-11-23 18:00:52 +09:00
Yukihiro "Matz" Matsumoto ffb6b2243b Merge pull request #5858 from dearblue/mrb_print_backtrace
Print errors by calling `mrb_print_backtrace()` without backtrace
2022-11-21 08:37:01 +09:00
dearblue 5e62990748 Add task rake doc:update-opcode.md
Allow to update `doc/internal/opcode.md` file mechanically from `include/mruby/ops.h` file.

At the same time, the `doc/internal/opcode.md` file has been updated.
Consecutive hyphens at the end of the table were removed as they would have created noise as markdown flavours.
2022-11-20 21:58:13 +09:00
dearblue 61b60273ea Print errors by calling mrb_print_backtrace() without backtrace
- In case of `NoMemoryError` exceptions, the error message is now printed directly.
- Replaced `mrb_p()` used by #4250 with `mrb_print_error()`.

  ref. squashed commit f1523d2404
  ref. subcommit da7d7f881b
  ref. subcommit d9c7b6be6e
2022-11-20 20:58:03 +09:00
Yukihiro "Matz" Matsumoto 3a0e2255bd Merge pull request #5857 from dearblue/avoid-abort-resume
Avoid `abort()` when exception occurs in `mrb_fiber_resume()`
2022-11-20 20:37:44 +09:00
dearblue f0a65ec3c2 Avoid abort() when FiberError occurs in mrb_fiber_resume()
However, this may not be the case depending on where the `FiberError` raises.
2022-11-20 20:32:44 +09:00
Yukihiro "Matz" Matsumoto 9c5dc42e59 small cosmetic changes.
I prefer `i++` style unless absolutely necessary.
This commit is an addition to 41e4148.
2022-11-19 17:11:56 +09:00
Yukihiro "Matz" Matsumoto 7ab7608094 small cosmetic changes.
I prefer `i++` style unless absolutely necessary.
2022-11-19 17:11:56 +09:00
Yukihiro "Matz" Matsumoto 89a34e1b7e Revert "error.c (mrb_sys_fail): errno argument removed from _sys_fail."
Intermediate function calls may update `errno`.
This reverts commit a099ca44f4.
2022-11-19 17:11:56 +09:00
Yukihiro "Matz" Matsumoto 80986804cc Merge pull request #5856 from dearblue/doc/fiber-funcs
Updates documentation for `mrb_fiber_resume()` and `mrb_fiber_yield()`
2022-11-19 17:11:48 +09:00
dearblue 6fed73445e Updates documentation for mrb_fiber_resume() and mrb_fiber_yield()
- Added note on `mrb_fiber_resume()` and `mrb_fiber_yield()`.
  Removed comments from C files that were not documented by yard and doxygen instead.
- Leads to use of `mrb_fiber_resume()` instead of `Fiber#resume` in C.
- Leads to use of `mrb_fiber_yield()` instead of `Fiber.yield` in C.
2022-11-19 16:59:28 +09:00
Yukihiro "Matz" Matsumoto a099ca44f4 error.c (mrb_sys_fail): errno argument removed from _sys_fail.
As a side effect, `errno.h` dependency removed from `error.c`.
2022-11-15 13:27:32 +09:00
Yukihiro "Matz" Matsumoto 71a1d0ad26 mruby-sprintf: fix a debug error message (remove additional "1"). 2022-11-15 13:27:31 +09:00
Yukihiro "Matz" Matsumoto 0ad29fda67 Merge pull request #5854 from jbampton/add-ubuntu-2204-to-build
gha: replace `Ubuntu 18.04` with `Ubuntu 22.04` in `build` workflow
2022-11-15 13:27:18 +09:00
John Bampton 512486d067 gha: replace Ubuntu 18.04 with Ubuntu 22.04 in build workflow
https://github.blog/changelog/2022-08-09-github-actions-ubuntu-22-04-is-now-generally-available-on-github-hosted-runners/
2022-11-15 09:27:52 +10:00
Yukihiro "Matz" Matsumoto c9f67d376f Merge pull request #5853 from jbampton/standardize-markdown-headings
docs: standardize Markdown headings
2022-11-13 17:21:59 +09:00
John Bampton 4903aa2be9 docs: standardize Markdown headings 2022-11-13 16:32:38 +10:00
Yukihiro "Matz" Matsumoto 5412f525fa Merge pull request #5851 from dearblue/prepare_missing
Changed `prepare_missing()` parameters
2022-11-13 09:14:12 +09:00
dearblue f9b13d27b5 Changed prepare_missing() parameters
- Now that it is called after `cipush()`, pass in a new ci pointer.
- Removed the parameters `clsp`, `a`, and `c`, which are no longer needed since they now operate directly on `ci`.
- Change the parameter `super`, which is treated as a boolean, to `mrb_bool`.
- Leave the parameter `mid`.
  Because if `prepare_missing()` raises the exception `NoMethodError`, `ci->mid` must not be set when suppressing extra information on the stack trace.
  However, set `ci->mid` here, since the preparation is completed at the end of the function.
2022-11-12 20:56:46 +09:00
Yukihiro "Matz" Matsumoto 6bcbfed8bb mruby-sprintf/sprintf.c: check integer overflow before casting. 2022-11-11 08:08:07 +09:00
Yukihiro "Matz" Matsumoto 9fcfd01f20 mruby-pack/pack.c (read_tmpl): check integer overflow before casting. 2022-11-10 22:21:12 +09:00
Yukihiro "Matz" Matsumoto 3b56332952 doc/mruby3.2.md: update [ci skip] 2022-11-09 23:37:02 +09:00
Yukihiro "Matz" Matsumoto c759ee5f77 AUTHORS: update entries [ci skip] 2022-11-08 16:28:09 +09:00
Yukihiro "Matz" Matsumoto 98cc66070b readnum.c: provide obsolete functions.
- mrb_int_read()
- mrb_float_read()

Both functions should not be use and this file should not be linked.
This is just for compatibility.
2022-11-07 16:09:31 +09:00
Yukihiro "Matz" Matsumoto 4a888a34bb readfloat.c (mrb_read_float): a new function.
We no longer use `mrb_float_read()` that depends on `errno`.
2022-11-07 16:09:31 +09:00
Yukihiro "Matz" Matsumoto 4e9773ae3d readint.c (mrb_int_read): new function.
We no longer use `mrb_read_int` which is kinda compatible with `strtol`.
2022-11-07 16:09:31 +09:00
Yukihiro "Matz" Matsumoto 440adc447b Merge pull request #5849 from dearblue/re-stackerr 2022-11-06 19:46:21 +09:00
dearblue 5db5b27aa0 Using mrb_realloc() with stack_extend_alloc()
Raising a `SystemStackError` exception in an out-of-memory situation will generate backtrace information.
This can eventually lead to a `NoMemoryError` exception, and this process flow is completely undesirable.

In effect, this change means that it will include a revert of commit 0dbb9e6e41.
2022-11-05 20:34:49 +09:00
Yukihiro "Matz" Matsumoto 47575ed72a Merge pull request #5848 from dearblue/mrb_str_inspect-utf-8
Reduce memory copy in `mrb_str_inspect()` with UTF-8
2022-11-04 23:27:05 +09:00
dearblue 97c075ad68 Reduce memory copy in mrb_str_inspect() with UTF-8 2022-11-04 22:13:07 +09:00
Yukihiro "Matz" Matsumoto 4f385f119c parse.y (call_with_block): a->cdr may be NULL. 2022-11-04 14:05:52 +09:00
Yukihiro "Matz" Matsumoto c6b7029cdc mruby-sprintf: fix int and mrb_int mixtures. 2022-11-04 13:11:36 +09:00
Yukihiro "Matz" Matsumoto 7e7cc425d4 bingint.c: add cast to silence some warnings (on VC). 2022-11-04 13:10:51 +09:00
Yukihiro "Matz" Matsumoto b7240056f8 vm.c (funcall_args_capture): fix integer size mixture. 2022-11-04 12:07:00 +09:00
Yukihiro "Matz" Matsumoto 5617de0071 mruby-method/method.c (method_eql): do not check _klass for equality. 2022-11-03 23:38:27 +09:00
Yukihiro "Matz" Matsumoto bf642becc2 internal.h: aggregate prototypes to internal.h.
- mrb_f_send()
- mrb_ci_nregs()
2022-11-02 14:24:42 +09:00
Yukihiro "Matz" Matsumoto e3dd65f761 throw.h: simplified a compilation conditional. 2022-11-02 14:22:04 +09:00
Yukihiro "Matz" Matsumoto c68d3dcbac vm.c: stop wrapping implementation by extern "C". 2022-11-02 14:22:04 +09:00
Yukihiro "Matz" Matsumoto 37fac6c089 throw.h: avoid using static member in C++ struct; fix #5846
The initialization causes linkage error with gcc (not clang), caused by
the following gcc bug:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86254
2022-11-02 14:22:03 +09:00
Yukihiro "Matz" Matsumoto ab0a7f0583 Merge pull request #5839 from jbampton/script-must-not-have-extension
pre-commit(shell): add hook `script-must-not-have-extension`
2022-11-01 23:16:04 +09:00
Yukihiro "Matz" Matsumoto a4b41fe53c Merge pull request #5843 from dearblue/simple-raise
Simplify the `L_RAISE` block
2022-11-01 00:06:06 +09:00
Yukihiro "Matz" Matsumoto ce535b872f Merge pull request #5844 from jbampton/ruby-remove-parenthesis
ruby: remove unneeded parenthesis from methods
2022-11-01 00:05:38 +09:00
John Bampton 2438195289 ruby: remove unneeded parenthesis from methods
commit eeb33da43035b5400f8d1830ea52a68691b3a678
Author: John Bampton <jbampton@gmail.com>
Date:   Mon Oct 31 23:53:43 2022 +1000

    Fix up

commit 80923c8f92a58b2f33a36d6403de7f6341973110
Merge: bc89500f6 416f012f6
Author: John Bampton <jbampton@users.noreply.github.com>
Date:   Mon Oct 31 20:12:59 2022 +1000

    Merge branch 'master' into ruby-remove-parenthesis

commit bc89500f6357c453b457516452ffcc7fd03fee88
Author: John Bampton <jbampton@gmail.com>
Date:   Mon Oct 31 14:39:20 2022 +1000

    ruby: remove unneeded parenthesis from methods
2022-11-01 00:25:09 +10:00
Yukihiro "Matz" Matsumoto 416f012f68 Merge pull request #5845 from jbampton/ruby-fix-whitespace
ruby: standardize whitespace
2022-10-31 18:43:08 +09:00
John Bampton ea8964ef35 ruby: standardize whitespace 2022-10-31 16:25:56 +10:00
Yukihiro "Matz" Matsumoto 734fe47de4 Merge pull request #5841 from dearblue/raise-in-vm
Use macro in `mrb_vm_exec()` exception raising
2022-10-31 13:04:23 +09:00
Yukihiro "Matz" Matsumoto e4d6ea3382 Merge pull request #5838 from jbampton/editorconfig-batch-charset-encoding
Remove `charset = latin1` from `.editorconfig` for batch files
2022-10-31 12:56:42 +09:00
Yukihiro "Matz" Matsumoto 9832e7db5b Merge pull request #5837 from jbampton/pre-commit-tabs-exclude
pre-commit(tabs): use blacklist to exclude files
2022-10-31 07:30:52 +09:00
Yukihiro "Matz" Matsumoto 21436e2350 Merge pull request #5842 from mattn/fix-use-after-free
fix use after free
2022-10-31 07:28:24 +09:00
dearblue 8a62bf25c8 Simplify the L_RAISE block
The current flow of the `L_RAISE` block is as follows:

```mermaid
flowchart LR

raise((raise))
raise --> citop{"top of call info?"}

citop -- YES --> chftop{"no catch handler?"}
citop -- NO --> chf{"no catch handler?"}

chftop -- YES --> fiber{"root of fiber?"}
chftop -- NO --> vmexec((vmexec))

fiber -- YES --> vmstop((vmstop))
fiber -- NO --> fswitch["switch fiber"]
fswitch --> citop

chf -- YES --> cipop["cipop"]
chf -- NO --> vmexec((vmexec))
cipop --> citop
```

This patch makes the catch handler search first:

```mermaid
flowchart LR

raise((raise))
raise --> chf{"no catch handler?"}

chf -- NO --> vmexec((vmexec))
chf -- YES --> citop{"top of call info?"}

citop -- YES --> fiber{"root of fiber?"}
citop -- NO --> cipop["cipop"]
cipop --> chf

fiber -- YES --> vmstop((vmstop))
fiber -- NO --> fswitch["switch fiber"]
fswitch --> chf
```
2022-10-30 23:05:29 +09:00
Yasuhiro Matsumoto 6697a6a067 fix use after free 2022-10-30 20:51:33 +09:00
Yukihiro "Matz" Matsumoto 4371b736b7 Merge pull request #5811 from FnControlRuby/splat
ops.h: update `OP_ARYDUP` instruction and rename  to `OP_ARYSPLAT`
2022-10-30 16:50:58 +09:00
fn ⌃ ⌥ 273fcbc347 ops.h: update OP_ARYDUP instruction and rename to OP_ARYSPLAT.
Transforms the value of a splat inside a return statement (similar
to an array). For example, `return *nil` should return `nil.to_a`,
while `return *1` should return `[1]`
2022-10-29 19:54:34 -07:00
dearblue 1de8fda2ec Use macro in mrb_vm_exec() exception raising
Introduce the macro functions `RAISE_EXC()`, `RAISE_FORMAT()` and `RAISE_LIT()`.
2022-10-30 11:04:38 +09:00
Yukihiro "Matz" Matsumoto 6ee4f845c6 Merge pull request #5840 from mattn/errno-windows
errno must be set before mrb_sys_fail
2022-10-30 07:56:59 +09:00
Yasuhiro Matsumoto 4612c8b2d6 errno must be set before mrb_sys_fail 2022-10-30 01:00:27 +09:00
John Bampton bd51915679 Remove charset = latin1 from .editorconfig for batch files
The top `.editorconfig` rule `charset = utf-8` now applies to batch files

```
mruby % file -I mrbgems/mruby-bin-config/mruby-config.bat
mrbgems/mruby-bin-config/mruby-config.bat: text/x-msdos-batch; charset=us-ascii
```

US-ASCII (basic English) is a 7-bit, 128 characters code page, originally designed for telegraphy.

UTF-8 encoding uses the same encoding as 7-bit ASCII for its first 128 characters. So a text file that only contains characters from that range of the first 128 characters will be identical at a byte level whether encoded with UTF-8 or 7-bit ASCII.

https://stackoverflow.com/questions/11303405/force-encode-from-us-ascii-to-utf-8-iconv
2022-10-29 23:45:39 +10:00
John Bampton af0b3e3388 pre-commit(shell): add hook script-must-not-have-extension
```
mruby % file -I mrbgems/mruby-bin-config/mruby-config
mrbgems/mruby-bin-config/mruby-config: text/x-shellscript; charset=us-ascii
```

The Google shell style guide states:

Executables should have no extension (strongly preferred)

This hook checks for conformance.

https://github.com/jumanjihouse/pre-commit-hooks#script-must-not-have-extension

We are already using hooks from "jumanjihouse" in the `mgem-list` repo.

https://github.com/mruby/mgem-list/blob/f5904922d5fbc87f45c582b8ef759e2ebf16df79/.pre-commit-config.yaml#L39
2022-10-29 23:08:48 +10:00
John Bampton e7507778a4 pre-commit(tabs): use blacklist to exclude files
Add `indent_style = space` to the `.editorconfig` file for batch files.
2022-10-29 20:26:00 +10:00
Yukihiro "Matz" Matsumoto 15eb62479b Merge pull request #5836 from jbampton/fix-whitespace-in-md-files
docs: standardize whitespace in Markdown files
2022-10-29 18:56:45 +09:00
John Bampton f631460dfb docs: standardize whitespace in Markdown files
Most of the Markdown has a single space between sentences.

This pr changes `2 spaces` to `1 space`.
2022-10-29 18:49:31 +10:00
Yukihiro "Matz" Matsumoto ce86585281 Merge pull request #5812 from FnControlRuby/block
parse.y: fix return/break/next with method call with args and block
2022-10-29 16:29:41 +09:00
Yukihiro "Matz" Matsumoto 9edf311fd3 Merge pull request #5834 from FnControlRuby/<=>
kernel.c (mrb_cmp_m): use mrb_equal instead of mrb_obj_equal.
2022-10-29 16:29:26 +09:00
fn ⌃ ⌥ 55c423fc55 kernel.c (mrb_cmp_m): use mrb_equal instead of mrb_obj_equal.
`Kernel#<=>` should also call `#==` to check if the objects are equal.
2022-10-28 06:19:37 -07:00
Yukihiro "Matz" Matsumoto 63c0abeabd Merge pull request #5835 from mattn/windows-errno
use WSAGetLastError() for errno on Windows
2022-10-28 18:13:39 +09:00
Yasuhiro Matsumoto fd5e3654c4 use WSAGetLastError() for errno on Windows 2022-10-28 17:17:09 +09:00
Yukihiro "Matz" Matsumoto 5ccca7e45b mruby-bigint/bigint.c (udiv): skip loop if xd<yd. 2022-10-28 17:01:46 +09:00
Yukihiro "Matz" Matsumoto 02f44d76fc codegen.c: stop peephole optimization for headless case statement.
This fixes #5815
2022-10-28 15:57:35 +09:00
Yukihiro "Matz" Matsumoto 9ff247c5c2 Revert "codegen.c: exit headless case early if a condition is always true"
This reverts commit e5b32e559860073632fc7b69cb98b90f2c069e81; ref #5815
2022-10-28 15:54:40 +09:00
Yukihiro "Matz" Matsumoto 604d7e9c86 mruby-bigint/bigint.c (mpz_mul_2exp): move mpz_clear() call.
No need to call mpz_clear() after mpz_move().
2022-10-28 15:36:34 +09:00
Yukihiro "Matz" Matsumoto 5f5109b72b Merge pull request #5815 from FnControlRuby/case
codegen.c: exit headless `case` early if a condition is always true
2022-10-28 15:36:22 +09:00
Yukihiro "Matz" Matsumoto 4f8ab59e79 Merge pull request #5819 from FnControlRuby/allocate
class.c (mrb_instance_alloc): raise error if NilClass/FalseClass
2022-10-28 15:19:24 +09:00
Yukihiro "Matz" Matsumoto bb67008663 Merge pull request #5832 from FnControlRuby/comparable
Fix `Comparable#clamp` with range
2022-10-27 18:13:40 +09:00
Yukihiro "Matz" Matsumoto 5ee42ff1dd Merge pull request #5833 from jbampton/remove-coding-utf-8-ruby
Remove `# coding: utf-8` from Ruby files
2022-10-27 18:11:54 +09:00
Yukihiro "Matz" Matsumoto 8a67a26104 mruby-pack/pack.c (unpack): check if the given length is positive.
To avoid out-of-bound array access.
2022-10-27 16:32:05 +09:00
John Bampton 44db4f18d3 Remove # coding: utf-8 from Ruby files
The default script encoding is Encoding::UTF-8 after v2.0.

https://ruby-doc.org/core-2.1.2/Encoding.html#class-Encoding-label-Script+encoding
2022-10-27 04:43:13 +10:00
fn ⌃ ⌥ c1697a9c4e kernel.c (mrb_cmp_m): implement Kernel#<=> 2022-10-26 09:04:29 -07:00
fn ⌃ ⌥ 3adae7d237 mruby-compar-ext/compar.rb (clamp): fix range support.
Also, raise error if any comparison among min, max, and self
returns nil.
2022-10-26 09:02:32 -07:00
Yukihiro "Matz" Matsumoto a8a8e7fbd8 Merge pull request #5831 from jbampton/fix-spelling
Fix spelling: `floating point` -> `floating-point`
2022-10-27 00:29:32 +09:00
Yukihiro "Matz" Matsumoto b49eb72a5a Merge pull request #5830 from jbampton/remove-semi-colons-ruby
Remove unneeded trailing semi-colons from Ruby files
2022-10-27 00:28:54 +09:00
John Bampton 8208a836ff Fix spelling: floating point -> floating-point
https://en.wikipedia.org/wiki/Floating-point_arithmetic
2022-10-27 00:09:12 +10:00
John Bampton 7870409cf1 Remove unneeded trailing semi-colons from Ruby files 2022-10-26 23:48:27 +10:00
Yukihiro "Matz" Matsumoto 7eb6d626f5 update pre-commit-config by rake checkupdate; ref #5816 2022-10-26 22:10:38 +09:00
Yukihiro "Matz" Matsumoto eba36f5991 Merge pull request #5827 from jbampton/c-remove-extra-semicolon
Remove unneeded trailing semi-colons from `C` files
2022-10-26 22:10:22 +09:00
Yukihiro "Matz" Matsumoto e678af175e Merge pull request #5829 from jbampton/fiber-c-fix-grammar
fiber.c: fix grammar
2022-10-26 22:09:58 +09:00
Yukihiro "Matz" Matsumoto f18a75e1dc Merge pull request #5828 from jbampton/add-hooks-for-tabs
pre-commit: add hooks `forbid-tabs` and `remove-tabs`
2022-10-26 22:09:21 +09:00
John Bampton da4d7d4bc6 fiber.c: fix grammar
`suspend` -> `suspended`
2022-10-26 22:48:01 +10:00
John Bampton aab7bc0023 pre-commit: add hooks forbid-tabs and remove-tabs
The indentation settings have been taken from the `.editorconfig` file

https://github.com/Lucas-C/pre-commit-hooks
2022-10-26 21:33:32 +10:00
John Bampton 664c9e533b Remove unneeded trailing semi-colons from C files 2022-10-26 20:07:18 +10:00
Yukihiro "Matz" Matsumoto 52a3dc2153 Merge pull request #5825 from jbampton/add-pre-commit-hook
pre-commit: add hook `check-shebang-scripts-are-executable`
2022-10-26 18:55:18 +09:00
Yukihiro "Matz" Matsumoto ce9918d45c Merge pull request #5824 from jbampton/tasks-rake-doc-macos
tasks: enable rake docs to open on macOS
2022-10-26 18:53:32 +09:00
Yukihiro "Matz" Matsumoto 1aa77c9f23 Merge pull request #5826 from jbampton/replace-gsub-with-tr
Replace `gsub` with `tr`
2022-10-26 18:04:32 +09:00
Yukihiro "Matz" Matsumoto 580134e07a Merge pull request #5823 from jbampton/remove-travis-button
docs: remove unused Travis CI button from README
2022-10-26 18:03:26 +09:00
Yukihiro "Matz" Matsumoto f718408371 Merge pull request #5822 from jbampton/assert-remove-comma
Remove unneeded trailing comma from `assert_equal` statement
2022-10-26 17:42:36 +09:00
John Bampton 1626758ccc Replace gsub with tr
Using `tr` is faster than `gsub` when replacing a single character in a string with another single character
2022-10-26 18:17:17 +10:00
John Bampton 1d37f75add pre-commit: add hook check-shebang-scripts-are-executable
chmod +x ./mrbgems/mruby-bin-config/mruby-config

https://github.com/pre-commit/pre-commit-hooks#check-shebang-scripts-are-executable
2022-10-26 16:37:17 +10:00
John Bampton 1bf9ed196c tasks: enable rake docs to open on macOS
The `xdg-open` command is not available on macOS.

macOS uses the `open` command.

Add info to install doxygen on macOS with Homebrew.

https://formulae.brew.sh/formula/doxygen
2022-10-26 15:39:10 +10:00
John Bampton 2e3861ff7c docs: remove unused Travis CI button from README
The building on travis-ci.org is ceased.
2022-10-26 14:40:20 +10:00
Yukihiro "Matz" Matsumoto 20617017df Merge pull request #5821 from jbampton/standardize-md-lists
docs: standardize Markdown lists
2022-10-26 13:12:56 +09:00
John Bampton b049a71582 Remove unneeded trailing comma from assert_equal statement 2022-10-26 13:58:53 +10:00
John Bampton 696226a60e docs: standardize Markdown lists
Previously for lists we were using both `*` and `-` to start the list items.

This pr changes all lists to use `-`.
2022-10-26 13:09:41 +10:00
Yukihiro "Matz" Matsumoto 0ae85c9233 Merge pull request #5816 from jbampton/add-target
Makefile/Rakefile: add checkupdate target
2022-10-26 11:20:25 +09:00
John Bampton 72f22afc99 Makefile/Rakefile: add checkupdate target
Runs `pre-commit autoupdate`
2022-10-26 12:04:59 +10:00
Yukihiro "Matz" Matsumoto a1cdb3240e Merge pull request #5820 from FnControlRuby/nil
Implement `nil.to_c` and `nil.to_r`
2022-10-26 07:32:19 +09:00
Yukihiro "Matz" Matsumoto fe5191398a mruby-set: rename mrb_set.rb to set.rb. 2022-10-25 16:59:49 +09:00
Yukihiro "Matz" Matsumoto e3f74074ba mruby-set: remove intialize_{dup,clone}. 2022-10-25 16:58:31 +09:00
Yukihiro "Matz" Matsumoto 1152c43039 mruby-set: remove taint/untaint which are no longer exist. 2022-10-25 16:57:24 +09:00
fn ⌃ ⌥ c65200cb5a complex.rb: implement Numeric#to_c 2022-10-24 17:31:52 -07:00
fn ⌃ ⌥ 7801741790 complex.c: implement nil.to_c 2022-10-24 17:31:52 -07:00
fn ⌃ ⌥ f3ec5f744f rational.c: implement nil.to_r and Float#to_r 2022-10-24 17:31:52 -07:00
fn ⌃ ⌥ 91f8245a0c class.c (mrb_instance_alloc): raise error if NilClass/FalseClass.
MRB_TT_FALSE is equal to 0, so we have to explicitly check if the
class is either NilClass or FalseClass.
2022-10-24 07:57:28 -07:00
Yukihiro "Matz" Matsumoto 7cf3b57cba mruby-set/mrb_set.rb (<=>): update definition.
Set#<=> needs to be comparing sets to be subset/superset relation.
2022-10-24 07:53:52 +09:00
Yukihiro "Matz" Matsumoto 7acf756b6f mruby-set/mrb_set.rb: add __ prefix to internal methods. 2022-10-24 07:44:21 +09:00
Yukihiro "Matz" Matsumoto ca0db4a161 mruby-set/README.md: more cleanup after #5814 2022-10-24 07:42:53 +09:00
Yukihiro "Matz" Matsumoto b1fd3dc160 mruby-set/mrbgem.rake; remove test dependency to mruby-metaprog.
mruby-set no longer depends on mruby-metaprog by introducing the
internal `_hash` method.
2022-10-24 07:42:52 +09:00
Yukihiro "Matz" Matsumoto e9ee0f2953 mruby-set/set.rb (_hash): add utility function to access internal hash.
Since `instance_variable_get` is no longer in the core.
2022-10-24 07:42:52 +09:00
Yukihiro "Matz" Matsumoto d5e13a7f2a mruby-set/set.rb (do_with_enum): prefix _ to internal method. 2022-10-24 07:41:30 +09:00
Yukihiro "Matz" Matsumoto 59162ceb4e Merge pull request #5817 from FnControlRuby/set
mrb_set.rb: improve ruby/spec compliance.
2022-10-24 07:41:20 +09:00
fn ⌃ ⌥ b0a494c414 mrb_set.rb: improve ruby/spec compliance.
- Alias `#===` to `#include?`
- Alias `#filter!` to `#select!`
- Fix `#subset?` and `#proper_subset?` for Set-like objects.
- Fix `#==`
- Fix `#inspect` for self-referencing sets.
- Add `#<=>` and `#join`
2022-10-23 07:42:25 -07:00
Yukihiro "Matz" Matsumoto f5824029ad Merge pull request #5814 from jbampton/mruby-set-docs
Clean up the mruby-set README
2022-10-22 22:57:22 +09:00
fn ⌃ ⌥ fee8f540c6 parse.y: fix return/break/next with method call with args and block 2022-10-21 20:01:08 -07:00
fn ⌃ ⌥ e5b32e5598 codegen.c: exit headless case early if a condition is always true 2022-10-21 20:00:44 -07:00
John Bampton f78fdecfc8 Clean up the mruby-set README 2022-10-22 12:25:29 +10:00
Yukihiro "Matz" Matsumoto 2d57967afa Merge pull request #5813 from jbampton/fix-pre-commit
gha: fix pre-commit
2022-10-22 07:50:03 +09:00
John Bampton 2ebb001e76 gha: fix pre-commit
Run `pre-commit run --all-files`
2022-10-22 08:31:38 +10:00
Yukihiro "Matz" Matsumoto e8e7887efe Merge pull request #5809 from dearblue/dep-mruby-proc-binding
Needs `mruby-proc-ext` by `mruby-proc-binding`
2022-10-22 00:34:05 +09:00
Yukihiro "Matz" Matsumoto d459b82c35 Merge pull request #5810 from dearblue/add-depends
Add default sauce to `#add_dependency`
2022-10-22 00:33:52 +09:00
dearblue bbb04d257f Add default sauce to #add_dependency 2022-10-21 22:27:20 +09:00
dearblue 6adbbd8773 Needs mruby-proc-ext by mruby-proc-binding
The `mruby-proc_source_location()` function used in `src/proc-binding.c` of `mruby-proc-binding` is defined in `mruby-proc-ext`.
2022-10-21 21:44:06 +09:00
Yukihiro "Matz" Matsumoto 63f7db0fba stdlib.gembox: add mruby-set gem. 2022-10-21 14:14:51 +09:00
Yukihiro "Matz" Matsumoto dad0852944 mruby-set/mrbgem.rake: add test dependency.
The `instance_variable_get` has been separated to `mruby-metaprog` gem,
so we need to specify the gem as test dependency.
2022-10-21 14:12:10 +09:00
Yukihiro "Matz" Matsumoto 4c86a7a5c3 Add 'mrbgems/mruby-set/' from commit '68334311ac7386eef84f3034a256e7135a87625d'
git-subtree-dir: mrbgems/mruby-set
git-subtree-mainline: 3b55a09f91
git-subtree-split: 68334311ac
2022-10-21 13:56:07 +09:00
Yukihiro "Matz" Matsumoto 3b55a09f91 mruby-hash-ext/hash.c (hash_values_at): early return from the function. 2022-10-21 13:41:38 +09:00
Yukihiro "Matz" Matsumoto 33f97bccba array.c (mrb_ary_unshift): use mrb_get_argc() and mrb_get_argv(). 2022-10-21 13:31:32 +09:00
Yukihiro "Matz" Matsumoto c27ae4337d mruby-array-ext/array.c (mrb_ary_values_at): avoid mrb_get_args().
If your function doesn't call VM recursively, you can use mrb_get_argv()
instead of mrb_get_args(mrb, "*", ...).
2022-10-20 19:07:25 +09:00
Yukihiro "Matz" Matsumoto da8ef29fba array.c (mrb_ary_push_m): fixed a stupid bug. 2022-10-19 17:14:49 +09:00
Yukihiro "Matz" Matsumoto cd17e177a7 Merge pull request #5808 from FnControlRuby/regx
parse.y: fix NODE_REGX dump
2022-10-19 17:12:50 +09:00
fn ⌃ ⌥ 6ba44f64d5 parse.y: fix NODE_REGX dump 2022-10-18 20:56:00 -07:00
Yukihiro "Matz" Matsumoto bdb51d1af4 array.c (mrb_ary_push_m): adjust function order.
ary_modify() and ary_expand_capa() may cause garbage collection and may
make argv invalid (in the future).
2022-10-18 17:11:07 +09:00
Yukihiro "Matz" Matsumoto 3f286f1bfd array.c: make ary_modify_check() an alias to mrb_check_frozen(). 2022-10-17 21:59:22 +09:00
Yukihiro "Matz" Matsumoto 84c26870d2 mruby-errno/errno.c (mrb_errno_list): no need to check array type here. 2022-10-16 23:20:49 +09:00
Yukihiro "Matz" Matsumoto 5c2f3f72a4 mruby-array-ext/array.c (mrb_ary_slice_bang): refactor.
Use `mrb_ary_new_from_value()` instead of adding individual elements
using a loop.
2022-10-15 08:46:48 +09:00
Yukihiro "Matz" Matsumoto d84daa56fa mruby-struct/struct.c (mrb_struct_modify): remove the write barrier.
Instead of calling write barriers (mrb_write_barrier) in the function,
call field write barriers (mrb_field_write_barrier_value) from the
individual functions.
2022-10-14 15:54:09 +09:00
Yukihiro "Matz" Matsumoto 6c40d64327 mruby-struct/struct.c: refactoring. 2022-10-13 23:12:53 +09:00
Yukihiro "Matz" Matsumoto af9ce1f64c mruby-struct/struct.c: adjust spaces. 2022-10-12 22:02:21 +09:00
Yukihiro "Matz" Matsumoto 37a3252ed3 mruby-struct/struct.c: need to use MRB_TT_STRUCT. 2022-10-11 23:24:19 +09:00
Yukihiro "Matz" Matsumoto 83fc75f399 doc/guides/mrbconf.md: update description for the configuration file. 2022-10-10 22:28:51 +09:00
Yukihiro "Matz" Matsumoto e19d55dbdd AUTHORS: update entries [ci skip] 2022-10-10 22:23:11 +09:00
Yukihiro "Matz" Matsumoto 4cefb2cccd class.c (mt_get): fix a bug regarding inline method cache. 2022-10-10 22:23:10 +09:00
Yukihiro "Matz" Matsumoto 16a224e25d mrbconf.h: add MRB_USE_INLINE_METHOD_CACHE option description.
Currently it does not improve the performance (yet).
2022-10-10 22:23:10 +09:00
Yukihiro "Matz" Matsumoto 5d1d58d4d1 Merge pull request #5805 from dearblue/doc/another-bigint
Add `examples/mrbgems/mruby-YOUR-bigint`
2022-10-10 19:52:30 +09:00
Yukihiro "Matz" Matsumoto c01587672d Merge pull request #5806 from dearblue/doc/mrbconf
Induce configuration to the `build_config` file
2022-10-10 19:51:08 +09:00
dearblue 6f80f09547 Induce configuration to the build_config file 2022-10-10 18:22:05 +09:00
dearblue 8f0dba2985 Add examples/mrbgems/mruby-YOUR-bigint 2022-10-10 14:12:53 +09:00
Yukihiro "Matz" Matsumoto 9fe5fc441a Merge pull request #5803 from bovi/patch-1
Update year in LICENSE file
2022-10-10 00:13:50 +09:00
Daniel Bovensiepen Li c47038462f Update year to 2022 in mruby.h 2022-10-09 17:02:27 +08:00
Daniel Bovensiepen Li 8717ef86c0 Update year in LICENSE file 2022-10-09 15:40:06 +08:00
Yukihiro "Matz" Matsumoto 95bf3c0d99 Merge pull request #5802 from dearblue/doc/addfiles
Additional file patterns to be documented
2022-10-07 12:05:31 +09:00
Yukihiro "Matz" Matsumoto daf2e23487 Merge pull request #5801 from dearblue/doc/call-seq
Corrected document directive to "call-seq"
2022-10-07 12:04:59 +09:00
Yukihiro "Matz" Matsumoto 27619cebc0 mruby.h: update documentation for mrb_singleton_class(); ref #5800 2022-10-07 12:03:28 +09:00
Yukihiro "Matz" Matsumoto 5d13733352 vm.c (OP_ENTER): address fast path.
For method of fixed arguments only (no rest arguments, no keyword
arguments). Makes Fibonacci benchmark and ao_bench 4-5% faster.
2022-10-07 12:01:13 +09:00
Yukihiro "Matz" Matsumoto df8295cbeb Merge pull request #5800 from dearblue/doc/singleton-class
Added documentation for `mrb_singleton_class()`
2022-10-07 12:01:02 +09:00
dearblue 911c81e0f1 Additional file patterns to be documented 2022-10-06 21:57:43 +09:00
dearblue 366185a54d Corrected document directive to "call-seq" 2022-10-06 21:56:38 +09:00
dearblue dbc78cd861 Added documentation for mrb_singleton_class() 2022-10-06 21:56:07 +09:00
Yukihiro "Matz" Matsumoto 52562f7dcc Merge pull request #5799 from mruby/dependabot/github_actions/github/super-linter-4.9.7
build(deps): bump github/super-linter from 4.9.6 to 4.9.7
2022-10-05 23:13:09 +09:00
Yukihiro "Matz" Matsumoto 78c8b649e7 mruby-print/print.c: small refactoring.
Inline `printstr` function which is called from only one place.
2022-10-05 23:11:11 +09:00
dependabot[bot] 5f4b83f7c1 build(deps): bump github/super-linter from 4.9.6 to 4.9.7
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.9.6 to 4.9.7.
- [Release notes](https://github.com/github/super-linter/releases)
- [Changelog](https://github.com/github/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/github/super-linter/compare/v4.9.6...v4.9.7)

---
updated-dependencies:
- dependency-name: github/super-linter
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-05 14:08:56 +00:00
Yukihiro "Matz" Matsumoto 268f6dcab3 numeric.c (mrb_float_to_integer): isinf/isnan takes any float values.
So don't need to cast to `float`, just use `mrb_float`.
2022-10-04 11:05:15 +09:00
Yukihiro "Matz" Matsumoto 62e0e3eebe class.c (mrb_get_args_a): adjust spacing [ci skip] 2022-10-04 11:05:15 +09:00
Yukihiro "Matz" Matsumoto ea1bc39b52 mruby-proc-ext/proc.c (mrb_proc_inspect): update the format. 2022-10-04 11:05:15 +09:00
Yukihiro "Matz" Matsumoto e7e22ec6a8 mruby-method/method.c (method_to_s): add location information.
Test updated too.
2022-10-04 11:05:14 +09:00
Yukihiro "Matz" Matsumoto 0c9fd9cffd Merge pull request #5798 from boahc077/github_actions_token_permission
ci: add minimum GitHub token permissions for workflows
2022-10-04 11:05:07 +09:00
Ashish Kurmi 34c640b8be ci: add minimum GitHub token permissions for workflows
Signed-off-by: Ashish Kurmi <akurmi@stepsecurity.io>
2022-10-02 10:15:55 -07:00
Yukihiro "Matz" Matsumoto 751ac378bd codegen.c: should not skip rhs array; fix #5797
When the value of multiple assignment taken, the rhs array needs to be
generated anyway.
2022-10-01 15:18:45 +09:00
Yukihiro "Matz" Matsumoto db7d40be85 mruby-proc-ext/proc.c (mrb_proc_parameters): disclose unnamed arguments.
Unnamed arguments (*, **, &) should be disclosed in the parameter list.
The test is also updated.
2022-09-30 22:19:59 +09:00
Yukihiro "Matz" Matsumoto 7ced009d4c mruby-proc-ext/proc.c (mrb_proc_parameters): unify conditions. 2022-09-30 22:19:58 +09:00
Yukihiro "Matz" Matsumoto 3d766aa1ef mruby-proc-ext/proc.c (mrb_proc_parameters): count arguments first.
Instead of approximating using `irep->nlocals-1` (which should be bigger
than argument numbers).
2022-09-30 22:19:36 +09:00
Yukihiro "Matz" Matsumoto 3a2de4af00 mruby-proc-ext/proc.c (mrb_proc_parameters): skip empty block slot.
Unlike other formal arguments, a block argument has an empty slot even
when the block is not given.
2022-09-30 07:49:44 +09:00
Yukihiro "Matz" Matsumoto 7667b0fc04 mruby-proc-ext/proc.c (mrb_proc_parameters): reformat. 2022-09-30 07:43:57 +09:00
Yukihiro "Matz" Matsumoto 3c16423c0a mruby-method/method.c (method_to_s): making it compatible with CRuby. 2022-09-29 11:00:49 +09:00
Yukihiro "Matz" Matsumoto b73802d437 vm.c (cipop): wrong callinfo shifts fixed; ref #5791 2022-09-28 16:57:11 +09:00
Yukihiro "Matz" Matsumoto 5e1c16653f mruby-method/method.c (method_super_method): fixed module related bug.
When the method is defined in module, super_method started method
searching from wrong point. We needed to find ICLASS corresponding to the
module, then start searching super_method from the next ancestor.
2022-09-27 23:03:38 +09:00
Yukihiro "Matz" Matsumoto 0a0ab73e8d mruby-class-ext: #subclasses should be a method of Class, not Module. 2022-09-27 23:03:23 +09:00
Yukihiro "Matz" Matsumoto 0c475708de vm.c (cipop): use mrb_object_dead_p() to detect reclaimed block; #5791 2022-09-26 07:50:41 +09:00
Yukihiro "Matz" Matsumoto 993c8c1053 gc.c (final_marking_phase): move exception clearing after marking; #5789 2022-09-24 23:08:28 +09:00
Yukihiro "Matz" Matsumoto d9061bd969 numeric.c: update documents [ci skip]. 2022-09-23 22:13:28 +09:00
Yukihiro "Matz" Matsumoto a04b09d535 Merge pull request #5796 from dearblue/bigint-readme
Small improves for `mrbgems/mruby-bigint/README.md` [ci skip]
2022-09-22 10:53:57 +09:00
dearblue b7069dba41 Small improves for mrbgems/mruby-bigint/README.md [ci skip]
- Add a period at the end of the line because markdown will combine lines if there are no blank lines.
- Enable link to `README-fgmp.md`.
2022-09-21 22:50:47 +09:00
Yukihiro "Matz" Matsumoto 07470eb538 mruby-exit.c: make exit() to raise SystemExit exception.
Now it allows error handlers to work, unlike `exit!`.
2022-09-21 22:37:23 +09:00
Yukihiro "Matz" Matsumoto 11504318b8 string-ext/string.rb: String#prepend to take multiple arguments. 2022-09-20 18:31:04 +09:00
Yukihiro "Matz" Matsumoto 4cba1b49c0 string-ext/string.c: String#concat to take multiple arguments. 2022-09-20 18:26:23 +09:00
Yukihiro "Matz" Matsumoto a4099ff776 enum-ext/enum.rb: add Enumerable#sum 2022-09-19 12:31:11 +09:00
Yukihiro "Matz" Matsumoto 81f98a3925 vm.c (cipop): check type of the callinfo::blk; fix #5791
Since `callinfo::blk` is not marked in the GC, it may be reclaimed in
the sweep phase. When it reclaimed, it will become either (a) a non Proc
object, or (b) a Proc object that happen to have the same address.

For case (a), adding `b->tt == MRB_TT_PROC` check works. We should avoid
the following `MRB_PROC_STRICT_P()` and `MRB_PROC_ENV()` operations for
non Proc objects.

For case (b), `MRB_PROC_ENV(b) == CI_ENV(&c->ci[-1])` check should work.
Unrelated Proc objects should be filtered by the check.

We don't need to clear `callinfo::blk` by `NULL` because the callinfo
struct will be discarded afterward in the `cipop()` function.
2022-09-19 08:35:36 +09:00
Yukihiro "Matz" Matsumoto 5b62fbc0fc array.c (mrb_ary_concat_m): Array#concat to take multiple arguments. 2022-09-19 08:25:00 +09:00
Yukihiro "Matz" Matsumoto 9caa4d642c errno.rb: fixed a typo. 2022-09-18 08:01:07 +09:00
Yukihiro "Matz" Matsumoto 3d125aeb89 errno.c (mrb_exxx_init): simplify the function.
Code duplication with mrb_sce_init has been unified.
2022-09-18 07:59:36 +09:00
Yukihiro "Matz" Matsumoto db536da412 errno.c (mrb_sce_sys_fail): SystemCallError may be overridden; fix #5793 2022-09-18 00:07:28 +09:00
Yukihiro "Matz" Matsumoto a5d7326eaa Merge pull request #5795 from jbampton/pre-commit-autoupdate
pre-commit autoupdate, fix spelling, update codespell.txt
2022-09-18 00:06:36 +09:00
John Bampton 2990aaa343 pre-commit autoupdate, fix spelling, update codespell.txt
https://pre-commit.com/#pre-commit-autoupdate
2022-09-18 00:22:55 +10:00
Yukihiro "Matz" Matsumoto 71d5cae016 Merge pull request #5792 from dearblue/stderr
Retrieve the `StandardError` class from `mrb_state`
2022-09-17 22:48:50 +09:00
Yukihiro "Matz" Matsumoto dd5a9f74d8 Merge pull request #5794 from jbampton/fix-makefile
Fix Makefile. Change `lint` to `check`
2022-09-17 22:45:38 +09:00
John Bampton d0ba1fb3ca Fix Makefile. Change lint to check 2022-09-17 23:23:35 +10:00
dearblue 50ea98e76d Retrieve the StandardError class from mrb_state 2022-09-17 22:03:52 +09:00
Yukihiro "Matz" Matsumoto a9d0e9a412 Makefile,Rakefile: rename lint target to check; #5790
The pre-commit check does some static analysis but the term lint is used
as static analysis of software code under the UNIX environment. So we
have renamed the target `check`.
2022-09-17 16:44:24 +09:00
Yukihiro "Matz" Matsumoto 52b2e12f07 numeric_ext.c: implement Integer#digits method.
Which is added in Ruby 2.4.
2022-09-17 16:43:06 +09:00
Yukihiro "Matz" Matsumoto bd1310c9f9 gc.c (incremental_gc_finish): rename the function.
incremental_gc_until() are always called with MRB_GC_STATE_ROOT.
So no need to supply it from outside.
2022-09-17 16:43:06 +09:00
Yukihiro "Matz" Matsumoto b774a004a0 Merge pull request #5790 from jbampton/add-lint-target-to-make
Add `lint` target to the Makefile
2022-09-17 16:41:16 +09:00
John Bampton b466271f16 Add lint target to the Makefile
Add `lint` task to the Rakefile

Runs `pre-commit run --all-files`
2022-09-16 13:26:25 +10:00
Yukihiro "Matz" Matsumoto 74b8bbd8b3 TODO.md: update [ci skip]
Remove bigint entry that we have implemented finally.
2022-09-15 06:43:11 +09:00
Yukihiro "Matz" Matsumoto 97a419f540 gc.c (clear_error_object): need to mark class of error objects; ref #5789 2022-09-13 22:20:34 +09:00
Yukihiro "Matz" Matsumoto b5677bff1f gc.c (final_marking_phase): clear error objects before sweep; close #5789
Some error objects are referenced from `mrb_state`, and previously they
are simply marked as root objects. But when they are not referenced from
other part of the program, they are no longer used at the current incarnation.
That means we can safely reclaim their child objects (their messages and
backtrace information).
2022-09-13 07:16:38 +09:00
Yukihiro "Matz" Matsumoto b716bf005e mruby-range-ext/range.c: use the reference from mrb structure.
Avoid `mrb_class_get()` if possible.
2022-09-12 10:29:45 +09:00
Yukihiro "Matz" Matsumoto d72d26afcb mruby-string-ext/string.c: use the reference from mrb structure. 2022-09-12 10:27:31 +09:00
Yukihiro "Matz" Matsumoto 3662d3d9da fixup! numeric_ext.c: use the reference from mrb structure. 2022-09-12 10:27:30 +09:00
Yukihiro "Matz" Matsumoto fc85523cf1 numeric_ext.c: use the reference from mrb structure. 2022-09-12 10:27:29 +09:00
Yukihiro "Matz" Matsumoto f05574606e mruby-numeric-ext: add ceildiv test with Float and Rational. 2022-09-12 10:27:29 +09:00
Yukihiro "Matz" Matsumoto b6d7564846 numeric_ext.rb: add Integer#ceildiv. 2022-09-12 10:27:28 +09:00
Yukihiro "Matz" Matsumoto ed28547553 doc/guides/mrbconf.md: updates. 2022-09-12 10:27:27 +09:00
Yukihiro "Matz" Matsumoto 3d26993458 AUTHORS: update entries [ci skip] 2022-09-06 13:49:30 +09:00
Yukihiro "Matz" Matsumoto b06fef65ea mruby-exit.c: add reference to exit method.
Currently `exit` works as `exit!` (no handler). It should be fixed
soon.
2022-09-05 23:36:04 +09:00
Yukihiro "Matz" Matsumoto d508c94f0e mruby-exit.c: add exit! method. 2022-09-05 23:35:37 +09:00
Yukihiro "Matz" Matsumoto 6ff00810c6 Merge pull request #5788 from ksss/patch-1
Fix doc for limitation
2022-09-05 14:46:24 +09:00
Yuki Kurihara 9d6cb6ecff Fix doc for limitation
`binding` has been supported since 3.1.0.
2022-09-05 12:12:37 +09:00
Yukihiro "Matz" Matsumoto 966d90e182 src/readfloat.c: renamed from readflt.c 2022-09-05 07:30:13 +09:00
Yukihiro "Matz" Matsumoto 4669d43f50 error.h: move rbreak_tag definitions to src/vm.c. 2022-09-05 07:30:12 +09:00
Yukihiro "Matz" Matsumoto bf16315b70 mruby-exit/exit.c: add fallback definition of constants.
- EXIT_SUCCESS
- EXIT_FAILURE
2022-09-05 07:30:12 +09:00
Yukihiro "Matz" Matsumoto 9f47f11abd math.c: update prototype style. 2022-09-05 07:30:12 +09:00
Yukihiro "Matz" Matsumoto 0cc361990c Merge pull request #5787 from dearblue/count_objects
Improves `ObjectSpace.count_objects`
2022-09-05 07:30:03 +09:00
dearblue c123c49ac4 Improves ObjectSpace.count_objects
- Support for `MRB_TT_STRUCT`, `MRB_TT_BREAK` and `MRB_TT_BIGINT`.
- Performs symbol value embedding with `MRB_SYM()`.
2022-09-04 20:53:18 +09:00
Yukihiro "Matz" Matsumoto eecb6cc080 vm.c (cipush): push block information in the callinfoa; fix #5786 2022-09-01 18:57:19 +09:00
Yukihiro "Matz" Matsumoto 4f0679bb86 pack.c (pack_unpack): small refactoring. 2022-08-31 23:29:12 +09:00
Yukihiro "Matz" Matsumoto 3643f067c2 proc.h: remove unused env flags.
- MRB_ENV_TOUCHED
- MRB_ENV_HEAPED
2022-08-31 07:27:14 +09:00
Yukihiro "Matz" Matsumoto 15e9b09bef pack.c (hex2int): should return signed integer. 2022-08-30 18:08:05 +09:00
Yukihiro "Matz" Matsumoto 0645c4536b readflt.c: small style modifications. 2022-08-29 15:14:46 +09:00
Yukihiro "Matz" Matsumoto dfeda0acc8 random.c: remove Random::DEFAULT. 2022-08-28 08:01:59 +09:00
Yukihiro "Matz" Matsumoto 8c1b2ee0bb numeric_ext.c (int_powm): avoid integer overflow by modulo first.
We do not fall back to big integer calculation unless absolutely necessary.
2022-08-27 22:18:38 +09:00
Yukihiro "Matz" Matsumoto 5b1e14b96b numeric_ext.c (int_powm): better error message. 2022-08-26 14:27:54 +09:00
Yukihiro "Matz" Matsumoto f5a3f4f2ea bigint.c (mpz_powm): avoid stack allocations. 2022-08-26 14:27:54 +09:00
Yukihiro "Matz" Matsumoto b158581118 bigint.c (udiv): xx%yy should have been xx when xx<yy. 2022-08-26 14:19:10 +09:00
Yukihiro "Matz" Matsumoto 4e0da4f0d8 bigint.c (mpz_init_set): fully initialize mpz_t first. 2022-08-26 14:18:30 +09:00
Yukihiro "Matz" Matsumoto 62c36c03b3 bigint.c (mpz_set_int): fixed a bug in integer size check. 2022-08-26 12:55:29 +09:00
Yukihiro "Matz" Matsumoto 6598732892 numeric_ext.c (int_powm): try bigint pow when overflow. 2022-08-26 12:37:54 +09:00
Yukihiro "Matz" Matsumoto b4785044d5 bigint.c (mrb_bint_powm): fix a return value bug. 2022-08-26 12:13:24 +09:00
Yukihiro "Matz" Matsumoto ef1974099d bigint.c (mrb_bint_powm): check zero division first. 2022-08-26 12:10:22 +09:00
Yukihiro "Matz" Matsumoto 818ca413af symbol.c (find_symbol): use mrb_byte_hash() instead of symhash(). 2022-08-25 18:50:17 +09:00
Yukihiro "Matz" Matsumoto b832856978 Merge branch 'sasq64-get-args-array' 2022-08-24 16:50:02 +09:00
Yukihiro "Matz" Matsumoto d4e649f8bf class.c: refactoring mrb_get_args(); ref #5596 2022-08-24 16:49:10 +09:00
Yukihiro "Matz" Matsumoto eaa89fbe2a Merge branch 'get-args-array' of https://github.com/sasq64/mruby into sasq64-get-args-array 2022-08-24 16:46:00 +09:00
Yukihiro "Matz" Matsumoto 7c0f7e2665 parse.y: allow NUMPARAMs (e.g. _1) as hash keys; fix #5785 2022-08-23 18:36:26 +09:00
Yukihiro "Matz" Matsumoto f587edd849 pack.c: need extra space for the terminal NULL. 2022-08-23 15:05:27 +09:00
Yukihiro "Matz" Matsumoto a641f146fc codegen.c (gen_assignment): use nsym() instead of simple type cast. 2022-08-23 11:30:54 +09:00
Yukihiro "Matz" Matsumoto 108875c972 codegen.c (gen_assignment): support NODE_COLON3 as lhs; fix #5752
We should allow `::C = 1` for example.
2022-08-23 07:53:23 +09:00
Yukihiro "Matz" Matsumoto c6daaa8c07 struct.c (make_struct): use preallocated symbols. 2022-08-22 16:12:59 +09:00
Yukihiro "Matz" Matsumoto 35a5678899 mruby-pack/pack.c: make base64_dec_tab a static array of chars. 2022-08-21 19:25:16 +09:00
Yukihiro "Matz" Matsumoto 9b4bbed047 vm.c (OP_SEND): remove scoping braces; ref #5775 2022-08-20 21:24:30 +09:00
Yukihiro "Matz" Matsumoto 43c5cd2dea Merge pull request #5775 from dearblue/integrate-super
Integrate the second half of `OP_SUPER` with `OP_SENDB`
2022-08-20 21:23:16 +09:00
Yukihiro "Matz" Matsumoto c7d2eaa3e8 Revert "vm.c (mrb_funcall_with_block): avoid use of MRB_METHOD_CFUNC_P()."
This reverts commit c28ac75a87.
This change caused SEGV in the case like the following:

```
class C
  class << self
    attr_accessor :a
    alias :const_missing :a=
  end
end
p C::CONST
```
2022-08-20 12:58:17 +09:00
Yukihiro "Matz" Matsumoto 563010697e doc/guides/compile.md: add rake clean tip; ref #5784 [ci skip] 2022-08-20 12:54:30 +09:00
dearblue 9c3e0145eb Directly write ARGUMENT_NORMALIZE()
The common parts of `OP_SEND` and `OP_SUPER` have been merged so they no longer need to be independent.
This effectively means revert commit d0e8637e30.
2022-08-20 10:46:46 +09:00
dearblue a7bfddecdb Integrate the second half of OP_SUPER with OP_SENDB
Not exactly the same, but I think there were some things that should have been fixed in the original `OP_SUPER`.
2022-08-20 10:46:46 +09:00
Yukihiro "Matz" Matsumoto 28d1e794db vm.c (mrb_funcall_with_block): need to initialize arginfo. 2022-08-19 23:17:23 +09:00
Yukihiro "Matz" Matsumoto 82b98bb8a4 vm.c (funcall_args_capture): move argument set-up in the function; #5777 2022-08-18 13:00:08 +09:00
Yukihiro "Matz" Matsumoto c28ac75a87 vm.c (mrb_funcall_with_block): avoid use of MRB_METHOD_CFUNC_P(). 2022-08-18 12:58:30 +09:00
Yukihiro "Matz" Matsumoto 772fe11d83 vm.c (stack_copy): use early return. 2022-08-18 12:57:51 +09:00
Yukihiro "Matz" Matsumoto d577221c2d vm.c (stack_copy) check if src is NULL before memcpy(); ref #5777
Because 2nd argument of memcpy() is declared to never be null.
2022-08-18 08:17:44 +09:00
Yukihiro "Matz" Matsumoto 8c08324d2f Merge pull request #5777 from dearblue/gc-on-cipush
Protect prepared arguments when GC occurs in `cipush()`
2022-08-18 08:09:05 +09:00
Yukihiro "Matz" Matsumoto 490d805577 Merge pull request #5783 from jbampton/patch-1
Use Super-Linter Slim Image
2022-08-17 12:58:54 +09:00
John Bampton 890d48463a Use Super-Linter Slim Image
Should improve workflow time.

https://github.com/github/super-linter#slim-image
2022-08-17 08:53:06 +10:00
Yukihiro "Matz" Matsumoto 993c388cce bigint.c (mrb_bint_idiv): remove unused function. 2022-08-16 15:45:54 +09:00
Yukihiro "Matz" Matsumoto 4107cc95a2 internal.c: move some functions to <mruby/internal.h>.
Ref #5776
2022-08-15 18:13:59 +09:00
Yukihiro "Matz" Matsumoto 37dc1be74b internal.c: move mrb_method_missing prototype to <mruby/internal.h>.
Ref #5776
2022-08-15 17:25:08 +09:00
Yukihiro "Matz" Matsumoto db20cbce53 src/class.c: move method_missing from Kernel to BasicObject; fix #5776
In ISO30170, method_missing is defined under Kernel, but BasicObject is
introduced after ISO and we should move (and have moved) some Kernel
methods to BasicObject, e.g. instance_eval, equal?, etc.

We have missed method_missing (mostly because built-in method_missing
in VM handles most of the case).
2022-08-15 16:41:19 +09:00
Yukihiro "Matz" Matsumoto 6a7fa26411 Merge pull request #5782 from haramako/crash-on-resume-from-cfunc
Protect when call Fiber#resume from C function.
2022-08-14 17:31:56 +09:00
Yukihiro "Matz" Matsumoto 83e8fd54f4 Merge pull request #5779 from dearblue/debug.h
Make definition of `mrb_irep` by `typedef` in `mruby.h`
2022-08-14 17:27:11 +09:00
HARADA Makoto dc65b1faf1 fiber.c: add fiber_check_cfunc in fiber_resume(). 2022-08-13 15:52:52 +09:00
Yukihiro "Matz" Matsumoto 3365388164 Merge pull request #5780 from dearblue/doc/mrb_value
Match the `mrb_value` documentation to the current implementation
2022-08-13 14:06:26 +09:00
dearblue 61c68927a2 Match the mrb_value documentation to the current implementation 2022-08-12 22:35:35 +09:00
dearblue 1e72c61b0f Make definition of mrb_irep by typedef in mruby.h
Eliminated invisible dependencies from `mruby/debug.h` to `mruby/irep.h`.
2022-08-12 22:25:27 +09:00
Yukihiro "Matz" Matsumoto b891c63ae1 numeric.c: calculate correct rounding for bigger numbers. 2022-08-12 12:31:38 +09:00
Yukihiro "Matz" Matsumoto 1a95da4ac2 numeric.c (mrb_cmp): inline big-integer comparison. 2022-08-12 12:24:04 +09:00
Yukihiro "Matz" Matsumoto d14fd77148 numeric.c (mrb_int_pow): make the function to take 2 operands. 2022-08-12 12:19:21 +09:00
Yukihiro "Matz" Matsumoto 15184c50f7 Merge pull request #5778 from dearblue/shadowing-insn
Avoid shadowing `insn` variables in `OP_EXT3`
2022-08-12 12:18:32 +09:00
dearblue 170118e4de Avoid shadowing insn variables in OP_EXT3 2022-08-12 11:12:18 +09:00
dearblue 3c2fcb5e74 Protect prepared arguments when GC occurs in cipush()
When `cipush()` extends "callinfo", GC may occur.
In this case, there was a problem that prepared arguments were spoiled depending on the situation when `cipush()` is called.
Therefore, in the problematic part, `cipush()` is prepared first, and then the arguments are prepared.

The reason for passing `CINFO_DIRECT` to `cipush()` is that it is simply ignored in the `MRB_CATCH()` part of `mrb_vm_exec()`.

Also, the argument processing parts of `mrb_funcall_with_block()` and `mrb_yield_with_class()` are combined and made independent as `funcall_args_capture()`.
2022-08-11 15:25:29 +09:00
Yukihiro "Matz" Matsumoto 8cdf14c06b numeric.c (int_rounding): unify code duplication. 2022-08-10 13:38:24 +09:00
Yukihiro "Matz" Matsumoto 4e735eb8ba numeric.c (flo_rounding): refactor float rounding methods. 2022-08-10 13:38:24 +09:00
Yukihiro "Matz" Matsumoto 7ffdb4c30e numeric.c: implement ndigits truncation for rounding methods.
- ceil
- floor
- round
- truncate
2022-08-10 13:38:23 +09:00
Yukihiro "Matz" Matsumoto abec98c681 numeric.c: implement ceil, floor, round, truncate methods in C.
- ISO 15.2.8.3.14 Integer#ceil
- ISO 15.2.8.3.17 Integer#floor
- ISO 15.2.8.3.20 Integer#round
- ISO 15.2.8.3.26 Integer#truncate
2022-08-10 13:38:23 +09:00
Yukihiro "Matz" Matsumoto 7340ad1c8b Merge pull request #5764 from dearblue/red-protect
Check `MRB_GC_RED` with `mrb_gc_protect()`
2022-08-09 23:01:55 +09:00
Yukihiro "Matz" Matsumoto 9f7cef2d42 Merge pull request #5763 from dearblue/realloc-fullgc
Perform Full-GC from `mrb_realloc_simple()` by `MRB_GC_STRESS + MRB_DEBUG`
2022-08-09 14:00:18 +09:00
Yukihiro "Matz" Matsumoto 78a3200fa5 etc.c (mrb_obj_id): separate object_id and hash values.
It's OK for hash values to conflict. But object_id is not (in theory).
2022-08-08 23:00:13 +09:00
dearblue 520df805a9 Check MRB_GC_RED with mrb_gc_protect()
When `gc_protect()` is called from `mrb_obj_alloc()`, unnecessary overhead is eliminated.
2022-08-08 22:10:22 +09:00
dearblue 71c398f298 Perform Full-GC from mrb_realloc_simple() by MRB_GC_STRESS + MRB_DEBUG
It also fills the GC'ed object area with `0xff` for debugging purposes.
2022-08-08 21:44:11 +09:00
Yukihiro "Matz" Matsumoto f653e89227 etc.c: refactor boxing/unboxing float values. 2022-08-07 20:43:31 +09:00
Yukihiro "Matz" Matsumoto 521072ca3a mruby-struct/struct.rb: include Enumerable module.
Struct.ancestors should be [Struct, Enumerable, Object, Kernel, BasicObject]
2022-08-06 16:03:26 +09:00
Yukihiro "Matz" Matsumoto a0c02e0a64 Merge pull request #5765 from dearblue/mrb_env_unshare
Improve out-of-memory tolerance of `mrb_env_unshare()`
2022-08-06 16:03:11 +09:00
Yukihiro "Matz" Matsumoto 5eaef1cf25 mruby-time/time.c: properly generate hash from time objects. 2022-08-06 06:43:42 +09:00
Yukihiro "Matz" Matsumoto 579379c517 rational.c (rational_hash): generate hash code from rational numbers. 2022-08-06 06:43:42 +09:00
Yukihiro "Matz" Matsumoto 25f9d2f65a complex.c (complex_hash): generate hash code from complex numbers. 2022-08-06 06:43:42 +09:00
Yukihiro "Matz" Matsumoto a7c3d59971 kernel.c (mrb_obj_hash): generate hash value for big-integers. 2022-08-06 06:43:41 +09:00
Yukihiro "Matz" Matsumoto 6d683785f9 etc.c: use mrb_byte_hash instead of simple hash function. 2022-08-06 06:43:41 +09:00
Yukihiro "Matz" Matsumoto 61f447e5df string.c (mrb_byte_hash): separate byte hashing functions. 2022-08-06 06:43:41 +09:00
Yukihiro "Matz" Matsumoto 62a35e502b bigint.c: rename double sized mp_limb.
- mp_limb2 -> mp_dbl_limb
- mp_limb2s -> mp_dbl_limb_signed
2022-08-06 06:43:41 +09:00
Yukihiro "Matz" Matsumoto 1718d9bafb bigint.c: add type cast to mp_limb. 2022-08-06 06:43:40 +09:00
Yukihiro "Matz" Matsumoto b7bc326b4c bigint.c (mpz_set_int): check mp_limb overflow from mrb_int. 2022-08-06 06:43:40 +09:00
Yukihiro "Matz" Matsumoto 798a2b1888 Merge pull request #5774 from dearblue/bidx-assert
Fixed assertion in `ARGUMENT_NORMALIZE()` for `bidx`.
2022-08-06 06:43:28 +09:00
dearblue 5bc15dd69b Fixed assertion in ARGUMENT_NORMALIZE() for bidx.
It should be compared to the `irep->nregs` value as is.

At the same time, discovered problems have been fixed.
2022-08-04 22:43:06 +09:00
Yukihiro "Matz" Matsumoto 72f2ac155e Merge pull request #5772 from mruby/dependabot/github_actions/github/super-linter-4.9.6
build(deps): bump github/super-linter from 4.9.5 to 4.9.6
2022-08-04 08:18:08 +09:00
Yukihiro "Matz" Matsumoto e2decd0528 Merge pull request #5773 from jbampton/run-pre-commit
Remove whitespace
2022-08-04 08:17:26 +09:00
John Bampton 791410ba3f Remove whitespace
pre-commit run --all-files
2022-08-04 00:51:03 +10:00
dependabot[bot] cf8d1eddf6 build(deps): bump github/super-linter from 4.9.5 to 4.9.6
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.9.5 to 4.9.6.
- [Release notes](https://github.com/github/super-linter/releases)
- [Changelog](https://github.com/github/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/github/super-linter/compare/v4.9.5...v4.9.6)

---
updated-dependencies:
- dependency-name: github/super-linter
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-03 14:05:47 +00:00
Yukihiro "Matz" Matsumoto 84b53fc1ee Merge pull request #5771 from sakisakira/master
Reenabling building for Android NDK
2022-08-03 12:34:12 +09:00
SAkira a.k.a. Akira Suzuki 4610fa55b9 Enabled building for Android again with NDK 25.0. 2022-08-03 08:23:54 +09:00
Yukihiro "Matz" Matsumoto 441c6ea30d bigint.c (udiv): check out of bound memory access. 2022-08-02 13:36:36 +09:00
Yukihiro "Matz" Matsumoto 75bd101685 AUTHORS: update entries [ci skip] 2022-08-02 09:04:47 +09:00
Yukihiro "Matz" Matsumoto 90e75f983e Merge pull request #5769 from dearblue/opdef-proc
Protected `proc` objects given by `OP_DEF` on registers
2022-08-01 17:46:09 +09:00
Yukihiro "Matz" Matsumoto 51f404be33 Merge pull request #5768 from dearblue/hash-expansion
Fix property between `ar_set()` and `ht_init()`.
2022-08-01 17:37:25 +09:00
Yukihiro "Matz" Matsumoto c32a8a71e9 Merge pull request #5767 from dearblue/fiber-gc
Fix `SIGSEGV` caused by GC during fiber initialization
2022-08-01 17:17:29 +09:00
Yukihiro "Matz" Matsumoto dd00724f30 Merge pull request #5766 from dearblue/red-write-barrier
Ignore `MRB_GC_RED` objects in `mrb_field_write_barrier()`
2022-08-01 17:15:54 +09:00
Yukihiro "Matz" Matsumoto c34bb7825a mruby-time/time.c: add Time#eql? to compare. 2022-08-01 16:29:35 +09:00
Yukihiro "Matz" Matsumoto 9dfbcbae7b object.c (mrb_equal): support big-integers. 2022-08-01 16:26:02 +09:00
Yukihiro "Matz" Matsumoto 4fb018d407 object.c (mrb_equal): shortcut per object comparison.
To reduce the chance to call mrb_funcall(), which is heavy and
unfriendly to fiber context switches.
2022-08-01 16:24:48 +09:00
Yukihiro "Matz" Matsumoto 585d80e0a7 numeric.c (num_eql): move eql? definition to Numeric class.
We no longer need Float#eql? etc.
2022-08-01 16:20:35 +09:00
Yukihiro "Matz" Matsumoto 569a8910af bigint.c: check division by zero errors. 2022-08-01 13:58:05 +09:00
Yukihiro "Matz" Matsumoto b5a3fe5276 Merge pull request #5770 from dearblue/doc-1
Avoid comparing `mrb_bool` to integer values in the documentation
2022-08-01 13:57:54 +09:00
dearblue 5215b9ce8b Avoid comparing mrb_bool to integer values in the documentation 2022-07-31 20:38:31 +09:00
Yukihiro "Matz" Matsumoto 9198b9c7db Merge pull request #5760 from jbampton/fix-type-use-array
CodeQL: fix type use array
2022-07-31 08:01:59 +09:00
Yukihiro "Matz" Matsumoto d28009ebd8 mruby-print/print.rb: reduce explicit return values; ref #5762
By making __printstr__ to return nil.
2022-07-31 07:56:06 +09:00
Yukihiro "Matz" Matsumoto a8e6b840ea Merge pull request #5762 from dearblue/iso-puts
Removed unnecessary ISO section numbers for `Kernel.puts` [ci skip]
2022-07-31 07:55:46 +09:00
dearblue 2d9ecc660e Fix property between ar_set() and ht_init().
If GC occurs in `mrb_realloc()` in `ht_init()` called from `ar_set()`, the following inconsistency occurs:
- If `h_ht_on()` is called before `mrb_realloc()`, `hash->hsh.ht` is referenced instead of `hash->hsh.ea` during GC.
- If the pointer is changed by `ea_adjust()` in `ar_set()`, `hash->hsh.ea` (`hash->hsh.ht`) is referenced in GC before the change.

These modifications can be resolved by changing the order of processing.

However, if a `NoMemoryError` exception is raised, it is presumed that the size of the "AR" will be exceeded and the unintended state will continue.
To prevent this, elements should be added after they have been converted to "HT".
2022-07-30 23:20:48 +09:00
dearblue 43fdce5019 Protected proc objects given by OP_DEF on registers
If a GC occurs in `mrb_calloc()` called by `mt_rehash()` inside `mrb_define_method_raw(), the `proc` may be destroyed.
2022-07-30 22:34:50 +09:00
dearblue a82a3533e6 Fix SIGSEGV caused by GC during fiber initialization
GC may occur in the `c->stbase = mrb_malloc()` part of the `fiber_init()` function.
The `SIGSEGV` happens because it references the `c->ci->stack` field without checking `c->ci`.
This is caused by #5272.
2022-07-30 22:32:02 +09:00
dearblue 2eefee0d6a Ignore MRB_GC_RED objects in mrb_field_write_barrier() 2022-07-30 22:32:01 +09:00
dearblue be3c0e5f4f Improve out-of-memory tolerance of mrb_env_unshare()
Exception raising can now be controlled by the caller.

The main purpose on this patch is:

- Suppress exceptions from `obj_free()` in `src/gc.c` with `mrb_env_unshare()`.

- Consider the possibility that calls to `mrb_malloc()` may cause `e` objects to be subject to GC.

  When control is returned to `mrb_env_unshare()`, `struct free_obj::next` in the same offset as `struct REnv::stack` is rewritten.
  Unexpected results then occur when the object is reused.
  Also, if `mrb_heap_page` containing an `e` object is freed, it may cause `SIGSEGV` at that point.

- Protects the value of the stack on `callinfo` that just exits if GC occurs inside `mrb_env_unshare()`.

  ```ruby
  def m
    b = -> { b }
  end

  p m.call
  # => print block object, not nil
  ```

  This patch does not raise a `NoMemoryError` exception in `mrb_env_unshare()` and can detect that error.
  Thus, the problem fixed in # 3087 is not resurrected.

Also, it may seem that this patch should suppress exceptions raised by `cipop()` during `mrb_protect_error()` and `mrb_vm_exec()` unwinds.
However, `mrb_callinfo::u.env` by `CINFO_DIRECT` is not seen to be set.
So in that case `mrb_env_unshare()` is assumed to be originally exception-free.
2022-07-30 22:32:00 +09:00
Yukihiro "Matz" Matsumoto 9e38aa8948 Merge pull request #5761 from jbampton/fix-grammar
docs: fix grammar
2022-07-30 15:56:48 +09:00
dearblue 2e6d2abf09 Removed unnecessary ISO section numbers for Kernel.puts [ci skip]
The `Kernel.puts` method is defined in the `mrbgems/mruby-print/mrblib/print.rb` file.
2022-07-30 11:54:23 +09:00
Yukihiro "Matz" Matsumoto b77b8f4deb numeric.c (flo_ceil_floor): negate after converting integer to float.
Otherwise integer negate may overflow.
2022-07-30 09:08:42 +09:00
Yukihiro "Matz" Matsumoto 9d774bc011 numeric.c (flo_ceil_floor): return bigint if possible. 2022-07-30 09:08:02 +09:00
Yukihiro "Matz" Matsumoto eb392cb643 numeric.c (mrb_float_to_integer): check for RangeError.
Otherwise flo_to_i raises FloatDomainError instead.
2022-07-30 09:06:49 +09:00
Yukihiro "Matz" Matsumoto e4bcd8a96a numeric.c (mrb_float_to_integer): unify with flo_to_i(). 2022-07-30 09:05:21 +09:00
Yukihiro "Matz" Matsumoto 5af98f2088 numeric.c (flo_ceil_floor): add exact number check. 2022-07-30 09:01:24 +09:00
Yukihiro "Matz" Matsumoto aebf75fed4 bigint.c (mrb_bint_as_int): change overflow message.
From "integer too big" to "integer out of range" because the integer can
be too small if it's negative.
2022-07-30 08:58:30 +09:00
Yukihiro "Matz" Matsumoto b8d3bc0eae numeric.c: move FloatDomainError description to the sufficient place. 2022-07-30 08:46:06 +09:00
Yukihiro "Matz" Matsumoto 89b0c7d7ab complex.c (mrb_complex_to_i): return bigint if possible. 2022-07-30 08:44:15 +09:00
Yukihiro "Matz" Matsumoto 273ca4d4f6 tasks/toolchains/gcc.rake: remove -lm on Windows; #5757 2022-07-30 07:33:45 +09:00
Yukihiro "Matz" Matsumoto 6da34fa735 numeric.c (int_div): add checks for division by zero. 2022-07-29 17:48:02 +09:00
John Bampton 9521e4e974 docs: fix grammar 2022-07-29 16:30:46 +10:00
John Bampton 5cae37abe5 CodeQL: fix type use array 2022-07-29 14:44:02 +10:00
Yukihiro "Matz" Matsumoto 387f383eeb bigint.c (mrb_sizeinbase): cast to remove a signedness warning. 2022-07-29 10:26:04 +09:00
Yukihiro "Matz" Matsumoto 5df3f8221d bigint.c (lzb): check x==0 before calling clz().
In theory, we should not call lzb() with 0, and we assume checks are
done before calling it. But we got a report that we call lzb(0) in some
use-case. We could not reproduce the issue, so we add this guard.
2022-07-29 10:24:41 +09:00
Yukihiro "Matz" Matsumoto 64ea7f0930 doc/guides/link.md: fixed typo. 2022-07-29 10:24:41 +09:00
Yukihiro "Matz" Matsumoto 23cb2a73ff bigint.c (mpz_move): reduce copying of digits arrays. 2022-07-29 10:24:41 +09:00
Yukihiro "Matz" Matsumoto dcf9e32870 Merge pull request #5759 from jbampton/lint-modified-files
Super-Linter: Lint modified files only
2022-07-29 10:24:01 +09:00
John Bampton 9ddc6c1915 Super-Linter: Lint modified files only
Following the basic example shown here

https://github.com/github/super-linter#example-connecting-github-action-workflow
2022-07-29 09:19:28 +10:00
Yukihiro "Matz" Matsumoto 33b11daca7 Merge pull request #5758 from jbampton/pre-commit-autoupdate
pre-commit autoupdate
2022-07-29 07:43:59 +09:00
John Bampton 718547be2b pre-commit autoupdate
https://pre-commit.com/#pre-commit-autoupdate
2022-07-29 08:29:12 +10:00
Yukihiro "Matz" Matsumoto d0780c0525 vm.c: should cast bigint length to unsigned.
Otherwise length>127 would be considered as negative.
2022-07-28 15:21:32 +09:00
Yukihiro "Matz" Matsumoto de2ea3c389 bigint.c (udiv): avoid integer underflow. 2022-07-28 15:07:22 +09:00
Yukihiro "Matz" Matsumoto 9592b7e4ec mruby_proto_fuzzer.cpp: try to print the code before evaluating it. 2022-07-27 13:42:28 +09:00
Yukihiro "Matz" Matsumoto 4620485135 Merge pull request #5756 from mruby/dependabot/github_actions/github/super-linter-4.9.5
build(deps): bump github/super-linter from 4.9.4 to 4.9.5
2022-07-27 09:23:05 +09:00
dependabot[bot] a65f953356 build(deps): bump github/super-linter from 4.9.4 to 4.9.5
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.9.4 to 4.9.5.
- [Release notes](https://github.com/github/super-linter/releases)
- [Changelog](https://github.com/github/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/github/super-linter/compare/v4.9.4...v4.9.5)

---
updated-dependencies:
- dependency-name: github/super-linter
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-07-26 14:09:39 +00:00
Yukihiro "Matz" Matsumoto 25a32ed681 bigint.c (ulshift,urshift): check uzero before actual shifting.
Bit-shifting zero always result in zero.
2022-07-26 15:06:06 +09:00
Yukihiro "Matz" Matsumoto 97b9bfc4fa bigint.c (mpz_init_set_str): move negative trick to mrb_bint_new_str().
It used to take negative base to generate negative value. But this weird
trick is now belong to the mruby API side.
2022-07-26 15:03:52 +09:00
Yukihiro "Matz" Matsumoto c2e4b82d84 codegen.c (new_litbint): remove surrounding braces.
It was to allow local variable declarations, but now we allow
declarations in the middle.
2022-07-26 13:55:54 +09:00
Yukihiro "Matz" Matsumoto 26ce85bd5d bigint.c (ucmp): fixed error with zero length zero value.
Big integers have two kind of zero values:

- digits in `p` array are all zeros
- length `sn` is zero

The old code crashed with the latter zero.
2022-07-26 00:13:15 +09:00
Yukihiro "Matz" Matsumoto e8ce82bf31 codegen.c (new_litbint): forgot else in a107b85. 2022-07-26 00:11:53 +09:00
Yukihiro "Matz" Matsumoto 3d1b5d2b06 Merge pull request #5754 from artichoke/lopopolo/class-name-use-after-free
Fix possible use after free in `mrb_class_find_path`
2022-07-25 15:41:07 +09:00
Yukihiro "Matz" Matsumoto c6bf4eaac0 codegen.c (new_litbint): renamed from new_litbn. 2022-07-25 15:33:43 +09:00
Yukihiro "Matz" Matsumoto a107b850eb codegen.c (new_bitbn): fixed wrong packing of integer radix. 2022-07-25 15:31:43 +09:00
Yukihiro "Matz" Matsumoto d2d105b589 bigint.c (mpz_get_int): should work with zero (i.e. y->p == NULL). 2022-07-25 14:54:41 +09:00
Yukihiro "Matz" Matsumoto 6a4c8e36b5 bigint.c (udiv): should trim remainder before bit shifting. 2022-07-25 14:54:41 +09:00
Yukihiro "Matz" Matsumoto e02e9ae434 bigint.c (mpz_mmod): should call mpz_clear() for internal mpz_t. 2022-07-25 14:54:41 +09:00
Yukihiro "Matz" Matsumoto 7d5475916c bigint.c (udiv): avoid out of bound access in division. 2022-07-25 14:54:40 +09:00
Yukihiro "Matz" Matsumoto 657263446e bigint.c: cosmetic changes (add spaces, etc.) 2022-07-25 14:54:40 +09:00
Yukihiro "Matz" Matsumoto 866ab88c94 mruby-os-memsize/memsize.c: add fall through comment. 2022-07-25 10:58:03 +09:00
Yukihiro "Matz" Matsumoto 13d909bd3c array.c: new configuration MRB_ARY_LENGTH_MAX.
The default value is 2**17 entries. If you want to avoid the limitation,
set this value to 0.
2022-07-25 10:58:02 +09:00
Yukihiro "Matz" Matsumoto c4cb416460 string.c: new configuration MRB_STR_LENGTH_MAX.
The default value is 1MB. If you want to avoid the limitation, set this
value to 0.
2022-07-25 10:58:02 +09:00
Yukihiro "Matz" Matsumoto 199758c0b9 bigint.c (mpz_sizeinbase): should return size_t instead of int.
`int` may overflow.
2022-07-25 10:58:02 +09:00
Ryan Lopopolo 547d465340 Fix possible use after free in mrb_class_find_path
`mrb_class_find_path` resolves a `char*` pointer to a class name string
by calling `mrb_class_name`. It then allocates a new string with
capacity 40 to copy that `char*` into.

https://github.com/mruby/mruby/blob/e04184185ab43b94980550e850d8813a415fa438/src/variable.c#L1111-L1112

`mrb_class_name` resolves the class name via `class_name_str`, which
returns an `mrb_value` with type tag `MRB_TT_STRING` and backed by an
`RString*`. Then `mrb_class_name` extracts the `RSTRING_PTR`:

https://github.com/mruby/mruby/blob/e04184185ab43b94980550e850d8813a415fa438/src/class.c#L2133-L2134

That `RString*`-backed `mrb_value` ultimately comes from `mrb_class_path`
which resolves the string from the symbol table:

https://github.com/mruby/mruby/blob/e04184185ab43b94980550e850d8813a415fa438/src/class.c#L2111

The allocation of the target `str` after resolving the class name
`mrb_value` and extracting its pointer is fragile and assumes the
`RString*` is "static". If the `RString*` is not static, the
interleaving of extracting the `RSTRING_PTR` followed by a subsequent
allocation might result in the class name `mrb_value` being garbage
collected, which will leave the extracted pointer invalid.

Fix this bad interleaving by allocating the destination string first
before taking a raw pointer to an `RString*`.
2022-07-24 09:33:51 -07:00
Yukihiro "Matz" Matsumoto e04184185a bigint.c: heavy restructuring of big-integers.
Instead of splitting mp_limb by bit operations (using HIGH/LOW macros),
now we use mp_limb2 (which is bigger integer size, e.g uint64_t). It
makes operations (especially mulitiplication) a lot faster. As a side
effect, it also reduces memory consumption (16,452,033 -> 15,545,853 on
my Linux machine).

Other changes:

- trailing zeros are removed after operations.
- division algorithm is simplified.
2022-07-23 07:50:30 +09:00
Yukihiro "Matz" Matsumoto c0a636c007 mruby-os-memsize/memsize.c: add up digit spaces for big-integers. 2022-07-21 20:56:32 +09:00
Yukihiro "Matz" Matsumoto 8bd1c56465 bigint.c (mpz_get_str): fixed wrong loop termination condition. 2022-07-21 20:40:35 +09:00
Yukihiro "Matz" Matsumoto 450382735b bigint.c (mrb_bint_to_s): shortcut for bigint zero. 2022-07-20 14:40:45 +09:00
Yukihiro "Matz" Matsumoto a4ce63abc5 bigint.c (mpz_sizeinbase): check zero length bigint. 2022-07-20 14:40:12 +09:00
Yukihiro "Matz" Matsumoto cfea0c28a0 bigint.c (digits): check zero length bigint. 2022-07-20 14:39:05 +09:00
Yukihiro "Matz" Matsumoto 2b07489372 codegen.c: keep stack space for block argument. 2022-07-20 14:27:02 +09:00
Yukihiro "Matz" Matsumoto b84bca666f bigint.c (mpz_get_int): avoid buffer overflow. 2022-07-19 18:20:28 +09:00
Yukihiro "Matz" Matsumoto a99d003622 Merge pull request #5751 from dearblue/mrb_insn_data
Fix the first operand of `struct mrb_insn_data` to 32 bits
2022-07-19 07:44:45 +09:00
Yukihiro "Matz" Matsumoto 714e8a57af bigint.c: avoid default allocation.
The digit space would be allocated on demand.
2022-07-19 00:52:54 +09:00
Yukihiro "Matz" Matsumoto 04ec65b87a mruby-numeric-ext/numeric.rb: add reference description.
- zero?
- nonzero?
- positive?
- negative?
2022-07-18 15:46:47 +09:00
Yukihiro "Matz" Matsumoto 56af812b98 mruby-numeric-ext/numeric.rb: bit predicates are implemented in Ruby now. 2022-07-18 12:59:10 +09:00
Yukihiro "Matz" Matsumoto a3f2470907 Merge pull request #5749 from dearblue/patch-5565
Corrected the number of registers in the `Class#new` method
2022-07-18 09:26:34 +09:00
Yukihiro "Matz" Matsumoto 0e530dbb63 numeric.c: fix smallint op bigint error in bitwise logical operators. 2022-07-18 08:29:52 +09:00
dearblue 1d95dd6e9b Fix the first operand of struct mrb_insn_data to 32 bits
Because there is `W` type, at least 24 bits must be represented.
2022-07-17 20:27:42 +09:00
Yukihiro "Matz" Matsumoto 2d749f5275 mruby-compar-ext/compar.rb (clamp): update document; ref #5748 2022-07-17 18:53:55 +09:00
Yukihiro "Matz" Matsumoto 33bf027d79 mruby-compar-ext/compar.rb (clamp): support endless/beginless range.
Ref #5748
2022-07-17 18:52:59 +09:00
dearblue c621d3cb95 Corrected the number of registers in the Class#new method
`OP_SEND R4 :allocate 0` requires an an invisible `nil` block to `R5`.
If `R5` is not allocated, this can lead to unexpected results due to buffer overflow.
This problem is caused by #5565.

ref. commit 33792c2a02
2022-07-17 10:38:53 +09:00
Yukihiro "Matz" Matsumoto b1bfa1d5c8 mruby-compar-ext/compar.rb (clamp): should take ranges too; fix #5748 2022-07-17 07:49:34 +09:00
Yukihiro "Matz" Matsumoto 53f131d8f1 bigint.c: remove unnecessary break in for loop. 2022-07-16 12:26:08 +09:00
Yukihiro "Matz" Matsumoto 4f737b8afb bigint.c: adjust integer types to remove warnings. 2022-07-15 18:37:45 +09:00
Yukihiro "Matz" Matsumoto 275684cf07 bigint.c: update header commend description. 2022-07-15 18:36:47 +09:00
Yukihiro "Matz" Matsumoto 30f6ad314d bigint.c (mpz_get_str): stringify multiple digits at once.
Instead of dividing by 10, 10000 (32 bit) or 100000000 (64 bit), for
example (Karatsuba method?).
2022-07-15 13:45:17 +09:00
Yukihiro "Matz" Matsumoto d9e0f3328b bigint.c (mpz_get_str): avoid bigint division for performance. 2022-07-15 13:45:17 +09:00
Yukihiro "Matz" Matsumoto f1f8221bf3 Merge pull request #5747 from dearblue/errno-summary
Added summary for `mrbgems/mruby-errno`
2022-07-15 13:45:09 +09:00
Yukihiro "Matz" Matsumoto 1d8f4bc775 Merge pull request #5746 from dearblue/cleanup-errno
Delete unnecessary files in `mrbgems/mruby-errno`
2022-07-15 13:44:35 +09:00
Yukihiro "Matz" Matsumoto ec688b34ec Merge pull request #5745 from dearblue/neg-errno
Allow negative `errno` to be handled as well
2022-07-15 13:43:33 +09:00
Yukihiro "Matz" Matsumoto 74a3e2353b Merge pull request #5744 from dearblue/checkout-ignore
Ignore git checkout if nil commit-hash
2022-07-14 23:49:39 +09:00
dearblue b012ebfa79 Ignore git checkout if nil commit-hash
If there is no `.lock` file and no commit hash specified, avoid `git checkout --detach`.
This behavior will be the same as up to mruby-3.1.

ref. #5638
2022-07-14 21:58:20 +09:00
dearblue bd98b71668 Added summary for mrbgems/mruby-errno 2022-07-14 21:55:15 +09:00
dearblue a74b0fb62b Delete unnecessary files in mrbgems/mruby-errno
This is because it has been integrated into the mruby repository.
2022-07-14 21:53:03 +09:00
dearblue 66b72430e6 Allow negative errno to be handled as well 2022-07-14 21:49:44 +09:00
Yukihiro "Matz" Matsumoto 7733f6b246 Merge pull request #5743 from dearblue/dummy-errno
Define `Errno::EXXX` when needed
2022-07-12 18:16:28 +09:00
Yukihiro "Matz" Matsumoto 37c2f080f0 numeric.c (int_to_s): should not bypass base range check. 2022-07-12 14:48:36 +09:00
Yukihiro "Matz" Matsumoto bae11ef689 complex.c (mrb_complex_copy): allow copying of complex numbers. 2022-07-11 11:25:31 +09:00
Yukihiro "Matz" Matsumoto 67f47c9b42 rational.c (mrb_rational_copy): allow copying of rational numbers. 2022-07-11 11:19:22 +09:00
Yukihiro "Matz" Matsumoto 3ebb55b75f bigint.c (mrb_bint_copy): allow dup operation for bigints. 2022-07-11 11:02:27 +09:00
Yukihiro "Matz" Matsumoto 95610a292b bigint.c (lzb): use __builtin_clz() if available. 2022-07-11 08:01:52 +09:00
Yukihiro "Matz" Matsumoto 3046440b5a bigint.c (mpz_set_int): remove an unused local variable. 2022-07-11 08:01:18 +09:00
dearblue c14e26d79e Define Errno::EXXX when needed
If the `Errno::EXXX` class is defined minimally when needed, it will save about 17 KiB of RAM in a 32-bit environment.
Define the singular methods `.const_defined?`, `.const_missing` and `.constants` in the `Errno` module and act as if there are classes that have not yet been defined.

However, if real classes are enumerated, for example by the following code, the effect is lost.

```ruby
Errno.constants.map { |id| Errno.const_get(id) }
```

But I believe that such codes are rarely written with the intention of being written.

In this patch, the `Errno::EXXX#initialize` method is no longer defined for further memory reduction.
Instead, it has been merged into the `SystemCallError#initialize` method.
2022-07-10 20:53:55 +09:00
Yukihiro "Matz" Matsumoto 04b153a3b1 bigint.c (mpz_init_set_int): unified with mpz_set_int(). 2022-07-10 08:06:55 +09:00
Yukihiro "Matz" Matsumoto 84d73ba6e8 bigint.c: small refactoring (removing extra lines and spaces). 2022-07-09 19:33:39 +09:00
Yukihiro "Matz" Matsumoto e157a84418 bigint.c (mpz_init_set_int): should avoid integer overflow.
Check MRB_INT_MIN which could overflow by negation.
2022-07-09 17:27:27 +09:00
Yukihiro "Matz" Matsumoto 48b43af37f numeric.c (mrb_div_int_value): should support integer overflow.
Especially in `MRB_INT_MIN/-1` which is bigger than MRB_INT_MAX.
2022-07-09 15:21:45 +09:00
Yukihiro "Matz" Matsumoto fa0ff7cf86 numeric.c: better error message (Float -> Integer). 2022-07-09 15:13:52 +09:00
Yukihiro "Matz" Matsumoto 7de03cbb68 numeric.c: add mrb_noreturn qualifier to error functions.
- mrb_int_zerodiv()
- mrb_int_overflow()
2022-07-09 15:12:37 +09:00
Yukihiro "Matz" Matsumoto e1980d7596 numeric.c (mrb_div_int): separate the function in two.
- mrb_div_int() does integer division in Ruby way (mdiv)
  returns mrb_int
- mrb_div_int_value() division with zero div and overflow checks.
  returns mrb_value
2022-07-09 14:38:18 +09:00
Yukihiro "Matz" Matsumoto f1275803c9 bigint.c (mpz_set): simplify memory reallocation code. 2022-07-09 14:36:17 +09:00
Yukihiro "Matz" Matsumoto a40842eb73 bigint.c (udiv): use (signed) int for loop counters.
Sometimes (xd-yd) may be negative and should be checked.
2022-07-09 10:56:02 +09:00
Yukihiro "Matz" Matsumoto a64d2bfbe6 bigint.c (mpz_mul,mpz_mdiv): return early on zero. 2022-07-09 10:47:23 +09:00
Yukihiro "Matz" Matsumoto a2f0fd81e6 numeric.c (mrb_int_mul): fix error message (Float -> Integer). 2022-07-09 10:45:44 +09:00
Yukihiro "Matz" Matsumoto 8d34981530 numeric.c: avoid mathematical operations for simple cases. 2022-07-09 10:45:11 +09:00
Yukihiro "Matz" Matsumoto 960021e519 numeric.c (cmpnum): call mrb_bigint_cmp() if v1 is bigint, not v2. 2022-07-08 21:57:05 +09:00
Yukihiro "Matz" Matsumoto 872020bb3d math.gembox: add cmath and bigint to math gembox; ref #5742 2022-07-07 15:39:36 +09:00
Yukihiro "Matz" Matsumoto b5538eded1 vm.c (OP_ENTER): need to protect kdict from GC; ref #5741 2022-07-06 14:57:06 +09:00
Yukihiro "Matz" Matsumoto 8fed80f5eb vm.c (OP_ENTER): protect kdict from GC; ref #5741 2022-07-06 14:29:14 +09:00
Yukihiro "Matz" Matsumoto 4225ae4176 vm.c (OP_ENTER): need to update ci->nk when kd is set; fix #5741 2022-07-06 13:57:12 +09:00
Yukihiro "Matz" Matsumoto 7e8a4212fb vm.c: refactor OP_ENTER code; ref #5741 2022-07-06 13:37:29 +09:00
Yukihiro "Matz" Matsumoto 82a419cde3 vm.c (mrb_ci_kdict): should return -1 when no kargs given; ref #5741 2022-07-06 13:37:20 +09:00
Yukihiro "Matz" Matsumoto 638356af03 class.c (mc_clear_by_id): clear method cache with method id specified. 2022-07-05 17:39:36 +09:00
Yukihiro "Matz" Matsumoto a99e4a926d class.c (mrb_mc_clear_by_class): simplify method cache clear condition. 2022-07-05 17:39:30 +09:00
Yukihiro "Matz" Matsumoto 1e7012f8c1 class.c (mrb_class_inherited): no need to clear method cache.
Since the function is only called for a newly created class, there is no
need to modify the method cache here.
2022-07-04 21:47:19 +09:00
Yukihiro "Matz" Matsumoto e8a202d461 vm.c: inline callinfo related functions. 2022-07-04 21:15:42 +09:00
Yukihiro "Matz" Matsumoto 78e723accb AUTHORS: update entries [ci skip] 2022-07-03 18:17:29 +09:00
Yukihiro "Matz" Matsumoto ce89ab8660 parse.y: class cannot be followed by modifier if. [ruby-bugs:18884] 2022-07-02 10:31:33 +09:00
Yukihiro "Matz" Matsumoto 0db9a8e8d7 Merge pull request #5740 from dearblue/src-include
Avoid adding `MRUBY_ROOT/src` to `cc.include_paths`
2022-07-02 10:31:14 +09:00
dearblue 9a84ef926b Avoid adding MRUBY_ROOT/src to cc.include_paths 2022-07-02 09:56:13 +09:00
Yukihiro "Matz" Matsumoto 03ae46e88d string.c: keep values in local variables to reduce member access. 2022-06-30 10:12:24 +09:00
Yukihiro "Matz" Matsumoto f2bc7c305a array.c (mrb_assoc_new): keep pointer in a local variable.
The optimizer may do the same, but tried to make it clear.
2022-06-30 10:09:34 +09:00
Yukihiro "Matz" Matsumoto e2c4a8cef0 array.c (ary_check_too_big): make the function inline. 2022-06-30 09:57:30 +09:00
Yukihiro "Matz" Matsumoto 72b60eb449 include/mruby/value.h: remove assertion from mrb_obj_value()
The function was called too often, so that even slightest assertion may
bother performance. The function is stable enough.
2022-06-30 08:11:36 +09:00
Yukihiro "Matz" Matsumoto b58094c881 mruby-sprintf/sprintf.c: call mrb_str_resize() less often. 2022-06-29 15:03:41 +09:00
Yukihiro "Matz" Matsumoto 580af1cf73 vm.c (mrb_bidx): avoid repeated packing/unpacking argument info. 2022-06-29 07:51:08 +09:00
Yukihiro "Matz" Matsumoto f7c2b0388a benchmark/bm_so_lists.rb: address the broken link; close #5737
The original page was lost, so we added the link to the wayback machine.
2022-06-28 11:31:16 +09:00
Yukihiro "Matz" Matsumoto 0b7822581f string.c (str_rindex): use more local variables; ref #5734 2022-06-27 19:04:36 +09:00
Yukihiro "Matz" Matsumoto 7319e744ad src/vm.c: move some inline functions from mruby/proc.h; ref #5732
Those functions are seldom called so no need to be inline functions.
2022-06-27 19:04:35 +09:00
Yukihiro "Matz" Matsumoto e5ec9a18fe Merge pull request #5738 from jbampton/fix-case-of-mruby
Fix case of `mruby`
2022-06-27 18:56:56 +09:00
John Bampton 48f03dceeb Fix case of mruby 2022-06-27 18:58:31 +10:00
Yukihiro "Matz" Matsumoto 1d87493803 Merge pull request #5736 from jbampton/update-docs
docs: add link and fix command
2022-06-27 16:53:08 +09:00
John Bampton 8f16c1d99e docs: add link and fix command 2022-06-27 15:30:17 +10:00
Yukihiro "Matz" Matsumoto f080005720 Merge pull request #5735 from jbampton/pre-commit-skip-docs
Add docs on the `SKIP` pre-commit environment variable
2022-06-27 13:18:43 +09:00
John Bampton 9841980bce Add docs on the SKIP pre-commit environment variable
Knowing about `SKIP` is useful

https://pre-commit.com/#temporarily-disabling-hook
2022-06-27 14:01:14 +10:00
Yukihiro "Matz" Matsumoto dc8da16b6b Merge pull request #5734 from sjothen/master
Fix out of bounds access by memcmp in String#rindex
2022-06-27 10:34:07 +09:00
Stephen Jothen 103f8bcad0 Fix out of bounds access by memcmp in String#rindex 2022-06-25 15:09:35 +02:00
Yukihiro "Matz" Matsumoto a3ccda657e Merge pull request #5733 from dearblue/patch-5402
Do not expand "included class" in `mrb_proc_new()`.
2022-06-25 14:48:02 +09:00
Yukihiro "Matz" Matsumoto d3e8494f8d Merge pull request #5732 from dearblue/patch-5272
Fixes `mrb_vm_ci_target_class_set()`
2022-06-25 12:24:33 +09:00
Yukihiro "Matz" Matsumoto 0caaf4da7f Merge pull request #5731 from dearblue/fix5725
Use `mrb->object_class` instead if `MRB_PROC_TARGET_CLASS()` is `NULL`
2022-06-25 12:23:34 +09:00
dearblue 8bab20ef7c Do not expand "included class" in mrb_proc_new().
If `target_class->tt` is `MRB_TT_ICLASS`, it may cause loss of class inheritance relationships.
This problem is caused by #5402.

ref. #5725
2022-06-25 11:45:18 +09:00
dearblue 109da08d8a Fixes mrb_vm_ci_target_class_set()
If `ci->u.target_class` was `NULL`, the value of the argument was always ignored.
This problem is caused by #5272.

ref. #5725
2022-06-25 11:41:55 +09:00
dearblue 1489338145 Use mrb->object_class instead if MRB_PROC_TARGET_CLASS() is NULL
Fix #5725
2022-06-25 11:10:39 +09:00
Yukihiro "Matz" Matsumoto ab3486d9ff Merge pull request #5730 from aoki1980taichi/patch-1
delete unused variable
2022-06-25 07:37:24 +09:00
aoki1980taichi ad1d35c342 delete unused variable
cnt is unused
2022-06-25 00:21:23 +09:00
Yukihiro "Matz" Matsumoto 88f3c19e5d Merge pull request #5729 from aoki1980taichi/patch-1
delete unnecessary code
2022-06-24 22:58:53 +09:00
aoki1980taichi 4332f56056 delete unnecessary code
"else 0.0" is not used
2022-06-24 19:22:28 +09:00
Yukihiro "Matz" Matsumoto d4d902b072 Merge pull request #5728 from artichoke/lopopolo/broken-extern-c-blocks-mrb-use-cxx-exception
Fix mismatched braces in `extern "C"` blocks when compiling as C++
2022-06-24 17:14:03 +09:00
Ryan Lopopolo 8a5e6f47f2 Match #if at end of vm.c 2022-06-23 22:25:15 -07:00
Ryan Lopopolo 3af82fbb51 Respect MRB_USE_CXX_ABI #define 2022-06-23 21:54:53 -07:00
Ryan Lopopolo c4c37b2069 Fix mismatched braces in extern "C" blocks when compiling as C++
When compiling mruby with `-DMRB_USE_CXX_EXCEPTION`, clang fails to
compile and emits these warnings:

    vendor/mruby/src/vm.c:3066:1: error: extraneous closing brace ('}')
    } /* end of extern "C" */
    ^
    vendor/mruby/src/vm.c:3072:7: error: expected '}'
    #endif
          ^
    vendor/mruby/src/vm.c:3070:12: note: to match this '{'
    extern "C" {
               ^
    2 errors generated.

Fixup the implementation of the `extern "C"` block in `vm.c`.
2022-06-23 21:38:55 -07:00
Yukihiro "Matz" Matsumoto 16cc6f3292 build_config/host-debug.rb: enable MRB_UTF8_STRING; ref #5727 2022-06-24 13:25:46 +09:00
Yukihiro "Matz" Matsumoto 89f22158d3 string.rb (each_line): may truncate string by mistake; fix #5727 2022-06-24 13:25:45 +09:00
Yukihiro "Matz" Matsumoto 22d0f4580e Merge pull request #5726 from aoki1980taichi/patch-1
fix typo otherBasis -> orthoBasis
2022-06-24 06:29:15 +09:00
aoki1980taichi ad8286c447 fix typo otherBasis -> orthoBasis
The original function name in ao.c was orthoBasis.
I guess the function is generating orthonormal basis (https://en.wikipedia.org/wiki/Orthonormal_basis).
2022-06-24 06:26:58 +09:00
Yukihiro "Matz" Matsumoto 92be161b1f vm.c (check_target_class): return Object class if target is NULL.
Since #5272 target_class kept in a Proc may be NULL. It crashes
`iij/mruby-require` gem for example; close #5725
2022-06-23 07:54:04 +09:00
Yukihiro "Matz" Matsumoto cd6e94c09f mruby/internal.h: move functions from internal.h; #5725
To compile `iij/mruby-require` gem.
2022-06-23 07:53:29 +09:00
Yukihiro "Matz" Matsumoto 01392e2719 mrblib/array.rb: add call-seq to each method description. [ci skip] 2022-06-22 19:02:54 +09:00
Yukihiro "Matz" Matsumoto 981740b1f2 mrblib/compar.rb: add call-seq to each method description. [ci skip] 2022-06-22 19:02:48 +09:00
Yukihiro "Matz" Matsumoto cf7aa74f7c mruby-rational/rational.c: update error message. 2022-06-21 22:17:17 +09:00
Yukihiro "Matz" Matsumoto 019a2ddff4 mruby-rational/rational.c: implement Rational#**; close #5724 2022-06-21 16:53:17 +09:00
Yukihiro "Matz" Matsumoto 04de280997 mruby-rational/rational.c: wrap prototype with mrb_float
When `MRB_NO_FLOAT` is defined, `mrb_float` is not defined.
2022-06-21 16:37:32 +09:00
Yukihiro "Matz" Matsumoto 6f78cd6c99 mruby-rational/rational.c: remove unused prototype [ci skip] 2022-06-21 14:01:38 +09:00
Yukihiro "Matz" Matsumoto 9a34bd9971 hash.rb: update Hash class documents [ci skip] 2022-06-20 12:19:54 +09:00
Yukihiro "Matz" Matsumoto d2a24a540c hash.c: implement typical part of merge in C. 2022-06-19 22:28:31 +09:00
Yukihiro "Matz" Matsumoto 909e1044ed mruby-hash-ext/hash.rb (merge!): takes multiple arguments. 2022-06-18 16:12:14 +09:00
Yukihiro "Matz" Matsumoto 0565bbf85a test/hash.rb: test Hash#merge that takes multiple arguments. 2022-06-18 08:30:26 +09:00
Yukihiro "Matz" Matsumoto 14e5c0c7b9 hash.rb (merge): now takes multiple arguments. 2022-06-18 08:25:11 +09:00
Yukihiro "Matz" Matsumoto 7dec6e776e mruby-random/random.c: pointer to uint32_t cast may fail with clang. 2022-06-17 10:06:07 +09:00
Yukihiro "Matz" Matsumoto f1d669024a mruby-random/random.c: srand to use pointer address as a seed.
Utilize process randomiser which may not be provided by non Linux OSes.
With those OSes, rand() would return same values if the processes are
invoked within a second.
2022-06-17 07:14:29 +09:00
Yukihiro "Matz" Matsumoto 267c26d20b mruby-random/random.c: randomize Random::DEFAULT.
Using time(2) and randomized pointer address. May not work well with old
OSes without process randomiser.
2022-06-17 07:12:12 +09:00
Yukihiro "Matz" Matsumoto 0a63cdd594 mruby-random/random.c: use random: keyword argument.
For Array#sample and Array#shuffle. They used to take optional ordinal
argument for Random object but CRuby uses `random:` keyword argument.
Now mruby is compatible with CRuby here.
2022-06-16 11:17:22 +09:00
Yukihiro "Matz" Matsumoto 7005f8661b parse.y (paser_pfree): recycle memory if possible. 2022-06-15 07:28:05 +09:00
Yukihiro "Matz" Matsumoto 65ff04b20d Merge pull request #5722 from dearblue/gc_protect
Fixed possible inconsistency in `gc_protect()`
2022-06-15 07:27:36 +09:00
dearblue cbeb392d7d Fixed possible inconsistency in gc_protect()
If `mrb_realloc()` raises an out-of-memory exception, `arena_capa` will hold the wrong value.
2022-06-14 22:31:45 +09:00
Yukihiro "Matz" Matsumoto 561dffcccc parse.y: fix nested here-document bug; fix #5607
- remove `lex_strterm_before_heredoc` that does not nest
- remove `all_heredocs` that cannot distinguish nested and followed
  here-doc
- replace `lex_strterm` represented by cons list by C struct
- push/pop `lex_strterm` before/after interpolation
2022-06-13 22:25:37 +09:00
Yukihiro "Matz" Matsumoto 3cab2e7b78 mruby-compiler: remove spaces before * in type casting. 2022-06-13 17:00:30 +09:00
Yukihiro "Matz" Matsumoto 4d70d17af7 compile.h: reorder parser_heredoc_info members to reduce alignment gap. 2022-06-12 18:48:34 +09:00
Yukihiro "Matz" Matsumoto c41f24216b Merge pull request #5718 from dearblue/rehash-iv_mt
Asigns table properties after `mrb_calloc()`
2022-06-10 10:44:14 +09:00
dearblue 56c6dde9c5 Asigns table properties after mrb_calloc()
If GC occurs in `mrb_calloc()` called by `iv_rehash()` or `mt_rehash()`, the object as table data may be destroyed.
2022-06-08 22:10:58 +09:00
Yukihiro "Matz" Matsumoto b1f6c856e3 parse.y (nextc0): small refactoring. 2022-06-08 21:59:51 +09:00
Yukihiro "Matz" Matsumoto 0d2c550f0f parse.y: use info as abbreviation for information.
Replace `inf` that looks like abbreviation for `infinity`.
2022-06-07 18:42:53 +09:00
Yukihiro "Matz" Matsumoto 62fc021f5a .git-blame-ignore-revs: add 650ffb9 to ignore indentation fix. 2022-06-06 08:00:43 +09:00
Yukihiro "Matz" Matsumoto 9cc9c9fe63 parse.y (heredoc_treat_nextline): simplify the logic using append(). 2022-06-06 08:00:04 +09:00
Yukihiro "Matz" Matsumoto 4c92636684 AUTHORS: update entries [ci skip] 2022-06-06 08:00:04 +09:00
Yukihiro "Matz" Matsumoto 81fb3c5a4b parse.y: need to update p->lex_strterm in heredoc_treat_nextline(). 2022-06-06 08:00:03 +09:00
Yukihiro "Matz" Matsumoto 5233865c47 codegen.c (search_upvar): update messages for anonymous parameters. 2022-06-03 13:00:13 +09:00
Yukihiro "Matz" Matsumoto aec849888e parse.y (new_kw_rest_args): aggregate integer to node* type casts. 2022-06-03 13:00:12 +09:00
Yukihiro "Matz" Matsumoto e49ae398bd Rakefile: add install target; close #5712
This change is not complete. Contribution is welcome.

- need to update `mruby-config` to refer installed path
- may need to support installing shared library
- need to support cross-compiled binaries
2022-06-03 13:00:12 +09:00
Yukihiro "Matz" Matsumoto 5cbce646b0 parse.y: allow anonymous rest (and keyword rest) arguments. 2022-06-03 13:00:12 +09:00
Yukihiro "Matz" Matsumoto 6649b353c9 Merge pull request #5716 from dearblue/__method__check
Check `NULL` for `proc` and `env` in `Kernel#__method__`
2022-05-31 11:23:23 +09:00
Yukihiro "Matz" Matsumoto 0d828fa918 Merge pull request #5717 from mruby/dependabot/github_actions/github/super-linter-4.9.4
build(deps): bump github/super-linter from 4.9.3 to 4.9.4
2022-05-31 11:23:00 +09:00
dependabot[bot] 0f88b74f2b build(deps): bump github/super-linter from 4.9.3 to 4.9.4
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.9.3 to 4.9.4.
- [Release notes](https://github.com/github/super-linter/releases)
- [Changelog](https://github.com/github/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/github/super-linter/compare/v4.9.3...v4.9.4)

---
updated-dependencies:
- dependency-name: github/super-linter
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-30 14:07:39 +00:00
Yukihiro "Matz" Matsumoto 8981b2fb28 vm.c (ary_new_from_regs): stack may be reallocated.
Unlike `hash_new_from_regs`, `ary_new_from_regs` do not call
`mrb_funcall` et al directly or indirectly. But since it may invoke the
garbage collection, and hooks for GC may call `mrb_funcall` etc (although
calling them is not encouraged), we care stack reallocation just for the
safety.
2022-05-30 11:52:12 +09:00
Yukihiro "Matz" Matsumoto aa7f98dedb vm.c (hash_new_from_regs): stack may be reallocated. 2022-05-30 01:18:15 +09:00
Yukihiro "Matz" Matsumoto af5acf3566 parse.y: fix wrong indent [ci skip]. 2022-05-30 01:16:47 +09:00
Yukihiro "Matz" Matsumoto d55a152b3d mruby-string-ext/string.c (utf8code): max length of UTF-8 is 4 bytes.
It used to be 6 bytes in RFC2279 but overridden by new RFC3629.
2022-05-29 22:19:00 +09:00
Yukihiro "Matz" Matsumoto 82b87be4df string.c (mrb_utf8len): retry 7cdef2b0.
C++ requires `extern` declaration before variable definition.
2022-05-29 22:18:59 +09:00
Yukihiro "Matz" Matsumoto 0a8bfd1f8b Merge pull request #5713 from dearblue/assert-object-size
Introduced `mrb_static_assert_object_size()`
2022-05-29 22:18:48 +09:00
dearblue 444fbd76c2 Check NULL for proc and env in Kernel#__method__
Fix #5714
2022-05-29 11:28:54 +09:00
dearblue 23611332d9 Introduced mrb_static_assert_object_size()
Asserts the size of the object structure is less than or equal to 6 words.
2022-05-28 11:08:27 +09:00
Yukihiro "Matz" Matsumoto 2e0d371ef1 Merge pull request #5711 from mruby/dependabot/github_actions/github/super-linter-4.9.3
build(deps): bump github/super-linter from 4.9.2 to 4.9.3
2022-05-26 08:03:30 +09:00
dependabot[bot] 0efe2e6514 build(deps): bump github/super-linter from 4.9.2 to 4.9.3
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.9.2 to 4.9.3.
- [Release notes](https://github.com/github/super-linter/releases)
- [Changelog](https://github.com/github/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/github/super-linter/compare/v4.9.2...v4.9.3)

---
updated-dependencies:
- dependency-name: github/super-linter
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-25 14:08:32 +00:00
Yukihiro "Matz" Matsumoto 82f0ba14a9 Revert "string.c: share UTF-8 length table with mruby-string-ext."
This reverts commit 7cdef2b03e.
This sharing does not with C++ compilers.
2022-05-25 16:07:52 +09:00
Yukihiro "Matz" Matsumoto 7cdef2b03e string.c: share UTF-8 length table with mruby-string-ext. 2022-05-25 11:25:43 +09:00
Yukihiro "Matz" Matsumoto be0b5f8cee mruby-string-ext/string.c: reduce UTF-8 table size. 2022-05-25 11:22:28 +09:00
Yukihiro "Matz" Matsumoto 2f4695b759 mruby-string-ext/string.c: check sequence length before decoding. 2022-05-25 11:20:29 +09:00
Yukihiro "Matz" Matsumoto f08e66e53e mruby-string-ext/string.c (mrb_str_ord): fail with invalid UTF-8. 2022-05-25 11:17:49 +09:00
Yukihiro "Matz" Matsumoto bb99d7b2ca string.c (mrb_utf8len): reduce UTF-8 table size. 2022-05-25 08:04:19 +09:00
Yukihiro "Matz" Matsumoto d7731a95ab string.c (mrb_str_rindex_m): avoid RSTRING_CHAR_LEN() if possible.
Since it scans the string. Use char_backtrack() instead for negative
offset (counting from the tail).
2022-05-24 08:47:07 +09:00
Yukihiro "Matz" Matsumoto 9475521fa3 string.c (char_adjust): simplify and unroll function. 2022-05-23 23:12:40 +09:00
Yukihiro "Matz" Matsumoto 4769ace7e1 string.c (char_backtrack): simplify the code using utf8_islead(). 2022-05-23 23:12:40 +09:00
Yukihiro "Matz" Matsumoto 916fd642fa string.c (mrb_utf8len): unroll a for loop. 2022-05-21 16:14:16 +09:00
Yukihiro "Matz" Matsumoto 54bbc062fb string.c (index,rindex) use single byte version for ASCII strings. 2022-05-21 08:51:11 +09:00
Yukihiro "Matz" Matsumoto ac79849fde mruby-io/io.c: refactor readable/writable checks for fptr. 2022-05-20 09:59:23 +09:00
Yukihiro "Matz" Matsumoto 013c9f31bc mruby-io/io.c: remove unnecessary type casts. 2022-05-20 09:53:12 +09:00
Yukihiro "Matz" Matsumoto 038aa6beb2 strinc.rb (sub, gsub): use byte index instead of char index. 2022-05-19 10:14:59 +09:00
Yukihiro "Matz" Matsumoto ce141b1332 string.rb (each_line): should not use [] reference.
Use `byteslice` instead.
2022-05-19 10:14:59 +09:00
Yukihiro "Matz" Matsumoto 19e4287d8b Merge pull request #5710 from suetanvil-misc/project-gemdecl-path-arg-flat
Fix `conf.gem path:` build_config argument.
2022-05-19 10:07:07 +09:00
Chris Reuter b297809b51 Fix conf.gem path: build_config argument.
The mrbgem guide (`doc/guides/mrbgems.md`) documents the `path:`
argument for `conf.gem` as being used to point to the root directory
of a gem when that gem is retrieved via git but is located in a
subdirectory of the checkout.

The actual code does not do this.  Instead, it treats path as (mostly)
identical to the `gemdir:` argument; that is, it points to a local
directory containing the gem.

This change fixes this by making `path:` behave as documented.
2022-05-18 14:02:47 -04:00
Yukihiro "Matz" Matsumoto 2cd966abc7 Merge pull request #5708 from jbampton/fix-spelling
Fix spelling
2022-05-18 07:50:00 +09:00
John Bampton 73580c49c4 Fix spelling 2022-05-17 19:47:54 +10:00
Yukihiro "Matz" Matsumoto f8b9464118 string.rb (each_line): use byteindex for performance; fix #4522
Character-wise String#index method calculate UTF-8 character width
numerous times if the string is long.
2022-05-17 07:18:44 +09:00
Yukihiro "Matz" Matsumoto 960da4ded4 cdump.c: should dump zero symbol (skip) too.
Zero symbol in the symbol table now means anonymous arguments.
2022-05-16 16:39:56 +09:00
Yukihiro "Matz" Matsumoto c2648ad95d string.c: add byteindex and byterindex methods. 2022-05-16 16:00:00 +09:00
Yukihiro "Matz" Matsumoto 8c985ff851 string.c (mrb_str_index_m): no need to align the position; ref #4569 2022-05-16 14:17:21 +09:00
Yukihiro "Matz" Matsumoto 0299ccf6c7 parse.y: allow inner anonymous block argument. 2022-05-16 14:17:21 +09:00
Yukihiro "Matz" Matsumoto 0a52f171aa mruby-random/random.c: factored out Random argument retrieval. 2022-05-16 14:17:20 +09:00
Yukihiro "Matz" Matsumoto 4283e2a950 Merge pull request #5707 from mruby/stable
Merge mruby 3.1.0
2022-05-13 07:38:26 +09:00
mimaki b3c04d036e Merge master branch. 2022-05-12 19:59:10 +09:00
Yukihiro "Matz" Matsumoto 6c6d8a98fa codedump.c: avoid printing 'local variable names:' header.
If there is no local variable defined in `irep`.
2022-05-12 19:14:40 +09:00
mimaki 1bec339230 Update version and release date. (mruby 3.1.0 (2022-05-12)) 2022-05-12 12:19:10 +09:00
Yukihiro "Matz" Matsumoto 257d16181d mruby3.2.md: add fixed CVE list. 2022-05-11 07:09:27 +09:00
Yukihiro "Matz" Matsumoto 090303568c mruby3.2.md: use dash instead of asterisk for itemize. 2022-05-11 07:08:39 +09:00
Yukihiro "Matz" Matsumoto 3ee10ccc63 mruby3.1.md: update fixed CVE list. 2022-05-11 07:06:36 +09:00
Yukihiro "Matz" Matsumoto 242a7f14e0 mruby3.1.md: update fixed CVE list. 2022-05-10 20:32:04 +09:00
Yukihiro "Matz" Matsumoto f13db72d26 load.c: add data boundary check for broken compiled binary. 2022-05-10 20:11:17 +09:00
Yukihiro "Matz" Matsumoto b82065aa92 load.c: should check if length of irep sections are valid. 2022-05-10 20:11:17 +09:00
Yukihiro "Matz" Matsumoto 11679e3f3a vm.c: check if target_class is NULL (when prepended).
Address CVE-2022-1427
2022-05-10 20:11:17 +09:00
Yukihiro "Matz" Matsumoto 82d3b3d11b vm.c: target class may be NULL.
Address CVE-2022-1201
2022-05-10 20:11:17 +09:00
Yukihiro "Matz" Matsumoto 2cbfc2f350 vm.c: vm.c: stack may be reallocated in functions calls; aaa28a5
`mrb_range_new()` also calls VM recursively.

Address CVE-2022-1106
2022-05-10 20:11:16 +09:00
Yukihiro "Matz" Matsumoto 6db4a58fbd vm.c: stack may be reallocated in functions calls.
Probably due to recursive VM calls via `mrb_funcall()`.

Address CVE-2022-1071
2022-05-10 19:24:46 +09:00
Yukihiro "Matz" Matsumoto 96cfde3488 fiber.c: should pack 15+ arguments in an array.
Address CVE-2022-0890
2022-05-10 19:24:46 +09:00
Yukihiro "Matz" Matsumoto 2e48070ab6 codegen.c: adjust stack position for OP_SUPER instruction.
Address CVE-2022-0632
2022-05-10 16:34:19 +09:00
Yukihiro "Matz" Matsumoto d823045af4 vm.c: packed arguments length may be zero for send method.
Address CVE-2022-0631
2022-05-10 16:32:03 +09:00
Yukihiro "Matz" Matsumoto c9ab1e601d codegen.c: fixed a bug in hash code generation with !val.
Address CVE-2022-0481
2022-05-10 14:56:53 +09:00
Yukihiro "Matz" Matsumoto beef5d37ad codegen.c: no OP_HASHADD required when val is false.
Address CVE-2022-0326
2022-05-10 14:55:58 +09:00
Yukihiro "Matz" Matsumoto 15f597e835 class.c: add obj->c check before prepare_singleton_class().
Address CVE-2022-0240
2022-05-10 14:54:45 +09:00
Yukihiro "Matz" Matsumoto 6189a90933 github/workflow: remove Cygwin build from Github Actions.
It often cross the 15 minutes timeout limit, so we just give up for now.
2022-05-10 14:02:16 +09:00
Yukihiro "Matz" Matsumoto fc4e9cdf81 mruby-test-inline-struct/inline.c: add type cast from void* to char*. 2022-05-09 18:57:26 +09:00
Yukihiro "Matz" Matsumoto eafc4b3f96 doc/mruby3.1.md: update for the 3.1 release. 2022-05-09 17:49:53 +09:00
Yukihiro "Matz" Matsumoto 84b0ba3f8d doc/mruby3.1.md: update for the release. 2022-05-09 17:46:26 +09:00
Yukihiro "Matz" Matsumoto 04d160f90b mruby-test-inline-struct/inline.c: add a comment about istruct protection. 2022-05-08 23:14:20 +09:00
Yukihiro "Matz" Matsumoto 8c2dbb761f mruby-test-inline-struct/inline.c: add mrb_istruct_p() checks. 2022-05-08 23:09:14 +09:00
Yukihiro "Matz" Matsumoto 45f61e3879 class.c (mrb_get_args): remove I specifier (istruct); close #5706 2022-05-07 17:35:45 +09:00
Yukihiro "Matz" Matsumoto 457abf4c9e error.c: now mrb_exc_mesg_get() returns a string or nil. 2022-05-06 16:45:17 +09:00
Yukihiro "Matz" Matsumoto 38b69b6014 error.c: protect mrb_print_error() from exceptions.
Now the function can be called when `mrb->jmp` is not set.
2022-05-06 16:26:31 +09:00
Yukihiro "Matz" Matsumoto c3e4ee0bf2 error.c: store error message converted as a string.
This is controversial since this change alters the `raise` behavior.
Previously, when an object that cannot be converted to a string, it just
ignore message when it's printed (using `Exception#inspect`). But after
this change, `raise` (more precisly `Exception.new`) raises TypeError
exception. I think the new behavior is clearer, more intuitive.
2022-05-06 16:21:39 +09:00
Yukihiro "Matz" Matsumoto d40822b148 Merge pull request #5705 from dearblue/adjust-stack
Introduce `mrb_stack_extend_adjust()`
2022-05-05 13:04:44 +09:00
dearblue c32cac6e59 Introduce mrb_stack_extend_adjust()
If necessary, adjust the pointer on the VM stack after `mrb_stack_extend()`.
2022-05-04 09:13:56 +09:00
Yukihiro "Matz" Matsumoto 50b1ded350 mruby-random/random.c: use rand_i() extensively. 2022-05-04 08:07:02 +09:00
Yukihiro "Matz" Matsumoto 49b8cef31f Merge pull request #5703 from dearblue/random-getargs
Strict acquisition of the `Random` class given by `mrb_get_args()`
2022-05-03 19:27:11 +09:00
dearblue 9b9424fe32 Strict acquisition of the Random class given by mrb_get_args()
This is to prevent data corruption of the substituted `Random` instance.
If the `Object::Random` constants are redefined to a different `MRB_TT_ISTRUCT` object class, they can pass `mrb_get_args()` validation.

The following is an example of how the `Array#shuffle` method rewrites the data of a non `Random` instance.

```c
// code.c

#include <mruby.h>
#include <mruby/class.h>
#include <mruby/compile.h>
#include <mruby/istruct.h>

#define EVAL_LIT(MRB, ...) mrb_load_string((MRB), #__VA_ARGS__)

static mrb_value
fake_initialize(mrb_state *mrb, mrb_value self)
{
  char *p = ISTRUCT_PTR(self);

  for (int i = 0; i < ISTRUCT_DATA_SIZE; i++) {
    p[i] = 'A' + i;
  }

  return self;
}

static mrb_value
fake_to_bytes(mrb_state *mrb, mrb_value self)
{
  const char *p = ISTRUCT_PTR(self);
  return mrb_str_new(mrb, p, ISTRUCT_DATA_SIZE);
}

int
main(int argc, char *argv[])
{
  mrb_state *mrb = mrb_open();

  struct RClass *fake = mrb_define_class(mrb, "Fake", mrb->object_class);
  MRB_SET_INSTANCE_TT(fake, MRB_TT_ISTRUCT);
  mrb_define_method(mrb, fake, "initialize", fake_initialize, MRB_ARGS_NONE());
  mrb_define_method(mrb, fake, "to_bytes", fake_to_bytes, MRB_ARGS_NONE());

  EVAL_LIT(mrb,
    Random = Fake \n
    fake = Fake.new \n
    p [fake, fake.to_bytes] \n
    p a = (1..10).to_a \n
    p a.shuffle(fake) \n
    p [fake, fake.to_bytes]
  );

  mrb_close(mrb);

  return 0;
}
```

```console
% `bin/mruby-config --cc --cflags --ldflags` code.c `bin/mruby-config --libs`
% ./a.out
[#<Fake:0x8007d8f20>, "ABCDEFGHIJKLMNOPQRSTUVWX"]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
[1, 7, 8, 10, 2, 6, 9, 3, 4, 5]
[#<Fake:0x8007d8f20>, "\xe81{\v\fM\xb0D<\x99\xb1V+l\x84\x86QRSTUVWX"]
```
2022-05-03 13:35:29 +09:00
Yukihiro "Matz" Matsumoto 23ce122fc2 vm.c (mrb_funcall_with_block): copy argv before prepare_missing(); fix #5704
Since prepare_missing() may call `missing` method internally.
2022-05-02 18:59:38 +09:00
Yukihiro "Matz" Matsumoto 651c872a71 Merge branch 'dearblue-exception' 2022-05-01 20:01:04 +09:00
Yukihiro "Matz" Matsumoto 06c4c76be8 Merge branch 'exception' of https://github.com/dearblue/mruby into dearblue-exception 2022-05-01 20:00:37 +09:00
Yukihiro "Matz" Matsumoto a243cf4d68 codedump.c: adjust integer size.
* uint32_t and ptrdiff_t
* uint16_t and uint8_t
2022-04-30 16:51:38 +09:00
Yukihiro "Matz" Matsumoto 49f3a028d1 AUTHORS: update entries [ci skip] 2022-04-29 16:52:34 +09:00
Yukihiro "Matz" Matsumoto 32fb8b19aa class.c: fix integer size mixtures (int, mrb_ssize and mrb_int). 2022-04-28 14:22:11 +09:00
Yukihiro "Matz" Matsumoto 6499efb8dd fmt_fp.c: add type cast to remove a warning. 2022-04-27 13:01:30 +09:00
Yukihiro "Matz" Matsumoto 132d55c924 symbol.c: fix size_t and uint32_t mixture. 2022-04-27 12:52:51 +09:00
Yukihiro "Matz" Matsumoto 4f14ada88a Merge pull request #5701 from jbampton/fix-grammar-and-spelling
docs: fix grammar and spelling
2022-04-26 17:40:32 +09:00
Yukihiro "Matz" Matsumoto a31cfff838 Merge pull request #5702 from jbampton/update-minimum-pre-commit-version
Update minimum `pre-commit` version to latest `2.18.1`
2022-04-26 17:37:14 +09:00
John Bampton c4bfbb2079 Update minimum pre-commit version to latest 2.18.1
Conda, Homebrew and PyPI all have `2.18.1`

https://github.com/pre-commit/pre-commit/releases
https://pypi.org/project/pre-commit/#history
https://formulae.brew.sh/formula/pre-commit
https://anaconda.org/conda-forge/pre-commit

Also run `pre-commit autoupdate`

https://pre-commit.com/#pre-commit-autoupdate
2022-04-26 15:50:49 +10:00
John Bampton c391d94da9 docs: fix grammar and spelling 2022-04-26 13:48:05 +10:00
Yukihiro "Matz" Matsumoto a31ff629ba Merge pull request #5700 from jbampton/codeql-on-pull-request-only
Avoid triggering CodeQL on the "push" event for Dependabot branches
2022-04-26 11:09:42 +09:00
Yukihiro "Matz" Matsumoto 50d1bf6214 Merge pull request #5699 from mruby/dependabot/github_actions/github/codeql-action-2
build(deps): bump github/codeql-action from 1 to 2
2022-04-26 08:45:55 +09:00
John Bampton 68ce424889 Avoid triggering CodeQL on the "push" event for Dependabot branches 2022-04-26 01:15:10 +10:00
dependabot[bot] d20ee7298a build(deps): bump github/codeql-action from 1 to 2
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 1 to 2.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/v1...v2)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-25 14:08:22 +00:00
Yukihiro "Matz" Matsumoto dd4da14772 symbol.c: remove type mismatch warnings. 2022-04-25 19:14:16 +09:00
Yukihiro "Matz" Matsumoto 73db8c5861 Merge branch 'dearblue-bigint-gem' 2022-04-25 11:21:12 +09:00
Yukihiro "Matz" Matsumoto 118ff0a529 Merge branch 'bigint-gem' of https://github.com/dearblue/mruby into dearblue-bigint-gem 2022-04-25 11:03:39 +09:00
Yukihiro "Matz" Matsumoto f225db4ed6 string.c: move compilation condition to remove unreachable code. 2022-04-25 10:04:39 +09:00
Yukihiro "Matz" Matsumoto 39c8c051f8 numeric.c: mrb_integer_to_str now supports big integers. 2022-04-25 10:03:47 +09:00
Yukihiro "Matz" Matsumoto df09838503 numeric.c: mrb_float_to_integer can return a big integer. 2022-04-25 10:02:54 +09:00
Yukihiro "Matz" Matsumoto 61700dbb0a mruby-sprintf/sprintf.c: raise an error with MRB_NO_FLOAT. 2022-04-25 10:01:09 +09:00
Yukihiro "Matz" Matsumoto b835979bf3 bigint.c: update the error message for too big integers. 2022-04-25 07:31:39 +09:00
Yukihiro "Matz" Matsumoto 0f4769536b src/numeric.c: use mrb_ensure_float_type().
Instead of obsolete `mrb_to_float()` or the combination of
`mrb_float_value(mrb_as_float())`.
2022-04-25 07:29:55 +09:00
Yukihiro "Matz" Matsumoto f45ac65532 fixup! mruby-kernel-ext/kernel.c: use mrb_ensure_integer_type(). 2022-04-25 07:29:21 +09:00
Yukihiro "Matz" Matsumoto 425097c7be mruby-kernel-ext/kernel.c: use mrb_ensure_integer_type().
Instead of obsolete `mrb_to_integer()`.
2022-04-25 07:26:42 +09:00
Yukihiro "Matz" Matsumoto ede3bed9e6 object.c: add new function mrb_ensure_integer_type().
that checks if the value is an `Integer` which may be a big integer,
where existing `mrb_ensure_int_type()` checks if the value is an Integer
**and** fits in `mrb_int`.
2022-04-25 07:21:40 +09:00
Yukihiro "Matz" Matsumoto 2bea39f339 mruby-range-ext/range.c: Range#cover?() takes a range too. 2022-04-24 14:02:00 +09:00
Yukihiro "Matz" Matsumoto 56a35131a4 numeric.c (mrb_cmp): should not raise NoMethodError.
Even when `obj1` does not have `<=>` method.
2022-04-24 14:02:00 +09:00
Yukihiro "Matz" Matsumoto 083691dbd1 variable.c (const_get): stop searching constant before Object.
`String::String` should raise `NameError` exception.
2022-04-24 14:02:00 +09:00
Yukihiro "Matz" Matsumoto 17b4d82f65 variable.c: remove mrb_ prefix from a static function. 2022-04-24 14:02:00 +09:00
Yukihiro "Matz" Matsumoto 8bd77ca332 vm.c: target_class should be retrieved from callinfo. 2022-04-24 14:01:59 +09:00
Yukihiro "Matz" Matsumoto 4afbf8ff01 Merge pull request #5697 from dearblue/mrb_alloca
Hides the class of string objects allocated by `mrb_alloca()`
2022-04-24 14:00:49 +09:00
dearblue 889f1b898f Hides the class of string objects allocated by mrb_alloca()
Prevents retrieval with the `ObjectSpace.each_object` method.
2022-04-23 22:13:30 +09:00
dearblue cc3a213fef Move bigint implementation files to mruby-bigint
Users can now switch to their own implementation of GEM.
However, we do not guarantee that this will not be a problem in the current situation.
This may need to be improved in the future.
2022-04-23 21:19:12 +09:00
dearblue e3e85df13a Removed duplicate prototype declarations for bigint
A part of `include/mruby/bigint.h` has been removed because it duplicates `include/mruby/internal.h`.
2022-04-23 21:11:42 +09:00
Yukihiro "Matz" Matsumoto a4d97934d5 vm.c: check if target_class is NULL (when prepended). 2022-04-22 08:32:18 +09:00
Yukihiro "Matz" Matsumoto bdc244e9b0 mruby-errno/errno.c: fix integer size mixtures. 2022-04-21 14:47:15 +09:00
Yukihiro "Matz" Matsumoto 3be461077d mruby-pack/pack.c: fix integer size mixtures. 2022-04-21 14:47:15 +09:00
Yukihiro "Matz" Matsumoto 9dd45df804 numeric.c (int_pow): should not overflow. 2022-04-21 11:35:52 +09:00
Yukihiro "Matz" Matsumoto e7d0e6fd5a vm.c: fix integer size mixtures. 2022-04-20 16:18:18 +09:00
Yukihiro "Matz" Matsumoto b07ce286f1 fmt_fp.c: fix int and size_t mixture. 2022-04-20 16:11:32 +09:00
Yukihiro "Matz" Matsumoto dd582069ed bigint.c: simplify a loop in mrb_bint_new_float(). 2022-04-20 14:47:40 +09:00
Yukihiro "Matz" Matsumoto b0be2b0176 bigint.c: fix integer size mixture warnings. 2022-04-20 14:47:40 +09:00
Yukihiro "Matz" Matsumoto 791635a8d1 Merge pull request #5695 from dearblue/mrbc-build
Setting `Command#build` correctly in automatic "mrbc" build for presym
2022-04-20 14:47:25 +09:00
Yukihiro "Matz" Matsumoto eb8f7e1b77 Merge pull request #5694 from dearblue/method_added
Move `method_added` method into the `Module`
2022-04-20 08:05:54 +09:00
dearblue be782b7d36 Setting Command#build correctly in automatic "mrbc" build for presym
This was the cause of the command line flag being affected by changes in the parent build.
So, for example, if `mruby-rational` was included, even the automatically added `mrbc` builds included `MRB_USE_RATIONAL`.
2022-04-19 21:48:50 +09:00
dearblue 8bd924c905 Move method_added method into the Module
Previously defined as `BasicObject#method_added`.
2022-04-19 21:00:45 +09:00
Yukihiro "Matz" Matsumoto 4ce0f6dc05 Merge pull request #5692 from jbampton/update-lint-workflow
Fix step names in lint workflow
2022-04-19 07:45:47 +09:00
Yukihiro "Matz" Matsumoto 94585a5902 mruby-binding/bindinc.c: should not mix int and size_t. 2022-04-18 17:47:10 +09:00
Yukihiro "Matz" Matsumoto b38a766427 numeric.c (flo_to_i): use bigint if the value is bigger than mrb_int. 2022-04-18 12:31:15 +09:00
Yukihiro "Matz" Matsumoto 96ff3c31c4 bigint.c: cast to unsigned integer to avoid undefined behavior. 2022-04-18 11:34:30 +09:00
Yukihiro "Matz" Matsumoto 25e6e24c19 bigint.c: adjust integer types to remove warnings. 2022-04-18 11:33:53 +09:00
Yukihiro "Matz" Matsumoto a89130561b bigint.c: remove unused function prototypes. 2022-04-18 11:32:09 +09:00
Yukihiro "Matz" Matsumoto c0b829acce bigint.h: remove unused macro OVMASK. 2022-04-18 11:30:50 +09:00
Yukihiro "Matz" Matsumoto cb353af9ad Merge pull request #5693 from dearblue/each_byte
Improvements to `String#each_byte`
2022-04-18 09:58:59 +09:00
Yukihiro "Matz" Matsumoto c0ef940c90 numeric.c: add boundary checks in Float#to_f.
- check_num_exact() before rounding the float value
- check integer (mrb_int) overflow.
2022-04-17 09:32:04 +09:00
Yukihiro "Matz" Matsumoto 790910b50a codegen.c: genop_3 to take uint16_t instead of uint8_t. 2022-04-17 09:32:04 +09:00
Yukihiro "Matz" Matsumoto 6df1e68e70 Merge pull request #5691 from dearblue/newlit
Avoid creating temporary objects with `new_lit()` in `codegen.c`
2022-04-17 09:18:25 +09:00
dearblue 76d3ea8458 Improvements to String#each_byte
Each byte value is now retrieved inside the loop.
2022-04-16 22:23:34 +09:00
John Bampton d1f754cc19 Fix step names in lint workflow 2022-04-16 22:40:03 +10:00
dearblue 1354ad96ec Avoid creating temporary objects with new_lit() in codegen.c
At the same time, the saving and restoration of unwanted object arenas was removed.
In addition, the common code to extend the pool that existed before has been grouped together and newly established as `lit_pool_extend()`.
Note that previously the variable `i` was updated at that time, but since it is the same as the value at the end of a `for` statement, it has been omitted.

The original catalyst was that `bin/mrbc` with the `MRB_WORD_BOXING` + not `MRB_BOXWORD_NO_FLOAT_TRUNCATE` configuration caused `bin/mrbtest` with the `MRB_NO_BOXING` configuration to fail.
Upon investigation, I concluded that avoiding the creation of temporary objects would prevent the truncation of floating point numbers.
Therefore, this patch also prevents the `rake test` from failing with the following configuration.

```console
% cat test_config.rb
bootstrap_mrbc = nil

MRuby::Build.new do |conf|
  conf.toolchain
  conf.enable_debug
  conf.enable_test
  conf.disable_presym
  conf.defines << %w(MRB_WORD_BOXING)
  #conf.defines << %w(MRB_WORDBOX_NO_FLOAT_TRUNCATE)
  gem core: "mruby-bin-mrbc"
  gem core: "mruby-kernel-ext"
  bootstrap_mrbc = File.join(conf.build_dir, "bin/mrbc")
end

MRuby::Build.new("nobox") do |conf|
  conf.toolchain
  conf.enable_debug
  conf.enable_test
  conf.defines << %(MRB_NO_BOXING)
  conf.mrbcfile = bootstrap_mrbc
  gem core: "mruby-kernel-ext"
end
```
2022-04-16 18:22:32 +09:00
Yukihiro "Matz" Matsumoto b352e462cf Merge pull request #5690 from jbampton/enable-MD010
Enable markdownlint rule MD010 no-hard-tabs
2022-04-15 14:22:04 +09:00
John Bampton 2e35a88c7b Enable markdownlint rule MD010 no-hard-tabs 2022-04-15 12:19:27 +10:00
Yukihiro "Matz" Matsumoto 528335ee99 Merge pull request #5689 from jbampton/case-and-grammar
Fix grammar and case of Ruby
2022-04-15 10:46:49 +09:00
John Bampton 888931c103 Fix grammar and case of Ruby 2022-04-15 11:32:32 +10:00
Yukihiro "Matz" Matsumoto 5f1ed381ae Merge pull request #5688 from jbampton/fix-spelling
Fix spelling in `doc/mruby3.2.md`
2022-04-15 07:44:50 +09:00
John Bampton aa4049e5e6 Fix spelling in doc/mruby3.2.md 2022-04-15 07:06:23 +10:00
Yukihiro "Matz" Matsumoto eba74c038e string.c: avoid a local variable. 2022-04-14 10:55:00 +09:00
Yukihiro "Matz" Matsumoto 15af07562a variable.c: use size_t to avoid integer type mismatch. 2022-04-14 10:54:37 +09:00
Yukihiro "Matz" Matsumoto 3c96ee704b fiber.c: cast integer to avoid a warning. 2022-04-14 10:53:58 +09:00
Yukihiro "Matz" Matsumoto fef7deabd5 doc/mruby3.2.md: add description about multi-precision integers. 2022-04-12 20:28:47 +09:00
Yukihiro "Matz" Matsumoto 2f918f1926 errno.c: fix int and mrb_int mixture.
`strerror(3) takes `int` not `mrb_int`.
2022-04-12 16:11:01 +09:00
Yukihiro "Matz" Matsumoto 0e975c1571 bigint.h: simplified the condition. 2022-04-12 15:06:28 +09:00
Yukihiro "Matz" Matsumoto ff2b21ddf3 Merge pull request #5687 from dearblue/sysfail
Must the `mrb_sys_fail()` function raise an exception
2022-04-12 08:59:50 +09:00
Yukihiro "Matz" Matsumoto 0ec5c3e493 bigint.c (mrb_bint_cmp): avoid object allocation for comparison. 2022-04-11 11:12:47 +09:00
Yukihiro "Matz" Matsumoto f63f57391f bigint.c: fix bugs caused by integer size variety. 2022-04-11 11:04:22 +09:00
Yukihiro "Matz" Matsumoto 30f6669d09 bigint.h: use int64_t as mp_limb if MRB_INT64 is set. 2022-04-11 11:03:08 +09:00
Yukihiro "Matz" Matsumoto bafca84c54 dump.c: should dump INT64 with MRB_32BIT. 2022-04-11 11:00:49 +09:00
dearblue ef5ae084d7 Must the mrb_sys_fail() function raise an exception
Normal return of control from the `mrb_sys_fail()` function has unexpected results.
Example: double free, malloc with huge size used as error integer

The following is an example of an actual crash:

```console
% cat crash.rb
def SystemCallError._sys_fail(*a)
  nil
end

File.readlink("/404")

% bin/mruby crash.rb
zsh: segmentation fault (core dumped)  bin/mruby crash.rb
```
2022-04-10 21:36:59 +09:00
Yukihiro "Matz" Matsumoto 676e9bcf81 bigint.h: use LL suffix for bigger integer literals. 2022-04-10 19:55:45 +09:00
Yukihiro "Matz" Matsumoto dda1626105 bigint.c: wrong position of break statement. 2022-04-10 19:55:22 +09:00
Yukihiro "Matz" Matsumoto 2f832f4479 bigint.c: fix infinite loop bugs. 2022-04-10 19:04:20 +09:00
Yukihiro "Matz" Matsumoto e14782e8a1 vm.c: fixed wrong compilation condition for MRB_INT32. 2022-04-10 19:03:37 +09:00
Yukihiro "Matz" Matsumoto 17a31efa8a vm.c: adjust size of int types. 2022-04-10 19:03:01 +09:00
Yukihiro "Matz" Matsumoto b3420faafd class.c: use mrb_ssize to keep the array length. 2022-04-10 19:02:17 +09:00
Yukihiro "Matz" Matsumoto b22044fca6 vm.c: cipush() to take uint16_t argc. 2022-04-10 17:36:03 +09:00
Yukihiro "Matz" Matsumoto 4260ce83a9 vm.c: avoid bare macro constant reference. wrap it by defined(). 2022-04-09 23:43:03 +09:00
Yukihiro "Matz" Matsumoto bbf4423f4c bigint.c: y->sz > 2 can be fit in mrb_int. 2022-04-09 18:21:45 +09:00
Yukihiro "Matz" Matsumoto 88e0c64ffc class.c: fix bugs in inline method cache. 2022-04-09 17:16:12 +09:00
Yukihiro "Matz" Matsumoto b1d0296a93 class.c: clear method cache after remove_method. 2022-04-09 17:16:12 +09:00
Yukihiro "Matz" Matsumoto c30e6ebe12 gc.c: add red (persistent no scan) color in the comment [ci skip] 2022-04-09 17:16:12 +09:00
Yukihiro "Matz" Matsumoto c8c083cb75 codegen.c: need to pack argument when n==13 too.
Because we have extra 2 arguments coming (kw and rhs).
2022-04-09 17:16:12 +09:00
Yukihiro "Matz" Matsumoto 55b526167b test/bigint.rb: add test for multi-precision integers. 2022-04-09 17:16:11 +09:00
Yukihiro "Matz" Matsumoto f33537f4fd dump.c: fix a bug in dump data size of BIGINT pool.
Was dumping extra NUL (\0) after the data.
2022-04-09 17:16:11 +09:00
Yukihiro "Matz" Matsumoto a252893292 load.c: should not skip bigint literal length. 2022-04-09 17:16:11 +09:00
Yukihiro "Matz" Matsumoto dcaf4083d5 src/bigint.c: implement multi-precision integer.
To enable multi-precision integer support, you need to link
`mruby-bigint` mrbgem. The gem itself is empty but it turns on
the "bigint" support.
2022-04-09 17:16:10 +09:00
Yukihiro "Matz" Matsumoto e3c20b7319 build_config: use full-core gembox on host configuration (except default) 2022-04-06 22:51:47 +09:00
Yukihiro "Matz" Matsumoto 5a27b69aa6 numeric.c: remove duplicated code in int_divmod. 2022-04-06 17:04:40 +09:00
Yukihiro "Matz" Matsumoto 5bef8e4135 numeric.c: the result of -5.div(2) should be -3 as CRuby does. 2022-04-06 17:04:40 +09:00
Yukihiro "Matz" Matsumoto 6ed21ead21 Merge pull request #5682 from dearblue/heap_p
Fixed bounds check for `heap_p()` function in `src/gc.c`
2022-04-06 17:04:32 +09:00
Yukihiro "Matz" Matsumoto f9378f45b9 Merge pull request #5684 from jbampton/run-super-linter-once
Run Super-Linter only once
2022-04-05 14:12:43 +09:00
Yukihiro "Matz" Matsumoto c9c63846e9 Merge pull request #5683 from mruby/dependabot/github_actions/github/super-linter-4.9.2
build(deps): bump github/super-linter from 4.9.1 to 4.9.2
2022-04-05 14:11:59 +09:00
John Bampton b4c70fbe51 Run Super-Linter only once 2022-04-05 00:18:29 +10:00
dependabot[bot] 70aded64f7 build(deps): bump github/super-linter from 4.9.1 to 4.9.2
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.9.1 to 4.9.2.
- [Release notes](https://github.com/github/super-linter/releases)
- [Changelog](https://github.com/github/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/github/super-linter/compare/v4.9.1...v4.9.2)

---
updated-dependencies:
- dependency-name: github/super-linter
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-04 14:08:43 +00:00
Yukihiro "Matz" Matsumoto 3cf291f722 vm.c: create break object before clearing GC arena.
Otherwise it possibly cause use-after-free.
2022-04-04 12:26:52 +09:00
dearblue 87c9bd0754 Fixed bounds check for heap_p() function in src/gc.c
One extra element was included.
2022-04-03 22:14:42 +09:00
Yukihiro "Matz" Matsumoto 8aec568fc5 range.c: detect integer overflow. 2022-04-03 18:39:40 +09:00
Yukihiro "Matz" Matsumoto 3dabd18dcc errno.c: resolve signedness warning. 2022-04-02 18:25:13 +09:00
Yukihiro "Matz" Matsumoto b99c389ec3 internal.h: aggregate internal functions.
Internal functions can only be called from within the library.
Functions listed in `mruby/internal.h` can be called from:

* core (src/*.c)
* gems (mrbgems/**/*.c)

But not from the application linked with `libmruby`.
2022-04-02 18:25:13 +09:00
dearblue 92ef9f1a9e Store backtrace to field of struct RException
Since the possible values of the backtrace are limited to `nil`, `RData`, and `RAray`, they are now stored as object pointers.

This change saves memory by eliminating the need to use instance variables for common exceptions.

ref. #2485
2022-04-01 23:27:19 +09:00
dearblue 7d85092bc4 Reorganize the struct RException::mesg member
There is no need to limit the type to `struct RString`.
Also, the `MRB_EXC_MESG_STRING_FLAG` flag can be eliminated by checking if `struct RException::mesg` is `NULL` or not.

ref. #2485
2022-04-01 23:25:20 +09:00
Yukihiro "Matz" Matsumoto 00acae117d vm.c: target class may be NULL. 2022-04-01 16:40:06 +09:00
Yukihiro "Matz" Matsumoto d1f1b4ea38 cdump.c: add const qualifier for line number arrays. 2022-04-01 15:02:39 +09:00
Yukihiro "Matz" Matsumoto 9de6065ae2 Merge pull request #5680 from jbampton/pre-commit-autoupdate
pre-commit autoupdate
2022-04-01 14:57:08 +09:00
John Bampton cc380c6546 pre-commit autoupdate
https://pre-commit.com/#pre-commit-autoupdate
2022-04-01 08:26:40 +10:00
Yukihiro "Matz" Matsumoto a3f2c95334 codegen.c: skip overwritten MOVE instructions. 2022-03-30 15:34:40 +09:00
Yukihiro "Matz" Matsumoto 60cf382ff9 codegen.c: peephole optimize consecutive MOVE instructions. 2022-03-29 22:36:40 +09:00
Yukihiro "Matz" Matsumoto 9593c15603 AUTHORS: update entries [ci skip] 2022-03-28 17:21:10 +09:00
Yukihiro "Matz" Matsumoto bb5f6a8b56 Merge pull request #5679 from dearblue/expiration-code
Remove old compatibility code
2022-03-27 19:13:26 +09:00
dearblue f9d72908ca Remove old compatibility code
The `mrb_voidp()` related macros have been removed in mruby-1.1.0.
2022-03-27 11:26:43 +09:00
Yukihiro "Matz" Matsumoto 91255c7e9f mrblib/array.rb: Array#<=> to handle NoMethodError exception.
Array element may not respond to `<=>` method.
2022-03-26 22:57:41 +09:00
Yukihiro "Matz" Matsumoto 7f5a490d09 vm.c: vm.c: stack may be reallocated in functions calls; aaa28a5
`mrb_range_new()` also calls VM recursively.
2022-03-26 21:06:02 +09:00
Yukihiro "Matz" Matsumoto bf5bbf0a4b test/integer: test negative integer divisions; ref #5678 2022-03-26 11:26:57 +09:00
Yukihiro "Matz" Matsumoto a91b55f5ca codegen.c: allow constant folding for multiply with zero. 2022-03-26 11:20:59 +09:00
Yukihiro "Matz" Matsumoto 90969cef4c codegen.c: fix the negative division regression; fix #5678 2022-03-26 11:20:59 +09:00
Yukihiro "Matz" Matsumoto 8afdf78928 Merge pull request #5677 from mruby/dependabot/github_actions/github/super-linter-4.9.1
build(deps): bump github/super-linter from 4.9.0 to 4.9.1
2022-03-26 10:52:24 +09:00
dependabot[bot] 4b118fcb0c build(deps): bump github/super-linter from 4.9.0 to 4.9.1
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.9.0 to 4.9.1.
- [Release notes](https://github.com/github/super-linter/releases)
- [Changelog](https://github.com/github/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/github/super-linter/compare/v4.9.0...v4.9.1)

---
updated-dependencies:
- dependency-name: github/super-linter
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-25 14:08:20 +00:00
Yukihiro "Matz" Matsumoto aaa28a5089 vm.c: stack may be reallocated in functions calls.
Probably due to recursive VM calls via `mrb_funcall()`.
2022-03-25 12:54:45 +09:00
Yukihiro "Matz" Matsumoto b4168c9b68 parse.y: empty here-doc delimiter caused infinite loop; fix #5676 2022-03-25 07:45:06 +09:00
Yukihiro "Matz" Matsumoto d53a991b07 Merge pull request #5668 from dearblue/gcred
No need to protect red objects
2022-03-24 10:33:40 +09:00
Yukihiro "Matz" Matsumoto ad568ebee5 Merge pull request #5674 from jbampton/fix-markdown-tables
Format Markdown tables
2022-03-24 09:37:45 +09:00
John Bampton 7e4eaaa11a Format Markdown tables 2022-03-24 01:00:24 +10:00
Yukihiro "Matz" Matsumoto 9debdf5a37 Merge pull request #5673 from mruby/dependabot/github_actions/actions/cache-3
build(deps): bump actions/cache from 2.1.7 to 3
2022-03-23 10:20:21 +09:00
Yukihiro "Matz" Matsumoto a153315975 Merge pull request #5665 from dearblue/benchmark1
Update benchmark task
2022-03-23 10:19:46 +09:00
dependabot[bot] be229d666f build(deps): bump actions/cache from 2.1.7 to 3
Bumps [actions/cache](https://github.com/actions/cache) from 2.1.7 to 3.
- [Release notes](https://github.com/actions/cache/releases)
- [Commits](https://github.com/actions/cache/compare/v2.1.7...v3)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-21 14:09:17 +00:00
Yukihiro "Matz" Matsumoto 982a4769a1 metaprog.c: add undefined_instance_methods method. 2022-03-21 11:15:23 +09:00
Yukihiro "Matz" Matsumoto 74597c6159 numeric.c: fix compile errors with MRB_NO_FLOAT; fix #5672 2022-03-20 19:04:00 +09:00
Yukihiro "Matz" Matsumoto 59d95352d6 doc/mruby3.2.md: new file to describe 3.2 changes. 2022-03-19 14:37:55 +09:00
Yukihiro "Matz" Matsumoto 4f869f3367 numeric.c: enhance float division to support Complex. 2022-03-18 14:23:17 +09:00
Yukihiro "Matz" Matsumoto e45081d310 mrbc/stub.c: define stub functions in a separated file. 2022-03-18 12:29:47 +09:00
Yukihiro "Matz" Matsumoto fe03e01078 numeric.c: enhance integer division to support Rational and Complex.
No longer need to override division methods in mrbgems.
2022-03-18 12:27:46 +09:00
Yukihiro "Matz" Matsumoto 4dcdf78f8a numeric_ext.c: add Integer#pow() method.
Which takes optional second argument of modulo.
2022-03-17 23:25:50 +09:00
Yukihiro "Matz" Matsumoto 6b2f08d933 Merge pull request #5670 from dearblue/exc-message
Reimplement `Exception#message` in Ruby
2022-03-16 22:17:55 +09:00
Yukihiro "Matz" Matsumoto 13d014ab5e complex.c: rename static functions to remove abbreviations.
- `flo_`
- `cpx_`
2022-03-15 19:14:45 +09:00
Yukihiro "Matz" Matsumoto a869e4e540 numeric.h: remove obsolete functions.
- mrb_flo_to_fixnum()
- mrb_to_flo()

This commit removes weird abbreviation `_flo`.
2022-03-15 19:10:49 +09:00
Yukihiro "Matz" Matsumoto 4e1cf3293b string.h: replace obsolete functions with macros.
- mrb_string_value_ptr()
- mrb_string_value_len()
2022-03-15 19:08:25 +09:00
Yukihiro "Matz" Matsumoto 6aa5d53867 numeric.c: avoid mrb_float with MRB_NO_FLOAT; fix #5671
`MRB_USE_COMPLEX` is exclusive with `MRB_NO_FLOAT`, so we only need to
check the former.
2022-03-15 19:07:28 +09:00
Yukihiro "Matz" Matsumoto 37d6506972 string.c: remove unused API mrb_str_strlen().
Compatibility macro is provided for safety.
2022-03-14 14:11:25 +09:00
Yukihiro "Matz" Matsumoto 7cd8641645 Merge pull request #5666 from dearblue/annotation.1
Correct truncated `SystemStackError` [ci skip]
2022-03-14 12:52:31 +09:00
Yukihiro "Matz" Matsumoto c5f2ac896c array.c: refactoring allocation size error. 2022-03-13 19:58:57 +09:00
Yukihiro "Matz" Matsumoto daebdb8a7a Merge pull request #5669 from dearblue/donothing
Change function name `mrb_bob_init` to `mrb_do_nothing`
2022-03-13 19:58:46 +09:00
dearblue 75371b8831 Reimplement Exception#message in Ruby
Suppresses the possibility of `mrb_vm_exec()` being called recursively.
2022-03-13 18:56:23 +09:00
dearblue 98d90d83cc Change function name mrb_bob_init to mrb_do_nothing
This is because it is not limited to the `BasicObject#initialize` method.
2022-03-13 16:45:20 +09:00
dearblue c3eac4fe5c No need to protect red objects
The object in `GC_RED` does not need to be marked, and the objects connected to this object should also not need to be marked.
2022-03-13 16:28:43 +09:00
dearblue 34048abcfc Correct truncated SystemStackError [ci skip] 2022-03-13 14:56:56 +09:00
Yukihiro "Matz" Matsumoto a2e9005286 parse.y: add type cast to integer comparison. 2022-03-12 13:31:46 +09:00
Yukihiro "Matz" Matsumoto 4beebc73a7 complex.c: avoid mrb_funcall; call functions directly. 2022-03-12 13:31:38 +09:00
Yukihiro "Matz" Matsumoto 2772e07dc8 rational.c: avoid mrb_funcall; call functions directly. 2022-03-12 13:31:38 +09:00
Yukihiro "Matz" Matsumoto 062c2128a3 numops.c: avoid mrb_funcall; call functions directly. 2022-03-12 13:31:38 +09:00
Yukihiro "Matz" Matsumoto 7659b3b271 numeric.c: avoid mrb_funcall; call functions directly.
When you try to call functions defined in mrbgems, you need to add the
names of functions to `mrbc.c`, since `mrbc` does not link any mrbgem
regardless of the configuration.
2022-03-12 13:31:38 +09:00
Yukihiro "Matz" Matsumoto b0d6413f2d numops.c: rename functions for addition and subtraction.
To more consistent names.

* mrb_num_plus() -> mrb_num_add()
* mrb_num_minus() -> mrb_num_sub()

Since no one seems to use those functions, there should be no problem.
We added migration macros for compatibility for safety.
2022-03-12 10:54:11 +09:00
Yukihiro "Matz" Matsumoto a20064bcb7 numops.c: separate API functions not used from mruby.
* mrb_num_plus()
* mrb_num_minus()
* mrb_num_mul()
2022-03-12 10:53:59 +09:00
Yukihiro "Matz" Matsumoto 5636e6ab54 numeric.c: rename and expose integer arithmetic functions.
* mrb_int_add()
* mrb_int_sub()
* mrb_int_mul()
2022-03-12 08:44:04 +09:00
Yukihiro "Matz" Matsumoto 10001ff67f rational.c, complex.c: expose arithmetic operation functions.
* mrb_{rational,complex}_{add,sub,mul,div}
2022-03-12 08:35:07 +09:00
Yukihiro "Matz" Matsumoto 55476efb62 error.c: use mrb_funcall_id and presym to call _sys_fail method. 2022-03-11 10:25:32 +09:00
Yukihiro "Matz" Matsumoto b3416832f4 vm.c: refactor block type checking. 2022-03-10 10:43:51 +09:00
Yukihiro "Matz" Matsumoto 0293037b21 proc.c: refactor proc type checking. 2022-03-10 10:43:22 +09:00
Yukihiro "Matz" Matsumoto 6ca1e5c8e0 kernel.c: use preallocated symbol. 2022-03-09 17:14:57 +09:00
Yukihiro "Matz" Matsumoto da48e7dbb2 fiber.c: should pack 15+ arguments in an array. 2022-03-09 15:21:15 +09:00
Yukihiro "Matz" Matsumoto 6e964bd1c6 array.c: check size bound by ARY_MAX_SIZE not MRB_INT_MAX. 2022-03-09 15:21:15 +09:00
Yukihiro "Matz" Matsumoto 6fa5aaf694 socket.c: unify error handling code. 2022-03-09 15:21:14 +09:00
Yukihiro "Matz" Matsumoto 2cb82803b3 socket.c: reorganize error condition in mrb_ipsocket_ntop(). 2022-03-09 15:21:14 +09:00
Yukihiro "Matz" Matsumoto 50f357ee5d mruby-sleep: make error messages consistent. 2022-03-09 15:21:14 +09:00
Yukihiro "Matz" Matsumoto 22a98a0ba7 pack.c: unify duplicated error handling code. 2022-03-09 15:21:14 +09:00
Yukihiro "Matz" Matsumoto 19b9184aa3 string.c: remove unnecessary goto. 2022-03-09 15:21:13 +09:00
Yukihiro "Matz" Matsumoto c2f7ed514d Merge pull request #5663 from dearblue/include-prepend
Small improvements to `Module#{include,prepend}`
2022-03-07 18:57:25 +09:00
Yukihiro "Matz" Matsumoto 2f8eba325a Merge pull request #5664 from dearblue/extend
Reimplement `Kernel.extend` in Ruby
2022-03-07 11:21:59 +09:00
Yukihiro "Matz" Matsumoto dc98988482 string.c: small refactoring regarding check_null_byte. 2022-03-06 23:49:40 +09:00
dearblue 267dd15767 Allow build settings to define if benchmarks are covered or not
Each build target can be explicitly disabled from benchmarking with `MRuby::Build#disable_benchmark`.

Also, the build target "host", which was previously excluded, is now included in the benchmark.
2022-03-06 15:35:05 +09:00
dearblue 1f0d265a83 Raise an exception if there is no benchmark target 2022-03-06 15:29:35 +09:00
dearblue e39581242d Display file paths for benchmark results 2022-03-06 15:28:56 +09:00
dearblue dfddb04063 Use standardized approach for get build configuration name 2022-03-06 15:27:50 +09:00
dearblue ac0d27d1a9 Reimplement Kernel.extend in Ruby 2022-03-06 13:48:04 +09:00
dearblue 9d04183ce1 Small improvements to Module#{include,prepend}
Array objects obtained as splat arguments are generated within the method.
Therefore, it is safe to perform destructive operations.
2022-03-06 13:43:31 +09:00
Yukihiro "Matz" Matsumoto 2dff7ed6a2 mrbc.c: add --no-optimize option to disable optimization; close #5661 2022-03-05 08:04:34 +09:00
Yukihiro "Matz" Matsumoto 41f5f464ae codegen.c: disable constant folding if no_optimize is set; ref #5661 2022-03-05 08:04:33 +09:00
Yukihiro "Matz" Matsumoto 7528c25aae string.c: remove unnecessary mrb_assert_int_fit(). 2022-03-05 08:04:33 +09:00
Yukihiro "Matz" Matsumoto 47cb831369 Merge pull request #5662 from mruby/dependabot/github_actions/actions/upload-artifact-3
build(deps): bump actions/upload-artifact from 2.3.1 to 3
2022-03-04 23:08:59 +09:00
dependabot[bot] d6e69ffef8 build(deps): bump actions/upload-artifact from 2.3.1 to 3
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 2.3.1 to 3.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v2.3.1...v3)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-04 14:07:02 +00:00
Yukihiro "Matz" Matsumoto 278f46f971 unpack.c: check if srcidx is shorter than srclen for safety. 2022-03-04 14:19:10 +09:00
Yukihiro "Matz" Matsumoto bc9476e7ca unpack.c: unpack_BER() did assume the string length is not zero. 2022-03-04 14:18:20 +09:00
Yukihiro "Matz" Matsumoto 31d4bbcfea string.c: improve size/capacity check before allocations. 2022-03-04 14:17:21 +09:00
Yukihiro "Matz" Matsumoto 876bcba694 string.c: avoid integer type mixture in mrb_str_cat(). 2022-03-03 16:29:54 +09:00
Yukihiro "Matz" Matsumoto 85c347c3af codegen.c: fix a bug in super with keyword arguments; fix #5660 2022-03-03 14:48:39 +09:00
Yukihiro "Matz" Matsumoto ef3a56c92b error.c: (mrb_exc_new) use mrb_int instead of size_t. 2022-03-03 14:48:39 +09:00
Yukihiro "Matz" Matsumoto b6531fa691 error.h: remove obsolete macro mrb_exc_new_str_lit(). 2022-03-03 14:48:39 +09:00
Yukihiro "Matz" Matsumoto c3f0f84da5 string.c: remove code duplication using str_init_modifiable(). 2022-03-03 14:48:29 +09:00
Yukihiro "Matz" Matsumoto 1a9991f165 string.c: remove unnecessary size check before string initialization. 2022-03-03 08:08:02 +09:00
Yukihiro "Matz" Matsumoto a9bde42641 string.c: small refactoring (open else clause after return). 2022-03-03 08:08:02 +09:00
Yukihiro "Matz" Matsumoto a4f740ff9a string.c: use mrb_int instead of size_t. 2022-03-03 08:08:02 +09:00
Yukihiro "Matz" Matsumoto 51a3317c5b string.c: check integer overflow using mrb_int_mul_overflow(). 2022-03-03 08:08:01 +09:00
Yukihiro "Matz" Matsumoto 0bf1ed9f2c array-ext/array.c: remove unused local variable. 2022-03-03 08:08:01 +09:00
Yukihiro "Matz" Matsumoto 84b5b4c6bf Merge pull request #5658 from mruby/dependabot/github_actions/actions/checkout-3
build(deps): bump actions/checkout from 2.4.0 to 3
2022-03-03 08:06:39 +09:00
dependabot[bot] d6ac7a3a7d build(deps): bump actions/checkout from 2.4.0 to 3
Bumps [actions/checkout](https://github.com/actions/checkout) from 2.4.0 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2.4.0...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-02 14:10:07 +00:00
Yukihiro "Matz" Matsumoto 1508da4740 array.c: check integer overflow in mrb_ary_set(). 2022-03-01 15:04:08 +09:00
Yukihiro "Matz" Matsumoto 9d8f3c60ff kernel.c: inline mrb_obj_extend() that is called only from one place. 2022-02-28 19:07:31 +09:00
Yukihiro "Matz" Matsumoto 740083eb72 AUTHORS: update entries [ci skip] 2022-02-27 23:42:45 +09:00
Yukihiro "Matz" Matsumoto 57540fbf6c object.c: improve handling of the broken inspect method.
When `inspect` method returns non-string value, it will return a string
given from `to_s` (and if `to_s` fails, will raise an exception).
2022-02-26 22:01:52 +09:00
Yukihiro "Matz" Matsumoto 5305c5c84d array.c: call mrb_ary_delete_at() directly from Array#slice!.
Avoid `mrb_funcall()`.
2022-02-26 14:21:35 +09:00
Yukihiro "Matz" Matsumoto b118ba9fb3 rational.c: avoid indirect calls using mrb_funcall(). 2022-02-25 17:53:55 +09:00
Yukihiro "Matz" Matsumoto 64d9808575 Merge pull request #5656 from suetanvil-misc/bug-missing-yaml
Added a dependency on 'yaml' to load_gems.rb.
2022-02-24 18:45:24 +09:00
Chris Reuter 73df87f7bd Added a dependency on 'yaml' to load_gems.rb.
It appears that some execution paths no longer load YAML before it is
needed so we explicitly `require` it here.
2022-02-23 14:23:57 -05:00
Yukihiro "Matz" Matsumoto c75dfad796 Merge pull request #5638 from suetanvil-misc/project-git-path-clash
Refactored load_gems.rb to be simpler and easier to understand.
Gracefully handle the case where multiple gems use the same git check out path.
2022-02-23 16:11:28 +09:00
Chris Reuter 8d1ffa8a11 Refactored load_gems.rb to be simpler and easier to understand:
- Converted LoadGems::load_special_path_gems() into a class, then
  subdivided the various types of gem dependencies into smaller
  private methods.

- Added class GemDepDetails to hold the relationship between a gem's
  location on the local disk and its upstream repository.  This will
  be used later.

- Removed the last remains of the '--pull-gems' option from the code
  base and documentation.  This is no longer present and the dead code
  is clutter.

Gracefully handle the case where multiple gems use the same git checkout path.

Previously, if two gems had the same directory name when cloning them
from git, mrbgems would assume they were the same gem.  This also
applied to different branches and/or commits of the same repository.
This led to a strange situation where the first `conf.gem` statement
"won" in cloning the repository but the last `conf.gem` ended up
choosing the branch/commit-id to use.

This change detects this situation and makes it an error.  It also
allows the config writer to explicitly specify a gem checkout to use
in place of the others.
2022-02-23 16:08:15 +09:00
Yukihiro "Matz" Matsumoto 776be1b397 codegen.c: use OP_ARRAY instead of OP_ARRAY2 in optimization.
If operand 1 and operand 2 specify the same register `OP_ARRAY2`
can/should be transformed to `OP_ARRAY`.
2022-02-22 19:28:40 +09:00
Yukihiro "Matz" Matsumoto d4d29b21b3 codegen.c: peephole optimize OP_MOVE after OP_ARRAY or OP_ARRAY2. 2022-02-22 17:27:24 +09:00
Yukihiro "Matz" Matsumoto c37f648552 codegen.c: use OP_ARRAY instead of OP_ARRAY2 if possible.
`OP_ARRAY` inline elements, i.e: with `OP_ARRAY Rn Rm len`, `Rn` and
`Rm` should always be the same register.
2022-02-22 17:21:51 +09:00
Yukihiro "Matz" Matsumoto 75e86dcfcd codegen.c: assign post assignees for fixed number of RHS. 2022-02-22 17:20:00 +09:00
Yukihiro "Matz" Matsumoto ae231924a9 parse.y: small refactoring in mrb_parser_dump(). 2022-02-22 16:46:02 +09:00
Yukihiro "Matz" Matsumoto 0282d3ec9f codegen.c: rename gen_vmassinment to gen_massignment.
`m` stands for `multiple` but I don't remember why I put `v` first.
2022-02-22 16:43:51 +09:00
Yukihiro "Matz" Matsumoto 80b44c6ade socket.c: avoid mrb_funcall_id() to retrieve file descriptor. 2022-02-22 11:46:02 +09:00
Yukihiro "Matz" Matsumoto 0fbdfaa831 Merge pull request #5652 from dearblue/check-type
Need to check the type of the method return value
2022-02-22 11:10:18 +09:00
Yukihiro "Matz" Matsumoto f72315575f codegen.c: fix a argument generation bug in array assignment. 2022-02-22 11:06:20 +09:00
Yukihiro "Matz" Matsumoto 349307ba88 codedump.c: do not print nameless registers. 2022-02-21 11:46:34 +09:00
Yukihiro "Matz" Matsumoto ce3b1c4780 SECURITY.md: added memory allocation error as a non security issue.
mruby expects `malloc(3)` returns `NULL` for too big allocations, so
even if big object allocation (e.g.  `[1,2,3]*268888888888888818`)
caused ASAN/Valgrind warnings, it's intentional, and we won't consider
the warning as a security issue.
2022-02-20 18:39:34 +09:00
Yukihiro "Matz" Matsumoto 5d9239c2c4 Merge pull request #5653 from dearblue/doc-keywords
Improved documentation for `struct mrb_kwargs` [ci skip]
2022-02-20 16:40:11 +09:00
dearblue d7c09fb24a Improved documentation for struct mrb_kwargs [ci skip]
- Changed the description to match the order of the changed members.
- Replaced "array of symbols" instead of "array of strings that mean symbols".
- The `mrb_kwargs::optional` member has not been present since the first merge. It is a remnant from development time.
- Removed `const` modifier used in variable declarations in examples. This is not always necessary from a user perspective.
- Added note on the use of `MRB_SYM()`.

resolved #5649
2022-02-19 21:55:52 +09:00
Yukihiro "Matz" Matsumoto 44f591aa8f codegen.c: adjust stack position for OP_SUPER instruction. 2022-02-19 16:17:33 +09:00
Yukihiro "Matz" Matsumoto f906ac314c Merge pull request #5651 from dearblue/doc3.1
Update `doc/mruby3.1.md`
2022-02-19 15:49:44 +09:00
dearblue 621cafde68 Need to check the type of the method return value 2022-02-19 15:01:46 +09:00
dearblue 401d316bcf Update doc/mruby3.1.md
- `OP_GETIDX`, `OP_SETIDX` : Fix operand number
- `OP_SYMBOL` : Add entry
2022-02-19 14:39:17 +09:00
Yukihiro "Matz" Matsumoto 5a014997ef Merge pull request #5650 from dearblue/keywords
Insert an empty hash before the first `NODE_KW_REST_ARGS`
2022-02-19 10:25:11 +09:00
dearblue 12d51807a3 Insert an empty hash before the first NODE_KW_REST_ARGS
I expect this will fix the two problems that "#5640" didn't address.

- It is expected to raise an exception `TypeError`, but it didn't before.

  ```console
  % bin/mruby -e 'p [**1]'
  [1]
  ```

- The variable `h` is expected to keep an empty hash, but it didn't before.

  ```console
  % bin/mruby -e 'h = {}; p(**h, a: 1, b: 2); p h'
  {:a=>1, :b=>2}
  {:a=>1, :b=>2}
  ```
2022-02-18 22:15:50 +09:00
Yukihiro "Matz" Matsumoto 47068ae07a vm.c: packed arguments length may be zero for send method. 2022-02-18 14:38:07 +09:00
Yukihiro "Matz" Matsumoto 1e314242e4 Merge pull request #5648 from mruby/dependabot/github_actions/github/super-linter-4.9.0
build(deps): bump github/super-linter from 4.8.7 to 4.9.0
2022-02-17 13:07:27 +09:00
dependabot[bot] 90e61e6a26 build(deps): bump github/super-linter from 4.8.7 to 4.9.0
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.8.7 to 4.9.0.
- [Release notes](https://github.com/github/super-linter/releases)
- [Changelog](https://github.com/github/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/github/super-linter/compare/v4.8.7...v4.9.0)

---
updated-dependencies:
- dependency-name: github/super-linter
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-02-16 14:05:48 +00:00
Yukihiro "Matz" Matsumoto a8f0e79107 parse.y: revert 9e064f2; fix #5647
Need to declare unnamed parameter when argument decomposition used.
2022-02-16 13:56:10 +09:00
Yukihiro "Matz" Matsumoto 1e0bdea30b codedump.c: print implicit operand of OP_HASHCAT.
Just like `OP_ARYCAT` and `OP_STRCAT`.
2022-02-16 07:40:42 +09:00
Yukihiro "Matz" Matsumoto ff3a5ebed6 vm.c: should check type before hash access.
Since the operand of double splat (`**`) may not be a hash, simple
assertion (previous code since d42a64e) was not enough for this case.
2022-02-15 18:36:38 +09:00
Yukihiro "Matz" Matsumoto ecb28f4bf4 load.c: add data boundary check for broken compiled binary. 2022-02-14 17:34:28 +09:00
Yukihiro "Matz" Matsumoto aba3d427c7 state.c: reps may be NULL if a broken compiled binary given. 2022-02-14 17:34:27 +09:00
Yukihiro "Matz" Matsumoto e884236e1c dump.h, irep.h: update comments not to omit buffer length for loading. [ci skip] 2022-02-14 17:34:27 +09:00
Yukihiro "Matz" Matsumoto ad3ce7b41c Merge pull request #5642 from dearblue/errmesg
Avoid direct access to error messages as instance variables
2022-02-13 20:59:47 +09:00
Yukihiro "Matz" Matsumoto 38b164ace7 codegen.c: fix a bug in gen_values().
- Fix limit handling that fails 15 arguments method calls.
- Fix too early argument packing in arrays.
2022-02-12 12:39:35 +09:00
Yukihiro "Matz" Matsumoto 0ed3fcfa26 Merge pull request #5646 from koic/support_array_join_with_string_argument
Make `Array#*` the CRuby compatible behavior when giving a string argument
2022-02-11 15:21:01 +09:00
Yukihiro "Matz" Matsumoto 11e7ca5db9 Merge pull request #5645 from jbampton/pre-commit-autoupdate
pre-commit autoupdate
2022-02-10 11:31:01 +09:00
Yukihiro "Matz" Matsumoto fb82108acb load.c: should check if length of irep sections are valid. 2022-02-10 11:25:45 +09:00
Yukihiro "Matz" Matsumoto d912b864df mruby-range-ext/range.c: cover? should work with begin-less ranges. 2022-02-09 13:32:20 +09:00
Yukihiro "Matz" Matsumoto 4e8ab145da vm.c: adjust integer types. 2022-02-08 13:11:44 +09:00
Yukihiro "Matz" Matsumoto 9037e447a5 numeric.c: avoid implicit cast from integer to double. 2022-02-08 13:11:44 +09:00
Yukihiro "Matz" Matsumoto 4562ba14c0 codegen.c: limit check was too restrictive in gen_values().
That can create unnecessary arrays when more than 12 arguments are
given to a method.
2022-02-08 13:11:43 +09:00
Yukihiro "Matz" Matsumoto 0849a2885f codegen.c: stack position may be wrong on assignments.
When `[]=` access includes keyword arguments.
2022-02-08 13:11:43 +09:00
Yukihiro "Matz" Matsumoto 4c13188ea6 codegen.c: generate OP_HASH in gen_hash() if limit exceeds.
That means when `limit` is `0` it should always generate a hash.
2022-02-08 13:11:43 +09:00
Yukihiro "Matz" Matsumoto 6f5e74f576 codegen.c: change size_t to uint16_t To remove type conversion warnings. 2022-02-08 13:11:42 +09:00
Koichi ITO 182096d8c0 Make Array#* the CRuby compatible behavior when giving a string argument
## Summary

This following is a behavior from CRuby 1.8.7 to 3.1.0.

```console
% ruby -ve "p ['a', 'b', 'c']*''"
ruby 1.8.7 (2013-12-22 patchlevel 375) [i686-darwin13.0.2]
"abc"

% ruby -ve "p ['a', 'b', 'c']*''"
ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [x86_64-darwin19]
"abc"
```

### Before (mruby 3.0.0)

mruby unexpectedly gives the TypeError.

```ruby
['a', 'b', 'c']*'' #=> String cannot be converted to Integer (TypeError)
```

### After

This PR makes mruby behave compatible with CRuby.

```ruby
['a', 'b', 'c']*'' #=> 'abc'
```

As far as I checked, the behavior is unspecified when `Array#*`'s argument
is not an instance of Integer class in X 3017 : 2013 (ISO/IEC 30170 : 2012).

## Additional Information

I noticed this difference by the following idiom when writing ASCII art code
using Ruby.

```ruby
%w(foo bar baz)*''
```

e.g. TRICK (https://github.com/tric)
2022-02-08 11:20:14 +09:00
John Bampton 4f986060c0 pre-commit autoupdate
https://pre-commit.com/#pre-commit-autoupdate
2022-02-07 19:52:12 +10:00
Yukihiro "Matz" Matsumoto 6cc6d9b078 Merge pull request #5644 from dearblue/errno-nopresym
Support `disable_presym` for `mrbgems/mruby-errno`
2022-02-07 16:05:22 +09:00
Yukihiro "Matz" Matsumoto 8b32a1f7ae Merge pull request #5643 from dearblue/errno-nostdio
Support `MRB_NO_STDIO` for `mrbgems/mruby-errno`
2022-02-07 15:43:51 +09:00
Yukihiro "Matz" Matsumoto e24e81cd3c mruby.c: rindex() is not supported by VC. 2022-02-06 22:44:02 +09:00
Yukihiro "Matz" Matsumoto d42a64eadf vm.c: add assertion for type of register values.
We used to check them by `mrb_ensure_xxx_type()` functions, but type
errors there should not occur if there's no bug in code generations.
So we use assertion rather than dynamic type checks.
2022-02-06 22:17:53 +09:00
Yukihiro "Matz" Matsumoto cf00c32e3a mruby.c: -b option should only affects the script.
Not the libraries loaded by `-r`. Instead, `.mrb` extension in the path
should determine whether they are compiled binary.
2022-02-06 22:17:41 +09:00
Yukihiro "Matz" Matsumoto bf8e061c17 Merge pull request #5641 from dearblue/ci-win2022
Pinning the Visual Studio version in GitHub Actions
2022-02-06 20:49:53 +09:00
dearblue 0a4f21c60f Support disable_presym for mrbgems/mruby-errno
The `mrbgems/mruby-errno/src/known_errors_def.cstub` file has been extended, so the `mrbgems/mruby-errno/src/known_errors_e2c.cstub` file is no longer needed.
2022-02-06 18:39:46 +09:00
dearblue a82220211d Support MRB_NO_STDIO for mrbgems/mruby-errno 2022-02-06 16:12:41 +09:00
dearblue d6773cbd71 Avoid direct access to error messages as instance variables
ref. #2485

The `SystemCallError#to_s` method also needed to be modified, but since it has no functional difference from the `Exception#to_s` method, it will be removed.
2022-02-06 15:45:13 +09:00
dearblue faffc0c4d3 Pinning the Visual Studio version in GitHub Actions
Until now, `windows-latest` meant `windows-2019`, but now it seems that it is being replaced by `windows-2022` in stages.
At the same time, Visual Studio 2019 will be replaced by Visual Studio 2022.

Since mruby's CI is configured to assume Visual Studio 2019, we'll update this and explicitly specify `windows-2022`.
2022-02-05 21:42:54 +09:00
Yukihiro "Matz" Matsumoto b7adf61fe2 Merge pull request #5640 from dearblue/rest-keywords
Check the type of the keyword rest argument
2022-02-05 18:30:58 +09:00
dearblue 6dfc47f5d4 Check the type of the keyword rest argument
If a non-hash object is passed in `OP_SEND` and `OP_SUPER`, an error should occur.

```ruby
kwd = "string"
p(**kwd)  #  => expect raised TypeError
```
2022-02-05 17:41:01 +09:00
dearblue d0e8637e30 Integrate argument normalization for OP_SEND and OP_SUPER 2022-02-05 17:36:23 +09:00
Yukihiro "Matz" Matsumoto 903c5f978a vm.c: check object type before concatenating strings. 2022-02-03 10:41:09 +09:00
Yukihiro "Matz" Matsumoto ae3c99767a codegen.c: fixed a bug in hash code generation with !val. 2022-02-03 10:40:05 +09:00
Yukihiro "Matz" Matsumoto 8d06e79c57 codedump.c: remove unnecessary condition.
`(irep->pool[b].tt & IREP_TT_NFLAG) == 0` is always true ensured by
the assertion.
2022-02-02 20:57:43 +09:00
Yukihiro "Matz" Matsumoto f9f2d4c4e3 codedump.c: adjust OP_HASHCAT variable label position. 2022-02-02 20:51:37 +09:00
Yukihiro "Matz" Matsumoto f0af96c130 mruby-class-ext: add Class#subclasses method. 2022-02-01 22:37:49 +09:00
Yukihiro "Matz" Matsumoto d9bf7982e9 class.c: set MRB_FL_CLASS_IS_INHERITED flag for bootstrapped classes. 2022-02-01 22:36:42 +09:00
Yukihiro "Matz" Matsumoto 00f2b74ab2 kernel.c, binding.c: use MRB_SYM() instead of mrb_intern_lit(). 2022-01-31 16:20:52 +09:00
Yukihiro "Matz" Matsumoto 92fb6d3526 Merge pull request #5639 from suetanvil-misc/project-mruby-errno-readme
Updated mruby-errno/README.md to pass the lint checks.
2022-01-31 15:45:18 +09:00
Yukihiro "Matz" Matsumoto 8252352d7b parse.y: fix buffer overflow with tweaked mruby binary. 2022-01-31 15:42:52 +09:00
Chris Reuter 198e10473b Updated mruby-errno/README.md to pass the lint checks. 2022-01-29 18:40:05 -05:00
Yukihiro "Matz" Matsumoto 0cd12c6d6f Merge pull request #5637 from mruby/dependabot/github_actions/github/super-linter-4.8.7
build(deps): bump github/super-linter from 4.8.6 to 4.8.7
2022-01-29 09:09:36 +09:00
dependabot[bot] 319340f309 build(deps): bump github/super-linter from 4.8.6 to 4.8.7
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.8.6 to 4.8.7.
- [Release notes](https://github.com/github/super-linter/releases)
- [Changelog](https://github.com/github/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/github/super-linter/compare/v4.8.6...v4.8.7)

---
updated-dependencies:
- dependency-name: github/super-linter
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-01-28 14:06:26 +00:00
Yukihiro "Matz" Matsumoto 8b443aa43b Merge pull request #5636 from mruby/dependabot/github_actions/github/super-linter-4.8.6
build(deps): bump github/super-linter from 4.8.5 to 4.8.6
2022-01-28 11:24:46 +09:00
dependabot[bot] 912925eab7 build(deps): bump github/super-linter from 4.8.5 to 4.8.6
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.8.5 to 4.8.6.
- [Release notes](https://github.com/github/super-linter/releases)
- [Changelog](https://github.com/github/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/github/super-linter/compare/v4.8.5...v4.8.6)

---
updated-dependencies:
- dependency-name: github/super-linter
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-01-27 14:09:18 +00:00
Yukihiro "Matz" Matsumoto c5bdfe1bd4 mruby-errno: add errno constants to known_errors.def.
Add unlisted errno constants found in macOS and FreeBSD.
If you see unlisted errno, please report.
2022-01-26 12:58:52 +09:00
Yukihiro "Matz" Matsumoto b7cdb59f26 errno.c: stop generating Errno::Exxx error classes on the fly. 2022-01-26 12:29:19 +09:00
Yukihiro "Matz" Matsumoto dd93dd7419 errno.c: refactor _sys_fail to avoid mrb_funcall. 2022-01-25 16:01:33 +09:00
Yukihiro "Matz" Matsumoto 9892742d27 errno.c: use C array instead of a hash table to lookup a errno class.
To reduce memory consumption by avoiding allocating Ruby objects.
2022-01-25 11:15:34 +09:00
Yukihiro "Matz" Matsumoto 194d0c6f46 mruby-errno: change the format of known_errors_e2c.cstub. 2022-01-25 11:08:52 +09:00
Yukihiro "Matz" Matsumoto 4176e8e88f error.c: use MRB_SYM() in mrb_sys_fail. 2022-01-25 11:08:05 +09:00
Yukihiro "Matz" Matsumoto 5c7338491c errno.c: use mrb_fixnum_p() instead of mrb_type(). 2022-01-25 10:39:13 +09:00
Yukihiro "Matz" Matsumoto 6744d69d3d errno.c: replace string literals by MRB_SYM(). 2022-01-25 10:39:13 +09:00
Yukihiro "Matz" Matsumoto 1e866dffc4 errno.c: bundled mrbgem need not to support mruby 1.x. 2022-01-25 10:28:50 +09:00
Yukihiro "Matz" Matsumoto 0f5829795e errno.c: use MRB_SYM() instead of mrb_intern_lit(). 2022-01-25 10:26:34 +09:00
Yukihiro "Matz" Matsumoto 3b5486e3ae mruby-errno/test: update test suites not to report warnings. 2022-01-25 10:22:28 +09:00
Yukihiro "Matz" Matsumoto 3a15d18ebb errno.c: hide internal _sys_fail from backtrace. 2022-01-24 18:14:28 +09:00
Yukihiro "Matz" Matsumoto c8d96ed782 stdlib.gembox: add mruby-errno 2022-01-24 18:13:28 +09:00
Yukihiro "Matz" Matsumoto a60073d7b9 mruby-errno: remove .gitkeep. 2022-01-24 18:07:59 +09:00
Yukihiro "Matz" Matsumoto 0a6d57ab3c Merge remote-tracking branch 'mruby-errno/master' 2022-01-24 17:58:41 +09:00
Yukihiro "Matz" Matsumoto 2adf32a3f4 add mruby-errno directory 2022-01-24 16:42:36 +09:00
Yukihiro "Matz" Matsumoto 7bedd5e05d codegen.c: generate OP_SETIDX from attribute assignments. 2022-01-24 11:18:27 +09:00
Yukihiro "Matz" Matsumoto cda4d9bcb4 codegen.c: refactor gen_call and gen_values.
Remove no longer used arguments from the functions.
2022-01-22 16:40:21 +09:00
Yukihiro "Matz" Matsumoto b611c43a5d codegen.c: no OP_HASHADD required when val is false. 2022-01-21 15:42:51 +09:00
Yukihiro "Matz" Matsumoto adb16fc6df codegen.c: adjust indentation after OP_STRCAT. 2022-01-21 10:51:07 +09:00
Yukihiro "Matz" Matsumoto ebb5287e29 codedump.c: omit raw c operand for OP_SEND etc. 2022-01-21 10:41:14 +09:00
Yukihiro "Matz" Matsumoto b53cd3ce25 codegen.c: fix evaluation order of attribute assignment. 2022-01-21 10:41:14 +09:00
Yukihiro "Matz" Matsumoto f8944792be parse.y: consistent argument pass for new_call(). 2022-01-21 10:41:13 +09:00
Yukihiro "Matz" Matsumoto ef98eb2c29 codegen.c: fix evaluation order of constant initialization.
`a::B = c` should evaluate `a` then `c`. It used to be `c` then `a`. The
`OP_SETMCNST` instruction operands are designed for older order in mind.
Should we changed the operand order?
2022-01-21 10:41:13 +09:00
Yukihiro "Matz" Matsumoto b68ba2df49 Merge pull request #5634 from hasumikin/fix_mruby-bin-example_tree
Fix tree of mruby-bin-example
2022-01-17 23:27:29 +09:00
HASUMI Hitoshi fb9bba34fb Fix tree of mruby-bin-example 2022-01-17 22:36:41 +09:00
Yukihiro "Matz" Matsumoto 31fa330404 class.c: add obj->c check before prepare_singleton_class(). 2022-01-16 22:22:46 +09:00
Yukihiro "Matz" Matsumoto 475b868b72 time.c: remove duplicated UTC condition check. 2022-01-15 18:24:39 +09:00
Yukihiro "Matz" Matsumoto 171d32c007 time.c: 1969-12-31 23:59:59 is a valid time.
But `mktime(3)` for the date returns `-1` which happen to be the
error value.
2022-01-14 11:40:52 +09:00
Yukihiro "Matz" Matsumoto 8f09d8feb4 time.c: check year range before creating Time object. 2022-01-13 15:40:09 +09:00
Yukihiro "Matz" Matsumoto 9f012724fb vm.c: need to adjust argument after packing keyword args; fix #5632
It was caused by #5628.
2022-01-12 12:44:23 +09:00
Jonas Minnberg c6f0452d13 Added comments about removal of objects[]
Made mrb_get_args_v() static
2021-12-12 16:14:53 +01:00
Jonas Minnberg b1cf973186 Added mrb_get_args_a() - an array version of mrb_get_args() 2021-12-11 14:24:36 +01:00
Jonas Minnberg 24939723d7 Remove zero length array since it is not C++ compatible 2021-12-11 14:23:59 +01:00
Tomoyuki Sahara 89dceefa12 s/__android__/__ANDROID__/. fixes #15.
mruby core uses __ANDROID__ to know whether the target system is
Android or not (in mrbgems/mruby-math).
2018-09-14 15:49:36 +09:00
Tomoyuki Sahara 14bc5c3e51 Merge pull request #14 from masahino/add_pointer_casting
Add pointer casting
2016-12-16 23:02:28 +09:00
masahino b1ccf9764b Add pointer casting 2016-12-15 21:34:27 +09:00
Tomoyuki Sahara 0c3c538855 Merge pull request #13 from udzura/add-chroot
Implement Dir.chroot on mruby
2016-06-13 09:54:03 +09:00
Uchio KONDO 7318ae5977 Remove perror 2016-06-13 09:42:16 +09:00
Uchio KONDO e9c4b10446 Implement Dir.chroot on mruby 2016-06-10 15:59:20 +09:00
yui-knk 68334311ac Remove dependency to mruby-sprintf (Fix #3) 2016-02-11 21:47:13 +09:00
yui-knk fbf8c10a94 Merge pull request #5 from yui-knk/use_new_container_based_infrastructure
Use the new container-based test infrastructure on travis ci
2016-02-11 20:38:46 +09:00
yui-knk 4f0a509342 Use the new container-based test infrastructure on travis ci 2016-02-11 20:36:25 +09:00
yui-knk 96ea55d2f9 Add a test case for Set#inspect 2016-02-11 20:27:55 +09:00
yui-knk 24b09fca69 Remove src directory (Fix #2)
This gem does not have c implementation, so remove src directory.
2016-02-11 20:13:53 +09:00
yui-knk d39dcb4370 [ci skip] Fix indent 2016-02-11 20:13:26 +09:00
yui-knk ea9a99541a [ci skip] Update license year 2016-02-11 20:13:00 +09:00
yui-knk f48f6e01b5 Merge pull request #4 from yui-knk/fix_test_script
Reform build process on travis ci
2016-02-11 20:03:23 +09:00
yui-knk 604fd5c437 Reform build process on travis ci
* Change to create "mruby" directory in a repository
* Create Rakefile and use it in .travis.yml
  This enable us to write build script with Ruby syntax
2016-02-11 19:53:48 +09:00
yui-knk befc5a4d83 Merge pull request #1 from takahashim/add-dependency
add add_dependency
2016-02-05 01:38:39 +09:00
Tomoyuki Sahara b4415207ff Merge pull request #2 from kazuho/kazuho/mrbint64
cast `mrb_int` to `int` before applying sprintf "%d"
2016-01-07 13:24:03 +09:00
Kazuho Oku b14df08be6 cast mrb_int to int before applying sprintf "%d" 2016-01-06 12:10:21 +09:00
Tomoyuki Sahara b64c701c64 Merge pull request #11 from takahashim/fix-win-test
fix test for windows
2015-12-03 16:45:25 +09:00
takahashim 71f21845ca fix test for windows
* _mkdir() has only one argument
* use mktemp && mkdir instead of mkdtemp
* use _getcwd instead of P_tmpdir (sandbox is on current dir)
* test for Dir#tell and Dir#seek: skip when NotImplementedError
2015-12-03 15:48:37 +09:00
Tomoyuki Sahara 66c6f8b9d1 Merge pull request #10 from takahashim/notimplemented
use NotImplementedError instead of RuntimeError for Win
2015-12-03 15:32:13 +09:00
takahashim 6140cb158d use NotImplementedError instead of RuntimeError for Win 2015-12-03 15:25:12 +09:00
Tomoyuki Sahara d98ecabd90 Merge pull request #9 from takahashim/enable_test
add conf.enable_test into build_config.rb
2015-12-03 09:51:36 +09:00
takahashim 3501af9ba2 add conf.enable_test into build_config.rb 2015-12-03 00:10:19 +09:00
takahashim 7584d49aa3 add add_dependency 2015-09-13 15:16:28 +09:00
Tomoyuki Sahara 49f6fa51d9 Merge pull request #8 from joans321/master
disable dir_seek and dir_tell on android platform
2015-08-13 20:19:58 +09:00
xuejianqing 6e30353dfd disable dir_seek and dir_tell on android platform 2015-08-13 17:33:45 +08:00
Tomoyuki Sahara 444abbe5f9 Merge pull request #7 from furunkel/master
Use _WIN32 and _WIN64 to detect Windows instead of RUBY_PLATFORM
2015-06-02 09:27:33 +09:00
furunkel 9eec22cda1 Add missing declarations 2015-06-01 21:16:25 +02:00
furunkel 5542f7b0fc Use _WIN32 and _WIN64 to detect Windows instead of RUBY_PLATFORM 2015-06-01 21:06:59 +02:00
Tomoyuki Sahara dfb471b40b type of 2nd argument was changed. 2014-09-19 13:49:39 +09:00
Tomoyuki Sahara f7a0946452 mrb_const_defined returns true if it is defined on a super class. 2014-09-19 13:22:56 +09:00
Tomoyuki Sahara 37105ef13b Merge pull request #1 from cremno/patch-1
use mrb_basic_ptr instead of obsolete mrb_basic
2014-09-01 09:29:31 +09:00
cremno baba54fb49 use mrb_basic_ptr instead of obsolete mrb_basic 2014-08-29 16:41:11 +02:00
yui-knk 93e1d2b992 implemente Set#divide (with 1 arity block) 2014-08-03 23:40:05 +09:00
yui-knk 93a8b08f59 implement #classify 2014-08-03 13:06:30 +09:00
yui-knk a442f232e9 Refactor #flatten_merge
Not to unnecessary recursive search.
2014-08-03 12:52:29 +09:00
yui-knk 0d89802877 fix typo 2014-08-03 12:50:51 +09:00
yui-knk 7861034bcf add test case to #flatten 2014-08-03 12:50:23 +09:00
yui-knk 2836acf045 implement flatten_merge, flatten, flatten! 2014-08-03 12:45:54 +09:00
yui-knk dd10f722ad Delete unused code in .h .c 2014-07-24 08:39:47 +09:00
yui-knk 4f73ff51e2 Add not implemented methods to README.md 2014-07-24 08:35:42 +09:00
yui-knk b4e4d98125 Add some comment outed methods
+ classify
+ divide
2014-07-24 08:29:45 +09:00
yui-knk 5e10c11662 Comment out some method
+ freeze
+ taint
+ untaint
2014-07-24 08:27:48 +09:00
yui-knk fad2bd9617 Add example to README.md 2014-07-24 08:22:22 +09:00
yui-knk 500bd30d6c Initial commit 2014-07-24 08:15:57 +09:00
Tomoyuki Sahara 6cc24d0793 add tests for #tell and #seek. 2014-06-20 15:25:10 +09:00
Tomoyuki Sahara 193c82174f P_tmpdir does not have trailing / on Linux. 2014-06-17 11:47:16 +09:00
Tomoyuki Sahara 14e325348b copy-and-paste bug... 2014-06-17 11:37:57 +09:00
Tomoyuki Sahara 0d378be34e tests and documentation. 2014-06-17 11:33:10 +09:00
Tomoyuki Sahara 546d923e67 Merge pull request #5 from windwiny/patch-1
compatible 32 bit windows
2014-05-09 01:56:46 +09:00
windwiny 627282a5f6 compatible 32 bit windows 2014-05-07 20:43:12 +08:00
Akira Yumiyama 536e83614d Update .travis.yml 2014-04-04 11:31:28 +09:00
Akira Yumiyama 2a0423c11d Update .travis.yml 2014-04-04 11:30:38 +09:00
Akira Yumiyama 06b4dd56a4 Create .travis.yml 2014-04-04 11:24:52 +09:00
Akira Yumiyama a252681f39 Create .travis.yml 2014-04-04 11:24:07 +09:00
Tomoyuki Sahara 4800836dd4 On Windows platforms, users must agree on addional license. 2014-03-14 10:06:14 +09:00
Tomoyuki Sahara dc17037349 Merge pull request #3 from pbosetti/master
Can Build with VisualStudio
2014-03-14 09:45:44 +09:00
Tomoyuki Sahara c0abfaf69d catch up with mrb_class_get API change. 2014-02-13 16:32:52 +09:00
Paolo Bosetti 9768535582 Made compatible with VisualStudio 2013-12-10 14:33:36 +01:00
Tomoyuki Sahara 09d51f46a7 mrb_intern API change. 2013-12-03 10:06:32 +09:00
Paolo Bosetti d7e880d9b9 Fix for compilation under Win/MinGW 2013-12-02 12:15:21 +01:00
Akira Yumiyama a036be21bc fix chdir (pass the current directory) 2013-11-16 14:37:21 +09:00
Akira Yumiyama 12dce91db8 support Dir.chdir with block 2013-11-16 14:28:40 +09:00
Akira Yumiyama 797c1cc178 Merge pull request #2 from syuu1228/chdir
add Dir.chdir
2013-11-15 20:50:01 -08:00
Takuya ASADA 0380865a55 add chdir 2013-11-14 03:08:43 -08:00
Tomoyuki Sahara 487ab66ea0 ARGS_XXX macros was renamed to MRG_ARGS_XXX. 2013-08-21 09:23:56 +09:00
Tomoyuki Sahara 09ea0586ee catch up with DATA API changes. 2013-08-20 17:27:10 +09:00
Akira Yumiyama 838e4f975d add run_test.rb, .gitignore 2013-05-02 23:57:20 +09:00
Akira Yumiyama 5903e2f3bf rename mrb_class_obj_get -> mrb_class_get 2013-05-02 23:56:52 +09:00
Akira Yumiyama ee4fef5127 update run_test.rb 2013-05-02 23:38:50 +09:00
Akira Yumiyama 57296298e9 put MRB_ prefix before ARGS_XXX macros 2013-04-27 09:46:11 +09:00
Tomoyuki Sahara db5e3af473 mrb_str_new2 -> mrb_str_new_cstr 2013-04-09 15:47:12 +09:00
Akira Yumiyama 104b69d943 rename mrb_str_new2 -> mrb_str_new_cstr 2013-03-13 22:28:06 +09:00
Tomoyuki Sahara e56d53e354 Errno module for mruby. 2013-03-13 10:00:22 +09:00
Tomoyuki Sahara b6c71e4c68 Initial commit 2013-03-12 00:21:04 -07:00
Akira Yumiyama 5e296b24f3 remove Makefile 2013-03-06 12:59:19 +09:00
Akira Yumiyama 221296cb55 update README.md 2013-03-06 12:59:03 +09:00
Akira Yumiyama 1cde1f24ce fix with mruby/mruby support. 2013-03-06 12:51:04 +09:00
Akira Yumiyama f22a72e754 update README.md 2013-01-30 17:02:54 +09:00
Akira Yumiyama 04d51d9719 add mrbgem test runner 2013-01-30 15:11:53 +09:00
Akira Yumiyama ae5671369e update mrbgem.rake 2013-01-30 15:11:15 +09:00
Akira Yumiyama 6b7e81f75b update mrbgem.rake 2013-01-24 10:18:13 +09:00
Akira Yumiyama 2f486fbccb add mrb_mruby_dir_gem_final 2013-01-24 10:18:05 +09:00
Akira Yumiyama 2e2225e2d3 add mrbgem.rake 2013-01-04 00:19:04 +09:00
Tomoyuki Sahara 92ad6dc8c3 should not ignore Makefile... 2012-12-25 13:44:22 +09:00
Tomoyuki Sahara f210dd553e requires iij/mruby. 2012-12-25 13:34:52 +09:00
Tomoyuki Sahara 7a593bf2d4 Dir class for mruby (from iij/mruby) 2012-12-25 13:32:29 +09:00
Tomoyuki Sahara ca525d5482 Initial commit 2012-12-24 20:11:55 -08:00
269 changed files with 19904 additions and 10880 deletions
+2 -1
View File
@@ -29,9 +29,10 @@ indent_style = space
trim_trailing_whitespace = true
#max_line_length = 120
# limitation to US-ASCII
[*.bat]
charset = latin1
end_of_line = crlf
indent_style = space
#max_line_length = 80
[*.{yaml,yml}]
+2
View File
@@ -2,3 +2,5 @@
6fc5dc986a5ffc1a74c63ad0617ea1dcc10d3cdd
# reformatted doc/opcode.md
61e8a540869c57ebddac53cf9d243db407d57fff
# reindent parse.y
650ffb9d8410e1ae2206890ef6e2a8643c600454
-3
View File
@@ -4,9 +4,6 @@
# MD001 heading-increment/header-increment - Heading levels should only increment by one level at a time
MD001: false
# MD010 no-hard-tabs - Hard tabs
MD010: false
# MD013 line-length - Line length
MD013: false
+24 -128
View File
@@ -2,15 +2,32 @@ name: Build & Test
on: [push, pull_request]
permissions:
contents: read
jobs:
Ubuntu-1804-gcc:
runs-on: ubuntu-18.04
GCC-CLANG:
name: "${{ matrix.os }}-${{ matrix.altname || matrix.cc }}"
runs-on: ${{ matrix.os }}
timeout-minutes: 10
strategy:
fail-fast: false
max-parallel: 8
matrix:
include:
- {os: ubuntu-22.04, cc: gcc, cxx: g++}
- {os: ubuntu-22.04, cc: clang, cxx: clang++}
- {os: ubuntu-20.04, cc: gcc, cxx: g++}
- {os: ubuntu-20.04, cc: clang, cxx: clang++}
- {os: macos-latest, cc: clang, cxx: clang++}
- {os: windows-latest, cc: gcc, cxx: g++, altname: "mingw-gcc"}
env:
MRUBY_CONFIG: ci/gcc-clang
CC: gcc
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
LD: ${{ matrix.cc }}
steps:
- uses: actions/checkout@v2.4.0
- uses: actions/checkout@v3
- name: Ruby version
run: ruby -v
- name: Compiler version
@@ -18,138 +35,17 @@ jobs:
- name: Build and test
run: rake -m test:build && rake test:run
Ubuntu-1804-clang:
runs-on: ubuntu-18.04
timeout-minutes: 10
env:
MRUBY_CONFIG: ci/gcc-clang
CC: clang
steps:
- uses: actions/checkout@v2.4.0
- name: Ruby version
run: ruby -v
- name: Compiler version
run: ${{ env.CC }} --version
- name: Build and test
run: rake -m test:build && rake test:run
Ubuntu-2004-gcc:
runs-on: ubuntu-20.04
timeout-minutes: 10
env:
MRUBY_CONFIG: ci/gcc-clang
CC: gcc
steps:
- uses: actions/checkout@v2.4.0
- name: Ruby version
run: ruby -v
- name: Compiler version
run: ${{ env.CC }} --version
- name: Build and test
run: rake -m test:build && rake test:run
Ubuntu-2004-clang:
runs-on: ubuntu-20.04
timeout-minutes: 10
env:
MRUBY_CONFIG: ci/gcc-clang
CC: clang
steps:
- uses: actions/checkout@v2.4.0
- name: Ruby version
run: ruby -v
- name: Compiler version
run: ${{ env.CC }} --version
- name: Build and test
run: rake -m test:build && rake test:run
macOS:
runs-on: macos-latest
timeout-minutes: 10
env:
MRUBY_CONFIG: ci/gcc-clang
CC: clang
steps:
- uses: actions/checkout@v2.4.0
- name: Ruby version
run: ruby -v
- name: Compiler version
run: ${{ env.CC }} --version
- name: Build and test
run: rake -m test:build && rake test:run
Windows-MinGW:
runs-on: windows-latest
timeout-minutes: 10
env:
MRUBY_CONFIG: ci/gcc-clang
CC: gcc
steps:
- uses: actions/checkout@v2.4.0
- name: Ruby version
run: ruby -v
- name: Compiler version
run: ${{ env.CC }} --version
- name: Build and test
run: rake -m test:build && rake test:run
Windows-Cygwin:
runs-on: windows-latest
timeout-minutes: 15
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
MRUBY_CONFIG: ci/gcc-clang
CC: gcc
installer-path: '%TMP%\cygwin-setup.exe'
cygwin-root: C:\cygwin
package-dir: C:\cygwin-package
cache-version: v1
steps:
- uses: actions/checkout@v2.4.0
- uses: actions/cache@v2.1.7
with:
path: ${{ env.package-dir }}
key: ${{ runner.os }}-cygwin-${{ env.cache-version }}
- name: Download Cygwin installer
shell: cmd
run: >
bitsadmin /transfer download /priority foreground
https://cygwin.com/setup-x86_64.exe ${{ env.installer-path }}
- name: Install Cygwin
shell: cmd
run: >
${{ env.installer-path }}
--quiet-mode --no-shortcuts --no-startmenu --no-desktop --no-admin
--only-site --site http://mirrors.kernel.org/sourceware/cygwin/
--root ${{ env.cygwin-root }}
--local-package-dir ${{ env.package-dir }}
--packages gcc-core,gcc-g++,ruby
- name: Set PATH for Cygwin
run: |
echo '::set-env name=PATH::${{ env.cygwin-root }}\bin;${{ env.cygwin-root }}\usr\bin'
- name: Ruby version
shell: cmd
run: ruby -v
- name: Compiler version
run: ${{ env.CC }} --version
- name: Build and test
shell: cmd
run: ruby /usr/bin/rake -m test:build && ruby /usr/bin/rake test:run
- name: Set PATH for cache archiving (tar)
# set Windows path so that Cygwin tar is not used for cache archiving
run: echo '::set-env name=PATH::C:\windows\System32'
Windows-VC:
runs-on: windows-latest
runs-on: windows-2022
timeout-minutes: 10
env:
MRUBY_CONFIG: ci/msvc
steps:
- uses: actions/checkout@v2.4.0
- uses: actions/checkout@v3
- name: Ruby version
run: ruby -v
- name: Build and test
shell: cmd
run: |
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
rake -m test:build && rake test:run
+14 -7
View File
@@ -1,19 +1,26 @@
name: "Code scanning - action"
name: Code scanning - action
on:
push:
branches-ignore:
- dependabot/**
pull_request:
schedule:
- cron: '0 19 * * 4'
permissions:
contents: read
jobs:
CodeQL-Build:
permissions:
actions: read # for github/codeql-action/init to get workflow details
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/autobuild to send a status report
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2.4.0
uses: actions/checkout@v3
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
@@ -21,7 +28,7 @@ jobs:
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
# Override language selection by uncommenting this and choosing your languages
# with:
# languages: go, javascript, csharp, python, cpp, java
@@ -29,7 +36,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v2
# ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
@@ -43,4 +50,4 @@ jobs:
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2
+9 -5
View File
@@ -2,29 +2,33 @@ name: Lint
on: [pull_request]
permissions:
contents: read
jobs:
misspell:
name: Check spelling with misspell
runs-on: ubuntu-latest
steps:
- name: Check Out
uses: actions/checkout@v2.4.0
uses: actions/checkout@v3
- name: Install
run: wget -O - -q https://git.io/misspell | sh -s -- -b .
- name: Misspell
- name: Run misspell
run: git ls-files --empty-directory | xargs ./misspell -error
pre-commit:
name: Run pre-commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.4.0
- name: Check merge conflict
- name: Check Out
uses: actions/checkout@v3
- name: Install
run: |
python -m pip install --upgrade pip
pip install pre-commit
- name: Set PY
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
- uses: actions/cache@v2.1.7
- uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
+4 -1
View File
@@ -1,5 +1,8 @@
name: CIFuzz
on: [pull_request]
permissions:
contents: read
jobs:
Fuzzing:
runs-on: ubuntu-latest
@@ -16,7 +19,7 @@ jobs:
fuzz-seconds: 600
dry-run: false
- name: Upload Crash
uses: actions/upload-artifact@v2.3.1
uses: actions/upload-artifact@v3
if: failure()
with:
name: artifacts
+17 -9
View File
@@ -1,23 +1,31 @@
name: Super Linter
name: Super-Linter
on:
push:
branches-ignore: [master]
# Remove the line above to run when pushing to master
pull_request:
branches: [master]
on: [pull_request]
permissions:
contents: read
jobs:
build:
permissions:
contents: read # for actions/checkout to fetch code
statuses: write # for github/super-linter/slim to mark status of each linter run
name: Lint Code Base
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.4.0
- uses: github/super-linter@v4.8.5
- name: Checkout Code
uses: actions/checkout@v3
with:
# Full git history is needed to get a proper list of changed files within `super-linter`
fetch-depth: 0
- name: Lint Code Base
uses: github/super-linter/slim@v4.10.1
env:
ERROR_ON_MISSING_EXEC_BIT: true
VALIDATE_BASH: true
# VALIDATE_BASH_EXEC: true
# VALIDATE_EDITORCONFIG: true
# VALIDATE_SHELL_SHFMT: true
DEFAULT_BRANCH: master
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VALIDATE_ALL_CODEBASE: false
+20 -10
View File
@@ -3,20 +3,21 @@ default_stages: [commit, push]
default_language_version:
# force all unspecified Python hooks to run python3
python: python3
minimum_pre_commit_version: "1.20.0"
minimum_pre_commit_version: '2.18.1'
repos:
- repo: meta
hooks:
- id: identity
- id: check-hooks-apply
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
rev: v4.4.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-executables-have-shebangs
exclude: ^test/t/lang\.rb$
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-vcs-permalinks
- id: check-yaml
- id: detect-private-key
@@ -26,20 +27,29 @@ repos:
- id: fix-byte-order-marker
- id: mixed-line-ending
- id: trailing-whitespace
# - repo: git://github.com/Lucas-C/pre-commit-hooks
# rev: v1.1.9
# hooks:
# - id: forbid-tabs
# - id: remove-tabs
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.3.1
hooks:
- id: forbid-tabs
exclude: Makefile$|Makefile\..+$|makefile$|\.mk$
- id: remove-tabs
args: [--whitespaces-count, '2']
exclude: Makefile$|Makefile\..+$|makefile$|\.mk$
- repo: https://github.com/codespell-project/codespell
rev: v2.1.0
rev: v2.2.2
hooks:
- id: codespell
name: Run codespell
description: Check spelling with codespell
entry: codespell --ignore-words=codespell.txt
- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 3.0.0
hooks:
- id: script-must-not-have-extension
name: Local policy is to exclude extension from all shell files
types: [shell]
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.30.0
rev: v0.33.0
hooks:
- id: markdownlint
name: Run markdownlint
@@ -48,7 +58,7 @@ repos:
types: [markdown]
files: \.(md|mdown|markdown)$
- repo: https://github.com/adrienverge/yamllint
rev: v1.26.3
rev: v1.28.0
hooks:
- id: yamllint
name: Run yamllint
+8 -2
View File
@@ -11,7 +11,13 @@ mrbgems/*/src/**/*.c
mrbgems/*/mrblib/**/*.rb
mrbgems/*/include/**/*.h
-
AUTHORS
LICENSE
CONTRIBUTING.md
SECURITY.md
TODO.md
doc/*.md
doc/guides/*.md
doc/internal/*.md
AUTHORS
LEGAL
LICENSE
NEWS
+35 -24
View File
@@ -1,48 +1,49 @@
# Authors of mruby (mruby developers)
## The List of Contributors sorted by number of commits (as of 2022-01-10 69b1667)
## The List of Contributors sorted by number of commits (as of 2022-01-08 4462e3d)
7956 Yukihiro "Matz" Matsumoto (@matz)*
8860 Yukihiro "Matz" Matsumoto (@matz)*
586 KOBAYASHI Shuji (@shuujii)
376 Daniel Bovensiepen (@bovi)
441 dearblue (@dearblue)*
378 Daniel Bovensiepen (@bovi)*
346 Takeshi Watanabe (@take-cheeze)*
342 dearblue (@dearblue)*
334 Masaki Muranaka (@monaka)
298 Tomoyuki Sahara (@tsahara)*
328 Tomoyuki Sahara (@tsahara)*
234 Jun Hiroe (@suzukaze)
219 Cremno (@cremno)*
208 Yuki Kurihara (@ksss)+
148 Yasuhiro Matsumoto (@mattn)*
220 Cremno (@cremno)*
209 Yuki Kurihara (@ksss)+
151 Yasuhiro Matsumoto (@mattn)*
113 Carson McDonald (@carsonmcdonald)
113 John Bampton (@jbampton)
103 Tomasz Dąbrowski (@dabroz)*
84 Akira Yumiyama (@akiray03)*
84 skandhas (@skandhas)
80 Masamitsu MURASE (@masamitsu-murase)
74 Yuichiro MASUI (@masuidrive)
73 Hiroshi Mimaki (@mimaki)*
71 Tatsuhiko Kubo (@cubicdaiya)*
68 Hiroshi Mimaki (@mimaki)*
63 Akira Yumiyama (@akiray03)*
62 Paolo Bosetti (@pbosetti)*
65 Yuichiro Kaneko (@yui-knk)+
64 Paolo Bosetti (@pbosetti)*
59 Kurebayashi, Takahiro (@crimsonwoods)*
56 h2so5 (@h2so5)
52 Ralph Desir (@Mav7)*
49 John Bampton (@jbampton)
45 Rory O'Connell (@RoryO)*
43 Yuichiro Kaneko (@yui-knk)+
42 fleuria (@flaneur2020)
40 Christopher Aue (@christopheraue)
40 Seba Gamboa (@sagmor)
38 Koji Yoshioka (@kyab)*+
38 Kouhei Sutou (@kou)*
32 Masayoshi Takahashi (@takahashim)+
31 MATSUMOTO Ryosuke (@matsumotory)*
30 Nobuyoshi Nakada (@nobu)
28 Masayoshi Takahashi (@takahashim)+
24 Julian Aron Prenner (@furunkel)*
26 Julian Aron Prenner (@furunkel)*
24 Ryan Scott (@ryan-scott-dev)*
22 Clayton Smith (@clayton-shopify)
22 Uchio Kondo (@udzura)*
22 Zachary Scott (@zzak)*
22 mirichi (@mirichi)
21 Jared Breeden (@jbreeden)*
20 Uchio Kondo (@udzura)*
21 Ryan Lopopolo (@lopopolo)
19 Bouke van der Bijl (@bouk)
19 Felix Jones (@felixjones)*
19 Hidetaka Takano (@TJ-Hidetaka-Takano)
@@ -50,13 +51,13 @@
18 Corey Powell (@IceDragon200)
18 Jon Maken (@jonforums)+
18 Mitchell Blank Jr (@mitchblank)*
17 Ryan Lopopolo (@lopopolo)
16 bggd (@bggd)
16 kano4 (@kano4)
14 Blaž Hrastnik (@archseer)*
14 Jose Narvaez (@goyox86)
14 Kazuki Tsujimoto (@k-tsj)
14 Tadashi FUKUZAWA (@FUKUZAWA-Tadashi)+
14 fn ⌃ ⌥ (@FnControlOption)
13 Patrick Hogan (@pbhogan)
12 Akira Kuroda (@akuroda)
12 Kouki Ooyatsu (kaishuu0123)*
@@ -66,10 +67,10 @@
12 Ukrainskiy Sergey (@ukrainskiysergey)
12 Xuejie "Rafael" Xiao (@xxuejie)*
11 Julien Ammous (@schmurfy)
11 Kazuho Oku (@kazuho)
11 Seeker (@SeekingMeaning)
11 YAMAMOTO Masaya (pandax381)
11 takkaw (@takkaw)
10 Kazuho Oku (@kazuho)
10 Miura Hideki (@miura1729)
10 Narihiro Nakamura (@authorNari)
10 Ray Chason (@chasonr)*
@@ -95,18 +96,22 @@
6 Kenji Okimoto (@okkez)+
6 Selman ULUG (@selman)
6 Yusuke Endoh (@mame)*
5 Chris Reuter (@suetanvil)
5 Davide D'Agostino (@DAddYE)
5 Eric Hodel (@drbrain)
5 Hendrik (@Asmod4n)
5 Ichito Nagata (@i110)
5 Keita Obo (@ktaobo)*
5 Max Anselm (@silverhammermba)
5 Rodrigo Malizia (@rmalizia44)+
5 SiZiOUS (@sizious)
5 Syohei YOSHIDA (@syohex)
5 TOMITA Masahiro (@tmtm)
5 Yurie Yamane (@yurie)+
5 dreamedge (@dreamedge)
5 masahino (@masahino)
5 nkshigeru (@nkshigeru)
5 xuejianqing (@joans321)
4 Dante Catalfamo (@dantecatalfamo)
4 Goro Kikuchi (@gorogit)
4 Herwin Weststrate (@herwinw)
@@ -121,26 +126,26 @@
4 Yuhei Okazaki (@Yuuhei-Okazaki)*
4 Yuji Yamano (@yyamano)
4 kurodash (@kurodash)*
4 masahino (@masahino)
4 wanabe (@wanabe)*
4 xuejianqing (@joans321)
3 Anton Davydov (@davydovanton)
3 Carlo Prelz (@asfluido)*
3 David Turnbull (@AE9RB)
3 Franck Verrot (@franckverrot)
3 HASUMI Hitoshi (@hasumikin)
3 Horimoto Yasuhiro (@komainu8)
3 J. Mutua (@katmutua)+
3 Jan Berdajs (@mrbrdo)
3 Jonas Minnberg (@sasq64)
3 Joseph McCullough (@joequery)
3 Mark McCurry (@fundamental)
3 Nobuhiro Iwamatsu (@iwamatsu)
3 Per Lundberg (@perlun)*
3 Rob Fors (@robfors)*
3 Rodrigo Malizia (@rmalizia44)+
3 Sebastián Katzer (@katzer)*
3 Shouji Kuboyama (@Shokuji)*
3 Shuta Kimura (@kimushu)+
3 TERAJIMA, Motoyuki (@trmmy)
3 Taichi AOKI (@aoki1980taichi)
3 Takashi Kokubun (@k0kubun)
3 Tatsuhiro Tsujikawa (@tatsuhiro-t)
3 Thiago Scalone (@scalone)
@@ -148,6 +153,7 @@
3 William Light (@wrl)
3 bamchoh (@bamchoh)
3 sasaki takeru (@takeru)
3 windwiny (@windwiny)
2 Akira Moroo (@retrage)
2 Artur K (@nemerle)
2 Christian Mauceri (@mauceri)
@@ -158,7 +164,6 @@
2 Francois Chagnon (@EiNSTeiN-)*
2 Gilad Zohari (@gzohari)
2 Go Saito (@govm)
2 HASUMI Hitoshi (@hasumikin)
2 Hirohito Higashi (@HirohitoHigashi)
2 Hiroyuki Iwatsuki (@iwadon)
2 Huei-Horng Yo (@hiroshiyui)
@@ -188,15 +193,14 @@
2 Yutaka HARA (@yhara)*+
2 Zhang Xiaohui (@hifoolno)
2 icm7216 (@icm7216)
2 windwiny (@windwiny)
1 A-Sat (@asatou)+
1 Abinoam Praxedes Marques Junior (@abinoam)
1 Alex Wang (@nanamiwang)+
1 Andrew Nordman (@cadwallion)
1 Ashish Kurmi (@boahc077)
1 Atsushi Morimoto (@mynz)
1 Ben A Morgan (@BenMorganIO)
1 Benoit Daloze (@eregon)
1 Chris Reuter (@suetanvil)
1 Daehyub Kim (@lateau)
1 Daniel Varga (@vargad)
1 Edgar Boda-Majer (@eboda)
@@ -205,6 +209,8 @@
1 Francis Bogsanyi (@fbogsany)
1 Guo Xiao (@guoxiao)
1 Gwen Boatrite (@boatrit)
1 Gwendolyn Boatrite (@boatrite)
1 HARADA Makoto (@haramako)
1 HAYASHI Kentaro (@kenhys)
1 Hiroki Mori (@yamori813)+
1 Hiromasa Ishii (@Hir0)+
@@ -225,6 +231,7 @@
1 Kazuhiro NISHIYAMA (@znz)
1 Kei Sawada (@remore)
1 Kim H Madsen (@kimhmadsen)
1 Koichi ITO (@koic)
1 Konstantin Haase (@rkh)
1 Leo Neat (@Leo-Neat)
1 Lian Cheng (@liancheng)
@@ -253,13 +260,17 @@
1 Robert Rowe (@CaptainJet)
1 Ryan Scott Lewis (@RyanScottLewis)
1 Ryo Okubo (@syucream)
1 SAkira a.k.a. Akira Suzuki (@sakisakira)
1 Santiago Rodriguez (@sanrodari)
1 Satoh, Hiroh (@cho45)+
1 Sayed Abdelhaleem (@visualsayed)
1 Sergey Ukrainskiy (@ukrainskiysergey)
1 Shugo Maeda (@shugo)
1 Sorah Fukumori (@sorah)
1 Stephen Jothen (@sjothen)
1 Stuart Hinson (@stuarth)
1 Takuma Kume (@takumakume)+
1 Takuya ASADA (@syuu1228)
1 Thomas Schmidt (@digitaltom)
1 Timo Schilling (@timoschilling)
1 Tom Black (@blacktm)
+39 -13
View File
@@ -8,14 +8,14 @@ Contributors agree to license their contribution(s) under MIT license.
To make it easy to review and understand your change please keep the following
things in mind before submitting your pull request:
* Work on the latest possible state of **mruby/master**
* Create a branch which is dedicated to your change
* Test your changes before creating a pull request (`rake test`)
* If possible write a test case which confirms your change
* Don't mix several features or bug-fixes in one pull request
* Create a meaningful commit message
* Explain your change (i.e. with a link to the issue you are fixing)
* Use mrbgem to provide non ISO features (classes, modules and methods) unless
- Work on the latest possible state of **mruby/master**
- Create a branch which is dedicated to your change
- Test your changes before creating a pull request (`rake test`)
- If possible write a test case which confirms your change
- Don't mix several features or bug-fixes in one pull request
- Create a meaningful commit message
- Explain your change (i.e. with a link to the issue you are fixing)
- Use mrbgem to provide non ISO features (classes, modules and methods) unless
you have a special reason to implement them in the core
## pre-commit
@@ -33,9 +33,22 @@ To run a single hook use `pre-commit run --all-files <hook_id>`
To update use `pre-commit autoupdate`
* [Quick start](https://pre-commit.com/#quick-start)
* [Usage](https://pre-commit.com/#usage)
* [pre-commit-autoupdate](https://pre-commit.com/#pre-commit-autoupdate)
Sometimes you might need to skip one or more hooks which can be done with the `SKIP` environment variable.
`$ SKIP=yamllint git commit -m "foo"`
For convenience, we have added `pre-commit run --all-files` and `pre-commit autoupdate`
to both the Makefile and the Rakefile. Run them with:
- `make check` or `rake check`
- `make checkupdate` or `rake checkupdate`
### pre-commit quick links
- [Quick start](https://pre-commit.com/#quick-start)
- [Usage](https://pre-commit.com/#usage)
- [pre-commit autoupdate](https://pre-commit.com/#pre-commit-autoupdate)
- [Temporarily disabling hooks](https://pre-commit.com/#temporarily-disabling-hooks)
## Spell Checking
@@ -50,8 +63,8 @@ find . -type f | xargs ./misspell -error
Notable `misspell` help options or flags are:
* `-i` string: ignore the following corrections, comma separated
* `-w`: Overwrite file with corrections (default is just to display)
- `-i` string: ignore the following corrections, comma separated
- `-w`: Overwrite file with corrections (default is just to display)
## Coding conventions
@@ -101,3 +114,16 @@ language itself. Please note the following hints for your Ruby code:
mruby is currently targeting to execute Ruby code which complies to ISO/IEC
30170:2012 (<https://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=59579>),
unless there's a clear reason, e.g. the latest Ruby has changed behavior from ISO.
## Building documentation
### mruby API
- [YARD](https://yardoc.org/) - YARD is a documentation generation tool for the Ruby programming language
- [yard-mruby](https://rubygems.org/gems/yard-mruby) - Document MRuby sources with YARD
- [yard-coderay](https://rubygems.org/gems/yard-coderay) - Adds coderay syntax highlighting to YARD docs
### C API
- [Doxygen](https://www.doxygen.nl/) - Generate documentation from source code
- [Graphviz](https://graphviz.org/) - Graphviz is open source graph visualization software
+11 -4
View File
@@ -6,7 +6,7 @@
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = "mruby"
PROJECT_NUMBER = 3.0.0
PROJECT_NUMBER = 3.1.0
PROJECT_BRIEF = "mruby is the lightweight implementation of the Ruby language"
@@ -16,13 +16,20 @@ OUTPUT_DIRECTORY = doc/capi
USE_MDFILE_AS_MAINPAGE = README.md
INPUT = README.md \
INPUT = CONTRIBUTING.md \
README.md \
SECURITY.md \
TODO.md \
src \
include \
include/mruby \
mrblib \
doc \
doc/guides
doc/guides \
doc/internal \
LEGAL \
LICENSE \
NEWS
# Red for Ruby
HTML_COLORSTYLE_HUE = 359
@@ -275,7 +282,7 @@ OPTIMIZE_OUTPUT_VHDL = NO
# Note that for custom extensions you also need to set FILE_PATTERNS otherwise
# the files are not read by doxygen.
EXTENSION_MAPPING =
EXTENSION_MAPPING = no_extension=md
# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments
# according to the Markdown format, which allows for more readable
+35
View File
@@ -3,3 +3,38 @@ LEGAL NOTICE INFORMATION
All the files in this distribution are covered under the MIT license
(see the file LICENSE) except some files mentioned below:
- src/readfloat.c: public domain by Yasuhiro Matsumoto (@mattn)
- src/fmt_fp.c: public domain by Dave Hylands (@dhylands)
- mrbgems/mruby-dir/src/Win/dirent.c: MIT-like license by Kevlin Henney
[src/readfloat.c]
strtod implementation.
author: Yasuhiro Matsumoto (@mattn)
license: public domain
The original code can be found in https://github.com/mattn/strtod
[src/fmt_fp.c]
The code in this function was inspired from Fred Bayer's pdouble.c.
Since pdouble.c was released as Public Domain, I'm releasing this
code as public domain as well.
Dave Hylands
The original code can be found in https://github.com/dhylands/format-float
[mrbgems/mruby-dir/src/Win/dirent.c] used only for Windows platform
Copyright Kevlin Henney, 1997, 2003, 2012. All rights reserved.
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose is hereby granted without fee, provided
that this copyright and permissions notice appear in all copies and
derivatives.
This software is supplied "as is" without express or implied warranty.
But that said, if there are any problems please get in touch.
+1 -1
View File
@@ -1,4 +1,4 @@
Copyright (c) 2010-2021 mruby developers
Copyright (c) 2010-2022 mruby developers
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
+8
View File
@@ -13,3 +13,11 @@ test : all
clean :
$(RAKE) clean
.PHONY : clean
check :
pre-commit run --all-files
.PHONY : check
checkupdate :
pre-commit autoupdate
.PHONY : checkupdate
+2 -1
View File
@@ -1,4 +1,5 @@
* NEWS
NEWS
----
This document is a list of user visible feature changes made between
releases except for bug fixes.
+16 -12
View File
@@ -1,17 +1,17 @@
# mruby
[![Build Status][build-status-img]][travis-ci]
[![GitHub Super-Linter](https://github.com/mruby/mruby/workflows/Lint%20Code%20Base/badge.svg)](https://github.com/marketplace/actions/super-linter)
## What is mruby
mruby is the lightweight implementation of the Ruby language complying to (part
of) the [ISO standard][ISO-standard]. Its syntax is Ruby 2.x compatible.
of) the [ISO standard][ISO-standard] with more recent features provided by Ruby 3.x.
Also, its syntax is Ruby 3.x compatible except for pattern matching.
mruby can be linked and embedded within your application. We provide the
mruby can be linked and embedded within your application. We provide the
interpreter program "mruby", and the interactive mruby shell "mirb" as examples.
You can also compile Ruby programs into compiled byte code using the mruby
compiler "mrbc". All those tools reside in the "bin" directory. "mrbc" is
compiler "mrbc". All those tools reside in the "bin" directory. "mrbc" is
also able to generate compiled byte code in a C source file, see the "mrbtest"
program under the "test" directory for an example.
@@ -20,7 +20,7 @@ of the Ministry of Economy, Trade and Industry of Japan.
## How to get mruby
The release candidate version 3.1.0 of mruby can be downloaded via the following URL: [https://github.com/mruby/mruby/archive/3.1.0-rc2.zip](https://github.com/mruby/mruby/archive/3.1.0-rc2.zip)
The release candidate version 3.2.0 of mruby can be downloaded via the following URL: [https://github.com/mruby/mruby/archive/3.2.0-rc2.zip](https://github.com/mruby/mruby/archive/3.2.0-rc2.zip)
The latest development version of mruby can be downloaded via the following URL: [https://github.com/mruby/mruby/zipball/master](https://github.com/mruby/mruby/zipball/master)
@@ -43,11 +43,17 @@ We don't have a mailing list, but you can use [GitHub issues](https://github.com
## How to compile, test, and install (mruby and gems)
See the [compile.md](doc/guides/compile.md) file.
For the simplest case, type
```
rake all test
```
See the [compile.md](doc/guides/compile.md) file for the detail.
## Building documentation
There are two sets of documentation in mruby: the mruby API (generated by yard) and C API (Doxygen)
There are two sets of documentation in mruby: the mruby API (generated by yard) and C API (Doxygen and Graphviz)
To build both of them, simply go
@@ -67,7 +73,7 @@ rake view_capi
mruby contains a package manager called *mrbgems*. To create extensions
in C and/or Ruby you should create a *GEM*. For a documentation of how to
use mrbgems consult the file [mrbgems.md](doc/guides/mrbgems.md).
For example code of how to use mrbgems look into the folder *examples/mrbgems/*.
For example code of how to use mrbgems look into the folder [examples/mrbgems/](examples/mrbgems).
## License
@@ -79,7 +85,7 @@ mruby has chosen a MIT License due to its permissive license allowing
developers to target various environments such as embedded systems.
However, the license requires the display of the copyright notice and license
information in manuals for instance. Doing so for big projects can be
complicated or troublesome. This is why mruby has decided to display "mruby
complicated or troublesome. This is why mruby has decided to display "mruby
developers" as the copyright name to make it simple conventionally.
In the future, mruby might ask you to distribute your new code
(that you will commit,) under the MIT License as a member of
@@ -93,10 +99,8 @@ Please ask us if you want to distribute your code under another license.
## How to Contribute
See the [contribution guidelines][contribution-guidelines], and then send a pull
request to <https://github.com/mruby/mruby>. We consider you have granted
request to <https://github.com/mruby/mruby>. We consider you have granted
non-exclusive right to your contributed code under MIT license.
[ISO-standard]: https://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=59579
[build-status-img]: https://travis-ci.org/mruby/mruby.svg?branch=master
[contribution-guidelines]: https://github.com/mruby/mruby/blob/master/CONTRIBUTING.md
[travis-ci]: https://travis-ci.org/mruby/mruby
+38 -1
View File
@@ -1,4 +1,3 @@
# encoding: utf-8
# Build description.
# basic build file for mruby
MRUBY_ROOT = File.dirname(File.expand_path(__FILE__))
@@ -67,3 +66,41 @@ task :deep_clean => %w[clean doc:clean] do
end
puts "Cleaned up mrbgems build folder"
end
PREFIX = ENV['PREFIX'] || ENV['INSTALL_PREFIX'] || '/usr/local'
desc "install compiled products"
task :install => :install_bin do
if host = MRuby.targets['host']
install_D host.libmruby_static, File.join(PREFIX, "lib", File.basename(host.libmruby_static))
# install mruby.h and mrbconf.h
Dir.glob(File.join(MRUBY_ROOT, "include", "*.h")) do |src|
install_D src, File.join(PREFIX, "include", File.basename(src))
end
Dir.glob(File.join(MRUBY_ROOT, "include", "mruby", "*.h")) do |src|
install_D src, File.join(PREFIX, "include", "mruby", File.basename(src))
end
Dir.glob(File.join(File.join(MRUBY_ROOT, "build", "host", "include", "mruby", "presym", "*.h"))) do |src|
install_D src, File.join(PREFIX, "include", "mruby", "presym", File.basename(src))
end
end
end
desc "install compiled executable (on host)"
task :install_bin => :all do
if host = MRuby.targets['host']
Dir.glob(File.join(MRUBY_ROOT, "bin", "*")) do |src|
install_D src, File.join(PREFIX, "bin", File.basename(src))
end
end
end
desc "run all pre-commit hooks against all files"
task :check do
sh "pre-commit run --all-files"
end
desc "check the pre-commit hooks for updates"
task :checkupdate do
sh "pre-commit autoupdate"
end
+9 -7
View File
@@ -6,13 +6,15 @@ If you have any security concern, contact <matz@ruby.or.jp>.
## Scope
We consider following issues as vulnerabilities:
We consider the following issues as vulnerabilities:
* Remote code execution
* Crash caused by a valid Ruby script
- Remote code execution
- Crash caused by a valid Ruby script
We *don't* consider following issues as vulnerabilities:
We *don't* consider the following issues as vulnerabilities:
* Runtime C undefined behavior (including integer overflow)
* Crash caused by misused API
* Crash caused by tweaked compiled binary
- Runtime C undefined behavior (including integer overflow)
- Crash caused by misused API
- Crash caused by modified compiled binary
- ASAN/Valgrind warning for too big memory allocation
mruby assumes `malloc(3)` returns `NULL` for too big allocations
+7 -8
View File
@@ -1,14 +1,13 @@
# Thing to Do in the future
# Things to Do in the future
# After mruby 3.1
* multi-precision integer
* parser and code generator independent from `mrb_state` (picoruby?)
* variable sized AST node
* iv/hash entry cache
* more peephole optimization (if possible)
- parser and code generator independent from `mrb_state` (picoruby?)
- variable sized AST node
- iv/hash entry cache
- more peephole optimization (if possible)
# Things to do (Things we need to consider)
* `begin ... end while cond` to behave as CRuby
* special variables ($1,$2..)
- `begin ... end while cond` to behave as CRuby
- special variables ($1,$2..)
+2 -8
View File
@@ -179,7 +179,7 @@ def clamp(f)
i.to_i
end
def otherBasis(basis, n)
def orthoBasis(basis, n)
basis[2] = Vec.new(n.x, n.y, n.z)
basis[1] = Vec.new(0.0, 0.0, 0.0)
@@ -211,7 +211,7 @@ class Scene
def ambient_occlusion(isect)
basis = Array.new(3)
otherBasis(basis, isect.n)
orthoBasis(basis, isect.n)
ntheta = NAO_SAMPLES
nphi = NAO_SAMPLES
@@ -243,8 +243,6 @@ class Scene
@plane.intersect(ray, occisect)
if occisect.hit
occlusion = occlusion + 1.0
else
0.0
end
end
end
@@ -254,7 +252,6 @@ class Scene
end
def render(w, h, nsubsamples)
cnt = 0
nsf = nsubsamples.to_f
h.times do |y|
w.times do |x|
@@ -263,7 +260,6 @@ class Scene
# Subsampling
nsubsamples.times do |v|
nsubsamples.times do |u|
cnt = cnt + 1
wf = w.to_f
hf = h.to_f
xf = x.to_f
@@ -288,8 +284,6 @@ class Scene
rad.x = rad.x + col.x
rad.y = rad.y + col.y
rad.z = rad.z + col.z
else
0.0
end
end
end
-1
View File
@@ -1,4 +1,3 @@
def fib n
return n if n < 2
fib(n-2) + fib(n-1)
+3 -1
View File
@@ -1,9 +1,11 @@
# from http://www.bagley.org/~doug/shootout/bench/lists/lists.ruby
# which is lost long time ago. The past content can be retrieved from
# https://web.archive.org/web/20040805115204/http://www.bagley.org/~doug/shootout/bench/lists/lists.ruby
NUM = 300
SIZE = 10000
def test_lists()
def test_lists
# create a list of integers (Li1) from 1 to SIZE
li1 = (1..SIZE).to_a
# copy the list to li2 (not by individual items)
+1 -1
View File
@@ -12,7 +12,7 @@ MRuby::CrossBuild.new("Galileo") do |conf|
#ARDUINO_GALILEO_PATH = '/opt/arduino'
GALILEO_BIN_PATH = "#{GALILEO_ARDUINO_PATH}/hardware/tools/x86/i386-pokysdk-darwin/usr/bin/i586-poky-linux-uclibc"
GALILEO_SYSROOT = "#{GALILEO_ARDUINO_PATH}/hardware/tools/x86/i586-poky-linux-uclibc"
GALILEO_SYSROOT = "#{GALILEO_ARDUINO_PATH}/hardware/tools/x86/i586-poky-linux-uclibc"
GALILEO_X86_PATH = "#{GALILEO_ARDUINO_PATH}/hardware/arduino/x86"
+1 -1
View File
@@ -2,7 +2,7 @@
MRuby::CrossBuild.new('android-arm64-v8a') do |conf|
params = {
:arch => 'arm64-v8a',
:platform => 'android-24',
:sdk_version => 26,
:toolchain => :clang,
}
toolchain :android, params
+1 -1
View File
@@ -2,7 +2,7 @@
MRuby::CrossBuild.new('android-armeabi') do |conf|
params = {
:arch => 'armeabi',
:platform => 'android-24',
:sdk_version => 26,
:toolchain => :clang,
}
toolchain :android, params
@@ -4,7 +4,7 @@ MRuby::CrossBuild.new('android-armeabi-v7a-neon-hard') do |conf|
:arch => 'armeabi-v7a',
:mfpu => 'neon',
:mfloat_abi => 'hard',
:platform => 'android-24',
:sdk_version => 26,
:toolchain => :clang,
}
toolchain :android, params
+1 -1
View File
@@ -5,7 +5,7 @@ ints = [64, 32]
boxings.product(bits, ints) do |boxing, bit, int|
MRuby::Build.new("boxing-#{boxing}-m#{bit}-i#{int}") do |conf|
conf.toolchain :gcc
conf.gembox 'default'
conf.gembox 'full-core'
conf.compilers.each do |c|
c.defines << "MRB_#{boxing.upcase}_BOXING"
c.defines << "MRB_INT#{int}"
+7 -8
View File
@@ -1,4 +1,3 @@
# Cross-compile using MinGW and test using Wine.
#
# Steps:
@@ -16,11 +15,11 @@
#
# 4. Confirm that drive 'z:' is mapped to your root filesystem.
# (This is supposed to be a default but it helps to
# double-check.) To confirm, run:
# double-check.) To confirm, run:
#
# wine cmd /c dir 'z:\\'
#
# This should give you a DOS-style equivalent of 'ls /'. If not,
# This should give you a DOS-style equivalent of 'ls /'. If not,
# you'll need to fix that with winecfg or by adding a symlink to
# '~/.wine/dosdevices'.
#
@@ -40,8 +39,8 @@
#
# 1. This works by using a helper script that rewrites test output
# to make it look *nix-like and then handing it back to the test
# cases. Some of the existing tests were (slightly) modified to
# make this easier but only for the 'full-core' gembox. Other
# cases. Some of the existing tests were (slightly) modified to
# make this easier but only for the 'full-core' gembox. Other
# gems' bintests may or may not work with the helper script and
# may or may not be fixable by extending the script.
#
@@ -50,11 +49,11 @@
#
# 3. This script assumes you are running it on a *nix-style OS.
#
# 4. I recommend building 64-bit targets only. Building a 32-bit
# 4. I recommend building 64-bit targets only. Building a 32-bit
# Windows binary with i686-w64-mingw32 seems to work (at least,
# it did for me) but the resulting executable failed a number of
# unit tests due to small errors in some floating point
# operations. It's unclear if this indicates more serious problems.
# unit tests due to small errors in some floating-point
# operations. It's unclear if this indicates more serious problems.
#
+2 -2
View File
@@ -35,7 +35,7 @@ def clean(output, stderr = false)
result_text = results.join("\n")
result_text += "\n" if ends_with_newline
return result_text
result_text
end
@@ -46,7 +46,7 @@ def main
end
# For simplicity, just read all of stdin into memory and pass that
# as an argument when invoking wine. (Skipped if STDIN was not
# as an argument when invoking wine. (Skipped if STDIN was not
# redirected.)
if !STDIN.tty?
input = STDIN.read
+1 -1
View File
@@ -8,7 +8,7 @@ MRuby::Build.new('host') do |conf|
conf.gembox 'full-core'
# C compiler settings
conf.cc.defines = %w(MRB_USE_DEBUG_HOOK MRB_NO_BOXING)
conf.cc.defines = %w(MRB_USE_DEBUG_HOOK MRB_NO_BOXING MRB_UTF8_STRING)
# Generate mruby debugger command (require mruby-eval)
conf.gem :core => "mruby-bin-debugger"
+1 -1
View File
@@ -3,7 +3,7 @@ MRuby::Build.new do |conf|
toolchain :gcc
# include the GEM box
conf.gembox 'default'
conf.gembox 'full-core'
conf.cc.defines << 'MRB_USE_FLOAT32'
+1 -1
View File
@@ -3,7 +3,7 @@ MRuby::Build.new do |conf|
toolchain :gcc
# include the GEM box
conf.gembox 'default'
conf.gembox 'full-core'
conf.cc.flags << '-pg'
conf.linker.flags << '-pg'
+1 -1
View File
@@ -3,7 +3,7 @@ MRuby::Build.new do |conf|
toolchain :gcc
# include the GEM box
conf.gembox 'default'
conf.gembox 'full-core'
conf.cc.flags << '-m32'
conf.linker.flags << '-m32'
+3
View File
@@ -1,8 +1,10 @@
ans
ba
clen
creat
delet
disabl
falsy
filetest
fo
hel
@@ -12,6 +14,7 @@ methid
nd
quitt
remore
ro
runn
sting
upto
+40 -36
View File
@@ -7,17 +7,17 @@ binaries.
To compile mruby out of the source code you need the following tools:
* C Compiler (e.g. `gcc` or `clang`)
* Linker (e.g. `gcc` or `clang`)
* Archive utility (e.g. `ar`)
* Ruby 2.5 or later (e.g. `ruby` or `jruby`)
- C Compiler (e.g. `gcc` or `clang`)
- Linker (e.g. `gcc` or `clang`)
- Archive utility (e.g. `ar`)
- Ruby 2.5 or later (e.g. `ruby` or `jruby`)
Optional:
* Git (to update mruby source and integrate mrbgems easier)
* C++ compiler (to use mrbgems which include `*.cpp`, `*.cxx`, `*.cc`)
* Bison (to compile `mrbgems/mruby-compiler/core/parse.y`)
* gperf (to compile `mrbgems/mruby-compiler/core/keywords`)
- Git (to update mruby source and integrate mrbgems easier)
- C++ compiler (to use mrbgems which include `*.cpp`, `*.cxx`, `*.cc`)
- Bison (to compile `mrbgems/mruby-compiler/core/parse.y`)
- gperf (to compile `mrbgems/mruby-compiler/core/keywords`)
Note that `bison` bundled with macOS is too old to compile `mruby`.
Try `brew install bison` and follow the instruction shown to update
@@ -103,8 +103,8 @@ in `ANDROID_STANDALONE_TOOLCHAIN`.
It is possible to select which tools should be compiled during the compilation
process. For example,
* `mruby`
* `mirb`
- `mruby`
- `mirb`
The configuration are done via `mrbgems`. See `Mrbgems` section.
@@ -332,11 +332,11 @@ conf.enable_debug
When debugging mode is enabled
* Macro `MRB_DEBUG` would be defined.
* Which means `mrb_assert()` macro is enabled.
* Debug information of irep would be generated by `mrbc`.
* Because `-g` flag would be added to `mrbc` runner.
* You can have better backtrace of mruby scripts with this.
- Macro `MRB_DEBUG` would be defined.
- Which means `mrb_assert()` macro is enabled.
- Debug information of irep would be generated by `mrbc`.
- Because `-g` flag would be added to `mrbc` runner.
- You can have better backtrace of mruby scripts with this.
## Cross-Compilation
@@ -401,19 +401,19 @@ root directory. The structure of this directory will look like this:
The compilation workflow will look like this:
* compile minimal `mrbc` from `src` and `mrblib` sources
* compile all files under `src` (object files will be stored in `build/host/mrbc/src`)
* compile `mruby-compiler` gem
* create `build/host/mrbc/lib/libmruby_core.a` out of all object files (C only)
* create `build/host/mrbc/bin/mrbc` via `mruby-bin-mrbc` gem
* compile all files under `src` and store result in `build/host/src`
* create `build/host/mrblib/mrblib.c` by compiling all `*.rb` files under `mrblib` with `build/host/mrbc/bin/mrbc`
* compile `build/host/mrblib/mrblib.c` to `build/host/mrblib/mrblib.o`
* create `build/host/lib/libmruby.a` out of all object files (C and Ruby)
* compile (normal) mrbgems specified in the configuration file
* create `build/host/lib/libmruby.a` from object files from gems and `libmruby_core.a`
* create binary commands according to binary gems (e.g. `mirb` and `mruby`)
* copy binaries under `build/host/bin` to `bin` directory
- compile minimal `mrbc` from `src` and `mrblib` sources
- compile all files under `src` (object files will be stored in `build/host/mrbc/src`)
- compile `mruby-compiler` gem
- create `build/host/mrbc/lib/libmruby_core.a` out of all object files (C only)
- create `build/host/mrbc/bin/mrbc` via `mruby-bin-mrbc` gem
- compile all files under `src` and store result in `build/host/src`
- create `build/host/mrblib/mrblib.c` by compiling all `*.rb` files under `mrblib` with `build/host/mrbc/bin/mrbc`
- compile `build/host/mrblib/mrblib.c` to `build/host/mrblib/mrblib.o`
- create `build/host/lib/libmruby.a` out of all object files (C and Ruby)
- compile (normal) mrbgems specified in the configuration file
- create `build/host/lib/libmruby.a` from object files from gems and `libmruby_core.a`
- create binary commands according to binary gems (e.g. `mirb` and `mruby`)
- copy binaries under `build/host/bin` to `bin` directory
```
_____ _____ ______ ____ ____ _____ _____ ____
@@ -465,13 +465,13 @@ for we don't have `host/mrbc` directory (`host` directory itself works
as placeholder for `mrbc`). Afterwards the cross compilation process
proceeds like this:
* cross-compile all files under `src` and store result in `build/i386/src`
* create `build/i386/lib/libmruby_core.a` out of C object files
* create `build/i386/mrblib/mrblib.c` by compiling all `*.rb` files under `mrblib` with native `build/host/bin/mrbc`
* cross-compile `build/i386/mrblib/mrblib.c` to `build/i386/mrblib/mrblib.o`
* create `build/i386/lib/libmruby.a` from object files from gems and `libmruby_core.a`
* create binary commands according to binary gems (e.g. `mirb` and `mruby`)
* copy binaries under `build/host/bin` to `bin` directory
- cross-compile all files under `src` and store result in `build/i386/src`
- create `build/i386/lib/libmruby_core.a` out of C object files
- create `build/i386/mrblib/mrblib.c` by compiling all `*.rb` files under `mrblib` with native `build/host/bin/mrbc`
- cross-compile `build/i386/mrblib/mrblib.c` to `build/i386/mrblib/mrblib.o`
- create `build/i386/lib/libmruby.a` from object files from gems and `libmruby_core.a`
- create binary commands according to binary gems (e.g. `mirb` and `mruby`)
- copy binaries under `build/host/bin` to `bin` directory
```
_______________________________________________________________
@@ -545,7 +545,7 @@ For example, when you have a C source file (`c.c`) and try to
compile and link it with `libmruby.a`, you can run the following command,
```
gcc `mruby-config --cflags` c.c `mruby-config --ldflags` `mruby-config --libs`
`mruby-config --cc --cflags` c.c `mruby-config --ldflags --libs`
```
When you use `make`, add following lines in `Makefile`
@@ -556,3 +556,7 @@ CFLAGS = `$(MRB_CONFIG) --cflags`
LDFLAGS = `$(MRB_CONFIG) --ldflags`
LIBS = `$(MRB_CONFIG) --libs`
```
## Tips
- If you see compilation troubles, try `rake clean` first.
+2 -2
View File
@@ -38,7 +38,7 @@ To confirm mrdb was installed properly, run mrdb with the `--version` option:
```bash
$ mrdb --version
mruby 3.0.0 (2021-03-05)
mruby 3.1.0 (2022-05-12)
```
## 2.2 Basic Operation
@@ -82,7 +82,7 @@ You can debug the mruby binary files.
#### 2.2.2.1 Debugging the binary files
* notice
- notice
To debug mruby binary files, you need to compile mruby files with option `-g`.
```bash
+20 -20
View File
@@ -7,19 +7,19 @@ _Some parts are updated to reflect recent changes._
When you are extending mruby using C language, you may encounter
mysterious "arena overflow error" or memory leak or very slow
execution speed. This is an error indicating overflow of "GC arena"
execution speed. This is an error indicating overflow of "GC arena"
implementing "conservative GC".
GC (garbage collector) must ensure that object is "alive", in other
words, that it is referenced by somewhere from the program. This can be
words, that it is referenced by somewhere from the program. This can be
determined by checking if the object can be directly or indirectly
referenced by root. The local variables, global variables and
constants etc are root.
referenced by root. The local variables, global variables and
constants etc. are root.
If program execution is performed inside mruby VM, there is nothing to
worry about because GC can access all roots owned by the VM.
The problem arises when executing C functions. The object referenced
The problem arises when executing C functions. The object referenced
by C variable is also "alive", but mruby GC cannot aware of this, so
it might mistakenly recognize the objects referenced by only C
variables as dead.
@@ -27,15 +27,15 @@ variables as dead.
This can be a fatal bug if the GC tries to collect a live object.
In CRuby, we scan C stack area, and use C variable as root to check
whether object is alive or not. Of course, because we are accessing C
whether object is alive or not. Of course, because we are accessing C
stack just as memory region, we never know it is an integer or a
pointer. We workaround this by assuming that if it looks like a
pointer, then assume it as a pointer. We call it "conservative".
pointer. We work around this by assuming that if it looks like a
pointer, then assume it as a pointer. We call it "conservative".
By the way, CRuby's "conservative GC" has some problems.
The biggest problem is we have no way to access to the stack area in
portable way. Therefore, we cannot use this method if we'd like to
portable way. Therefore, we cannot use this method if we'd like to
implement highly portable runtime, like mruby.
So we came up with another plan to implement "conservative GC" in mruby.
@@ -65,14 +65,14 @@ objects (See `MRB_GC_FIXED_ARENA` and `MRB_GC_ARENA_SIZE` in
doc/guides/mrbconf.md).
If you create many objects in C functions, memory usage will increase, since
GC never kick in. This memory usage may look like memory leak, but will also
GC never kicks in. This memory usage may look like memory leaks, but will also
make execution slower as more memory will need to be allocated.
With the build time configuration, you can limit the maximum size of
arena (e.g., 100). Then if you create many objects, arena overflows,
arena (e.g., 100). Then if you create many objects, arena overflows,
thus you will get an "arena overflow error".
To workaround these problems, we have `mrb_gc_arena_save()` and
To work around these problems, we have `mrb_gc_arena_save()` and
`mrb_gc_arena_restore()` functions.
`int mrb_gc_arena_save(mrb)` returns the current position of the stack
@@ -93,7 +93,7 @@ In mruby, C function calls are surrounded by this save/restore, but we
can further optimize memory usage by surrounding save/restore, and can
avoid creating arena overflow bugs.
Let's take a real example. Here is the source code of `Array#inspect`:
Let's take a real example. Here is the source code of `Array#inspect`:
```c
static mrb_value
@@ -146,23 +146,23 @@ of array using `inspect` method, we join them together so that we can
get `inspect` representation of the entire array.
After the `inspect` representation is created, we no longer require the
individual string representation. This means that we don't have to register
individual string representation. This means that we don't have to register
these temporal objects into GC arena.
Therefore, in order to keep the arena size small; the `ary_inspect()` function
will do the following:
* save the position of the stack top using `mrb_gc_arena_save()`.
* get `inspect` representation of each element.
* append it to the constructing entire `inspect` representation of array.
* restore stack top position using `mrb_gc_arena_restore()`.
- save the position of the stack top using `mrb_gc_arena_save()`.
- get `inspect` representation of each element.
- append it to the constructing entire `inspect` representation of array.
- restore stack top position using `mrb_gc_arena_restore()`.
Please note that the final `inspect` representation of entire array
was created before the call of `mrb_gc_arena_restore()`. Otherwise,
was created before the call of `mrb_gc_arena_restore()`. Otherwise,
required temporal object may be deleted by GC.
We may have an usecase where after creating many temporal objects, we'd
like to keep some of them. In this case, we cannot use the same idea
like to keep some of them. In this case, we cannot use the same idea
in `ary_inspect()` like appending objects to existing one.
Instead, after `mrb_gc_arena_restore()`, we must re-register the objects we
want to keep in the arena using `mrb_gc_protect(mrb, obj)`.
+13 -13
View File
@@ -2,13 +2,13 @@
You have two ways to link `libmruby` to your application.
* using executable gem.
* using normal compilation process
- using executable gem.
- using normal compilation process
## Executable Gems
If your application is relatively small, `mrbgem` is an easier way to
create the executable. By tradition, the gem name start with
create the executable. By tradition, the gem name start with
`mruby-bin-`, e.g. `mruby-bin-debugger`.
### `mrbgem.rake` file
@@ -28,7 +28,7 @@ end
### Source tree structure
The source file for the gem executable should be in
`<gem-name>/tools/<bin-name>`. Currently, we support C or C++ source code
`<gem-name>/tools/<bin-name>`. Currently, we support C or C++ source code
(`.c`, `.cpp`, `.cxx`, `.cc`) for the executable. Ruby source files are not
supported. Put the functionality in the different gem and specify dependency to
it in `mrbgem.rake`.
@@ -37,7 +37,7 @@ it in `mrbgem.rake`.
The `libmruby` is a normal library so that you can just link it to your
application. Specify proper compiler options (`-I` etc.) and linker options
(`-Lmruby` etc.) to compile and link your application. Specify those options in
(`-lmruby` etc.) to compile and link your application. Specify those options in
your build script (e.g. `Makefile`).
### Compiler options
@@ -45,14 +45,14 @@ your build script (e.g. `Makefile`).
You need to specify compiler options that are compatible to mruby configuration,
for example:
* `-I` to specify the place for mruby header files
* `-D` to specify mruby configuration macros
- `-I` to specify the place for mruby header files
- `-D` to specify mruby configuration macros
To retrieve compiler options used to build `mruby`, you can use `mruby-config`
command with following options:
* `--cc` compiler name
* `--cflags` options passed to compiler
- `--cc` compiler name
- `--cflags` options passed to compiler
```
$ mruby-config --cflags
@@ -66,10 +66,10 @@ compatible to mruby configuration.
To retrieve linker options, you can use `mruby-config` with following options:
* `--ld` linker name
* `--ldflags` options passed to linker
* `--ldflags-before-libs` options passed to linker before linked libraries
* `--libs` linked libraries
- `--ld` linker name
- `--ldflags` options passed to linker
- `--ldflags-before-libs` options passed to linker before linked libraries
- `--libs` linked libraries
```
$ mruby-config --ldflags
+129 -86
View File
@@ -1,209 +1,252 @@
# mruby configuration macros
## The configuration file
You can do the build configuration in the build configuration file. The default
configuration file is `build_config/default.rb`.
You can specify your own configuration file by the `MRUBY_CONFIG` environment
variable (you can use `CONFIG` for shorthand for `MRUBY_CONFIG`). If the path
doesn't exist, `build_config/${MRUBY_CONFIG}.rb` is used.
## How to use these macros
You can use mrbconfs with following ways:
Just add the configuration value to the `MRuby::Build#defines` attribute.
This is the same for `MRuby::CrossBuild`.
* Write them in `mrbconf.h`.
* Using compiler flags is preferred when building a cross binaries or multiple mruby binaries
since it's easier to use different mrbconf per each `MRuby::Build`.
* Most flags can be enabled by just commenting in.
* Pass them as compiler flags.
* Make sure you pass the same flags to all compilers since some mrbconf(e.g., `MRB_GC_FIXED_ARENA`)
changes `struct` layout and cause memory access error when C and other language(e.g., C++) is mixed.
```ruby
# build_config.rb
MRuby::Build.new do |conf|
.....
conf.defines << 'MRB_GC_FIXED_ARENA'
conf.defines << 'MRB_NO_METHOD_CACHE'
.....
end
```
***NOTE***
- Use common definitions (`conf.defines`) instead of per-compiler definitions (e.g., `conf.cc.defines`) unless there is a special reason not to.
- It is now deprecated to edit the `include/mruby/mrbconf.h` file or give it directly as a compiler flag, as was the case before.
## stdio setting
`MRB_NO_STDIO`
* When defined `<stdio.h>` functions won't be used.
* Some features will be disabled when this is enabled:
* `mrb_irep` load/dump from/to file.
* Compiling mruby script from a file.
* Printing features in **src/print.c**.
- When defined `<stdio.h>` functions won't be used.
- Some features will be disabled when this is enabled:
- `mrb_irep` load/dump from/to file.
- Compiling mruby script from a file.
- Printing features in **src/print.c**.
## Debug macros
`MRB_USE_DEBUG_HOOK`
* When defined code fetch hook and debug OP hook will be enabled.
* When using any of the hook set function pointer `code_fetch_hook` and/or `debug_op_hook` of `mrb_state`.
* Fetch hook will be called before any OP.
* Debug OP hook will be called when dispatching `OP_DEBUG`.
- When defined code fetch hook and debug OP hook will be enabled.
- When using any of the hook set function pointer `code_fetch_hook` and/or `debug_op_hook` of `mrb_state`.
- Fetch hook will be called before any OP.
- Debug OP hook will be called when dispatching `OP_DEBUG`.
`MRB_DEBUG`
* When defined `mrb_assert*` macro will be defined with macros from `<assert.h>`.
* Could be enabled via `enable_debug` method of `MRuby::Build`.
- When defined `mrb_assert*` macro will be defined with macros from `<assert.h>`.
- Could be enabled via `enable_debug` method of `MRuby::Build`.
## Stack configuration
`MRB_STACK_EXTEND_DOUBLING`
* If defined doubles the stack size when extending it.
* Else extends stack with `MRB_STACK_GROWTH`.
- If defined doubles the stack size when extending it.
- Otherwise extends stack with `MRB_STACK_GROWTH`.
`MRB_STACK_GROWTH`
* Default value is `128`.
* Used in stack extending.
* Ignored when `MRB_STACK_EXTEND_DOUBLING` is defined.
- Default value is `128`.
- Used in stack extending.
- Ignored when `MRB_STACK_EXTEND_DOUBLING` is defined.
`MRB_STACK_MAX`
* Default value is `0x40000 - MRB_STACK_GROWTH`.
* Raises `RuntimeError` when stack size exceeds this value.
- Default value is `0x40000 - MRB_STACK_GROWTH`.
- Raises `RuntimeError` when stack size exceeds this value.
## Primitive type configuration
`MRB_USE_FLOAT32`
* When defined single precision floating-point type(C type `float`) is used as `mrb_float`.
* Otherwise, double precision floating-point type(C type `double`) is used as `mrb_float`.
- When defined single-precision floating-point type(C type `float`) is used as `mrb_float`.
- Otherwise, double-precision floating-point type(C type `double`) is used as `mrb_float`.
`MRB_NO_FLOAT`
* When defined removes floating-point numbers from mruby.
* It makes mruby easier to handle in "Microcontroller without FPU" and "Kernel Space".
- When defined removes floating-point numbers from mruby.
- It makes mruby easier to handle in "Micro-controller without FPU" and "Kernel Space".
`MRB_INT32`
* When defined, or `MRB_INT64` are not defined on 32-bit CPU mode, `mrb_int` will be defined as `int32_t`.
* Conflicts with `MRB_INT64`.
- When defined, or `MRB_INT64` are not defined on 32-bit CPU mode, `mrb_int` will be defined as `int32_t`.
- Conflicts with `MRB_INT64`.
`MRB_INT64`
* When defined, or `MRB_INT32` are not defined on 64-bit CPU mode, `mrb_int` will be defined as `int64_t`.
* Conflicts with `MRB_INT32`.
- When defined, or `MRB_INT32` are not defined on 64-bit CPU mode, `mrb_int` will be defined as `int64_t`.
- Conflicts with `MRB_INT32`.
## Garbage collector configuration
`MRB_GC_STRESS`
* When defined full GC is emitted per each `RBasic` allocation.
* Mainly used in memory manager debugging.
- When defined full GC is emitted per each `RBasic` allocation.
- Mainly used in memory manager debugging.
- If defined at the same time as `MRB_DEBUG`, full GC is emitted also per each heap allocation (`mrb_malloc()` or etc.).
This configuration slows down mruby execution by a factor of 2 to 3 or even more.
`MRB_GC_TURN_OFF_GENERATIONAL`
* When defined turns generational GC by default.
- When defined turns generational GC by default.
`MRB_GC_FIXED_ARENA`
* When defined used fixed size GC arena.
* Raises `RuntimeError` when this is defined and GC arena size exceeds `MRB_GC_ARENA_SIZE`.
* Useful tracking unnecessary mruby object allocation.
- When defined used fixed size GC arena.
- Raises `RuntimeError` when this is defined and GC arena size exceeds `MRB_GC_ARENA_SIZE`.
- Useful tracking unnecessary mruby object allocation.
`MRB_GC_ARENA_SIZE`
* Default value is `100`.
* Ignored when `MRB_GC_FIXED_ARENA` isn't defined.
* Defines fixed GC arena size.
- Default value is `100`.
- Ignored when `MRB_GC_FIXED_ARENA` isn't defined.
- Defines fixed GC arena size.
`MRB_HEAP_PAGE_SIZE`
* Defines value is `1024`.
* Specifies number of `RBasic` per each heap page.
- Defines value is `1024`.
- Specifies number of `RBasic` per each heap page.
- To calculate the number of bytes per heap page, it is "(size of management data per heap page) + (size per object) * `MRB_HEAP_PAGE_SIZE`".
In mruby 3.1.0, the "size of management data per heap page" is 6 words, also "size per object" is 6 words.
For a 32-bit CPU, `(6 * 4) + (6 * 4) * MRB_HEAP_PAGE_SIZE` gives the bytes of size per heap page.
Conversely, for example, to keep the size per heap page to 4 Ki bytes,
calculate `(4096 - (6 * 4)) / (6 * 4)` to specify `MRB_HEAP_PAGE_SIZE=169`.
## Memory pool configuration
`POOL_ALIGNMENT`
* Default value is `4`.
* If you're allocating data types that requires alignment more than default value define the
- Default value is `4`.
- If you're allocating data types that requires alignment more than default value define the
largest value of required alignment.
`POOL_PAGE_SIZE`
* Default value is `16000`.
* Specifies page size of pool page.
* Smaller the value is increases memory overhead.
- Default value is `16000`.
- Specifies page size of pool page.
- Smaller the value is increases memory overhead.
## State atexit configuration
`MRB_FIXED_STATE_ATEXIT_STACK`
* If defined enables fixed size `mrb_state` atexit stack.
* Raises `RuntimeError` when `mrb_state_atexit` call count to same `mrb_state` exceeds
- If defined enables fixed size `mrb_state` atexit stack.
- Raises `RuntimeError` when `mrb_state_atexit` call count to same `mrb_state` exceeds
`MRB_FIXED_STATE_ATEXIT_STACK_SIZE`'s value.
`MRB_FIXED_STATE_ATEXIT_STACK_SIZE`
* Default value is `5`.
* If `MRB_FIXED_STATE_ATEXIT_STACK` isn't defined this macro is ignored.
- Default value is `5`.
- If `MRB_FIXED_STATE_ATEXIT_STACK` isn't defined this macro is ignored.
## `mrb_value` configuration
`MRB_ENDIAN_BIG`
* If defined compiles mruby for big endian machines.
* Used in `MRB_NAN_BOXING`.
* Some mrbgem use this mrbconf.
- If defined compiles mruby for big endian machines.
- Used in `MRB_NAN_BOXING`.
- Some mrbgem use this mrbconf.
`MRB_NAN_BOXING`
* If defined represent `mrb_value` in boxed `double`.
* Conflicts with `MRB_USE_FLOAT32` and `MRB_NO_FLOAT`.
- If defined represent `mrb_value` in boxed `double`.
- Conflicts with `MRB_USE_FLOAT32` and `MRB_NO_FLOAT`.
`MRB_WORD_BOXING`
* If defined represent `mrb_value` as a word.
* If defined `Float` will be a mruby object with `RBasic`.
- If defined represent `mrb_value` as a word.
- If defined `Float` will be a mruby object with `RBasic`.
## Reduce heap memory configuration
`MRB_USE_ETEXT_RO_DATA_P`
* Use `etext` and `edata` section addresses defined by the linker to detect read-only data.
* Those addresses are widely available, but not portable, nor standardized.
* This macro is defined by default on User-mode Linux.
- Use `etext` and `edata` section addresses defined by the linker to detect read-only data.
- Those addresses are widely available, but not portable, nor standardized.
- This macro is defined by default on User-mode Linux.
`MRB_NO_DEFAULT_RO_DATA_P`
* Define this macro when the default `mrb_ro_data_p()` does not work for any reason.
- Define this macro when the default `mrb_ro_data_p()` does not work for any reason.
`MRB_USE_CUSTOM_RO_DATA_P`
* Please try if `MRB_USE_LINK_TIME_RO_DATA_P` is not available.
* The `mrb_ro_data_p()` function is implemented by the user in an arbitrary file.
* The prototype declaration is `mrb_bool mrb_ro_data_p(const char *ptr)`.
* Return `TRUE` if `ptr` is in the read-only section, otherwise return `FALSE`.
- Please try if `MRB_USE_LINK_TIME_RO_DATA_P` is not available.
- The `mrb_ro_data_p()` function is implemented by the user in an arbitrary file.
- The prototype declaration is `mrb_bool mrb_ro_data_p(const char *ptr)`.
- Return `TRUE` if `ptr` is in the read-only section, otherwise return `FALSE`.
## Other configuration
`MRB_MALLOC_TRIM`
- call malloc_trim(0) for each mrb_full_gc() call
`MRB_UTF8_STRING`
* Adds UTF-8 encoding support to character-oriented String instance methods.
* If it isn't defined, they only support the US-ASCII encoding.
- Adds UTF-8 encoding support to character-oriented String instance methods.
- If it isn't defined, they only support the US-ASCII encoding.
`MRB_STR_LENGTH_MAX`
- The maximum length of strings (default 1MB)
- set this value to zero to skip the check
`MRB_ARY_LENGTH_MAX`
- The maximum length of strings (default 1MB)
- set this value to zero to skip the check
`MRB_FUNCALL_ARGC_MAX`
* Default value is `16`.
* Specifies 4th argument(`argc`) max value of `mrb_funcall`.
* Raises `ArgumentError` when the `argc` argument is bigger then this value `mrb_funcall`.
- Default value is `16`.
- Specifies 4th argument(`argc`) max value of `mrb_funcall`.
- Raises `ArgumentError` when the `argc` argument is bigger then this value `mrb_funcall`.
`KHASH_DEFAULT_SIZE`
* Default value is `32`.
* Specifies default size of khash table bucket.
* Used in `kh_init_ ## name` function.
- Default value is `32`.
- Specifies default size of khash table bucket.
- Used in `kh_init_ ## name` function.
`MRB_NO_METHOD_CACHE`
* Disable method cache to save memory.
- Disable method cache to save memory.
`MRB_METHOD_CACHE_SIZE`
* Default value is `256`.
* Ignored if `MRB_NO_METHOD_CACHE` is defined.
* Need to be the power of 2.
- Default value is `256`.
- Ignored if `MRB_NO_METHOD_CACHE` is defined.
- Need to be the power of 2.
`MRB_USE_METHOD_T_STRUCT`
* Use C struct to represent `mrb_method_t`
* No `MRB_USE_METHOD_T_STRUCT` requires highest 2 bits of function pointers to be zero
* Define this macro on machines that use higher bits of pointers
- Use C struct to represent `mrb_method_t`
- No `MRB_USE_METHOD_T_STRUCT` requires highest 2 bits of function pointers to be zero
- Define this macro on machines that use higher bits of pointers
`MRB_USE_ALL_SYMBOLS`
* Make it available `Symbol.all_symbols` in `mrbgems/mruby-symbol-ext`
* Increase heap memory usage.
- Make it available `Symbol.all_symbols` in `mrbgems/mruby-symbol-ext`
- Increase heap memory usage.
`MRB_NO_DIRECT_THREADING`
- Turn off direct threading optimization in VM loop
+85 -53
View File
@@ -6,7 +6,7 @@ standardised way into mruby. Conventionally, each mrbgem name is prefixed by
## Usage
You have to activate mrbgems explicitly in your build configuration. To add
You have to activate mrbgems explicitly in your build configuration. To add
a gem, add the following line to your build configuration file, for example:
```ruby
@@ -21,9 +21,9 @@ conf.gem 'examples/mrbgems/ruby_extension_example'
In that case,
* if your build configuration file is in the `build_config` directory, it's
- if your build configuration file is in the `build_config` directory, it's
relative from `MRUBY_ROOT`.
* otherwise, it is relative from the directory where your build configuration is.
- otherwise, it is relative from the directory where your build configuration is.
A remote GIT repository location for a GEM is also supported:
@@ -33,6 +33,9 @@ conf.gem :github => 'masuidrive/mrbgems-example', :branch => 'master'
conf.gem :bitbucket => 'mruby/mrbgems-example', :branch => 'master'
```
NOTE: `:bitbucket` option supports only git. Hg is unsupported in this
version.
You can specify the subdirectory of the repository with `:path` option:
```ruby
@@ -55,19 +58,48 @@ conf.gem mgem: 'mruby-redis', checksum_hash: '3446d19fc4a3f9697b5ddbf2a904f301c4
If there are missing dependencies, mrbgem dependencies solver will reference
mrbgem from the core or mgem-list.
To pull all gems from remote GIT repository on build, call `rake -p`,
or `rake --pull-gems`.
Note that if more than one git-based gem has the same base name
(i.e. the default checkout directory name), it is (now) an error
**UNLESS** they have the same repository URL, branch name and
commit-id (i.e. checksum hash). You can bypass this by explicitly
importing your preferred version **first** and setting the
`canonical:` option to `true`:
NOTE: `:bitbucket` option supports only git. Hg is unsupported in this version.
```ruby
conf.gem github: 'me/mruby-yaml', branch: 'my-hacked-branch', canonical: true
```
If you do this, the system will (mostly) silently ignore other
attempts to clone a gem with this name.
Note that this only affects cloning the gem from git. It does not
resolve version conflicts. If the version as specified in the gem's
rakefile is incompatible with a dependency, your build will still
fail.
### Tweak the gem in your build configuration file
You can give blocks in the `conf.gem` call to make adjustments for
environments where the original gem does not expect them:
```ruby
conf.gem core: "mruby-bin-mirb" do |g|
# For cross build to NetBSD
g.linker.libraries = %w(edit termcap)
end
```
However, it should be used with caution, as it may deviate from the intent
of the gem's author.
## GemBox
There are instances when you wish to add a collection of mrbgems into mruby at
once, or be able to substitute mrbgems based on configuration, without having to
add each gem to your build configuration file. A packaged collection of mrbgems
is called a GemBox. A GemBox is a file that contains a list of mrbgems to load
add each gem to your build configuration file. A packaged collection of mrbgems
is called a GemBox. A GemBox is a file that contains a list of mrbgems to load
into mruby, in the same format as if you were adding them to the build config
via `config.gem`, but wrapped in an `MRuby::GemBox` object. GemBoxes are
via `config.gem`, but wrapped in an `MRuby::GemBox` object. GemBoxes are
loaded into mruby via `config.gembox 'boxname'`.
Below we have created a GemBox containing `mruby-time` and `mrbgems-example`:
@@ -79,7 +111,7 @@ MRuby::GemBox.new do |conf|
end
```
As mentioned, the GemBox uses the same conventions as `MRuby::Build`. The GemBox
As mentioned, the GemBox uses the same conventions as `MRuby::Build`. The GemBox
must be saved with a `.gembox` extension inside the `mrbgems` directory to be
picked up by mruby.
@@ -94,7 +126,7 @@ conf.gembox 'custom'
This will cause the `custom` GemBox to be read in during the build process,
adding `mruby-time` and `mrbgems-example` to the build.
If you want, you can put GemBox outside of mruby directory. In that case you must
If you want, you can put GemBox outside the mruby directory. In that case you must
specify an absolute path like below.
```ruby
@@ -143,7 +175,7 @@ GEM directory. A typical GEM specification could look like this for example:
MRuby::Gem::Specification.new('c_and_ruby_extension_example') do |spec|
spec.license = 'MIT'
spec.author = 'mruby developers'
spec.summary = 'Example mrbgem using C and ruby'
spec.summary = 'Example mrbgem using C and Ruby'
end
```
@@ -154,15 +186,15 @@ the GEM functionality to tools like `mruby` and `mirb`.
The following properties can be set inside your `MRuby::Gem::Specification` for
information purpose:
* `spec.license` or `spec.licenses` (A single license or a list of them under which this GEM is licensed)
* `spec.author` or `spec.authors` (Developer name or a list of them)
* `spec.version` (Current version)
* `spec.description` (Detailed description)
* `spec.summary`
* One line short description of mrbgem.
* Printed in build summary of rake when set.
* `spec.homepage` (Homepage)
* `spec.requirements` (External requirements as information for user)
- `spec.license` or `spec.licenses` (A single license or a list of them under which this GEM is licensed)
- `spec.author` or `spec.authors` (Developer name or a list of them)
- `spec.version` (Current version)
- `spec.description` (Detailed description)
- `spec.summary`
- One line short description of mrbgem.
- Printed in build summary of rake when set.
- `spec.homepage` (Homepage)
- `spec.requirements` (External requirements as information for user)
The `license` and `author` properties are required in every GEM!
@@ -193,15 +225,15 @@ The version requirements and default gem information are optional.
Version requirement supports following operators:
* '=': is equal
* '!=': is not equal
* '>': is greater
* '<': is lesser
* '>=': is equal or greater
* '<=': is equal or lesser
* '~>': is equal or greater and is lesser than the next major version
* example 1: '~> 2.2.2' means '>= 2.2.2' and '< 2.3.0'
* example 2: '~> 2.2' means '>= 2.2.0' and '< 3.0.0'
- '=': is equal
- '!=': is not equal
- '>': is greater
- '<': is lesser
- '>=': is equal or greater
- '<=': is equal or lesser
- '~>': is equal or greater and is lesser than the next major version
- example 1: '~> 2.2.2' means '>= 2.2.2' and '< 2.3.0'
- example 2: '~> 2.2' means '>= 2.2.0' and '< 3.0.0'
When more than one version requirements is passed, the dependency must satisfy all of it.
@@ -214,8 +246,8 @@ use `MRuby::Build#gem` in the build configuration to override default gem.
If you have conflicting GEMs use the following method:
* `spec.add_conflict(gem, *requirements)`
* The `requirements` argument is same as in `add_dependency` method.
- `spec.add_conflict(gem, *requirements)`
- The `requirements` argument is same as in `add_dependency` method.
like following code:
@@ -234,18 +266,18 @@ end
In case your GEM has more complex build requirements you can use
the following options additionally inside your GEM specification:
* `spec.cc.flags` (C compiler flags)
* `spec.cc.defines` (C compiler defines)
* `spec.cc.include_paths` (C compiler include paths)
* `spec.linker.flags` (Linker flags)
* `spec.linker.libraries` (Linker libraries)
* `spec.linker.library_paths` (Linker additional library path)
* `spec.bins` (Generate binary file)
* `spec.rbfiles` (Ruby files to compile)
* `spec.objs` (Object files to compile)
* `spec.test_rbfiles` (Ruby test files for integration into mrbtest)
* `spec.test_objs` (Object test files for integration into mrbtest)
* `spec.test_preload` (Initialization files for mrbtest)
- `spec.cc.flags` (C compiler flags)
- `spec.cc.defines` (C compiler defines)
- `spec.cc.include_paths` (C compiler include paths)
- `spec.linker.flags` (Linker flags)
- `spec.linker.libraries` (Linker libraries)
- `spec.linker.library_paths` (Linker additional library path)
- `spec.bins` (Generate binary file)
- `spec.rbfiles` (Ruby files to compile)
- `spec.objs` (Object files to compile)
- `spec.test_rbfiles` (Ruby test files for integration into mrbtest)
- `spec.test_objs` (Object test files for integration into mrbtest)
- `spec.test_preload` (Initialization files for mrbtest)
You also can use `spec.mruby.cc` and `spec.mruby.linker` to add extra global parameters for the compiler and linker.
@@ -380,7 +412,7 @@ See C and Ruby example.
## Binary gems
Some gems can generate executables under `bin` directory. Those gems are called
binary gems. Names of binary gems are conventionally prefixed by `mruby-bin`,
binary gems. Names of binary gems are conventionally prefixed by `mruby-bin`,
e.g. `mruby-bin-mirb` and `mruby-bin-strip`.
To specify the name of executable, you need to specify `spec.bins` in the
@@ -397,21 +429,21 @@ binary gems, to separate normal gems and binary gems.
```
+- mruby-bin-example/
|
+- README.md (Optional)
+- README.md (Optional)
|
+- bintest/
| |
| +- example.rb <- Test code for binary gem
| +- example.rb <- Test code for binary gem
|
+- mrbgem.rake <- Gem specification
+- mrbgem.rake <- Gem specification
|
+- mrblib/ <- Source for Ruby extension (Optional)
+- mrblib/ <- Source for Ruby extension (Optional)
|
+- src/ <- Source for C extension (Optional)
+- src/ <- Source for C extension (Optional)
|
+- tools/
|
+- example/ <- Executable name directory
|
+- example.c <- Source for Executable (includes main)
+- example/ <- Executable name directory
|
+- example.c <- Source for Executable (includes main)
```
+10 -10
View File
@@ -1,7 +1,7 @@
# Symbols
Symbols in `mruby` C source code is represented by `mrb_sym` which is alias of
`uint32_t`. Lower 30 bits are used for symbols so that higher 2 bits can be
`uint32_t`. Lower 30 bits are used for symbols so that higher 2 bits can be
used as flags, e.g. `struct mt_elem` in `class.c`.
```c
@@ -57,13 +57,13 @@ To save RAM, `mruby` can use compile-time allocation of some symbols. You can
use following macros to get preallocated symbols by including `mruby/presym.h`
header.
* `MRB_SYM(xor)` //=> xor (Word characters)
* `MRB_SYM_B(xor)` //=> xor! (Method with Bang)
* `MRB_SYM_Q(xor)` //=> xor? (Method with Question mark)
* `MRB_SYM_E(xor)` //=> xor= (Method with Equal)
* `MRB_CVSYM(xor)` //=> @@xor (Class Variable)
* `MRB_IVSYM(xor)` //=> @xor (Instance Variable)
* `MRB_OPSYM(xor)` //=> ^ (Operator)
- `MRB_SYM(xor)` //=> xor (Word characters)
- `MRB_SYM_B(xor)` //=> xor! (Method with Bang)
- `MRB_SYM_Q(xor)` //=> xor? (Method with Question mark)
- `MRB_SYM_E(xor)` //=> xor= (Method with Equal)
- `MRB_CVSYM(xor)` //=> @@xor (Class Variable)
- `MRB_IVSYM(xor)` //=> @xor (Instance Variable)
- `MRB_OPSYM(xor)` //=> ^ (Operator)
For `MRB_OPSYM()`, specify the names corresponding to operators (see
`MRuby::Presym::OPERATORS` in `lib/mruby/presym.rb` for the names that
@@ -71,9 +71,9 @@ can be specified for it). Other than that, describe only word characters
excluding leading and ending punctuations.
These macros are converted to static symbol IDs at compile time, unless
preallocate symbols are disabled by `conf.disable_presym`. In that case,
preallocate symbols are disabled by `conf.disable_presym`. In that case,
these macros are expanded to `mrb_intern_lit` calls, therefore the mruby state
variable is required. The above macros assume the variable name is `mrb`. If
variable is required. The above macros assume the variable name is `mrb`. If
its name is not `mrb`, you need to use macros with `_2` suffix, such as
`MRB_SYM_2` to specify `mrb_state*` variable.
+26 -26
View File
@@ -2,9 +2,9 @@
The mruby objects and data are represented by C data type `mrb_value`. There are three options how to pack the data values in the `mrb_value`.
* Word Boxing
* NaN Boxing
* No Boxing
- Word Boxing
- NaN Boxing
- No Boxing
## Word Boxing
@@ -14,38 +14,38 @@ Some values (called immediate values, e.g. integers, booleans, symbols, etc.) ar
The Word boxing packing bit patterns are like following:
| Types | Bit Pattern |
|--------|-------------------------------------|
| object | xxxxxxxx xxxxxxxx xxxxxxxx xxxxx000 |
| fixnum | xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxx1 |
| nil | 00000000 00000000 00000000 00000000 |
| true | 00000000 00000000 00000000 00001100 |
| false | 00000000 00000000 00000000 00000100 |
| undef | 00000000 00000000 00000000 00010100 |
| symbol | xxxxxxxx xxxxxxxx xxxxxxxx xxxxxx10 |
| Types | Bit Pattern |
|--------|---------------------------------------|
| object | `xxxxxxxx xxxxxxxx xxxxxxxx xxxxx000` |
| fixnum | `xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxx1` |
| nil | `00000000 00000000 00000000 00000000` |
| true | `00000000 00000000 00000000 00001100` |
| false | `00000000 00000000 00000000 00000100` |
| undef | `00000000 00000000 00000000 00010100` |
| symbol | `xxxxxxxx xxxxxxxx xxxxxxxx xxxxxx10` |
On 64 bit platform (unless `MRB_WORDBOX_NO_FLOAT_TRUNCATE`), float values are also packed in the `mrb_value`. In that case, we drop least significant 2 bits from mantissa.
If you need full precision for floating point numbers, define `MRB_WORDBOX_NO_FLOAT_TRUNCATE`.
If you need full precision for floating-point numbers, define `MRB_WORDBOX_NO_FLOAT_TRUNCATE`.
## NaN Boxing
NaN boxing packs the Ruby data in a floating point numbers, which represent NaN (Not a Number) values. Under IEEE753 definitions every value that exponent is all set are considered as NaN. That means NaN can represent `2^51` values. NaN boxing is a teaching to pack the values in those NaN representation. In theory, 64 bits pointers are too big to fit in NaN, but practically most OS uses only 48 bits at most for pointers (except for some OS e.g. Solaris).
NaN boxing packs the Ruby data in a floating-point numbers, which represent NaN (Not a Number) values. Under IEEE753 definitions every value that exponent is all set are considered as NaN. That means NaN can represent `2^51` values. NaN boxing is a teaching to pack the values in those NaN representation. In theory, 64 bits pointers are too big to fit in NaN, but practically most OS uses only 48 bits at most for pointers (except for some OS e.g. Solaris).
The NaN boxing packing bit patterns are like following:
| Types | Bit Pattern |
|--------|-------------------------------------------------------------------------|
| float | SEEEEEEE EEEEFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |
| +/-inf | S1111111 11110000 00000000 00000000 00000000 00000000 00000000 00000000 |
| nan | 01111111 11111000 00000000 00000000 00000000 00000000 00000000 00000000 |
| fixnum | 01111111 11111001 00000000 00000000 IIIIIIII IIIIIIII IIIIIIII IIIIIIII |
| symbol | 01111111 11111110 00000000 00000000 SSSSSSSS SSSSSSSS SSSSSSSS SSSSSSSS |
| misc | 01111111 11111111 00000000 00000000 00000000 00000000 00TTTTTT 0000MMMM |
| object | 01111111 11111100 PPPPPPPP PPPPPPPP PPPPPPPP PPPPPPPP PPPPPPPP PPPPPP00 |
| ptr | 01111111 11111100 PPPPPPPP PPPPPPPP PPPPPPPP PPPPPPPP PPPPPPPP PPPPPP01 |
| nil | 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 |
| Types | Bit Pattern |
|--------|---------------------------------------------------------------------------|
| float | `SEEEEEEE EEEEFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF` |
| +/-inf | `S1111111 11110000 00000000 00000000 00000000 00000000 00000000 00000000` |
| nan | `01111111 11111000 00000000 00000000 00000000 00000000 00000000 00000000` |
| fixnum | `01111111 11111001 00000000 00000000 IIIIIIII IIIIIIII IIIIIIII IIIIIIII` |
| symbol | `01111111 11111110 00000000 00000000 SSSSSSSS SSSSSSSS SSSSSSSS SSSSSSSS` |
| misc | `01111111 11111111 00000000 00000000 00000000 00000000 00TTTTTT 0000MMMM` |
| object | `01111111 11111100 PPPPPPPP PPPPPPPP PPPPPPPP PPPPPPPP PPPPPPPP PPPPPP00` |
| ptr | `01111111 11111100 PPPPPPPP PPPPPPPP PPPPPPPP PPPPPPPP PPPPPPPP PPPPPP01` |
| nil | `00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000` |
The object values appear far more frequently than floating point numbers, so we offset the value so that object pointers are unchanged. This technique is called "favor pointer"".
The object values appear far more frequently than floating-point numbers, so we offset the value so that object pointers are unchanged. This technique is called "favor pointer".
## No Boxing
+119 -111
View File
@@ -7,122 +7,130 @@ reducing the memory consumption of mruby VM.
# Instructions
Instructions are bytes. There can be 256 instructions. Currently, we
have 94 instructions. Instructions can take 0 to 3 operands.
have 106 instructions. Instructions can take 0 to 3 operands.
## operands
The size of operands can be either 8bits, 16bits or 24bits.
In the table.1 below, the second field describes the size (and
sign) of operands.
In the table.1 below, the second field describes the size
of operands.
* B: 8bit
* S: 16bit
* sS: signed 16bit
* W: 24bit
- B: 8bit
- S: 16bit
- W: 24bit
If the first and second operands are of type `B` (8bits), they may be
extended to 16bits by the operand extension instruction immediately
preceding them.
See also `OP_EXT1`, `OP_EXT2` and `OP_EXT3`.
## table.1 Instruction Table
| Instruction Name | Operand type | Semantics |
|------------------|--------------|----------------------------------------------------------|
| `OP_NOP` | `-` | `no operation` |
| `OP_MOVE` | `BB` | `R(a) = R(b)` |
| `OP_LOADL` | `BB` | `R(a) = Pool(b)` |
| `OP_LOADI` | `BB` | `R(a) = mrb_int(b)` |
| `OP_LOADINEG` | `BB` | `R(a) = mrb_int(-b)` |
| `OP_LOADI__1` | `B` | `R(a) = mrb_int(-1)` |
| `OP_LOADI_0` | `B` | `R(a) = mrb_int(0)` |
| `OP_LOADI_1` | `B` | `R(a) = mrb_int(1)` |
| `OP_LOADI_2` | `B` | `R(a) = mrb_int(2)` |
| `OP_LOADI_3` | `B` | `R(a) = mrb_int(3)` |
| `OP_LOADI_4` | `B` | `R(a) = mrb_int(4)` |
| `OP_LOADI_5` | `B` | `R(a) = mrb_int(5)` |
| `OP_LOADI_6` | `B` | `R(a) = mrb_int(6)` |
| `OP_LOADI_7` | `B` | `R(a) = mrb_int(7)` |
| `OP_LOADI16` | `BS` | `R(a) = mrb_int(b)` |
| `OP_LOADI32` | `BSS` | `R(a) = mrb_int((b<<16)+c)` |
| `OP_LOADSYM` | `BB` | `R(a) = Syms(b)` |
| `OP_LOADNIL` | `B` | `R(a) = nil` |
| `OP_LOADSELF` | `B` | `R(a) = self` |
| `OP_LOADT` | `B` | `R(a) = true` |
| `OP_LOADF` | `B` | `R(a) = false` |
| `OP_GETGV` | `BB` | `R(a) = getglobal(Syms(b))` |
| `OP_SETGV` | `BB` | `setglobal(Syms(b), R(a))` |
| `OP_GETSV` | `BB` | `R(a) = Special[Syms(b)]` |
| `OP_SETSV` | `BB` | `Special[Syms(b)] = R(a)` |
| `OP_GETIV` | `BB` | `R(a) = ivget(Syms(b))` |
| `OP_SETIV` | `BB` | `ivset(Syms(b),R(a))` |
| `OP_GETCV` | `BB` | `R(a) = cvget(Syms(b))` |
| `OP_SETCV` | `BB` | `cvset(Syms(b),R(a))` |
| `OP_GETCONST` | `BB` | `R(a) = constget(Syms(b))` |
| `OP_SETCONST` | `BB` | `constset(Syms(b),R(a))` |
| `OP_GETMCNST` | `BB` | `R(a) = R(a)::Syms(b)` |
| `OP_SETMCNST` | `BB` | `R(a+1)::Syms(b) = R(a)` |
| `OP_GETUPVAR` | `BBB` | `R(a) = uvget(b,c)` |
| `OP_SETUPVAR` | `BBB` | `uvset(b,c,R(a))` |
| `OP_JMP` | `S` | `pc+=a` |
| `OP_JMPIF` | `BS` | `if R(a) pc+=b` |
| `OP_JMPNOT` | `BS` | `if !R(a) pc+=b` |
| `OP_JMPNIL` | `BS` | `if R(a)==nil pc+=b` |
| `OP_JMPUW` | `S` | `unwind_and_jump_to(a)` |
| `OP_EXCEPT` | `B` | `R(a) = exc` |
| `OP_RESCUE` | `BB` | `R(b) = R(a).isa?(R(b))` |
| `OP_RAISEIF` | `B` | `raise(R(a)) if R(a)` |
| `OP_SEND` | `BBB` | `R(a) = call(R(a),Syms(b),R(a+1),...,R(a+c))` |
| `OP_SENDB` | `BBB` | `R(a) = call(R(a),Syms(b),R(a+1),...,R(a+c),&R(a+c+1))` |
| `OP_CALL` | `-` | `R(0) = self.call(frame.argc, frame.argv)` |
| `OP_SUPER` | `BB` | `R(a) = super(R(a+1),... ,R(a+b+1))` |
| `OP_ARGARY` | `BS` | `R(a) = argument array (16=m5:r1:m5:d1:lv4)` |
| `OP_ENTER` | `W` | `arg setup according to flags (23=m5:o5:r1:m5:k5:d1:b1)` |
| `OP_KEY_P` | `BB` | `R(a) = kdict.key?(Syms(b))` |
| `OP_KEYEND` | `-` | `raise unless kdict.empty?` |
| `OP_KARG` | `BB` | `R(a) = kdict[Syms(b)]; kdict.delete(Syms(b))` |
| `OP_RETURN` | `B` | `return R(a) (normal)` |
| `OP_RETURN_BLK` | `B` | `return R(a) (in-block return)` |
| `OP_BREAK` | `B` | `break R(a)` |
| `OP_BLKPUSH` | `BS` | `R(a) = block (16=m5:r1:m5:d1:lv4)` |
| `OP_ADD` | `B` | `R(a) = R(a)+R(a+1)` |
| `OP_ADDI` | `BB` | `R(a) = R(a)+mrb_int(b)` |
| `OP_SUB` | `B` | `R(a) = R(a)-R(a+1)` |
| `OP_SUBI` | `BB` | `R(a) = R(a)-mrb_int(b)` |
| `OP_MUL` | `B` | `R(a) = R(a)*R(a+1)` |
| `OP_DIV` | `B` | `R(a) = R(a)/R(a+1)` |
| `OP_EQ` | `B` | `R(a) = R(a)==R(a+1)` |
| `OP_LT` | `B` | `R(a) = R(a)<R(a+1)` |
| `OP_LE` | `B` | `R(a) = R(a)<=R(a+1)` |
| `OP_GT` | `B` | `R(a) = R(a)>R(a+1)` |
| `OP_GE` | `B` | `R(a) = R(a)>=R(a+1)` |
| `OP_ARRAY` | `BB` | `R(a) = ary_new(R(a),R(a+1)..R(a+b))` |
| `OP_ARRAY2` | `BBB` | `R(a) = ary_new(R(b),R(b+1)..R(b+c))` |
| `OP_ARYCAT` | `B` | `ary_cat(R(a),R(a+1))` |
| `OP_ARYPUSH` | `BB` | `ary_push(R(a),R(a+1)..R(a+b))` |
| `OP_ARYDUP` | `B` | `R(a) = ary_dup(R(a))` |
| `OP_AREF` | `BBB` | `R(a) = R(b)[c]` |
| `OP_ASET` | `BBB` | `R(b)[c] = R(a)` |
| `OP_APOST` | `BBB` | `*R(a),R(a+1)..R(a+c) = R(a)[b..]` |
| `OP_INTERN` | `B` | `R(a) = intern(R(a))` |
| `OP_STRING` | `BB` | `R(a) = str_dup(Pool(b))` |
| `OP_STRCAT` | `B` | `str_cat(R(a),R(a+1))` |
| `OP_HASH` | `BB` | `R(a) = hash_new(R(a),R(a+1)..R(a+b*2-1))` |
| `OP_HASHADD` | `BB` | `hash_push(R(a),R(a+1)..R(a+b*2))` |
| `OP_HASHCAT` | `B` | `R(a) = hash_cat(R(a),R(a+1))` |
| `OP_LAMBDA` | `BB` | `R(a) = lambda(Irep(b),OP_L_LAMBDA)` |
| `OP_BLOCK` | `BB` | `R(a) = lambda(Irep(b),OP_L_BLOCK)` |
| `OP_METHOD` | `BB` | `R(a) = lambda(Irep(b),OP_L_METHOD)` |
| `OP_RANGE_INC` | `B` | `R(a) = range_new(R(a),R(a+1),FALSE)` |
| `OP_RANGE_EXC` | `B` | `R(a) = range_new(R(a),R(a+1),TRUE)` |
| `OP_OCLASS` | `B` | `R(a) = ::Object` |
| `OP_CLASS` | `BB` | `R(a) = newclass(R(a),Syms(b),R(a+1))` |
| `OP_MODULE` | `BB` | `R(a) = newmodule(R(a),Syms(b))` |
| `OP_EXEC` | `BB` | `R(a) = blockexec(R(a),Irep[b])` |
| `OP_DEF` | `BB` | `R(a).newmethod(Syms(b),R(a+1)); R(a) = Syms(b)` |
| `OP_ALIAS` | `BB` | `alias_method(target_class,Syms(a),Syms(b))` |
| `OP_UNDEF` | `B` | `undef_method(target_class,Syms(a))` |
| `OP_SCLASS` | `B` | `R(a) = R(a).singleton_class` |
| `OP_TCLASS` | `B` | `R(a) = target_class` |
| `OP_DEBUG` | `BBB` | `print a,b,c` |
| `OP_ERR` | `B` | `raise(LocalJumpError, Pool(a))` |
| `OP_EXT1` | `-` | `make 1st operand 16bit` |
| `OP_EXT2` | `-` | `make 2nd operand 16bit` |
| `OP_EXT3` | `-` | `make 1st and 2nd operands 16bit` |
| `OP_STOP` | `-` | `stop VM` |
|------------------|--------------|----------------------------------------------------------|
| Instruction Name | Operand type | Semantics |
|--------------------|----------------|------------------------------------------------------------|
| `OP_NOP` | `-` | `no operation` |
| `OP_MOVE` | `BB` | `R(a) = R(b)` |
| `OP_LOADL` | `BB` | `R(a) = Pool(b)` |
| `OP_LOADI` | `BB` | `R(a) = mrb_int(b)` |
| `OP_LOADINEG` | `BB` | `R(a) = mrb_int(-b)` |
| `OP_LOADI__1` | `B` | `R(a) = mrb_int(-1)` |
| `OP_LOADI_0` | `B` | `R(a) = mrb_int(0)` |
| `OP_LOADI_1` | `B` | `R(a) = mrb_int(1)` |
| `OP_LOADI_2` | `B` | `R(a) = mrb_int(2)` |
| `OP_LOADI_3` | `B` | `R(a) = mrb_int(3)` |
| `OP_LOADI_4` | `B` | `R(a) = mrb_int(4)` |
| `OP_LOADI_5` | `B` | `R(a) = mrb_int(5)` |
| `OP_LOADI_6` | `B` | `R(a) = mrb_int(6)` |
| `OP_LOADI_7` | `B` | `R(a) = mrb_int(7)` |
| `OP_LOADI16` | `BS` | `R(a) = mrb_int(b)` |
| `OP_LOADI32` | `BSS` | `R(a) = mrb_int((b<<16)+c)` |
| `OP_LOADSYM` | `BB` | `R(a) = Syms(b)` |
| `OP_LOADNIL` | `B` | `R(a) = nil` |
| `OP_LOADSELF` | `B` | `R(a) = self` |
| `OP_LOADT` | `B` | `R(a) = true` |
| `OP_LOADF` | `B` | `R(a) = false` |
| `OP_GETGV` | `BB` | `R(a) = getglobal(Syms(b))` |
| `OP_SETGV` | `BB` | `setglobal(Syms(b), R(a))` |
| `OP_GETSV` | `BB` | `R(a) = Special[Syms(b)]` |
| `OP_SETSV` | `BB` | `Special[Syms(b)] = R(a)` |
| `OP_GETIV` | `BB` | `R(a) = ivget(Syms(b))` |
| `OP_SETIV` | `BB` | `ivset(Syms(b),R(a))` |
| `OP_GETCV` | `BB` | `R(a) = cvget(Syms(b))` |
| `OP_SETCV` | `BB` | `cvset(Syms(b),R(a))` |
| `OP_GETCONST` | `BB` | `R(a) = constget(Syms(b))` |
| `OP_SETCONST` | `BB` | `constset(Syms(b),R(a))` |
| `OP_GETMCNST` | `BB` | `R(a) = R(a)::Syms(b)` |
| `OP_SETMCNST` | `BB` | `R(a+1)::Syms(b) = R(a)` |
| `OP_GETUPVAR` | `BBB` | `R(a) = uvget(b,c)` |
| `OP_SETUPVAR` | `BBB` | `uvset(b,c,R(a))` |
| `OP_GETIDX` | `B` | `R(a) = R(a)[R(a+1)]` |
| `OP_SETIDX` | `B` | `R(a)[R(a+1)] = R(a+2)` |
| `OP_JMP` | `S` | `pc+=a` |
| `OP_JMPIF` | `BS` | `if R(a) pc+=b` |
| `OP_JMPNOT` | `BS` | `if !R(a) pc+=b` |
| `OP_JMPNIL` | `BS` | `if R(a)==nil pc+=b` |
| `OP_JMPUW` | `S` | `unwind_and_jump_to(a)` |
| `OP_EXCEPT` | `B` | `R(a) = exc` |
| `OP_RESCUE` | `BB` | `R(b) = R(a).isa?(R(b))` |
| `OP_RAISEIF` | `B` | `raise(R(a)) if R(a)` |
| `OP_SSEND` | `BBB` | `R(a) = self.send(Syms(b),R(a+1)..,R(a+n+1):R(a+n+2)..) (c=n\|k<<4)` |
| `OP_SSENDB` | `BBB` | `R(a) = self.send(Syms(b),R(a+1)..,R(a+n+1):R(a+n+2)..,&R(a+n+2k+1))` |
| `OP_SEND` | `BBB` | `R(a) = R(a).send(Syms(b),R(a+1)..,R(a+n+1):R(a+n+2)..) (c=n\|k<<4)` |
| `OP_SENDB` | `BBB` | `R(a) = R(a).send(Syms(b),R(a+1)..,R(a+n+1):R(a+n+2)..,&R(a+n+2k+1))` |
| `OP_CALL` | `-` | `self.call(*, **, &) (But overlay the current call frame; tailcall)` |
| `OP_SUPER` | `BB` | `R(a) = super(R(a+1),... ,R(a+b+1))` |
| `OP_ARGARY` | `BS` | `R(a) = argument array (16=m5:r1:m5:d1:lv4)` |
| `OP_ENTER` | `W` | `arg setup according to flags (23=m5:o5:r1:m5:k5:d1:b1)` |
| `OP_KEY_P` | `BB` | `R(a) = kdict.key?(Syms(b))` |
| `OP_KEYEND` | `-` | `raise unless kdict.empty?` |
| `OP_KARG` | `BB` | `R(a) = kdict[Syms(b)]; kdict.delete(Syms(b))` |
| `OP_RETURN` | `B` | `return R(a) (normal)` |
| `OP_RETURN_BLK` | `B` | `return R(a) (in-block return)` |
| `OP_BREAK` | `B` | `break R(a)` |
| `OP_BLKPUSH` | `BS` | `R(a) = block (16=m5:r1:m5:d1:lv4)` |
| `OP_ADD` | `B` | `R(a) = R(a)+R(a+1)` |
| `OP_ADDI` | `BB` | `R(a) = R(a)+mrb_int(b)` |
| `OP_SUB` | `B` | `R(a) = R(a)-R(a+1)` |
| `OP_SUBI` | `BB` | `R(a) = R(a)-mrb_int(b)` |
| `OP_MUL` | `B` | `R(a) = R(a)*R(a+1)` |
| `OP_DIV` | `B` | `R(a) = R(a)/R(a+1)` |
| `OP_EQ` | `B` | `R(a) = R(a)==R(a+1)` |
| `OP_LT` | `B` | `R(a) = R(a)<R(a+1)` |
| `OP_LE` | `B` | `R(a) = R(a)<=R(a+1)` |
| `OP_GT` | `B` | `R(a) = R(a)>R(a+1)` |
| `OP_GE` | `B` | `R(a) = R(a)>=R(a+1)` |
| `OP_ARRAY` | `BB` | `R(a) = ary_new(R(a),R(a+1)..R(a+b))` |
| `OP_ARRAY2` | `BBB` | `R(a) = ary_new(R(b),R(b+1)..R(b+c))` |
| `OP_ARYCAT` | `B` | `ary_cat(R(a),R(a+1))` |
| `OP_ARYPUSH` | `BB` | `ary_push(R(a),R(a+1)..R(a+b))` |
| `OP_ARYSPLAT` | `B` | `R(a) = ary_splat(R(a))` |
| `OP_AREF` | `BBB` | `R(a) = R(b)[c]` |
| `OP_ASET` | `BBB` | `R(b)[c] = R(a)` |
| `OP_APOST` | `BBB` | `*R(a),R(a+1)..R(a+c) = R(a)[b..]` |
| `OP_INTERN` | `B` | `R(a) = intern(R(a))` |
| `OP_SYMBOL` | `BB` | `R(a) = intern(Pool(b))` |
| `OP_STRING` | `BB` | `R(a) = str_dup(Pool(b))` |
| `OP_STRCAT` | `B` | `str_cat(R(a),R(a+1))` |
| `OP_HASH` | `BB` | `R(a) = hash_new(R(a),R(a+1)..R(a+b*2-1))` |
| `OP_HASHADD` | `BB` | `hash_push(R(a),R(a+1)..R(a+b*2))` |
| `OP_HASHCAT` | `B` | `R(a) = hash_cat(R(a),R(a+1))` |
| `OP_LAMBDA` | `BB` | `R(a) = lambda(Irep(b),OP_L_LAMBDA)` |
| `OP_BLOCK` | `BB` | `R(a) = lambda(Irep(b),OP_L_BLOCK)` |
| `OP_METHOD` | `BB` | `R(a) = lambda(Irep(b),OP_L_METHOD)` |
| `OP_RANGE_INC` | `B` | `R(a) = range_new(R(a),R(a+1),FALSE)` |
| `OP_RANGE_EXC` | `B` | `R(a) = range_new(R(a),R(a+1),TRUE)` |
| `OP_OCLASS` | `B` | `R(a) = ::Object` |
| `OP_CLASS` | `BB` | `R(a) = newclass(R(a),Syms(b),R(a+1))` |
| `OP_MODULE` | `BB` | `R(a) = newmodule(R(a),Syms(b))` |
| `OP_EXEC` | `BB` | `R(a) = blockexec(R(a),Irep(b))` |
| `OP_DEF` | `BB` | `R(a).newmethod(Syms(b),R(a+1)); R(a) = Syms(b)` |
| `OP_ALIAS` | `BB` | `alias_method(target_class,Syms(a),Syms(b))` |
| `OP_UNDEF` | `B` | `undef_method(target_class,Syms(a))` |
| `OP_SCLASS` | `B` | `R(a) = R(a).singleton_class` |
| `OP_TCLASS` | `B` | `R(a) = target_class` |
| `OP_DEBUG` | `BBB` | `print a,b,c` |
| `OP_ERR` | `B` | `raise(LocalJumpError, Pool(a))` |
| `OP_EXT1` | `-` | `make 1st operand (a) 16bit` |
| `OP_EXT2` | `-` | `make 2nd operand (b) 16bit` |
| `OP_EXT3` | `-` | `make 1st and 2nd operands 16bit` |
| `OP_STOP` | `-` | `stop VM` |
+19 -13
View File
@@ -30,7 +30,7 @@ end
`ZeroDivisionError` is raised.
#### mruby [3.0.0 (2021-03-05)]
#### mruby [3.1.0 (2022-05-12)]
`RuntimeError` is raised instead of `ZeroDivisionError`. To re-raise the exception, you have to do:
@@ -66,7 +66,7 @@ p Liste.new "foobar"
` [] `
#### mruby [3.0.0 (2021-03-05)]
#### mruby [3.1.0 (2022-05-12)]
`ArgumentError` is raised.
@@ -96,7 +96,7 @@ false
true
```
#### mruby [3.0.0 (2021-03-05)]
#### mruby [3.1.0 (2022-05-12)]
```
true
@@ -107,10 +107,10 @@ true
The declaration form of following visibility methods are not implemented.
* `public`
* `private`
* `protected`
* `module_function`
- `public`
- `private`
- `protected`
- `module_function`
Especially, `module_function` method is not dummy, but no declaration form.
@@ -133,7 +133,7 @@ p 'ok'
ok
```
#### mruby [3.0.0 (2021-03-05)]
#### mruby [3.1.0 (2022-05-12)]
```
test.rb:8: undefined method 'test_func' (NoMethodError)
@@ -155,7 +155,7 @@ defined?(Foo)
nil
```
#### mruby [3.0.0 (2021-03-05)]
#### mruby [3.1.0 (2022-05-12)]
`NameError` is raised.
@@ -172,7 +172,7 @@ alias $a $__a__
` nil `
#### mruby [3.0.0 (2021-03-05)]
#### mruby [3.1.0 (2022-05-12)]
Syntax error
@@ -194,12 +194,12 @@ end
`ArgumentError` is raised.
The re-defined `+` operator does not accept any arguments.
#### mruby [3.0.0 (2021-03-05)]
#### mruby [3.1.0 (2022-05-12)]
` 'ab' `
Behavior of the operator wasn't changed.
## `Kernel#binding` is not supported
## `Kernel#binding` is not supported until [3.0.0 (2021-03-05)]
`Kernel#binding` method is not supported.
@@ -219,6 +219,12 @@ trace (most recent call last):
-e:1: undefined method 'binding' (NoMethodError)
```
#### mruby [3.1.0 (2022-05-12)]
`binding` has been supported since 3.1.0.
See also [mrbgems/mruby-binding](https://github.com/mruby/mruby/tree/master/mrbgems/mruby-binding) and [mrbgems/mruby-binding-core](https://github.com/mruby/mruby/tree/master/mrbgems/mruby-binding-core).
## `nil?` redefinition in conditional expressions
Redefinition of `nil?` is ignored in conditional expressions.
@@ -231,7 +237,7 @@ end
puts(a.nil? ? "truthy" : "falsy")
```
Ruby outputs `falsy`. mruby outputs `truthy`.
Ruby outputs `truthy`. mruby outputs `falsy`.
## Argument Destructuring
+30 -30
View File
@@ -7,17 +7,17 @@
Typical build configuration files are located in `build_config`
directory. For examples:
* `default`: the default configuration
* `host-gprof`: compiles with `gprof` for performance tuning
* `host-m32`: compiles in gcc 32bit mode on 64bit platforms
* `boxing`: compiles all three boxing options
* `clang-asan`: compiles with `clang`'s Address Sanitizer
- `default`: the default configuration
- `host-gprof`: compiles with `gprof` for performance tuning
- `host-m32`: compiles in gcc 32bit mode on 64bit platforms
- `boxing`: compiles all three boxing options
- `clang-asan`: compiles with `clang`'s Address Sanitizer
You can specify the build configuration file with the
`MRUBY_CONFIG` environment variable (or `CONFIG` in short).
If the value specified by `MRUBY_CONFIG` is not the path to
the configuration file, `build_config/${MRUBY_CONFIG}.rb` is
used. So you can specify it as `rake MRUBY_CONFIG=boxing`,
used. So you can specify it as `rake MRUBY_CONFIG=boxing`,
for example.
# Build Configuration Contribution
@@ -32,10 +32,10 @@ pull-request.
We have ported some new syntax from CRuby.
* Single line pattern matching (`12 => x`);
- Single line pattern matching (`12 => x`);
mruby matches only with local variables at the moment
* Numbered block parameter (`x.map{_1 * 2}`)
* End-less `def` (`def double(x) = x*2`)
- Numbered block parameter (`x.map{_1 * 2}`)
- End-less `def` (`def double(x) = x*2`)
# Configuration Options Changed
@@ -59,11 +59,11 @@ Some configuration macro names are changed for consistency (use `MRB_USE_XXX`
| `ENABLE_READLINE` | `MRB_USE_READLINE` |
| `DISABLE_MIRB_UNDERSCORE` | `MRB_NO_MIRB_UNDERSCORE` |
* `MRB_USE_FLOAT32` is changed from `MRB_USE_FLOAT` to make sure `float` here
means using single precision float, and not the opposite of `MRB_NO_FLOAT`.
* `MRB_USE_METHOD_T_STRUCT` uses `struct` version of `mrb_method_t`. More
- `MRB_USE_FLOAT32` is changed from `MRB_USE_FLOAT` to make sure `float` here
means using single-precision float, and not the opposite of `MRB_NO_FLOAT`.
- `MRB_USE_METHOD_T_STRUCT` uses `struct` version of `mrb_method_t`. More
portable but consumes more memory. Turned on by default on 32bit platforms.
* `MRB_` prefix is added to those without.
- `MRB_` prefix is added to those without.
## `MRB_NO_BOXING`
@@ -75,13 +75,13 @@ to be default `mrb_value` representation. Now the default is
## `MRB_WORD_BOXING`
Pack `mrb_value` in an `intptr_t` integer. Consumes less
memory compared to `MRB_NO_BOXING` especially on 32 bit
memory compared to `MRB_NO_BOXING` especially on 32-bit
platforms. `Fixnum` size is 31 bits so some integer values
does not fit in `Fixnum` integers.
## `MRB_NAN_BOXING`
Pack `mrb_value` in a floating pointer number. Nothing
Pack `mrb_value` in a floating-point number. Nothing
changed from previous versions.
## `MRB_USE_MALLOC_TRIM`
@@ -112,40 +112,40 @@ $ bin/mruby -r lib1.rb -r lib2.rb < app.mrb
Instructions that access pool[i]/syms[i] where i>255.
* `OP_LOADL16`
* `OP_STRING16`
* `OP_LOADSYM16`
- `OP_LOADL16`
- `OP_STRING16`
- `OP_LOADSYM16`
Instructions that load a 32 bit integer.
Instructions that load a 32-bit integer.
* `OP_LOADI32`
- `OP_LOADI32`
Instruction that unwinds jump table for rescue/ensure.
* `OP_JMPUW`
- `OP_JMPUW`
Renamed from `OP_RAISE`
* `OP_RAISEIF`
- `OP_RAISEIF`
Instruction that is reserved for the future keyword argument support.
* OP_SENDVK
- OP_SENDVK
## Removed Instructions
Instructions for old exception handling
* `OP_ONERR`
* `OP_POPERR`
* `OP_EPUSH`
* `OP_EPOP`
- `OP_ONERR`
- `OP_POPERR`
- `OP_EPUSH`
- `OP_EPOP`
No more operand extension
* `OP_EXT1`
* `OP_EXT2`
* `OP_EXT3`
- `OP_EXT1`
- `OP_EXT2`
- `OP_EXT3`
## Changed Instructions
+151 -44
View File
@@ -1,48 +1,91 @@
# User visible changes in `mruby3.1` from `mruby3.0`
# Build System
# New Features
## `build_config` directory
## Core Language Features
Several configurations for new platforms are added:
### Keyword Arguments
* `cross-mingw-winetest.rb`
* `cross-mingw.rb`
* `nintendo_switch.rb`
* `serenity.rb`
CRuby3.0 compatible keyword arguments are introduced.
Keyword arguments are basically separated from ordinal arguments.
Some new configurations for added for convenience.
### Other Language Enhancement
* `minimal`: minimal configuration
* `host-f32`: compiles with `mrb_float` as 32 bit `float`
* `host-nofloat`: compiles with no float configuration
- Implement endless-def [Ruby:Feature#16746](https://bugs.ruby-lang.org/issues/16746)
- Replace `R-assignment` by `single-line pattern matching` [Ruby:Feature#15921](https://bugs.ruby-lang.org/issues/15921)
- Support squiggly heredocs. [#5246](https://github.com/mruby/mruby/pull/5246)
- Hash value omission [Ruby:Feature#14579](https://bugs.ruby-lang.org/issues/14579)
And `android_arm64-v8a.rb` was renamed to `android_arm64_v8a.rb` for consistency.
# Configuration Options Changed
## Configuration Options Changed
Some configuration macros are available:
* `MRB_WORDBOX_NO_FLOAT_TRUNCATE`: by default, float values are packed in the word if possible, but define this macro to allocate float values in the heap.
* `MRB_USE_RO_DATA_P_ETEXT`: define this macro if `_etext` is available on your platform.
* `MRB_NO_DEFAULT_RO_DATA_P`: define this macro to avoid using predefined `mrb_ro_data_p()` function
- `MRB_WORDBOX_NO_FLOAT_TRUNCATE`: by default, float values are packed in the word if possible, but define this macro to allocate float values in the heap.
- `MRB_USE_RO_DATA_P_ETEXT`: define this macro if `_etext` is available on your platform.
- `MRB_NO_DEFAULT_RO_DATA_P`: define this macro to avoid using predefined `mrb_ro_data_p()` function
# Language Changes
---
## Keyword Arguments
# Updated Features
CRuby3.0 compatible keyword arguments are introduced.
Keyword arguments are basically separated from ordinal arguments
## New build configurations
## New Methods
We have added several new build configurations in the `build_config` directory.
* `Array#product`
* `Array#repeated_combination`
* `Array#repeated_permutation`
* `Random.bytes`
* `Random#bytes`
- `cross-mingw-winetest.rb`
- `cross-mingw.rb`
- `nintendo_switch.rb`
- `serenity.rb`
- `minimal`: minimal configuration
- `host-f32`: compiles with `mrb_float` as 32 bit `float`
- `host-nofloat`: compiles with no float configuration
- `android_arm64_v8a.rb`: renamed from `android_arm64-v8a.rb`
# Internal Changes
## Core Libraries
### New Methods
- `Array#product`
- `Array#repeated_combination`
- `Array#repeated_permutation`
- `Kernel#__ENCODING__`
- `Random.bytes`
- `Random#bytes`
- `String#center`
### New Gem Enhancement
- `mrbgems/mruby-pack` now supports `M` directive (Q encoding)
- `mrbgems/mruby-pack` now supports `X` directive (back-up by bytes)
- `mrbgems/mruby-pack` now supports `@` directive (absolute position)
- `mrbgems/mruby-pack` now supports `w` directive (BER compression)
## Tools
- `mruby-config` now supports `--cc` and `--ld` options.
- Remove `OP_` prefix from `mruby -v` code dump output.
- Prohibit use of `OP_EXT{1,2,3}` by `mrbc` with `--no-ext-ops` option.
## Features for mruby Developer
- Add new specifier `c` to `mrb_get_args()` for receive Class/Module.
---
# Breaking Changes
## Incompatibly Changed Methods
- `Kernel#printf` (`mruby-sprintf`) Format specifiers `%a` and `%A` are removed.
- `Kernel#puts` (`mruby-print`) Now expand Array arguments.
## mruby VM and bytecode
Due to improvements in the binary format, mruby binaries are no longer backward compatible.
To run the mruby binaries on mruby 3.1, recompile with the mruby 3.1 `mrbc`.
- Upgrade mruby VM version `RITE_VM_VER` to `0300` (means mruby 3.0 or after).
- Upgrade mruby binary version `RITE_BINARY_FORMAT_VER` to `0300`.
## Reintroduced Instructions
@@ -53,18 +96,18 @@ Keyword arguments are basically separated from ordinal arguments
`mruby3.1` removed following instructions.
* `OP_LOADL16`
* `OP_LOADSYM16`
* `OP_STRING16`
* `OP_LAMBDA16`
* `OP_BLOCK16`
* `OP_METHOD16`
* `OP_EXEC16`
- `OP_LOADL16`
- `OP_LOADSYM16`
- `OP_STRING16`
- `OP_LAMBDA16`
- `OP_BLOCK16`
- `OP_METHOD16`
- `OP_EXEC16`
Those instructions are no longer needed by reintroduction of extension instructions.
* `OP_SENDV`
* `OP_SENDVB`
- `OP_SENDV`
- `OP_SENDVB`
Those instructions for method calls with variable number of arguments are no longer needed. They are covered by `OP_SEND` instruction with `n=15`.
@@ -72,10 +115,11 @@ Those instructions for method calls with variable number of arguments are no lon
`mruby3.1` introduces following new instructions.
* `OP_GETIDX`: takes 2 operands `a[b]`
* `OP_SETIDX`: takes 3 operands `a[b]=c`
* `OP_SSEND`: takes 3 operands `a=self.b(c...)`; see `OP_SEND`
* `OP_SSENDB`: takes 3 operands `a=self.b(c...){...}`; see `OP_SEND`
- `OP_GETIDX`: takes 1 operands `R[a][a+1]`
- `OP_SETIDX`: takes 1 operands `R[a][a+1]=R[a+2]`
- `OP_SSEND`: takes 3 operands `a=self.b(c...)`; see `OP_SEND`
- `OP_SSENDB`: takes 3 operands `a=self.b(c...){...}`; see `OP_SEND`
- `OP_SYMBOL`: takes 2 operands `R[a] = intern(Pool[b])`
### `OP_GETIDX` and `OP_SETIDX`
@@ -85,6 +129,10 @@ Execute `obj[int]` and `obj[int] = value` respectively, where `obj` is `string|a
They are similar to `OP_SEND` and `OP_SENDB` respectively. They initialize the `R[a]` by `self` first so that we can skip one `OP_LOADSELF` instruction for each call.
### `OP_SYMBOL`
Extracts the character string placed in the pool as a symbol.
## Changed Instructions
### `OP_SEND` and `OP_SENDB`
@@ -107,14 +155,14 @@ Now takes 2 operands and pushes multiple entries to an array.
### Word Boxing
`MRB_WORD_BOXING` now packs floating point numbers in the word, if the size of `mrb_float` is equal or smaller than the size of `mrb_int` by default.
`MRB_WORD_BOXING` now packs floating-point numbers in the word, if the size of `mrb_float` is equal or smaller than the size of `mrb_int` by default.
If the size of `mrb_float` and `mrb_int` are same, the last 2 bits in the `mrb_float` are trimmed and used as flags. If you need full precision, you need to define `MRB_WORDBOX_NO_FLOAT_TRUNCATE` as described above.
### NaN Boxing
Previous NaN boxing packs values in NaN representation, but pointer retrievals are far more frequent than floating point number references. So we add constant offset to NaN representation to clear higher bits of pointer representation. This representation is called "Favor Pointer" NaN Boxing.
Previous NaN boxing packs values in NaN representation, but pointer retrievals are far more frequent than floating-point number references. So we add constant offset to NaN representation to clear higher bits of pointer representation. This representation is called "Favor Pointer" NaN Boxing.
Also, previous NaN boxing limit the size of `mrb_int` to 4 bytes (32 bits) to fit in NaN values. Now we allocates integer values in the heap, if the value does not fit in the 32 bit range, just like we did in Word Boxing.
Also, previous NaN boxing limit the size of `mrb_int` to 4 bytes (32 bits) to fit in NaN values. Now we allocate integer values in the heap, if the value does not fit in the 32 bit range, just like we did in Word Boxing.
## Constant Folding
@@ -146,3 +194,62 @@ GETIV R1 :@foo
## `String#hash` now use `FNV1a` algorithm
For better and faster hash values.
---
# Major bug fixes
- Fix infinite recursive call bugs in integer division [98799aa6](https://github.com/mruby/mruby/commit/98799aa6)
- Fix to raise TypeError with super inside instance_eval / class_eval [#5476](https://github.com/mruby/mruby/pull/5476)
- Fix to call `method_added` hooks on method definitions; [#2339](https://github.com/mruby/mruby/pull/2339)
- Fix a potential buffer overflow in `time_zonename` [26340a88](https://github.com/mruby/mruby/commit/26340a88)
- Fix `Module.instance_eval` bug [#5528](https://github.com/mruby/mruby/pull/5528)
- Fix fix `M` packing bug [bfe2bd49](https://github.com/mruby/mruby/commit/bfe2bd49)
- Fix a bug regarding attribute assignment with kargs [de2b4bd0](https://github.com/mruby/mruby/commit/de2b4bd0)
- Fix SIGSEGV with mrbgems/mruby-method [#5580](https://github.com/mruby/mruby/pull/5580)
- Fix print error before cleanup in `codegen_error()` [#5603](https://github.com/mruby/mruby/pull/5603)
- Fix a bug in unpacking BER [#5611](https://github.com/mruby/mruby/pull/5611)
- Fix a bug with numbered parameters as arguments [#5605](https://github.com/mruby/mruby/pull/5605)
- Fix `mrb_ary_shift_m` initialization bug [27d1e013](https://github.com/mruby/mruby/commit/27d1e013)
- Fix keyword argument with `super` [#5628](https://github.com/mruby/mruby/pull/5628)
- Fix a bug with numbered parameters on toplevel [7e7f1b2f](https://github.com/mruby/mruby/commit/7e7f1b2f)
- Fix keyword argument bug [#5632](https://github.com/mruby/mruby/issues/5632)
- Fix multiple assignments in parameters [#5647](https://github.com/mruby/mruby/issues/5647)
- Fix keyword parameters not passing through super [#5660](https://github.com/mruby/mruby/issues/5660)
- Fix infinite loop from unclosed here-doc [#5676](https://github.com/mruby/mruby/issues/5676)
- Fix negative integer division bug [#5678](https://github.com/mruby/mruby/issues/5678)
# CVEs
## Fixed CVEs
Following CVEs are fixed in this release.
- [CVE-2021-4110](https://nvd.nist.gov/vuln/detail/CVE-2021-4110)
- [CVE-2021-4188](https://nvd.nist.gov/vuln/detail/CVE-2021-4188)
- [CVE-2022-0080](https://nvd.nist.gov/vuln/detail/CVE-2022-0080)
- [CVE-2022-0240](https://nvd.nist.gov/vuln/detail/CVE-2022-0240)
- [CVE-2022-0326](https://nvd.nist.gov/vuln/detail/CVE-2022-0326)
- [CVE-2022-0481](https://nvd.nist.gov/vuln/detail/CVE-2022-0481)
- [CVE-2022-0631](https://nvd.nist.gov/vuln/detail/CVE-2022-0631)
- [CVE-2022-0632](https://nvd.nist.gov/vuln/detail/CVE-2022-0632)
- [CVE-2022-0890](https://nvd.nist.gov/vuln/detail/CVE-2022-0890)
- [CVE-2022-1071](https://nvd.nist.gov/vuln/detail/CVE-2022-1071)
- [CVE-2022-1106](https://nvd.nist.gov/vuln/detail/CVE-2022-1106)
- [CVE-2022-1201](https://nvd.nist.gov/vuln/detail/CVE-2022-1201)
- [CVE-2022-1427](https://nvd.nist.gov/vuln/detail/CVE-2022-1427)
## Unaffected CVEs
Following CVEs do not cause problems in this release. They are fixed in the later release.
- [CVE-2022-0481](https://nvd.nist.gov/vuln/detail/CVE-2022-0481)
- [CVE-2022-0525](https://nvd.nist.gov/vuln/detail/CVE-2022-0525)
- [CVE-2022-0570](https://nvd.nist.gov/vuln/detail/CVE-2022-0570)
- [CVE-2022-0614](https://nvd.nist.gov/vuln/detail/CVE-2022-0614)
- [CVE-2022-0623](https://nvd.nist.gov/vuln/detail/CVE-2022-0623)
- [CVE-2022-0630](https://nvd.nist.gov/vuln/detail/CVE-2022-0630)
- [CVE-2022-0717](https://nvd.nist.gov/vuln/detail/CVE-2022-0817)
- [CVE-2022-1212](https://nvd.nist.gov/vuln/detail/CVE-2022-1212)
- [CVE-2022-1276](https://nvd.nist.gov/vuln/detail/CVE-2022-1276)
- [CVE-2022-1286](https://nvd.nist.gov/vuln/detail/CVE-2022-1286)
+61
View File
@@ -0,0 +1,61 @@
# User visible changes in `mruby3.2` from `mruby3.1`
# The language
- Now `a::B = c` should evaluate `a` then `c`.
- Anonymous arguments `*`, `**`, `&` can be passed for forwarding.
- Multi-precision integer is available now via `mruby-bigint` gem.
# mruby VM and bytecode
- `OP_ARYDUP` was renamed to `OP_ARYSPLAT`. The instruction name
was changed but instruction number and basic behavior have not
changed (except that `ARYDUP nil` makes `[]`).
# Tools
## `mruby`
- `-b` only specifies the script is the binary. The files loaded by `-r` are not affected by the option.
- `mruby` now loads complied binary if the suffix is `.mrb`.
## `mrbc`
- Add `--no-optimize` option to disable optimization.
# mrbgems
## mruby-class-ext
- Add `Class#subclasses` method.
- Add `Module#undefined_instance_methods` method.
## New bundled gems
- mruby-errno from [https://github.com/iij/mruby-errno.git]
- mruby-set from [https://github.com/yui-knk/mruby-set.git]
- mruby-dir from [https://github.com/iij/mruby-dir.git]
# CVEs
Following CVEs are fixed.
- [CVE-2022-0080](https://nvd.nist.gov/vuln/detail/CVE-2022-0080)
- [CVE-2022-0240](https://nvd.nist.gov/vuln/detail/CVE-2022-0240)
- [CVE-2022-0326](https://nvd.nist.gov/vuln/detail/CVE-2022-0326)
- [CVE-2022-0631](https://nvd.nist.gov/vuln/detail/CVE-2022-0631)
- [CVE-2022-0481](https://nvd.nist.gov/vuln/detail/CVE-2022-0481)
- [CVE-2022-0525](https://nvd.nist.gov/vuln/detail/CVE-2022-0525)
- [CVE-2022-0570](https://nvd.nist.gov/vuln/detail/CVE-2022-0570)
- [CVE-2022-0614](https://nvd.nist.gov/vuln/detail/CVE-2022-0614)
- [CVE-2022-0623](https://nvd.nist.gov/vuln/detail/CVE-2022-0623)
- [CVE-2022-0630](https://nvd.nist.gov/vuln/detail/CVE-2022-0630)
- [CVE-2022-0631](https://nvd.nist.gov/vuln/detail/CVE-2022-0631)
- [CVE-2022-0632](https://nvd.nist.gov/vuln/detail/CVE-2022-0632)
- [CVE-2022-0717](https://nvd.nist.gov/vuln/detail/CVE-2022-0717)
- [CVE-2022-0890](https://nvd.nist.gov/vuln/detail/CVE-2022-0890)
- [CVE-2022-1106](https://nvd.nist.gov/vuln/detail/CVE-2022-1106)
- [CVE-2022-1212](https://nvd.nist.gov/vuln/detail/CVE-2022-1212)
- [CVE-2022-1276](https://nvd.nist.gov/vuln/detail/CVE-2022-1276)
- [CVE-2022-1286](https://nvd.nist.gov/vuln/detail/CVE-2022-1286)
- [CVE-2022-1934](https://nvd.nist.gov/vuln/detail/CVE-2022-1934)
@@ -1,4 +1,3 @@
C and Ruby Extension Example
=========
# C and Ruby Extension Example
This is an example gem which implements a C and Ruby extension.
@@ -1,4 +1,3 @@
C Extension Example
=========
# C Extension Example
This is an example gem which implements a C extension.
@@ -0,0 +1,3 @@
# C Data Extension Example
This is an example gem which implements a C extension with Data.
@@ -0,0 +1,23 @@
MRuby::Gem::Specification.new('cdata_extension_example') do |spec|
spec.license = 'MIT'
spec.author = 'mruby developers'
# Add compile flags
# spec.cc.flags << '-g'
# Add cflags to all
# spec.mruby.cc.flags << '-g'
# Add libraries
# spec.linker.libraries << 'external_lib'
# Default build files
# spec.rbfiles = Dir.glob("#{dir}/mrblib/*.rb")
# spec.objs = Dir.glob("#{dir}/src/*.{c,cpp,m,asm,S}").map { |f| objfile(f.relative_path_from(dir).pathmap("#{build_dir}/%X")) }
# spec.test_rbfiles = Dir.glob("#{dir}/test/*.rb")
# spec.test_objs = Dir.glob("#{dir}/test/*.{c,cpp,m,asm,S}").map { |f| objfile(f.relative_path_from(dir).pathmap("#{build_dir}/%X")) }
# spec.test_preload = 'test/assert.rb'
# Values accessible as TEST_ARGS inside test scripts
# spec.test_args = {'tmp_dir' => Dir::tmpdir}
end
@@ -0,0 +1,77 @@
#include <mruby.h>
#include <mruby/string.h>
#include <mruby/class.h>
#include <mruby/data.h>
#include <stdio.h>
static void mrb_foo_free(mrb_state *mrb, void *ptr) {
/* custom destructor */
mrb_free(mrb, ptr);
}
struct mrb_data_type mrb_foo_type = { "Foo", mrb_foo_free };
struct Foo {
int bar;
char baz[32];
};
static mrb_value
mrb_foo_initialize(mrb_state *mrb, mrb_value self)
{
struct Foo *f;
f = (struct Foo*)mrb_malloc(mrb, sizeof(struct Foo));
f->bar = 0;
DATA_PTR(self) = f;
DATA_TYPE(self) = &mrb_foo_type;
return self;
}
static mrb_value
mrb_foo_get_bar(mrb_state *mrb, mrb_value self)
{
struct Foo *f;
f = (struct Foo*)mrb_data_get_ptr(mrb, self, &mrb_foo_type);
if(f == NULL) {
mrb_raise(mrb, E_RUNTIME_ERROR, "uninitialized data");
}
return mrb_fixnum_value(f->bar);
}
static mrb_value
mrb_foo_set_bar(mrb_state *mrb, mrb_value self)
{
struct Foo *f;
int v;
f = (struct Foo*)mrb_data_get_ptr(mrb, self, &mrb_foo_type);
if(f == NULL) {
mrb_raise(mrb, E_RUNTIME_ERROR, "uninitialized data");
}
mrb_get_args(mrb, "i", &v);
f->bar = v;
return mrb_fixnum_value(f->bar);
}
void
mrb_cdata_extension_example_gem_init(mrb_state* mrb) {
struct RClass *class_foo;
class_foo = mrb_define_class(mrb, "Foo", mrb->object_class);
MRB_SET_INSTANCE_TT(class_foo, MRB_TT_CDATA);
mrb_define_method(mrb, class_foo, "initialize", mrb_foo_initialize, MRB_ARGS_NONE());
mrb_define_method(mrb, class_foo, "bar", mrb_foo_get_bar, MRB_ARGS_NONE());
mrb_define_method(mrb, class_foo, "bar=", mrb_foo_set_bar, MRB_ARGS_REQ(1));
}
void
mrb_cdata_extension_example_gem_final(mrb_state* mrb) {
/* gem finalizer */
}
@@ -0,0 +1,7 @@
#include <mruby.h>
void
mrb_cdata_extension_example_gem_test(mrb_state *mrb)
{
/* test initializer in C */
}
@@ -0,0 +1,39 @@
# Hints for creating your own bigint GEM
This example gem, mruby-YOUR-bigint, is available under the Creative Commons Zero License (CC0).
This file is placed for the purpose of describing hints for creating a `mruby-bigint` compatible GEM to realize multiple integers.
The file structure in this example is as follows:
```
+- mruby-YOUR-bigint/ <- Make this directory public if necessary.
| Change the name of copied directory.
|
+- TODO-HINT.md <- This file is currently viewing by you.
| Remove this from copied directory.
|
+- core/
| |
| +- bigint.c <- Body of the implementation.
|
+- mrbgem.rake <- GEM name is "mruby-bigint".
May be depended on by other GEMs.
```
Implementors of own bigints should copy below this directory to another directory and do the following:
- Rewrite `spec.author`, `spec.license`, `spec.homepage` and `spec.summary` in `<gem-dir>/mrbgem.rake` file to those of your own implementors.
- Implement the respective functions in `<gem-dir>/core/bigint.c`.
- Define and use an object structure for `MRB_TT_BIGINT` type-tag.
It is recommended to use `mrb_static_assert_object_size()` to ensure that the size of the object structure is within 6 words.
- Delete this file from the destination of the copy.
If you wish to use it as an alternative to the `mruby-bigint` provided by mruby, please leave the GEM name in `<gem-dir>/mrbgem.rake` as it is.
This is an important factor when it is depended from other GEMs with `spec.add_dependency 'mruby-bigint'`.
The name of the top directory of GEM can be changed arbitrarily.
The name of the git repository can also be changed arbitrarily.
Note that there is no need for an initialization function as there is in normal GEM.
If you need it, create a file `<gem-dir>/src/bigint.c` for example, and implement the `mrb_mruby_bigint_gem_init()` function.
@@ -0,0 +1,70 @@
/*
* If placed under the "mruby/examples/mrbgems/mruby-YOUR-bigint" directory,
* this file is available under the Creative Commons Zero License (CC0).
* Note that file is incomplete.
*
* TODO: If this file is copied and another implementation is written,
* remove this comment block from the copied file.
*/
#include <mruby.h>
#include <mruby/numeric.h>
/*
* The "mruby/internal.h" file should be placed after the other mruby header files.
*/
#include <mruby/internal.h>
/*
* The "mruby/presym.h" file is placed at the end of the mruby header file.
*/
#include <mruby/presym.h>
/*
* Define your own struct RBigint.
*
* - Object type must be MRB_TT_BIGINT.
* - If the structure is named RBigint, MRB_OBJ_ALLOC() can be used as is.
*/
struct RBigint {
/*
* Put MRB_OBJECT_HEADER before the first member of the structure.
*/
MRB_OBJECT_HEADER;
/*
* Up to 3 words can be freely configured.
*/
size_t len;
size_t capa;
uintptr_t *num;
};
/*
* Assert with mrb_static_assert_object_size() that the entire structure is within 6 words.
*/
mrb_static_assert_object_size(struct RBigint);
/*
* The lower 16 bits of the object flags (`obj->flags`) can be used freely by the GEM author.
*/
#define MY_BIGINT_NEGATIVE_FLAG 1
#define MY_BIGINT_NEGATIVE_P(obj) ((obj)->flags & MY_BIGINT_NEGATIVE_FLAG)
/*
* Implement the functions declared in `#ifdef MRUBY_USE_BIGINT ... #endif` in the "mruby/internal.h" file.
*/
mrb_value
mrb_bint_new_int(mrb_state *mrb, mrb_int x)
{
struct RBigint *obj = MRB_OBJ_ALLOC(mrb, MRB_TT_BIGINT, mrb->integer_class);
...
return mrb_obj_value(obj);
}
/*
* The implementation function continues...
*/
@@ -0,0 +1,12 @@
MRuby::Gem::Specification.new('mruby-bigint') do |spec|
spec.author = 'YOUR-NAME-HERE'
spec.license = 'YOUR-LICENSE-HERE'
spec.summary = 'Yet another multi-precision Integer extension'
spec.homepage = 'https://gem.example/for/mruby-YOUR-bigint'
spec.build.defines << 'MRB_USE_BIGINT'
#spec.build.linker.libraries << 'gmp' # when uses libgmp
spec.build.libmruby_core_objs << Dir.glob(File.join(__dir__, 'core/**/*.c')).map { |fn|
objfile(fn.relative_path_from(__dir__).pathmap("#{spec.build_dir}/%X"))
}
end
@@ -1,4 +1,3 @@
Pure Ruby Extension Example
=========
# Pure Ruby Extension Example
This is an example gem which implements a pure Ruby extension.
+11
View File
@@ -46,6 +46,7 @@
//#define MRB_NO_METHOD_CACHE
/* size of the method cache (need to be the power of 2) */
//#define MRB_METHOD_CACHE_SIZE (1<<8)
//#define MRB_USE_INLINE_METHOD_CACHE
/* add -DMRB_USE_METHOD_T_STRUCT on machines that use higher bits of function pointers */
/* no MRB_USE_METHOD_T_STRUCT requires highest 2 bits of function pointers to be zero */
@@ -107,6 +108,16 @@
/* string class to handle UTF-8 encoding */
//#define MRB_UTF8_STRING
/* maximum length of strings */
/* the default value is 1MB */
/* set this value to zero to skip the check */
//#define MRB_STR_LENGTH_MAX 1048576
/* maximum length of arrays */
/* the default value is 2**17 entries */
/* set this value to zero to skip the check */
//#define MRB_ARY_LENGTH_MAX 131072
/* argv max size in mrb_funcall */
//#define MRB_FUNCALL_ARGC_MAX 16
+67 -30
View File
@@ -1,7 +1,7 @@
/*
** mruby - An embeddable Ruby implementation
**
** Copyright (c) mruby developers 2010-2021
** Copyright (c) mruby developers 2010-2022
**
** Permission is hereby granted, free of charge, to any person obtaining
** a copy of this software and associated documentation files (the
@@ -154,7 +154,7 @@ typedef uint8_t mrb_code;
*/
typedef uint32_t mrb_aspec;
struct mrb_irep;
typedef struct mrb_irep mrb_irep;
struct mrb_state;
/**
@@ -178,6 +178,7 @@ typedef struct {
uint8_t cci; /* called from C function */
mrb_sym mid;
const struct RProc *proc;
struct RProc *blk;
mrb_value *stack;
const mrb_code *pc; /* current address on iseq of this proc */
union {
@@ -312,7 +313,7 @@ typedef struct mrb_state {
struct RClass *eException_class;
struct RClass *eStandardError_class;
struct RObject *nomem_err; /* pre-allocated NoMemoryError */
struct RObject *stack_err; /* pre-allocated SysStackError */
struct RObject *stack_err; /* pre-allocated SystemStackError */
#ifdef MRB_GC_FIXED_ARENA
struct RObject *arena_err; /* pre-allocated arena overflow error */
#endif
@@ -361,7 +362,18 @@ MRB_API struct RClass *mrb_define_class_id(mrb_state *mrb, mrb_sym name, struct
MRB_API struct RClass *mrb_define_module(mrb_state *mrb, const char *name);
MRB_API struct RClass *mrb_define_module_id(mrb_state *mrb, mrb_sym name);
/**
* Returns the singleton class of an object.
*
* Raises a `TypeError` exception for immediate values.
*/
MRB_API mrb_value mrb_singleton_class(mrb_state *mrb, mrb_value val);
/**
* Returns the singleton class of an object.
*
* Returns `NULL` for immediate values,
*/
MRB_API struct RClass *mrb_singleton_class_ptr(mrb_state *mrb, mrb_value val);
/**
@@ -686,9 +698,9 @@ MRB_API struct RClass * mrb_module_new(mrb_state *mrb);
* example_class = mrb_define_class(mrb, "ExampleClass", mrb->object_class);
* cd = mrb_class_defined(mrb, "ExampleClass");
*
* // If mrb_class_defined returns 1 then puts "True"
* // If mrb_class_defined returns 0 then puts "False"
* if (cd == 1){
* // If mrb_class_defined returns TRUE then puts "True"
* // If mrb_class_defined returns FALSE then puts "False"
* if (cd) {
* puts("True");
* }
* else {
@@ -735,9 +747,9 @@ MRB_API struct RClass* mrb_exc_get_id(mrb_state *mrb, mrb_sym name);
* example_inner = mrb_define_class_under(mrb, example_outer, "ExampleInner", mrb->object_class);
* cd = mrb_class_defined_under(mrb, example_outer, "ExampleInner");
*
* // If mrb_class_defined_under returns 1 then puts "True"
* // If mrb_class_defined_under returns 0 then puts "False"
* if (cd == 1){
* // If mrb_class_defined_under returns TRUE then puts "True"
* // If mrb_class_defined_under returns FALSE then puts "False"
* if (cd) {
* puts("True");
* }
* else {
@@ -821,14 +833,14 @@ MRB_API mrb_value mrb_obj_dup(mrb_state *mrb, mrb_value obj);
* example_class = mrb_define_class(mrb, "ExampleClass", mrb->object_class);
* mrb_define_method(mrb, example_class, "example_method", exampleMethod, MRB_ARGS_NONE());
* mid = mrb_intern_str(mrb, mrb_str_new_lit(mrb, "example_method" ));
* obj_resp = mrb_obj_respond_to(mrb, example_class, mid); // => 1(true in Ruby world)
* obj_resp = mrb_obj_respond_to(mrb, example_class, mid); // => TRUE (true in Ruby world)
*
* // If mrb_obj_respond_to returns 1 then puts "True"
* // If mrb_obj_respond_to returns 0 then puts "False"
* if (obj_resp == 1) {
* // If mrb_obj_respond_to returns TRUE then puts "True"
* // If mrb_obj_respond_to returns FALSE then puts "False"
* if (obj_resp) {
* puts("True");
* }
* else if (obj_resp == 0) {
* else {
* puts("False");
* }
* }
@@ -948,14 +960,14 @@ typedef const char *mrb_args_format;
/**
* Get keyword arguments by `mrb_get_args()` with `:` specifier.
*
* `mrb_kwargs::num` indicates that the number of keyword values.
* `mrb_kwargs::num` indicates that the total number of keyword values.
*
* `mrb_kwargs::values` is an object array, and the keyword argument corresponding to the string array is assigned.
* Note that `undef` is assigned if there is no keyword argument corresponding to `mrb_kwargs::optional`.
* `mrb_kwargs::required` indicates that the specified number of keywords starting from the beginning of the `mrb_sym` array are required.
*
* `mrb_kwargs::table` accepts a string array.
* `mrb_kwargs::table` accepts a `mrb_sym` array of C.
*
* `mrb_kwargs::required` indicates that the specified number of keywords starting from the beginning of the string array are required.
* `mrb_kwargs::values` is an object array of C, and the keyword argument corresponding to the `mrb_sym` array is assigned.
* Note that `undef` is assigned if there is no keyword argument corresponding over `mrb_kwargs::required` to `mrb_kwargs::num`.
*
* `mrb_kwargs::rest` is the remaining keyword argument that can be accepted as `**rest` in Ruby.
* If `NULL` is specified, `ArgumentError` is raised when there is an undefined keyword.
@@ -964,11 +976,11 @@ typedef const char *mrb_args_format;
*
* // def method(a: 1, b: 2)
*
* uint32_t kw_num = 2;
* const char *kw_names[kw_num] = { "a", "b" };
* uint32_t kw_required = 0;
* mrb_int kw_num = 2;
* mrb_int kw_required = 0;
* mrb_sym kw_names[] = { mrb_intern_lit(mrb, "a"), mrb_intern_lit(mrb, "b") };
* mrb_value kw_values[kw_num];
* const mrb_kwargs kwargs = { kw_num, kw_required, kw_names, kw_values, NULL };
* mrb_kwargs kwargs = { kw_num, kw_required, kw_names, kw_values, NULL };
*
* mrb_get_args(mrb, ":", &kwargs);
* if (mrb_undef_p(kw_values[0])) { kw_values[0] = mrb_fixnum_value(1); }
@@ -979,10 +991,12 @@ typedef const char *mrb_args_format;
*
* mrb_value str, kw_rest;
* uint32_t kw_num = 3;
* const mrb_sym kw_names[kw_num] = { MRB_SYM(x), MRB_SYM(y), MRB_SYM(z) };
* uint32_t kw_required = 1;
* // Note that `#include <mruby/presym.h>` is required beforehand because `MRB_SYM()` is used.
* // If the usage of `MRB_SYM()` is not desired, replace it with `mrb_intern_lit()`.
* mrb_sym kw_names[] = { MRB_SYM(x), MRB_SYM(y), MRB_SYM(z) };
* mrb_value kw_values[kw_num];
* const mrb_kwargs kwargs = { kw_num, kw_required, kw_names, kw_values, &kw_rest };
* mrb_kwargs kwargs = { kw_num, kw_required, kw_names, kw_values, &kw_rest };
*
* mrb_get_args(mrb, "S:", &str, &kwargs);
* // or: mrb_get_args(mrb, ":S", &kwargs, &str);
@@ -993,8 +1007,8 @@ typedef struct mrb_kwargs mrb_kwargs;
struct mrb_kwargs
{
uint32_t num; /* number of keyword arguments */
uint32_t required; /* number of required keyword arguments */
mrb_int num; /* number of keyword arguments */
mrb_int required; /* number of required keyword arguments */
const mrb_sym *table; /* C array of symbols for keyword names */
mrb_value *values; /* keyword argument values */
mrb_value *rest; /* keyword rest (dict) */
@@ -1012,6 +1026,13 @@ struct mrb_kwargs
*/
MRB_API mrb_int mrb_get_args(mrb_state *mrb, mrb_args_format format, ...);
/**
* Array version of mrb_get_args()
*
* @param ptr Array of void*, in the same order as the varargs version.
*/
MRB_API mrb_int mrb_get_args_a(mrb_state *mrb, mrb_args_format format, void** ptr);
MRB_INLINE mrb_sym
mrb_get_mid(mrb_state *mrb) /* get method symbol */
{
@@ -1178,13 +1199,13 @@ MRB_API void mrb_free(mrb_state*, void*);
*/
#define MRB_OBJ_ALLOC(mrb, tt, klass) ((MRB_VTYPE_TYPEOF(tt)*)mrb_obj_alloc(mrb, tt, klass))
MRB_API mrb_value mrb_str_new(mrb_state *mrb, const char *p, size_t len);
MRB_API mrb_value mrb_str_new(mrb_state *mrb, const char *p, mrb_int len);
/**
* Turns a C string into a Ruby string value.
*/
MRB_API mrb_value mrb_str_new_cstr(mrb_state*, const char*);
MRB_API mrb_value mrb_str_new_static(mrb_state *mrb, const char *p, size_t len);
MRB_API mrb_value mrb_str_new_static(mrb_state *mrb, const char *p, mrb_int len);
#define mrb_str_new_lit(mrb, lit) mrb_str_new_static(mrb, (lit), mrb_strlen_lit(lit))
MRB_API mrb_value mrb_obj_freeze(mrb_state*, mrb_value);
@@ -1336,7 +1357,7 @@ MRB_API mrb_value mrb_obj_clone(mrb_state *mrb, mrb_value self);
#define TOLOWER(c) (ISUPPER(c) ? ((c) | 0x20) : (c))
#endif
MRB_API mrb_value mrb_exc_new(mrb_state *mrb, struct RClass *c, const char *ptr, size_t len);
MRB_API mrb_value mrb_exc_new(mrb_state *mrb, struct RClass *c, const char *ptr, mrb_int len);
MRB_API mrb_noreturn void mrb_exc_raise(mrb_state *mrb, mrb_value exc);
MRB_API mrb_noreturn void mrb_raise(mrb_state *mrb, struct RClass *c, const char *msg);
@@ -1404,6 +1425,9 @@ MRB_API mrb_value mrb_check_string_type(mrb_state *mrb, mrb_value str);
#define mrb_to_str(mrb, str) mrb_ensure_string_type(mrb,str)
/* obsolete: use mrb_obj_as_string() instead */
#define mrb_str_to_str(mrb, str) mrb_obj_as_string(mrb, str)
/* check if val is an integer (including Bigint) */
MRB_API mrb_value mrb_ensure_integer_type(mrb_state *mrb, mrb_value val);
/* check if val fit in mrb_int */
MRB_API mrb_value mrb_ensure_int_type(mrb_state *mrb, mrb_value val);
#define mrb_as_int(mrb, val) mrb_integer(mrb_ensure_int_type(mrb, val))
/* obsolete: use mrb_ensure_int_type() instead */
@@ -1436,6 +1460,10 @@ MRB_API mrb_bool mrb_func_basic_p(mrb_state *mrb, mrb_value obj, mrb_sym mid, mr
* Resume a Fiber
*
* Implemented in mruby-fiber
*
* Switches to the specified fiber and executes. Like the `Fiber#resume` method.
*
* @note It can only be called before entering the mruby VM (e.g. in the `main()` function).
*/
MRB_API mrb_value mrb_fiber_resume(mrb_state *mrb, mrb_value fib, mrb_int argc, const mrb_value *argv);
@@ -1443,6 +1471,15 @@ MRB_API mrb_value mrb_fiber_resume(mrb_state *mrb, mrb_value fib, mrb_int argc,
* Yield a Fiber
*
* Implemented in mruby-fiber
*
* Passes control to the caller fiber of the running fiber. Like the `Fiber.yield` method.
*
* @note This function is only available from inside a function defined as a method by,
* for example, `mrb_define_method()`.
* Also, the work following `mrb_fiber_yield()` cannot be performed,
* and the return value of `mrb_fiber_yield()` must be returned as is.
*
* return mrb_fiber_yield(mrb, argc, argv);
*/
MRB_API mrb_value mrb_fiber_yield(mrb_state *mrb, mrb_int argc, const mrb_value *argv);
-3
View File
@@ -85,7 +85,6 @@ struct RArray {
#define ARY_SET_SHARED_FLAG(a) ((a)->flags |= MRB_ARY_SHARED)
#define ARY_UNSET_SHARED_FLAG(a) ((a)->flags &= ~MRB_ARY_SHARED)
void mrb_ary_decref(mrb_state*, mrb_shared_array*);
MRB_API void mrb_ary_modify(mrb_state*, struct RArray*);
MRB_API mrb_value mrb_ary_new_capa(mrb_state*, mrb_int);
@@ -296,8 +295,6 @@ MRB_API mrb_value mrb_ary_join(mrb_state *mrb, mrb_value ary, mrb_value sep);
*/
MRB_API mrb_value mrb_ary_resize(mrb_state *mrb, mrb_value ary, mrb_int new_len);
/* helper functions */
mrb_value mrb_ary_subseq(mrb_state *mrb, mrb_value ary, mrb_int beg, mrb_int len);
MRB_END_DECL
+2 -2
View File
@@ -180,6 +180,8 @@ mrb_integer_func(mrb_value o) {
#else
#define mrb_float_p(o) WORDBOX_OBJ_TYPE_P(o, FLOAT)
#endif
#else
#define mrb_float_p(o) FALSE
#endif
#define mrb_array_p(o) WORDBOX_OBJ_TYPE_P(o, ARRAY)
#define mrb_string_p(o) WORDBOX_OBJ_TYPE_P(o, STRING)
@@ -222,9 +224,7 @@ mrb_type(mrb_value o)
mrb_fixnum_p(o) ? MRB_TT_INTEGER :
mrb_symbol_p(o) ? MRB_TT_SYMBOL :
mrb_undef_p(o) ? MRB_TT_UNDEF :
#ifndef MRB_NO_FLOAT
mrb_float_p(o) ? MRB_TT_FLOAT :
#endif
mrb_val_union(o).bp->tt;
}
-11
View File
@@ -73,8 +73,6 @@ mrb_class(mrb_state *mrb, mrb_value v)
#define MRB_SET_INSTANCE_TT(c, tt) ((c)->flags = (((c)->flags & ~MRB_INSTANCE_TT_MASK) | (char)(tt)))
#define MRB_INSTANCE_TT(c) (enum mrb_vtype)((c)->flags & MRB_INSTANCE_TT_MASK)
struct RClass *mrb_vm_define_class(mrb_state*, mrb_value, mrb_value, mrb_sym);
struct RClass *mrb_vm_define_module(mrb_state*, mrb_value, mrb_sym);
MRB_API void mrb_define_method_raw(mrb_state*, struct RClass*, mrb_sym, mrb_method_t);
MRB_API void mrb_alias_method(mrb_state*, struct RClass *c, mrb_sym a, mrb_sym b);
MRB_API void mrb_remove_method(mrb_state *mrb, struct RClass *c, mrb_sym sym);
@@ -83,15 +81,6 @@ MRB_API mrb_method_t mrb_method_search_vm(mrb_state*, struct RClass**, mrb_sym);
MRB_API mrb_method_t mrb_method_search(mrb_state*, struct RClass*, mrb_sym);
MRB_API struct RClass* mrb_class_real(struct RClass* cl);
mrb_value mrb_instance_new(mrb_state *mrb, mrb_value cv);
void mrb_class_name_class(mrb_state*, struct RClass*, struct RClass*, mrb_sym);
mrb_bool mrb_const_name_p(mrb_state*, const char*, mrb_int);
mrb_value mrb_class_find_path(mrb_state*, struct RClass*);
mrb_value mrb_mod_to_s(mrb_state*, mrb_value);
void mrb_gc_mark_mt(mrb_state*, struct RClass*);
size_t mrb_gc_mark_mt_size(mrb_state*, struct RClass*);
void mrb_gc_free_mt(mrb_state*, struct RClass*);
#ifndef MRB_NO_METHOD_CACHE
void mrb_mc_clear_by_class(mrb_state *mrb, struct RClass* c);
+2 -4
View File
@@ -99,9 +99,9 @@ enum mrb_string_type {
struct mrb_parser_heredoc_info {
mrb_bool allow_indent:1;
mrb_bool remove_indent:1;
mrb_bool line_head:1;
size_t indent;
mrb_ast_node *indented;
mrb_bool line_head:1;
enum mrb_string_type type;
const char *term;
int term_len;
@@ -127,7 +127,7 @@ struct mrb_parser_state {
int column;
enum mrb_lex_state_enum lstate;
mrb_ast_node *lex_strterm; /* (type nest_level beg . end) */
struct parser_lex_strterm *lex_strterm;
unsigned int cond_stack;
unsigned int cmdarg_stack;
@@ -143,10 +143,8 @@ struct mrb_parser_state {
int tidx;
int tsiz;
mrb_ast_node *all_heredocs; /* list of mrb_parser_heredoc_info* */
mrb_ast_node *heredocs_from_nextline;
mrb_ast_node *parsing_heredoc;
mrb_ast_node *lex_strterm_before_heredoc;
void *ylval;
+4 -3
View File
@@ -31,10 +31,11 @@ typedef struct mrb_irep_debug_info_file {
uint32_t line_entry_count;
mrb_debug_line_type line_type;
union {
const char *s;
void *ptr;
uint16_t *ary;
mrb_irep_debug_info_line *flat_map;
uint8_t *packed_map;
const uint16_t *ary;
const mrb_irep_debug_info_line *flat_map;
const uint8_t *packed_map;
} lines;
} mrb_irep_debug_info_file;
+3 -5
View File
@@ -21,15 +21,13 @@ MRB_BEGIN_DECL
#define MRB_DUMP_STATIC 2
#define DUMP_DEBUG_INFO MRB_DUMP_DEBUG_INFO /* deprecated */
int mrb_dump_irep(mrb_state *mrb, const mrb_irep *irep, uint8_t flags, uint8_t **bin, size_t *bin_size);
#ifndef MRB_NO_STDIO
int mrb_dump_irep_binary(mrb_state*, const mrb_irep*, uint8_t, FILE*);
int mrb_dump_irep_cfunc(mrb_state *mrb, const mrb_irep*, uint8_t flags, FILE *f, const char *initname);
int mrb_dump_irep_cstruct(mrb_state *mrb, const mrb_irep*, uint8_t flags, FILE *f, const char *initname);
mrb_irep *mrb_read_irep_file(mrb_state*, FILE*);
MRB_API mrb_value mrb_load_irep_file(mrb_state*,FILE*);
MRB_API mrb_value mrb_load_irep_file_cxt(mrb_state*, FILE*, mrbc_context*);
mrb_irep *mrb_read_irep_file(mrb_state*, FILE*);
int mrb_dump_irep_binary(mrb_state*, const mrb_irep*, uint8_t, FILE*);
#endif
/* avoid mrb_read_irep(); use mrb_read_irep_buf() instead (may cause buffer overflow) */
MRB_API mrb_irep *mrb_read_irep(mrb_state*, const uint8_t*);
MRB_API mrb_irep *mrb_read_irep_buf(mrb_state*, const void*, size_t);
+12 -41
View File
@@ -17,20 +17,24 @@ MRB_BEGIN_DECL
struct RException {
MRB_OBJECT_HEADER;
struct iv_tbl *iv;
struct RString *mesg;
struct RObject *mesg; // NULL or probably RString
struct RObject *backtrace; // NULL, RArray or RData
};
#define mrb_exc_ptr(v) ((struct RException*)mrb_ptr(v))
#define MRB_EXC_MESG_STRING_FLAG 0x100
/* error that should terminate execution */
#define MRB_EXC_EXIT 65536
#define MRB_EXC_EXIT_P(e) ((e)->flags & MRB_EXC_EXIT)
/* retrieve status value from exc; need <mruby/variable.h> and <mruby/presym.h> */
#define MRB_EXC_EXIT_STATUS(mrb,e) ((int)mrb_as_int((mrb),mrb_obj_iv_get((mrb),(e),MRB_SYM(status))))
/* exit with SystemExit status */
#define MRB_EXC_CHECK_EXIT(mrb,e) do {if (MRB_EXC_EXIT_P(e)) exit(MRB_EXC_EXIT_STATUS((mrb),(e)));} while (0)
MRB_API void mrb_sys_fail(mrb_state *mrb, const char *mesg);
#define mrb_exc_ptr(v) ((struct RException*)mrb_ptr(v))
MRB_API mrb_noreturn void mrb_sys_fail(mrb_state *mrb, const char *mesg);
MRB_API mrb_value mrb_exc_new_str(mrb_state *mrb, struct RClass* c, mrb_value str);
#define mrb_exc_new_lit(mrb, c, lit) mrb_exc_new_str(mrb, c, mrb_str_new_lit(mrb, lit))
#define mrb_exc_new_str_lit(mrb, c, lit) mrb_exc_new_lit(mrb, c, lit)
MRB_API mrb_value mrb_make_exception(mrb_state *mrb, mrb_int argc, const mrb_value *argv);
mrb_value mrb_exc_backtrace(mrb_state *mrb, mrb_value exc);
mrb_value mrb_get_backtrace(mrb_state *mrb);
MRB_API mrb_noreturn void mrb_no_method_error(mrb_state *mrb, mrb_sym id, mrb_value args, const char *fmt, ...);
/* declaration for `fail` method */
@@ -70,39 +74,6 @@ mrb_break_value_set(struct RBreak *brk, mrb_value val)
#define mrb_break_proc_get(brk) ((brk)->proc)
#define mrb_break_proc_set(brk, p) ((brk)->proc = p)
#define RBREAK_TAG_FOREACH(f) \
f(RBREAK_TAG_BREAK, 0) \
f(RBREAK_TAG_BREAK_UPPER, 1) \
f(RBREAK_TAG_BREAK_INTARGET, 2) \
f(RBREAK_TAG_RETURN_BLOCK, 3) \
f(RBREAK_TAG_RETURN, 4) \
f(RBREAK_TAG_RETURN_TOPLEVEL, 5) \
f(RBREAK_TAG_JUMP, 6) \
f(RBREAK_TAG_STOP, 7)
#define RBREAK_TAG_DEFINE(tag, i) tag = i,
enum {
RBREAK_TAG_FOREACH(RBREAK_TAG_DEFINE)
};
#undef RBREAK_TAG_DEFINE
#define RBREAK_TAG_BIT 3
#define RBREAK_TAG_BIT_OFF 8
#define RBREAK_TAG_MASK (~(~UINT32_C(0) << RBREAK_TAG_BIT))
static inline uint32_t
mrb_break_tag_get(struct RBreak *brk)
{
return (brk->flags >> RBREAK_TAG_BIT_OFF) & RBREAK_TAG_MASK;
}
static inline void
mrb_break_tag_set(struct RBreak *brk, uint32_t tag)
{
brk->flags &= ~(RBREAK_TAG_MASK << RBREAK_TAG_BIT_OFF);
brk->flags |= (tag & RBREAK_TAG_MASK) << RBREAK_TAG_BIT_OFF;
}
/**
* Protect
*
+3 -3
View File
@@ -48,7 +48,8 @@ typedef struct mrb_heap_page {
struct mrb_heap_page *free_next;
struct mrb_heap_page *free_prev;
mrb_bool old:1;
void *objects[];
/* Flexible array members area a C99 feature, not C++ compatible */
/* void* objects[]; */
} mrb_heap_page;
#ifdef _MSC_VER
@@ -84,8 +85,7 @@ typedef struct mrb_gc {
size_t majorgc_old_threshold;
} mrb_gc;
MRB_API mrb_bool
mrb_object_dead_p(struct mrb_state *mrb, struct RBasic *object);
MRB_API mrb_bool mrb_object_dead_p(struct mrb_state *mrb, struct RBasic *object);
#define MRB_GC_RED 7
-6
View File
@@ -35,7 +35,6 @@ struct RHash {
#define mrb_hash_ptr(v) ((struct RHash*)(mrb_ptr(v)))
#define mrb_hash_value(p) mrb_obj_value((void*)(p))
size_t mrb_hash_memsize(mrb_value obj);
MRB_API mrb_value mrb_hash_new_capa(mrb_state *mrb, mrb_int capa);
/*
@@ -226,11 +225,6 @@ MRB_API void mrb_hash_merge(mrb_state *mrb, mrb_value hash1, mrb_value hash2);
#define MRB_RHASH_DEFAULT_P(hash) (RHASH(hash)->flags & MRB_HASH_DEFAULT)
#define MRB_RHASH_PROCDEFAULT_P(hash) (RHASH(hash)->flags & MRB_HASH_PROC_DEFAULT)
/* GC functions */
void mrb_gc_mark_hash(mrb_state*, struct RHash*);
size_t mrb_gc_mark_hash_size(mrb_state*, struct RHash*);
void mrb_gc_free_hash(mrb_state*, struct RHash*);
/* return non zero to break the loop */
typedef int (mrb_hash_foreach_func)(mrb_state *mrb, mrb_value key, mrb_value val, void *data);
MRB_API void mrb_hash_foreach(mrb_state *mrb, struct RHash *hash, mrb_hash_foreach_func *func, void *p);
+207
View File
@@ -0,0 +1,207 @@
/**
** @file mruby/internal.h - Functions only called from within the library
**
** See Copyright Notice in mruby.h
*/
#ifndef MRUBY_INTERNAL_H
#define MRUBY_INTERNAL_H
#ifdef MRUBY_ARRAY_H
void mrb_ary_decref(mrb_state*, mrb_shared_array*);
mrb_value mrb_ary_subseq(mrb_state *mrb, mrb_value ary, mrb_int beg, mrb_int len);
#endif
#ifdef MRUBY_CLASS_H
struct RClass *mrb_vm_define_class(mrb_state*, mrb_value, mrb_value, mrb_sym);
struct RClass *mrb_vm_define_module(mrb_state*, mrb_value, mrb_sym);
mrb_value mrb_instance_new(mrb_state *mrb, mrb_value cv);
void mrb_class_name_class(mrb_state*, struct RClass*, struct RClass*, mrb_sym);
mrb_bool mrb_const_name_p(mrb_state*, const char*, mrb_int);
mrb_value mrb_class_find_path(mrb_state*, struct RClass*);
mrb_value mrb_mod_to_s(mrb_state *, mrb_value);
void mrb_method_added(mrb_state *mrb, struct RClass *c, mrb_sym mid);
mrb_noreturn void mrb_method_missing(mrb_state *mrb, mrb_sym name, mrb_value self, mrb_value args);
#endif
/* debug */
size_t mrb_packed_int_len(uint32_t num);
size_t mrb_packed_int_encode(uint32_t num, uint8_t *p, uint8_t *pend);
uint32_t mrb_packed_int_decode(const uint8_t *p, const uint8_t **newpos);
/* dump */
#ifdef MRUBY_IREP_H
int mrb_dump_irep(mrb_state *mrb, const mrb_irep *irep, uint8_t flags, uint8_t **bin, size_t *bin_size);
#ifndef MRB_NO_STDIO
int mrb_dump_irep_cfunc(mrb_state *mrb, const mrb_irep*, uint8_t flags, FILE *f, const char *initname);
int mrb_dump_irep_cstruct(mrb_state *mrb, const mrb_irep*, uint8_t flags, FILE *f, const char *initname);
#endif
#endif
/* codedump */
void mrb_codedump_all(mrb_state *mrb, struct RProc *proc);
#ifndef MRB_NO_STDIO
void mrb_codedump_all_file(mrb_state *mrb, struct RProc *proc, FILE *out);
#endif
/* error */
mrb_value mrb_exc_inspect(mrb_state *mrb, mrb_value exc);
mrb_value mrb_exc_backtrace(mrb_state *mrb, mrb_value exc);
mrb_value mrb_get_backtrace(mrb_state *mrb);
void mrb_exc_mesg_set(mrb_state *mrb, struct RException *exc, mrb_value mesg);
mrb_value mrb_exc_mesg_get(mrb_state *mrb, struct RException *exc);
/* gc */
void mrb_gc_mark_mt(mrb_state*, struct RClass*);
size_t mrb_gc_mark_mt_size(mrb_state*, struct RClass*);
void mrb_gc_free_mt(mrb_state*, struct RClass*);
/* hash */
size_t mrb_hash_memsize(mrb_value obj);
void mrb_gc_mark_hash(mrb_state*, struct RHash*);
size_t mrb_gc_mark_hash_size(mrb_state*, struct RHash*);
void mrb_gc_free_hash(mrb_state*, struct RHash*);
/* irep */
struct mrb_insn_data mrb_decode_insn(const mrb_code *pc);
#ifdef MRUBY_IREP_H
void mrb_irep_free(mrb_state*, struct mrb_irep*);
void mrb_irep_remove_lv(mrb_state *mrb, mrb_irep *irep);
static inline const struct mrb_irep_catch_handler *
mrb_irep_catch_handler_table(const struct mrb_irep *irep)
{
if (irep->clen > 0) {
return (const struct mrb_irep_catch_handler*)(irep->iseq + irep->ilen);
}
else {
return (const struct mrb_irep_catch_handler*)NULL;
}
}
#endif
/* numeric */
mrb_value mrb_div_int_value(mrb_state *mrb, mrb_int x, mrb_int y);
mrb_int mrb_div_int(mrb_int x, mrb_int y);
mrb_value mrb_int_add(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_int_sub(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_int_mul(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_noreturn void mrb_int_zerodiv(mrb_state *mrb);
mrb_noreturn void mrb_int_overflow(mrb_state *mrb, const char *reason);
#ifdef MRB_USE_COMPLEX
mrb_value mrb_complex_new(mrb_state *mrb, mrb_float x, mrb_float y);
mrb_value mrb_complex_add(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_complex_sub(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_complex_mul(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_complex_div(mrb_state *mrb, mrb_value x, mrb_value y);
void mrb_complex_copy(mrb_state *mrb, mrb_value x, mrb_value y);
#endif
#ifdef MRB_USE_RATIONAL
mrb_value mrb_rational_new(mrb_state *mrb, mrb_int x, mrb_int y);
mrb_value mrb_rational_add(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_rational_sub(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_rational_mul(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_rational_div(mrb_state *mrb, mrb_value x, mrb_value y);
void mrb_rational_copy(mrb_state *mrb, mrb_value x, mrb_value y);
#endif
#ifdef MRUBY_PROC_H
struct RProc *mrb_closure_new(mrb_state*, const mrb_irep*);
void mrb_proc_copy(mrb_state *mrb, struct RProc *a, struct RProc *b);
mrb_int mrb_proc_arity(const struct RProc *p);
struct REnv *mrb_env_new(mrb_state *mrb, struct mrb_context *c, mrb_callinfo *ci, int nstacks, mrb_value *stack, struct RClass *tc);
#endif
/* range */
#ifdef MRUBY_RANGE_H
mrb_value mrb_get_values_at(mrb_state *mrb, mrb_value obj, mrb_int olen, mrb_int argc, const mrb_value *argv, mrb_value (*func)(mrb_state*, mrb_value, mrb_int));
void mrb_gc_mark_range(mrb_state *mrb, struct RRange *r);
#endif
/* string */
void mrb_gc_free_str(mrb_state*, struct RString*);
uint32_t mrb_str_hash(mrb_state *mrb, mrb_value str);
mrb_value mrb_str_dump(mrb_state *mrb, mrb_value str);
mrb_value mrb_str_inspect(mrb_state *mrb, mrb_value str);
mrb_bool mrb_str_beg_len(mrb_int str_len, mrb_int *begp, mrb_int *lenp);
mrb_value mrb_str_byte_subseq(mrb_state *mrb, mrb_value str, mrb_int beg, mrb_int len);
mrb_value mrb_str_aref(mrb_state *mrb, mrb_value str, mrb_value idx, mrb_value len);
uint32_t mrb_byte_hash(const uint8_t*, mrb_int);
uint32_t mrb_byte_hash_step(const uint8_t*, mrb_int, uint32_t);
#ifdef MRB_UTF8_STRING
mrb_int mrb_utf8len(const char *str, const char *end);
mrb_int mrb_utf8_strlen(const char *str, mrb_int byte_len);
#endif
/* variable */
mrb_value mrb_vm_special_get(mrb_state*, mrb_sym);
void mrb_vm_special_set(mrb_state*, mrb_sym, mrb_value);
mrb_value mrb_vm_cv_get(mrb_state*, mrb_sym);
void mrb_vm_cv_set(mrb_state*, mrb_sym, mrb_value);
mrb_value mrb_vm_const_get(mrb_state*, mrb_sym);
void mrb_vm_const_set(mrb_state*, mrb_sym, mrb_value);
size_t mrb_obj_iv_tbl_memsize(mrb_value);
mrb_value mrb_obj_iv_inspect(mrb_state*, struct RObject*);
void mrb_obj_iv_set_force(mrb_state *mrb, struct RObject *obj, mrb_sym sym, mrb_value v);
mrb_value mrb_mod_constants(mrb_state *mrb, mrb_value mod);
mrb_value mrb_f_global_variables(mrb_state *mrb, mrb_value self);
mrb_value mrb_obj_instance_variables(mrb_state*, mrb_value);
mrb_value mrb_mod_class_variables(mrb_state*, mrb_value);
mrb_value mrb_mod_cv_get(mrb_state *mrb, struct RClass * c, mrb_sym sym);
mrb_bool mrb_mod_cv_defined(mrb_state *mrb, struct RClass * c, mrb_sym sym);
mrb_bool mrb_ident_p(const char *s, mrb_int len);
/* GC functions */
void mrb_gc_mark_gv(mrb_state*);
void mrb_gc_free_gv(mrb_state*);
void mrb_gc_mark_iv(mrb_state*, struct RObject*);
size_t mrb_gc_mark_iv_size(mrb_state*, struct RObject*);
void mrb_gc_free_iv(mrb_state*, struct RObject*);
/* VM */
mrb_int mrb_ci_bidx(mrb_callinfo *ci);
mrb_int mrb_ci_nregs(mrb_callinfo *ci);
mrb_value mrb_exec_irep(mrb_state *mrb, mrb_value self, struct RProc *p);
mrb_value mrb_obj_instance_eval(mrb_state*, mrb_value);
mrb_value mrb_mod_module_eval(mrb_state*, mrb_value);
mrb_value mrb_f_send(mrb_state *mrb, mrb_value self);
#ifdef MRB_USE_BIGINT
mrb_value mrb_bint_new_int(mrb_state *mrb, mrb_int x);
mrb_value mrb_bint_new_str(mrb_state *mrb, const char *x, mrb_int len, mrb_int base);
mrb_value mrb_as_bint(mrb_state *mrb, mrb_value x);
mrb_value mrb_bint_add(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_bint_sub(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_bint_mul(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_bint_div(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_bint_divmod(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_bint_add_ii(mrb_state *mrb, mrb_int x, mrb_int y);
mrb_value mrb_bint_sub_ii(mrb_state *mrb, mrb_int x, mrb_int y);
mrb_value mrb_bint_mul_ii(mrb_state *mrb, mrb_int x, mrb_int y);
mrb_value mrb_bint_div_ii(mrb_state *mrb, mrb_int x, mrb_int y);
mrb_value mrb_bint_mod(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_bint_rem(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_bint_pow(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_bint_powm(mrb_state *mrb, mrb_value x, mrb_int y, mrb_value z);
mrb_value mrb_bint_and(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_bint_or(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_bint_xor(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_bint_rev(mrb_state *mrb, mrb_value x);
mrb_value mrb_bint_lshift(mrb_state *mrb, mrb_value x, mrb_int width);
mrb_value mrb_bint_rshift(mrb_state *mrb, mrb_value x, mrb_int width);
mrb_value mrb_bint_to_s(mrb_state *mrb, mrb_value x, mrb_int base);
#ifndef MRB_NO_FLOAT
mrb_value mrb_bint_new_float(mrb_state *mrb, mrb_float x);
mrb_float mrb_bint_as_float(mrb_state *mrb, mrb_value x);
#endif
mrb_int mrb_bint_as_int(mrb_state *mrb, mrb_value x);
mrb_int mrb_bint_cmp(mrb_state *mrb, mrb_value x, mrb_value y);
void mrb_gc_free_bint(mrb_state *mrb, struct RBasic *x);
void mrb_bint_copy(mrb_state *mrb, mrb_value x, mrb_value y);
size_t mrb_bint_memsize(mrb_value x);
mrb_value mrb_bint_hash(mrb_state *mrb, mrb_value x);
#endif
#endif /* MRUBY_INTERNAL_H */
+9 -24
View File
@@ -52,7 +52,7 @@ struct mrb_irep_catch_handler {
};
/* Program data array struct */
typedef struct mrb_irep {
struct mrb_irep {
uint16_t nlocals; /* Number of local variables */
uint16_t nregs; /* Number of register variables */
uint16_t clen; /* Number of catch handlers */
@@ -76,7 +76,7 @@ typedef struct mrb_irep {
uint16_t plen, slen;
uint16_t rlen;
uint16_t refcnt;
} mrb_irep;
};
#define MRB_ISEQ_NO_FREE 1
#define MRB_IREP_NO_FREE 2
@@ -99,7 +99,7 @@ MRB_API mrb_value mrb_load_irep(mrb_state*, const uint8_t*);
/*
* @param [const void*] irep code
* @param [size_t] size of irep buffer. If -1 is given, it is considered unrestricted.
* @param [size_t] size of irep buffer.
*/
MRB_API mrb_value mrb_load_irep_buf(mrb_state*, const void*, size_t);
@@ -108,40 +108,25 @@ MRB_API mrb_value mrb_load_irep_cxt(mrb_state*, const uint8_t*, mrbc_context*);
/*
* @param [const void*] irep code
* @param [size_t] size of irep buffer. If -1 is given, it is considered unrestricted.
* @param [size_t] size of irep buffer.
*/
MRB_API mrb_value mrb_load_irep_buf_cxt(mrb_state*, const void*, size_t, mrbc_context*);
void mrb_irep_free(mrb_state*, struct mrb_irep*);
void mrb_irep_incref(mrb_state*, struct mrb_irep*);
void mrb_irep_decref(mrb_state*, struct mrb_irep*);
void mrb_irep_cutref(mrb_state*, struct mrb_irep*);
void mrb_irep_remove_lv(mrb_state *mrb, mrb_irep *irep);
struct mrb_insn_data {
uint8_t insn;
uint16_t a;
uint32_t a;
uint16_t b;
uint16_t c;
const mrb_code *addr;
};
struct mrb_insn_data mrb_decode_insn(const mrb_code *pc);
static inline const struct mrb_irep_catch_handler *
mrb_irep_catch_handler_table(const struct mrb_irep *irep)
{
if (irep->clen > 0) {
return (const struct mrb_irep_catch_handler*)(irep->iseq + irep->ilen);
}
else {
return (const struct mrb_irep_catch_handler*)NULL;
}
}
#define mrb_irep_catch_handler_pack(n, v) uint32_to_bin(n, v)
#define mrb_irep_catch_handler_unpack(v) bin_to_uint32(v)
void mrb_irep_incref(mrb_state*, struct mrb_irep*);
void mrb_irep_decref(mrb_state*, struct mrb_irep*);
void mrb_irep_cutref(mrb_state*, struct mrb_irep*);
MRB_END_DECL
#endif /* MRUBY_IREP_H */
+6 -9
View File
@@ -30,16 +30,17 @@ MRB_BEGIN_DECL
#endif
#endif
MRB_API mrb_value mrb_num_plus(mrb_state *mrb, mrb_value x, mrb_value y);
MRB_API mrb_value mrb_num_minus(mrb_state *mrb, mrb_value x, mrb_value y);
/* utility functions */
MRB_API mrb_value mrb_num_add(mrb_state *mrb, mrb_value x, mrb_value y);
MRB_API mrb_value mrb_num_sub(mrb_state *mrb, mrb_value x, mrb_value y);
MRB_API mrb_value mrb_num_mul(mrb_state *mrb, mrb_value x, mrb_value y);
/* obsolete old names */
#define mrb_num_plus(mrb, x, y) mrb_num_add(mrb, x, y)
#define mrb_num_minus(mrb, x, y) mrb_num_sub(mrb, x, y)
MRB_API mrb_value mrb_integer_to_str(mrb_state *mrb, mrb_value x, mrb_int base);
MRB_API char *mrb_int_to_cstr(char *buf, size_t len, mrb_int n, mrb_int base);
/* internal function(s) */
mrb_int mrb_div_int(mrb_state *mrb, mrb_int x, mrb_int y);
/* obsolete function(s); will be removed */
#define mrb_fixnum_to_str(mrb, x, base) mrb_integer_to_str(mrb, x, base)
@@ -166,10 +167,6 @@ mrb_float mrb_div_float(mrb_float x, mrb_float y);
mrb_value mrb_float_to_str(mrb_state *mrb, mrb_value x, const char *fmt);
int mrb_format_float(mrb_float f, char *buf, size_t buf_size, char fmt, int prec, char sign);
/* obsolete functions; will be removed */
#define mrb_flo_to_fixnum(mrb, val) mrb_float_to_integer(mrb, val)
#define mrb_to_flo(mrb, x) mrb_as_float(mrb, x)
#endif /* MRB_NO_FLOAT */
MRB_END_DECL
+4
View File
@@ -40,4 +40,8 @@ struct RFiber {
struct mrb_context *cxt;
};
#define mrb_static_assert_object_size(st) \
mrb_static_assert(sizeof(st) <= sizeof(void*) * 6, \
#st " size must be within 6 words")
#endif /* MRUBY_OBJECT_H */
+2 -2
View File
@@ -61,7 +61,7 @@ OPCODE(SSEND, BBB) /* R[a] = self.send(Syms[b],R[a+1]..,R[a+n+1]:R[a+n
OPCODE(SSENDB, BBB) /* R[a] = self.send(Syms[b],R[a+1]..,R[a+n+1]:R[a+n+2]..,&R[a+n+2k+1]) */
OPCODE(SEND, BBB) /* R[a] = R[a].send(Syms[b],R[a+1]..,R[a+n+1]:R[a+n+2]..) (c=n|k<<4) */
OPCODE(SENDB, BBB) /* R[a] = R[a].send(Syms[b],R[a+1]..,R[a+n+1]:R[a+n+2]..,&R[a+n+2k+1]) */
OPCODE(CALL, Z) /* R[0] = self.call(frame.argc, frame.argv) */
OPCODE(CALL, Z) /* self.call(*, **, &) (But overlay the current call frame; tailcall) */
OPCODE(SUPER, BB) /* R[a] = super(R[a+1],... ,R[a+b+1]) */
OPCODE(ARGARY, BS) /* R[a] = argument array (16=m5:r1:m5:d1:lv4) */
OPCODE(ENTER, W) /* arg setup according to flags (23=m5:o5:r1:m5:k5:d1:b1) */
@@ -87,7 +87,7 @@ OPCODE(ARRAY, BB) /* R[a] = ary_new(R[a],R[a+1]..R[a+b]) */
OPCODE(ARRAY2, BBB) /* R[a] = ary_new(R[b],R[b+1]..R[b+c]) */
OPCODE(ARYCAT, B) /* ary_cat(R[a],R[a+1]) */
OPCODE(ARYPUSH, BB) /* ary_push(R[a],R[a+1]..R[a+b]) */
OPCODE(ARYDUP, B) /* R[a] = ary_dup(R[a]) */
OPCODE(ARYSPLAT, B) /* R[a] = ary_splat(R[a]) */
OPCODE(AREF, BBB) /* R[a] = R[b][c] */
OPCODE(ASET, BBB) /* R[b][c] = R[a] */
OPCODE(APOST, BBB) /* *R[a],R[a+1]..R[a+c] = R[a][b..] */
+12 -76
View File
@@ -26,17 +26,18 @@ struct REnv {
#define MRB_ENV_SET_LEN(e,len) ((e)->flags = (((e)->flags & ~0xff)|((unsigned int)(len) & 0xff)))
#define MRB_ENV_LEN(e) ((mrb_int)((e)->flags & 0xff))
#define MRB_ENV_CLOSED (1<<20)
#define MRB_ENV_TOUCHED (1<<19)
#define MRB_ENV_HEAPED (1<<18)
#define MRB_ENV_CLOSE(e) ((e)->flags |= MRB_ENV_CLOSED)
#define MRB_ENV_TOUCH(e) ((e)->flags |= MRB_ENV_TOUCHED)
#define MRB_ENV_HEAP(e) ((e)->flags |= MRB_ENV_HEAPED)
#define MRB_ENV_HEAP_P(e) ((e)->flags & MRB_ENV_HEAPED)
#define MRB_ENV_ONSTACK_P(e) (((e)->flags & MRB_ENV_CLOSED) == 0)
#define MRB_ENV_BIDX(e) (((e)->flags >> 8) & 0xff)
#define MRB_ENV_SET_BIDX(e,idx) ((e)->flags = (((e)->flags & ~(0xff<<8))|((unsigned int)(idx) & 0xff)<<8))
void mrb_env_unshare(mrb_state*, struct REnv*);
/*
* Returns TRUE on success.
* If the function fails:
* * Returns FALSE if noraise is TRUE.
* * Raises a NoMemoryError exception if noraise is FALSE.
*/
mrb_bool mrb_env_unshare(mrb_state*, struct REnv*, mrb_bool noraise);
struct RProc {
MRB_OBJECT_HEADER;
@@ -89,11 +90,8 @@ struct RProc {
#define mrb_proc_ptr(v) ((struct RProc*)(mrb_ptr(v)))
struct RProc *mrb_proc_new(mrb_state*, const mrb_irep*);
struct RProc *mrb_closure_new(mrb_state*, const mrb_irep*);
MRB_API struct RProc *mrb_proc_new_cfunc(mrb_state*, mrb_func_t);
MRB_API struct RProc *mrb_closure_new_cfunc(mrb_state *mrb, mrb_func_t func, int nlocals);
void mrb_proc_copy(mrb_state *mrb, struct RProc *a, struct RProc *b);
mrb_int mrb_proc_arity(const struct RProc *p);
/* following functions are defined in mruby-proc-ext so please include it when using */
MRB_API struct RProc *mrb_proc_new_cfunc_with_env(mrb_state *mrb, mrb_func_t func, mrb_int argc, const mrb_value *argv);
@@ -138,73 +136,11 @@ MRB_API mrb_value mrb_proc_cfunc_env_get(mrb_state *mrb, mrb_int idx);
MRB_API mrb_value mrb_load_proc(mrb_state *mrb, const struct RProc *proc);
static inline void
mrb_vm_ci_proc_set(mrb_callinfo *ci, const struct RProc *p)
{
ci->proc = p;
ci->pc = (p && !MRB_PROC_CFUNC_P(p)) ? p->body.irep->iseq : NULL;
}
static inline struct RClass *
mrb_vm_ci_target_class(const mrb_callinfo *ci)
{
if (ci->u.env && ci->u.env->tt == MRB_TT_ENV) {
return ci->u.env->c;
}
else {
return ci->u.target_class;
}
}
static inline void
mrb_vm_ci_target_class_set(mrb_callinfo *ci, struct RClass *tc)
{
struct REnv *e = ci->u.env;
if (e) {
if (e->tt == MRB_TT_ENV) {
e->c = tc;
}
else {
ci->u.target_class = tc;
}
}
}
static inline struct REnv *
mrb_vm_ci_env(const mrb_callinfo *ci)
{
if (ci->u.env && ci->u.env->tt == MRB_TT_ENV) {
return ci->u.env;
}
else {
return NULL;
}
}
static inline void
mrb_vm_ci_env_set(mrb_callinfo *ci, struct REnv *e)
{
if (ci->u.env) {
if (ci->u.env->tt == MRB_TT_ENV) {
if (e) {
e->c = ci->u.env->c;
ci->u.env = e;
}
else {
ci->u.target_class = ci->u.env->c;
}
}
else {
if (e) {
e->c = ci->u.target_class;
ci->u.env = e;
}
}
}
else {
ci->u.env = e;
}
}
void mrb_vm_ci_proc_set(mrb_callinfo *ci, const struct RProc *p);
struct RClass * mrb_vm_ci_target_class(const mrb_callinfo *ci);
void mrb_vm_ci_target_class_set(mrb_callinfo *ci, struct RClass *tc);
struct REnv * mrb_vm_ci_env(const mrb_callinfo *ci);
void mrb_vm_ci_env_set(mrb_callinfo *ci, struct REnv *e);
MRB_END_DECL
-2
View File
@@ -71,8 +71,6 @@ enum mrb_range_beg_len {
};
MRB_API enum mrb_range_beg_len mrb_range_beg_len(mrb_state *mrb, mrb_value range, mrb_int *begp, mrb_int *lenp, mrb_int len, mrb_bool trunc);
mrb_value mrb_get_values_at(mrb_state *mrb, mrb_value obj, mrb_int olen, mrb_int argc, const mrb_value *argv, mrb_value (*func)(mrb_state*, mrb_value, mrb_int));
void mrb_gc_mark_range(mrb_state *mrb, struct RRange *r);
MRB_END_DECL
+5 -22
View File
@@ -102,7 +102,6 @@ struct RStringEmbed {
#define RSTRING_LEN(s) RSTR_LEN(RSTRING(s))
#define RSTRING_CAPA(s) RSTR_CAPA(RSTRING(s))
#define RSTRING_END(s) (RSTRING_PTR(s) + RSTRING_LEN(s))
MRB_API mrb_int mrb_str_strlen(mrb_state*, struct RString*);
#define RSTRING_CSTR(mrb,s) mrb_string_cstr(mrb, s)
#define MRB_STR_SHARED 1
@@ -115,8 +114,6 @@ MRB_API mrb_int mrb_str_strlen(mrb_state*, struct RString*);
#define MRB_STR_EMBED_LEN_MASK (((1 << MRB_STR_EMBED_LEN_BIT) - 1) << MRB_STR_EMBED_LEN_SHIFT)
#define MRB_STR_TYPE_MASK 15
void mrb_gc_free_str(mrb_state*, struct RString*);
MRB_API void mrb_str_modify(mrb_state *mrb, struct RString *s);
/* mrb_str_modify() with keeping ASCII flag if set */
MRB_API void mrb_str_modify_keep_ascii(mrb_state *mrb, struct RString *s);
@@ -324,7 +321,7 @@ MRB_API mrb_value mrb_str_resize(mrb_state *mrb, mrb_value str, mrb_int len);
*/
MRB_API mrb_value mrb_str_substr(mrb_state *mrb, mrb_value str, mrb_int beg, mrb_int len);
MRB_API mrb_value mrb_str_new_capa(mrb_state *mrb, size_t capa);
MRB_API mrb_value mrb_str_new_capa(mrb_state *mrb, mrb_int capa);
#define mrb_str_buf_new(mrb, capa) mrb_str_new_capa(mrb, (capa))
/* NULL terminated C string from mrb_value */
@@ -332,9 +329,11 @@ MRB_API const char *mrb_string_cstr(mrb_state *mrb, mrb_value str);
/* NULL terminated C string from mrb_value; `str` will be updated */
MRB_API const char *mrb_string_value_cstr(mrb_state *mrb, mrb_value *str);
/* obsolete: use RSTRING_PTR() */
MRB_API const char *mrb_string_value_ptr(mrb_state *mrb, mrb_value str);
#define mrb_string_value_ptr(mrb, str) RSTRING_PTR(str)
/* obsolete: use RSTRING_LEN() */
MRB_API mrb_int mrb_string_value_len(mrb_state *mrb, mrb_value str);
#define mrb_string_value_len(mrb, str) RSTRING_LEN(str)
/* obsolete: substituted by a macro; shall be removed */
#define mrb_str_strlen(mrb, s) strlen(RSTR_PTR(s))
/**
* Duplicates a string object.
@@ -422,27 +421,11 @@ MRB_API int mrb_str_cmp(mrb_state *mrb, mrb_value str1, mrb_value str2);
*/
MRB_API char *mrb_str_to_cstr(mrb_state *mrb, mrb_value str);
uint32_t mrb_str_hash(mrb_state *mrb, mrb_value str);
mrb_value mrb_str_dump(mrb_state *mrb, mrb_value str);
/**
* Returns a printable version of str, surrounded by quote marks, with special characters escaped.
*/
mrb_value mrb_str_inspect(mrb_state *mrb, mrb_value str);
/* For backward compatibility */
#define mrb_str_cat2(mrb, str, ptr) mrb_str_cat_cstr(mrb, str, ptr)
#define mrb_str_buf_cat(mrb, str, ptr, len) mrb_str_cat(mrb, str, ptr, len)
#define mrb_str_buf_append(mrb, str, str2) mrb_str_cat_str(mrb, str, str2)
mrb_bool mrb_str_beg_len(mrb_int str_len, mrb_int *begp, mrb_int *lenp);
mrb_value mrb_str_byte_subseq(mrb_state *mrb, mrb_value str, mrb_int beg, mrb_int len);
#ifdef MRB_UTF8_STRING
mrb_int mrb_utf8len(const char *str, const char *end);
mrb_int mrb_utf8_strlen(const char *str, mrb_int byte_len);
#endif
MRB_END_DECL
#endif /* MRUBY_STRING_H */
+6 -7
View File
@@ -7,10 +7,8 @@
#ifndef MRB_THROW_H
#define MRB_THROW_H
#if defined(MRB_USE_CXX_ABI)
# if !defined(__cplusplus)
#if defined(MRB_USE_CXX_ABI) && !defined(__cplusplus)
# error Trying to use C++ exception handling in C code
# endif
#endif
#if defined(MRB_USE_CXX_EXCEPTION)
@@ -52,14 +50,15 @@ typedef mrb_int mrb_jmpbuf_impl;
#endif
#if defined(MRB_USE_CXX_EXCEPTION)
extern mrb_int mrb_jmpbuf_id;
#endif
struct mrb_jmpbuf {
mrb_jmpbuf_impl impl;
#if defined(MRB_USE_CXX_EXCEPTION)
static mrb_int jmpbuf_id;
# if defined(__cplusplus)
mrb_jmpbuf() : impl(jmpbuf_id++) {}
# endif
mrb_jmpbuf() : impl(mrb_jmpbuf_id++) {}
#endif
};
+32 -11
View File
@@ -100,9 +100,13 @@ struct mrb_state;
# define MRB_ENDIAN_LOHI(a,b) b a
#endif
MRB_API mrb_int mrb_int_read(const char *p, const char *e, char **endp);
MRB_API mrb_bool mrb_read_int(const char *p, const char *e, char **endp, mrb_int *np);
/* obsolete; do not use mrb_int_read() */
MRB_API mrb_int mrb_int_read(const char*, const char*, char**);
#ifndef MRB_NO_FLOAT
MRB_API double mrb_float_read(const char*, char**);
MRB_API mrb_bool mrb_read_float(const char *p, char **endp, double *fp);
/* obsolete; do not use mrb_float_read() */
MRB_API double mrb_float_read(const char *p, char **endp);
#ifdef MRB_USE_FLOAT32
typedef float mrb_float;
#else
@@ -148,13 +152,14 @@ static const unsigned int IEEE754_INFINITY_BITS_SINGLE = 0x7F800000;
f(MRB_TT_RANGE, struct RRange, "Range") \
f(MRB_TT_EXCEPTION, struct RException, "Exception") \
f(MRB_TT_ENV, struct REnv, "env") \
f(MRB_TT_DATA, struct RData, "Data") \
f(MRB_TT_CDATA, struct RData, "C data") \
f(MRB_TT_FIBER, struct RFiber, "Fiber") \
f(MRB_TT_STRUCT, struct RArray, "Struct") \
f(MRB_TT_ISTRUCT, struct RIStruct, "istruct") \
f(MRB_TT_BREAK, struct RBreak, "break") \
f(MRB_TT_COMPLEX, struct RComplex, "Complex") \
f(MRB_TT_RATIONAL, struct RRational, "Rational")
f(MRB_TT_RATIONAL, struct RRational, "Rational") \
f(MRB_TT_BIGINT, struct RBigint, "Integer")
enum mrb_vtype {
#define MRB_VTYPE_DEFINE(tt, type, name) tt,
@@ -163,6 +168,9 @@ enum mrb_vtype {
MRB_TT_MAXDEFINE
};
/* obsolete name for MRB_TT_CDATA */
#define MRB_TT_DATA MRB_TT_CDATA
#define MRB_VTYPE_TYPEOF(tt) MRB_TYPEOF_##tt
#define MRB_VTYPE_TYPEDEF(tt, type, name) typedef type MRB_VTYPE_TYPEOF(tt);
@@ -182,8 +190,8 @@ MRB_VTYPE_FOREACH(MRB_VTYPE_TYPEDEF)
*
* Actual implementation depends on configured boxing type.
*
* @see mruby/boxing_no.h Default boxing representation
* @see mruby/boxing_word.h Word representation
* @see mruby/boxing_word.h Word boxing representation (Default)
* @see mruby/boxing_no.h No boxing representation
* @see mruby/boxing_nan.h Boxed double representation
*/
typedef void mrb_value;
@@ -237,9 +245,11 @@ struct RCptr {
#ifndef mrb_true_p
#define mrb_true_p(o) (mrb_type(o) == MRB_TT_TRUE)
#endif
#ifndef MRB_NO_FLOAT
#ifndef mrb_float_p
#ifndef MRB_NO_FLOAT
#define mrb_float_p(o) (mrb_type(o) == MRB_TT_FLOAT)
#else
#define mrb_float_p(o) FALSE
#endif
#endif
#ifndef mrb_array_p
@@ -285,7 +295,7 @@ struct RCptr {
#define mrb_env_p(o) (mrb_type(o) == MRB_TT_ENV)
#endif
#ifndef mrb_data_p
#define mrb_data_p(o) (mrb_type(o) == MRB_TT_DATA)
#define mrb_data_p(o) (mrb_type(o) == MRB_TT_CDATA)
#endif
#ifndef mrb_fiber_p
#define mrb_fiber_p(o) (mrb_type(o) == MRB_TT_FIBER)
@@ -300,6 +310,9 @@ struct RCptr {
#define mrb_bool(o) (mrb_type(o) != MRB_TT_FALSE)
#endif
#define mrb_test(o) mrb_bool(o)
#ifndef mrb_bigint_p
#define mrb_bigint_p(o) (mrb_type(o) == MRB_TT_BIGINT)
#endif
/**
* Returns a float in Ruby.
@@ -355,8 +368,6 @@ mrb_obj_value(void *p)
{
mrb_value v;
SET_OBJ_VALUE(v, (struct RBasic*)p);
mrb_assert(p == mrb_ptr(v));
mrb_assert(((struct RBasic*)p)->tt == mrb_type(v));
return v;
}
@@ -424,10 +435,20 @@ mrb_ro_data_p(const char *p)
#elif defined(__APPLE__)
#define MRB_LINK_TIME_RO_DATA_P
#include <mach-o/getsect.h>
#include <crt_externs.h> // for _NSGetMachExecuteHeader
static inline mrb_bool
mrb_ro_data_p(const char *p)
{
return (char*)get_etext() < p && p < (char*)get_edata();
#ifdef __LP64__
struct mach_header_64 *mhp;
#else
struct mach_header *mhp;
#endif
mhp = _NSGetMachExecuteHeader();
unsigned long textsize, datasize;
char *text = (char*)getsegmentdata(mhp, SEG_TEXT, &textsize);
char *data = (char*)getsegmentdata(mhp, SEG_DATA, &datasize);
return text + textsize < p && p < data + datasize;
}
#endif /* Linux or macOS */
#endif /* MRB_NO_DEFAULT_RO_DATA_P */
-23
View File
@@ -14,13 +14,6 @@
*/
MRB_BEGIN_DECL
mrb_value mrb_vm_special_get(mrb_state*, mrb_sym);
void mrb_vm_special_set(mrb_state*, mrb_sym, mrb_value);
mrb_value mrb_vm_cv_get(mrb_state*, mrb_sym);
void mrb_vm_cv_set(mrb_state*, mrb_sym, mrb_value);
mrb_value mrb_vm_const_get(mrb_state*, mrb_sym);
void mrb_vm_const_set(mrb_state*, mrb_sym, mrb_value);
size_t mrb_obj_iv_tbl_memsize(mrb_value);
MRB_API mrb_value mrb_const_get(mrb_state*, mrb_value, mrb_sym);
MRB_API void mrb_const_set(mrb_state*, mrb_value, mrb_sym, mrb_value);
MRB_API mrb_bool mrb_const_defined(mrb_state*, mrb_value, mrb_sym);
@@ -99,22 +92,6 @@ MRB_API mrb_value mrb_cv_get(mrb_state *mrb, mrb_value mod, mrb_sym sym);
MRB_API void mrb_mod_cv_set(mrb_state *mrb, struct RClass * c, mrb_sym sym, mrb_value v);
MRB_API void mrb_cv_set(mrb_state *mrb, mrb_value mod, mrb_sym sym, mrb_value v);
MRB_API mrb_bool mrb_cv_defined(mrb_state *mrb, mrb_value mod, mrb_sym sym);
mrb_value mrb_obj_iv_inspect(mrb_state*, struct RObject*);
void mrb_obj_iv_set_force(mrb_state *mrb, struct RObject *obj, mrb_sym sym, mrb_value v);
mrb_value mrb_mod_constants(mrb_state *mrb, mrb_value mod);
mrb_value mrb_f_global_variables(mrb_state *mrb, mrb_value self);
mrb_value mrb_obj_instance_variables(mrb_state*, mrb_value);
mrb_value mrb_mod_class_variables(mrb_state*, mrb_value);
mrb_value mrb_mod_cv_get(mrb_state *mrb, struct RClass * c, mrb_sym sym);
mrb_bool mrb_mod_cv_defined(mrb_state *mrb, struct RClass * c, mrb_sym sym);
mrb_bool mrb_ident_p(const char *s, mrb_int len);
/* GC functions */
void mrb_gc_mark_gv(mrb_state*);
void mrb_gc_free_gv(mrb_state*);
void mrb_gc_mark_iv(mrb_state*, struct RObject*);
size_t mrb_gc_mark_iv_size(mrb_state*, struct RObject*);
void mrb_gc_free_iv(mrb_state*, struct RObject*);
/* return non zero to break the loop */
typedef int (mrb_iv_foreach_func)(mrb_state*,mrb_sym,mrb_value,void*);
+5 -5
View File
@@ -27,7 +27,7 @@ MRB_BEGIN_DECL
/*
* The version of Ruby used by mruby.
*/
#define MRUBY_RUBY_VERSION "3.1"
#define MRUBY_RUBY_VERSION "3.2"
/*
* Ruby engine.
@@ -42,7 +42,7 @@ MRB_BEGIN_DECL
/*
* Minor release version number.
*/
#define MRUBY_RELEASE_MINOR 1
#define MRUBY_RELEASE_MINOR 2
/*
* Tiny release version number.
@@ -80,17 +80,17 @@ MRB_BEGIN_DECL
/*
* Release year.
*/
#define MRUBY_RELEASE_YEAR 2022
#define MRUBY_RELEASE_YEAR 2023
/*
* Release month.
*/
#define MRUBY_RELEASE_MONTH 3
#define MRUBY_RELEASE_MONTH 1
/*
* Release day.
*/
#define MRUBY_RELEASE_DAY 31
#define MRUBY_RELEASE_DAY 18
/*
* Release date as a string.
+11 -1
View File
@@ -123,6 +123,7 @@ module MRuby
@enable_test = false
@enable_lock = true
@enable_presym = true
@enable_benchmark = true
@mrbcfile_external = false
@internal = internal
@toolchains = []
@@ -232,6 +233,14 @@ module MRuby
@cxx_abi_enabled = true
end
def benchmark_enabled?
@enable_benchmark
end
def disable_benchmark
@enable_benchmark = false
end
def compile_as_cxx(src, cxx_src = nil, obj = nil, includes = [])
#
# If `cxx_src` is specified, this method behaves the same as before as
@@ -491,7 +500,8 @@ EOS
v = instance_variable_get(n)
v = case v
when nil, true, false, Numeric; v
when String, Command; v.clone
when String; v.clone
when Command; v.clone.tap { |u| u.build = build }
else Marshal.load(Marshal.dump(v)) # deep clone
end
build.instance_variable_set(n, v)
+1 -5
View File
@@ -25,11 +25,7 @@ module MRuby
end
def shellquote(s)
if ENV['OS'] == 'Windows_NT'
"\"#{s}\""
else
"#{s}"
end
"\"#{s}\""
end
private
+319 -82
View File
@@ -1,5 +1,8 @@
require 'yaml'
module MRuby
module LoadGems
def gembox(gemboxfile)
gembox = File.expand_path("#{gemboxfile}.gembox", "#{MRUBY_ROOT}/mrbgems")
fail "Can't find gembox '#{gembox}'" unless File.exist?(gembox)
@@ -12,28 +15,30 @@ module MRuby
GemBox.path = nil
end
def gem(gemdir, &block)
if gemdir.is_a?(Hash)
gemdir = load_special_path_gem(gemdir)
elsif GemBox.path
gemdir = File.expand_path(gemdir, File.dirname(GemBox.path))
else
caller_dir = File.expand_path(File.dirname(caller(1,1)[0][/^(.*?):\d/,1]))
if caller_dir == "#{MRUBY_ROOT}/build_config"
caller_dir = MRUBY_ROOT
end
gemdir = File.expand_path(gemdir, caller_dir)
end
def gem(gem_src, &block)
gemrake = File.join(gemdir, "mrbgem.rake")
caller_dir = File.expand_path(File.dirname(caller(1,1)[0][/^(.*?):\d/,1]))
gem_src = {gemdir: gem_src} if gem_src.is_a? String
@gem_checkouts ||= {}
checkout = GemLoader
.new(self, caller_dir, @gem_checkouts, **gem_src)
.fetch!
return nil unless checkout
@gem_checkouts[checkout.gemdir] = checkout
# Load the gem's rakefile
gemrake = File.join(checkout.full_gemdir, "mrbgem.rake")
fail "Can't find #{gemrake}" unless File.exist?(gemrake)
Gem.current = nil
load gemrake
return nil unless Gem.current
current = Gem.current
current.dir = gemdir
# Add it to gems
current.dir = checkout.full_gemdir
current.build = self.is_a?(MRuby::Build) ? self : MRuby::Build.current
current.build_config_initializer = block
gems << current
@@ -44,92 +49,324 @@ module MRuby
current
end
def load_special_path_gem(params)
if params[:github]
params[:git] = "https://github.com/#{params[:github]}.git"
elsif params[:bitbucket]
if params[:method] == "ssh"
params[:git] = "git@bitbucket.org:#{params[:bitbucket]}.git"
else
params[:git] = "https://bitbucket.org/#{params[:bitbucket]}.git"
end
elsif params[:mgem]
mgem_list_dir = "#{gem_clone_dir}/mgem-list"
mgem_list_url = 'https://github.com/mruby/mgem-list.git'
if File.exist? mgem_list_dir
git.run_pull mgem_list_dir, mgem_list_url if $pull_gems
else
mkdir_p mgem_list_dir
git.run_clone mgem_list_dir, mgem_list_url, "--depth 1"
end
require 'yaml'
# Class to represent the relationship between a gem dependency and
# its remote repository (if any).
class GemCheckout
attr_reader :gemdir, :repo, :branch, :commit
conf_path = "#{mgem_list_dir}/#{params[:mgem]}.gem"
conf_path = "#{mgem_list_dir}/mruby-#{params[:mgem]}.gem" unless File.exist? conf_path
fail "mgem not found: #{params[:mgem]}" unless File.exist? conf_path
conf = YAML.load File.read conf_path
def initialize(gemdir, repo, branch, commit, canonical, path = nil)
@gemdir = gemdir # Working copy of the gem
@path = path # Path to gem relative to checkout
fail "unknown mgem protocol: #{conf['protocol']}" if conf['protocol'] != 'git'
params[:git] = conf['repository']
params[:branch] = conf['branch'] if conf['branch']
@repo = repo # Remote gem repo
@branch = branch # Branch to check out
@commit = commit # Commit-id to use
@canonical = canonical # This is the One True checkout
end
if params[:core]
gemdir = "#{root}/mrbgems/#{params[:core]}"
elsif params[:git]
url = params[:git]
gemdir = "#{gem_clone_dir}/#{url.match(/([-\w]+)(\.[-\w]+|)$/).to_a[1]}"
def full_gemdir
return @gemdir unless @path
return File.join(@gemdir, @path)
end
# by default the 'master' branch is used
branch = params[:branch] ? params[:branch] : 'master'
def canonical?() return @canonical; end
def git?() return !!@repo; end
def gemname() return File.basename(@gemdir); end
lock = locks[url] if lock_enabled?
def hash
return [@gemdir, @repo, @branch, @commit, @canonical, @path].hash
end
if File.exist?(gemdir)
if $pull_gems
# Jump to the top of the branch
git.run_checkout gemdir, branch
git.run_pull gemdir, url
elsif params[:checksum_hash]
git.run_checkout_detach gemdir, params[:checksum_hash]
elsif lock
git.run_checkout_detach gemdir, lock['commit']
end
def ==(other)
return @gemdir == other.gemdir &&
@repo == other.repo &&
@branch == other.branch &&
@commit == other.commit &&
@canonical == other.canonical? &&
full_gemdir == other.full_gemdir
end
alias_method :eql?, :==
def to_s
desc = @gemdir
desc += " -> #{@repo}/#{@branch}" if git?
desc += "/#{commit}" if commit
return desc
end
end
# Class to decode the argument set given to 'MRuby::Build::gem',
# and git-clone+git-checkout the sources if needed.
class GemLoader
def initialize(build,
build_config_dir, # Parent dir. of build_config
gem_checkouts, # Hash of existing checkouts
# Git repo:
git: nil,
branch: "master",
checksum_hash: nil,
options: [],
path: nil, # path to root relative to gem checkout
# Git repo on GitHub
github: nil,
# Git repo on BitBucket
bitbucket: nil,
method: nil,
# mgem entry
mgem: nil,
# Core package
core: nil,
# Local file(s)
gemdir: nil,
# Related flags:
canonical: false # Ignore subsequent checkout of this gem
)
# Tolerate a single string option
options = [options] unless options.is_a? Array
@build = build
@build_config_dir = build_config_dir
@gem_checkouts = gem_checkouts
@canonical = canonical
@git = git
@path = path
@branch = branch
@checksum_hash = checksum_hash
@options = options
@canonical = canonical
@github = github
@bitbucket = bitbucket
@method = method
@mgem = mgem
@core = core
@gemdir = gemdir
actions = [git, github, bitbucket, mgem, core, gemdir]
fail("Need to set exactly ONE of git, github, bitbucket, mgem, core, " +
"or gemdir") unless actions.compact.size == 1
end
# Retrieve the repo and return the details in a GemCheckout
# object or nil if nothing needed to be done.
def fetch!
return fromGemdir! if @gemdir
return fromCore! if @core
return fromGitHub! if @github
return fromBitBucket! if @bitbucket
return fromMGem! if @mgem
return fromGit!(@git, @branch) if @git
# Shouldn't be reachable, but...
fail "Invalid gem configuration!"
end
private
#
# Local Paths
#
def fromGemdir!
gem_src = @gemdir
# If @gemdir is a relative path, we first convert it to an
# absolute path; this depends on circumstances.
if MRuby::GemBox.path
# If GemBox.path is set, it means that this fetch operation is
# happening as part of a gembox evaluation and we use the
# gembox's path as the starting point.
gem_src = File.expand_path(gem_src, File.dirname(MRuby::GemBox.path))
else
options = [params[:options]] || []
options << "--recursive"
options << "--branch \"#{branch}\""
options << "--depth 1" unless params[:checksum_hash] || lock
mkdir_p "#{gem_clone_dir}"
git.run_clone gemdir, url, options
# Otherwise, we use the path to the build_config.rb file that
# requested this gem. This path was extracted earlier and
# stored in @build_config_dir via the second argument of
# 'initialize'.
root_dir = @build_config_dir
# Jump to the specified commit
if params[:checksum_hash]
git.run_checkout_detach gemdir, params[:checksum_hash]
elsif lock
git.run_checkout_detach gemdir, lock['commit']
end
# And we default to the repo root if the file is one of the
# stock configs in build_config/.
root_dir = MRUBY_ROOT if root_dir == "#{MRUBY_ROOT}/build_config"
gem_src = File.expand_path(gem_src, root_dir)
end
if lock_enabled?
@gem_dir_to_repo_url[gemdir] = url unless params[:path]
locks[url] = {
return GemCheckout.new(gem_src, nil, nil, nil, @canonical)
end
def fromCore!
return GemCheckout.new("#{@build.root}/mrbgems/#{@core}", nil, nil,
nil, @canonical)
end
#
# Git forges
#
def fromGitHub!
url = "https://github.com/#{@github}.git"
return fromGit!(url, @branch)
end
def fromBitBucket!
if @method == "ssh"
url = "git@bitbucket.org:#{@bitbucket}.git"
else
url = "https://bitbucket.org/#{@bitbucket}.git"
end
return fromGit!(url, @branch)
end
#
# mgem file
#
def fromMGem!
mgem = fetchMGem(@mgem)
url = mgem['repository']
branch = mgem['branch'] || @branch
return fromGit!(url, branch)
end
# Fetch the contents of the named mgem item. Will clone the
# mgem-list repo if not present
def fetchMGem(mgem)
list_dir = "#{@build.gem_clone_dir}/mgem-list"
url = 'https://github.com/mruby/mgem-list.git'
git_clone_dependency(url, list_dir, nil, 'master')
conf_path = "#{list_dir}/#{mgem}.gem"
conf_path = "#{list_dir}/mruby-#{mgem}.gem" unless
File.exist? conf_path
fail "mgem not found: #{mgem}" unless File.exist? conf_path
conf = YAML.load File.read conf_path
fail "unknown mgem protocol: #{conf['protocol']}" if
conf['protocol'] != 'git'
return conf
end
#
# Git checkouts
#
def fromGit!(url, branch)
repo_dir = "#{@build.gem_clone_dir}/" +
"#{url.match(/([-\w]+)(\.[-\w]+|)$/).to_a[1]}"
commit = @checksum_hash
return nil if skip_this?(url, repo_dir, branch, commit)
# If there's a lockfile entry for this repo AND the user hasn't
# specified a specific commit ID, we use the locked branch and
# commit.
lock = @build.locks[url] if @build.lock_enabled?
if !commit && lock
branch = lock['branch']
commit = lock['commit']
end
# Clone the dependency (if needed) and checkout the expected
# revision.
git_clone_dependency(url, repo_dir, commit, branch)
git_checkout_dependency(repo_dir, commit, branch)
# Set the lockfile entry if enabled
if @build.lock_enabled?
@build.gem_dir_to_repo_url[repo_dir] = url
@build.locks[url] = {
'url' => url,
'branch' => git.current_branch(gemdir),
'commit' => git.commit_hash(gemdir),
'branch' => @build.git.current_branch(repo_dir),
'commit' => @build.git.commit_hash(repo_dir),
}
end
gemdir << "/#{params[:path]}" if params[:path]
elsif params[:path]
require 'pathname'
gemdir = Pathname.new(params[:path]).absolute? ? params[:path] : "#{root}/#{params[:path]}"
else
fail "unknown gem option #{params}"
return GemCheckout.new(repo_dir, url, branch, commit, @canonical,@path)
end
gemdir
# Test if this repo can be skipped. This will happen if it's
# already in @gem_checkouts and EITHER it is identical (same
# url, branch, commit-ID and subdirectory path) as the current
# checkout OR its "canonical" flag is true. If it's in
# @gem_checkouts and neither of these conditions is true, that's
# a fatal error; it means there are multiple incompatible
# versions of this gem to be checked out into this directory.
#
# Otherwise, returns false.
def skip_this?(url, repo_dir, branch, commit)
prev = @gem_checkouts[repo_dir]
return false unless prev
# Canonical declarations must precede all others.
fail("Attempted to re-declare #{prev.gemname} as canonical!\n" +
"('canonical' can only be used on its first declaration.)") if
prev && @canonical
# If prev is canonical, we can ignore this
if prev.canonical?
puts "Found canonical #{prev.gemname}; skipping this one."
return true
end
# If this checkout is identical to the current one, we can skip it.
candidate = GemCheckout.new(repo_dir, url, branch, commit, @canonical,
@path)
if prev == candidate
puts "Found duplicate checkout for #{repo_dir}; ignoring."
return true
end
# Otherwise, we have a checkout conflict. This is an error.
fail "Conflicting gem definitions for '#{repo_dir}':\n" +
" #{candidate}\n" +
" #{prev}\n"
end
# Retrieve a git repo if it's not present. Return
# [path_to_checkout, did_clone]
def git_clone_dependency(url, repo_dir, commit, branch)
return if
File.exist?(repo_dir) && File.exist?(File.join(repo_dir, '.git'))
FileUtils.mkdir_p repo_dir
options = @options.dup
options << "--recursive"
options << "--branch \"#{branch}\""
options << "--depth 1" unless commit
@build.git.run_clone repo_dir, url, options
end
def git_checkout_dependency(repo_dir, commit, branch)
return unless commit
@build.git.run_checkout_detach(repo_dir, commit)
end
end
def enable_gems?
+50
View File
@@ -0,0 +1,50 @@
autoload :Pathname, 'pathname'
module MRuby
module Documentation
def Documentation.update_opcode_md
mrubydir = Pathname(MRUBY_ROOT)
path_ops_h = mrubydir + "include/mruby/ops.h"
path_opcode_md = mrubydir + "doc/internal/opcode.md"
opspecs = {
"Z" => { prefix: "", modified: "-" },
"B" => { prefix: "\'" },
"BB" => { prefix: "\"" },
"BBB" => { prefix: "\"" },
"BS" => { prefix: "\'" },
"BSS" => { prefix: "\'" },
"S" => { prefix: "" },
"W" => { prefix: "" },
}
diff = ""
spliter = <<~'SPLITER'
| Instruction Name | Operand type | Semantics |
|--------------------|----------------|------------------------------------------------------------|
SPLITER
diff = path_opcode_md.read.sub(/^#{Regexp.escape spliter}.*?(?=\z|^$\n)/m) do
repl = spliter
ops = path_ops_h.read
ops.scan(/^\s*OPCODE\s*\(\s*(\w+)\s*,\s*(\w+)\s*\)\s*(?:\/\*\s*(.*?)\s*\*\/\s*)?/).each do |ins, opr, cmt|
if cmt
cmt.sub!(/\s*#.*/, "")
cmt.sub!(/\b(?=L_\w+\b)/, "OP_")
cmt.gsub!(/\b(Irep|Pool|R|Syms)\[([^\[\]]+)\]/, "\\1(\\2)")
cmt.gsub!(/[\\\|]/) { |m| "\\#{m}" } # Ruby-2.5 is not support "Numbered block parameter"
end
spec = opspecs[opr] or raise "unknown operand type: #{opr}"
item = format(%(| %-18s | %-14s | %-58s |\n), "`OP_#{ins}`", "`#{spec[:modified] || opr}`", cmt && "`#{cmt}`")
repl << item
end
repl
end
path_opcode_md.binwrite diff
end
end
end
+2 -2
View File
@@ -170,7 +170,7 @@ module MRuby
end
def funcname
@funcname ||= @name.gsub('-', '_')
@funcname ||= @name.tr('-', '_')
end
def compilers
@@ -225,7 +225,7 @@ module MRuby
f.puts %Q[ }]
f.puts %Q[ struct REnv *e = mrb_vm_ci_env(mrb->c->cibase);]
f.puts %Q[ mrb_vm_ci_env_set(mrb->c->cibase, NULL);]
f.puts %Q[ mrb_env_unshare(mrb, e);]
f.puts %Q[ mrb_env_unshare(mrb, e, FALSE);]
end
f.puts %Q[ mrb_gc_arena_restore(mrb, ai);]
f.puts %Q[}]
+1 -1
View File
@@ -102,7 +102,7 @@ module MRuby
@list_path ||= "#{@build.build_dir}/presym".freeze
end
def header_dir;
def header_dir
@header_dir ||= "#{@build.build_dir}/include/mruby/presym".freeze
end
+4
View File
@@ -7,4 +7,8 @@ MRuby::GemBox.new do |conf|
# Use Rational/Complex numbers
conf.gem :core => "mruby-rational"
conf.gem :core => "mruby-complex"
# Use Complex math functions in CMath module
conf.gem :core => "mruby-cmath"
# Use Multi-precision Integer
conf.gem :core => "mruby-bigint"
end
+8 -8
View File
@@ -239,7 +239,7 @@ class Array
#
# Returns a new array that is a one-dimensional flattening of this
# array (recursively). That is, for every element that is an array,
# extract its elements into the new array. If the optional
# extract its elements into the new array. If the optional
# <i>level</i> argument determines the level of recursion to flatten.
#
# s = [ 1, 2, 3 ] #=> [1, 2, 3]
@@ -262,7 +262,7 @@ class Array
#
# Flattens +self+ in place.
# Returns <code>nil</code> if no modifications were made (i.e.,
# <i>ary</i> contains no subarrays.) If the optional <i>level</i>
# <i>ary</i> contains no subarrays.) If the optional <i>level</i>
# argument determines the level of recursion to flatten.
#
# a = [ 1, 2, [3, [4, 5] ] ]
@@ -313,7 +313,7 @@ class Array
# ary.fetch(index) { |index| block } -> obj
#
# Tries to return the element at position +index+, but throws an IndexError
# exception if the referenced +index+ lies outside of the array bounds. This
# exception if the referenced +index+ lies outside of the array bounds. This
# error can be prevented by supplying a second argument, which will act as a
# +default+ value.
#
@@ -539,7 +539,7 @@ class Array
# the given condition in O(log n) where n is the size of the array.
#
# You can use this method in two use cases: a find-minimum mode and
# a find-any mode. In either case, the elements of the array must be
# a find-any mode. In either case, the elements of the array must be
# monotone (or sorted) with respect to the block.
#
# In find-minimum mode (this is a good choice for typical use case),
@@ -551,7 +551,7 @@ class Array
# - the block returns true for any element whose index is greater
# than or equal to i.
#
# This method returns the i-th element. If i is equal to ary.size,
# This method returns the i-th element. If i is equal to ary.size,
# it returns nil.
#
# ary = [0, 4, 7, 10, 12]
@@ -570,7 +570,7 @@ class Array
# j <= k < ary.size.
#
# Under this condition, this method returns any element whose index
# is within i...j. If i is equal to j (i.e., there is no element
# is within i...j. If i is equal to j (i.e., there is no element
# that satisfies the block), this method returns nil.
#
# ary = [0, 4, 7, 10, 12]
@@ -580,7 +580,7 @@ class Array
# ary.bsearch {|x| 4 - (x / 2).truncate } #=> nil
#
# You must not mix the two modes at a time; the block must always
# return either true/false, or always return a number. It is
# return either true/false, or always return a number. It is
# undefined which value is actually picked up at each iteration.
def bsearch(&block)
@@ -707,7 +707,7 @@ class Array
# <code>==</code> to +obj+.
#
# If a block is given instead of an argument, returns the _index_ of the
# first object for which the block returns +true+. Returns +nil+ if no
# first object for which the block returns +true+. Returns +nil+ if no
# match is found.
#
# ISO 15.2.12.5.14
+17 -29
View File
@@ -3,6 +3,7 @@
#include <mruby/array.h>
#include <mruby/range.h>
#include <mruby/hash.h>
#include <mruby/internal.h>
#include <mruby/presym.h>
/*
@@ -32,7 +33,7 @@ mrb_ary_assoc(mrb_state *mrb, mrb_value ary)
mrb_value v;
mrb_value k = mrb_get_arg1(mrb);
for (i = 0; i < RARRAY_LEN(ary); ++i) {
for (i = 0; i < RARRAY_LEN(ary); i++) {
v = mrb_check_array_type(mrb, RARRAY_PTR(ary)[i]);
if (!mrb_nil_p(v) && RARRAY_LEN(v) > 0 &&
mrb_equal(mrb, RARRAY_PTR(v)[0], k))
@@ -62,7 +63,7 @@ mrb_ary_rassoc(mrb_state *mrb, mrb_value ary)
mrb_value v;
mrb_value value = mrb_get_arg1(mrb);
for (i = 0; i < RARRAY_LEN(ary); ++i) {
for (i = 0; i < RARRAY_LEN(ary); i++) {
v = RARRAY_PTR(ary)[i];
if (mrb_array_p(v) &&
RARRAY_LEN(v) > 1 &&
@@ -103,14 +104,14 @@ ary_ref(mrb_state *mrb, mrb_value ary, mrb_int n)
static mrb_value
mrb_ary_values_at(mrb_state *mrb, mrb_value self)
{
mrb_int argc;
const mrb_value *argv;
mrb_get_args(mrb, "*", &argv, &argc);
mrb_int argc = mrb_get_argc(mrb);
const mrb_value *argv = mrb_get_argv(mrb);
return mrb_get_values_at(mrb, self, RARRAY_LEN(self), argc, argv, ary_ref);
}
mrb_value mrb_ary_delete_at(mrb_state *mrb, mrb_value self);
/*
* call-seq:
* ary.slice!(index) -> obj or nil
@@ -136,8 +137,7 @@ static mrb_value
mrb_ary_slice_bang(mrb_state *mrb, mrb_value self)
{
struct RArray *a = mrb_ary_ptr(self);
mrb_int i, j, k, len, alen;
mrb_value val;
mrb_int i, j, len, alen;
mrb_value *ptr;
mrb_value ary;
@@ -146,21 +146,13 @@ mrb_ary_slice_bang(mrb_state *mrb, mrb_value self)
if (mrb_get_argc(mrb) == 1) {
mrb_value index = mrb_get_arg1(mrb);
switch (mrb_type(index)) {
case MRB_TT_RANGE:
if (mrb_type(index) == MRB_TT_RANGE) {
if (mrb_range_beg_len(mrb, index, &i, &len, ARY_LEN(a), TRUE) == MRB_RANGE_OK) {
goto delete_pos_len;
}
else {
return mrb_nil_value();
}
case MRB_TT_INTEGER:
val = mrb_funcall_id(mrb, self, MRB_SYM(delete_at), 1, index);
return val;
default:
val = mrb_funcall_id(mrb, self, MRB_SYM(delete_at), 1, index);
return val;
return mrb_nil_value();
}
return mrb_ary_delete_at(mrb, self);
}
mrb_get_args(mrb, "ii", &i, &len);
@@ -172,16 +164,12 @@ mrb_ary_slice_bang(mrb_state *mrb, mrb_value self)
if (alen == i) return mrb_ary_new(mrb);
if (len > alen - i) len = alen - i;
ary = mrb_ary_new_capa(mrb, len);
ptr = ARY_PTR(a);
for (j = i, k = 0; k < len; ++j, ++k) {
mrb_ary_push(mrb, ary, ptr[j]);
}
ptr = ARY_PTR(a) + i;
ary = mrb_ary_new_from_values(mrb, len, ptr);
ptr += i;
for (j = i; j < alen - len; ++j) {
for (j = i; j < alen - len; j++) {
*ptr = *(ptr+len);
++ptr;
ptr++;
}
mrb_ary_resize(mrb, self, alen - len);
@@ -205,7 +193,7 @@ mrb_ary_compact(mrb_state *mrb, mrb_value self)
mrb_int len = RARRAY_LEN(self);
mrb_value *p = RARRAY_PTR(self);
for (mrb_int i = 0; i < len; ++i) {
for (mrb_int i = 0; i < len; i++) {
if (!mrb_nil_p(p[i])) {
mrb_ary_push(mrb, ary, p[i]);
}
@@ -233,7 +221,7 @@ mrb_ary_compact_bang(mrb_state *mrb, mrb_value self)
mrb_value *p = ARY_PTR(a);
mrb_ary_modify(mrb, a);
for (i = 0; i < len; ++i) {
for (i = 0; i < len; i++) {
if (!mrb_nil_p(p[i])) {
if (i != j) p[j] = p[i];
j++;
+154
View File
@@ -0,0 +1,154 @@
# fgmp
FGMP is a public domain implementation of a subset of the GNU gmp library with the same API.
WELCOME TO FGMP.
FGMP is a public domain implementation of a subset of the GNU gmp library
with the same API.
For instance, you can link the following trivial program with either
this code, or libgmp.a and get the same results.
```c
#include <stdio.h>
#include "gmp.h"
main()
{
MP_INT a; MP_INT b; MP_INT c;
mpz_init_set_ui(&a,1); mpz_init_set_ui(&b,2); mpz_init(&c);
mpz_add(&c,&a,&b);
printf("\n%s\n", mpz_get_str(NULL,10,&c));
}
```
FGMP is really in the public domain. You can do whatever you want with
it.
I wrote FGMP so that we would all have access to a (truly free)
implementation of this subset of the API of GNU libgmp. I encourage
everyone to distribute this as widely as possible.
If you need more documentation, I suggest you look at the file
gmp.texi which is included with the GNU gmp library.
You can send me bug reports, implementations of missing functions, flames
and rants by Email.
Any submissions of new code to be integrated into fgmp must also be
placed in the public domain (For the particularly dense, you can
release a new fgmp yourself under different licensing terms. This
is a condition for including a submission in a release of FGMP that
I personally prepare).
Mark Henderson <markh@wimsey.bc.ca>
# This is the fifth BETA release. 1.0b5
I hearby place this file and all of FGMP in the public domain.
Thanks to Paul Rouse <par@r-cube.demon.co.uk> for changes to get fgmp
to work on a 286 MS-DOS compiler, the functions mpz_sqrt and
mpz_sqrtrem, plus other general bug fixes.
Thanks also to Erick Gallesio <eg@kaolin.unice.fr> for a fix
to mpz_init_set_str
Define B64 if your "long" type is 64 bits. Otherwise we assume 32
bit longs. (The 64 bit version hasn't been tested enough)
```
Platforms:
Linux 0.99 (gcc)
IBM RS6000/AIX 3.2 (IBM xlc compiler and gcc 2.3)
Sun OS 4.1, Sun 3/4
DEC Alpha OSF/1 (only lightly tested, 64 bit longs do make a difference,
thanks to DEC for providing access via axposf.pa.dec.com). Define B64
for this platform
MS-DOS 286 C compiler (see credits above)
```
# Some differences between gmp and fgmp
1. fgmp is considerably slower than gmp
2. fgmp does not implement the following:
all mpq_*
internal mpn_* functions
mpz_perfect_square_p
mpz_inp_raw, mpz_out_raw
mp_set_memory_functions, mpz_out_str, mpz_inp_str
3. fgmp implements the following in addition to the routines in GNU gmp.
`int mpz_jacobi(MP_INT *a, MP_INT *b)`
- finds the jacobi symbol (a/b)
4. mpz_sizeinbase often overestimates the exact value
5. To convert your gmp based program to fgmp (subject to the
above)
- recompile your source. Make sure to include the gmp.h file included
with fgmp rather than that included with gmp. (The point is to recompile
all files which include gmp.h)
- link with gmp.o instead of libgmp.a
Here's a complete sorted list of function implemented in fgmp:
```
_mpz_realloc
mpz_abs
mpz_add
mpz_add_ui
mpz_and
mpz_clear
mpz_cmp
mpz_cmp_si
mpz_cmp_ui
mpz_div
mpz_div_2exp
mpz_div_ui
mpz_divmod
mpz_divmod_ui
mpz_fac_ui
mpz_gcd
mpz_gcdext
mpz_get_si
mpz_get_str
mpz_get_ui
mpz_init
mpz_init_set
mpz_init_set_si
mpz_init_set_str
mpz_init_set_ui
mpz_jacobi
mpz_mdiv
mpz_mdiv_ui
mpz_mdivmod
mpz_mdivmod_ui
mpz_mmod
mpz_mmod_ui
mpz_mod
mpz_mod_2exp
mpz_mod_ui
mpz_mul
mpz_mul_2exp
mpz_mul_ui
mpz_neg
mpz_or
mpz_pow_ui
mpz_powm
mpz_powm_ui
mpz_probab_prime_p
mpz_random
mpz_random2
mpz_set
mpz_set_si
mpz_set_str
mpz_set_ui
mpz_size
mpz_sizeinbase
mpz_sqrt
mpz_sqrtrem
mpz_sub
mpz_sub_ui
mpz_xor
```
+7
View File
@@ -0,0 +1,7 @@
# Multi-precision Integer extension for mruby
This extension uses fgmp, which is a public domain implementation of a subset of the GNU gmp library by Mark Henderson <markh@wimsey.bc.ca>.
But it's heavily modified to fit with mruby. You can get the original source code from <https://github.com/deischi/fgmp.git>.
You can read the original README for fgmp in [README-fgmp.md](README-fgmp.md).
If you want to create your own Multi-precision Integer GEM, see [examples/mrbgems/mruby-YOUR-bigint/TODO-HINT.md](../../examples/mrbgems/mruby-YOUR-bigint/TODO-HINT.md).
File diff suppressed because it is too large Load Diff
+63
View File
@@ -0,0 +1,63 @@
/**
** @file mruby/bigint.h - Multi-precision Integer
**
** See Copyright Notice in mruby.h
*/
#ifndef MRUBY_BIGINT_H
#define MRUBY_BIGINT_H
/*
* FREE GMP - a public domain implementation of a subset of the
* gmp library
*
* I hearby place the file in the public domain.
*
* Do whatever you want with this code. Change it. Sell it. Claim you
* wrote it.
* Bugs, complaints, flames, rants: please send email to
* Mark Henderson <markh@wimsey.bc.ca>
* I'm already aware that fgmp is considerably slower than gmp
*
* CREDITS:
* Paul Rouse <par@r-cube.demon.co.uk> - generic bug fixes, mpz_sqrt and
* mpz_sqrtrem, and modifications to get fgmp to compile on a system
* with int and long of different sizes (specifically MS-DOS,286 compiler)
* Also see the file "notes" included with the fgmp distribution, for
* more credits.
*
* VERSION 1.0 - beta 5
*/
#include <sys/types.h>
#if defined(MRB_INT32) && defined(_WIN32) && !defined(MRB_NO_MPZ64BIT)
#define MRB_NO_MPZ64BIT
#endif
#ifdef MRB_NO_MPZ64BIT
typedef uint16_t mp_limb;
typedef uint32_t mp_dbl_limb;
typedef int32_t mp_dbl_limb_signed;
#define MPZ_DIG_SIZE 16
#else
typedef uint32_t mp_limb;
typedef uint64_t mp_dbl_limb;
typedef int64_t mp_dbl_limb_signed;
#define MPZ_DIG_SIZE 32
#endif
typedef struct _mpz_t {
mp_limb *p;
short sn;
size_t sz;
} mpz_t;
struct RBigint {
MRB_OBJECT_HEADER;
mpz_t mp;
};
#define RBIGINT(v) ((struct RBigint*)mrb_ptr(v))
mrb_static_assert_object_size(struct RBigint);
#endif /* MRUBY_BIGINT_H */
+10
View File
@@ -0,0 +1,10 @@
MRuby::Gem::Specification.new('mruby-bigint') do |spec|
spec.license = 'MIT'
spec.author = 'mruby developers'
spec.summary = 'Integer class extension to multiple-precision'
spec.build.defines << "MRB_USE_BIGINT"
spec.build.libmruby_core_objs << Dir.glob(File.join(__dir__, "core/**/*.c")).map { |fn|
objfile(fn.relative_path_from(__dir__).pathmap("#{spec.build_dir}/%X"))
}
end
+23
View File
@@ -0,0 +1,23 @@
assert 'Bigint basic' do
n = 1<<65
assert_equal 36893488147419103232, n
assert_equal 36893488147419104229, n+997
assert_equal 36893488147419102235, n-997
assert_equal 36782807682976845922304, n*997
assert_equal 37004501652376231, n.div(997)
end
assert 'Bigint to_s' do
n = 1197857166996989179607278372168909873645893814254642585755536286462800958278984531968
assert_equal n, "11978_571669_96989179607278372168909873645893814254642585755536286462800958278984531968".to_i
assert_equal(-n, "-11978_571669_96989179607278372168909873645893814254642585755536286462800958278984531968".to_i)
n = 0x1197857166996989179607278372168909873645893814254642585755536286462800958278984531968
assert_equal n, "1197857166996989179607278372168909873645893814254642585755536286462800958278984531968".to_i(16)
end
assert 'Bigint pow' do
n = 18446744073709551616
assert_equal n, 2 ** 64
assert_equal n, 1 << 64
assert_equal 2, n >> 63
end
View File
@@ -12,6 +12,7 @@
#include <mruby/class.h>
#include <mruby/proc.h>
#include <mruby/variable.h>
#include <mruby/internal.h>
#include "mrdberror.h"
#include "apibreak.h"
#include "apistring.h"
@@ -20,8 +21,6 @@
#define MRB_DEBUG_BP_FILE_OK (0x0001)
#define MRB_DEBUG_BP_LINENO_OK (0x0002)
uint32_t mrb_packed_int_decode(uint8_t *p, uint8_t **newpos);
static uint16_t
check_lineno(mrb_irep_debug_info_file *info_file, uint16_t lineno)
{
@@ -47,8 +46,8 @@ check_lineno(mrb_irep_debug_info_file *info_file, uint16_t lineno)
case mrb_debug_line_packed_map:
{
uint8_t *p = info_file->lines.packed_map;
uint8_t *pend = p + count;
const uint8_t *p = info_file->lines.packed_map;
const uint8_t *pend = p + count;
uint32_t line = 0;
while (p < pend) {
mrb_packed_int_decode(p, &p);
@@ -14,6 +14,7 @@
#include <mruby/opcode.h>
#include <mruby/variable.h>
#include <mruby/proc.h>
#include <mruby/internal.h>
#include "mrdb.h"
#include "apibreak.h"

Some files were not shown because too many files have changed in this diff Show More