Compare commits

..

1969 Commits

Author SHA1 Message Date
mimaki 2a435caf79 Update version to 3.4.0RC2. 2025-03-17 16:31:36 +09:00
mimaki 8b65a296db Merge branch 'master' into stable 2025-03-17 15:52:25 +09:00
Yukihiro "Matz" Matsumoto 468c6f1901 doc/mruby3.4.md: add #6491 to the release note 2025-03-17 09:21:36 +09:00
Yukihiro "Matz" Matsumoto d1909320d9 mruby-compiler: fixed a bug in string literal merge; fix #6491 2025-03-17 09:17:38 +09:00
Yukihiro "Matz" Matsumoto a6848ca2cb pre-commit autoupdate 2025-03-15 16:34:18 +09:00
Yukihiro "Matz" Matsumoto eb455c19fe mruby-compiler: prohibit singleton methods for literals
We have checked `def (literal).m` style but not `def literal.m` style.
In addition, `NODE_INT` check is newly added.
2025-03-14 23:28:42 +09:00
Yukihiro "Matz" Matsumoto 8472fe0f13 doc/limitation.md: remove visibility note
We have implemented visibility in mruby 3.4
2025-03-13 22:46:23 +09:00
Yukihiro "Matz" Matsumoto 9c37098c15 Merge pull request #6490 from dearblue/string
Fixed `RSTR_SINGLE_BYTE_P()` return values to boolean
2025-03-13 10:57:49 +09:00
dearblue 609a5c23b2 Fixed RSTR_SINGLE_BYTE_P() return values to boolean
Incorrectly returned void type when `MRB_UTF8_STRING` definition is not present.
2025-03-12 22:01:37 +09:00
Yukihiro "Matz" Matsumoto 17d5aaa048 doc/mruby3.4.md: first draft of the mruby 3.4 release note 2025-03-12 14:51:58 +09:00
Yukihiro "Matz" Matsumoto 5bc00bf199 mruby-compiler: detect super without surrounding method; close #6271 2025-03-11 21:21:50 +09:00
Yukihiro "Matz" Matsumoto 1e6442f54e Revert "class.c (include_module_at): narrow local variable scope"
C++ does not compile `goto` cross local variable declaration.
This reverts commit c618b44fee.
2025-03-10 19:33:49 +09:00
mimaki a2841fd9a8 Update version to 3.4.0RC. 2025-03-10 14:42:59 +09:00
Yukihiro "Matz" Matsumoto 1e36d7662c object.h: rename gccolor to clearer gc_color 2025-03-10 14:23:51 +09:00
Yukihiro "Matz" Matsumoto 92b18d6a44 gc.c: fix re-using to reusing 2025-03-10 14:23:21 +09:00
Yukihiro "Matz" Matsumoto f4de205960 range.c (range_num_to_a): reduce integer to float conversion
For big numbers (especially integers close to MRB_INT_MAX), float
conversion may be lose precisions. So we try not to convert numbers, but
just compare.
2025-03-10 13:13:10 +09:00
Yukihiro "Matz" Matsumoto 76d3739a89 mruby-metaprog (mrb_obj_methods): should not retrieve obj->c directly
In some cases, `obj` may not be an object structure, but an immediate.
2025-03-10 11:40:48 +09:00
Yukihiro "Matz" Matsumoto c618b44fee class.c (include_module_at): narrow local variable scope 2025-03-10 11:26:13 +09:00
Yukihiro "Matz" Matsumoto 48f93adcdc class.c (boot_defclass): unify variable declaration and initialization 2025-03-10 11:25:34 +09:00
Yukihiro "Matz" Matsumoto 32200f1eb9 build_config/no-float.rb: test build for MRB_NO_FLOAT
mruby allows to disable floating point numbers. We have add a build
configuration to test mruby build without floating point numbers.
2025-03-09 17:14:46 +09:00
Yukihiro "Matz" Matsumoto f2c8b43d42 mruby-test: stop unused local variable warning 2025-03-09 16:43:28 +09:00
Yukihiro "Matz" Matsumoto 4ba0cac481 numeric.c (coerce_step_counter): move local variable definition
To avoid unused local variable warning.
2025-03-09 16:42:28 +09:00
Yukihiro "Matz" Matsumoto 2b76967724 Merge pull request #6487 from esotericpig/master
Add Emscripten toolchain & build_config
2025-03-09 14:28:30 +09:00
Yukihiro "Matz" Matsumoto 9a226c28bc hash.c: add arity check for Hash#default_proc (and Hash.new); fix #6484 2025-03-08 16:14:26 +09:00
Yukihiro "Matz" Matsumoto a7f3cfb711 hash.c: allow 'default_proc=nil' to clear default_proc; ref #6483 2025-03-08 15:49:26 +09:00
Yukihiro "Matz" Matsumoto 837f62f18a hash.c: should check type before setting default_proc; fix #6483 2025-03-08 12:34:25 +09:00
Yukihiro "Matz" Matsumoto fbaedfeaad test/hash.rb: remove Hash#freeze before Hash#rehash; ref #6485 2025-03-08 11:25:49 +09:00
Yukihiro "Matz" Matsumoto 87680d3ab2 hash.c (mrb_hash_rehash): call hash_modify before actual modify; fix #6485 2025-03-08 11:21:27 +09:00
Yukihiro "Matz" Matsumoto 213a262b20 hash.c (mrb_hash_compact): call hash_modify instead of mrb_check_frozen
Currently, hash_modify() only calls mrb_check_frozen, but we may add new
checks in the future; ref #6485
2025-03-08 11:15:37 +09:00
Yukihiro "Matz" Matsumoto 96113a2ed9 mruby-io: define File.absolute_path method; ref #6482 2025-03-08 11:12:12 +09:00
Yukihiro "Matz" Matsumoto 436269f62c class.c: remove duplicated CI_TARGET_CLASS definition from class.c 2025-03-08 11:09:57 +09:00
Yukihiro "Matz" Matsumoto 3c4f6501b0 class.c (find_visibility_ci): inline find_ci_from_proc() 2025-03-08 07:54:51 +09:00
esotericpig bfc9742848 Add Emscripten toolchain & build_config 2025-03-07 12:39:54 -10:00
Yukihiro "Matz" Matsumoto 07b986f710 symbol.c (sym_inline_unpack): should not mix signedness 2025-03-07 17:55:20 +09:00
Yukihiro "Matz" Matsumoto ec7477fe0d class.c: take visibility from outer scope
It is possible to update the visibility from within a block, so that
`find_visibility_ci()` should look up outer scopes.
2025-03-07 17:49:08 +09:00
Yukihiro "Matz" Matsumoto 67e85ed296 vm.c (mrb_object_exec): update ci's target class by update function
To avoid breaking a Proc with env set.
2025-03-07 17:17:50 +09:00
Yukihiro "Matz" Matsumoto fb56fecf51 class.h: remove macros no longer used 2025-03-07 17:17:50 +09:00
Yukihiro "Matz" Matsumoto 889f09f8b7 class.c: move visibility flags from classes/modules to callinfo 2025-03-07 17:17:50 +09:00
Yukihiro "Matz" Matsumoto 02bf7fe08e symbol.c (sym_inline_pack): max inline symbol length is now 4 2025-03-07 17:17:50 +09:00
Yukihiro "Matz" Matsumoto 6e1ab49ed3 class.c: allow changing visibility of methods defined in superclasses 2025-03-07 17:17:49 +09:00
Yukihiro "Matz" Matsumoto 2309fa0353 AUTHORS: update entries [ci skip] 2025-03-07 17:17:49 +09:00
Yukihiro "Matz" Matsumoto 37fb59bdac class.h: rename macros for clarity
- MRB_SET_VISIBILITY -> MRB_CLASS_SET_VISIBILITY
- MRB_VISIBILITY -> MRB_CLASS_VISIBILITY
2025-03-07 17:17:49 +09:00
Yukihiro "Matz" Matsumoto 5e6ea6c5f9 vm.c: restore visibility when reopen class/module definition
Ideally, the default visibility should be stored in the scope. But for
the time being mruby stores the visibility in the class/module. As a
result, nesting class/module reopening or class_eval/module_eval could
cause incompatibility. We will try to fix them in the future.
2025-03-07 17:17:49 +09:00
Yukihiro "Matz" Matsumoto 2a876d2047 class.c: implement top-level public/private/protected in the core in C 2025-03-07 17:17:49 +09:00
Yukihiro "Matz" Matsumoto 43da490a1e class.c: alias should keep the visibility of the original 2025-03-07 17:17:48 +09:00
Yukihiro "Matz" Matsumoto 18674c0237 test/module.rb: add visibility tests; ref #1835 2025-03-07 17:17:48 +09:00
Yukihiro "Matz" Matsumoto 384579fd21 test/module.rb: rename to pass the spell check 2025-03-07 17:17:48 +09:00
Yukihiro "Matz" Matsumoto 921d632615 class.c (mrb_mod_visibility): clear method cache 2025-03-07 17:17:48 +09:00
Yukihiro "Matz" Matsumoto 20d5330417 class.c: use MT_VMASK to mask the flag values 2025-03-07 17:17:48 +09:00
Yukihiro "Matz" Matsumoto 3f93254b02 mruby-metaprog: add actual test for Kernel#protected_methods 2025-03-07 17:17:47 +09:00
Yukihiro "Matz" Matsumoto 16db15d6fd mruby-metaprog: add actual test for Kernel#private_methods 2025-03-07 17:17:47 +09:00
Yukihiro "Matz" Matsumoto 2db1ad9ce3 mruby-metaprog/test: avoid potential name crash by Foo class 2025-03-07 17:17:47 +09:00
Yukihiro "Matz" Matsumoto 6f2409adf3 Revert "proc.h: define visibility flags for RProc"
This reverts commit 7948373c7d2a019b0eed6ca6dfcb4d6e503b75d8.
2025-03-07 17:17:47 +09:00
Yukihiro "Matz" Matsumoto b0db0bdd3a vm.c: add checks for visibility (private, protected); close #1835 2025-03-07 17:17:47 +09:00
Yukihiro "Matz" Matsumoto aba9a7d053 class.c: #initialize should be private by default
Fixed wrong condition.
2025-03-07 17:17:46 +09:00
Yukihiro "Matz" Matsumoto 1a026ba9aa pre-commit: autoupdate 2025-03-07 17:17:46 +09:00
Yukihiro "Matz" Matsumoto 29cb270ef4 proc.h: define visibility flags for RProc
Visibility status should be store in Procs (that represent scopes), not
classes. Since classes can be reopened or can be accessed recursively.
2025-03-07 17:17:46 +09:00
Yukihiro "Matz" Matsumoto c22f527bac symbol.c (SYMBOL_INLINE_P): fix the check condition
Symbol `:_` would break the assertion.
2025-03-07 17:17:46 +09:00
Yukihiro "Matz" Matsumoto 6a61cd9373 kernel.c: make #respond_to_missing? private 2025-03-07 17:17:46 +09:00
Yukihiro "Matz" Matsumoto 52403abcf8 mruby-binding: make Kernel#binding private 2025-03-07 17:17:45 +09:00
Yukihiro "Matz" Matsumoto e5e8dd11c0 mruby-rational: make Rational() private 2025-03-07 17:17:45 +09:00
Yukihiro "Matz" Matsumoto 2a991fb399 mruby-complex: make Complex() private 2025-03-07 17:17:45 +09:00
Yukihiro "Matz" Matsumoto 111fe4b3be mruby-compiler: generate OP_SSEND from Complex and Rational literals 2025-03-07 17:17:45 +09:00
Yukihiro "Matz" Matsumoto 4a0e80601f mruby-kernel-ext: make Kernel methods private
- fail
- caller
= __method__
- __callee__
- Integer
= Float
- String
- Array
- Hash
2025-03-07 17:17:45 +09:00
Yukihiro "Matz" Matsumoto 93e133548f mruby-eval: make #eval private 2025-03-07 17:17:44 +09:00
Yukihiro "Matz" Matsumoto d7a4275dd1 mruby-metaprog: make #global_variables, #local_variables private 2025-03-07 17:17:44 +09:00
Yukihiro "Matz" Matsumoto 95b30a38dc kernel.rb: make Kernel#loop private 2025-03-07 17:17:44 +09:00
Yukihiro "Matz" Matsumoto ff6149dea7 kernel.c: removed some Kernel singleton methods
Since virtually no one calls `Kernel.block_given?` but just
`block_given?`. For the cases `raise` is redefined (like Ruby/Tk),
`Kernel.raise` is kept.
2025-03-07 17:17:44 +09:00
Yukihiro "Matz" Matsumoto 3a56106d6c mruby-proc-ext: make #proc private 2025-03-07 17:17:43 +09:00
Yukihiro "Matz" Matsumoto efc03f60af proc.c: make #lambda private 2025-03-07 17:17:43 +09:00
Yukihiro "Matz" Matsumoto cc54865873 mruby-sleep: make #sleep (and #usleep) private 2025-03-07 17:17:43 +09:00
Yukihiro "Matz" Matsumoto f7142cd327 mruby-random: make Kernel#srand and #rand private 2025-03-07 17:17:43 +09:00
Yukihiro "Matz" Matsumoto 4f5cad6444 mruby-catch: make #catch and #throw private 2025-03-07 17:17:43 +09:00
Yukihiro "Matz" Matsumoto 6bb629e957 mruby-exit: make exit methods private 2025-03-07 17:17:42 +09:00
Yukihiro "Matz" Matsumoto 6f97c842d2 mruby-io: use ... for argument forwarding 2025-03-07 17:17:42 +09:00
Yukihiro "Matz" Matsumoto a736ddcbb7 mruby-io: make some methods private
- open
- print
- printf
- gets
2025-03-07 17:17:42 +09:00
Yukihiro "Matz" Matsumoto 37d3d34036 mruby-compiler: use OP_SSEND for backquote calls 2025-03-07 17:17:42 +09:00
Yukihiro "Matz" Matsumoto cfc104e66c class.c (mrb_define_module_function): make instance method private 2025-03-07 17:17:42 +09:00
Yukihiro "Matz" Matsumoto d022a3ee68 mruby-eval/test: use #__send__ to call private #eval 2025-03-07 17:17:41 +09:00
Yukihiro "Matz" Matsumoto 23d5e04fdf mruby-proc-ext/test: fix wrong usage of mrb_module_function() 2025-03-07 17:17:41 +09:00
Yukihiro "Matz" Matsumoto 541cdf35eb 00kernel.rb: use #__send__ to skip private check 2025-03-07 17:17:41 +09:00
Yukihiro "Matz" Matsumoto 798fd7dbdf 00class.rb: use #__send__ to skip private check 2025-03-07 17:17:41 +09:00
Yukihiro "Matz" Matsumoto e8574b6298 mruby-struct/test: call #remove_const via #__send__ 2025-03-07 17:17:41 +09:00
Yukihiro "Matz" Matsumoto cce8f62b21 mruby-object-ext/test: call #remove_const via #__send__ 2025-03-07 17:17:40 +09:00
Yukihiro "Matz" Matsumoto 4d547b6cbb test/module.rb: call #remove_const via #__send__ to skip private check 2025-03-07 17:17:40 +09:00
Yukihiro "Matz" Matsumoto e0cb99aad4 test/module.rb: call #extend_object via #__send__ to skip private check 2025-03-07 17:17:40 +09:00
Yukihiro "Matz" Matsumoto 8a409feaad test/module.rb: call #prepend_features via #__send__ to skip private check 2025-03-07 17:17:40 +09:00
Yukihiro "Matz" Matsumoto 701a18deda test/module.rb: call #append_features via #__send__ to skip private check 2025-03-07 17:17:40 +09:00
Yukihiro "Matz" Matsumoto 7653bdd05e test/codegen.rb: call #remove_const via #__send__ to skip private check 2025-03-07 17:17:39 +09:00
Yukihiro "Matz" Matsumoto f82cd188b0 test/exception.rb: call #initialize via #__send__ to skip private check 2025-03-07 17:17:39 +09:00
Yukihiro "Matz" Matsumoto 214ae5aad3 test/array.rb: call #initialize via #__send__ to skip private check 2025-03-07 17:17:39 +09:00
Yukihiro "Matz" Matsumoto 7981865e18 test/string.rb: call #initialize via #__send__ to skip private check 2025-03-07 17:17:39 +09:00
Yukihiro "Matz" Matsumoto 4122cee9e4 class.c: implement attr_accessor in C 2025-03-07 17:17:39 +09:00
Yukihiro "Matz" Matsumoto 27828de749 kernel.c: make some methods private
- block_given?
- initialize_copy
- iterator?
- p
- print
- raise
- respond_to_missing?
2025-03-07 17:17:38 +09:00
Yukihiro "Matz" Matsumoto bfcc1e3c2c mruby-io: puts should print nothing for empty arrays 2025-03-07 17:17:38 +09:00
Yukihiro "Matz" Matsumoto 7d2beb9fef class.c (mrb_remove_method): should call hook method from the origin
MRB_CLASS_ORIGIN moves the pointer for prepended class/module, but the
hook method should be searched from the original class/module.
2025-03-07 17:17:38 +09:00
Yukihiro "Matz" Matsumoto 6168b15e0e class.c (undef_method): call hook method when undef'ing a method 2025-03-07 17:17:38 +09:00
Yukihiro "Matz" Matsumoto bcd0e0e439 class.c (mrb_remove_method): call hook method
Depending the context, hook method should be either method_removed or
singleton_method_removed.
2025-03-07 17:17:38 +09:00
Yukihiro "Matz" Matsumoto 457aaa173b mruby-metaprog (mrb_mod_remove_method): stop calling method_removed()
The hook method should be called from mrb_remove_method().
2025-03-07 17:17:37 +09:00
Yukihiro "Matz" Matsumoto 0863c08841 class.c: implement singleton method hook methods
- singleton_method_removed
- singleton_method_undefined
2025-03-07 17:17:37 +09:00
Yukihiro "Matz" Matsumoto 9c74f6e908 class.c: implement method hook methods
- method_removed
- method_undefined
2025-03-07 17:17:37 +09:00
Yukihiro "Matz" Matsumoto eb8b4120d7 class.c: initialize method needs to be private by default 2025-03-07 17:17:37 +09:00
Yukihiro "Matz" Matsumoto 4ea5510937 mruby-compiler (merge_op_string): fix #6477
If two merging strings are the same and registered at the bottom of the
pool, we should not remove the slot from the pool.
2025-03-07 17:17:37 +09:00
Yukihiro "Matz" Matsumoto e660e28a39 class.c: make some Module methods private
- append_features
- extend_object
- extended
- included
- initialize
- method_added
- module_function
- prepend_features
- prepended
- private
- protected
- public
- remove_const
2025-03-07 17:17:36 +09:00
Yukihiro "Matz" Matsumoto f5150ab98a class.c: make some Class methods private
- initialize
- inherited
2025-03-07 17:17:36 +09:00
Yukihiro "Matz" Matsumoto c5e270e8f3 class.c: make some BasicObject methods private
- initialize
- singleton_method_added
- method_missing
2025-03-07 17:17:36 +09:00
Yukihiro "Matz" Matsumoto ca20017ac9 class.c: implement mrb_define_private_method() 2025-03-07 17:17:36 +09:00
Yukihiro "Matz" Matsumoto 71c0de7f08 class.c (mrb_define_method_raw): take visibility from the class
If not explicitly specified in the method struct.
2025-03-07 17:17:36 +09:00
Yukihiro "Matz" Matsumoto 1ab8e4d27d mruby-toplevel-ext: make Main#include private 2025-03-07 17:17:35 +09:00
Yukihiro "Matz" Matsumoto 7f12e6648f AUTHORS: update entries [ci skip] 2025-03-07 17:17:35 +09:00
Yukihiro "Matz" Matsumoto 1e4a3f3e5c mruby-toplevel-ext: implement toplevel public/private/protected 2025-03-07 17:17:35 +09:00
Yukihiro "Matz" Matsumoto 235c1484d0 mruby-toplevel-ext: Directly include features to Object class 2025-03-07 17:17:35 +09:00
Yukihiro "Matz" Matsumoto 9e3e7b2cfe mruby-metaprog: add 3 new methods to retrieve instance method names
- public_instance_methods
- private_instance_methods
- protected_instance_methods
2025-03-07 17:17:34 +09:00
Yukihiro "Matz" Matsumoto 9229da10e4 mruby-metaprog: implement method list from a class (or an instance) 2025-03-07 17:17:34 +09:00
Yukihiro "Matz" Matsumoto a282f8bf2a mruby-metaprog: remove unnecessary enum 2025-03-07 17:17:34 +09:00
Yukihiro "Matz" Matsumoto fdf71d8f2d class.c: first step to private methods; #1835
Now each method entry holds visibility information in flag bits.
2025-03-07 17:17:34 +09:00
Yukihiro "Matz" Matsumoto 3a3e877ae5 codedump.c: update OP_DEF output
OP_DEF takes R(a) as a class to define a method, sym(b) as a method
name, and R(a+1) as a method body. So we added `(R(a+1))` in the output.
2025-03-07 17:17:34 +09:00
Yukihiro "Matz" Matsumoto 6442a012c8 symbol.c (SYMBOL_INLINE_P): inline symbol to occupy 26 bits in mrb_sym
It used to occupy 30 bits, but we need 2 more bits to keep method
visibility in the method tables.
2025-03-07 17:17:33 +09:00
Yukihiro "Matz" Matsumoto 3e6abfd21c symbol.c (sym_inline_pack): set pack_length_max to 4 2025-03-07 17:17:33 +09:00
Yukihiro "Matz" Matsumoto fc16f9dd13 Merge pull request #6482 from dearblue/absolute_path
Add `File.absolute_path?` method
2025-03-07 17:16:20 +09:00
dearblue c796729fa8 Add File.absolute_path? method 2025-03-05 22:23:49 +09:00
Yukihiro "Matz" Matsumoto 8f69fbbaf8 Merge pull request #6480 from mruby/dependabot/github_actions/super-linter/super-linter-7.3.0 2025-02-28 12:24:20 +09:00
dependabot[bot] 1d76e9f4f4 build(deps): bump super-linter/super-linter from 7.2.1 to 7.3.0
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 7.2.1 to 7.3.0.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/CHANGELOG.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v7.2.1...v7.3.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-27 14:28:50 +00:00
Yukihiro "Matz" Matsumoto 0e1a77e7d7 Merge pull request #6479 from dearblue/expand_path 2025-02-27 10:36:32 +09:00
Yukihiro "Matz" Matsumoto 30b0b41fb1 Merge pull request #6478 from dearblue/chars2bytes 2025-02-27 10:32:55 +09:00
dearblue f77ebfe102 Reimplementation of File.expand_path method
The reason for this is to fix the following problems

  - Even on non-Windows, drive letter recognition was still being handled.
  - On Windows, paths starting with a slash were not expanded correctly.
  - On Windows, relative paths containing drive letters behaved differently than in CRuby.

Due to reimplementation, the internal methods `File._concat_path`, `File._gethome` and `File._getwd` methods have been removed.
2025-02-26 21:55:25 +09:00
dearblue 437065997f Redefine some macros in mruby-io
To improve uniformity of names and definition locations.
2025-02-26 21:55:17 +09:00
dearblue 76fc6e9ace Fixed buffer overrun in function chars2bytes()
If `off` was greater than zero, the address pointed to by `e` exceeded the valid range of the buffer.
2025-02-26 21:22:37 +09:00
Yukihiro "Matz" Matsumoto 66606f71dd Merge pull request #6474 from dearblue/kwerr 2025-02-03 11:54:52 +09:00
Yukihiro "Matz" Matsumoto 623e953193 Merge pull request #6473 from dearblue/bigint 2025-02-03 08:28:54 +09:00
Yukihiro "Matz" Matsumoto 8c1915ec3b Merge pull request #6475 from dearblue/buildconf 2025-02-02 21:24:32 +09:00
dearblue d946c3e264 Don't include deleted mruby-print 2025-02-02 21:13:11 +09:00
dearblue b86c220384 Avoid array object creation with “unknown keyword” error
It is sufficient to return the first element.
2025-02-02 21:02:03 +09:00
dearblue 3b1e3d930f Hide mpz_and() symbol 2025-02-02 16:59:28 +09:00
Yukihiro "Matz" Matsumoto 49396024b7 Merge pull request #6472 from dearblue/rational 2025-01-27 12:37:53 +09:00
Yukihiro "Matz" Matsumoto cb3b94346e mruby-complier (gen_call): remove duplicate MRB_OPSYM_2(); #6471 2025-01-27 12:36:14 +09:00
Yukihiro "Matz" Matsumoto 69024d9a36 mruby-compiler (gen_call): operator optimization with self; close #6471
If the left operand is `self`, the previous (reverted) change disabled
optimization with operators. This is sort of a hack, but it works.
2025-01-26 23:14:19 +09:00
dearblue 12e90896a5 Moved tests for Integer#quo
The `Rational` class is never defined during core testing.
2025-01-26 21:11:21 +09:00
Yukihiro "Matz" Matsumoto acddb3945b mruby-compiler (gen_call): adjust spacing 2025-01-26 20:08:01 +09:00
Yukihiro "Matz" Matsumoto 6731d59f06 Revert "mruby-compiler (gen_call): use OP_SSEND for self.foo() calls"
This reverts commit 583aa985c8f3117a833a38f0d27753a090503f17; #6471
2025-01-26 19:52:01 +09:00
Yukihiro "Matz" Matsumoto 171847a99a build_config/playstationportable.rb: remove obsolete mruby-print gem 2025-01-23 22:02:24 +09:00
Yukihiro "Matz" Matsumoto 37cff2ceea Merge pull request #6469 from dearblue/const-proc 2025-01-23 22:01:57 +09:00
Yukihiro "Matz" Matsumoto 9bab92e060 .git-blame-ignore-revs: ignore indentation fix commit; ref #6470 2025-01-22 14:10:30 +09:00
Yukihiro "Matz" Matsumoto f311a53995 Merge pull request #6470 from dearblue/psp 2025-01-22 13:58:18 +09:00
Yukihiro "Matz" Matsumoto 91a7bc53a6 .pre-commit-config.yml: pre-commit autoupdate 2025-01-21 13:07:44 +09:00
Yukihiro "Matz" Matsumoto 5ed4a772f3 array.c (mrb_ary_unshift_m): defer mrb_get_argv call 2025-01-21 13:07:44 +09:00
Yukihiro "Matz" Matsumoto 3b6325ba3c hash.c (mrb_hash_aset): use pre-assigned local variable 2025-01-21 13:07:44 +09:00
Yukihiro "Matz" Matsumoto 4ebe706496 Merge pull request #6468 from dearblue/hash 2025-01-21 10:29:47 +09:00
dearblue 90ab714fda Adjusting indentation 2025-01-20 22:51:36 +09:00
dearblue a981f5aed7 Add more const qualifier for RProc 2025-01-20 22:25:50 +09:00
dearblue 1e504bb16a Fixed missing changes to IB_FIND_BY_KEY() parameter names
This is a #6432 supplement.
2025-01-20 22:11:45 +09:00
Yukihiro "Matz" Matsumoto ab3abdf5aa print.c (mrb_print_m): need to copy argument array; fix #6467 2025-01-18 13:35:40 +09:00
Yukihiro "Matz" Matsumoto 6174541d82 mruby-encoding: move String#b to mruby-string-ext gem 2025-01-18 13:23:55 +09:00
Yukihiro "Matz" Matsumoto 583214f452 build_config: remove MRB_UTF8_STRING from full-core configurations
- host-debug
- ci/gcc-clang

Since it is automatically turned on by mruby-encoding.
2025-01-16 09:18:14 +09:00
Yukihiro "Matz" Matsumoto 351cd5aa46 mruby-string-ext: remove some methods moved to mruby-encoding
- String#valid_encoding?
- String#force_encoding
2025-01-16 09:12:09 +09:00
Yukihiro "Matz" Matsumoto 3b1c5d7397 mruby-string-ext: remove duplicated definition of String#b
When we use `mruby-encoding` gem as well.
2025-01-16 09:08:14 +09:00
Yukihiro "Matz" Matsumoto 0c01bf7ff0 mruby-string-ext: String#codepoints to support binary encoding 2025-01-16 09:06:19 +09:00
Yukihiro "Matz" Matsumoto 8395ffb5f8 mruby-string-ext: String#ord to support binary encoding 2025-01-16 09:00:44 +09:00
Yukihiro "Matz" Matsumoto 74bdae9e4c mruby-encoding: add Poorman's Encoding gem
The difference from CRuby's Encoding:

- Encoding is a module, instead of a class
- each Encoding (e.g. `Encoding::UTF_8) is a string instead of Encoding object
- only supports  `UTF-8` and `ASCII-8BIT` (and its alias `BINARY`)

Using this gem automatically turn on `MRB_UTF8_STRING` support.
2025-01-16 08:52:41 +09:00
Yukihiro "Matz" Matsumoto e45ea53773 print.c: update the header comment 2025-01-15 14:27:22 +09:00
Yukihiro "Matz" Matsumoto f9c1894087 print.c (printstrln): a new function to print string and newline 2025-01-15 09:19:34 +09:00
Yukihiro "Matz" Matsumoto 25bf1faa81 print.c: fixed link error from mrb_print_m with MRB_NO_STDIO; #6466 2025-01-15 09:12:36 +09:00
Yukihiro "Matz" Matsumoto 6c3143aa12 mrbgem/full-core.gembox: stop excluding mruby-print gem; #6466
Since the gem no longer exists.
2025-01-14 13:30:33 +09:00
Yukihiro "Matz" Matsumoto 89d83c27f3 mruby-print: remove the gem; ref #6466 2025-01-14 13:30:32 +09:00
Yukihiro "Matz" Matsumoto b9b505b5f2 kernel.c: define Kernel#print unless mruby-io is loaded; fix #6466
- In addition, merge mruby-print body in to print.c
2025-01-14 13:30:32 +09:00
Yukihiro "Matz" Matsumoto b623f5c149 mruby-io: define HAVE_MRUBY_IO_GEM if present; ref #6466 2025-01-14 13:24:16 +09:00
Yukihiro "Matz" Matsumoto 272f61a051 AUTHORS: update entries [ci skip] 2025-01-13 12:18:59 +09:00
Yukihiro "Matz" Matsumoto e47b4ca704 mruby-string-ext: new method String#force_encoding
It takes a string instead of Encoding object for simplicity
2025-01-12 23:13:28 +09:00
Yukihiro "Matz" Matsumoto 187f27b00b string.c (char_adjust): align arguments with char_backtrack
Also remove the unused argument.
2025-01-12 23:13:28 +09:00
Yukihiro "Matz" Matsumoto a67c8f9335 string.c: use byte index for a string with binary encoding 2025-01-12 23:13:28 +09:00
Yukihiro "Matz" Matsumoto d5fa9504ad mruby-string-ext (str_b): String#b should copy the receiver 2025-01-12 23:13:28 +09:00
Yukihiro "Matz" Matsumoto 6c530b8f48 mruby-string-ext (str_append_as_bytes): reimplement in C
To handle strings as byte sequences.
2025-01-12 23:13:27 +09:00
Yukihiro "Matz" Matsumoto c18cd60c4b string.h: remove unused flag unset macros 2025-01-12 23:13:27 +09:00
Yukihiro "Matz" Matsumoto 0098654e1f string.h: rename MRB_STR_EMBED_LEN_BITS (use plurality for bit width) 2025-01-12 23:13:26 +09:00
Yukihiro "Matz" Matsumoto 8c184d4566 string.h: move flag definitions for readability 2025-01-12 23:13:26 +09:00
Yukihiro "Matz" Matsumoto e75654a991 string.h (RSTR_SET_TYPE): simplify macro definition 2025-01-12 23:13:26 +09:00
Yukihiro "Matz" Matsumoto 0a5acc0303 string.c (str_unshare_buffer): renamed function for more intuitive name
The old name `str_modify_keep_ascii` does not describe the function
behavior. It was named so since it was separated from the function
`mrb_str_modify_keep_ascii`.
2025-01-12 23:13:25 +09:00
Yukihiro "Matz" Matsumoto 797c49bc0b Merge pull request #6465 from diamant3/add-psp-build 2025-01-12 23:10:06 +09:00
Diamond Rivero 7fa467eb40 Add initial playstation portable crossbuild 2025-01-11 08:28:06 +08:00
Yukihiro "Matz" Matsumoto 8276143f03 object.h: remove MRB_SET_FROZEN_FLAG/MRB_UNSET_FROZEN_FLAG macros
Simple `o->frozen = 1/0` now works.
2025-01-07 13:56:30 +09:00
Yukihiro "Matz" Matsumoto c11d18e426 object.h: unify MRB_FROZEN_P() and mrb_frozen_p() 2025-01-07 11:24:58 +09:00
Yukihiro "Matz" Matsumoto 21003746df object.h: separate frozen flag to the independent bit-field
So that other flag operation do not break frozen flag.
2025-01-07 07:44:10 +09:00
Yukihiro "Matz" Matsumoto a234c66c97 class.c: removed a mistakenly copied function 2025-01-06 22:15:58 +09:00
Yukihiro "Matz" Matsumoto 003e0fb330 mruby-print: disable the gem unless explicitly specified
mruby-print is the duplicate of part of mruby-io. You need it only when
limited I/O functionality required.
2025-01-06 13:57:23 +09:00
Yukihiro "Matz" Matsumoto ef88c3b726 kernel.c: move Kernel#p to kernel.c from mruby-print
It's easier to skip `p` in the debugger if it's implemented in C.
2025-01-06 13:57:23 +09:00
Yukihiro "Matz" Matsumoto 6f8bfed18e object.h: change gccolor type to unsigned int
I was uncomfortable with the combination of an integer with a size
specification (uint32_t) and a bit field.
2025-01-06 13:56:58 +09:00
Yukihiro "Matz" Matsumoto 0e79f6b34b include/object.h: rename color to gccolor
To clarify the color is for garbage collection.
2025-01-03 19:12:40 +09:00
Yukihiro "Matz" Matsumoto 4582cc8579 string.c: rename type setting macro 2025-01-03 09:29:43 +09:00
Yukihiro "Matz" Matsumoto 04ab2be2f0 mruby-string-ext (str_ascii_only_p): simplify the flag update 2025-01-03 08:47:38 +09:00
Yukihiro "Matz" Matsumoto 5a7c944a52 mruby-string-ext (str_b): simplify the flag update 2025-01-03 08:46:04 +09:00
Yukihiro "Matz" Matsumoto 8c2c57c59b Merge pull request #6461 from dearblue/auto-release 2025-01-02 21:58:26 +09:00
Yukihiro "Matz" Matsumoto e35c027966 Merge pull request #6463 from dearblue/dirname 2025-01-02 21:58:01 +09:00
Yukihiro "Matz" Matsumoto 1c50d1885d Merge pull request #6462 from dearblue/mruby-io 2025-01-02 21:55:17 +09:00
Yukihiro "Matz" Matsumoto b0127f0cdd mruby-string-ext (str_b): add a new method String#b
The method makes the receiver binary-mode, but in mruby, which is
virtually no meaning.
2025-01-02 18:45:50 +09:00
dearblue 5c91014530 Add level argument to File.dirname
from Ruby-3.1
https://bugs.ruby-lang.org/issues/12194
2025-01-02 18:10:14 +09:00
dearblue ef11cd94e7 Reimplement the File.dirname method
The purpose is as follows:

  - Stop using `mrb_locale_from_utf8()`.
      - Because there is no corresponding `mrb_utf8_from_locale()`.
      - Because on Windows, for example, if the code page is 932 (CP932, likely ShiftJIS), it cannot be distinguished from the second byte 0x5c (\), and returns wrong results.
  - Stop using `dirname(3)`.
      - Because leading consecutive slashes are not truncated.
        For example, if `/////a/b` is given, CRuby returns `/a`, but mruby so far returns `/////a`.
      - Because the `path` argument cannot be passed in an immutable form.
  - Stop using `_splitpath()` in the Windows implementation.
      - Because there is no support for UNC paths with up to 32767 characters.
        ref. https://learn.microsoft.com/ja-jp/dotnet/standard/io/file-path-formats#unc-paths
      - Because modifying the result of paths terminated by a directory separator.
        Previously, for example, `C:/` would return `C:.` instead of `C:/`, and `a/b/` would return `a/b` instead of `a`.
2025-01-02 17:42:40 +09:00
dearblue 3b659f5320 Properly cast the return value of memchr() 2025-01-02 15:34:36 +09:00
dearblue af1e33c442 To create a release package file in draft
This is to allow final confirmation of the created release file.
Release files in draft form cannot be downloaded by the general public.
2025-01-01 20:24:56 +09:00
Yukihiro "Matz" Matsumoto 85df487e63 mruby-string-ext (append_as_bytes): new method introduced by CRuby 3.4
Since mruby does not have Encoding support, append_as_bytes works
exactly same as String#concat.
2025-01-01 16:05:00 +09:00
Yukihiro "Matz" Matsumoto 9f59d26c35 class.c: adjust space around the operator 2024-12-30 22:45:13 +09:00
Yukihiro "Matz" Matsumoto 59d1fcfa02 include/proc/h: add 2 new constants for the future 2024-12-29 18:04:40 +09:00
Yukihiro "Matz" Matsumoto d7559253de mruby-compiler: need to add proper type cast for C++ 2024-12-28 11:39:22 +09:00
Yukihiro "Matz" Matsumoto 86a40189b4 class.c: remove _P suffix from non predicate 2024-12-28 11:18:46 +09:00
Yukihiro "Matz" Matsumoto 0b5ebf1b79 class.c: avoid using separate values in files 2024-12-27 18:49:35 +09:00
Yukihiro "Matz" Matsumoto cf8e0f3f47 class.c: define MT_KEY_SHIFT (2) for the future 2024-12-27 18:39:46 +09:00
Yukihiro "Matz" Matsumoto 32d11d86ff mruby-compiler (new_lit_str2): move declarations to the point needed 2024-12-26 09:58:01 +09:00
Yukihiro "Matz" Matsumoto 648495a4b3 mruby-compiler (mrb_prev_pc): remove unnecessary local variable 2024-12-25 12:40:33 +09:00
Yukihiro "Matz" Matsumoto 160935dc24 mruby-compiler (mrb_prev_pc): add assertion to ensure pc within iseq 2024-12-25 12:39:57 +09:00
Yukihiro "Matz" Matsumoto dbcb5b5a6d mruby-compiler (merge_pool_str): check whether merged string is in the pool 2024-12-25 12:39:34 +09:00
Yukihiro "Matz" Matsumoto 890a8362b6 mruby-compiler (new_lit_str2): fixed a bug in pool string equality check 2024-12-25 12:39:34 +09:00
Yukihiro "Matz" Matsumoto 6687bddba3 mruby-compiler (gen_addsub): merge 2 literal strings str + str
Unlike previous attempt, this change can merge sequence of plus
operations (e.g. `str + str + str`). Need more tests though.
2024-12-25 12:39:34 +09:00
Yukihiro "Matz" Matsumoto b44372599e mruby-compiler (codegen): combine literal str + str to one string 2024-12-25 12:39:34 +09:00
Yukihiro "Matz" Matsumoto 61f57b22dd Merge pull request #6459 from dearblue/FileTest 2024-12-25 00:04:11 +09:00
dearblue 7c69a37aa6 FileTest is a module
It has been incorrectly defined as a class.
2024-12-23 22:45:47 +09:00
Yukihiro "Matz" Matsumoto 6037e50298 test/hash: update tests to new hash format 2024-12-21 08:53:57 +09:00
Yukihiro "Matz" Matsumoto baeeb5e435 hash.c (mrb_hash_to_s): print :sym => val as sym: val
Ruby 3.4 changed the format of hash string representation. We follow.
2024-12-21 08:52:23 +09:00
Yukihiro "Matz" Matsumoto e31869fd91 mruby-fiber: rename fiber_init_fiber to init_fiber
Resolve confusing function names
2024-12-20 17:56:25 +09:00
Yukihiro "Matz" Matsumoto 583aa985c8 mruby-compiler (gen_call): use OP_SSEND for self.foo() calls 2024-12-20 10:05:09 +09:00
Yukihiro "Matz" Matsumoto aad7dce017 gc.c (mark_context_stack): use SET_NIL_VALUE macro to clear the stack 2024-12-19 16:20:46 +09:00
Yukihiro "Matz" Matsumoto c83bddd856 mruby-bigint (bint_new): avoid memcpy'ing NULL pointer
The second argument of memcpy() is declared to never be NULL. Clang ASAN
report this as an undefined behavior error.
2024-12-18 13:48:11 +09:00
Yukihiro "Matz" Matsumoto 18cc2cea41 mruby-compiler (codegen): loop info may be NULL (retry) 2024-12-17 10:41:23 +09:00
Yukihiro "Matz" Matsumoto a77b9b4bab mruby-compiler (codegen): loop info may be NULL (redo) 2024-12-17 10:41:23 +09:00
Yukihiro "Matz" Matsumoto f67939ff78 Merge pull request #6458 from mruby/dependabot/github_actions/super-linter/super-linter-7.2.1 2024-12-17 10:32:32 +09:00
dependabot[bot] 8099db94ff Bump super-linter/super-linter from 7.2.0 to 7.2.1
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 7.2.0 to 7.2.1.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/CHANGELOG.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v7.2.0...v7.2.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-16 14:23:58 +00:00
Yukihiro "Matz" Matsumoto 2f5c2d6b42 Revert "vm.c (OP_ENTER): clear all registers region in the stack"
This reverts commit 19385a8710.
The issue is covered by 1003a6.
2024-12-16 19:26:56 +09:00
Yukihiro "Matz" Matsumoto d1003a6f9a mruby-fiber (fiber_init_fiber): clear all of fiber stack allocated 2024-12-16 19:23:05 +09:00
Yukihiro "Matz" Matsumoto 19385a8710 vm.c (OP_ENTER): clear all registers region in the stack
To keep GC away from touching uninitialized values
2024-12-15 23:23:07 +09:00
Yukihiro "Matz" Matsumoto d13e6ff8c9 include/presym.h: MRB_GVSYM() for global variables is now available 2024-12-14 16:03:35 +09:00
Yukihiro "Matz" Matsumoto 46019f3871 Merge pull request #6444 from hoshiumiarata/tests_for_bigint 2024-12-13 17:57:16 +09:00
Hoshiumi Arata 03ed952600 Merge branch 'master' into tests_for_bigint 2024-12-13 17:31:54 +09:00
Yukihiro "Matz" Matsumoto b561abd46b Merge pull request #6457 from hoshiumiarata/fix_division_of_smallint_by_bigint 2024-12-13 14:23:52 +09:00
Hoshiumi Arata 6fb93ce6f7 mruby-bigint: fix bug with division of a small number by a bigint; fix #6456 2024-12-13 12:07:34 +09:00
Yukihiro "Matz" Matsumoto 917066647e Merge pull request #6450 from dearblue/io-pread-pwrite 2024-12-13 08:19:55 +09:00
dearblue ce1abfb2c9 Change MRB_WITH_IO_PREAD_PWRITE configuration name
Change to `MRB_USE_IO_PREAD_PWRITE` for consistency with mruby configuration macros.
Similarly, `MRB_WITHOUT_IO_PREAD_PWRITE` is changed to `MRB_NO_IO_PREAD_PWRITE`.

The previous names are available for compatibility but are deprecated.
2024-12-12 22:18:34 +09:00
Yukihiro "Matz" Matsumoto 29a2bc19a3 mruby-bigint (mpz_get_str): use UL suffix for mp_limb table 2024-12-12 17:15:02 +09:00
Hoshiumi Arata 3152402fa6 Merge branch 'master' into tests_for_bigint 2024-12-12 17:01:06 +09:00
Yukihiro "Matz" Matsumoto c495d08c5b mruby-io (mrb_file__gethome): add casts to stop type warnings 2024-12-12 16:13:56 +09:00
Yukihiro "Matz" Matsumoto 423c12e985 Merge pull request #6455 from hoshiumiarata/bigint_fix_div_rounding 2024-12-12 16:13:47 +09:00
Yukihiro "Matz" Matsumoto ceb1885121 Merge pull request #6454 from hoshiumiarata/fix_rhs_bigint_mod_and_divmod 2024-12-12 13:45:48 +09:00
Yukihiro "Matz" Matsumoto d8e6de28e9 mruby-bigint (mrb_bint_add_n): fixed a memory leak 2024-12-11 21:29:22 +09:00
Yukihiro "Matz" Matsumoto 8bd62ca311 mruby-bigint (mrb_bint_xor): fix a bug in bigint ^ int operation
Fix #6453; ref #6444
2024-12-11 21:29:21 +09:00
Yukihiro "Matz" Matsumoto b807c0a27d mruby-bigint (mpz_pow): combine mpz_init and mpz_set 2024-12-11 21:29:21 +09:00
Yukihiro "Matz" Matsumoto 8da0db545e mruby-bigint (mpz_get_str): reduce one division 2024-12-11 21:29:21 +09:00
Hoshiumi Arata 94a3a3eb6e mruby-bigint: fix rounding behavior in mpz_mdiv and mpz_mdivmod functions 2024-12-11 21:09:46 +09:00
Hoshiumi Arata 52e1ebe191 mruby-bigint: handle rhs bigint in int_mod and int_divmod functions 2024-12-11 20:58:03 +09:00
Yukihiro "Matz" Matsumoto 989c133c9f Merge pull request #6449 from dearblue/presym.2 2024-12-11 10:46:27 +09:00
Yukihiro "Matz" Matsumoto a77e917d78 Merge pull request #6448 from dearblue/presym.1 2024-12-11 10:08:22 +09:00
Yukihiro "Matz" Matsumoto 19cb0fc374 Merge pull request #6447 from dearblue/File.expand_path
Fixed `File.expand_path`
2024-12-10 13:54:46 +09:00
Hoshiumi Arata 7dfbbd1eaa Merge branch 'master' into tests_for_bigint 2024-12-09 22:38:32 +09:00
dearblue 27082d143c Using presym in the mruby-io/src/file_test.c file 2024-12-09 22:09:15 +09:00
dearblue 384db9054d Suppress presym in mruby/ext/io.h file
When defining macro constants for error classes in public header files, it is preferable to use `MRB_ERROR_SYM()`.
2024-12-09 22:05:01 +09:00
Yukihiro "Matz" Matsumoto 9af061a4ce mruby-bigint: fixed a bug in string conversion; ref #6444 2024-12-09 13:14:22 +09:00
Yukihiro "Matz" Matsumoto 6d2e7f50e2 mruby-bigint: compact mpz_add_int,mpz_sub_int calling conditions 2024-12-09 13:04:01 +09:00
Yukihiro "Matz" Matsumoto 441d4be0ad mruby-bigint: fixed a bug with bigint +/- mrb_int; close #6445 2024-12-08 23:45:25 +09:00
Yukihiro "Matz" Matsumoto 33841519a9 AUTHORS: update entries [ci skip] 2024-12-08 19:35:41 +09:00
Yukihiro "Matz" Matsumoto 7b0dcaaa34 Merge pull request #6446 from dearblue/win64 2024-12-08 19:35:27 +09:00
dearblue 88e3ce1b58 Fix File.expand_path for Windows
- The inner method `File._gethome` could be read as intending to use the `USERPROFILE` environment variable instead on Windows when the `HOME` environment variable is not available.
    In reality, however, this was not the case.
  - The result of `File.expand_path` should unify path separators with `/`, but it did not.
2024-12-08 10:43:20 +09:00
dearblue 06bb54d380 Improved File.expand_path test in `mruby-io
Since `mruby-io` does not depend on `mruby-env` even for test builds, it is impossible that `ENV` constants are defined.
Therefore, define `MRubyIOTestUtil::ENV_HOME` for alternative use.
2024-12-08 10:43:20 +09:00
dearblue 1326017d1d Omit the _WIN64 definition check
Checking the official MSVC documentation, if `_WIN64` is defined, then `_WIN32` is also defined.
https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros

I could not find any documentation on MinGW, but I assume it is not a problem.
2024-12-07 22:47:28 +09:00
Yukihiro "Matz" Matsumoto 1dfd3d9043 Merge pull request #6442 from dearblue/jmpuw 2024-12-06 23:43:31 +09:00
Yukihiro "Matz" Matsumoto ac6436556b Merge pull request #6440 from dearblue/redo
Fix `redo` keyword
2024-12-06 23:42:44 +09:00
Hoshiumi Arata 9a02daaca0 Merge branch 'master' into tests_for_bigint 2024-12-04 20:58:55 +09:00
Yukihiro "Matz" Matsumoto 16028442e6 Merge pull request #6443 from hoshiumiarata/node_negate_for_bigint 2024-12-04 20:50:22 +09:00
Hoshiumi Arata 21ccbf965e bigint: expand test cases for arithmetic operations 2024-12-04 18:34:21 +09:00
Hoshiumi Arata 3034b0847a codegen: fix NODE_NEGATE for bigints 2024-12-04 17:57:50 +09:00
dearblue 95e2f8e844 Fixed wrong range condition in OP_JMPUW
fixed #6441
2024-12-03 22:14:50 +09:00
Yukihiro "Matz" Matsumoto 4a99f28ec3 Revert "vm.c (cipush): small refactoring"
This reverts commit d6e23f3cdc.
Caused some memory crashes.
2024-12-03 16:48:48 +09:00
Yukihiro "Matz" Matsumoto 94a4b95b5d test/lang.rb: update compiled code in comments
- variable sized instructions
- new instruction names
- remove OP_ prefix as code dump does
2024-12-02 15:23:06 +09:00
Yukihiro "Matz" Matsumoto 77e08c9193 ops.h: rename OP_LOADI to OP_LOADI8
OP_LOADI stores an 8 bit integer to a register, so we renamed the
instruction name to describe the behavior more precisely, like
OP_LOADI16 and OP_LOADI32.
2024-12-01 19:16:54 +09:00
dearblue 9a67bdb6aa Fix redo keyword
Add `OP_NOP` to distinguish `retry` and jump targets while maintaining instruction compatibility.
Ideally, it might be preferable to separate them into `OP_REDO`.

fixed #6439
2024-12-01 11:40:17 +09:00
dearblue 939659e2db Allow redo from nested LOOP_BEGIN and LOOP_RESCUE 2024-12-01 11:34:10 +09:00
dearblue 01ea2c088d Add more tests for redo keyword 2024-12-01 11:33:23 +09:00
Yukihiro "Matz" Matsumoto d6e23f3cdc vm.c (cipush): small refactoring
- simplified if-statement
- rename local variable size to diff (means diff between cibase & ci).
2024-11-30 11:13:38 +09:00
Yukihiro "Matz" Matsumoto e05dbf7bbc mruby-compiler (mrb_irep_remove_lv): remove the function altogether
Recent changes make mrb_irep_remove_lv() used no longer.  Removing this
function would not make any compatibility issue, since it's an internal
function.
2024-11-29 17:09:44 +09:00
Yukihiro "Matz" Matsumoto 28d2dfbb11 mruby-bin-mrbc: use MRB_DUMP_NO_LVAR flag
Instead of `mrb_irep_remove_lv()` function.
2024-11-29 16:45:26 +09:00
Yukihiro "Matz" Matsumoto 3a6272d9e9 mruby-bin-strip: use MRB_DUMP_NO_LVAR flags
Instead of `mrb_irep_remove_lv()` function.
2024-11-29 16:41:27 +09:00
Yukihiro "Matz" Matsumoto 5b69185171 dump.c (mrb_dump_irep): skip lv section if MRB_DUMP_NO_LVAR is set 2024-11-29 16:29:18 +09:00
Yukihiro "Matz" Matsumoto bd5ece3a26 dump.h: remove obsolete flag DUMP_DEBUG_INFO 2024-11-29 07:39:26 +09:00
Yukihiro "Matz" Matsumoto 4751e385c3 dump.h: add new dump flag MRB_DUMP_NO_LVAR 2024-11-29 07:38:47 +09:00
Yukihiro "Matz" Matsumoto 673d71ffca dump.c (mrb_dump_irep): reorganize if-structure 2024-11-28 10:14:06 +09:00
Yukihiro "Matz" Matsumoto 8a25c424a4 dump.c: remove unnecessary braces around return 2024-11-28 04:54:20 +09:00
Yukihiro "Matz" Matsumoto b1091e7c64 dump.c: use post-decrements 2024-11-28 04:54:19 +09:00
Yukihiro "Matz" Matsumoto a5c6cb5afb Merge pull request #6434 from dearblue/doc/hier 2024-11-28 04:53:55 +09:00
dearblue 26f949e612 Added document "The mruby directory structure"
This text was translated from Japanese to English by https://www.deepl.com/ .
2024-11-27 23:04:23 +09:00
Yukihiro "Matz" Matsumoto 3505874f72 Merge pull request #6437 from jbampton/pre-commit-config-add-more-details 2024-11-27 14:40:38 +09:00
Yukihiro "Matz" Matsumoto 85eeeda0b3 Merge pull request #6438 from dearblue/task/install 2024-11-27 14:36:21 +09:00
dearblue c7ca1038d2 Remove unused MRuby::Build#list_install_excludes method
This method was added by commit 0ac755dbc8 (#6407).
It was added during the initial conception, but was ultimately no longer needed.
2024-11-26 22:05:47 +09:00
Yukihiro "Matz" Matsumoto c96f0cd265 mruby-compar-ext (clamp): found a bug by newly added test
Translate CRuby's logic (in C) to Ruby.
2024-11-26 17:40:10 +09:00
Yukihiro "Matz" Matsumoto ec68c6afd8 mruby-compar-ext: add test for Comparable#clamp 2024-11-26 17:40:09 +09:00
Yukihiro "Matz" Matsumoto a6267a4145 Merge pull request #6436 from dearblue/doc/index 2024-11-26 13:35:27 +09:00
John Bampton 7fb6fdd4e2 Add more details to the pre-commit config 2024-11-25 22:49:30 +10:00
dearblue f42a55d9e0 Make rake doc:update-index prettier friendly 2024-11-25 21:32:14 +09:00
Yukihiro "Matz" Matsumoto 3ececd4f1f mruby-catch: fixed typo 2024-11-25 16:51:46 +09:00
Yukihiro "Matz" Matsumoto 1c317cf79e mruby-catch (throw_m): small refactoring 2024-11-25 12:28:50 +09:00
Yukihiro "Matz" Matsumoto 79dda053a5 mruby-numeric-ext: add test for Integer#digits 2024-11-23 23:16:47 +09:00
Yukihiro "Matz" Matsumoto 781359a1d1 Merge pull request #6432 from dearblue/hash 2024-11-22 09:53:10 +09:00
dearblue fd97241cd6 Moving code in macro arguments out of macros
In `src/hash.c`, there are code blocks that are passed as macro arguments.
These code blocks are interpreted as part of the macro function, so breakpoints cannot be set in the debugger.
Also, the gcov command will aggregate them to the caller, and the code in the block will not be counted.

This patch will prevent them from being interpreted as part of a macro, and thus the aforementioned problems will no longer occur.
2024-11-21 22:52:29 +09:00
Yukihiro "Matz" Matsumoto 87bd5c7abc Merge pull request #6409 from jbampton/add-prettier-config 2024-11-21 14:01:41 +09:00
Yukihiro "Matz" Matsumoto 1e41c47ebf Merge pull request #6429 from hoshiumiarata/fix_num_params_as_hash_key 2024-11-21 11:47:00 +09:00
Yukihiro "Matz" Matsumoto 4a54b551e8 hash.c (ht_set): inline ht_set_without_ib_adjustment() 2024-11-21 07:59:11 +09:00
Yukihiro "Matz" Matsumoto 3ad85e6038 Merge pull request #6431 from dearblue/typo 2024-11-21 07:58:55 +09:00
dearblue de494796ac Fixed typo 2024-11-20 21:14:55 +09:00
John Bampton a7c947360e [CI] Add prettier to pre-commit
Add `.prettierignore` and the `.prettierrc` config file. Prettier is currently targeting the `JSON`, `Markdown` and `YAML` files in the mruby repo.

Additional file types can be targetted with prettier via additional community plugins.

https://prettier.io/docs/en/

You can see all the languages that are supported on the homepage:

https://prettier.io/

This PR references a few other issues and PRs

We did have prettier running with pre-commit before that method was removed from prettier.

https://github.com/mruby/mruby/pull/6292

https://github.com/mruby/mruby/issues/6291

https://github.com/mruby/mruby/issues/6138

https://github.com/mruby/mruby/pull/5490

Perhaps we could add more npm software to pre-commit in future using new the `local` repo approach.

https://pre-commit.com/#repository-local-hooks

The best part is that it runs with pre-commit on our local machines on `git commit` and also when running `pre-commit run --all-files` or for example when running `make check`.

There were also some minor fixes / style changes in the pre-commit config to standardize casing.

https://www.npmjs.com/package/prettier?activeTab=readme
2024-11-20 14:51:11 +10:00
Yukihiro "Matz" Matsumoto dc5566e560 mruby-bigint (int_fit_limb_p): fix the logic to check mrb_int size
`int_fit_limb_p()` checks if `mrb_int` fits in `mp_limb`. Previous logic
did not work well with negative integers.
2024-11-20 11:27:54 +09:00
Yukihiro "Matz" Matsumoto 33357d4f35 hash.c (ht_set_without_ib_adjustment): need to skip tombstone; #6421
If a tombstone (a deleted entry slot) is found in searching the entry,
it should be skipped, but we had added the new entry even if the entry
to be replaced might be found in the further search. #6414 and #6421
tried to rehash the table to remove tombstone. But rehashing consumes
memory. So for the time being, we just skip tombstones in the search.
Maybe we will add some heuristics to rehash when the table has too many
tombstones. close #6414
2024-11-20 10:52:39 +09:00
Yukihiro "Matz" Matsumoto 9ea6bda781 Merge pull request #6427 from dearblue/vm-recursive 2024-11-20 07:22:12 +09:00
Yukihiro "Matz" Matsumoto 4953dcd81f Merge pull request #6428 from hoshiumiarata/change_limits_of_addi_and_subi 2024-11-20 06:37:19 +09:00
Hoshiumi Arata 386cd771e7 Fix numbered parameters when used as hash keys 2024-11-20 00:31:44 +09:00
Hoshiumi Arata d5823623ed Change the limits of OP_ADDI and OP_SUBI from 0-127 to 0-255. 2024-11-19 23:36:22 +09:00
Yukihiro "Matz" Matsumoto 9546207047 Merge pull request #6426 from hoshiumiarata/coverage
Add GitHub Actions workflow for coverage reporting
2024-11-19 22:55:37 +09:00
dearblue 0337e0e0f1 Need to update ci variable after re-entry to VM
Some functions called by `mrb_vm_exec()` involve re-entry into the mruby VM.
If the `ci` variable is not updated after re-entry, use-after-free is caused.

This patch makes the following after-call fixes.

| called                  | might call methods
| ----------------------- | ----------------
| `mrb_ary_splat()`       | `#to_a`
| `hash_new_from_regs()`  | `#eql?` `#hash`
| `mrb_hash_delete_key()` | `#eql?` `#hash`
| `mrb_hash_get()`        | `#eql?` `#hash` `#default`
| `mrb_hash_key_p()`      | `#eql?` `#hash`
| `mrb_hash_merge()`      | `#eql?` `#hash`
| `mrb_hash_set()`        | `#eql?` `#hash`
| `mrb_range_new()`       | `#<=>`
2024-11-19 22:47:04 +09:00
Hoshiumi Arata 0947dd64d0 Update coverage workflow to use Clang 18 for compilation 2024-11-19 18:24:40 +09:00
Hoshiumi Arata abca6549d8 Update coverage workflow to use Clang for compilation 2024-11-19 18:12:57 +09:00
Hoshiumi Arata 593cda570f Update retention days for coverage report in GitHub Actions workflow 2024-11-19 18:11:08 +09:00
Yukihiro "Matz" Matsumoto dbb1d2342f Merge pull request #6425 from mruby/dependabot/github_actions/super-linter/super-linter-7.2.0 2024-11-19 06:41:07 +09:00
Hoshiumi Arata 1fbcd4a39b Fix lint errors 2024-11-19 00:06:37 +09:00
Hoshiumi Arata f7b2ec1408 Fix formatting of coverage report in GitHub Actions workflow 2024-11-19 00:00:49 +09:00
Hoshiumi Arata 7cf5e9b0af Refactor coverage report generation in GitHub Actions workflow 2024-11-18 23:56:55 +09:00
dependabot[bot] cc76dda8a5 Bump super-linter/super-linter from 7.1.0 to 7.2.0
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 7.1.0 to 7.2.0.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/CHANGELOG.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v7.1.0...v7.2.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-18 14:45:49 +00:00
Hoshiumi Arata fbcc6cf255 Update coverage workflow to trigger on pull requests 2024-11-18 23:29:17 +09:00
Hoshiumi Arata 6028be193c Add GitHub Actions workflow for coverage reporting 2024-11-18 23:19:28 +09:00
Yukihiro "Matz" Matsumoto b437b1da24 Merge pull request #6424 from MaxFork/max-add-check_command 2024-11-18 23:15:40 +09:00
Max Base f6106f62c7 Update Makefile - Add check_command 2024-11-17 14:43:21 +03:30
Yukihiro "Matz" Matsumoto f27bc6ab32 Merge pull request #6423 from dearblue/task/test 2024-11-17 07:52:50 +09:00
Yukihiro "Matz" Matsumoto 6663f1072c Merge pull request #6422 from dearblue/hash 2024-11-17 00:05:20 +09:00
dearblue cf91cbf090 Adding a serialized test task
Under normal circumstances, `rake -m test` will parallelize not only the build task, but also the test task.
With this patch, `rake -m test:run:serial` will parallelize the build tasks, but the test tasks will be done one by one in sequence.

The name of the task to be added is as follows:

| tasks to be added     | corresponding exist tasks
| --------------------- | ----------------
| `test:run:serial`     | `test:run`
| `test:run:serial:bin` | `test:run:bin`
| `test:run:serial:lib` | `test:run:lib`
2024-11-16 21:21:51 +09:00
dearblue 9501c3f58c Add annotations for function names defined in the preprocessor 2024-11-16 20:50:49 +09:00
Yukihiro "Matz" Matsumoto 013bcb9221 Merge pull request #6420 from jbampton/patch-2 2024-11-16 04:52:15 +09:00
Yukihiro "Matz" Matsumoto 628f057482 Merge pull request #6419 from hoshiumiarata/fix_numparams_in_lambda 2024-11-15 16:17:03 +09:00
Yukihiro "Matz" Matsumoto e0d9bce8b6 Merge pull request #6415 from hoshiumiarata/fix_numbered_parameters_in_singleton 2024-11-15 16:10:34 +09:00
Yukihiro "Matz" Matsumoto a00267c802 Merge pull request #6417 from hoshiumiarata/fix_email_lint 2024-11-15 16:03:41 +09:00
Yukihiro "Matz" Matsumoto a247f48cf6 Merge pull request #6416 from hoshiumiarata/optimize_class_new_iseq 2024-11-15 15:42:57 +09:00
Yukihiro "Matz" Matsumoto ab3bc12fcb class.c: remove 'class' prefix from error messages 2024-11-15 15:33:14 +09:00
Yukihiro "Matz" Matsumoto a109599d53 vm.c (prepare_missing): add receiver's class in superclass calls 2024-11-15 15:15:08 +09:00
Yukihiro "Matz" Matsumoto 65e0e5bbd3 class.c (mrb_method_missing): add receiver's class to clarify
We needed to modify a lot of test code that expected the old style.
2024-11-15 15:13:24 +09:00
John Bampton d506ed08da Update .github/labeler.yml 2024-11-13 23:46:22 +10:00
John Bampton 33ba77fb00 Update labeler.yml: add label for the tools directory 2024-11-13 23:39:51 +10:00
Hoshiumi Arata 9fe2a5c46a parser: setup numbered parameters in new_lambda and adjust dump_prefix offset 2024-11-13 22:19:27 +09:00
Hoshiumi Arata 3be0e6b24f Update mlc_config.json to ignore mailto links in linting 2024-11-13 20:45:28 +09:00
Hoshiumi Arata 0b1d55a088 class.c: replace OP_SEND with OP_SSEND in "new" method's iseq 2024-11-13 18:34:16 +09:00
Hoshiumi Arata cc2ec53807 parser: support numbered parameters when used as a singleton 2024-11-13 00:22:49 +09:00
Yukihiro "Matz" Matsumoto 13acf12df5 test/t/vformat.rb: fix encoding error; should have been UTF-8 2024-11-11 23:52:58 +09:00
Yukihiro "Matz" Matsumoto 5387b74be7 hash.c (mrb_hash_to_s): put spaces around =>
CRuby 3.4 puts spaces around `=>` since for example `{:a!=>2}` can be
confusing where to separate tokens.  mruby should follow the behavior.

Many tests in `test/t` directory assumed no spaces around `=>`, so we
needed to fix them too.
2024-11-11 11:07:43 +09:00
Yukihiro "Matz" Matsumoto d2eb2bcacc Update AUTHORS [ci skip] 2024-11-11 11:07:42 +09:00
Yukihiro "Matz" Matsumoto 1d88398d94 Merge pull request #6413 from dearblue/doc/index 2024-11-11 09:45:14 +09:00
Yukihiro "Matz" Matsumoto d4cb111d14 Merge pull request #6412 from dearblue/OP_RETURN_BLK
Distinguish the call frame of the generator with `OP_RETURN_BLK`
2024-11-10 23:10:27 +09:00
dearblue 6291b55bba Add links to documentation in README.md
The documentation table is generated by the `rake doc:update-index` command.
The following conditions must be met for links to be added to the documentation table.

  - The file must be placed under the `doc/` directory
  - The file must have the extension `.md`
  - The file must be written at the top of the file with `<! -- summary: ANY-TEXT -->`
2024-11-10 22:39:14 +09:00
dearblue c654123561 Distinguish the call frame of the generator with OP_RETURN_BLK
When multiple identical proc objects are placed on the call stack, it is not possible to distinguish where to `return`.
Therefore, use env object comparisons to do this.

fixed #6411
2024-11-10 18:39:00 +09:00
Yukihiro "Matz" Matsumoto 90764b10fd Merge pull request #6410 from dearblue/msvc 2024-11-07 14:12:18 +09:00
dearblue ff9c03fde4 Put #include <stdlib.h> in parse.y
ref. #6388
2024-11-06 22:29:29 +09:00
Yukihiro "Matz" Matsumoto fcab6d2769 Merge pull request #6408 from dearblue/c++ 2024-11-06 13:31:42 +09:00
dearblue a92b97ff45 Improve compliance with C++ standards
- Avoid "Designated initializer"
    C++20 is required for C++.
  - Avoid "Compound literals"
    Not available for C++.
2024-11-05 22:07:53 +09:00
Yukihiro "Matz" Matsumoto ee7919e658 Merge pull request #6407 from dearblue/install/libmruby_core 2024-11-05 13:10:44 +09:00
Yukihiro "Matz" Matsumoto 521766009b Merge pull request #6405 from ArtSin/io_read-fix-mrb_raisef-arg 2024-11-05 13:08:42 +09:00
Yukihiro "Matz" Matsumoto fed631c21b mruby-bigint (mrb_bint_sub_n): avoid allocating mpz_z 2024-11-05 13:03:54 +09:00
Yukihiro "Matz" Matsumoto 6085ffb968 mruby-bigint (mrb_bint_add_n): avoid allocating mpz_z 2024-11-05 12:22:10 +09:00
Yukihiro "Matz" Matsumoto ef18bd86a6 mruby-bigint (mpz_sub_int): avoid allocating mpz_t for mrb_int 2024-11-05 11:52:22 +09:00
Yukihiro "Matz" Matsumoto fe12e840f3 mruby-bigint (mpz_add_int): move the function definition
To prepare `mpz_sub_int` update.
2024-11-05 11:52:22 +09:00
dearblue 0ac755dbc8 Allow to exclude specific files in rake install
Introduce the `MRuby::Build#install_excludes` attribute.
This attribute is an array to which you add strings, regular expressions, and proc objects that will serve as filters to exclude.

This feature was inspired by @hoshiumiarata's comment.
https://github.com/mruby/mruby/issues/6352#issuecomment-2426721517
2024-11-04 20:44:13 +09:00
ArtSin 0afc7ae13b io_read: use %i instead of %d in call to mrb_raisef
`length` is `mrb_int`, not `int`.
2024-11-04 13:56:46 +04:00
Yukihiro "Matz" Matsumoto 48455756d2 Merge pull request #6399 from jbampton/patch-2 2024-11-03 07:21:26 +09:00
John Bampton 903baddb03 Add macOS 15 to the build
macOS 15 (Sequoia) is now available as a public beta in GitHub Actions

https://github.com/actions/runner-images/issues/10686

https://github.com/actions/runner-images/blob/main/images/macos/macos-15-Readme.md
2024-11-02 12:50:17 +10:00
Yukihiro "Matz" Matsumoto 16ae9e6ed9 Merge pull request #6397 from wataash/boxno-set-value 2024-11-01 11:11:39 +09:00
Wataru Ashihara b1d299f88b boxing_no.h: rename BOXNIX_SET_VALUE -> BOXNO_SET_VALUE
boxing_nix.h was renamed to boxing_no.h on
https://github.com/mruby/mruby/commit/df4c298e3b280b11add8502f1602cefc246655dd
2024-10-31 16:01:05 +09:00
Yukihiro "Matz" Matsumoto 3885e14049 mruby-rational: explicitly add return for error cases too 2024-10-31 14:06:10 +09:00
Yukihiro "Matz" Matsumoto 19d3620965 mruby-bigint (mrb_bint_powm): stop a warning for no return 2024-10-31 14:06:10 +09:00
Yukihiro "Matz" Matsumoto 49525fa207 mempool.c: renamed from pool.c
To avoid confusion with pools in irep, we renamed region-based memory
manager from pool to mempool.

- rename pool.c to mempool.c
- separate mempool.h
- rename all mrb_pool to mrb_mempool

So if someone is using pool.c functions (I suppose no one does though),
they need to rename all `mrb_pool` to `mrb_mempool` and include
`mruby/mempool.h` header at the top.
2024-10-31 14:06:10 +09:00
Yukihiro "Matz" Matsumoto 62ef5db13e irep.h: rename mrb_pool_value to mrb_irep_pool
mrb_pool_value is a structure that represents a value in the irep
literal pool and is unrelated to mrb_pool, which performs region-based
memory management. It has been renamed mrb_irep_pool to avoid confusion.
2024-10-29 20:34:53 +09:00
Yukihiro "Matz" Matsumoto 2436b32f1f irep.h: reformat comments 2024-10-29 20:34:52 +09:00
Yukihiro "Matz" Matsumoto 6ad6b6c6c1 Merge pull request #6396 from vickash/milkvduo 2024-10-28 10:42:51 +09:00
vickash 8fbc809614 milkvduo: update GPIO gem url 2024-10-27 17:37:33 -04:00
Yukihiro "Matz" Matsumoto cda7b56d65 Merge pull request #6395 from dearblue/to_proc 2024-10-27 21:14:48 +09:00
dearblue a7a81aa761 Storing method-id inside Symbol#to_proc
When called in combination with a method like `*_eval` or `*_exec` that switches self, `__send__` was passed an object that was not necessarily a symbol as the method name.

This problem was discovered during the #6389 correction process.
2024-10-27 10:41:51 +09:00
Yukihiro "Matz" Matsumoto 38487f2100 Merge pull request #6393 from dearblue/mrb_object_exec 2024-10-26 07:51:55 +09:00
dearblue 94290b9bb8 Follow-up to #6391
The #6392 has been merged, so the call to `mrb_yield_with_class()` is no longer needed.
2024-10-25 21:11:07 +09:00
Yukihiro "Matz" Matsumoto ba69f36d6d Merge pull request #6392 from dearblue/mrb_exec_irep 2024-10-25 07:12:05 +09:00
Yukihiro "Matz" Matsumoto 49b9db24b2 Merge pull request #6391 from dearblue/instance_exec 2024-10-25 07:09:44 +09:00
dearblue 8d64788cbf Fix argument forwarding in mrb_exec_irep()
C to Ruby calls using `mrb_exec_irep()` were not forwarding arguments.

There was also a problem in setting the target class and method ID, which is also fixed.

This issue was discovered during the work to fix #6389.
2024-10-24 22:33:18 +09:00
dearblue a196d8a5f3 Fixed also argument forwarding in class_exec
Pointed out by @matz.
https://github.com/mruby/mruby/pull/6391#issuecomment-2433662139
2024-10-24 22:05:59 +09:00
dearblue f9151e0bd9 Fixed argument forwarding in instance_exec
However, on C, there is no easy way to pass keyword arguments.
Therefore, when called `Kernel#instance_exec` on C, keyword arguments are converted to positional arguments.
This is a limitation of current mruby.

fixed #6389
2024-10-24 21:20:46 +09:00
Yukihiro "Matz" Matsumoto f245943aed mruby-bigint (mrb_bint_powm): fixed bugs in type casting 2024-10-24 07:21:12 +09:00
Yukihiro "Matz" Matsumoto 0b96f7f2f7 mruby-bigint (mrb_bint_to_s): add uzero_p() check 2024-10-24 07:20:24 +09:00
Yukihiro "Matz" Matsumoto c5565a37ac mruby-bigint: add checks for divided by zero by sizes and contents 2024-10-24 07:18:34 +09:00
Yukihiro "Matz" Matsumoto 5e9593e285 mruby-bigint (udiv): add assertion for divided by zero 2024-10-24 07:16:32 +09:00
Yukihiro "Matz" Matsumoto 3d3aa92649 Merge pull request #6390 from dearblue/mrb_gc_free_gv 2024-10-23 10:03:16 +09:00
dearblue be9431a9ef Fix use-after-free by mrb_gc_unregistor()
Calling `mrb_gc_unregistor()` from `mrb_data_type::dfree` caused a use-after-free deep inside `mrb_close()`.
The impetus to investigate was <https://github.com/mruby/mruby/pull/6342#pullrequestreview-2292747530>.

Currently, when `mrb_close()` is called, all objects are destroyed first.
The process is done heap page by heap page, and when all objects belonging to a heap page are destroyed, the heap page is released.
If the next heap page contains `RData` objects, the `mrb_gc_unregistor()` function may be called from the `mrb_data_type::dfree` function.
At this time, the `mrb_gc_unregistor()` function gets an array object from a Ruby global variable.
If the array object belongs to a freed heap page, use-after-free is established by referencing this array object.

About the fixes.

First of all, there is the fact that the `mrb_gv_get()` function returns `nil` if `mrb->globals` is `NULL`.
Therefore, before destroying all objects, free `mrb->globals` and set `mrb->globals` to `NULL` at the same time.
Now the `mrb_gv_get()` function will return `nil` to the calling `mrb_gc_unregistor()` function and `mrb_gc_unregistor()` will do nothing more.

ref. https://github.com/mruby/mruby/issues/4618
2024-10-22 22:57:49 +09:00
Yukihiro "Matz" Matsumoto b95ca53e5c mruby-compiler: revert ce2fdb7; close #6388
The commit was to stop warnings from Visual C but unexpectedly caused
compilation errors on some configuration.
2024-10-22 14:46:12 +09:00
Yukihiro "Matz" Matsumoto 51fd065722 mruby-compiler (parser_yylex): skip sign if bigint starts with +
To reserve memory (1 byte) and avoid error (fixed by 11cff8f).
2024-10-22 14:45:48 +09:00
Yukihiro "Matz" Matsumoto 11cff8fa7d mruby-bigint (mpz_init_set_str): should skip + in the string
When the string starts with `+` it should not cause error silently. It
might cause serious error afterwards.
2024-10-22 14:44:51 +09:00
Yukihiro "Matz" Matsumoto f2908031c4 Merge pull request #6387 from dearblue/gc-unregister.1 2024-10-21 10:56:49 +09:00
Yukihiro "Matz" Matsumoto f6fbfdfcf0 Merge pull request #6386 from dearblue/gc-unregister 2024-10-21 10:55:38 +09:00
Yukihiro "Matz" Matsumoto df0fc6f3a8 Merge pull request #6385 from dearblue/gc-register.1 2024-10-21 10:49:37 +09:00
Yukihiro "Matz" Matsumoto c317659b8f Merge pull request #6382 from dearblue/gc-register 2024-10-21 10:48:46 +09:00
Yukihiro "Matz" Matsumoto 1f5ba7e01d vm.c (OP_STRCAT): mrb_str_concat may call VM recursively
And recursive calls may reallocate call-info stack.
2024-10-20 19:46:23 +09:00
Yukihiro "Matz" Matsumoto d8e6987e4c Merge pull request #6358 from jbampton/add-latest-ubuntu-to-build 2024-10-19 02:17:59 -04:00
Yukihiro "Matz" Matsumoto 56fc329633 Merge pull request #6383 from jbampton/remove-macos-12 2024-10-19 00:28:25 -04:00
Yukihiro "Matz" Matsumoto f3257c448b mruby-bigint (mrb_bint_powm): should call mpz_clear() on exceptions 2024-10-19 13:09:03 +09:00
Yukihiro "Matz" Matsumoto e4d2f343fe mruby-bigint (mrb_bint_neg): move the function to group bit operations 2024-10-19 12:47:06 +09:00
Yukihiro "Matz" Matsumoto ee13b9e67b mruby-bigint: fix mrb_int optimization bugs for and, or, xor
If the operand is a small integer, those functions tried to reduce
bigint allocations, but we had some bugs in them. We removed those
imperfect optimization altogether.
2024-10-19 12:45:04 +09:00
dearblue 2ec2437d23 Small improvements for mrb_gc_unregister()
`ARY_PTR()` and `ARY_LEN()` avoid using them in a loop if the array is not changed, since they involve branching.
2024-10-19 11:10:10 +09:00
dearblue 1dcc2cac03 Avoid calling mrb_gv_set() from mrb_gc_unregister()
Should simply be ignored for the possibility of being called from `RData::dfree`.
2024-10-19 11:08:32 +09:00
dearblue b28d53bda9 Small improvements for mrb_gc_register()
The `mrb_nil_p()` used in conditional expressions is semantically included in `!mrb_array_p()`.
2024-10-19 10:59:21 +09:00
Yukihiro "Matz" Matsumoto 2430eaba13 mruby-bigint (mrb_bint_powm): fixed memory leak 2024-10-19 07:32:06 +09:00
Yukihiro "Matz" Matsumoto 001d5fcc3f mruby-bigint (mpz_get_str): get b2 by table lookup
The `b2` is the power of `base` no bigger than DIG_BASE.
2024-10-19 07:32:05 +09:00
Yukihiro "Matz" Matsumoto 4aa87acfc9 mruby-bigint (mpz_set_uint64): adjust reallocation size for uint64
The uint64_t value may fit in `mp_limb*n` where n is 1..4.
2024-10-19 07:32:05 +09:00
John Bampton 86e969a406 Remove macOS 12 from the build
The macOS 12 runner image will be removed by December 3rd, 2024.
2024-10-19 00:18:19 +10:00
dearblue 13512aba91 Make array objects invisible in mrb_gc_register()
Once the class is set, objects can be referenced and manipulated from the Ruby side by using `ObjectSpace.each_object`.
Also, currently `mrb_gc_unregister()` assumes that the element is a non-immediate object.
However, `mrb_gc_unregister()` does not read or write to the address, so there was no problem.
2024-10-18 22:29:23 +09:00
Yukihiro "Matz" Matsumoto c3be2568ea Merge pull request #6005 from jbampton/build-and-test-on-macos-13 2024-10-17 23:28:03 -04:00
Yukihiro "Matz" Matsumoto 5e6d382782 mruby-bigint (mpz_set_uint64): fixed a bug in for loop
Found double increments in a loop. Since no one called mpz_set_int64()
in the real code, we could not find this bug for long time.
2024-10-18 12:27:02 +09:00
Yukihiro "Matz" Matsumoto fe42f1d047 mruby-bigint (mpz_set_int): simplify using early return 2024-10-18 12:27:02 +09:00
Yukihiro "Matz" Matsumoto a5c0b2114a mruby-bigint (mrb_bint_2comp): need to initialize mpz_t 2024-10-18 12:27:02 +09:00
Yukihiro "Matz" Matsumoto c8a73515e9 Merge pull request #6381 from 513ry/iss6380 2024-10-17 22:00:56 -04:00
siery 1a426e245f part 2: Fix indentation to include break after function return type 2024-10-17 22:26:20 +02:00
siery 7d694df717 Fix indentation to include break after function return type 2024-10-17 21:11:11 +02:00
John Bampton d387e89ae2 Build and test on macOS 13
https://github.com/actions/runner-images#available-images
2024-10-17 22:33:59 +10:00
Yukihiro "Matz" Matsumoto 63f3ff4ac5 Merge pull request #6379 from jbampton/add-pre-commit-hook-gitleaks 2024-10-17 02:40:28 -04:00
Yukihiro "Matz" Matsumoto b4ab4cd7cf Merge branch 'master' into add-pre-commit-hook-gitleaks 2024-10-17 02:33:23 -04:00
Yukihiro "Matz" Matsumoto f1863163a8 mruby-bigint (uzero_p): avoid signed and unsigned comparison in loop 2024-10-16 16:33:43 +09:00
Yukihiro "Matz" Matsumoto 84d17f2c44 array.c (mrb_ary_clear): remove unnecessary function 2024-10-16 16:33:42 +09:00
Yukihiro "Matz" Matsumoto 389740e1d2 Merge pull request #6377 from jbampton/add-pre-commit-hook-oxipng 2024-10-16 03:34:12 -04:00
Yukihiro "Matz" Matsumoto 62c8951787 Merge pull request #6378 from jbampton/add-pre-commit-hook-format-json 2024-10-16 03:25:58 -04:00
John Bampton 42d3eb4b60 Add pre-commit hook gitleaks to detect and prevent hardcoded secrets
https://github.com/gitleaks/gitleaks

Adding another check/test to our pre-commit framework.

gitleaks is a popular tool that helps with security.

Removes the gitleaks check from the Super-Linter.

So now we can run gitleaks with pre-commit on `git commit`
2024-10-16 04:20:49 +10:00
John Bampton e0a9a06c77 Add pre-commit hook pretty-format-json
https://github.com/pre-commit/pre-commit-hooks?tab=readme-ov-file#pretty-format-json

From the official pre-commit team a minor feature to add.

We have one JSON file at `.github/linters/mlc_config.json`.
2024-10-16 03:56:19 +10:00
John Bampton 83040c50e7 Add pre-commit hook oxipng for lossless PNG compression
Oxipng is a multithreaded lossless PNG/APNG compression optimizer.

Lossless compression is a class of data compression that allows the original data to be perfectly reconstructed from the compressed data with no loss of information.

https://en.wikipedia.org/wiki/Lossless_compression

https://github.com/shssoichiro/oxipng?tab=readme-ov-file#git-integration-via-pre-commit

Oxipng is a multithreaded PNG optimizer written in Rust

https://pre-commit.com/index.html#rust

"pre-commit will bootstrap rust if it is not present."
2024-10-16 03:10:16 +10:00
Yukihiro "Matz" Matsumoto bbce194609 Merge pull request #6374 from jbampton/add-hooks-upgrade-pre-commit 2024-10-15 08:43:54 -04:00
Yukihiro "Matz" Matsumoto 7b5608e78a mruby-rational: refactor float to rational conversion
- the function `float_decode_internal` was removed
- simplified `rational_new_f()`
- do not need to call `ldexp`
- allocate less bigint objects
2024-10-15 21:10:11 +09:00
Yukihiro "Matz" Matsumoto 51b11a6919 mruby-rational: add comments
We used `mrb_bint_mul(mrb, n, ONE)` to normalize `n`. The code confused
ChatGPT that could not read the intention.
2024-10-15 21:10:10 +09:00
Yukihiro "Matz" Matsumoto 8cfc1a4581 variable.c: fix int and mrb_bool confusion 2024-10-15 21:10:10 +09:00
Yukihiro "Matz" Matsumoto 540bd54ed3 variable.c (iv_rehash): name magic number 4 as IV_INITIAL_SIZE 2024-10-15 21:10:10 +09:00
Yukihiro "Matz" Matsumoto 06f45f8635 mruby-compiler (codegen): detect too-deep nesting error; fix #6270 2024-10-15 21:10:10 +09:00
Yukihiro "Matz" Matsumoto fa68e634a7 variable.c (mrb_exc_const_get): E_XXX_ERROR should not call const_missing
As #6359 pointed out, calling const_missing hook from E_XXX_ERROR (that
calls mrb_exc_get_id()) can be an attack vector.  Since E_XXX_ERROR is
supposed to be a defined error class, we think that the situation where
it is undefined and the const_missing hook is called should be detected
as an error; fix #6359
2024-10-15 21:09:48 +09:00
Yukihiro "Matz" Matsumoto b5801cd730 mruby-bigint (mrb_bint_new_int64): fixed a bug on the 32bit platforms 2024-10-11 14:19:33 +09:00
Yukihiro "Matz" Matsumoto 2d565d30cb Merge pull request #6376 from 513ry/master 2024-10-11 01:18:02 -04:00
siery c8203b2d52 Fix typo 2024-10-11 05:08:46 +02:00
Yukihiro "Matz" Matsumoto e29f3d64b2 mruby-compiler: stop malloc/free warnings from Visual Studio build 2024-10-11 09:10:44 +09:00
Yukihiro "Matz" Matsumoto 32a527ad6d readfloat.c: fix float to int assignment 2024-10-11 08:45:27 +09:00
Yukihiro "Matz" Matsumoto 763c9cba03 mruby-rational (int_lshift): add cast to stop overflow warning 2024-10-11 08:44:12 +09:00
Yukihiro "Matz" Matsumoto f4fdf25bb0 mruby-bigint (mrb_bint_new_int64): wrong return value 2024-10-11 08:41:51 +09:00
Yukihiro "Matz" Matsumoto 39a5d2a9d8 Merge pull request #6375 from jbampton/fix-grammar 2024-10-10 19:36:49 -04:00
John Bampton 6f97cf10e9 docs: fix grammar 2024-10-11 04:07:58 +10:00
John Bampton 95f58d8a98 Upgrade pre-commit min version; add hook; pre-commit autoupdate
https://github.com/pre-commit/pre-commit-hooks/releases/tag/v5.0.0

pre-commit-hooks now requires pre-commit>=3.2.0

https://github.com/pre-commit/pre-commit-hooks?tab=readme-ov-file#check-illegal-windows-names

https://pre-commit.com/#pre-commit-autoupdate

refs pre-commit/pre-commit#2808

https://pre-commit.com/#top_level-default_stages
2024-10-11 03:32:16 +10:00
Yukihiro "Matz" Matsumoto 6d4de2496c mruby-bigint: remove unused macros; ref #6371 2024-10-10 23:14:27 +09:00
Yukihiro "Matz" Matsumoto e21055604c mruby-bigint: separate mpz and bint functions; ref #6371
The pull-request #6371 was tight integration of mpz and bint functions.
The mpz functions take `struct RBigint*` instead of `mpz_t*`. It
decrease maintainability, in my opinion. This commit initializes `mpz_t`
from `struct RBigint*` in bint functions, so that we can keep separation
of function roles.
2024-10-10 23:04:04 +09:00
Yukihiro "Matz" Matsumoto c6dbaf702e Merge branch 'bigint-embed'; #6371 2024-10-10 23:02:10 +09:00
Yukihiro "Matz" Matsumoto 12b97ceb78 fixup! Merge branch 'bigint-embed' of https://github.com/dearblue/mruby into bigint-embed 2024-10-10 22:57:32 +09:00
Yukihiro "Matz" Matsumoto bda2fa39d2 Merge branch 'bigint-embed' of https://github.com/dearblue/mruby into bigint-embed 2024-10-10 22:31:55 +09:00
Yukihiro "Matz" Matsumoto 453e9eabf0 mruby-rational (rat_add_b): might have called rational_new_b with int
`rational_new_b` should be called with bigint objects.
2024-10-10 07:55:51 +09:00
Yukihiro "Matz" Matsumoto 5a40f6710b Update AUTHORS [ci skip] 2024-10-09 22:56:45 +09:00
Yukihiro "Matz" Matsumoto b56ad8fdee mruby-bigint: improve mpz_mul_int() and mpz_add_int()
Both functions are only called from mpz_init_set_str(). We can assume

- mpz_t is modifiable
- mpz_t is positive
- n is positive and small (n <= 36)

Those new definitions consume less memory and are slightly faster.
2024-10-08 16:09:46 +09:00
Yukihiro "Matz" Matsumoto 3b06ad4737 mruby-bigint (mpz_mul): cancel Karatsuba algorithm
We tried many times to implement the Karatsuba method to improve the
performance of multiplication of large multi-precision integers. But it
did not speed up in all cases due to the cost of memory allocation.  We
decided to go back to the basic multiplication method.

If anyone wants to take on the challenge of improving the performance of
multiplication, we welcome it.
2024-10-08 16:02:19 +09:00
John Bampton f13a4bfe65 gha: add Ubuntu 24.04 to the build
Remove Ubuntu 20.04
2024-10-08 16:23:49 +10:00
Yukihiro "Matz" Matsumoto 7e6f8685a3 Merge pull request #6373 from vickash/milkvduo 2024-10-06 20:30:10 -04:00
Yukihiro "Matz" Matsumoto 77fb1b1b65 mruby-bigint (mul_karatsuba): use byte-wise addition to combine 2024-10-07 07:28:24 +09:00
vickash e99f605458 milkv config: Add directive for board variant, and optional wiringX mrbgem 2024-10-06 12:27:12 -04:00
dearblue 6366f1cbb9 Update mrbgems/mruby-bigint/core/bigint.h
Co-authored-by: John Bampton <jbampton@users.noreply.github.com>
2024-10-06 23:03:03 +09:00
vickash 115a739059 milkv config: forgot to remove "-L" in linker paths taken from official Makefile 2024-10-06 09:54:41 -04:00
dearblue 009a79b5c9 Embedding in RBigint objects
Integers up to 3 words long will no longer allocate heap space.
2024-10-06 22:28:22 +09:00
vickash d2878ef47f Comment out test-inline-struct in milv_duo config 2024-10-06 08:33:21 -04:00
vickash 491b7685db Add build config for Milk-V Duo (RISC-V Linux) board 2024-10-06 00:26:07 -04:00
Yukihiro "Matz" Matsumoto 40c7febca8 mruby-bigint (uadd): remove redundant trim() 2024-10-05 15:08:16 +09:00
Yukihiro "Matz" Matsumoto be9da7199b mruby-bigint (mul_karatsuba) improve performance
Unnecessary mpz_t u0u1 and v0v1 are removed.
2024-10-05 10:57:42 +09:00
Yukihiro "Matz" Matsumoto 8faf78f1b8 mruby-method: singleton_method() should search in superclasses
[ruby-bugs:20620](https://bugs.ruby-lang.org/issues/20620)
2024-10-04 21:37:49 +09:00
Yukihiro "Matz" Matsumoto 32aed6ad8c mruby-bigint: increase KARATSUBA_THREASHOLD to 512
Since Karatsuba algorithm is far heavier than the basic multiplication,
we have increased KARATSUBA_THREASHOLD and decreased MAX_RECURSION_DEPTH.
2024-10-04 18:10:14 +09:00
Yukihiro "Matz" Matsumoto 6820da1526 mruby-bigint (mpz_abs): use zero_p() 2024-10-04 18:10:14 +09:00
Yukihiro "Matz" Matsumoto fd8d3a8d70 mruby-bigint: use zero() to make mpz_t zero. 2024-10-04 18:10:14 +09:00
Yukihiro "Matz" Matsumoto 6274f8de43 mruby-bigint (mpz_sub): avoid data copy
Since mpz_sub() calls mpz_add() with opposite sign, refer same data from
the original, instead of copying whole data.
2024-10-04 18:10:14 +09:00
Yukihiro "Matz" Matsumoto 363754b5d1 mruby-bigint (uzero_p): check from the top, not bottom
For most of the case, the first non-zero value would be found earlier
when search starts from the top.
2024-10-04 18:10:14 +09:00
Yukihiro "Matz" Matsumoto fcc1832efc mruby-bigint (mul_karatsuba): avoid copying operand u and v 2024-09-30 18:32:26 +09:00
Yukihiro "Matz" Matsumoto 0023cbdb3d mruby-bigint (mpz_mul): use Karatsuba algorithm to improve performance 2024-09-28 05:26:40 +09:00
Yukihiro "Matz" Matsumoto 1348daa683 vm.c: save offset in a local variable in OP_BLKPUSH 2024-09-27 16:31:13 +09:00
Yukihiro "Matz" Matsumoto b94be7de5a gc.c (mark_context): no need to mark ci->blk; ref #5791
Since the passed block is referenced from the stack after the last
commit.
2024-09-26 02:57:57 +09:00
Yukihiro "Matz" Matsumoto 9c5812a463 mruby-compier: keep stack reference to passed block after modifying &b
To mark `MRB_PROC_ORPHAN` we need to keep track of passed block, even
after the assignment to the block argument. And `yield` should use the
original block; #5786, #5791, #6369
2024-09-26 02:48:16 +09:00
Yukihiro "Matz" Matsumoto d6fa7772a0 mruby.h (mrb_method_t): avoid unnamed union
It caused errors in the pedantic-mode of GCC.
2024-09-26 00:07:03 +09:00
Yukihiro "Matz" Matsumoto 204928120b vm.c (cipop): fix improper code to check if env is reclaimed; fix #6369
The callinfo refers blk since #5786 but not marked at the time. Later we
added reclamation check by #5791 but its repeated heap scans decrease
the performance drastically in some cases. So the original @dearblue's
solution should be taken

Probably we need to always keep the original block at the bottom of
arguments. And the explicit block argument should be a normal local
variable. We will investigate it later.
2024-09-25 14:12:50 +09:00
Yukihiro "Matz" Matsumoto 12264e33e5 Merge pull request #6361 from jbampton/add-pre-commit-hook-shellcheck 2024-09-24 09:44:25 +09:00
Yukihiro "Matz" Matsumoto abc4ccf763 Merge pull request #6368 from jbampton/add-pre-commit-hook-check-json 2024-09-24 09:40:39 +09:00
Yukihiro "Matz" Matsumoto 05e3c5831d Merge pull request #6367 from jbampton/fix-spelling 2024-09-24 07:16:55 +09:00
John Bampton 2adf60320d Add pre-commit hook check-json
https://github.com/pre-commit/pre-commit-hooks?tab=readme-ov-file#check-json

Adds another check/test to our pre-commit framework for checking JSON files

We have one JSON file at `.github/linters/mlc_config.json`
2024-09-24 00:47:27 +10:00
John Bampton e12da35645 Fix spelling 2024-09-24 00:14:24 +10:00
Yukihiro "Matz" Matsumoto 919a689517 Merge pull request #6363 from dearblue/mrb_type 2024-09-23 14:49:55 +09:00
Yukihiro "Matz" Matsumoto 17acf23914 readfloat.c: we don't need long double for mruby; fix #6365
`mrb_read_float()` function does not raise ERANGE (unlike `strtod()`)
so we don't need high precision double for calculation.
2024-09-23 08:11:23 +09:00
Yukihiro "Matz" Matsumoto ecd42ab3e9 Merge pull request #6360 from jbampton/add-actionslint-to-pre-commit 2024-09-22 20:21:44 +09:00
Yukihiro "Matz" Matsumoto 1b875a925c Merge pull request #6364 from jbampton/fix-spelling 2024-09-22 20:19:06 +09:00
John Bampton b974b944af docs: fix spelling 2024-09-22 12:16:23 +10:00
dearblue 1f933c21e3 Revert "Perform pseudo binary search with mrb_type()"
This reverts commit e76bebe836 (#6309).

Because it crashes limited to gcc13 -O3.
ref. #6358.

Also, benchmark tests have shown that revert tends to be preferable in this time.
2024-09-22 10:51:12 +09:00
John Bampton 6fe57ae44e Add pre-commit hook shellcheck-py to check syntax of shell scripts
https://github.com/shellcheck-py/shellcheck-py

https://www.shellcheck.net/

https://github.com/koalaman/shellcheck

Remove bash/shell checking from the Super-Linter
2024-09-22 10:18:21 +10:00
John Bampton 6d749e92ed Add pre-commit hook actionlint
Validate GitHub Actions with pre-commit.

Remove the Super-Linter GitHub Actions check.

It is more useful to run "actionlint" with pre-commit
since the hooks run on our local machines on git commit.

We also run pre-commit on GitHub.

Whereas the Super-Linter tests only run on GitHub.

https://github.com/rhysd/actionlint/blob/main/docs/usage.md#pre-commit
2024-09-22 08:51:42 +10:00
Yukihiro "Matz" Matsumoto bd668e4c9d readfloat.c: new implementation of mrb_read_float(); ref #6187
The new version gives more accurate values for decimal number
representation that are not divisible in binary representations, for
example `0.3`.

The function uses `long double` for precision. Please report if `long
double` causes problems on any platform (especially microcontrollers).
Ref #6182
2024-09-21 02:47:42 +09:00
Yukihiro "Matz" Matsumoto c162f8f709 Merge pull request #6356 from dearblue/get-args-splat 2024-09-21 00:03:38 +09:00
dearblue cf23861166 Making splat argument objects invisible from Ruby side
The `mrb_get_argv()` function and the `*` specifier of `mrb_get_args()` get the address of the argument.
At this time, if it is passed in the form of a splat argument, it will be an address to an element of an array object.

After getting the pointer to the array object, the caller may call `mrb_vm_exec()` directly or indirectly.
At this time, a splat argument with the class set can be retrieved as an array object by searching with `ObjectSpace.each_object`.
If changes are made as array objects, addresses on the heap as arrays may become invalid, or objects in the array may be recycled by the GC.
When the caller references the changed address in a subsequent operation, use-after-free is established.

This patch assigns `NULL` as the class of the array object so that it cannot be detected by `ObjectSpace.each_object` from the Ruby side.
2024-09-19 23:13:18 +09:00
Yukihiro "Matz" Matsumoto f6caf0d788 mruby-bigint (mrb_init_set_str): reduce mpz_t allocations 2024-09-19 20:52:11 +09:00
Yukihiro "Matz" Matsumoto e3ff54fda3 vm.c (mrb_vm_exec): unify declaration and initialization of variables 2024-09-18 22:32:35 +09:00
Yukihiro "Matz" Matsumoto d1d010a03a array.c (mrb_ary_delete): array index should be mrb_int 2024-09-17 12:07:39 +09:00
Yukihiro "Matz" Matsumoto ba8ee7b895 mruby-socket (inet_pton): need to initialize loop variable 2024-09-17 12:05:46 +09:00
Yukihiro "Matz" Matsumoto 4b500eb971 Merge pull request #6340 from dearblue/array-cmp 2024-09-17 11:29:41 +09:00
Yukihiro "Matz" Matsumoto b8a6752570 Merge pull request #6354 from dabroz/dabroz-patch-1 2024-09-17 11:00:49 +09:00
Tomasz Pędraszewski 78ee1529d6 Update AUTHORS 2024-09-17 00:01:02 +02:00
Yukihiro "Matz" Matsumoto de6955b1b0 vm.c (mrb_vm_run): merge declaration and initialization 2024-09-16 17:50:13 +09:00
Yukihiro "Matz" Matsumoto fddc7650ca numeric.c (int_ceil): should rename mrb_bint_add_d to mrb_bint_add_n 2024-09-15 04:00:52 +09:00
Yukihiro "Matz" Matsumoto afefb5261b mruby-rational (rat_sub_b): avoid normalization of big integers 2024-09-15 03:04:32 +09:00
Yukihiro "Matz" Matsumoto bdbf8536a7 mruby-bigint: rename add_d and sub_d to add_n and sub_n respectively
`_n` suffix represents `no_normalize`.
2024-09-15 03:02:41 +09:00
Yukihiro "Matz" Matsumoto 50225acec4 mruby-rational (rat_mul_b): should not normalize multiplication results 2024-09-15 02:50:57 +09:00
Yukihiro "Matz" Matsumoto 3ce96e5c4d Merge pull request #6353 from dearblue/array-delete 2024-09-14 06:11:54 +09:00
dearblue 0955539cf9 Fix use-after-free in mrb_ary_delete()
`mrb_equal()` may call `obj.==` method internally.
Therefore, using an unupdated pointer and length after `mrb_equal()` could result in a read/write to an invalid address.

Fresh properties must always be obtained regardless of the result of `mrb_equal()`.
Also, `ary_modify()` must be called each time before writing.

ref. #6339
2024-09-13 21:44:56 +09:00
Yukihiro "Matz" Matsumoto 6e44c0bc91 vm.c (argnum_error): merge declaration and initialization 2024-09-13 07:27:17 +09:00
Yukihiro "Matz" Matsumoto 704ad87150 Merge pull request #6338 from dearblue/proc-align 2024-09-12 06:43:42 +09:00
Yukihiro "Matz" Matsumoto ee9b1381ec Merge pull request #6347 from leviongit/fixes/yield-kw-codegen
codegen.c,parse.y: remove flattening of `yield` arguments; fix #6346
2024-09-12 06:39:27 +09:00
Yukihiro "Matz" Matsumoto 413b005801 Merge pull request #6349 from dearblue/dir-test 2024-09-11 07:12:31 +09:00
Yukihiro "Matz" Matsumoto a38dd0c988 Merge pull request #6350 from dearblue/io-filepath 2024-09-11 07:10:45 +09:00
Yukihiro "Matz" Matsumoto 9aee23b056 Merge pull request #6351 from dearblue/io-arena 2024-09-11 07:09:11 +09:00
Yukihiro "Matz" Matsumoto 06db87e758 Merge pull request #6348 from dearblue/warnings 2024-09-10 22:11:14 +09:00
dearblue 9cb42438e1 Remove unnecessary mrb_gc_arena_restore()
When a function defined as a method returns, there is no need to call `mrb_gc_arena_restore()` immediately before it.
2024-09-10 21:45:44 +09:00
dearblue 33cf729a39 Fixed character encoding conversion function mismatch 2024-09-10 21:34:05 +09:00
dearblue 3aa9a5ee68 Perform GC before deleting directories
In some environments, the test will fail because the directory in use cannot be deleted.
This problem was encountered when building 32-bit binary with mingw32 on FreeBSD and running on wine.
2024-09-10 21:17:10 +09:00
dearblue 8b495cdfda Cancel the warning disablement
Suppress warnings for 0-length sequences is not required.

By commit f1a02dff58, it was introduced.
By commit 24939723d7, pseudo-variable length arrays are now used and the warning suppression is no longer needed.
By commit e8841fbf58, moved the intervening code.
2024-09-10 21:07:43 +09:00
Yukihiro "Matz" Matsumoto da4cfbf89c mruby-array-ext: add a new method Array#fetch_values 2024-09-10 10:22:34 +09:00
leviongit 87801ed5f1 codegen.c,parse.y: remove flattening of yield arguments; fix #6346
this commit changes the parse tree of the `yield` node, allowing for
proper keyword argument generation
2024-09-09 10:06:31 +02:00
Yukihiro "Matz" Matsumoto 0972c84773 array.c (mrb_ary_delete): protect return value; fix #6339
The C local variable is not protected from GC, so we use the function
mrb_gc_protect() to keep the value. We also keep the arena position by
mrb_gc_arena_save(), then restoring the position for every new return
value, to minimize arena size.

Small cosmetic changes (pre-increment to post-increment) are also made
in this commit.
2024-09-09 14:57:32 +09:00
Yukihiro "Matz" Matsumoto 1c4514964e AUTHORS: update entries [ci skip] 2024-09-09 09:55:30 +09:00
Yukihiro "Matz" Matsumoto 2d871fb1ef vm.c (catch_handler_find): merge declaration and initialization 2024-09-09 07:10:50 +09:00
Yukihiro "Matz" Matsumoto a3aff8f437 vm.c (mrb_yield_cont): merge declaration and initialization 2024-09-07 08:36:02 +09:00
Yukihiro "Matz" Matsumoto 1f9fa06119 array.c: no need to assert if blk is a Proc; ref #6344
Since `blk` always comes from `mrb_get_args`, it should always be either
`nil` or a Proc.
2024-09-05 15:26:09 +09:00
Yukihiro "Matz" Matsumoto 3ca3849f54 Merge pull request #6344 from leviongit/array/yield 2024-09-05 15:23:01 +09:00
leviongit 020cfa9283 prefer using mrb_yield to call block arguments 2024-09-04 20:44:51 +02:00
Yukihiro "Matz" Matsumoto 4671459e73 Merge pull request #6343 from mruby/dependabot/bundler/yard-0.9.37 2024-09-05 00:10:42 +09:00
dependabot[bot] c3615be2ac build(deps): bump yard from 0.9.36 to 0.9.37
Bumps [yard](https://github.com/lsegal/yard) from 0.9.36 to 0.9.37.
- [Release notes](https://github.com/lsegal/yard/releases)
- [Changelog](https://github.com/lsegal/yard/blob/main/CHANGELOG.md)
- [Commits](https://github.com/lsegal/yard/compare/v0.9.36...v0.9.37)

---
updated-dependencies:
- dependency-name: yard
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-04 14:52:41 +00:00
Yukihiro "Matz" Matsumoto 649162624f Merge pull request #6341 from dearblue/restore-arena 2024-09-04 09:39:41 +09:00
dearblue e476d9a344 Need to restore the GC arena after some function calls
When calling `mrb_equal()` or `mrb_funcall()` family functions, the GC arena should be restored if the loop is repeated by a non-immediate return value.

In my opinion, restoring the GC arena is unnecessary when a non-immediate (true) value causes the function to return (e.g. the `mrb_ary_index_m()` function).

The patch does not take into account the case of recursive calls and may be incomplete.
2024-09-03 21:29:06 +09:00
dearblue 29496c9931 Fix use-after-free for Array#<=>
The `mrb_ary_cmp()` function calls `mrb_cmp()` for comparison, but `mrb_cmp()` may call the `obj.<=>` method internally.
If a user-defined `<=>` method is called and the array object under comparison is expanded or reduced, a reference to an invalid address may subsequently be made.
2024-09-03 21:25:31 +09:00
Yukihiro "Matz" Matsumoto 1d12097bae mruby-io (mrb_file__gethome): allow avoiding getpwnam(3); ref #5358
You have to define `MRB_IO_NO_PWNAM` to skip calling getpwname(3).
2024-09-03 15:27:29 +09:00
Yukihiro "Matz" Matsumoto 96cf9ba230 vm.c (mrb_yield_with_class): merge declaration and initialization 2024-09-03 11:58:20 +09:00
Yukihiro "Matz" Matsumoto 4062069679 gc.c (gc_arena_keep): revert 2 commits regarding arena allocation; #6329
We assumed there's no need for gc_arena_keep() when MRB_GC_FIXED_ARENA
is set.  But it turned out that gc_protect() still can cause use-after-free
with fixed arena.

Revert "gc.c (gc_protect): should not call gc_arena_keep twice from allocation"

This reverts commit 28ece4ed8b.

Revert "gc.c (gc_arena_keep): reorganized for MRB_GC_FIXED_ARENA; ref #6329"

This reverts commit 33dd623a02.
2024-09-02 23:00:09 +09:00
Yukihiro "Matz" Matsumoto 6c4dbe8584 vm.c (eval_under): unify declaration and initialization of variables 2024-09-02 11:52:32 +09:00
Yukihiro "Matz" Matsumoto f2d9995984 Merge pull request #6332 from dearblue/mruby-compiler 2024-09-01 22:45:07 +09:00
Yukihiro "Matz" Matsumoto 472f699ee6 vm.c (mrb_f_send): unify declaration and initialization of variables 2024-09-01 22:29:46 +09:00
dearblue 42513d61fd Need to place static proc objects into 8-byte alignments
Static proc objects defined as methods may be placed in 4-byte alignments in 32-bit environments.
This may be misinterpreted as an immediate value depending on the address.

Since C11 and C++11 have additional language features for byte alignment, corresponding compilers use them to define the `mrb_alignas()` macro.
For earlier compilers, they use their own extensions to define the `mrb_alignas()` macro.

GCC supports `__attribute__((aligned(alignment)))` since at least version 2.95.3 (1999).
https://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_4.html#IDX305
According to GPT-4, support was added in version 2.7 (1995).

It is not known which version of Visual C++ added support for `__declspec(align(n))`.
According to GPT-4, at least Visual C++ 6.0 (1998) seems to support it.
Also, the documentation of past Intel C/C++ compilers that support `__declspec(align(n))` makes reference to support with Visual C++ 4.2 (1996).
https://www.intel.com/content/dam/www/public/ijkk/jp/ja/documents/developer/ccomp40j.pdf
2024-09-01 20:28:34 +09:00
Yukihiro "Matz" Matsumoto 56c3d748fb Merge pull request #6335 from dearblue/OP_RETURN 2024-08-30 10:53:58 +09:00
Yukihiro "Matz" Matsumoto fa62129fdc Merge pull request #6337 from mruby/dependabot/github_actions/super-linter/super-linter-7.1.0 2024-08-29 09:55:03 +09:00
dependabot[bot] 45bb0973fd build(deps): bump super-linter/super-linter from 7.0.0 to 7.1.0
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 7.0.0 to 7.1.0.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/CHANGELOG.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v7.0.0...v7.1.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-08-28 14:08:55 +00:00
Yukihiro "Matz" Matsumoto 6de3009606 Merge pull request #6328 from dearblue/env-obj_free 2024-08-28 16:40:04 +09:00
Yukihiro "Matz" Matsumoto 4a71d4604e mruby-rational: add typecast to check if a value is fit in mrb_int 2024-08-27 22:48:40 +09:00
Yukihiro "Matz" Matsumoto 540d976f7f array.c (sort_cmp): mrb_cmp() may return -2 for errors 2024-08-27 22:36:24 +09:00
dearblue 7ec5d47a91 Add return_ci in CHECKPOINT_MAIN() of OP_RETURN
For role clarity, distinguish between `ci` and `return_ci`.
2024-08-27 21:39:09 +09:00
Yukihiro "Matz" Matsumoto 28ece4ed8b gc.c (gc_protect): should not call gc_arena_keep twice from allocation 2024-08-27 11:03:14 +09:00
Yukihiro "Matz" Matsumoto ef5ae1c629 Merge pull request #6333 from dearblue/heap_p 2024-08-26 05:49:49 +09:00
Yukihiro "Matz" Matsumoto 33dd623a02 gc.c (gc_arena_keep): reorganized for MRB_GC_FIXED_ARENA; ref #6329 2024-08-26 05:47:28 +09:00
Yukihiro "Matz" Matsumoto 1a322449aa Merge pull request #6331 from dearblue/test-gcarena 2024-08-26 05:47:48 +09:00
Yukihiro "Matz" Matsumoto b9c93673f9 Merge pull request #6329 from dearblue/mrb_obj_alloc 2024-08-26 05:40:12 +09:00
Yukihiro "Matz" Matsumoto 325c918464 class.c: use mrb_unboxed_type where obj is not immediate for sure 2024-08-26 05:33:19 +09:00
dearblue 98fdfe1037 Reduce the number of branch instructions in the heap_p()
As far as `gcc -S` for several CPU architectures has confirmed, it reduces the number of branch instructions by one.
2024-08-25 20:35:41 +09:00
dearblue cfe410f466 Must not depend on the “host” build to generate mruby-compiler/core/y.tab.c
“mruby-compiler” should be able to generate `y.tab.c` files through a separate build configuration if it is not added to the ‘host’ build.
In the example above, the “host/mrbc” build should generate the `y.tab.c` file.
2024-08-25 11:17:56 +09:00
dearblue 79d7ac5f7e Restore the GC arena with tests.
This was the unintentional catalyst for finding the problem in #6329, but it is preferable to add a test if necessary.
2024-08-25 11:08:40 +09:00
dearblue 1c5839fb01 Fix use-after-free in mrb_obj_alloc()
When GC occurs during the expansion of the GC arena by `gc_protect()` in `mrb_obj_alloc()`, the object page just allocated by `add_heap()` is released.
Therefore, as soon as control returns from `gc_protect()`, there is a possibility of illegal writing or reading to the address just released.

This issue was discovered during the investigation of #6326.
2024-08-25 10:55:15 +09:00
Yukihiro "Matz" Matsumoto a2db222422 Merge pull request #6330 from dearblue/mrb_env_unshare 2024-08-24 21:47:44 +09:00
dearblue 13571402d2 Add a precondition to call mrb_env_unshare().
The following assertions can be added to omit the `if` block

  - env object must be non-null
  - env object must be in a shared state with the stack

The current caller is believed to satisfy the condition.
2024-08-24 17:30:54 +09:00
dearblue 22b1ac9070 Fix use-after-free in obj_free() for env objects
A reference to an invalid address might occur in `is_dead()` of `obj_free()` called from `incremental_sweep_phase()`.
This would happen if the heap page was freed ahead of time in the same `incremental_sweep_phase()`.

fixed #6326
2024-08-24 16:46:27 +09:00
Yukihiro "Matz" Matsumoto 204b81c563 mruby-bin-mirb: fix the issue on macOS; #6327 2024-08-24 07:13:45 +09:00
Yukihiro "Matz" Matsumoto 7ba95e2f5e Merge pull request #6327 from juchem/master 2024-08-23 22:33:44 +09:00
Yukihiro "Matz" Matsumoto f35000f2a9 array.c (sort_cmp): comparing objects may be freed by GC; #6326
If comparing function (block or `<=>`) modifies the sorting array and GC
happens after the modification, objects passed to comparison may be
freed by GC.
2024-08-23 22:29:45 +09:00
Marcelo Juchem a6eb3e5c27 fix ncurses linking issues
The build configuration for `mruby` assumes only the `ncurses` library
needs to be linked because `tinfo` is implicitly pulled in.

In environments where ncurses is available only as a static library,
`tinfo` needs to be linked explicitly (needed for functions like
`tputs`.

This patch fixes that by linking `tinfo` if available.

It also fixes the build for environments where only the `ncursesw`
version of the library (including wide character support) is present,
while still giving preference to the `ncurses` version (without wide
character support).
2024-08-22 14:11:48 -05:00
Yukihiro "Matz" Matsumoto 58c70834d9 array.c (srot_cmp): need modify check after mrb_cmp as well; #6326
mrb_cmp() may also modify the sorting array internally.
2024-08-22 07:49:16 +09:00
Yukihiro "Matz" Matsumoto 4ea6d74d83 mruby-rational: introduce the constants ONE and ZERO 2024-08-21 18:38:51 +09:00
Yukihiro "Matz" Matsumoto 752ebe6b7f array.c (mrb_ary_sort_bang): check if array is modified in blocks
This address at least part of #6326. CRuby copied the array internally,
but mruby avoid copying to reserve memory.
2024-08-21 18:31:46 +09:00
Yukihiro "Matz" Matsumoto 4b9f567821 vm.c (exec_irep): unify declaration and initialization 2024-08-20 12:49:45 +09:00
Yukihiro "Matz" Matsumoto 98440e095f vm.c (mrb_ci_nregs): unify declaration and initialization 2024-08-20 10:39:12 +09:00
Yukihiro "Matz" Matsumoto 166262243a benchmark/bm_so_mandelbrot.rb: add new benchmark 2024-08-18 23:11:29 +09:00
Yukihiro "Matz" Matsumoto 39b9a1a06a mruby-rational (rational_new): fix compilation condition 2024-08-17 16:29:51 +09:00
Yukihiro "Matz" Matsumoto 44908e5cba mruby-rational: support bigint numerators & denominators 2024-08-16 15:12:03 +09:00
Yukihiro "Matz" Matsumoto 92f476d8fa mruby-bigint (mpz_set): trim destination mpz_t 2024-08-16 07:32:05 +09:00
Yukihiro "Matz" Matsumoto 479259b4e1 Merge pull request #6324 from dearblue/localjump_error 2024-08-16 06:22:32 +09:00
Yukihiro "Matz" Matsumoto b202d00219 Merge pull request #6325 from mruby/dependabot/github_actions/super-linter/super-linter-7.0.0 2024-08-16 06:19:16 +09:00
dependabot[bot] f3b24009e6 build(deps): bump super-linter/super-linter from 6.9.0 to 7.0.0
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 6.9.0 to 7.0.0.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/CHANGELOG.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v6.9.0...v7.0.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-08-15 14:34:20 +00:00
Yukihiro "Matz" Matsumoto a4225709ef Merge pull request #6323 from mruby/dependabot/github_actions/super-linter/super-linter-6.9.0 2024-08-15 12:15:17 +09:00
dearblue 9d0617f27b Remove localjump_error()
Suppress heap allocation for strings.
2024-08-15 10:27:53 +09:00
Yukihiro "Matz" Matsumoto dfe2dbcde6 class.c (init_copy): need to copy float numbers in some cases
If `MRB_BOXING_WORD` and `MRB_WORDBOXING_NO_FLOAT_TRANCATE` is defined,
float numbers are packed in the heap object. We need to copy them
explicitly.
2024-08-15 09:57:56 +09:00
dependabot[bot] eb6d7afd7e build(deps): bump super-linter/super-linter from 6.8.0 to 6.9.0
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 6.8.0 to 6.9.0.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/CHANGELOG.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v6.8.0...v6.9.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-08-14 14:56:30 +00:00
Yukihiro "Matz" Matsumoto e9c4486e27 mruby-bigint: add fast path to mrb_bint_mul() & mrb_bint_div() 2024-08-14 22:36:47 +09:00
Yukihiro "Matz" Matsumoto 16f5000794 Merge pull request #6320 from dearblue/OP_BREAK 2024-08-14 18:02:34 +09:00
Yukihiro "Matz" Matsumoto 6e5a493ff3 mruby-bigint (mrb_bint_new_float): add fast path for FIXABLE_FLOAT 2024-08-14 16:11:27 +09:00
Yukihiro "Matz" Matsumoto 92302df49d Merge pull request #6322 from hoshiumiarata/fix_mrb_ro_data_p 2024-08-13 17:50:35 +09:00
Hoshiumi Arata da54da1923 Fix mrb_ro_data_p on Intel Mac 2024-08-13 17:27:08 +09:00
Yukihiro "Matz" Matsumoto 1e503f902d Merge pull request #6321 from dearblue/lib-warnings 2024-08-13 11:48:21 +09:00
Yukihiro "Matz" Matsumoto c853dc4090 vm.c (funcall): move va_list declaration right before va_start() 2024-08-12 22:57:05 +09:00
dearblue 79f4a67268 Avoid warnings in lib/**/*.rb
```console
% find -s lib -type f -name '*.rb' -exec ruby -cw {} \;
lib/mruby/build/command.rb:320: warning: `+' after local variable or literal is interpreted as binary operator
lib/mruby/build/command.rb:320: warning: even though it seems like unary operator
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
lib/mruby/gem.rb:469: warning: `&' interpreted as argument prefix
Syntax OK
Syntax OK
Syntax OK
Syntax OK
```
2024-08-12 21:06:31 +09:00
dearblue 682583a609 Shrinking the code in OP_BREAK and OP_RETURN_BLK
- Can refer directly to `proc->e.env` after `MRB_PROC_ENV_P()`.
  - Can omit `MRB_ENV_ONSTACK_P()` since `mrb->c` is never NULL and can be directly compared to `env->cxt`.
  - Can avoid `goto` by putting the code block that raises the `LocalJumpError` at the end.
2024-08-12 20:54:55 +09:00
Yukihiro "Matz" Matsumoto 22eb7e87af vm.c (uvenv): move declaration to initialization 2024-08-11 23:45:40 +09:00
Yukihiro "Matz" Matsumoto 7ca60a0964 vm.c (stack_extend_alloc): move variable declaration to initialization 2024-08-10 21:57:51 +09:00
Yukihiro "Matz" Matsumoto 56a82009aa Revert "The lex_state after literals should be EXPR_ENDARG."; fix #6298
This reverts commit e98823f189.
2024-08-10 19:17:49 +09:00
Yukihiro "Matz" Matsumoto a267dfd76b vm.c (OP_CLASS,OP_MODULE): combine declarations with initializers 2024-08-08 06:11:52 +09:00
Yukihiro "Matz" Matsumoto 22ec76f46c vm.c (OP_RANGE_INC): remove unnecessary local variable 2024-08-08 06:10:35 +09:00
Yukihiro "Matz" Matsumoto 320c757186 Merge pull request #6318 from dearblue/shrink-vm-vars
Shrink variables in `mrb_vm_exec()`
2024-08-06 12:21:36 +09:00
Yukihiro "Matz" Matsumoto aad2aacf25 range.c (mrb_get_values_at): support bigint too 2024-08-05 16:35:41 +09:00
Yukihiro "Matz" Matsumoto 6da2e60edc mruby-bigint (mpz_get_str): avoid malloc when base is a power of 2 2024-08-05 10:43:47 +09:00
Yukihiro "Matz" Matsumoto 0e6ef15b0f AUTHORS: update entries [ci skip] 2024-08-04 23:19:25 +09:00
Yukihiro "Matz" Matsumoto e8bb03da40 numeric.rb (step): iterate over integers even if end is a float
It used to check all `start`, `end` and `step`. If either of them are
float number, `#step` iterated over float number. Now we don't check the
type of `end` argument.
2024-08-03 13:35:09 +09:00
Yukihiro "Matz" Matsumoto 6d6e26661d gc.c: remove unnecessary argument from add_gray_list() 2024-08-02 21:14:58 +09:00
Yukihiro "Matz" Matsumoto 3324773f56 gc.c (mrb_gc_register): protect obj from GC during execution
Because `mrb_ary_new()` and `mrb_ary_push()` can cause GC; fix #6317
2024-08-02 04:52:11 +09:00
Yukihiro "Matz" Matsumoto 16fe4b2701 Merge pull request #6319 from mruby/dependabot/github_actions/super-linter/super-linter-6.8.0 2024-08-02 04:47:42 +09:00
dependabot[bot] 7db4cfd5cd build(deps): bump super-linter/super-linter from 6.7.0 to 6.8.0
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 6.7.0 to 6.8.0.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/CHANGELOG.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v6.7.0...v6.8.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-08-01 14:32:11 +00:00
Yukihiro "Matz" Matsumoto aa06432776 mruby-array-ext: index should be within mrb_int range
Type check is done by `__to_int` method.
2024-08-01 07:34:20 +09:00
dearblue 822e3fdfd7 Remove pool and syms variables in mrb_vm_exec()
Can be referenced by traversing through the `irep` pointer.
2024-07-31 22:27:04 +09:00
dearblue f2a139a616 Avoid assignments to pc and proc parameters in mrb_vm_exec()
Introduce the `ci` variable instead and refer to it indirectly.
2024-07-31 22:27:04 +09:00
Yukihiro "Matz" Matsumoto a668e6d81e Merge pull request #6310 from dearblue/ci-extend 2024-07-31 11:09:23 +09:00
Yukihiro "Matz" Matsumoto eca59ad9ac Merge pull request #6312 from dearblue/OP_RETURN 2024-07-30 12:04:01 +09:00
Yukihiro "Matz" Matsumoto 3c5baac5c5 mruby-sprintf: fix a bug with negative octals
Leading octal digit may be 1, 3, 7 unlike binary or hexadecimal.
2024-07-30 11:33:18 +09:00
Yukihiro "Matz" Matsumoto ab95e042ca mruby-bigint (mrb_bint_xor): add fast path with fixnums 2024-07-29 16:44:54 +09:00
Yukihiro "Matz" Matsumoto b706c89c41 mruby-bigint (mrb_bint_2comp): fix assertion 2024-07-29 16:44:54 +09:00
Yukihiro "Matz" Matsumoto bf7f14341d mruby-bigint (mrb_bint_or): add fast path with fixnums 2024-07-29 15:47:19 +09:00
Yukihiro "Matz" Matsumoto dcf7adeeb7 mruby-bigint: use zero_p() 2024-07-29 15:43:22 +09:00
Yukihiro "Matz" Matsumoto 196c2bd0b9 mruby-bigint (mrb_bint_add): add type cast to stop warnings in C++ 2024-07-28 23:29:54 +09:00
Yukihiro "Matz" Matsumoto 081cd0627f mruby-bigint (mrb_bint_hash): need to get hash from all digits 2024-07-27 18:54:50 +09:00
Yukihiro "Matz" Matsumoto 203a89a3f2 mruby-bigint (zero_p): define a new predicate to check if mpz_t is 0 2024-07-27 18:54:50 +09:00
Yukihiro "Matz" Matsumoto 234a2b10fb mruby-bigint (mpz_neg): no need to check x != y 2024-07-27 18:54:50 +09:00
Yukihiro "Matz" Matsumoto 811637e99f mruby-bigint (mrb_bint_2comp): inline mpz_2comp 2024-07-27 18:54:49 +09:00
Yukihiro "Matz" Matsumoto c218894af9 mruby-bigint: use mp_limb instead of uint32_t
Because mp_limb may be uint16_t on some platforms.
2024-07-27 18:54:48 +09:00
Yukihiro "Matz" Matsumoto a50a2ce148 .gitingore: add entries (.cache, gmon.out, perf.data) 2024-07-27 18:53:55 +09:00
Yukihiro "Matz" Matsumoto 2247e4f355 mruby-bigint (mpz_xor): simplify the code 2024-07-27 18:53:36 +09:00
Yukihiro "Matz" Matsumoto b573a8430f mruby-bigint (mpz_or): simplify the code 2024-07-27 18:50:09 +09:00
Yukihiro "Matz" Matsumoto dea1cc18a6 mruby-bigint (mpz_and): simplify the code 2024-07-27 18:48:01 +09:00
Yukihiro "Matz" Matsumoto bf081c3d3d mruby-bigint (mrb_bint_and): further optimization for bint & int 2024-07-25 17:46:36 +09:00
Yukihiro "Matz" Matsumoto 99c078bb6b mruby-bigint (mrb_bint_2comp): simplify using mpz_2comp() 2024-07-25 16:18:49 +09:00
Yukihiro "Matz" Matsumoto 3d69412ea5 mruby-bigint: Distinguish uzero_p(x) and x->sn == 0
The latter is a check for integers that have been set up (and disclosed to the
outer world), while the former is a check for integers that are being worked on.
2024-07-25 16:18:48 +09:00
Yukihiro "Matz" Matsumoto 93653dfd4c mruby-bigint (uzero_p): add fast path 2024-07-25 16:18:48 +09:00
Yukihiro "Matz" Matsumoto 4ee7c8e021 mruby-bigint: rename uzero to uzero_p
Since uzero() is a predicate, and zero() is a function to assign zero to
mpz_t, it's confusion. Rename predicate uzero() to uzero_p() to follow
mruby naming convention.
2024-07-25 16:18:48 +09:00
Yukihiro "Matz" Matsumoto 88536ebe30 mruby-bigint (mpz_xor): support bit-wise xor with negative numbers; #6314 2024-07-25 16:18:48 +09:00
Yukihiro "Matz" Matsumoto ee2eb6c87e mruby-bigint (mpz_or): support bit-wise or with negative numbers; #6314 2024-07-25 16:18:48 +09:00
Yukihiro "Matz" Matsumoto 69a80c94b9 mruby-bigint (mpz_and): support bit-wise and with negative numbers
Negative integers are virtually considered as 2's compliment of the
absolute value of the corresponding number. It means `-1` is considered
as infinite sequence of `1` toward msb side. ref #6314
2024-07-25 16:18:48 +09:00
Yukihiro "Matz" Matsumoto e3a459d5b9 mruby-bigint (mrb_bint_and): optimize bint & fixnum operation; ref #6314 2024-07-25 16:18:48 +09:00
Yukihiro "Matz" Matsumoto c16aba9280 mruby-bigint: remove special handling of Float in bitwise operations
CRuby raises TypeError with float numbers as operands; ref #6314
2024-07-25 16:18:47 +09:00
Yukihiro "Matz" Matsumoto 81a9eef591 Merge pull request #6313 from hoshiumiarata/fix_typo_in_opcode_doc 2024-07-24 12:28:52 +09:00
Yukihiro "Matz" Matsumoto b4ffddebdf Merge pull request #6314 from hoshiumiarata/optimize_int_even 2024-07-24 08:11:43 +09:00
Hoshiumi Arata 612941dcbc Add test code for even?/odd? 2024-07-23 21:09:17 +09:00
Hoshiumi Arata 80502b30fb Optimize even?/odd? for big integers 2024-07-23 21:05:10 +09:00
Hoshiumi Arata 35571df7ea Update opcode.md: fix wrong column number 2024-07-23 20:25:22 +09:00
Yukihiro "Matz" Matsumoto bb4a8c2410 Merge pull request #6311 from dearblue/OP_SEND 2024-07-23 11:04:20 +09:00
Yukihiro "Matz" Matsumoto 6a03647fc0 Merge pull request #6309 from dearblue/mrb_type 2024-07-23 07:26:04 +09:00
Yukihiro "Matz" Matsumoto d2878138d9 mruby-numeric-ext: implement Integer#even? and Integer#odd? 2024-07-23 07:23:13 +09:00
Yukihiro "Matz" Matsumoto 9d709164dc Merge pull request #6308 from dearblue/vm-catch 2024-07-22 16:29:56 +09:00
Yukihiro "Matz" Matsumoto f3b570f33a mruby-enumerator: add test for Enumerable#chunk_while 2024-07-22 13:52:12 +09:00
dearblue e93226f402 Doubling the call stack when extending it
Previously it was "approximately double".
2024-07-21 21:58:18 +09:00
dearblue 748af76ed2 Omit error checking at OP_RETURN, OP_RETURN_BLK and OP_BREAK
Clearing errors at the beginning of `mrb_vm_exec()` essentially keeps the mruby VM in a non-error state.

For consistency, functions such as `mrb_funcall()` check for errors when control returns from a C function as a method.
In the case of a tail call, it should return to `mrb_vm_exec()` afterwards, so error checking is performed there.

Instructions issued while `mrb->exc` is non-null should be limited to `OP_EXCEPT`, the jump target of the catch handler table.
2024-07-21 21:58:18 +09:00
dearblue ce847c1aa9 Added fast-path for positional arguments less than 15 in OP_SEND 2024-07-21 21:58:18 +09:00
dearblue e76bebe836 Perform pseudo binary search with mrb_type() 2024-07-21 21:58:18 +09:00
dearblue 45007888f5 Assume that MRB_CATCH() has mrb->exc set
The caller of `MRB_EXC_THROW()` must be preconfigured.
2024-07-21 21:58:18 +09:00
Yukihiro "Matz" Matsumoto dcbe2e3eb3 mruby-enumerator: add Enumerable#chunk_while 2024-07-21 20:29:27 +09:00
Yukihiro "Matz" Matsumoto 7d8fc3b35f Merge pull request #6305 from dearblue/method_missing
Protect keyword arguments in `prepare_missing()`
2024-07-20 22:04:50 +09:00
dearblue 890dda79d0 Protect keyword arguments in prepare_missing()
Previously, keyword arguments were lost if no positional arguments were passed.

Fixed #6304
2024-07-20 16:25:11 +09:00
Yukihiro "Matz" Matsumoto 3ec6038505 Merge pull request #6299 from mruby/dependabot/github_actions/super-linter/super-linter-6.7.0
build(deps): bump super-linter/super-linter from 6.6.0 to 6.7.0
2024-07-20 15:25:20 +09:00
dependabot[bot] 6c4ea4cd10 build(deps): bump super-linter/super-linter from 6.6.0 to 6.7.0
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 6.6.0 to 6.7.0.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/CHANGELOG.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v6.6.0...v6.7.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-20 06:16:03 +00:00
Yukihiro "Matz" Matsumoto 9326c514c5 mruby-enum-ext: add Enumerable#each_entry test 2024-07-20 14:20:15 +09:00
Pete Kinnecom 509590c18d Method missing kwargs test failure:
Fail: Method#call with undefined method -- only kwargs (mrbgems: mruby-method)
 - Assertion[6]
    NoMethodError exception expected, not
    Class: <TypeError>
    Message: <Array cannot be converted to Hash>
 - Assertion[9]
    Expected: {:kwarg1=>:val1, :kwarg2=>:val2}
      Actual: [:foo]
2024-07-19 20:37:40 +00:00
Yukihiro "Matz" Matsumoto c539256b43 mruby-enum-ext: add Enumerable#each_entry 2024-07-19 23:29:45 +09:00
Yukihiro "Matz" Matsumoto 313c5a31ac test/hash.rb: add tests for Hash#assoc and Hash#rassoc 2024-07-18 15:09:49 +09:00
Yukihiro "Matz" Matsumoto 398e669bbf hash.c: add Hash#assoc and Hash#rassoc 2024-07-18 15:06:31 +09:00
Yukihiro "Matz" Matsumoto 1fc8c20723 Merge pull request #6303 from hasumikin/fix/return-value-of-String_aset
mrb_str_aset_m() should return replace instead of str
2024-07-17 09:49:34 +09:00
Yukihiro "Matz" Matsumoto cd8582a011 hash.c: define Hash#to_hash 2024-07-17 09:46:46 +09:00
Yukihiro "Matz" Matsumoto 45078d9a49 mruby-string-ext: fixed typo (casecmp! -> casecmp?) 2024-07-17 02:25:49 +09:00
HASUMI Hitoshi cc16afb7f3 mrb_str_aset_m() should return replace instead of str
`string[]=(idx, replace)` should return `replace`.

## Actual (wrong)

```
string.[]=(idx, replace) → string
string.[]=(idx, len, replace) → string
```

## Expected

```
string.[]=(idx, replace) → replace
string.[]=(idx, len, replace) → replace
```

## Sidenote

As of the current mruby-compiler, `(string[idx] = 'X')` creates not only "CALL_NODE" but also "ASGN_NODE" and "OP_MOVE", overriding the wrong return value.
On the other hand, `string.[]=(idx, 'X')` creates only "CALL_NODE", exposing the wrong return value.

If my new mruby-compiler2, leveraging Prism, took the place of official compiler, `(string[idx] = 'X')` and `string.[]=(idx, 'X')` would be going to generate the same VM code without "OP_MOVE".
So I paranoidly added tests.

FYI: You can find how the new mruby-compiler2's AST and VM code look like in mruby/c's issue (mruby/c had the same bug): https://github.com/mrubyc/mrubyc/pull/210
2024-07-16 18:55:26 +09:00
Yukihiro "Matz" Matsumoto ac8846dbce numeric.c: add Numeric#fdiv 2024-07-15 22:16:52 +09:00
Yukihiro "Matz" Matsumoto 301242c822 numeric.c (int_fdiv): add Integer#fdiv and Float#fdiv 2024-07-15 22:16:52 +09:00
Yukihiro "Matz" Matsumoto 4faab0581e Merge pull request #6302 from auroranockert/minor-mrb-str-init-cleanup
Minor cleanup in mrb_str_init
2024-07-15 21:38:48 +09:00
Yukihiro "Matz" Matsumoto ca28e639c6 mruby-numeric-ext: move allbits?, anybits?, nobits? to Integer class 2024-07-15 21:35:42 +09:00
Yukihiro "Matz" Matsumoto 3f5138a6ac mruby-numeric-ext: implement Numeric#integer? method 2024-07-15 21:35:42 +09:00
Yukihiro "Matz" Matsumoto 1a8df40392 mruby-enum-ext: add Array#sort_by! method 2024-07-15 21:35:42 +09:00
Yukihiro "Matz" Matsumoto fcab7ef377 numeric.c (int_div): fixed a bug regarding bigint / non-integer
Non-integer means Complex or Rational.
2024-07-15 21:35:42 +09:00
Yukihiro "Matz" Matsumoto bcba0bc674 Merge pull request #6300 from jbampton/fix-spelling
Fix spelling
2024-07-15 21:35:43 +09:00
Aurora Nockert a871e4908f Minor cleanup in mrb_str_init
mrb_str_new was essentially manually inlined here, and I think it is a bit easier to follow if we just call the function instead.
2024-07-13 15:38:14 +02:00
John Bampton de8a6fe787 Fix spelling 2024-07-13 00:21:53 +10:00
Yukihiro "Matz" Matsumoto c75f7587bc mruby-numeric-ext: add call-seq reference for Integer#size 2024-07-10 14:56:13 +09:00
Yukihiro "Matz" Matsumoto ee296f024b mruby-numeric-ext: add Integer#size method
Although CRuby uses clz() for the biggest word, mruby bigint only counts
number of digit words.
2024-07-10 14:50:54 +09:00
Yukihiro "Matz" Matsumoto a77bc25a5f mruby-sprintf: support dots expression of negative integer format
For specifiers assume unsigned integers, negative numbers show dots (..)
to indicate virtual infinite 1s at the MSB side of 2's compliment.
2024-07-09 11:13:55 +09:00
Yukihiro "Matz" Matsumoto 80fec16cb6 mruby-sprintf: inline sign_bits() function 2024-07-09 10:48:07 +09:00
Yukihiro "Matz" Matsumoto d249c2e939 mruby-sprintf: separate filling high bits and converting negatives 2024-07-09 10:40:46 +09:00
Yukihiro "Matz" Matsumoto 2488375a35 mruby-bigint (mpz_mod): move mpz_init() to avoid memory leak 2024-07-09 08:00:23 +09:00
Yukihiro "Matz" Matsumoto 0ea1549faa mruby-sprintf: reorder functions
In addition, internal function `mrb_str_format()` is made `static`.
2024-07-06 08:45:19 +09:00
Yukihiro "Matz" Matsumoto bd502f6d7b mruby-sprintf: support Big integers for %d etc. 2024-07-04 22:51:14 +09:00
Yukihiro "Matz" Matsumoto f1a04dae3e mruby-enum-ext (sort_by): avoid copying the receiver
When the receiver is an Array.
2024-07-03 07:31:32 +09:00
Yukihiro "Matz" Matsumoto 7c7ee5c244 array.c: implement Array#delete method in C 2024-07-02 11:45:20 +09:00
Yukihiro "Matz" Matsumoto b9cb9b9bbe Merge pull request #6295 from dearblue/revert-6282
Revert "Delegate the care of a directly given block from `cipop()` to `cipush()`"
2024-07-02 11:45:13 +09:00
dearblue ad576f1e75 Revert "Delegate the care of a directly given block from cipop() to cipush()"
This reverts commit ad2e626e7a.

Because of the changes made by #6282, the following code caused a problem.

```ruby
b = proc { break "BAD!" }
p self.tap { b.call }
# (expected)    => break from proc-closure (LocalJumpError)
# (after #6282) => "BAD!"
```

I revived the `mrb_callinfo::blk` field to fix this, but it did not overcome the following problem.

```ruby
def m(&b); b = b.clone; GC.start; b.call; end
p m { break "OK!" }
# (expected)    => "OK!"
# (revived blk) => break from proc-closure (LocalJumpError)
```
2024-06-30 21:01:45 +09:00
Yukihiro "Matz" Matsumoto 73337133f7 Merge pull request #6294 from auroranockert/optimise-obj-iv-p
Optimise `mrb_iv_get`
2024-06-30 18:25:43 +09:00
Yukihiro "Matz" Matsumoto 72bf46de22 array.c (mrb_ary_cmp): fixed wrong type casting 2024-06-30 18:19:52 +09:00
Yukihiro "Matz" Matsumoto eee83ed7af array.c: implement Array#index and Array#rindex in C
No need to override Array#index in mruby-array-ext. We can call
`to_enum` from C implemented methods.
2024-06-29 15:03:12 +09:00
Yukihiro "Matz" Matsumoto dd808a0be4 array.c: implement Array#<=> in C 2024-06-29 15:03:12 +09:00
Yukihiro "Matz" Matsumoto 8cffa04def array.c: implement Array#== and Array#eql? in C
It seems OK to call comparison from C method from measurement.
2024-06-29 08:32:06 +09:00
Yukihiro "Matz" Matsumoto 5b8de8d616 Array.c (mrb_ary_init): implement Array#initialize in C 2024-06-28 08:56:41 +09:00
Aurora Nockert 646c37ecda Add a fast-path for mrb_type
By adding a fast-path where we ignore boxed types we can gain a pretty substantial speedup of mrb_iv_get, making it about 25% faster during a standard optcarrot benchmark run.

NOTE: It is just mrb_iv_get that is that much faster, the whole benchmark seems to be about 3-5% faster with word boxing.
2024-06-27 22:46:13 +02:00
Aurora Nockert 27f972b048 Reorder mrb_vtype
This allows the compiler to optimise the case in obj_iv_p into a range check. There does not seem to be any other very hot uses of this index and it grants a pretty big gain on optcarrot.
2024-06-27 22:46:13 +02:00
Yukihiro "Matz" Matsumoto f709847bde numeric.c (cmpnum): skip mrb_as_float() if possible 2024-06-27 10:02:06 +09:00
Yukihiro "Matz" Matsumoto 5b27469d19 numeric.c (mrb_cmp): check the first argument if it's int or float
To avoid the cost of `mrb_type(obj1)`.
2024-06-27 09:24:34 +09:00
Yukihiro "Matz" Matsumoto ac1e4a2d58 numeric.c (cmpnum): handle the case where both arguments are fixnum first
To avoid the cost of `mrb_type(v2)`.
2024-06-27 08:55:28 +09:00
Yukihiro "Matz" Matsumoto b8f968b4a3 numeric.c (mrb_cmp): no need to check respond_to?(:<=>)
Because every object responds to `<=>`.
2024-06-27 08:48:11 +09:00
Yukihiro "Matz" Matsumoto 5bd63d6232 array.c: replace sort! method implementation
- use heap sort (O(1)) instead of merge sort (O(n)) for better space
  complexity.

- method implemented in C for better performance

As a result, simple sorting now consumes far less memory and is faster.
Since it's implemented in C, fiber context switching is not allowed from
comparison, but we consider the risk is minimal (no one switches context
in the comparison, right?)
2024-06-26 11:28:56 +09:00
Yukihiro "Matz" Matsumoto b521d0816f numeric.c (cmpnum): restrict comparison between Numeric objects 2024-06-25 14:36:56 +09:00
Yukihiro "Matz" Matsumoto bb2733e9a2 numeric.c (cmpnum): rafactoring
- separate `MRB_NO_FLOAT` case
- use `mrb_as_float()` as much as possible
2024-06-24 09:34:13 +09:00
Yukihiro "Matz" Matsumoto a0d4c63f9a Merge pull request #6293 from dearblue/doc/opcode.md
Changed the instruction table in `opcode.md`
2024-06-23 20:14:51 +09:00
dearblue f4f3a061be Changed the instruction table in opcode.md
- Added the index number corresponding to the instruction code.
  - Omitted trailing `|` from table elements.
    The table elements in GitHub Flavored Markdown can't wrap wherever wanted.
    And trying to align the end of it tends to make the whole thing longer.
2024-06-22 23:21:43 +09:00
Yukihiro "Matz" Matsumoto 54e99197bd Revert "tools/lrama: apply ruby/lrama#442"
This reverts commit fb9fbc8498.

The fix in the upstream still causes syntax error in C++.
2024-06-22 13:34:46 +09:00
Yukihiro "Matz" Matsumoto eab6bddffe Merge pull request #6292 from jbampton/pre-commit-autoupdate
markdownlint --fix; remove prettier; pre-commit autoupdate; fix spelling
2024-06-21 14:33:44 +09:00
Yukihiro "Matz" Matsumoto d4c65d7ab1 AUTHORS: update entries [ci skip] 2024-06-21 13:01:38 +09:00
Yukihiro "Matz" Matsumoto c592e7b70d string.c: small refactoring 2024-06-21 10:11:32 +09:00
Yukihiro "Matz" Matsumoto fb9fbc8498 tools/lrama: apply ruby/lrama#442 2024-06-21 08:12:27 +09:00
John Bampton 88e2eb0188 Fix spelling 2024-06-21 08:14:17 +10:00
John Bampton 06becc3495 pre-commit autoupdate 2024-06-21 08:14:17 +10:00
John Bampton bbb0dddc7e Remove prettier from pre-commit 2024-06-21 08:14:17 +10:00
John Bampton ac74c90b30 Run markdownlint --fix 2024-06-21 06:53:42 +10:00
Yukihiro "Matz" Matsumoto 73c3970ea1 numeric.c: fix spacing in a comment 2024-06-19 09:25:19 +09:00
Yukihiro "Matz" Matsumoto b8396aec33 numeric.c (cmpnum): fix a bug in float-bigint comparison
Should have used bigint to float conversion.
2024-06-19 09:25:19 +09:00
Yukihiro "Matz" Matsumoto 0f2d12a005 numeric.c (cmpnum): reduce else nesting 2024-06-18 01:50:49 +09:00
Yukihiro "Matz" Matsumoto 75de002058 mruby-complex: provide Complex#<=> in Ruby 2024-06-17 08:14:27 +09:00
Yukihiro "Matz" Matsumoto 3b9aec90dd mruby-rational: define <=> method in Ruby, not in C 2024-06-17 08:02:42 +09:00
Yukihiro "Matz" Matsumoto 36eff3ec59 mruby-rational/test: remove UserDefinedNumeric tests
Since they checks the behavior different from CRuby.
2024-06-17 07:57:54 +09:00
Yukihiro "Matz" Matsumoto d1592ba9f9 numeric.c (cmpnum): use mrb_as_int() instead of mrb_integer() 2024-06-17 07:51:25 +09:00
Yukihiro "Matz" Matsumoto b44dc1c0b9 mruby-rational: use presym for initialization 2024-06-14 06:17:20 +09:00
Yukihiro "Matz" Matsumoto 0e045a52f6 mruby-complex: use presym for initialization 2024-06-14 06:15:34 +09:00
Yukihiro "Matz" Matsumoto 921a54ef33 mruby-socket/socket.rb: done some small refactoring 2024-06-14 06:14:27 +09:00
Yukihiro "Matz" Matsumoto 39d577799f mruby-socket: use presym for initialization 2024-06-14 06:14:07 +09:00
Yukihiro "Matz" Matsumoto 7be10097a0 mruby-io: use presym for initialization 2024-06-14 02:00:17 +09:00
Yukihiro "Matz" Matsumoto db8d43090a mruby-struct: use presym for initialization 2024-06-14 01:59:30 +09:00
Yukihiro "Matz" Matsumoto 8bd66a9358 mruby-data: use presym for initialization 2024-06-14 01:59:10 +09:00
Yukihiro "Matz" Matsumoto d5fd3338a4 mruby-method: use presym for initialization 2024-06-14 01:46:22 +09:00
Yukihiro "Matz" Matsumoto 71a4e5f3ff mruby-proc-ext: use presym for initialization 2024-06-14 01:45:58 +09:00
Yukihiro "Matz" Matsumoto 2b4591fe68 mruby-proc-binding: use presym for initialization 2024-06-14 01:45:23 +09:00
Yukihiro "Matz" Matsumoto 9fbdf78380 mruby-binding: use presym for initialization 2024-06-14 01:44:49 +09:00
Yukihiro "Matz" Matsumoto d1e49f7121 mruby-metaprog: use presym for initialization 2024-06-14 01:43:57 +09:00
Yukihiro "Matz" Matsumoto c32a94d878 mruby-string-ext: use presym for initialization 2024-06-14 01:43:03 +09:00
Yukihiro "Matz" Matsumoto 513908d77f mruby-range-ext: use presym for initialization 2024-06-14 01:42:30 +09:00
Yukihiro "Matz" Matsumoto 4104837ba1 mruby-hash-ext: use presym for initialization 2024-06-14 01:41:55 +09:00
Yukihiro "Matz" Matsumoto cfd90a65f7 mruby-array-ext: use presym for initialization 2024-06-14 01:41:06 +09:00
Yukihiro "Matz" Matsumoto 574f9f0d39 mruby-class_ext: use presym for initialization 2024-06-14 00:37:05 +09:00
Yukihiro "Matz" Matsumoto 6361f6d661 mruby-numeric-ext: use presym for initialization 2024-06-14 00:35:44 +09:00
Yukihiro "Matz" Matsumoto d94916bf15 mruby-kernel-ext: use presym for initialization 2024-06-14 00:34:07 +09:00
Yukihiro "Matz" Matsumoto e1a62a581f mruby-object-ext: use presym for initialization 2024-06-14 00:33:18 +09:00
Yukihiro "Matz" Matsumoto c99b8d7d3b mruby-fiber: use presym for initialization 2024-06-14 00:32:07 +09:00
Yukihiro "Matz" Matsumoto bf8e19f7da mruby-sleep: use presym for initialization 2024-06-14 00:30:32 +09:00
Yukihiro "Matz" Matsumoto 0eb616e3bd mruby-symbol-ext: use presym for initialization 2024-06-14 00:28:33 +09:00
Yukihiro "Matz" Matsumoto 3628d093f4 mruby-dir: use presym for initialization 2024-06-14 00:27:13 +09:00
Yukihiro "Matz" Matsumoto 6535f6d159 mruby-eval: use presym for initialization 2024-06-14 00:26:22 +09:00
Yukihiro "Matz" Matsumoto 9c060b425c mruby-errno: use presym for initialization 2024-06-14 00:25:26 +09:00
Yukihiro "Matz" Matsumoto e4c2423f6e mruby-catch: use presym for initialization 2024-06-14 00:23:11 +09:00
Yukihiro "Matz" Matsumoto 6bcaeb5a93 mruby-pack: use presym for initialization 2024-06-14 00:19:21 +09:00
Yukihiro "Matz" Matsumoto f3c2373c6f mruby-print: use presym for initialization 2024-06-14 00:18:22 +09:00
Yukihiro "Matz" Matsumoto c94ae288d5 mruby-time: use presym for initialization 2024-06-14 00:16:21 +09:00
Yukihiro "Matz" Matsumoto 8f184a356b mruby-random: use presym for initialization 2024-06-14 00:15:25 +09:00
Yukihiro "Matz" Matsumoto 3141b9424c mruby-compiler/y.tab.c: it will be generated by Lrama from parse.y
No longer need to bundle in the repository.
2024-06-10 15:34:16 +09:00
Yukihiro "Matz" Matsumoto 933e966fab tools/lrama: update template to stop C++ compiler error 2024-06-10 15:23:53 +09:00
Yukihiro "Matz" Matsumoto fbe21a0321 tools/lrama: bundle Lrama 0.6.9 (copied from CRuby source) 2024-06-10 14:26:26 +09:00
Yukihiro "Matz" Matsumoto d6da2d4760 mruby-compiler: use @1 in parse.y to enable YYLTYPE
This change itself does nothing good, but it is a preparation for the
future Bison to Lrama migration. As of 0.6.9, Lrama has a compatibility
issue for grammar files without `@n`.
2024-06-10 08:23:36 +09:00
Yukihiro "Matz" Matsumoto 473206c5d8 class.c: adjust local variable declarations with initialization 2024-06-10 08:23:36 +09:00
Yukihiro "Matz" Matsumoto b6b74b3a5b Merge pull request #6290 from dearblue/libdir
Allow to change the output directory name of the `libmruby` file
2024-06-10 08:22:52 +09:00
dearblue 0fcf54b47d Allow to change the output directory name of the libmruby file
Add the `MRuby::Build#libdir_name` accessor and the `MRUBY_SYSTEM_LIBDIR_NAME` environment variable.

Resolved #6240
2024-06-09 22:49:46 +09:00
Yukihiro "Matz" Matsumoto 43b3536803 Merge pull request #6288 from dearblue/closing
Detach `env` of ci explicitly on atexit
2024-06-09 19:40:21 +09:00
Yukihiro "Matz" Matsumoto b60cd351a1 Merge pull request #6289 from dearblue/orphan-block
Simplify `OP_RETURN_BLK` and `OP_BREAK
2024-06-08 23:51:48 +09:00
dearblue f48ac7469b Simplify OP_RETURN_BLK and `OP_BREAK
- There was some unnecessary complexity in `OP_BREAK` introduced in commit ad2e626 (#6282).
  - Since `mrb->c` is never NULL, there is no need to check it with `MRB_ENV_ONSTACK_P()` beforehand.
2024-06-08 13:46:28 +09:00
dearblue bd596153f1 Detach env of ci explicitly on atexit
Supplement to commit 177debacc5 (#6276).

If the ci is incomplete, the previous method may cause the application to crash because `env->stack` points to an invalid address when expanding the data stack.
Since the ci is in an abnormal state, control it by putting `NULL` in `env->stack`.

If the ci is fine and top-level, detach `env` as usual with `mrb_env_unshare()`.
2024-06-06 21:35:24 +09:00
Yukihiro "Matz" Matsumoto 8c1e12263e Merge pull request #6287 from mruby/dependabot/github_actions/super-linter/super-linter-6.6.0
build(deps): bump super-linter/super-linter from 6.5.1 to 6.6.0
2024-06-05 21:26:23 +09:00
Yukihiro "Matz" Matsumoto 889af10090 mruby-compiler: prohibit dynamic assignment to constants; #3521
Along with some declaration adjustments to minimize `y.tab.c` diff.
2024-06-05 18:56:11 +09:00
dependabot[bot] bc930d68ab build(deps): bump super-linter/super-linter from 6.5.1 to 6.6.0
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 6.5.1 to 6.6.0.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/CHANGELOG.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v6.5.1...v6.6.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-04 14:49:19 +00:00
Yukihiro "Matz" Matsumoto 5072358276 vm.c: remove unnecessary type cast to blk; ref #6282 2024-06-03 19:45:53 +09:00
Yukihiro "Matz" Matsumoto dcdd94c04c Merge pull request #6282 from dearblue/orphan-block
Delegate the care of a directly given block from `cipop()` to `cipush()`
2024-06-02 22:02:58 +09:00
Yukihiro "Matz" Matsumoto 95dcc52e16 Merge pull request #6283 from dearblue/env
Simplify `uvenv()`
2024-06-01 22:51:02 +09:00
dearblue d0b06446f2 Simplify uvenv()
The part removed in this patch was introduced by commit c7c9543bed.

The current mechanism should be able to trace from block objects created by `eval` to higher level blocks without any problems.
2024-06-01 20:36:22 +09:00
Yukihiro "Matz" Matsumoto 00a874cff6 Merge pull request #6281 from dearblue/binding
Fixes local variables in `mruby-binding`.
2024-05-31 22:56:04 +09:00
Yukihiro "Matz" Matsumoto 8d79cfdc83 Merge pull request #6280 from dearblue/env
Remove `MRB_ENV_CLOSED` flag
2024-05-31 22:50:56 +09:00
Yukihiro "Matz" Matsumoto 7b9b0997e0 string.c: adjust local variable declarations 2024-05-31 22:49:25 +09:00
dearblue ad2e626e7a Delegate the care of a directly given block from cipop() to cipush()
Outlines:
  - Removed `mrb_callinfo::blk`
  - Added `mrb_callinfo::flags`
  - Added `MRB_CI_COMPANION_BLOCK` flag
2024-05-31 22:03:15 +09:00
dearblue e82b36035e Fixes local variables in mruby-binding.
There are two issues to be fixed:
  - `mrb_irep` could leak if `mrb_calloc()` encountered an out-of-memory exception
  - `mrb_proc_merge_lvar()` allocated one extra variable name.

`irep->lv` can always refer to only one less range than `irep->nlocals`.
Also, when `mrb_proc_merge_lvar()` extends `irep->lv`, `mrb_realloc()` with `NULL` has the same behavior as `mrb_malloc()`.
2024-05-30 21:25:30 +09:00
dearblue 7ab6386cc6 Remove MRB_ENV_CLOSED flag
Set `env->cxt` to `NULL` when it is detached from the call frame.
In other words, we can determine if `env->cxt` is `NULL` or not.

Also, `mruby-binding` had been setting `env->cxt` unnecessarily, so this has been fixed.
2024-05-30 21:09:49 +09:00
Yukihiro "Matz" Matsumoto 0a11af74f4 Merge pull request #6279 from kou/windows-lean-and-mean-include
Include headers for malloc() explicitly; fix #6277
2024-05-29 14:37:10 +09:00
Sutou Kouhei c258ead85b Include headers for malloc() explicitly; fix #6277
We need to include stdlib.h and malloc.h to use malloc()/free() but
they aren't included in src/string.c with WIN32_LEAN_AND_MEAN. It
generates build time warnings.

We can solve this by including stdlib.h and malloc.h explicitly.
2024-05-29 09:45:36 +09:00
Yukihiro "Matz" Matsumoto f1dec3959f mruby-range-ext (range_size): raise TypeError if not iterable
According ruby/ruby#8663, `Range#size` behavior has changed.
2024-05-28 15:30:08 +09:00
Yukihiro "Matz" Matsumoto f2dc44215c Merge pull request #6276 from dearblue/closing
Always run `atexit` on the top-level call frame
2024-05-27 12:40:52 +09:00
Yukihiro "Matz" Matsumoto bf244d65db Merge pull request #6275 from dearblue/binding.eval
Fixed `Binding#eval` that failed to assign to the same variable
2024-05-27 08:49:14 +09:00
dearblue 177debacc5 Always run atexit on the top-level call frame
In the following example, the fiber context and call stack may be in an incomplete state.
  - In case another thread running mruby is terminated abnormally
  - In case of a global jump that is out of management by mruby
2024-05-26 21:17:00 +09:00
Yukihiro "Matz" Matsumoto d03394fbc4 mruby-os-memsize: adjust local variable declarations 2024-05-26 18:01:15 +09:00
Yukihiro "Matz" Matsumoto 681bcdbcd3 mruby-bigint: adjust local variable declarations 2024-05-26 07:38:34 +09:00
dearblue 75b0d06c41 Fixed Binding#eval that failed to assign to the same variable
In `Binding#eval`, two times parsing is executed.
The problem found in this case was caused by not passing an upper block to hold variables of the binding object during the first parsing.

The problem was uncovered by <https://github.com/mruby/mruby/discussions/6274>.
2024-05-25 21:55:02 +09:00
Yukihiro "Matz" Matsumoto 20cf58d1d3 Merge pull request #6273 from dearblue/closing
Improvements to `mrb_protect_atexit()`
2024-05-25 16:48:56 +09:00
Yukihiro "Matz" Matsumoto d415a45a33 AUTHORS: update entries [ci skip] 2024-05-25 16:47:08 +09:00
Yukihiro "Matz" Matsumoto 10bc15c23e mruby-class-ext: adjust variable declarations 2024-05-25 16:41:24 +09:00
Yukihiro "Matz" Matsumoto 292f7ef0ce mruby-proc-ext (mrb_proc_parameters): adjust variable declarations 2024-05-25 16:39:32 +09:00
Yukihiro "Matz" Matsumoto 89c70aeea0 mruby-range-ext: move local variable declarations to minimize scope 2024-05-25 16:39:32 +09:00
Yukihiro "Matz" Matsumoto 7c2be58e2a mruby-rational (rational_pow): fix wrong power calculation
`a/b ** -n` can be calculated by `b/a ** n` for correctness.
2024-05-25 16:39:32 +09:00
Yukihiro "Matz" Matsumoto d148bf8c0b mruby-rational: adjust local variable declarations with initialization 2024-05-25 16:39:32 +09:00
Yukihiro "Matz" Matsumoto 68e093729b string.c: refactor bit operation (e.g. SWAR)
To generate a bit mask of `0x8080...` of the word size, we prepare
`MASK01` which is `0x0101...` and multiply masking word (e.g., `0x80).
2024-05-25 16:39:32 +09:00
Yukihiro "Matz" Matsumoto bff68cbf17 mruby-socket (inet_ntop): refactor addrinfo loop 2024-05-25 16:39:31 +09:00
Yukihiro "Matz" Matsumoto 4e824048c0 mruby-socket: adjust local variable declarations 2024-05-25 16:39:31 +09:00
Yukihiro "Matz" Matsumoto bd7efbe75f string.c: check if the index points character boundary; fix #6267 2024-05-25 16:39:31 +09:00
dearblue b12ea17d0b Improvements to mrb_protect_atexit()
- Initialize the GC arena each time `atexit` is called.
  - To reduce the overhead of `MRB_TRY()`, an internal loop is also performed.
2024-05-25 10:48:16 +09:00
Yukihiro "Matz" Matsumoto f2e1cf2d3c Merge pull request #6272 from mruby/dependabot/github_actions/super-linter/super-linter-6.5.1
build(deps): bump super-linter/super-linter from 6.5.0 to 6.5.1
2024-05-25 07:57:55 +09:00
dependabot[bot] ccc34c37b9 build(deps): bump super-linter/super-linter from 6.5.0 to 6.5.1
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 6.5.0 to 6.5.1.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/CHANGELOG.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v6.5.0...v6.5.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-24 14:22:15 +00:00
Yukihiro "Matz" Matsumoto 86f620822f Merge pull request #6269 from mruby/dependabot/github_actions/super-linter/super-linter-6.5.0
build(deps): bump super-linter/super-linter from 6.4.1 to 6.5.0
2024-05-16 07:09:41 +09:00
Yukihiro "Matz" Matsumoto c635456f16 mruby-dir: fix indentation 2024-05-16 07:06:59 +09:00
dependabot[bot] e36f0fd266 build(deps): bump super-linter/super-linter from 6.4.1 to 6.5.0
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 6.4.1 to 6.5.0.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/CHANGELOG.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v6.4.1...v6.5.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-15 14:28:17 +00:00
Yukihiro "Matz" Matsumoto 156c7ecae3 Merge pull request #6266 from dearblue/array-delete
Passes the nonexistent key as a block argument in `Array#delete`
2024-05-14 09:49:36 +09:00
Yukihiro "Matz" Matsumoto 7865593823 mruby-dir: enumerating methods should return enumerators; #6265 2024-05-14 09:42:38 +09:00
Yukihiro "Matz" Matsumoto dd552cee13 Merge pull request #6265 from dearblue/dir-children
Fixes `Dir.children` and `Dir.each_child`
2024-05-14 09:32:51 +09:00
Yukihiro "Matz" Matsumoto 169114666a mruby-io: fix Win32 declaration bugs 2024-05-14 01:34:43 +09:00
Yukihiro "Matz" Matsumoto a147b2c149 Merge pull request #6264 from dearblue/to_enum
Must pass keyword arguments for `Kernel#to_enum`
2024-05-14 01:28:14 +09:00
Yukihiro "Matz" Matsumoto 37e7c071c2 mruby-io: adjust local variable declarations 2024-05-14 01:22:04 +09:00
Yukihiro "Matz" Matsumoto ae6e5b7b5e mruby-method: adjust local variable declaration place 2024-05-13 23:37:21 +09:00
Yukihiro "Matz" Matsumoto 7dee66c5db mruby-fiber: adjust local variable declaration places 2024-05-12 20:34:25 +09:00
dearblue f0cd35c78b Passes the nonexistent key as a block argument in Array#delete
```ruby
a = %w(R G B A)
p a.delete("Y") { _1 }
# BEFORE => nil (same for mruby 3.3)
# AFTER  => "Y" (same for CRuby)
```
2024-05-10 22:46:11 +09:00
dearblue c753ca33d0 Add test for Array#delete 2024-05-10 22:35:13 +09:00
dearblue 12030b3f41 Fixes Dir.children and Dir.each_child
The two methods exclude "." and "..".
2024-05-10 21:54:59 +09:00
dearblue a06e2484e6 Must pass keyword arguments for Kernel#to_enum 2024-05-10 21:50:51 +09:00
Yukihiro "Matz" Matsumoto dcee404ebb mruby-hash-ext: use NONE.equal?() for NONE comparison; ref #6262 2024-05-10 20:40:11 +09:00
Yukihiro "Matz" Matsumoto 4d7ad4863f mruby-enumerator: use NONE.equal?() for NONE comparison; ref #6262 2024-05-10 20:40:11 +09:00
Yukihiro "Matz" Matsumoto 1f80b875c4 mruby-enum-ext: use NONE.equal?() for NONE comparison; ref #6262 2024-05-10 20:40:11 +09:00
Yukihiro "Matz" Matsumoto db30b0636f mruby-array-ext: use NONE.equal?() for NONE comparison; fix #6262
The equal (`==`) method of the comparison target might be redefined
(the root cause of #6262), and not supposed to be compared with NONE.
To reduce chance for the problem, we use `NONE.equal?()` for comparison.
2024-05-10 20:37:01 +09:00
Yukihiro "Matz" Matsumoto 058a4ab5c6 Merge pull request #6263 from leviongit:array/delete
fix: `Array#delete` mistakingly calling block even if not passed
2024-05-10 12:11:53 +09:00
leviongit 67df0aca67 fix: Array#delete mistakingly calling block even if not passed 2024-05-09 14:33:23 +02:00
Yukihiro "Matz" Matsumoto 19d9f48f7d mruby-sleep: update MIT license URL 2024-05-09 17:08:27 +09:00
Yukihiro "Matz" Matsumoto aac9e4cf0d Merge pull request #6261 from leviongit/range/to_a
fix: `to_a` integer ranges with `begin > end` failing
2024-05-09 17:07:51 +09:00
leviongit fff07ca182 fix: to_a integer ranges with begin > end failing
example of failure:
```rb
(-1..-4).to_a
```

expected result:
```rb
(-1..-4).to_a
```
2024-05-08 23:10:28 +02:00
Yukihiro "Matz" Matsumoto 06480f7147 mruby-string-ext: move local variable declarations 2024-05-08 11:29:20 +09:00
Yukihiro "Matz" Matsumoto cf785a6133 mruby-random: move variable declarations to initialization 2024-05-07 17:57:41 +09:00
Yukihiro "Matz" Matsumoto f975794f19 Merge pull request #6260 from dearblue/mrb_vm_exec-exception
Remove `exc_caught` from `mrb_vm_exec()`
2024-05-06 22:55:07 +09:00
dearblue dea5c9e1dc Remove exc_caught from mrb_vm_exec()
Only go to exception handling if `mrb->exc` is non-null.

This may cause some compatibility problems, but I doubt that it is necessary to maintain that compatibility.
Here is how I see the incompatibility with the change at this time:
  - If `mrb->exc` is non-null and `mrb_vm_exec()` is called, an exception will be thrown immediately.
  - If `MRB_THROW()` is used while `mrb->exc` is `NULL`, it will not go to exception handling.
2024-05-05 21:30:18 +09:00
Yukihiro "Matz" Matsumoto 1e61a875ed mruby-data: adjust local variable declarations 2024-05-05 18:56:20 +09:00
Yukihiro "Matz" Matsumoto 0a61a9a76f mruby-struct: adjust local variable declarations 2024-05-05 18:55:42 +09:00
Yukihiro "Matz" Matsumoto c548943a2b mruby-symbol-ext: adjust local variable declarations 2024-05-04 08:30:53 +09:00
Yukihiro "Matz" Matsumoto 86b1c8ff87 string.c (utf8_strlen): add assertion utf8_len <= byte_len 2024-05-03 07:50:40 +09:00
Yukihiro "Matz" Matsumoto aea3e7aedd mruby-sprintf: raise ArgumentError for % at the bottom 2024-05-03 07:46:45 +09:00
Yukihiro "Matz" Matsumoto 4801a424a3 mruby-time: adjust local variable declarations 2024-05-02 19:55:29 +09:00
Yukihiro "Matz" Matsumoto c5314a29b7 mruby-test: move declarations in driver.c and vformat.c 2024-05-01 13:24:32 +09:00
Yukihiro "Matz" Matsumoto 2c8cde2ba7 codedump.c: move variable declarations to initialization place 2024-04-30 22:17:22 +09:00
Yukihiro "Matz" Matsumoto fa213a2d89 string.c (search_nonascii): prevent buffer overrun; ref #6255 2024-04-29 16:35:08 +09:00
Yukihiro "Matz" Matsumoto 714ef4c4fd string.c (mrb_utf8_strlen): handle invalid UTF-8 sequence; fix #6255
Previous SWAR version assumes valid UTF-8 to count number of code points
in the string, but we need to handle invalid sequence as well. We now
use `search_nonascii` to skip counting single byte characters for
performance. The new version is even faster than SWAR version (probably
because `search_nonascii` uses SSE2 on Intel compatible CPU (which I use).
2024-04-29 15:37:22 +09:00
Yukihiro "Matz" Matsumoto c9ae8df2c2 error.c: move variable declaration to initialization 2024-04-29 14:42:49 +09:00
Yukihiro "Matz" Matsumoto 7cea1cd035 Merge pull request #6256 from dearblue/doc/mrb_top_run
Update documentation for `mrb_top_run()`
2024-04-27 14:57:03 +09:00
Yukihiro "Matz" Matsumoto 09896099ee Merge pull request #6257 from jethrodaniel/tiny-mrbconf-doc-updates
fix some mrbconf.md typos
2024-04-27 14:41:50 +09:00
Mark Delk b99536f1fc rm unneeded MRB_NO_GEMS doc addition 2024-04-26 23:33:16 -05:00
Mark Delk f78eab7c3f fix some typos, mention MRB_NO_GEMS 2024-04-26 19:54:07 -05:00
Yukihiro "Matz" Matsumoto 598dca7a08 debug.c: move local variable declarations to initialization place 2024-04-27 08:40:36 +09:00
dearblue a0526418ce Update documentation for mrb_top_run()
Also, add explanations for the `mrb_load_irep()` and `mrb_load_string()` families, which are indirect calls to `mrb_top_run()`.
2024-04-26 22:05:45 +09:00
Yukihiro "Matz" Matsumoto 7edbff8c83 Merge pull request #6253 from dearblue/fiber-sweep
Allow recycling fibers by GC if not referenced directly
2024-04-25 11:34:08 +09:00
Yukihiro "Matz" Matsumoto 22518b5b78 Merge pull request #6244 from dearblue/mrb_vm_run
Revise scope of role of `mrb_vm_run()`
2024-04-24 08:45:29 +09:00
dearblue f1c9260ada Allow recycling fibers by GC if not referenced directly
The patch assumes that `struct REnv::cxt` only performs checks with the `OP_BREAK` and `OP_RETURN_BLK` instructions, and does not reference the entity.
Therefore, by changing to a weak reference, it is possible to collect fibers that are no longer directly referenced while in the suspended state.

However, we need to detach the living env objects that remain in the call stack of the fiber.
So, in effect, it involves a revert of following commits.
  - commit a3365d8b3f
  - commit 57ffa1c150

Examples of the effects of change are shown below.
Note that it was built with `rake MRUBY_CONFIG=host-debug`.

```ruby
f = Fiber.new { (x, y, z) = "X", "Y", "Z"; Fiber.yield -> { [x, y, z] } }
g = f.resume
GC.start
p ObjectSpace.memsize_of_all
# => 59532
g.call
# => ["X", "Y", "Z"]
f = nil
GC.start
ObjectSpace.memsize_of_all
# BEFORE => 59532
# AFTER  => 58044
g.call
# => ["X", "Y", "Z"]
```
2024-04-23 22:30:32 +09:00
dearblue c8c7d1ab23 Don't mrb_realloc_simple() call mrb_full_gc() in the sweep phase
`mrb_env_unshare()` calls `mrb_realloc_simple()` and follows `mrb_full_gc()` to avoid an infinite loop where `mrb_env_unshare()` is called again.
This does not occur at this time, but may occur in subsequent patches.
2024-04-23 22:25:54 +09:00
Yukihiro "Matz" Matsumoto 85120d524a Merge pull request #6250 from jbampton/fix-spelling
Fix spelling
2024-04-23 00:21:59 +09:00
Yukihiro "Matz" Matsumoto 3d32bc11ef Merge pull request #6252 from mruby/dependabot/github_actions/super-linter/super-linter-6.4.1
build(deps): bump super-linter/super-linter from 6.4.0 to 6.4.1
2024-04-23 00:20:28 +09:00
Yukihiro "Matz" Matsumoto 2e4dc20673 Merge pull request #6251 from jbampton/clean-up-root-move-codeowners
Clean up root move `CODEOWNERS` to `.github` directory
2024-04-23 00:18:03 +09:00
dependabot[bot] 2fc2c20155 build(deps): bump super-linter/super-linter from 6.4.0 to 6.4.1
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 6.4.0 to 6.4.1.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/CHANGELOG.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v6.4.0...v6.4.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-22 14:37:45 +00:00
John Bampton 5c39e39b8a Clean up root move CODEOWNERS to .github directory
https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#codeowners-file-location
2024-04-22 20:41:41 +10:00
John Bampton 67c5ced277 Fix spelling 2024-04-22 18:00:27 +10:00
Yukihiro "Matz" Matsumoto ca29aa81bd Merge pull request #6247 from jbampton/clean-up-dockerignore
Clean up the `.dockerignore` file
2024-04-22 09:49:52 +09:00
Yukihiro "Matz" Matsumoto 34c8e8253a Merge pull request #6249 from jbampton/fix-grammar
Fix grammar in `src/vm.c`; `catched` -> `caught`
2024-04-22 09:49:19 +09:00
Yukihiro "Matz" Matsumoto 9c2fa6239e Merge pull request #6248 from jbampton/pre-commit-autoupdate
pre-commit autoupdate
2024-04-22 09:47:53 +09:00
Yukihiro "Matz" Matsumoto 87b756086f Merge pull request #6246 from jbampton/fix-spelling
Fix typo in `test/t/hash.rb`
2024-04-22 09:47:22 +09:00
Yukihiro "Matz" Matsumoto 5661cf6939 Merge pull request #6245 from jbampton/gha-label-more-files
gha: add labels to more files
2024-04-22 09:46:58 +09:00
John Bampton f9c2ea2f11 Fix grammar in src/vm.c; catched -> caught
Saying 'catched' instead of 'caught' is a grammatical error
2024-04-22 00:01:21 +10:00
John Bampton fef91724cb pre-commit autoupdate
https://pre-commit.com/#pre-commit-autoupdate
2024-04-21 23:21:46 +10:00
John Bampton 7e8ec85f6b Clean up the .dockerignore file 2024-04-21 22:46:19 +10:00
John Bampton 983a13f342 Fix typo in test/t/hash.rb 2024-04-21 22:21:57 +10:00
John Bampton b71092d440 gha: add labels to more files 2024-04-21 21:32:03 +10:00
dearblue 5aa20f41ef Revise scope of role of mrb_vm_run()
`mrb_vm_run()` is,
  - It does not change the fiber context.
  - When control is returned, only one ci prepared by the caller is popped.
    If the ci equals cibase when called, the ci position does not change.

related commits:
  - commit 4e84bdb507
  - commit 34dd258c63
  - commit ebd6636a1e
  - commit c6736357a7
  - commit 23a4e7149d
  - commit 31a961acf1
2024-04-21 13:30:24 +09:00
Yukihiro "Matz" Matsumoto ad476c3684 Merge pull request #6243 from dearblue/base64 2024-04-21 08:25:56 +09:00
dearblue 6c2f570d79 Fixed base64 decoding in mruby-pack
Previously `\x80` was incorrectly mapped to `0`.

```ruby
"\x80\x80\x80\x80".unpack("m*")
# before => "\x00\x00\x00"
# after  => ""
```

The reason is that the C string terminator is placed in `base64_dec_tab[128]` and the array length is obtained by `sizeof`.
Therefore, the length of `base64_dec_tab[]` is strictly specified and replaced with element-by-element initialization.

Also, similar changes are made to `base64chars[]`.
2024-04-20 09:56:08 +09:00
Yukihiro "Matz" Matsumoto 4a27a18807 dump.c: adjust local variable declarations 2024-04-20 09:54:55 +09:00
Yukihiro "Matz" Matsumoto c445723fa4 enum.c: adjust local variable declaration 2024-04-19 16:20:36 +09:00
Yukihiro "Matz" Matsumoto 8350106896 etc.c: adjust local variable initializations 2024-04-18 15:49:19 +09:00
Yukihiro "Matz" Matsumoto ca26f41b57 mruby-sprintf: remove unnecessary assignment 2024-04-18 15:48:45 +09:00
Yukihiro "Matz" Matsumoto e52b608ed9 Merge pull request #6241 from mruby/dependabot/github_actions/super-linter/super-linter-6.4.0
build(deps): bump super-linter/super-linter from 6.3.1 to 6.4.0
2024-04-18 07:53:16 +09:00
dependabot[bot] e2f7c5daff build(deps): bump super-linter/super-linter from 6.3.1 to 6.4.0
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 6.3.1 to 6.4.0.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/CHANGELOG.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v6.3.1...v6.4.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-17 14:28:32 +00:00
Yukihiro "Matz" Matsumoto c01899a8d3 Merge pull request #6235 from leviongit/array/delete
fix `Array#delete` always firing the block when deleting `nil`
2024-04-16 07:35:59 +09:00
Yukihiro "Matz" Matsumoto aec67dcd17 Merge pull request #6237 from dearblue/env-strict
Stricter env objects to attach to ci
2024-04-15 13:59:32 +09:00
Yukihiro "Matz" Matsumoto 93c02e96d5 Merge pull request #6238 from dearblue/init-stack
Minimize zero initialization of the stack
2024-04-15 13:59:14 +09:00
Yukihiro "Matz" Matsumoto c183e12d68 Merge pull request #6236 from leviongit/array/filters
unify the code for filter methods (and speed up `#reject!`)
2024-04-15 00:05:12 +09:00
Yukihiro "Matz" Matsumoto bc8b76a7a5 cdump.c: adjust local variable declarations 2024-04-15 00:01:11 +09:00
dearblue a4b57aa47b Minimize zero initialization of the stack 2024-04-13 22:22:39 +09:00
dearblue e3d51497cf Stricter env objects to attach to ci
- Don't create multiple envs on one ci.
  - Don't share a env to different ci.
  - Don't attach a closed env to any ci.

Changes in `envadjust()` can be simplified with those guarantees.
2024-04-13 22:13:04 +09:00
Yukihiro "Matz" Matsumoto 3174488851 backtrace.c: remove uninitialized local variable declaration 2024-04-13 16:17:47 +09:00
leviongit 81bb520919 unify the code for filter methods (and speed up #reject!)
the worst case for `Array#reject!` (i.e. a proc always returning `true`)
is at least 5x worse than the worst case for `Array#select!` (proc
always returning `false`)

this commit unifies these implementations and inlines the (effective)
call of `#select!` in `#keep_if` and `#reject!` in `#delete_if`
2024-04-13 08:53:32 +02:00
leviongit bb78c2cbc9 reimplement Array#delete with a helper method 2024-04-13 07:41:00 +02:00
leviongit 312d49c59f reimplement Array#delete in ruby 2024-04-13 07:21:51 +02:00
leviongit c04afb9e99 revert moving Array#delete to c 2024-04-13 06:52:37 +02:00
leviongit d46e9a9480 fix shared array mistake 2024-04-12 18:12:51 +02:00
leviongit 14bd875d70 fix Array#delete
reimplement `Array#delete` in c, fixing `ary.delete(nil, &blk)` firing the block regardless of removal

minimal reproduction:
```rb
ary = [nil]
ret = ary.delete(nil) { "not deleted?" }
```
2024-04-12 17:30:03 +02:00
Yukihiro "Matz" Matsumoto f30e8240d2 array.c: adjust local variable declarations 2024-04-12 18:07:51 +09:00
Yukihiro "Matz" Matsumoto d761561be3 Merge pull request #6233 from dearblue/fiber-end-free
Free stack memory at end of fiber
2024-04-11 23:31:54 +09:00
Yukihiro "Matz" Matsumoto 1c021a5c3a hash.c (obj_eql): simplify the expression 2024-04-11 15:39:45 +09:00
Yukihiro "Matz" Matsumoto 492d8331e1 mruby-io/ext/io.h: reorder struct mrb_io to reduce the size; #6231
The `sizeof(struct mrb_io)` is reduced from 32 bytes to 24 bytes on
x86_64-linux.
2024-04-10 13:35:03 +09:00
Yukihiro "Matz" Matsumoto 0ad669eb80 Merge pull request #6231 from Asmod4n/add_close_fd_to_io
Add a way to let other gems handle closing of fds in mruby-io
2024-04-10 13:29:20 +09:00
Yukihiro "Matz" Matsumoto 6c4f5a34cc Revert "object.c (mrb_eql): avoid mrb_funcall_argv() when possible"
This reverts commit bc012deef9.
Ref #6168
2024-04-10 13:28:28 +09:00
dearblue f3b393272c Free stack memory at end of fiber
Immediately frees the call stack and data stack at the end of a non-root fiber.
If the env object needs to be detached, the data stack is reused through `mrb_realloc()`.

Previously, it was not necessary to take into account that `c->cibase` could be `NULL`.
Note that this is no longer the case due to this patch.
In fact, changes to "mruby-fiber" are now required.
2024-04-09 21:13:32 +09:00
Yukihiro "Matz" Matsumoto 7403cb57ac AUTHORS: update entries [ci skip]
From now on, we exclude merge commits (add `--no-merges` option to
`git shortlog` command in the counting script) to count contribution
fairly.
2024-04-09 08:03:50 +09:00
Yukihiro "Matz" Matsumoto 3ce5f3acbc Merge pull request #6232 from dearblue/free-env
Fold the code for freeing `env`
2024-04-08 23:37:24 +09:00
Yukihiro "Matz" Matsumoto 6eeb06795f Merge pull request #6230 from dearblue/fiber-err-switch
Fix status of fiber after switched by exception raised
2024-04-08 23:37:09 +09:00
Yukihiro "Matz" Matsumoto f3f7df0da0 vm.c: update ci after switching context
0614a1 removed too much `ci` updates, as @dearblue pointed out.
2024-04-08 08:38:23 +09:00
Asmod4n 96b5cd757d Add a way to let other gems handle closing of FDs 2024-04-07 13:46:11 +02:00
dearblue 1a9282914e Fold the code for freeing env
Also, `e->stack = NULL` is not needed.
This is because "use-after-free" can be detected with `MRB_DEBUG` + `MRB_GC_STRESS`.
2024-04-07 20:45:10 +09:00
dearblue 4956584ff1 Fix status of fiber after switched by exception raised
The state of a fiber switched due to an exception occurrence was incorrectly set to "Suspended".

```ruby
Fiber.new {
  begin
    Fiber.new { 0 / 0 }.resume
  rescue
    p Fiber.current
    # before  => #<Fiber:0x159f61e43ce0 fiber.rb:1 (suspended by resuming)>
    # after   => #<Fiber:0x159f61e43ce0 fiber.rb:1 (resumed)>
  end
}.resume
```
2024-04-07 20:08:12 +09:00
dearblue 307812ff20 Revert "env referred from top-level callinfo should not be unshared; fix #4019"
This reverts commit 72581696d3.

The #4012 that may have been the trigger for issue #4019 was later reverted by #4039 due to issue #4021.
2024-04-06 08:59:51 +09:00
Yukihiro "Matz" Matsumoto d503d9b113 Merge pull request #6229 from mruby/dependabot/bundler/rake-13.2.1
build(deps): bump rake from 13.2.0 to 13.2.1
2024-04-06 08:51:07 +09:00
dependabot[bot] b174ea5847 build(deps): bump rake from 13.2.0 to 13.2.1
Bumps [rake](https://github.com/ruby/rake) from 13.2.0 to 13.2.1.
- [Release notes](https://github.com/ruby/rake/releases)
- [Changelog](https://github.com/ruby/rake/blob/master/History.rdoc)
- [Commits](https://github.com/ruby/rake/compare/v13.2.0...v13.2.1)

---
updated-dependencies:
- dependency-name: rake
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-05 14:52:46 +00:00
Yukihiro "Matz" Matsumoto 47642f70cb Merge pull request #6227 from leviongit/array/shuffle_b
fix: `Array#shuffle(!)` result distribution
2024-04-05 08:33:04 +09:00
Yukihiro "Matz" Matsumoto 88792e0d9a Merge pull request #6226 from mruby/dependabot/github_actions/super-linter/super-linter-6.3.1
build(deps): bump super-linter/super-linter from 6.3.0 to 6.3.1
2024-04-05 08:19:12 +09:00
leviongit ad62d7809e fix: Array#shuffle(!) result distribution 2024-04-04 20:36:44 +02:00
dependabot[bot] e610322a47 build(deps): bump super-linter/super-linter from 6.3.0 to 6.3.1
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 6.3.0 to 6.3.1.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/CHANGELOG.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v6.3.0...v6.3.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-04 14:33:40 +00:00
Yukihiro "Matz" Matsumoto d3e4450917 Merge pull request #6225 from dearblue/revert-3991
Revert "Adjust environment when `mrb_exec_irep` happened."
2024-04-04 08:19:57 +09:00
Yukihiro "Matz" Matsumoto d8a3406132 Merge pull request #6224 from dearblue/orphan-env
`mrb_env_unshare()` to break the link to fiber
2024-04-04 08:19:08 +09:00
Yukihiro "Matz" Matsumoto c42f4e1d2c Merge pull request #6191 from leviongit/sym-eql
Speed up symbol equality comparison
2024-04-04 07:35:54 +09:00
dearblue 28d31262e5 Revert "Adjust environment when mrb_exec_irep happened."
This reverts commit 26e436e247.

After investigation, it is possible to revert by commit e89cc9b9fa.

The build configuration file used in the investigation is shown below.

```ruby
MRuby::Build.new do |conf|
  toolchain :clang

  enable_debug
  enable_bintest
  enable_test

  cc.command = "clang18"
  linker.command = "clang18"

  [cc, cxx].each { |c| c.defines << "MRB_GC_STRESS" }
  [cc, cxx, linker].each { |cmd| cmd.flags << %w(-fsanitize=address) }

  gem github: "iij/mruby-dir"       # rev: "89dceefa1250fb1ae868d4cb52498e9e24293cd1"
  gem github: "iij/mruby-env"       # rev: "056ae324451ef16a50c7887e117f0ea30921b71b"
  gem github: "iij/mruby-errno"     # rev: "b4415207ff6ea62360619c89a1cff83259dc4db0"
  gem github: "iij/mruby-require"   # rev: "f0634d785e5cbb73cd7d118ee36deff499e4181e"
  gem github: "iij/mruby-tempfile"  # rev: "9b883438547020dae328e34c8a2fe736171cd0ab"
end
```

Since the `rake` command needs to be from the past, we used the Ruby 2.6 version.
2024-04-03 22:04:25 +09:00
dearblue 96d56debc7 mrb_env_unshare() to break the link to fiber
Currently `e->cxt` is used exclusively to check for `break` / `return` availability.
In other words, there is no need to maintain a reference to a fiber that has reached its end.
2024-04-03 21:54:53 +09:00
Yukihiro "Matz" Matsumoto 88004e44af Merge pull request #6223 from mruby/dependabot/bundler/rake-13.2.0
build(deps): bump rake from 13.1.0 to 13.2.0
2024-04-03 08:15:45 +09:00
dependabot[bot] bb7370b59a build(deps): bump rake from 13.1.0 to 13.2.0
Bumps [rake](https://github.com/ruby/rake) from 13.1.0 to 13.2.0.
- [Release notes](https://github.com/ruby/rake/releases)
- [Changelog](https://github.com/ruby/rake/blob/master/History.rdoc)
- [Commits](https://github.com/ruby/rake/compare/v13.1.0...v13.2.0)

---
updated-dependencies:
- dependency-name: rake
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-02 14:38:41 +00:00
Yukihiro "Matz" Matsumoto aa28f48c3b string.c (search_nonascii): simplify fallback implementation by SWAR 2024-04-02 19:50:13 +09:00
Yukihiro "Matz" Matsumoto 898d1ff11e proc.h: simplify method macros; ref #6220
- MRB_METHOD_CFUNC_P: reduce ternary; use logical-or instead
- MRB_METHOD_CFUNC: assume MRB_METHOD_CFUNC_P check before call
2024-04-01 07:33:28 +09:00
Yukihiro "Matz" Matsumoto 4982999e07 Merge pull request #6221 from dearblue/arrange-each_backtrace
Arranging `each_backtrace()`
2024-03-31 21:44:56 +09:00
Yukihiro "Matz" Matsumoto 586ce04cee Merge pull request #6222 from dearblue/sync-regs
Need to synchronize `dbg->regs` after VM call in `mrdb`
2024-03-31 21:41:16 +09:00
Yukihiro "Matz" Matsumoto 423026353d Merge pull request #6220 from dearblue/methodcache
Reorganize `mrb_cache_entry` and `mrb_method_t` types
2024-03-31 21:36:19 +09:00
dearblue 8dfebe8d12 Need to synchronize dbg->regs after VM call in mrdb
VM inrush could invalidate addresses stored in `dbg->regs` by `stack_extend()`.
2024-03-31 11:53:09 +09:00
dearblue 9b8b864be1 Arranging each_backtrace()
Highlights are:
  - `Integrate the blocks `if (!ci->proc || MRB_PROC_CFUNC_P(ci->proc))` and `if (loc.irep == NULL)`.
  - Folding some other conditionals.
  - Assertions ensure that procs are not aliases.
2024-03-31 09:53:16 +09:00
Yukihiro "Matz" Matsumoto 2fbd49903b LEGAL: update memsearch_swar description 2024-03-30 23:06:03 +09:00
Yukihiro "Matz" Matsumoto cbb31e6a7c string.c (mrb_utf8_strlen): use SWAR technique for performance 2024-03-30 22:50:12 +09:00
dearblue 328eb71e52 Reorganize mrb_cache_entry and mrb_method_t types
The purpose is to remove the `mid` field from the `mrb_cache_entry` structure.
The resulting RAM requirement for the method cache is reduced from 5 words per entry to 4 words per entry for 32-bit CPUs.

The relevant changes are as follows:

  - Removed `MRB_USE_METHOD_T_STRUCT`.

    The `mrb_method_t` type is now always defined as a structure.

  - Include method IDs in `mrb_method_t`

    Change the `flags` member to `uint32_t`.
    The bitstring structure should be the same as the keys of the `mt` table in `class.c`.

I believe the impact on API compatibility with previous versions is minimal.
2024-03-30 18:19:26 +09:00
Yukihiro "Matz" Matsumoto 61b1a4db8e Merge pull request #6219 from dearblue/fixed-to-out
Avoid assigning a fixed value in the loop
2024-03-29 23:55:05 +09:00
Yukihiro "Matz" Matsumoto 27061e4d58 Merge pull request #6216 from dearblue/shared-class-iv
Shared empty `iv_tbl` of module
2024-03-29 23:12:32 +09:00
dearblue 3d91ae28f5 Avoid assigning a fixed value in the loop 2024-03-29 22:26:46 +09:00
Yukihiro "Matz" Matsumoto f0614a1e0c vm.c: remove unnecessary update of ci local variable 2024-03-29 21:22:37 +09:00
Yukihiro "Matz" Matsumoto f54ff74f9b vm.c: add volatile to a variable across setjmp/longjmp 2024-03-29 21:22:37 +09:00
Yukihiro "Matz" Matsumoto c54bf673a9 vm.c: remove unused initializations 2024-03-29 21:22:36 +09:00
Yukihiro "Matz" Matsumoto 5b133e42cc Merge pull request #6217 from dearblue/mrb_istruct_size
Strict declaration for `mrb_istruct_size()`
2024-03-28 15:29:25 +09:00
dearblue 1c1c67b878 Strict declaration for mrb_istruct_size()
In C, `void` is required if there are no parameters.
2024-03-27 22:01:18 +09:00
dearblue f1c0752ab8 Shared empty iv_tbl of module
This will be a partial merge of #5317 with the following changes.

- Remove `iclass->iv_c` since `iclass->iv_c` is equivalent to `iclass->c`.
- `class_iv_ptr()` returns a single pointer instead of a double pointer.
2024-03-27 21:39:32 +09:00
Yukihiro "Matz" Matsumoto ef94bfc2e6 proc.c (closure_setup): fix NULL check logic
It used to check ci to be non NULL in line 37, but we silently assumed
ci was not NULL in the `else` clause too. So instead of checking NULL,
we add assertion. This incomplete check was found by clang-tidy.
2024-03-26 14:00:00 +09:00
Yukihiro "Matz" Matsumoto b42b8480d1 vm.c: adjust spacing 2024-03-26 14:00:00 +09:00
Yukihiro "Matz" Matsumoto a97c27358e class.c (prepare_name_common): remove unnecessary pointer update 2024-03-26 14:00:00 +09:00
Yukihiro "Matz" Matsumoto 07f9f9b4be gc.c (mrb_alloca): add const modifier 2024-03-26 13:59:59 +09:00
Yukihiro "Matz" Matsumoto 87b358a342 Including header files in include/* by <> 2024-03-26 13:59:59 +09:00
Yukihiro "Matz" Matsumoto 0786b24528 proc.h: stop including khash.h which is no longer used
Instead, we need to include <string.h> explicitly.
2024-03-26 13:59:59 +09:00
Yukihiro "Matz" Matsumoto 81e8617d02 mruby-metaprog: explicitly include khash.h which was included from proc.h 2024-03-26 13:59:59 +09:00
Yukihiro "Matz" Matsumoto a8977f713d class.c,variable.c: use mrb_int_hash_func instead of kh_ version 2024-03-26 13:59:59 +09:00
Yukihiro "Matz" Matsumoto 96fa3461f0 mruby.h: move integer hash function from khash.h 2024-03-26 13:59:58 +09:00
Yukihiro "Matz" Matsumoto 3ccc98fa32 Merge pull request #6215 from mruby/dependabot/bundler/rake-13.1.0
build(deps): bump rake from 13.0.6 to 13.1.0
2024-03-26 12:05:29 +09:00
dependabot[bot] 86155d8ab4 build(deps): bump rake from 13.0.6 to 13.1.0
Bumps [rake](https://github.com/ruby/rake) from 13.0.6 to 13.1.0.
- [Release notes](https://github.com/ruby/rake/releases)
- [Changelog](https://github.com/ruby/rake/blob/master/History.rdoc)
- [Commits](https://github.com/ruby/rake/compare/v13.0.6...v13.1.0)

---
updated-dependencies:
- dependency-name: rake
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-26 02:12:45 +00:00
Yukihiro "Matz" Matsumoto a7aa7a8772 Merge pull request #6205 from jbampton/gha-label-more-files
GitHub labeler: label more files
2024-03-26 11:12:40 +09:00
Yukihiro "Matz" Matsumoto 24c60895cd Merge pull request #6214 from jbampton/add-more-comments
Improve the `pre-commit` and `.github` YAML files
2024-03-26 11:12:06 +09:00
Yukihiro "Matz" Matsumoto 4cdbddb3b0 Merge pull request #6213 from jbampton/add-pre-commit-hook-destroyed-symlinks
Add `pre-commit` hook `destroyed-symlinks`
2024-03-26 11:11:06 +09:00
John Bampton e26d33caf5 GitHub labeler: label more files
These are some of the config files for the linters/tests that run
2024-03-24 04:36:09 +10:00
John Bampton cc6d25dc29 Improve the pre-commit and .github YAML files 2024-03-23 22:46:19 +10:00
John Bampton 2e9f79409a Add pre-commit hook destroyed-symlinks
https://github.com/pre-commit/pre-commit-hooks?tab=readme-ov-file#destroyed-symlinks

Another check or test we can have
2024-03-23 20:46:11 +10:00
Yukihiro "Matz" Matsumoto a810b9bca8 mruby-compiler/codegen.c: stop too aggressive optimization; fix #6210
The old code assumes unary minus (`-@`) does not cause any side effect
(including errors). Considering the code like `-nil; nil`, the
assumption was too aggressive.
2024-03-19 13:38:05 +09:00
Yukihiro "Matz" Matsumoto 7404fab8fb Merge pull request #6211 from jbampton/clean-up-git-ignore
Minor `.gitignore` clean up; order entries
2024-03-19 13:13:38 +09:00
John Bampton 0541713b6b Minor .gitignore clean up; order entries 2024-03-19 12:51:37 +10:00
Yukihiro "Matz" Matsumoto 07fd080321 Merge pull request #6208 from jbampton/clean-up-the-pre-commit-config
Clean up the `pre-commit` config
2024-03-18 14:57:32 +09:00
Yukihiro "Matz" Matsumoto 35cf1abd4e Merge pull request #6209 from jbampton/clean-up-gitignore
Minor `.gitignore` clean up
2024-03-17 23:57:33 +09:00
John Bampton 7ac2773a84 Minor .gitignore clean up 2024-03-16 20:40:49 +10:00
John Bampton f18d8888ba Clean up the pre-commit config
Removal of unneeded files / file types

Clean up the repo root folder by moving `codespell.txt`
2024-03-16 20:03:21 +10:00
Yukihiro "Matz" Matsumoto 4da5d025d3 Merge pull request #6206 from dearblue/table-expansion
Simplify expansion of mt and iv a bit
2024-03-16 08:17:42 +09:00
Yukihiro "Matz" Matsumoto eb57432d03 Bump yard from 0.9.28 to 0.9.36 2024-03-15 23:52:00 +09:00
Yukihiro "Matz" Matsumoto 53c38db2fc Merge pull request #6200 from jbampton/super-linter-validate-dockerfile
super-linter: validate the `Dockerfile` with `hadolint`
2024-03-15 23:38:22 +09:00
Yukihiro "Matz" Matsumoto b913824d47 range.c (mrb_gc_mark_range): return size
If not initialized, size is zero, otherwise two.
2024-03-15 23:36:30 +09:00
dearblue 227ebb9daa Simplify expansion of mt and iv a bit 2024-03-14 22:12:35 +09:00
Yukihiro "Matz" Matsumoto f13daee2f5 class.c (mrb_gc_mark_mt_size) unify with mrb_gc_mark_mt 2024-03-14 11:58:00 +09:00
Yukihiro "Matz" Matsumoto 2cb3f1d9e5 hash.c (mrb_gc_mark_hash_size): unify with mrb_gc_mark_hash 2024-03-14 11:52:25 +09:00
Yukihiro "Matz" Matsumoto 63900814b9 variable.c (mrb_gc_mark_iv_size): unify the function with mrb_gc_mark_iv 2024-03-14 11:49:47 +09:00
Yukihiro "Matz" Matsumoto e8525df576 gc.c (gc_gray_counts): unify the function with gc_mark_children
Avoid traversing object repeatedly.
2024-03-14 11:44:06 +09:00
Yukihiro "Matz" Matsumoto 2b597c596c Merge pull request #6180 from jbampton/super-linter-validate-github-actions
super-linter: set `VALIDATE_GITHUB_ACTIONS` to `true`
2024-03-13 10:14:49 +09:00
John Bampton 107b6f7d30 super-linter: set VALIDATE_GITHUB_ACTIONS to true
Flag to enable the linting process of the GitHub Actions.

Another check or test we can have.

https://github.com/super-linter/super-linter?tab=readme-ov-file#configure-super-linter

Lint shell script. Tested with ShellCheck

https://www.shellcheck.net/
2024-03-13 10:37:40 +10:00
Yukihiro "Matz" Matsumoto 9bbefd3979 Merge pull request #6204 from jbampton/editorconfig-clean-up
Clean up the `.editorconfig` file
2024-03-13 09:08:59 +09:00
Yukihiro "Matz" Matsumoto 31d85c20db Merge pull request #6202 from jbampton/clean-yardoc-folder
Remove the `.yardoc` folder with `rake doc:clean:api`
2024-03-13 09:08:07 +09:00
Yukihiro "Matz" Matsumoto ea7c067bd0 Merge pull request #6201 from jbampton/standardize-rake-doc-error-message
tasks/doc.rake: standardize the `rake doc` error messages
2024-03-13 09:07:24 +09:00
Yukihiro "Matz" Matsumoto aa247d3e14 Merge pull request #6199 from jbampton/configure-pre-commit
pre-commit: fix the arguments syntax
2024-03-13 09:06:17 +09:00
Yukihiro "Matz" Matsumoto faf76b6b7f Merge pull request #6198 from mruby/dependabot/github_actions/softprops/action-gh-release-2
build(deps): bump softprops/action-gh-release from 1 to 2
2024-03-12 08:22:37 +09:00
Yukihiro "Matz" Matsumoto 168eb8c267 readint.c (mrb_read_int): narrow scope of a local variable 2024-03-12 08:21:27 +09:00
John Bampton 774ee3c760 Clean up the .editorconfig file 2024-03-12 08:41:33 +10:00
John Bampton 5895e8ebeb Remove the .yardoc folder with rake doc:clean:api 2024-03-12 06:43:35 +10:00
John Bampton d2206cd359 tasks/doc.rake: standardize the rake doc error messages 2024-03-12 05:30:54 +10:00
John Bampton e266ea760f super-linter: validate the Dockerfile with hadolint
https://github.com/super-linter/super-linter?tab=readme-ov-file#configure-super-linter

https://github.com/hadolint/hadolint

https://github.com/hadolint/hadolint?tab=readme-ov-file#configure

https://github.com/hadolint/hadolint/wiki/DL3042
2024-03-12 04:40:27 +10:00
John Bampton 3b3f8b1196 pre-commit: fix the arguments syntax
https://github.com/igorshubovych/markdownlint-cli?tab=readme-ov-file#use-with-pre-commit

https://yamllint.readthedocs.io/en/stable/integration.html#integration-with-pre-commit
2024-03-12 01:55:21 +10:00
dependabot[bot] c56e61ebbd build(deps): bump softprops/action-gh-release from 1 to 2
Bumps [softprops/action-gh-release](https://github.com/softprops/action-gh-release) from 1 to 2.
- [Release notes](https://github.com/softprops/action-gh-release/releases)
- [Changelog](https://github.com/softprops/action-gh-release/blob/master/CHANGELOG.md)
- [Commits](https://github.com/softprops/action-gh-release/compare/v1...v2)

---
updated-dependencies:
- dependency-name: softprops/action-gh-release
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-11 14:43:56 +00:00
Yukihiro "Matz" Matsumoto db8368fa86 numeric.c: remove bit operations methods from Float class; #6197
mruby used to use float numbers for overflown integers before we
implemented big integers. Now we don't need bit operations for float
numbers anymore. Also removed tests for shift operations for float
numbers.
2024-03-11 11:44:41 +09:00
Yukihiro "Matz" Matsumoto 39e3db20af Merge pull request #6197 from niyarin/fix/call-flo_xor
Fix int_xor to call flo_xor.
2024-03-11 11:44:17 +09:00
Yukihiro "Matz" Matsumoto 95765c8193 mruby-time: mrb_time_at is an API function; close #6195
5265e35 was wrong. Should not remove `mrb_` prefix from the function.
2024-03-11 09:48:32 +09:00
niyarin af8e772b9e Fix int_xor to call flo_xor. 2024-03-10 12:13:34 +09:00
leviongit deb133c8ef use a type-check macro instead of mrb_type comparison 2024-03-09 13:56:21 +01:00
leviongit d1b3198109 remove redundant function definition 2024-03-09 13:41:58 +01:00
Yukihiro "Matz" Matsumoto 44edd3438b gc.c: remove unused local variable; ref #6194 2024-03-09 14:29:42 +09:00
Yukihiro "Matz" Matsumoto 4b312bdb2f debug.c: narrow scope of local variables 2024-03-09 14:29:42 +09:00
Yukihiro "Matz" Matsumoto 678bdd2c4b cdump.c (sym_operator_name): narrow scope of local variables 2024-03-09 14:29:42 +09:00
Yukihiro "Matz" Matsumoto 3699f013ac Merge pull request #6193 from dearblue/c-epilogue-assert
Fix wrong assertion in `OP_SENDB`.
2024-03-09 13:23:33 +09:00
Yukihiro "Matz" Matsumoto f1f022bd1a Merge pull request #6194 from dearblue/count-closures
Simplify the calculation of the number of closures in `MRB_TT_FIBER`
2024-03-09 13:22:47 +09:00
Yukihiro "Matz" Matsumoto 6c73defb26 Merge pull request #6192 from dearblue/OP_STOP
Fix `OP_STOP` with exception
2024-03-09 13:21:13 +09:00
dearblue cb36398d30 Simplify the calculation of the number of closures in MRB_TT_FIBER 2024-03-08 22:06:08 +09:00
dearblue 9616971c70 Fix wrong assertion in OP_SENDB.
Assertions were failing on exit if started with `mrb_fiber_resume()`.

The bug that caused it was introduced by commit 42308c42b5 (#6106).
The bug was moved by commit 990e18ad59.
2024-03-08 21:56:00 +09:00
dearblue 4380773666 Fix OP_STOP with exception
Previously, `mrb->exc` would remain replaced by a `break` object if a rewind operation was performed during the processing of a `OP_STOP` instruction.
This problem has existed since #5060, when it was introduced in mruby-3.0.

However, as of mruby-3.0, a manual or third-party generator is required to cause the `OP_STOP` instruction to be issued.
Therefore, it is believed that this has not had an impact until now.
2024-03-08 21:50:46 +09:00
leviongit af06d54843 Speed up symbol equality comparison 2024-03-07 16:22:35 +01:00
Yukihiro "Matz" Matsumoto 9257a61b39 Merge pull request #6137 from dearblue/fiber-unreachable
Remove unreachable blocks in `OP_RETURN`
2024-03-07 16:13:56 +09:00
Yukihiro "Matz" Matsumoto a8694bdefb Merge pull request #6184 from dearblue/L_STOP
Remove the `L_STOP` label
2024-03-06 18:02:34 +09:00
Yukihiro "Matz" Matsumoto 01373a9db0 Merge pull request #6188 from mruby/dependabot/github_actions/super-linter/super-linter-6.3.0
build(deps): bump super-linter/super-linter from 6.2.0 to 6.3.0
2024-03-06 18:01:05 +09:00
Yukihiro "Matz" Matsumoto 130ec9cd90 backtrace.c (mrb_unpack_backtrace): need no NULL check 2024-03-05 12:24:49 +09:00
Yukihiro "Matz" Matsumoto 0ca4ab886f AUTHORS: update entries [ci skip] 2024-03-04 13:01:21 +09:00
Yukihiro "Matz" Matsumoto 439a895f46 symbol.c: use post increment if possible (just style matter) 2024-03-04 13:01:21 +09:00
Yukihiro "Matz" Matsumoto d840274805 symbol.c: narrow scope of local variables 2024-03-04 13:01:20 +09:00
Yukihiro "Matz" Matsumoto aa0cb370a8 kernel.c (mrb_obj_is_instance_of): add const qualifier 2024-03-04 13:01:20 +09:00
Yukihiro "Matz" Matsumoto b023017a0d Merge pull request #6190 from jbampton/label-more-files
Pull Request Labeler: Add labels to more files
2024-03-04 13:01:04 +09:00
Yukihiro "Matz" Matsumoto 861bf778b5 Merge pull request #6189 from jbampton/pre-commit-autoupdate
pre-commit autoupdate
2024-03-04 12:59:42 +09:00
John Bampton 6dd3f27634 Pull Request Labeler: Add labels to more files 2024-03-02 13:51:09 +10:00
John Bampton fc13411c61 pre-commit autoupdate
https://pre-commit.com/#pre-commit-autoupdate
2024-03-02 13:37:00 +10:00
dependabot[bot] 7864112f96 build(deps): bump super-linter/super-linter from 6.2.0 to 6.3.0
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 6.2.0 to 6.3.0.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/CHANGELOG.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v6.2.0...v6.3.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-29 14:35:04 +00:00
Yukihiro "Matz" Matsumoto b0d11ddb4e error.c (mrb_sys_fail): narrow scope of local variables 2024-02-29 19:14:19 +09:00
Yukihiro "Matz" Matsumoto a0d10c0384 pool.c (mrb_pool_close): narrow scope of a local variable 2024-02-29 19:14:19 +09:00
Yukihiro "Matz" Matsumoto 371b13a32e dump.c: inline loop variables (with small refactoring) 2024-02-29 19:14:18 +09:00
Yukihiro "Matz" Matsumoto 099d01c751 class.c (mrb_mod_module_function): narrow scope of local variables 2024-02-29 19:14:18 +09:00
Yukihiro "Matz" Matsumoto 11d7c74e50 Merge pull request #6185 from dearblue/keep_context
Added `mrb_callinfo::u.keep_context` for clarity
2024-02-29 19:13:59 +09:00
Yukihiro "Matz" Matsumoto 0673563968 Merge pull request #6186 from dearblue/check-env.cxt
Omit NULL check of `e->cxt` in `OP_RETURN_BLK`
2024-02-25 23:46:16 +09:00
Yukihiro "Matz" Matsumoto ab94f6533d Revert "gha: add macOS 14 to the build"
This reverts commit 9b9cbd77b0.
2024-02-24 23:31:28 +09:00
Yukihiro "Matz" Matsumoto 8130bbc479 string.c (mrb_str_len_to_dbl): should return zero for invalid string
We should not use uninitialized value; fix #6183
2024-02-24 23:03:15 +09:00
dearblue e94eef6f98 Omit NULL check of e->cxt in OP_RETURN_BLK
Since `mrb->c` is never `NULL`, there is no need to check it beforehand.
2024-02-24 21:38:51 +09:00
dearblue ce8b2d4973 Added mrb_callinfo::u.keep_context for clarity 2024-02-24 21:32:11 +09:00
dearblue c7af3d48e3 Remove the L_STOP label
The post-processing of the jump source is decided, and it is more natural to deploy it on the spot.
2024-02-24 18:23:33 +09:00
Yukihiro "Matz" Matsumoto 6248e9c2ef Merge pull request #6155 from dearblue/jmpbuf_id
Removed `mrb_jmpbuf_id` for C++ exceptions
2024-02-23 23:51:45 +09:00
Yukihiro "Matz" Matsumoto 72f956d3e0 readfloat.c: remove unused local variable 2024-02-22 10:40:24 +09:00
Yukihiro "Matz" Matsumoto 643d91d566 Merge pull request #6181 from mruby/dependabot/github_actions/super-linter/super-linter-6.2.0
build(deps): bump super-linter/super-linter from 6.1.1 to 6.2.0
2024-02-22 10:32:22 +09:00
dependabot[bot] d4eb58c824 build(deps): bump super-linter/super-linter from 6.1.1 to 6.2.0
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 6.1.1 to 6.2.0.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/CHANGELOG.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v6.1.1...v6.2.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-21 14:50:07 +00:00
Yukihiro "Matz" Matsumoto 49f8c9be5b Merge pull request #6177 from jbampton/test-on-macOS14
gha: add macOS 14 to the build
2024-02-20 12:16:47 +09:00
Yukihiro "Matz" Matsumoto 88c7e14d24 Merge pull request #6179 from jbampton/link-check-ignore-links
pre-commit: add `markdown-link-check` config and ignore links
2024-02-20 12:15:51 +09:00
Yukihiro "Matz" Matsumoto dde8b37331 Merge pull request #6178 from jbampton/super-linter-validate-gitleaks
super-linter: set `VALIDATE_GITLEAKS` to `true`
2024-02-20 12:15:13 +09:00
John Bampton 8772592fa2 pre-commit: add markdown-link-check config and ignore links
https://github.com/tcort/markdown-link-check?tab=readme-ov-file#config-file-format
2024-02-20 12:28:16 +10:00
John Bampton ae8419dba7 super-linter: set VALIDATE_GITLEAKS to true
Flag to enable the linting process of the secrets.

Just another check or test we can have.

Set VALIDATE_ALL_CODEBASE: true

https://github.com/super-linter/super-linter?tab=readme-ov-file#configure-super-linter
2024-02-20 12:11:19 +10:00
John Bampton 6f8ae1cbb3 Update .github/workflows/build.yml 2024-02-20 11:07:47 +10:00
John Bampton 9b9cbd77b0 gha: add macOS 14 to the build
https://github.com/actions/runner-images?tab=readme-ov-file#available-images
2024-02-20 10:58:00 +10:00
Yukihiro "Matz" Matsumoto 2f77f2b525 Merge pull request #6133 from dearblue/auto-release
Create source code packages by adding release tags
2024-02-19 22:20:43 +09:00
Yukihiro "Matz" Matsumoto 9e9545b1a6 Merge pull request #6176 from dearblue/alias-proc
Stop assuming alias proc in `CI_PROC_SET()`
2024-02-18 22:13:30 +09:00
Yukihiro "Matz" Matsumoto 1bb93e74a0 Merge pull request #6175 from dearblue/mrb_vm_run-cond
Corrected strange conditional in `mrb_vm_run()`
2024-02-18 22:11:45 +09:00
dearblue f5cce68ba6 Stop assuming alias proc in CI_PROC_SET()
Resolving alias proc should be done by the caller of `CI_PROC_SET()`.
The same applies to `mrb_vm_ci_proc_set()`.
2024-02-18 21:09:45 +09:00
dearblue 2c66d34a7e Corrected strange conditional in mrb_vm_run()
This was introduced in commit 365c151df0.
I should have checked env first.
2024-02-18 18:18:21 +09:00
Yukihiro "Matz" Matsumoto 10de08fa4e Merge pull request #6174 from dearblue/mruby-config-dir
Fix `MRUBY_PACKAGE_DIR` in `mruby-config.bat`
2024-02-17 23:21:01 +09:00
dearblue 06e791e1d7 Fix MRUBY_PACKAGE_DIR in mruby-config.bat
Previously, the correct directory could not be obtained in some environments.
Therefore, changed the method to leave an element indicating the parent directory.

fix #6156
2024-02-17 11:14:57 +09:00
Yukihiro "Matz" Matsumoto 4855e50cbe Merge pull request #6172 from mruby/dependabot/github_actions/super-linter/super-linter-6.1.1
build(deps): bump super-linter/super-linter from 6.0.0 to 6.1.1
2024-02-16 08:14:18 +09:00
Yukihiro "Matz" Matsumoto 7d199b7256 src/error.h: remove unused header 2024-02-16 08:10:53 +09:00
Yukihiro "Matz" Matsumoto a1be05e79f src/opcode.h: remove unused header 2024-02-16 08:09:58 +09:00
dependabot[bot] aebc951533 build(deps): bump super-linter/super-linter from 6.0.0 to 6.1.1
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 6.0.0 to 6.1.1.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/CHANGELOG.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v6.0.0...v6.1.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-15 14:43:54 +00:00
Yukihiro "Matz" Matsumoto c37e76ec75 Merge pull request #6171 from buty4649/add-enumrable-lazy-grep_v
Add Enumerable::Lazy#grep_v to mruby-enum-lazy
2024-02-15 15:49:30 +09:00
buty4649 031476a853 mruby-enum-lazy: add grep_v method 2024-02-15 14:55:38 +09:00
Yukihiro "Matz" Matsumoto 3eeeb8fabf string.c (memsearch_swar): skip a local variable 2024-02-15 14:01:49 +09:00
Yukihiro "Matz" Matsumoto 55ca34c31b backtrace.c (mrb_print_backtrace): skip a local variable 2024-02-15 14:01:48 +09:00
Yukihiro "Matz" Matsumoto c3f8227c6d mruby.h: adjust comment offset [ci skip] 2024-02-15 14:01:48 +09:00
Yukihiro "Matz" Matsumoto 9e1ed100ce Merge pull request #6169 from mruby/stable
Merge mruby 3.3.0
2024-02-15 14:01:28 +09:00
mimaki 94062b4356 Merge branch 'master' into stable 2024-02-14 19:01:59 +09:00
mimaki 32279e4128 Update version and release date. (mruby 3.3.0 (2024-02-14)) 2024-02-14 13:25:11 +09:00
Yukihiro "Matz" Matsumoto 06466fd2e0 Merge branch 'dearblue-doc/mruby3.3.md' 2024-02-14 09:29:54 +09:00
Yukihiro "Matz" Matsumoto 9c840a68e2 string.c (memsearch_swar): boundary check by the latest position 2024-02-13 22:36:03 +09:00
Yukihiro "Matz" Matsumoto 6810423da1 backtrace.c (mrb_print_backtrace): avoid backtrace to array conversion
Made print_backtrace() to support both array form and packed backtrace
form, so that we can avoid allocating an array.
2024-02-13 16:18:14 +09:00
Yukihiro "Matz" Matsumoto 441de05376 error.h: use RBasic instead of RObject for generic objects
RObject is type for objects with instance variables. For generic
objects, use RBasic.
2024-02-13 11:05:27 +09:00
Yukihiro "Matz" Matsumoto f285420653 backtrace.c (decode_location): decode packed backtrace location on demand. 2024-02-13 00:07:54 +09:00
Yukihiro "Matz" Matsumoto a3da9c1da3 AUTHORS: update entries [ci skip] 2024-02-12 00:02:35 +09:00
Yukihiro "Matz" Matsumoto d2af9da799 Merge branch 'dearblue-doc/mruby3.3.md' 2024-02-10 17:08:57 +09:00
Yukihiro "Matz" Matsumoto 01ff7fbf0a Update mruby3.3.md 2024-02-10 17:05:55 +09:00
Yukihiro "Matz" Matsumoto 2d2693d823 Merge branch 'doc/mruby3.3.md' of https://github.com/dearblue/mruby into dearblue-doc/mruby3.3.md 2024-02-10 16:49:56 +09:00
Yukihiro "Matz" Matsumoto abcad36bae string.c (memsearch_swar): fixed a buffer overflow 2024-02-09 19:09:01 +09:00
Yukihiro "Matz" Matsumoto 868aeaf48c string.c (memsearch_swar): fixed a buffer overflow 2024-02-09 18:52:44 +09:00
Yukihiro "Matz" Matsumoto 874f1e0138 backtrace.c (copy_location): rename some function and arguments 2024-02-08 23:41:22 +09:00
Yukihiro "Matz" Matsumoto 432caf0670 backtrace.c (pack_backtrace): refactor the function that called once 2024-02-08 23:22:48 +09:00
Yukihiro "Matz" Matsumoto 60919807e5 backtrace.c (each_backtrace): make return type to size_t 2024-02-07 17:34:33 +09:00
Yukihiro "Matz" Matsumoto 0a11215452 backtrace.c (packed_backtrace): avoid calling each_backtrace() twice
Since the length of the backtrace is at most `ciidx + 1` we can avoid
the first call of each_backtrace().
2024-02-07 17:32:58 +09:00
Yukihiro "Matz" Matsumoto b67cea4442 backtrace.c (pack_backtrace_i): avoid infinite loop; ref #6161
When irep->refcnt reaches UINT16_MAX, mrb_irep_incref() raises
exception but the function pack_backtrace_i() is called from
mrb_exc_raise() thus causes the infinite loop problem. So this is a
hack-ish workaround by making irep reference to NULL if refcnt reaches
the maximum count. Probably we will address this issue again to make it
better.
2024-02-07 17:30:11 +09:00
Yukihiro "Matz" Matsumoto b8e4c4b6ba Merge pull request #6166 from dearblue/mrb_heap_page
Stop pseudo flexible array in `mrb_heap_page`
2024-02-05 21:45:04 +09:00
Yukihiro "Matz" Matsumoto 32fb0c04ee Merge pull request #6165 from dearblue/RVALUE
Reduce `RVALUE` related pointer casts.
2024-02-05 21:42:51 +09:00
Yukihiro "Matz" Matsumoto 5f699e797d Merge pull request #6167 from dearblue/obj_free
Change the `end` parameter of `obj_free()` to a boolean type
2024-02-05 21:42:41 +09:00
Yukihiro "Matz" Matsumoto 0fe95d6c81 mruby-pack (mrb_pack_pack): avoid integer overflow
`int` (32bit integer) may be too small on 64bit platforms.
2024-02-05 21:28:11 +09:00
dearblue 8f14785f10 Stop pseudo flexible array in mrb_heap_page
For reference, the flexible array was introduced by commit 3ab2f9371e (#2997).
Subsequently changed for compatibility with C++ by commit 24939723d7 (#5596).
2024-02-04 21:55:54 +09:00
dearblue 84fbe63457 Change the end parameter of obj_free() to a boolean type
The caller is a boolean value from the first.
2024-02-04 21:55:54 +09:00
dearblue dde5fe3a60 Reduce RVALUE related pointer casts. 2024-02-04 21:55:53 +09:00
Yukihiro "Matz" Matsumoto f04a729dc9 gc.c (obj_free): check if irep is NULL before mrb_irep_decref(); #6161 2024-02-04 17:06:05 +09:00
Yukihiro "Matz" Matsumoto 2f63b49542 backtrace.c: use mrb_irep references instead of struct RProc
To reduce GC burden (no mark needed). We use `mrb_irep_incref()` and
`mrb_irep_decref()` instead to track irep memory usage; ref #6161
2024-02-04 16:48:42 +09:00
Yukihiro "Matz" Matsumoto 4dfadb4f9f Merge pull request #6159 from dearblue/debug/irep-free
Allow to detect use-after-free after `mrb_irep_free()` for debugging
2024-02-04 16:26:03 +09:00
Yukihiro "Matz" Matsumoto 0abc36f761 Merge pull request #6161 from dearblue/backtrace
Fixed use-after-free by backtrace object
2024-02-03 23:39:58 +09:00
Yukihiro "Matz" Matsumoto 9524d8e199 Merge pull request #6164 from jbampton/remove-ERROR_ON_MISSING_EXEC_BIT
super-linter: remove `ERROR_ON_MISSING_EXEC_BIT` check
2024-02-03 00:25:35 +09:00
John Bampton 8e04e76325 super-linter: remove ERROR_ON_MISSING_EXEC_BIT check
https://github.com/super-linter/super-linter/releases/tag/v6.0.0

https://github.com/super-linter/super-linter/pull/5120
2024-02-02 15:51:18 +10:00
Yukihiro "Matz" Matsumoto 08c422c7ee numeric.c (cmpnum): support fixnum cmp bignum; fix #6163 2024-02-02 14:18:57 +09:00
Yukihiro "Matz" Matsumoto 4762689f93 Merge pull request #6153 from dearblue/gem-list
Make `MRuby::Gems::List#{each,<<}` method return `self`
2024-02-02 08:19:44 +09:00
Yukihiro "Matz" Matsumoto fd04ffc2f6 Merge pull request #6144 from jbampton/add-hook-detect-aws-credentials
pre-commit: add hook `detect-aws-credentials`
2024-02-02 08:15:38 +09:00
Yukihiro "Matz" Matsumoto 6e09555749 Merge pull request #6150 from dearblue/itself
Introduce `mrb_obj_itself()`
2024-02-01 16:15:42 +09:00
Yukihiro "Matz" Matsumoto 24aad706e1 Merge pull request #6162 from mruby/dependabot/github_actions/super-linter/super-linter-6.0.0
build(deps): bump super-linter/super-linter from 5.7.2 to 6.0.0
2024-02-01 16:02:45 +09:00
dependabot[bot] a0bcf63bd5 build(deps): bump super-linter/super-linter from 5.7.2 to 6.0.0
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 5.7.2 to 6.0.0.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/CHANGELOG.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v5.7.2...v6.0.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-31 14:23:26 +00:00
dearblue 9543cfa7ee Fixed use-after-free by backtrace object
The `MRB_TT_BACKTRACE` object has been added for the purpose.

Previously, "use-after-free" could occur because the reference count in `backtrace_location::irep` was not incremented.

fixed #6160
2024-01-31 22:17:16 +09:00
Yukihiro "Matz" Matsumoto cac698fe88 string.c (memsearch_swar): changed the function name
For your information, SWAR stands for SIMD within a register.
2024-01-31 21:37:39 +09:00
Yukihiro "Matz" Matsumoto f8527f0670 string.c (mrb_memsearch_ss): update a comment regarding alignment issue 2024-01-31 21:36:05 +09:00
Yukihiro "Matz" Matsumoto d8144aef78 string.c: remove a comment regarding unsigned char* 2024-01-31 21:34:54 +09:00
Yukihiro "Matz" Matsumoto 363f795432 string.c: remove unnecessary type casts
We don't need `unsigned` for string pointers.
2024-01-31 15:06:04 +09:00
Yukihiro "Matz" Matsumoto e61a2881a7 string.c (mrb_memsearch_ss): fix potential buffer overflow; fix #6158
- stop using `bigint*`
- stop integer pointer dereferences
- use `memcpy` to integer variables
- add reminder search for shorter patterns
2024-01-31 07:48:24 +09:00
Yukihiro "Matz" Matsumoto 219cfd63e1 string.c (mrb_memsearch_ss): update integer prefixes (LLU -> ULL) 2024-01-31 07:42:52 +09:00
Yukihiro "Matz" Matsumoto 6ba65ea0f0 string.c (mrb_memsearch_ss): update comment 2024-01-31 01:54:37 +09:00
Yukihiro "Matz" Matsumoto 44a5882bc2 string.c (mrb_memsearch_ss): remove useless alignment adjustment
Ref #6158
2024-01-31 01:27:10 +09:00
Yukihiro "Matz" Matsumoto be5448fd16 string.c (mrb_memsearch): refactor m==1 (use memchr) case 2024-01-31 01:17:12 +09:00
Yukihiro "Matz" Matsumoto d8e1aed646 string.c (search_nonascii): need not to check n>3 on 32bit platforms 2024-01-30 12:35:56 +09:00
dearblue 60dd6b5586 Allow to detect use-after-free after mrb_irep_free() for debugging
Write invalid value to `irep` if `MRB_DEBUG` is defined by `MRuby::Build#enable_debug`.
2024-01-29 21:32:04 +09:00
Yukihiro "Matz" Matsumoto 0e1125c3af Merge pull request #6152 from dearblue/io-error
Retrieving the IO exception class with presym
2024-01-27 15:10:29 +09:00
Yukihiro "Matz" Matsumoto fefebf7a77 Merge pull request #6151 from dearblue/eval-init
Refer to `mrb->module_class` directly in `mrb_mruby_eval_gem_init()`
2024-01-27 15:09:30 +09:00
Yukihiro "Matz" Matsumoto e859b430cc fixup! string.c (search_nonascii): add faster search using SSE2 2024-01-27 11:59:29 +09:00
Yukihiro "Matz" Matsumoto dee1ded7b5 string.c (mrb_memsearch_ss): support bigendians 2024-01-27 06:23:16 +09:00
Yukihiro "Matz" Matsumoto 06d9a54760 string.c (mrb_memsearch): remove simple search and quick search
Since mrb_memsearch_ss() is fast enough for most of the cases, we try to
simplify the code.
2024-01-27 06:22:55 +09:00
Yukihiro "Matz" Matsumoto 2943ca2685 string.c (mrb_memsearch_ss): faster integer-wise substring search
The function is based on @WojciechMula's code from the repository
https://github.com/WojciechMula/sse4-strstr.git Since it's licensed
under 2 clause BSD, we updated LEGAL file too.
2024-01-27 06:16:33 +09:00
Yukihiro "Matz" Matsumoto 08cd281200 string.c (search_nonascii): skip alignment adjustment for some CPUs
Some CPUs (e.g. x86) allow unaligned access to the memory.
2024-01-26 08:22:33 +09:00
Yukihiro "Matz" Matsumoto 68ab95ea57 string.c (mrb_memsearch): take char* instead of void*
Avoid useless `void*`.
2024-01-25 22:32:31 +09:00
Yukihiro "Matz" Matsumoto cf0cd6785c string.c: rename MRB_QS_SHORT_STRING_LENGTH
The new name is MRB_SEARCH_SHORT_STRING_LENGTH since it's no longer used
in the mrb_memsearch_qs(). FYI, 'qs' stands for 'quick search'.
2024-01-23 23:28:45 +09:00
Yukihiro "Matz" Matsumoto fb2ebcde7c string.c (search_nonascii): add faster search using SSE2 2024-01-23 23:28:45 +09:00
Yukihiro "Matz" Matsumoto 4108b85c62 string.c (search_nonascii): faster search using integer match
If you define `SIMPLE_SEARCH_NONASCII`, you can use old, naive
implementation of search_nonascii(). You may want to use the old one for
code size constraint for example.
2024-01-23 23:28:45 +09:00
Yukihiro "Matz" Matsumoto f41593f55a Merge pull request #6154 from dearblue/int_to_str 2024-01-23 21:59:14 +09:00
Yukihiro "Matz" Matsumoto 18bdcbe536 Merge pull request #6145 from hoshiumiarata/enum_chunk
Enumerable#chunk implementation
2024-01-23 08:58:19 +09:00
星湖新 ab21813100 Move Enumerable#chunk to mruby-enumerator 2024-01-22 18:31:28 +09:00
星湖新 d001974439 Revert "Enumerable#chunk implementation"
This reverts commit ebf86a24b0.
2024-01-22 18:26:01 +09:00
Yukihiro "Matz" Matsumoto 5431575d11 Merge pull request #6148 from buty4649/add-enumerable-grep_v
Add Enumerable#grep_v to mruby-enum-ext
2024-01-21 18:51:11 +09:00
dearblue c112e83b5d Removed mrb_jmpbuf_id for C++ exceptions
Use stack variable addresses as identifiers instead of global variable values.
Since the stack variable address is uniquely determined within the call, there is no need to maintain a global variable.
2024-01-21 13:14:41 +09:00
dearblue bf2db1ed2b Check mrb_bigint_p() before mrb_integer() 2024-01-21 10:59:06 +09:00
Yukihiro "Matz" Matsumoto 028c53d667 Merge pull request #6149 from dearblue/rational.new
Remove unnecessary `Rational._new` method
2024-01-20 23:28:38 +09:00
Yukihiro "Matz" Matsumoto 888dd230dd Merge pull request #6147 from dearblue/memsearch
Fixed buffer overflow in `mrb_memsearch()`
2024-01-20 23:25:34 +09:00
Yukihiro "Matz" Matsumoto 12483c8393 Merge pull request #6146 from mruby/dependabot/github_actions/actions/cache-4
build(deps): bump actions/cache from 3 to 4
2024-01-20 23:24:40 +09:00
dearblue 464ac4581e Make MRuby::Gems::List#{each,<<} method return self
Returning internal objects is undesirable.
2024-01-20 22:49:31 +09:00
dearblue 5caf8e14cf Retrieving the IO exception class with presym 2024-01-20 22:33:43 +09:00
dearblue 82312467d0 Refer to mrb->module_class directly in mrb_mruby_eval_gem_init() 2024-01-20 22:20:20 +09:00
dearblue 3111990089 Introduce mrb_obj_itself()
Some method definitions were changed to use this function.
2024-01-20 22:07:29 +09:00
dearblue 35375257f6 Remove unnecessary Rational._new method 2024-01-20 21:52:49 +09:00
buty4649 97203729a9 Add Enumerable#grep_v to mruby-enum-ext 2024-01-20 11:47:37 +09:00
dearblue 772f13520c Fixed buffer overflow in mrb_memsearch() 2024-01-20 09:44:47 +09:00
Yukihiro "Matz" Matsumoto f13101124c string.c: add cast to remove warnings 2024-01-19 18:24:34 +09:00
Yukihiro "Matz" Matsumoto 69cf074778 string.c (mrb_memsearch): move simple search from mrb_memsearch_qs() 2024-01-19 15:21:43 +09:00
dependabot[bot] 1e9d69f896 build(deps): bump actions/cache from 3 to 4
Bumps [actions/cache](https://github.com/actions/cache) from 3 to 4.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v3...v4)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-18 14:59:43 +00:00
Yukihiro "Matz" Matsumoto 6f0c34e04e mruby-string-ext: implement String#ascii_only? method 2024-01-18 22:53:46 +09:00
Yukihiro "Matz" Matsumoto 57fd0edaa7 mruby.h: rename ASCII flag to SINGLE_BYTE
This flag means all the characters in the string can be represented by a
single byte, i.e., the string does not contain any multi-byte character.
Those characters are likely ASCII characters, but may be a part of broken
UTF-8 sequence, so the term 'ASCII' is not sufficient.
2024-01-18 22:50:39 +09:00
Yukihiro "Matz" Matsumoto 5b76d2cbbe string.h: RSTR_ASCII_P(s) should always be true for non-UTF8 mode 2024-01-16 17:38:51 +09:00
Yukihiro "Matz" Matsumoto 6c2ed55077 mruby-bin-mruby: remove unused assignments 2024-01-16 12:28:32 +09:00
Yukihiro "Matz" Matsumoto 0e079fe946 mruby-bin-mruby: reduce the scope of a loop variable i 2024-01-15 23:04:18 +09:00
Yukihiro "Matz" Matsumoto 9298dfb927 mruby-bin-mruby: reduce the scope of a local variable c 2024-01-15 23:03:34 +09:00
Yukihiro "Matz" Matsumoto 90fac46751 mruby-bin-mruby: remove unnecessary condition 2024-01-15 23:00:46 +09:00
Yukihiro "Matz" Matsumoto 4f8fd23f7a mruby-string-ext (str_uminus): remove wrong document
In mruby, deduplication of strings is not implemented (yet), so we have
to remove the description from `String#-@` document.
2024-01-13 23:00:13 +09:00
Yukihiro "Matz" Matsumoto c53d9a33fc mruby-string-ext (mrb_valid_enc_p): simplify the code
By using `mrb_utf8len` directly. If `len == 1` and `ch >= 0x80`, the
character should be an invalid character.
2024-01-13 22:48:16 +09:00
星湖新 ebf86a24b0 Enumerable#chunk implementation 2024-01-13 17:36:02 +09:00
Yukihiro "Matz" Matsumoto fb8bc1954b string.c: improve performance of chars2bytes/bytes2chars; ref #6143 2024-01-11 18:23:50 +09:00
Yukihiro "Matz" Matsumoto f646228dbe string.c (str_index_str_by_char): simplify using str_index_str()
Instead of its own version of quick search, now we use str_index_str()
and adjust character position. This change makes searching 4 times
faster in some cases; ref #6143
2024-01-11 12:23:06 +09:00
Yukihiro "Matz" Matsumoto e42f3b36f9 string.c (chars2bytes): simplify the condition to detect break 2024-01-11 11:49:49 +09:00
John Bampton f8f3ff10fa pre-commit: add hook detect-aws-credentials
https://github.com/pre-commit/pre-commit-hooks#detect-aws-credentials

Another check or test we can have.

"--allow-missing-credentials - Allow hook to pass when no credentials are detected."
2024-01-11 03:18:15 +10:00
dearblue 514c926e97 Update the mruby3.3.md file
- Remove items changed by mruby 3.2.
  - The commit hash or pull request number will be written along with the changes.
  - Add some items.
2024-01-10 23:00:10 +09:00
Yukihiro "Matz" Matsumoto 787439455c string.c: remove the macro BYTES_ALIGN_CHECK which is no longer used 2024-01-10 17:31:04 +09:00
Yukihiro "Matz" Matsumoto c2f148e15d string.c (mrb_memsearch_qs): reduce the scope of local variables 2024-01-10 16:21:39 +09:00
Yukihiro "Matz" Matsumoto 31f2d93657 string.c (bytes2chars): skip calling mrb_utf8len() if possible
If (ch < 0x80) the length of the character (in bytes) should be 1, so we
don't have to call mrb_utf8len().
2024-01-10 15:36:07 +09:00
Yukihiro "Matz" Matsumoto 4c859e754d string.c (bytes2chars): skip scanning if the string is ASCII only 2024-01-10 14:40:39 +09:00
Yukihiro "Matz" Matsumoto df0a5e838d string.c (chars2bytes): use early return 2024-01-10 12:41:28 +09:00
Yukihiro "Matz" Matsumoto e39e4ea26d string.c (chars2bytes): small refactoring 2024-01-10 11:09:47 +09:00
Yukihiro "Matz" Matsumoto 1d243bc58b string.c (bytes2chars): takes a string object instead of char* 2024-01-10 10:53:26 +09:00
Yukihiro "Matz" Matsumoto 59a1d74937 string.c: inline str_range_to_bytes 2024-01-09 18:22:38 +09:00
Yukihiro "Matz" Matsumoto 9135f0991b string.c: avoid RSTRING_CHAR_LEN() if possible
Current code scan the string twice (once from RSTRING_CHAR_LEN, and once
from chars2bytes), but those scans are not necessary. Just point the end
of the string.
2024-01-09 11:44:12 +09:00
Yukihiro "Matz" Matsumoto f3ebef1172 mruby-string (chars2bytes): reduce the scope of local variables 2024-01-09 11:00:44 +09:00
Yukihiro "Matz" Matsumoto f1d01a6107 string.c (mrb_utf8len): should return 1 for invalid chars; ref #6143 2024-01-09 10:39:03 +09:00
Yukihiro "Matz" Matsumoto 64a4bf0e28 string.c: avoid infinite loop; fix #6143
`mrb_utf8len` returns 0 for invalid characters.
2024-01-09 10:37:52 +09:00
Yukihiro "Matz" Matsumoto a5e83075d4 string.c: reduce the scope of a local variable 2024-01-09 08:22:26 +09:00
Yukihiro "Matz" Matsumoto af3482d562 mruby-math: use erfc(x) instead of 1.0 - erf(x) 2024-01-09 08:01:28 +09:00
Yukihiro "Matz" Matsumoto 51c4c4716a mruby-math: use log1p(x) instead of log(1.0+x) 2024-01-09 07:59:42 +09:00
Yukihiro "Matz" Matsumoto 8a2e88390b mruby-math: reduce the scope of a local variable 2024-01-09 07:47:57 +09:00
Yukihiro "Matz" Matsumoto c1fc3219db mruby-math: fix spacing 2024-01-08 23:18:57 +09:00
Yukihiro "Matz" Matsumoto 05e9fa34af mruby-random: rename a conflicting local variable 2024-01-08 19:12:55 +09:00
Yukihiro "Matz" Matsumoto 27c2f9ac38 mruby-random (mrb_ary_sample): reduce the scope of loop variables 2024-01-08 07:23:03 +09:00
Yukihiro "Matz" Matsumoto 2cf6f7f5c7 mruby-rational: move misplaced #ifndef MRB_NO_FLOAT 2024-01-08 07:19:30 +09:00
Yukihiro "Matz" Matsumoto be3b93ecb9 array.c (ary_expand_capa): rename a conflicting local variable 2024-01-06 14:33:50 +09:00
Yukihiro "Matz" Matsumoto d47f1b4df3 array.c (ary_expand_capa): remove unnecessary condition check 2024-01-06 14:32:54 +09:00
Yukihiro "Matz" Matsumoto 2eeb19a5ed mruby-kernel-ext (mrb_f_caller): remove unnecessary condition check 2024-01-06 14:31:32 +09:00
Yukihiro "Matz" Matsumoto b06fdb4bfa mruby-io/file.c: reduce the scope of local variables 2024-01-06 08:30:56 +09:00
Yukihiro "Matz" Matsumoto e1b6501183 mruby-io: fix local variable initialization redundancy 2024-01-05 13:03:33 +09:00
Yukihiro "Matz" Matsumoto f1b8d38eb5 mruby-io: narrow a local variable scope 2024-01-05 13:02:39 +09:00
Yukihiro "Matz" Matsumoto 20dd737a4a mruby-io (io_s_popen): remove fflush(stdin)
Flushing input I/O should be useless.
2024-01-05 13:00:55 +09:00
mimaki 28a1f7d143 Update version to 3.3.0RC2. 2024-01-04 14:56:56 +09:00
dearblue 69682e3d41 Fixed when combined mrb_fiber_resume() and Fiber#transfer
For example, the following code was crashing.

```c
#include <mruby.h>
#include <mruby/compile.h>
#include <mruby/proc.h>

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

  mrb_value fiber = mrb_load_string(mrb, "Fiber.new { Fiber.new { 12345.6789 }.transfer }");
  mrb_value res = mrb_fiber_resume(mrb, fiber, 0, NULL);
  mrb_p(mrb, res);

  mrb_close(mrb);

  return 0;
}
```
2024-01-04 14:12:35 +09:00
Yukihiro "Matz" Matsumoto 9ee7d955e3 mruby-metaprog: narrow the scope of a local variable 2024-01-04 11:18:14 +09:00
Yukihiro "Matz" Matsumoto 2ce5c52726 mruby-errno (mrb_sce_sys_fail): remove redundant assignment 2024-01-04 10:08:22 +09:00
Yukihiro "Matz" Matsumoto 7861422cbe mruby-fiber (fiber_switch): reduce the scope of local variables 2024-01-03 16:07:15 +09:00
Yukihiro "Matz" Matsumoto 93bda0d27f mruby-fiber (fiber_init_fiber): rename conflicting local variables 2024-01-03 16:05:46 +09:00
Yukihiro "Matz" Matsumoto f0ab79b195 Merge pull request #6136 from dearblue/fiber-fix
Fixed when combined `mrb_fiber_resume()` and `Fiber#transfer`
2024-01-03 07:33:48 +09:00
Yukihiro "Matz" Matsumoto 5257fe4333 mruby-bigint (mrb_bint_new_float): narrow the scope of variable 'f' 2024-01-03 07:23:55 +09:00
Yukihiro "Matz" Matsumoto d632085b5b mruby-bigint (udiv): narrow the scope of loop variable 'i' 2024-01-03 07:23:55 +09:00
Yukihiro "Matz" Matsumoto d944a079a3 mruby-numeric-ext (int_digits): avoid variable name override 2024-01-03 07:23:55 +09:00
Yukihiro "Matz" Matsumoto e71e1bc50e mruby-hash-ext: reduce the scope of the loop variable i 2024-01-03 07:23:55 +09:00
Yukihiro "Matz" Matsumoto 17b2ec643e Merge pull request #6140 from jbampton/actions-label-more-files
actions: label more files for build
2024-01-03 07:23:39 +09:00
dearblue 519a2cbd59 Fixed when combined mrb_fiber_resume() and Fiber#transfer
For example, the following code was crashing.

```c
#include <mruby.h>
#include <mruby/compile.h>
#include <mruby/proc.h>

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

  mrb_value fiber = mrb_load_string(mrb, "Fiber.new { Fiber.new { 12345.6789 }.transfer }");
  mrb_value res = mrb_fiber_resume(mrb, fiber, 0, NULL);
  mrb_p(mrb, res);

  mrb_close(mrb);

  return 0;
}
```
2024-01-02 21:34:44 +09:00
John Bampton f8511ecb22 Fix pre-commit failure from prettier 2024-01-01 18:32:48 +09:00
John Bampton e471399044 actions: label more files for build 2024-01-01 17:19:53 +10:00
Yukihiro "Matz" Matsumoto d7a2174519 Merge pull request #6139 from jbampton/fix-prettier-hook
Fix `pre-commit` failure from `prettier`
2024-01-01 15:46:41 +09:00
Yukihiro "Matz" Matsumoto a406e008d1 Merge branch 'master' into fix-prettier-hook 2024-01-01 15:29:08 +09:00
Yukihiro "Matz" Matsumoto d4cd589733 NEWS: add mruby3.3 changes description 2024-01-01 10:11:32 +09:00
John Bampton 19d0ea803d Fix pre-commit failure from prettier 2023-12-31 21:57:58 +10:00
dearblue 8322c441ee Remove unreachable blocks in OP_RETURN
When `mrb->c->prev` is non `NULL` and `mrb->c->noexec` is false, switching source fiber should suspend with `Fiber#resume`.
In this case, the condition `mrb->c->ci == mrb->c->cibase` is not satisfied.
2023-12-31 14:49:59 +09:00
Yukihiro "Matz" Matsumoto 8094ac27d7 NEWS: add mruby3.3 changes description 2023-12-31 00:43:02 +09:00
Yukihiro "Matz" Matsumoto 39f48d732a mruby-pack: update README.md
'X' and '@' directives are not listed
2023-12-30 16:02:20 +09:00
Yukihiro "Matz" Matsumoto 56b67f8613 mruby-pack (u64tostr): reimplement the function
- direct conversion of single digit numbers
- remove unnecessary update of `line` variable
- simplify the body according to the assertion
2023-12-30 15:35:55 +09:00
Yukihiro "Matz" Matsumoto 8cbd4638f4 mruby-pack (u64tostr): len should always be positive
Add `mrb_assert()` instead of just skipping the function.
2023-12-30 15:33:57 +09:00
Yukihiro "Matz" Matsumoto 1871ff14db mruby-pack (pack_unpack): skip continuous extraction from unpack1
Ref #6134
2023-12-30 15:31:44 +09:00
Yukihiro "Matz" Matsumoto 7765c23f69 mruby-pack (pack_hex): the scope of variables a and b can be reduced 2023-12-30 15:12:17 +09:00
Yukihiro "Matz" Matsumoto fca2bbdcca mruby-pack (unpack_str): the scope of the variable cp can be reduced 2023-12-30 15:12:10 +09:00
dearblue 9d4931cd1b Create source code packages by adding release tags
According to the [GitHub blog](https://github.blog/2023-02-21-update-on-the-future-stability-of-source-code-archives-and-hashes/), files by `git archive` are not guaranteed to have checksum persistence.
It is also stated that the archive file at this time is stable in bytes, but that this may change in the future.
2023-12-29 17:50:33 +09:00
mimaki 82e289a64d Update version to 3.3.0RC. 2023-12-29 16:02:13 +09:00
Yukihiro "Matz" Matsumoto 159687bef3 mruby-pack: add tests for unpack1 method; ref #6134 2023-12-29 15:05:16 +09:00
mimaki c1ed125689 Merge remote-tracking branch 'origin/master' into stable 2023-12-29 14:26:19 +09:00
Yukihiro "Matz" Matsumoto 6d8323f3c7 mruby-pack (pack_unpack): unpack1 did not return single data; fix #6134
For following unpack directives:

- PACK_DIR_HEX (h)
- PACK_DIR_BSTR (b)
- PACK_DIR_STR (a,A,Z)
- PACK_DIR_BASE64 (m)
- PACK_DIR_QENC (M)
2023-12-29 13:09:14 +09:00
mimaki c11679ad79 Merge remote-tracking branch 'origin/master' into stable 2023-12-29 10:51:32 +09:00
Yukihiro "Matz" Matsumoto 95aa92d5c4 Update AUTHORS (date and commit hash) 2023-12-28 23:36:40 +09:00
Yukihiro "Matz" Matsumoto c1511d5f5d AUTHORS: update entries [ci skip] 2023-12-28 19:51:31 +09:00
mimaki e9047562a1 Merge branch 'master' into stable 2023-12-28 13:39:55 +09:00
Yukihiro "Matz" Matsumoto 67cb987510 doc/mruby3.{1,2}.md: update CVE links (nvd.nist.gov is down) 2023-12-27 22:24:12 +09:00
Yukihiro "Matz" Matsumoto 6ea3166005 doc/guides/memory.md: small style changes (markdownlink-cli) 2023-12-27 22:24:12 +09:00
Yukihiro "Matz" Matsumoto ae43ce7593 mruby-time: refactor _POSIX_TIMERS handling issue; ref #6124 2023-12-27 22:24:12 +09:00
Yukihiro "Matz" Matsumoto a8b82bfae5 Merge pull request #6128 from dearblue/fiber-end
Integrates the sequence when a fiber is terminated by `OP_RETURN`
2023-12-27 22:24:01 +09:00
Yukihiro "Matz" Matsumoto e51c20888b Merge pull request #6127 from dearblue/catch_handler_find
Changed parameters for `catch_handler_find()`
2023-12-27 22:22:12 +09:00
Yukihiro "Matz" Matsumoto 1ac4148020 Merge pull request #6126 from dearblue/block-return
Fixed return value of `OP_RETURN_BLK` called directly under C function
2023-12-27 22:19:36 +09:00
Yukihiro "Matz" Matsumoto 074374e28d Merge pull request #6125 from dearblue/cross-c
Allow `OP_RETURN_BLK` to cross C boundaries
2023-12-27 22:18:06 +09:00
Yukihiro "Matz" Matsumoto dc633ecae8 Merge pull request #6123 from dearblue/allocate-undef.2
Inherit `MRB_FL_UNDEF_ALLOCATE` in subclasses
2023-12-27 22:16:51 +09:00
Yukihiro "Matz" Matsumoto 7d83e9cd27 Merge pull request #6130 from sizious/dreamcast-shelf-build-config-overhaul
`dreamcast_shelf build config`: complete overhaul
2023-12-27 21:54:26 +09:00
SiZiOUS f81b7a3a1f dreamcast_shelf build config: complete overhaul
This configuration is used to support the Sega Dreamcast system.
mruby is now officially supported as a KallistiOS Port in kos-ports.
See: https://dreamcast.wiki/Using_Ruby_for_Sega_Dreamcast_development
2023-12-25 21:40:37 +00:00
Yukihiro "Matz" Matsumoto ebf66a2b80 Add prettier pre-commit hook; close #5490 2023-12-25 08:02:58 +09:00
Yukihiro "Matz" Matsumoto 9c66d4a453 Merge pull request #6124 from sizious/mruby-time-update
`mruby-time`: protect against incorrectly defined `_POSIX_TIMERS`
2023-12-24 17:33:23 +09:00
dearblue dba1dcdd25 Integrates the sequence when a fiber is terminated by OP_RETURN
In the `ensure` block while executing `fiber.transfer`, keep `fiber->cxt->prev` to be `NULL`.
2023-12-24 15:45:15 +09:00
dearblue dc09000f01 Fixed return value of OP_RETURN_BLK called directly under C function
```ruby
def cross; Class.new { return 1 }; end; p cross'
# => #<Class:0x8245cf170>               # without this patch
# => 1                                  # with this patch
```
2023-12-24 13:56:25 +09:00
dearblue d41a2612f4 Allow OP_RETURN_BLK to cross C boundaries
The restriction was introduced in commit b563bcb7ff to resolve https://github.com/mruby/mruby/issues/3462.
Subsequently, the `RBreak` object, introduced by mruby 1.3.0, allowed crossing the C boundary.

```ruby
def cross; Class.new { proc { return }.call }; end; cross
# => unexpected return (LocalJumpError) # without this patch
# => nothing raised                     # with this patch
```
2023-12-24 13:56:25 +09:00
SiZiOUS c0ffc13801 mruby-time: protect against incorrectly defined _POSIX_TIMERS
This update avoids the following error: operator '&&' has no right operand (related to _POSIX_TIMERS)
See: https://stackoverflow.com/questions/48538243/macro-if-statement-returns-error-operator-has-no-right-operand
2023-12-23 19:16:23 +00:00
dearblue 6a9671eac7 Changed parameters for catch_handler_find()
- Removed `mrb` and `ci` parameters.
  - Added `irep` parameter.
    The caller must guarantee that `irep->clen > 0`.
2023-12-23 23:02:48 +09:00
dearblue 2a1ea7d605 Inherit MRB_FL_UNDEF_ALLOCATE in subclasses
If `Class#allocate` is prohibited, subclasses should also be implicitly prohibited.

```ruby
p Class.new(Struct).allocate.class
# => #<Class:0x82362ac00>                                             by #6122
# => allocator undefined for #<Class:0x000000083a983220> (TypeError)  by Ruby 3.2
```

Added `MRB_DEFINE_ALLOCATOR()` to allow subclasses to use `Class#allocate`.

Supplement to #6122.
2023-12-23 21:01:42 +09:00
Yukihiro "Matz" Matsumoto 63580581f7 Merge pull request #6122 from dearblue/allocate-undef.1
Prohibit `Class#allocate` in a different way
2023-12-23 15:15:11 +09:00
dearblue 8ecfacefca Prohibit Class#allocate in a different way
The method introduced by #5979 causes a fault by swapping classes.

```console
% bin/mruby -e 'Method = Proc; p Object.method(:inspect)'
zsh: segmentation fault (core dumped)  bin/mruby -e 'Method = Proc; p Object.method(:inspect)'
```

After applying this patch, a `TypeError` exception will be raised.

```console
% bin/mruby -e 'Method = Proc; p Object.method(:inspect)'
trace (most recent call last):
        [1] -e:1
-e:1:in method: allocation failure of Proc (TypeError)
```

However, if the `mrb_vtype` is the same object, the same care must still be taken as before.

```console
% bin/mruby -e 'Method = Binding; p method(:puts).eval("12345")'
trace (most recent call last):
        [1] -e:1
-e:1:in eval: wrong argument type nil (expected Proc) (TypeError)
```
2023-12-22 21:59:34 +09:00
Yukihiro "Matz" Matsumoto fa75865a33 Merge pull request #6121 from dearblue/separate-breaks
Separate unwinding process for `break` / `return`
2023-12-22 16:12:12 +09:00
Yukihiro "Matz" Matsumoto 97b522d778 src/fmt_fp.c: change condition order for memory safety 2023-12-22 15:35:21 +09:00
Yukihiro "Matz" Matsumoto cfee5c2753 doc/guides/memory.md: guide to memory management customization 2023-12-21 16:48:33 +09:00
Yukihiro "Matz" Matsumoto 28b526cf81 Update .pre-commit-config.yaml 2023-12-21 16:47:16 +09:00
Yukihiro "Matz" Matsumoto 34c5d96e86 allof.c: mrb_default_allocf() definition in the separate file
So that the user can define their own version of mrb_default_alloc
function to override memory allocation of mruby.
2023-12-21 15:28:04 +09:00
dearblue 859f1b3002 Separate unwinding process for break / return 2023-12-20 21:54:53 +09:00
Yukihiro "Matz" Matsumoto 899a09152b mruby.h (mrb_alloc): better description for the function type 2023-12-20 19:39:09 +09:00
Yukihiro "Matz" Matsumoto 72ca266ed7 mruby-io: rename some functions with io_buf prefix
Now all functions with `io_buf` takes `mrb_io_buf` as an argument.

Renamed functions (old names):

- io_init_buf (io_buf_init)
- io_fill_buf (io_buf_fill)
- io_fill_buf_comp (io_buf_fill_comp) for UTF-8 encoding
2023-12-20 08:59:46 +09:00
Yukihiro "Matz" Matsumoto 84fb9f40f0 mruby-io: some functions take mrb_io_buf as an argument
- io_buf_reset
- io_buf_shift
- io_buf_cat
- io_buf_cat_all
2023-12-20 08:59:46 +09:00
Yukihiro "Matz" Matsumoto 054f5b5284 mruby-io (io_eof): avoid unnecessary read(2) call 2023-12-20 08:59:46 +09:00
Yukihiro "Matz" Matsumoto 2e8bede6ea mruby-io (io_read): small refactoring; ref #6118
If `outbuf` is `nil` we allocate a buffer string, if `outbuf` is a
string, we resize it to zero length. In the function `io_read`, this
condition is done twice, so we refactor out to `io_reset_outbuf()`.
2023-12-20 08:59:46 +09:00
Yukihiro "Matz" Matsumoto 2e24c94873 Merge pull request #6120 from dearblue/file-EBADF
Set `EBADF` if `check_file_descriptor()` fails
2023-12-20 08:59:29 +09:00
Yukihiro "Matz" Matsumoto 82ed1c2600 Merge pull request #6118 from dearblue/io.read
Fixed `IO#read` with `buf`.
2023-12-19 08:00:42 +09:00
Yukihiro "Matz" Matsumoto 992bd49344 Merge pull request #6116 from dearblue/send-branch
Improve branching in the execution part of the `OP_SEND` block
2023-12-18 12:17:39 +09:00
Yukihiro "Matz" Matsumoto e8a36235d8 Merge pull request #6115 from dearblue/loop-inclusion
Replace `for` and `CHECKPOINT` block comprehensions
2023-12-18 12:16:38 +09:00
dearblue 5e3e75ed7b Set EBADF if check_file_descriptor() fails 2023-12-17 10:50:59 +09:00
Yukihiro "Matz" Matsumoto b20418cf78 Merge pull request #6119 from jbampton/fix-spelling
docs: fix spelling
2023-12-17 07:14:17 +09:00
John Bampton 4c79fce665 docs: fix spelling 2023-12-17 00:58:24 +10:00
dearblue 7611dc8338 Fixed IO#read with buf.
I hit the following two problems.

  - `io.read(0, buf)` always returned a new empty string object.
  - `io.read(num, buf)` was appending data to the given `buf`.
    This also meant that `buf` was never empty if EOF was reached.
2023-12-16 14:42:52 +09:00
Yukihiro "Matz" Matsumoto d14a269f49 Merge pull request #6114 from dearblue/integrate-catch
Move `L_RAISE` and `L_BREAK` blocks to `OP_RAISEIF`
2023-12-16 13:08:33 +09:00
Yukihiro "Matz" Matsumoto ecea3f2531 Merge pull request #6117 from mruby/dependabot/github_actions/actions/upload-artifact-4
build(deps): bump actions/upload-artifact from 3 to 4
2023-12-16 13:05:38 +09:00
Yukihiro "Matz" Matsumoto 6fad067ded mruby-binding: raise in upper count check
We count `Proc` upper links then check for upper bounds (default:20),
but now we raise an exception as soon as the count exceeds the limit so
that we can avoid traverse unnecessary upper links.
2023-12-16 12:21:55 +09:00
dependabot[bot] 1b7f2fb175 build(deps): bump actions/upload-artifact from 3 to 4
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3 to 4.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v3...v4)

---
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>
2023-12-15 14:22:12 +00:00
dearblue 990e18ad59 Improve branching in the execution part of the OP_SEND block
The `MRB_METHOD_CFUNC_P()` macro contains several branches, which will be replaced by simple branches.
2023-12-15 21:46:00 +09:00
dearblue 7144eab350 Replace for and CHECKPOINT block comprehensions
I think it will make the eyes less tired for a process flow.
2023-12-15 21:46:00 +09:00
dearblue e9904ddb2a Move L_RAISE and L_BREAK blocks to OP_RAISEIF
`OP_RAISEIF` should be easier to relate than `OP_RETURN`.
2023-12-15 21:46:00 +09:00
Yukihiro "Matz" Matsumoto 24eca2e50b mruby-fiber (fiber_to_s): omit position info for terminated fibers
Since Fiber#to_s did not include location information before #6105,
when location information cannot be retrieved for terminated fibers,
instead of meaningless information such as "(unknown):0", we omit
positional information altogether for terminated fibers; ref #6111
2023-12-14 18:56:19 +09:00
Yukihiro "Matz" Matsumoto e9237f444a Merge pull request #6111 from dearblue/fiber-to_s.1
Consider proc to be GC'ed if fiber is terminated
2023-12-14 14:59:18 +09:00
Yukihiro "Matz" Matsumoto 5311d1aa1b Merge pull request #6106 from dearblue/fiber-limits-ease
Ease fiber limitations
2023-12-13 16:10:42 +09:00
Yukihiro "Matz" Matsumoto ae8dcb82ba vm.c: CINFO_SKIP should not be called with prev_jmp == NULL
We have added assertion to ensure.
2023-12-12 16:49:11 +09:00
Yukihiro "Matz" Matsumoto 89d4e8c851 Merge pull request #6113 from dearblue/unreachable
Remove unreachable code in `OP_R_BREAK`
2023-12-12 16:48:55 +09:00
dearblue 38c7936c94 Remove unreachable code in OP_R_BREAK
Termination of fiber by `break` results in a `LocalJumpError`, so the indicated code will not be executed.
2023-12-11 21:25:08 +09:00
Yukihiro "Matz" Matsumoto 93d842e045 Merge pull request #6112 from dearblue/labeler
Update labeler.yml for version 5
2023-12-10 20:01:17 +09:00
dearblue c0b5bc4ae8 Consider proc to be GC'ed if fiber is terminated
When fiber is terminated, the pointer indicated by `f->cxt->cibase->proc` is not protected from GC.
I should have done this patch way as of commit 9af6264d6b (#6105).
2023-12-09 22:28:47 +09:00
dearblue 88571052e8 Update labeler.yml for version 5 2023-12-09 17:28:13 +09:00
Yukihiro "Matz" Matsumoto 34346e75a4 Merge pull request #6103 from dearblue/RBreak-ci
RBreak remembers the CI location
2023-12-09 11:35:23 +09:00
Yukihiro "Matz" Matsumoto 645a464b2d mruby-fiber (fiber_to_s): retrieve position from terminated fibers; #6105
Since `cxt->ci` points to the last active callinfo, `cxt->ci == cxt->cibase`
does not mean it does not have correct `proc` information, so we have
removed the `f->cxt->ci > f->cxt->cibase` check. Instead, just in case
`proc` does not have `irep` information, we try to confirm `proc` does not
point to `CFUNC` nor is not an alias.
2023-12-08 09:33:05 +09:00
Yukihiro "Matz" Matsumoto fdea7924fe mruby-fiber (fiber_to_s): do not rely on mrb_any_to_s(); ref #6105 2023-12-08 09:25:46 +09:00
Yukihiro "Matz" Matsumoto b7949e81d7 mruby-fiber (fiber_to_s): use "(unknown):0" for unknown position
Ref #6105
2023-12-08 09:22:59 +09:00
Yukihiro "Matz" Matsumoto cb54138b81 Merge pull request #6105 from dearblue/fiber.to_s
Implement `Fiber#to_s` method
2023-12-08 09:00:05 +09:00
dearblue 73c8330cbd RBreak remembers the CI location
It is now possible to specify return destination directly.
This allows callinfo to distinguish between calls to the same proc object.

At the same time, the `Kernel#catch` method is adjusted.
By removing the previously required double lambda object, the REnv object is no longer created as well.
2023-12-07 21:33:14 +09:00
Yukihiro "Matz" Matsumoto 658d5a51ac mruby-string-ext: add test for String#valid_encoding? 2023-12-07 11:34:10 +09:00
Yukihiro "Matz" Matsumoto eabe2d96e2 mruby-string-ext: add String#valid_encoding? method 2023-12-07 10:58:20 +09:00
Yukihiro "Matz" Matsumoto bef7eea468 mruby-method: small refactoring mostly regarding declarations 2023-12-06 22:20:38 +09:00
Yukihiro "Matz" Matsumoto b01eb03d2a Merge pull request #6110 from mruby/dependabot/github_actions/actions/labeler-5
build(deps): bump actions/labeler from 4 to 5
2023-12-06 15:58:59 +09:00
Yukihiro "Matz" Matsumoto fab3dfc145 Merge pull request #6107 from mruby/dependabot/github_actions/super-linter/super-linter-5.7.2
build(deps): bump super-linter/super-linter from 5.7.0 to 5.7.2
2023-12-06 15:58:47 +09:00
Yukihiro "Matz" Matsumoto 5a258f0872 Merge pull request #6109 from dearblue/fix-6108
Needs `cipop()` before crossing the C boundary
2023-12-06 15:57:16 +09:00
Yukihiro "Matz" Matsumoto abd26b7ca6 mruby-bin-mrbc/mrbc.c: replace mrbc_ prefix by mrb_ccontext
This is a most confusion file because it contained both `mrbc_` from
"mruby compiler" (e.g. mrbc_args) and `mrbc_` from "mruby compiler
context".
2023-12-06 15:54:33 +09:00
Yukihiro "Matz" Matsumoto 7be67d3acf mruby-bin-mirb: replace mrbc_ prefix by mrb_ccontext 2023-12-06 15:51:20 +09:00
Yukihiro "Matz" Matsumoto 72689b0b9c mruby-eval: replace mrbc_ prefix by mrb_ccontext 2023-12-06 15:49:21 +09:00
Yukihiro "Matz" Matsumoto 7e74dbeed3 mruby-bin-mruby: replace mrbc_ prefix by mrb_ccontext 2023-12-06 15:45:01 +09:00
Yukihiro "Matz" Matsumoto c36b212fa9 mruby-bin-debugger: replace mrbc_ prefix by mrb_ccontext 2023-12-06 15:41:15 +09:00
Yukihiro "Matz" Matsumoto a66c685c81 mruby-bin-debugger/mrdb.h: remove unnecessary struct declarations 2023-12-06 15:40:31 +09:00
Yukihiro "Matz" Matsumoto 6de4df3b31 parse.y: replace mrbc_ prefix by mrb_ccontext 2023-12-06 15:32:13 +09:00
Yukihiro "Matz" Matsumoto 9c2af6aaed load.c: replace mrbc_ prefix by mrb_ccontext 2023-12-06 15:29:02 +09:00
Yukihiro "Matz" Matsumoto 073a4f19f8 proc.h: update document in the comment (regarding compiler context) 2023-12-06 15:22:09 +09:00
Yukihiro "Matz" Matsumoto c5e3cbe4bf compile.h: stop using mrbc_ prefix for compiler context
Since it is confusing that the term `mrbc` stands for both "mruby
compiler" and "mruby compiler context" in the source code. Instead,
we use `mrb_ccontext` (stands for compiler context) prefix hereafter.

We choose `mrb_ccontext` because we have already used `mrb_context` (for
VM execusion context).
2023-12-06 15:22:08 +09:00
dependabot[bot] 7ac0b60255 build(deps): bump actions/labeler from 4 to 5
Bumps [actions/labeler](https://github.com/actions/labeler) from 4 to 5.
- [Release notes](https://github.com/actions/labeler/releases)
- [Commits](https://github.com/actions/labeler/compare/v4...v5)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-05 14:41:52 +00:00
dearblue ca9e8d91e4 Needs cipop() before crossing the C boundary
fix #6108
2023-12-05 22:03:38 +09:00
dependabot[bot] 7b74d22310 build(deps): bump super-linter/super-linter from 5.7.0 to 5.7.2
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 5.7.0 to 5.7.2.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v5.7.0...v5.7.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-04 14:03:16 +00:00
dearblue 4f1c1c16da Check fiber backward when switching with Fiber#transfer
Previously, if the caller of `Fiber#resume` had a C function call, an inconsistency would occur.
2023-12-04 22:32:57 +09:00
dearblue 42308c42b5 Fix CI misalignment between Fiber#resume and Fiber.yield
When a fiber switched by `Fiber.yield` is resumed by `Fiber#resume` by C, it is necessary to pop CI with `fiber_switch()`.
Previously, CI misalignment caused inconsistencies, including crashes, on the next `Fiber#resume`.
2023-12-04 22:32:57 +09:00
dearblue 568309b25a Propagating exceptions to the caller of Fiber#resume
Need to return control from `mrb_vm_exec()` to the caller if `Fiber#resume` was done from C.
2023-12-04 22:32:57 +09:00
dearblue aaa0f124c3 Restore the value of ci->cci with fiber_switch()
If `mrb_fiber_resume()` was called from a C function as a method definition, the mruby VM was not processed afterwards.

    Called Fiber.yield
    mrb_vm_exec()       <<-- returns from the function by CINFO_RESUMED
    fiber_switch()      <<-- this patch causes the value to return to its pre-call state
    mrb_fiber_resume()
    mrb_vm_exec()       <<-- previously, returns from the function immediately as it was CINFO_RESUMED
    ...
    main()
2023-12-04 22:32:57 +09:00
dearblue ef8b0b7ed8 Allows calling Fiber#resume from C
This patch is effectively reverts to the following:
  - commit dc65b1faf1 (#5782)
  - commit f4c4809750 (#5947)

Ref. #6063
2023-12-04 22:32:51 +09:00
dearblue ad4c35b022 Enhanced Fiber Testing
The main objective is to make sure that fiber can be handled from C.

Also, add a mechanism to detect that the mruby VM has stopped in the middle of the process.
If it stops halfway, the test will be terminated with `abort()`.
2023-12-04 21:48:23 +09:00
Yukihiro "Matz" Matsumoto 7f1ae1c344 mruby-method (method_to_s): avoid goto across declarations for C++ 2023-12-03 22:39:27 +09:00
Yukihiro "Matz" Matsumoto 90ec09a716 mruby-proc-ext (mrb_proc_source_location): support aliases 2023-12-03 22:38:31 +09:00
Yukihiro "Matz" Matsumoto 87453fb70b vm.c (CI_PROC_SET): consider alias proc 2023-12-03 22:38:31 +09:00
Yukihiro "Matz" Matsumoto 9eae7df26e mruby-method (method_to_s): _proc may be nil; add check 2023-12-03 22:38:31 +09:00
Yukihiro "Matz" Matsumoto e8da16cdf5 vm.c (exec_irep): need to support aliases 2023-12-03 22:38:30 +09:00
Yukihiro "Matz" Matsumoto 02f189cebc mruby-method (method_to_s): add origin name in the string representation 2023-12-03 22:38:30 +09:00
Yukihiro "Matz" Matsumoto f5bc82f267 mruby-method (method_to_s): avoid origin class like Object(Object) 2023-12-03 22:38:30 +09:00
Yukihiro "Matz" Matsumoto b52870b4c6 mruby-method: add const modifier to struct RProc* 2023-12-03 22:38:29 +09:00
Yukihiro "Matz" Matsumoto 9da0c7e1a4 Update .pre-commit-config.yaml 2023-12-03 09:39:33 +09:00
dearblue 9af6264d6b Implement Fiber#to_s method
If the filename and line number cannot be obtained, "(unknown):1" is used instead.

Also, the file name information of the terminated fiber cannot be retrieved and will be replaced as well.
This limitation is due to the fact that `cibase->proc` of the terminated fiber is collected by the GC.

```console
% bin/mruby -e 'p Fiber.new { p Fiber.current }.resume'
#<Fiber:0x82423bef0 -e:1 (resumed)>
#<Fiber:0x82423bef0 (unknown):1 (terminated)>
```
2023-12-01 21:30:16 +09:00
Yukihiro "Matz" Matsumoto ccdd81eb69 Merge pull request #6101 from dearblue/unwinding
Reorganization of unwinding at `break` / `return`.
2023-11-22 08:11:15 +09:00
Yukihiro "Matz" Matsumoto fdef59b3a1 AUTHORS: update entries [ci skip] 2023-11-21 09:37:58 +09:00
Yukihiro "Matz" Matsumoto 53a8472e5e mruby-kernel-ext/test: skip some tests that related to alias callee.
The last commit changed the behavior of aliases, and we no longer keep
the alias name symbol but the original name. Since this is a small
incompatibility from CRuby and it requires some memory to fix this, we
keep this issue right now.
2023-11-21 09:37:17 +09:00
Yukihiro "Matz" Matsumoto f2dc76e3b5 Change alias handling to avoid using mid in Env; ref 6098
Since `Env` objects are shared by Blocks/Procs in the same context,
making multiple aliases in one context screws up with alias names.
New implementation uses alias bodies (Procs) to refer new names.
As a side effect, `__callee__` stop working correctly for aliases.
To fix this `__callee__` problem, we need to keep alias method names in
`callinfo`, which consumes more memory. We are wondering that is worth
the compatibility.
2023-11-21 09:37:17 +09:00
Yukihiro "Matz" Matsumoto f6cbf6ac1a Merge pull request #6102 from mruby/dependabot/github_actions/super-linter/super-linter-5.7.0
build(deps): bump super-linter/super-linter from 5.6.1 to 5.7.0
2023-11-21 09:37:07 +09:00
Yukihiro "Matz" Matsumoto 9c1c9ba8e5 vm.c: rename local variable m to p
`m` usually stands for a method but this one was `struct RProc*`.
2023-11-19 23:21:05 +09:00
Yukihiro "Matz" Matsumoto 956379928c mruby-io/io.c: fix possible short integer overflow 2023-11-19 07:47:23 +09:00
Yukihiro "Matz" Matsumoto 698da0982f mruby-io/io.c: fix fsize_t and mrb_ssize mixture 2023-11-19 07:45:29 +09:00
dependabot[bot] ee7ea34b10 build(deps): bump super-linter/super-linter from 5.6.1 to 5.7.0
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 5.6.1 to 5.7.0.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v5.6.1...v5.7.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-16 14:28:54 +00:00
Yukihiro "Matz" Matsumoto 91b4da3a2b class.c: keep alias flag in proc object; fix #6098 2023-11-16 17:18:28 +09:00
Yukihiro "Matz" Matsumoto 9959d4fc66 range.c: use presym for symbol initialization 2023-11-16 16:30:40 +09:00
Yukihiro "Matz" Matsumoto a94005b740 range.c: use presym to initialize Range class 2023-11-16 16:27:57 +09:00
dearblue 2e881d3297 Reorganization of unwinding at break / return.
The unwinding process that has been done at each point in time is now done in a merged block after looking for the last ci to `break` / `return`.
2023-11-12 20:39:33 +09:00
Yukihiro "Matz" Matsumoto 431d9d8a12 mrbgems/full-core.gembox: use parentheses for method call expression 2023-11-12 19:01:08 +09:00
Yukihiro "Matz" Matsumoto 76d0ff9a45 error.c: use presym for error initialization 2023-11-11 23:49:32 +09:00
Yukihiro "Matz" Matsumoto 8e6f4a79a8 hash.c: use presym to initialize Hash class 2023-11-11 23:48:31 +09:00
Yukihiro "Matz" Matsumoto df1d397da5 numeric.c: use presym to initialize numeric classes 2023-11-11 23:48:31 +09:00
Yukihiro "Matz" Matsumoto 5084716e6b class.c: use presym to undefine Module methods 2023-11-11 23:48:23 +09:00
Yukihiro "Matz" Matsumoto d5a69ac8c7 proc.c: use presym to initialize Proc class 2023-11-07 21:40:45 +09:00
Yukihiro "Matz" Matsumoto e41bbaa67a class.c: move Proc class allocation to proc.c 2023-11-07 21:40:45 +09:00
Yukihiro "Matz" Matsumoto eb906bd4c1 array.c: use presyms to define the class 2023-11-07 21:40:44 +09:00
Yukihiro "Matz" Matsumoto 1dec82d82f object.c: use presyms to define classes 2023-11-07 21:40:44 +09:00
Yukihiro "Matz" Matsumoto 4fd63cfb9d kernel.c: use presym to define a module 2023-11-07 21:40:44 +09:00
Yukihiro "Matz" Matsumoto 82f6facaad Merge pull request #6097 from dearblue/fiber-new
Add a new `mrb_fiber_new()` with MRB_API
2023-11-07 21:40:31 +09:00
dearblue 1bb77170ec Add a new mrb_fiber_new() with MRB_API 2023-11-05 20:36:29 +09:00
Yukihiro "Matz" Matsumoto 9e50d67fe7 Merge pull request #6096 from mruby/dependabot/github_actions/super-linter/super-linter-5.6.1
build(deps): bump super-linter/super-linter from 5.6.0 to 5.6.1
2023-11-03 07:35:13 +09:00
dependabot[bot] 52ac930af3 build(deps): bump super-linter/super-linter from 5.6.0 to 5.6.1
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 5.6.0 to 5.6.1.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v5.6.0...v5.6.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-02 14:07:54 +00:00
Yukihiro "Matz" Matsumoto 587d93d5a5 Merge pull request #6095 from mruby/dependabot/github_actions/super-linter/super-linter-5.6.0
build(deps): bump super-linter/super-linter from 5.4.3 to 5.6.0
2023-11-02 13:21:35 +09:00
Yukihiro "Matz" Matsumoto bc012deef9 object.c (mrb_eql): avoid mrb_funcall_argv() when possible 2023-11-02 13:20:10 +09:00
Yukihiro "Matz" Matsumoto 7db4050040 enum.c: use presym 2023-11-02 13:15:45 +09:00
Yukihiro "Matz" Matsumoto 8c068c57c8 Merge pull request #6092 from dearblue/lockfile
Get from local only if there is no default branch name
2023-11-02 12:07:56 +09:00
Yukihiro "Matz" Matsumoto 1e3d47760f Merge pull request #6090 from LanzaSchneider/patch-1
fix(class.c): typo in format specifiers
2023-11-02 08:20:39 +09:00
Yukihiro "Matz" Matsumoto 8708186692 Merge pull request #6091 from dearblue/binding.5
Fixed acquisition of wrong target class in `Kernel#binding`
2023-11-01 23:05:50 +09:00
Yukihiro "Matz" Matsumoto c99b67db65 gc.c: use presym for GC initialization 2023-11-01 22:24:57 +09:00
Yukihiro "Matz" Matsumoto c080d16150 string.c: use presym to define String class 2023-11-01 22:23:35 +09:00
Yukihiro "Matz" Matsumoto 571cb54f38 compar.c: remove unused file 2023-11-01 22:21:59 +09:00
dependabot[bot] ccf37b00aa build(deps): bump super-linter/super-linter from 5.4.3 to 5.6.0
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 5.4.3 to 5.6.0.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v5.4.3...v5.6.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-31 14:26:22 +00:00
dearblue 8284234229 Get from local only if there is no default branch name
The branch name of the cloned repository should be determined by the build configuration file.

fixes #6087
2023-10-28 19:02:50 +09:00
dearblue 0b25c9d224 Fixed acquisition of wrong target class in Kernel#binding
fixed #6089
2023-10-28 18:24:41 +09:00
Lanza 4ae0bacc6e fix(class.c): typo in format specifiers 2023-10-28 13:47:05 +08:00
Yukihiro "Matz" Matsumoto 552944b34e Merge pull request #6088 from jbampton/format-markdown-table
Standardize Markdown table format
2023-10-27 07:46:14 +09:00
John Bampton bbd5701617 Standardize Markdown table format 2023-10-26 16:15:57 +10:00
Yukihiro "Matz" Matsumoto c1feb41828 Merge pull request #6056 from dearblue/build/host-shared
Brush up `build_config/host-shared.rb` file
2023-10-26 14:23:49 +09:00
Yukihiro "Matz" Matsumoto ac73793a8f range.c: use mrb_define_method_id() which directly use symbols 2023-10-25 22:01:54 +09:00
dearblue 41cce1561f Brush up build_config/host-shared.rb file
Summary:

  - VisualC++ does not supported.
  - `cc.flags` must maintain array objects.
2023-10-25 21:58:28 +09:00
Yukihiro "Matz" Matsumoto 7a08c7042f string.c: move __ENCODING__ from kernel.c 2023-10-25 15:05:10 +09:00
Yukihiro "Matz" Matsumoto f85a3aff2b Merge pull request #6086 from yujiyokoo/add-wii-build-config
Add build config for Nintendo Wii
2023-10-23 17:34:33 +09:00
Yukihiro "Matz" Matsumoto 279e100ad5 Merge pull request #6085 from dearblue/define_installer.1
Fixed `MRuby::Build#define_installer`
2023-10-23 15:36:14 +09:00
Yukihiro "Matz" Matsumoto bba659f174 Merge pull request #6083 from mruby/dependabot/github_actions/super-linter/super-linter-5.4.3
build(deps): bump super-linter/super-linter from 5.4.0 to 5.4.3
2023-10-23 15:34:17 +09:00
Yukihiro "Matz" Matsumoto 461c97225e LICENSE: remove the end date of copyright notice; close #6080 2023-10-23 15:31:34 +09:00
Yukihiro "Matz" Matsumoto e7e47bb683 AUTHORS: update entries [ci skip] 2023-10-23 15:29:23 +09:00
Yukihiro "Matz" Matsumoto 0443f14fd0 array.c,hash.c,numeric.c,string.c: use mrb_define_method_id()
For primary class libraries.
2023-10-23 15:23:08 +09:00
Yukihiro "Matz" Matsumoto 8ad825dc3b class.c,kernel.c,object.c: use mrb_define_method_id()
Instead of mrb_define_method(), so that symbol resolution can be done in
compile-time.
2023-10-23 15:18:26 +09:00
Yukihiro "Matz" Matsumoto 0b8daabf27 object.c: fix wrong ISO section numbers 2023-10-23 12:26:51 +09:00
Yukihiro "Matz" Matsumoto fe6f9faba4 vm.c: reduce number of check_method_noarg() calls 2023-10-22 22:04:58 +09:00
Yuji Yokoo 2b9287dbc4 Add build_config.rb for Nintendo Wii 2023-10-22 00:07:22 +10:30
dearblue 9b0d516310 Fixed MRuby::Build#define_installer
Symbolic links were created with absolute paths, but to cope with path fluctuations between build and reference, they are now relative paths.

ref. #6084
2023-10-21 19:42:26 +09:00
dependabot[bot] 3c5aa936c7 build(deps): bump super-linter/super-linter from 5.4.0 to 5.4.3
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 5.4.0 to 5.4.3.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v5.4.0...v5.4.3)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-18 14:50:06 +00:00
Yukihiro "Matz" Matsumoto 10d4a4278e class.c: make keyword_max mrb_int; ref #4754
Which is compared to other mrb_int.
2023-10-17 13:27:19 +09:00
Yukihiro "Matz" Matsumoto 9553284480 Merge pull request #6081 from dearblue/open-x
Add "x" mode option for `IO.open`
2023-10-17 13:27:07 +09:00
dearblue 88bc8c9144 Add "x" mode option for IO.open
From CRuby 2.6 feature.

This is the "x" mode (`O_EXCL`; exclusive create) of `fopen(3)` introduced in C11.

ref. https://bugs.ruby-lang.org/issues/11258
2023-10-15 16:41:48 +09:00
dearblue 782fd7e014 Integrate error handling for IO.open 2023-10-15 16:32:01 +09:00
Yukihiro "Matz" Matsumoto dec81fde4a Merge pull request #6079 from jbampton/fix-case-of-mruby
include/mruby/version.h: change `MRuby` to `mruby`
2023-10-15 05:16:04 +07:00
Yukihiro "Matz" Matsumoto 244156af2a Merge pull request #6078 from jbampton/fix-indent
Fix indentation in two Ruby files
2023-10-15 05:15:38 +07:00
John Bampton db20a19711 include/mruby/version.h: change MRuby to mruby 2023-10-14 19:13:49 +10:00
John Bampton a83d7d3510 Fix indentation in two Ruby files 2023-10-14 18:52:30 +10:00
Yukihiro "Matz" Matsumoto 4656ea5ccd Merge pull request #6000 from jbampton/update-docker-files
docker: use less image layers and update compose version
2023-10-14 05:36:04 +07:00
Yukihiro "Matz" Matsumoto 56a46cdff5 Merge pull request #6075 from mruby/dependabot/github_actions/super-linter/super-linter-5.4.0
build(deps): bump super-linter/super-linter from 5.3.1 to 5.4.0
2023-10-14 05:34:49 +07:00
Yukihiro "Matz" Matsumoto c22fbb2aa7 Merge pull request #6076 from dearblue/fiber-unwinding
Fixed unwinding block that could point to invalid PC
2023-10-13 20:33:03 +07:00
Yukihiro "Matz" Matsumoto 3e20c5c9b3 Merge pull request #6069 from dearblue/MRUBY_PACKAGE_DIR
Corrected wrong `MRUBY_PACKAGE_DIR`
2023-10-13 16:04:25 +07:00
Yukihiro "Matz" Matsumoto 4c696ed9e3 array.c: set array size limitation again
Unlike strings, arrays occupies more memory. It is still arguable
whether the current limit (131072) is appropriate.
2023-10-13 18:01:21 +09:00
Yukihiro "Matz" Matsumoto 1321e33f08 mruby-range-ext: implement __empty_range? in C 2023-10-13 16:59:21 +09:00
Yukihiro "Matz" Matsumoto deae227dff mruby-range-ext: update overlap? to handle empty ranges
The code is taken from ActiveSupport (Rails).
2023-10-12 13:40:28 +09:00
Yukihiro "Matz" Matsumoto 3277cc9ce1 numeric.c (int_to_s): avoid mrb_get_args() 2023-10-11 20:32:09 +09:00
Yukihiro "Matz" Matsumoto 717f91e5c6 array.c (mrb_ary_last): avoid mrb_get_args() 2023-10-11 20:31:23 +09:00
Yukihiro "Matz" Matsumoto fae8e55396 pool.c (mrb_pool_realloc): add comments in reallocation code 2023-10-11 13:39:53 +09:00
Yukihiro "Matz" Matsumoto 64e08c6d99 pool.c: add cast to void* 2023-10-11 13:38:59 +09:00
Yukihiro "Matz" Matsumoto 5d53c2b951 pool.c: remove unused mrb_pool_can_realloc() 2023-10-10 22:31:34 +09:00
Yukihiro "Matz" Matsumoto a538837fb1 pool.c (mrb_pool_realloc): do nothing if realloc() tries to shrink 2023-10-10 22:17:30 +09:00
dearblue e7828bac4d Fixed unwinding block that could point to invalid PC
Switching back from a fiber with an exception could point to an invalid PC.
The investigation was inspired by #6060.
2023-10-10 21:29:38 +09:00
Yukihiro "Matz" Matsumoto 42a621b42e pool.c: small refactoring regarding local variable declarations 2023-10-10 14:49:19 +09:00
dependabot[bot] 66ce1c03f4 build(deps): bump super-linter/super-linter from 5.3.1 to 5.4.0
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 5.3.1 to 5.4.0.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v5.3.1...v5.4.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-09 14:09:08 +00:00
Yukihiro "Matz" Matsumoto 097681b4d4 mruby-pack: unpack "b/B" should limit result size 2023-10-09 22:39:44 +09:00
Yukihiro "Matz" Matsumoto 861f8bdfa9 mruby-enumerator: add Enumerator#size
If the original object responds to `size` method, `Enumerator#size` calls
that method, otherwise return `nil`. CRuby returns the exact size for
more cases (e.g. Enumerable::Lazy#size), but mruby has more limitations.
2023-10-09 22:39:43 +09:00
Yukihiro "Matz" Matsumoto 49f86f19b2 mruby-enumerator: put "__" prefix to internal enumerator_block_call() 2023-10-09 22:39:43 +09:00
Yukihiro "Matz" Matsumoto 735fa246bf mruby-enumerator: remove internal attribute methods; ref #6068
Removed methods: obj, args, kwd, meth, fib.
2023-10-09 22:39:43 +09:00
Yukihiro "Matz" Matsumoto 298155d59e Merge pull request #6071 from jbampton/pre-commit-autoupdate 2023-10-06 23:58:45 +09:00
John Bampton 903ffb1584 pre-commit autoupdate
https://pre-commit.com/#pre-commit-autoupdate
2023-10-04 01:17:23 +10:00
John Bampton 24ac7a547a Fix spelling 2023-10-04 01:17:23 +10:00
Yukihiro "Matz" Matsumoto 83d12f8d52 vm.c: GCC does not provide __has_feature() 2023-10-03 01:05:26 +09:00
Yukihiro "Matz" Matsumoto b9536ea35f vm.c: use smaller MRB_CALL_LEVEL_MAX with address sanitizer; fix #6068
Since ASAN uses lower memory bound. The other ideas to address #6068
might follow, e.g. removing `args=` from Enumerator.
2023-10-02 21:15:54 +09:00
Yukihiro "Matz" Matsumoto 771b56c796 mruby-socket: hide internal method new_with_prelude
- rename new_with_prelude to _new_with_prelude
- take a block instead of proc
2023-09-28 14:36:42 +09:00
Yukihiro "Matz" Matsumoto 67f1f0997c Merge pull request #6070 from komainu8/demotion-mrb_f_raise-from-mrb_api
Demotion mrb_f_raise() in kernel.c from MRB_API too
2023-09-28 14:22:19 +09:00
Yukihiro "Matz" Matsumoto 10aab4cc1b proc.c: prohibit direct Proc allocation() like CRuby; ref #6065 2023-09-28 11:37:46 +09:00
Yukihiro "Matz" Matsumoto d298da8e72 vm.c (eval_under): check if irep is NULL; fix #6065 2023-09-28 11:37:07 +09:00
Yukihiro "Matz" Matsumoto 0e98508c33 string.c (mrb_string_value_cstr): RSTR_PTR(s) may be NULL; fix #6067 2023-09-28 09:26:02 +09:00
Yukihiro "Matz" Matsumoto 4c7fab6126 string.c (check_null_byte): str may point NULL buffer; ref #6067 2023-09-28 09:24:30 +09:00
Horimoto Yasuhiro d55cec41eb Demotion mrb_f_raise() in kernel.c from MRB_API
The prototype declaration of mrb_f_raise() has arleady demoted from
MRB_API in a below commit.

https://github.com/mruby/mruby/commit/0898ce982eea706c9a7b814280cdda09e82abe17

However, the entity of mrb_f_raise() in kernel.c is set MRB_API yet.
Therefore, mruby occures build error with MSVC(in Visual Studio 2022) as below.

https://github.com/groonga/groonga/actions/runs/6310140553/job/17131485675#step:11:2067

The cause of the above error that we define both mrb_f_raise() with
MRB_API and mrb_f_raise() without MRB_API.
2023-09-28 09:17:54 +09:00
Yukihiro "Matz" Matsumoto 0ac917e228 Revert "mrbgems/mruby-struct/src/struct.c: use direct array access"
This reverts commit 159ff5b28d.
Fix #6066
2023-09-28 07:40:31 +09:00
Yukihiro "Matz" Matsumoto a80f394d97 mruby-array-ext (ary_rotate_bang): mrb_ary_modify may alter buf address 2023-09-27 18:37:38 +09:00
Yukihiro "Matz" Matsumoto 629a6839fd mruby-array-ext (ary_compact_bang): skip check that is always true 2023-09-27 18:32:44 +09:00
Yukihiro "Matz" Matsumoto f65229d103 mruby-array-ext (ary_compact_bang): mrb_ary_modify may alter buf address 2023-09-27 18:30:43 +09:00
Yukihiro "Matz" Matsumoto 7d3679dfc8 mruby-string-ext: refactoring
- raise exception in utf8code
- str_codepoints() use mrb_utf8len_table directly
2023-09-27 18:11:19 +09:00
Yukihiro "Matz" Matsumoto 5705d884ce mruby-string-ext (utf8code): change arguments to point at the end 2023-09-27 18:08:12 +09:00
dearblue c805d4dbba Corrected wrong MRUBY_PACKAGE_DIR
ref. #6064
2023-09-25 21:50:31 +09:00
Yukihiro "Matz" Matsumoto 2e3b482aa9 array.c, string.c: remove length limits on UNIX-ish OSes
- Linux
- MacOS
- FreeBSD
- OpenBSD

Send us a pull-request if you want to add your favorite OS here.
The size limitation will be done by malloc(3) on those OSes.
2023-09-23 19:57:44 +09:00
Yukihiro "Matz" Matsumoto 15bb6a9f9b mruby-string-ext: fix a typo; ref #6016 2023-09-23 11:44:15 +09:00
Yukihiro "Matz" Matsumoto 8a538c40c0 mruby-string-ext: implement core part of codepoints in C; close #6061 2023-09-23 11:36:20 +09:00
Yukihiro "Matz" Matsumoto 2db80b81c9 Merge pull request #6062 from mruby/dependabot/github_actions/super-linter/super-linter-5.3.1
build(deps): bump super-linter/super-linter from 5.3.0 to 5.3.1
2023-09-23 00:04:07 +09:00
Yukihiro "Matz" Matsumoto 9ee7edc1ac mruby-fiber/fiber.c (fiber_switch): check c->cibase->proc env is NULL
ref #6060
2023-09-22 19:36:33 +09:00
dependabot[bot] ed30e2e568 build(deps): bump super-linter/super-linter from 5.3.0 to 5.3.1
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 5.3.0 to 5.3.1.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v5.3.0...v5.3.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-21 14:29:25 +00:00
Yukihiro "Matz" Matsumoto 0730bda60e mruby-range-ext: add tests for Range#overlap? 2023-09-21 15:28:56 +09:00
Yukihiro "Matz" Matsumoto 384d0e2d21 mruby-range-ext: implement Range#overlap? method
Which is implemented in CRuby recently.
2023-09-21 15:28:06 +09:00
Yukihiro "Matz" Matsumoto 393aaada64 mruby-pack/pack.c (read_tmpl): fix out-of-bound access with templates 2023-09-20 09:51:22 +09:00
Yukihiro "Matz" Matsumoto b064d7e547 mruby-time/time.c (time_alloc_time): need to handle negative time_t 2023-09-19 14:22:49 +09:00
Yukihiro "Matz" Matsumoto ec3baece4f vm.c (catch_handler_find): check if irep is NULL; fix #6052 2023-09-19 14:22:49 +09:00
Yukihiro "Matz" Matsumoto 75e8a72649 vm.c (CI_PROC_SET): check whether p->body.irep is not NULL; ref #6052 2023-09-19 14:22:49 +09:00
Yukihiro "Matz" Matsumoto 8afb73f3e2 mruby-socket/socket.rb: should not call unix_path for non UNIX Addrinfo
ref #6051
2023-09-19 14:22:49 +09:00
Yukihiro "Matz" Matsumoto 52082ba399 mruby-socket/socket.c (mrb_addrinfo_unix_path): check sockaddr type
`sockaddr` should be a string; fix #6051
2023-09-19 14:22:49 +09:00
Yukihiro "Matz" Matsumoto 40f08e22f1 Merge pull request #6058 from mruby/dependabot/github_actions/super-linter/super-linter-5.3.0
build(deps): bump super-linter/super-linter from 5.2.2 to 5.3.0
2023-09-19 14:05:20 +09:00
dependabot[bot] 38113d2524 build(deps): bump super-linter/super-linter from 5.2.2 to 5.3.0
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 5.2.2 to 5.3.0.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v5.2.2...v5.3.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-18 14:15:49 +00:00
Yukihiro "Matz" Matsumoto 39d805e1da Merge pull request #6055 from dearblue/libmruby-name
Fix libmruby name for VisualC++
2023-09-18 15:47:41 +09:00
Yukihiro "Matz" Matsumoto 3ce5f2df8b Merge pull request #6054 from dearblue/mruby-config-plus
Extends `bin/mruby-config`
2023-09-17 18:23:54 +09:00
dearblue 7112db9fba Extends bin/mruby-config
Added output for C++ and Assembly, ObjectiveC.
2023-09-17 17:48:36 +09:00
dearblue 7ac536e3ca Fix libmruby name for VisualC++ 2023-09-17 17:42:25 +09:00
Yukihiro "Matz" Matsumoto 74949b3e7e Merge pull request #6053 from dearblue/gitattributes
Add `.gitattributes` for newline code normalization
2023-09-17 16:36:28 +09:00
dearblue 078b5ccaff Add .gitattributes for newline code normalization
References:
  - [Git] リポジトリで改行コードを正規化する
    https://zenn.dev/murnana/articles/eol-and-gitattributes
  - 行終端を処理するようGitを設定する - GitHub Docs
    https://docs.github.com/ja/get-started/getting-started-with-git/configuring-git-to-handle-line-endings
2023-09-17 13:52:48 +09:00
Yukihiro "Matz" Matsumoto 4810706ccc vm.c: refactor redundant if conditions 2023-09-16 14:49:58 +09:00
Yukihiro "Matz" Matsumoto f041d3a5d5 Merge pull request #6047 from mruby/dependabot/github_actions/super-linter/super-linter-5.2.2
build(deps): bump super-linter/super-linter from 5.2.1 to 5.2.2
2023-09-15 13:35:03 +09:00
Yukihiro "Matz" Matsumoto e8254eda42 gc.c: update comment for flexible array members (C++ incompatible) [ci skip] 2023-09-15 13:33:52 +09:00
Yukihiro "Matz" Matsumoto 4fe8b074bb gc.c: remove prev link from mrb_heap_page 2023-09-15 13:33:52 +09:00
Yukihiro "Matz" Matsumoto 44b5153360 gc.c: revert af68de52dddd80afe1620c45680eb055767a412f
The change increased memory consumption significantly
2023-09-15 13:33:52 +09:00
Yukihiro "Matz" Matsumoto 22e74a7ee5 gc.c: experiment before removing page->prev link 2023-09-15 13:33:52 +09:00
Yukihiro "Matz" Matsumoto 9b90fd4f60 gc.c (incremental_sweep_phase): rebuild free pages link only if needed 2023-09-15 13:33:52 +09:00
Yukihiro "Matz" Matsumoto 9f840e111a gc.c: inline unlink_heap_page which was called only once 2023-09-15 13:33:52 +09:00
Yukihiro "Matz" Matsumoto 0f69e93664 gc.c: inline link_heap_page which was called once 2023-09-15 13:33:51 +09:00
Yukihiro "Matz" Matsumoto 117fcfc8e9 gc.c: stop using bidirectional link for free_heaps
Reduce size of the heap pages again; ref #6041
2023-09-15 13:33:51 +09:00
Yukihiro "Matz" Matsumoto e1c96b709a Merge pull request #6045 from dearblue/presym-escape.2
Fixes escape sequence bug and enhancements in Presym scanning
2023-09-15 13:11:26 +09:00
dependabot[bot] d8ad654460 build(deps): bump super-linter/super-linter from 5.2.1 to 5.2.2
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 5.2.1 to 5.2.2.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v5.2.1...v5.2.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-13 14:08:56 +00:00
Yukihiro "Matz" Matsumoto d708931b10 gc.c: revert 38b9a25e83
Fix #6041
2023-09-09 14:31:13 +09:00
dearblue 25f360803c Fixes escape sequence bug and enhancements in Presym scanning
In #6011, a hexadecimal escape sequence followed by a hexadecimal character would cause a compile error.
Also, avoid using "Numbered Parameter" which older Ruby does not have (e.g. AppVeyor).

ref. #6044
2023-09-08 22:57:24 +09:00
Yukihiro "Matz" Matsumoto 5eddccf89a gc.c: remove unnecessary symbol local variables 2023-09-08 14:15:54 +09:00
Yukihiro "Matz" Matsumoto d7b2e3ab14 mruby-compiler/parse.y: add print name for identifier tokens 2023-09-05 23:29:24 +09:00
Yukihiro "Matz" Matsumoto e8841fbf58 gc.h: move mrb_heap_page definition to gc.c 2023-09-05 23:29:24 +09:00
Yukihiro "Matz" Matsumoto acf5b74daa vm.c (ary_new_from_regs): avoid mrb_ary_push()
Use mrb_ary_new_from_values(), which is faster instead.
2023-09-05 23:29:23 +09:00
Yukihiro "Matz" Matsumoto 9914243d68 vm.c: use direct array access if possible 2023-09-05 23:29:23 +09:00
Yukihiro "Matz" Matsumoto 0eef05cc00 array.c (mrb_ary_to_s): use direct array access 2023-09-05 23:29:23 +09:00
Yukihiro "Matz" Matsumoto 159ff5b28d mrbgems/mruby-struct/src/struct.c: use direct array access
Unless we need boundary check, we don't need to use mrb_ary_ref().
2023-09-05 23:29:23 +09:00
Yukihiro "Matz" Matsumoto 1578f4bb99 mruby-data/data.c: use direct array access
Unless we need boundary check, we don't need to use mrb_ary_ref()
2023-09-05 23:29:23 +09:00
Yukihiro "Matz" Matsumoto 4cf810e4ea Merge pull request #6042 from mruby/dependabot/github_actions/actions/checkout-4
build(deps): bump actions/checkout from 3 to 4
2023-09-05 23:28:55 +09:00
dependabot[bot] f893c18088 build(deps): bump actions/checkout from 3 to 4
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [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/v3...v4)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-04 14:59:02 +00:00
Yukihiro "Matz" Matsumoto 792459e63d Merge pull request #6040 from dearblue/puts-eol
Convert to string before output in `puts`
2023-08-30 22:30:58 +09:00
Yukihiro "Matz" Matsumoto a20fbe54b9 mrbgems/mruby-test/mrbgem.rake: stop mrb isolation for each test file
It reduces the number of `mrb_state` initialization in `mrbtest`. But at
the same time, each test in a gem shares states (classes, methods, etc.)
2023-08-30 18:32:48 +09:00
Yukihiro "Matz" Matsumoto a67f32561f test/t/codegen.rb: test 127 arguments with break not next
In addition, avoid using undefined constant `A` because it terminates
actual execution by `NameError`.
2023-08-30 18:28:59 +09:00
dearblue 301bcc636e Convert to string before output in puts
For example, evaluating `puts nil` raised `NoMethodError` before.
2023-08-29 21:59:09 +09:00
Yukihiro "Matz" Matsumoto a17fdb7481 AUTHORS: update entries [ci skip] 2023-08-28 10:59:29 +09:00
Yukihiro "Matz" Matsumoto b85b6822b2 hash.c (mrb_hash_aset): avoid slower mrb_get_args() 2023-08-26 22:30:20 +09:00
Yukihiro "Matz" Matsumoto 0578e518e6 src/vm.c: adjust mrb_gc_protect() for kdict argument
It was called repeatedly in some cases.
2023-08-25 23:12:08 +09:00
Yukihiro "Matz" Matsumoto 1e385692d1 Rakefile: remove default build target directories in deep_clean
Ref #6038, #6032
2023-08-24 12:57:27 +09:00
Yukihiro "Matz" Matsumoto f43f2fc8f3 mruby-socket/socket.c: use internal name for instance variables
For Socket::Option objects.
2023-08-23 11:27:03 +09:00
Yukihiro "Matz" Matsumoto 2160be7db7 mruby-socket/socket.rb: remove unused canonname accessor 2023-08-22 23:27:08 +09:00
Yukihiro "Matz" Matsumoto 95e09c0c95 mruby-method: implement Kernel#singleton method in C
- Also fixes error message inconsistency
- Avoid unnecessary method object allocation if possible
2023-08-22 10:53:52 +09:00
Yukihiro "Matz" Matsumoto a16b2b0e12 Merge pull request #6038 from dearblue/revert-6032-update-rake-task-clean
Revert "Rake: update task clean to remove `bin` and `build` folders"
2023-08-21 22:28:17 +09:00
Yukihiro "Matz" Matsumoto 182c06a46b codedump.c: fflush() output 2023-08-21 17:27:03 +09:00
Yukihiro "Matz" Matsumoto 982a378425 mruby-print/print.c: stop flushing every time in printstr
Instead, call `fflush` at the end of `print` method, if stdout is
connected to a tty.
2023-08-21 12:47:44 +09:00
Yukihiro "Matz" Matsumoto 192e6e3b9f mruby-print/print.c: remove internal method __printstr
Instead, implement `print` method in C and use it from mrblib/print.rb
2023-08-21 12:47:44 +09:00
dearblue 14a0cc4b7b Revert "Rake: update task clean to remove bin and build folders" 2023-08-18 22:36:21 +09:00
Yukihiro "Matz" Matsumoto bd41dfbcb9 mruby-socket/socket.c (socket_option_inspect): readable family name
Print readable name for know protocol families.
2023-08-17 10:54:59 +09:00
Yukihiro "Matz" Matsumoto 2fb478db76 Merge pull request #6037 from mruby/dependabot/github_actions/super-linter/super-linter-5.2.1
build(deps): bump super-linter/super-linter from 5.2.0 to 5.2.1
2023-08-17 10:53:10 +09:00
dependabot[bot] 1dbfeab2df build(deps): bump super-linter/super-linter from 5.2.0 to 5.2.1
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 5.2.0 to 5.2.1.
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/super-linter/super-linter/compare/v5.2.0...v5.2.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-16 14:29:51 +00:00
Yukihiro "Matz" Matsumoto 58e10f16e9 mruby-socket/socket.c: include Socket::Constants in C init 2023-08-16 13:23:56 +09:00
Yukihiro "Matz" Matsumoto 1d7c00e920 mruby-socket/socket.c: implement whole Socket::Option class in C
`mruby-pack` gem no longer needed.
2023-08-15 15:29:36 +09:00
Yukihiro "Matz" Matsumoto 83b6a63c16 mruby-socket/socket.c: implement accessors in C 2023-08-15 07:35:29 +09:00
Yukihiro "Matz" Matsumoto e209f0a220 mruby-socket/socket.c (socket_option_init): add integer type checks 2023-08-15 07:31:04 +09:00
Yukihiro "Matz" Matsumoto 892596d372 mruby-socket/socket.c: implement Socket::Option#initialize in C 2023-08-14 23:32:22 +09:00
Yukihiro "Matz" Matsumoto 2a3af5dc67 Merge pull request #6036 from jbampton/add-pre-commit-hook
pre-commit: add hook `forbid-submodules`
2023-08-13 22:05:20 +09:00
Yukihiro "Matz" Matsumoto d53aa54e3b Merge pull request #6035 from jbampton/fix-super-linter-path
Fix Super-Linter action path
2023-08-13 22:04:33 +09:00
Yukihiro "Matz" Matsumoto 3310e10318 mruby-test/mrbgem.rake: fix mrb_state handling bug
You should not pass values from different mrb_state. No one has ever
used test_args for gems, the issue has not been realized.
2023-08-13 20:02:01 +09:00
John Bampton 6ac6d690dd pre-commit: add hook forbid-submodules
https://github.com/pre-commit/pre-commit-hooks#forbid-submodules

If you want to ban them entirely use forbid-submodules.

Really this is just one extra check or test we can have.
2023-08-13 11:17:22 +10:00
John Bampton 9051367fd8 Fix Super-Linter action path
https://github.com/super-linter/super-linter

https://github.com/marketplace/actions/super-linter

They changed the organization name to "super-linter" from "github" for the Super-Linter Action
2023-08-13 11:03:28 +10:00
Yukihiro "Matz" Matsumoto 4769a474a4 mruby-test/mrbgem.rake: remove unnecessary arena_index 2023-08-12 23:43:48 +09:00
Yukihiro "Matz" Matsumoto 435cce7efd mruby-socket/socket.c: use mrb_iv_get() instead of accessors 2023-08-12 20:19:32 +09:00
Yukihiro "Matz" Matsumoto c675c0cbb1 mruby-socket/socket.c: use mrb_ensure_int_type() 2023-08-11 23:10:02 +09:00
Yukihiro "Matz" Matsumoto 34e7a0ef4b mruby-socket/socket.c (socket_option_class): a new function
To retrieve Socket::Option class from C functions.
2023-08-11 23:07:38 +09:00
Yukihiro "Matz" Matsumoto 0864f44c24 mruby-socket/socket.c: use mrb_obj_new() instead of mrb_obj_funcall() 2023-08-09 18:45:42 +09:00
Yukihiro "Matz" Matsumoto 08a780edd6 mruby-socket/socket.c: rename a local variable for clarity (res0 -> addr) 2023-08-09 14:33:14 +09:00
Yukihiro "Matz" Matsumoto edf3f1226c mruby-socket/socket.c: pass klass to gen_addrinfo 2023-08-09 14:33:14 +09:00
Yukihiro "Matz" Matsumoto 9e37a490f8 mruby-socket/socket.c: narrow local variable scope 2023-08-09 14:33:14 +09:00
Yukihiro "Matz" Matsumoto 10ed2ea03b mruby-socket/socket.c: use z! argument specifier rather than o
`z!` specifier checks if the argument is NULL terminated string or nil.
2023-08-09 14:33:14 +09:00
Yukihiro "Matz" Matsumoto 9d370e0851 mruby-socket/socket.c: ensure struct addrinfo to be freed
Instead of referring the last addrinfo via Addrinfo's class variable, we
use `mrb_ensure()` from `mruby-error` gem.
2023-08-09 13:51:25 +09:00
Yukihiro "Matz" Matsumoto 12bd395012 fmt_fp.c: revert 647324ad45c0d779a3c36f0bb7955b8b8fc9f491
C++ complier does not allow jump across local variable declaration, even
if we don't access those variables after the destination label.
2023-08-08 11:24:15 +09:00
Yukihiro "Matz" Matsumoto 8591211494 dump.c (mrb_dump_irep): remove a function which only delegates 2023-08-08 11:24:14 +09:00
Yukihiro "Matz" Matsumoto ceb5086eb3 fmt_fp.c: unify returning code 2023-08-08 11:24:14 +09:00
Yukihiro "Matz" Matsumoto 7e865aec51 mruby-bigint/bigint.c: remove unused mrb_bint_new() 2023-08-08 11:24:14 +09:00
Yukihiro "Matz" Matsumoto a22ea766e2 mruby-numeric-ext/numeric_ext.c: use local variables. 2023-08-08 11:24:14 +09:00
Yukihiro "Matz" Matsumoto 5de3be1bee mruby-dir/dir.c (mrb_di_getwd): reduce buffer allocation size
Instead of allocating `MAXPATHLEN` buffer string at the beginning,
allocate smaller (64 bytes) buffer, then resize it if needed. The
allocating max size is safe but consumes more memory.
2023-08-08 11:24:14 +09:00
Yukihiro "Matz" Matsumoto a2649652f1 mruby-os-memsize/memsize.c: fix irep size calculation
Need to count the following as well:

- size of pool values
- size of reps array
2023-08-02 07:04:35 +09:00
Yukihiro "Matz" Matsumoto 1bc8ef903e Merge pull request #6032 from jbampton/update-rake-task-clean
Rake: update task clean to remove `bin` and `build` folders
2023-07-31 10:42:01 +09:00
Yukihiro "Matz" Matsumoto 0af6f8ff57 Merge pull request #6033 from jbampton/file-sorter-unique
pre-commit: file-contents-sorter ensure each line is unique
2023-07-30 18:30:26 +09:00
John Bampton a2785a8180 pre-commit: file-contents-sorter ensure each line is unique
https://github.com/pre-commit/pre-commit-hooks#file-contents-sorter
2023-07-30 04:25:38 +10:00
John Bampton a94a8b1cf0 Rake: update task clean to remove bin and build folders 2023-07-30 03:51:48 +10:00
Yukihiro "Matz" Matsumoto bbd4edc607 mruby-data/data.c (mrb_data_ref): remove code duplication 2023-07-29 08:42:25 +09:00
Yukihiro "Matz" Matsumoto 8d2f9b3d12 mruby-data/data.c: skip inefficient env for first some accessors 2023-07-28 23:45:25 +09:00
Yukihiro "Matz" Matsumoto 1e1184f62d mruby-pack/pack.c (read_tmpl): should consume skips in the function 2023-07-28 17:05:49 +09:00
Yukihiro "Matz" Matsumoto 0542d6bad4 debug.c (mrb_packed_int_encode): remove end argument
The function requires the buffer bigger than `mrb_packed_int_len()`
anyway, so we don't need boundary checks for each iteration. Should
makes the function a little bit faster.
2023-07-28 17:05:38 +09:00
Yukihiro "Matz" Matsumoto 5b2056efda Merge pull request #6031 from jbampton/pre-commit-autoupdate
Run `pre-commit autoupdate` and update `codespell.txt`
2023-07-25 10:57:03 +09:00
John Bampton 0464ca3870 Run pre-commit autoupdate 2023-07-24 22:26:53 +10:00
John Bampton b66b67beda Update codespell.txt 2023-07-24 22:25:03 +10:00
Yukihiro "Matz" Matsumoto 1535e031df mruby-pack/pack.c (read_tmpl): direct return from skipping directives
We used to read counts after spaces, for example `pack("j 4")` read `4`
as counts after a space.
2023-07-24 18:03:39 +09:00
Yukihiro "Matz" Matsumoto a5a13ad35f mruby-pack/pack.c (read_tmpl): read_tmpl to return dir
Use return value for directives information.
2023-07-24 18:03:39 +09:00
Yukihiro "Matz" Matsumoto 8a3d52f494 mruby-pack/pack.c (read_tmpl): rename PACK_DIR_INVALID
The value is used for spaces and comments, so the term "skip" is more
appropriate than "invalid".
2023-07-24 18:03:38 +09:00
Yukihiro "Matz" Matsumoto e17f3256c6 mruby-pack/pack.c (read_tmpl): support comments in derectives 2023-07-24 18:03:38 +09:00
Yukihiro "Matz" Matsumoto 5d0016186f numeric.c (mrb_float_to_str): avoid memcpy() 2023-07-24 18:03:38 +09:00
Yukihiro "Matz" Matsumoto 0eceadd037 mruby-pack/test/pack.rb: test B/b directives 2023-07-24 18:03:38 +09:00
Yukihiro "Matz" Matsumoto e7021f190a mruby-pack/pack.c (pack_bstr): support B/b directives 2023-07-24 18:03:38 +09:00
Yukihiro "Matz" Matsumoto 05549410d9 mruby-pack/pack.c (read_tmpl): check unknown directives 2023-07-24 18:03:38 +09:00
Yukihiro "Matz" Matsumoto 2a1e3a572c mruby-pack/pack.c (read_tmpl): support J/j template in pack
J/j is available since Ruby 2.3.
2023-07-24 18:03:37 +09:00
Yukihiro "Matz" Matsumoto 663f936ba8 Merge pull request #6030 from jbampton/standardize-dots
Standardize docs to use 3 dots: `...`
2023-07-24 08:21:16 +09:00
Yukihiro "Matz" Matsumoto 0876cf82ff Merge pull request #6028 from jbampton/fix-super-linter-button
Fix Super-Linter button in README
2023-07-24 08:20:06 +09:00
John Bampton 14b4f5953b Standardize docs to use 3 dots: ... 2023-07-23 03:39:03 +10:00
Yukihiro "Matz" Matsumoto 455a5689f3 lib/mruby/build/command.rb: skip mrbgems in parent directory; fix #6029
If `mrbgems` is included in the parent directory path (MRUBY_ROOT), it
confuses gem path and build path.
2023-07-17 13:24:47 +09:00
Yukihiro "Matz" Matsumoto f84f129d65 AUTHORS: update entries [ci skip] 2023-07-17 12:18:10 +09:00
Yukihiro "Matz" Matsumoto 5e7d763e91 variable.c (mrb_obj_iv_set_force): check namespace_p beforehand
To reduce number of assign_class_name() invocation.
2023-07-17 12:09:28 +09:00
John Bampton 95fbacb1dc Fix Super-Linter button in README
Updated the button to the latest format seen here:

https://github.com/marketplace/actions/super-linter#add-super-linter-badge-in-your-repository-readme
2023-07-15 20:49:58 +10:00
Yukihiro "Matz" Matsumoto 82a48bd455 error.c (mrb_bug): avoid formatting in mrb_bug()
Since mrb_bug() would be called under the abnormal situation (and should
not be called if possible), the process should be minimal.
2023-07-14 21:48:11 +09:00
Yukihiro "Matz" Matsumoto d6d434eb3f Inline loop variables everywhere 2023-07-13 08:05:00 +09:00
Yukihiro "Matz" Matsumoto d4a03be96b mruby-string-ext/string.c (str_casecmp): small refactoring 2023-07-12 09:14:45 +09:00
Yukihiro "Matz" Matsumoto 2af0ff52e9 backtrace.c (count_backtrace_i): remove empty callback
Instead specifying NULL as function argument of each_backtrace()
count the number of callbacks.
2023-07-11 07:17:19 +09:00
Yukihiro "Matz" Matsumoto 6f99806d5b backtrace.c (packed_backtrace): remove count_backtrace()
Since we have stop calling mrb_debug_get_position() in each_backtrace(),
we don't need to craft special function count_backtrace(). We just use
each_backtrace() to count the number of backtraces.
2023-07-11 06:59:09 +09:00
Yukihiro "Matz" Matsumoto 316119069d backtrace.c (each_backtrace): skip callinfo without debug_info 2023-07-10 07:57:02 +09:00
Yukihiro "Matz" Matsumoto 7aa914b4d4 cdump.c (cdump_debug): restore arena index at the end of the function 2023-07-10 07:26:19 +09:00
Yukihiro "Matz" Matsumoto c57610ad8a backtrace.c (packed_backtrace): fix broken ciidx
- fix at higher level to remove redundancy
- ciidx should always be smaller than ci stack length
2023-07-10 07:05:27 +09:00
Yukihiro "Matz" Matsumoto 9c61c66045 gc.c (mrb_obj_alloc): clarify the heap initialization 2023-07-09 22:59:58 +09:00
Yukihiro "Matz" Matsumoto eebbc6eaa4 gc.c (mrb_obj_alloc): gc->heaps may be NULL 2023-07-07 06:53:19 +09:00
Yukihiro "Matz" Matsumoto af85b1fbed gc.c (gc_mark_gray_list): cut gcnext link 2023-07-06 22:57:14 +09:00
Yukihiro "Matz" Matsumoto aa5ffb686f mruby-os-memsize: more precise memory size for method tables 2023-07-06 16:12:51 +09:00
Yukihiro "Matz" Matsumoto 0a4473bf64 mruby-socket/socket.c: fix indentation 2023-07-04 17:50:37 +09:00
Yukihiro "Matz" Matsumoto 0558b1abd8 backtrace.c: reorder functions for clarity 2023-07-03 15:26:45 +09:00
Yukihiro "Matz" Matsumoto 97b60e7fb1 backtrace.c (backtrace_location): defer retrieving positions
Instead of calling `mrb_debug_get_position` in the `each_backtrace`, we
just keep `irep` and `idx` information in the backtrace_location, and
get the exact position in `mrb_unpack_backtrace` which may not be called
if exceptions are handled in the `rescue` clauses.
2023-07-03 15:21:16 +09:00
Yukihiro "Matz" Matsumoto 40bdd65ce6 backtrace.c (each_backtrace): return number of traces iterated 2023-07-03 15:20:24 +09:00
Yukihiro "Matz" Matsumoto 70b49eaef2 debug.c (debug_get_line): remove obsolete debug line types
- mrb_debug_line_ary
- mrb_debug_line_flat_map

Those two are no longer used, so we can safely remove the support.
2023-07-03 15:16:29 +09:00
Yukihiro "Matz" Matsumoto ea649e70b8 mruby-pack/pack.c (mrb_pack_pack): use direct array buffer access
We don't need index wrap-around not boundary check here, so we can use
faster direct array access.
2023-06-29 22:54:58 +09:00
Yukihiro "Matz" Matsumoto 0c4f5a4093 backtrace.c (mrb_unpack_backtrace): make the function static 2023-06-29 22:54:09 +09:00
Yukihiro "Matz" Matsumoto e563a3cb2c backtrace.c (packed_backtrace): reduce unnecessary calls
Instead of calling each_backtrace() twice, use a new function
count_backtrace().
2023-06-28 21:53:17 +09:00
Yukihiro "Matz" Matsumoto f1d6af08cf gc.c: inline heap page linkage 2023-06-27 15:48:33 +09:00
Yukihiro "Matz" Matsumoto 38b9a25e83 gc.c (mrb_obj_alloc): remove free_next,free_prev from heap pages
It used to be maintain heap pages with allocatable objects (free_heaps)
but we can save two words (16 bytes) per page by scanning live heap pages.
2023-06-27 15:48:25 +09:00
Yukihiro "Matz" Matsumoto 695ad6ea95 gc.c (incremental_sweep_phase): freed need not to be smaller than page size 2023-06-26 17:14:43 +09:00
Yukihiro "Matz" Matsumoto b2110c23a1 Merge pull request #6023 from dearblue/expose-headers
"expose_header_files" task split per build
2023-06-24 15:35:31 +09:00
Yukihiro "Matz" Matsumoto a3365d8b3f gc.c (obj_free): need not to unshare env object when freeing fibers
Since when env objects reference the context, we no longer need to
unshare (stack reallocate) env objects. Currently all env objects
referenced from fibers are already recycled, so we removed unnecessary
code altogether.
2023-06-23 23:06:15 +09:00
Yukihiro "Matz" Matsumoto fc9fffc5b5 kernel.rb (_inspect): _inspect method no longer needed 2023-06-22 23:32:31 +09:00
Yukihiro "Matz" Matsumoto 6ae6b63aaf mruby-struct: add recursive inspect check instead of _inspect hack 2023-06-22 12:53:51 +09:00
Yukihiro "Matz" Matsumoto 849963b81e variable.c (mrb_obj_iv_inspect): support recursion detection 2023-06-21 23:36:59 +09:00
Yukihiro "Matz" Matsumoto 0713f2a840 mruby-set/set.rb (inspect): add recursive inspect check to Set#inspect 2023-06-20 11:25:49 +09:00
Yukihiro "Matz" Matsumoto 113565a1c5 hash.c (mrb_hash_to_s): add recursive inspect check to Hash#inspect 2023-06-20 11:18:38 +09:00
Yukihiro "Matz" Matsumoto 5cb0c7463b array.c (mrb_ary_to_s): add recursive check to Array#inspect 2023-06-20 07:06:33 +09:00
Yukihiro "Matz" Matsumoto e2bbf75d58 kernel.c: prepare for new recursive inspect check
Like previous recursive `<=>` check, scan call stack to detect recursive
`inspect` calls. We no longer need incomplete `_inspect` hack to pass
around a hash table to record objects currently inspecting.
2023-06-20 07:04:28 +09:00
Yukihiro "Matz" Matsumoto 75c8ffddf5 object.c (mrb_equal) move mrb_equal() back to object.c 2023-06-20 06:45:05 +09:00
Yukihiro "Matz" Matsumoto 89a1719a13 compar.rb: use equal?() instead of ==
To avoid unnecessary infinite recursion.
2023-06-19 15:33:13 +09:00
dearblue fdec32a8f2 "expose_header_files" task split per build
If there are multiple build targets, it should be preferable to have the task processed at each of them.
2023-06-18 21:22:31 +09:00
Yukihiro "Matz" Matsumoto 7f85ae2c48 Merge pull request #6022 from chasonr/msdos-build
Build configuration for MS-DOS and DJGPP
2023-06-18 18:13:24 +09:00
Ray Chason 23e9befbc0 Changes to cross-compile with DJGPP 2023-06-17 17:20:33 -04:00
Ray Chason 853b25972e Build configuration for MS-DOS 2023-06-17 17:20:20 -04:00
Yukihiro "Matz" Matsumoto a638a71c72 test/hash.rb: remove some inspect/to_s tests
CRuby does prohibits Hash modification during iteration, so remove those
self modifying inspect/to_s.
2023-06-17 17:56:41 +09:00
Yukihiro "Matz" Matsumoto 20552fe176 hash.c (mrb_hash_foreach): wrap function call with h_check_modified
If the iterating hash is modified in the function, h_each loop may
crash accessing modified (and probably deallocated) internal data.
2023-06-17 10:55:55 +09:00
Yukihiro "Matz" Matsumoto e502fd88b9 kernel.c (mrb_cmp_m): check recursive <=> calls
If previous `<=>` method invocation with same arguments is detected in
the stack trace, this `<=>` call must be recursive and can cause stack
overflow.
2023-06-17 09:18:55 +09:00
Yukihiro "Matz" Matsumoto 7c9cb0901c kernel.c (mrb_equal): simplify the code 2023-06-16 13:45:58 +09:00
Yukihiro "Matz" Matsumoto 5e4cecf766 internal.h: add mrb_obj_equal_m to internal.h 2023-06-15 23:36:27 +09:00
Yukihiro "Matz" Matsumoto a04d18bb6d kernel.c (mrb_eqq_m): rename function equal -> eqq
This function implements `Kernel#===` and it's usually abbreviated to
`eqq` not `equal`.
2023-06-15 23:32:41 +09:00
Yukihiro "Matz" Matsumoto 359c630d73 kernel.c (mrb_equal): move mrb_equal() from object.c 2023-06-15 23:31:45 +09:00
Yukihiro "Matz" Matsumoto 2be7cba8f5 kernel.c (obj_respond_to): refactoring
- skip basic_obj_respond_to(); call mrb_respond_to() directly
- narrower scope for `mrb_sym rtm_id`
- use mrb_func_basic_p() to detect override
- use mrb_funcall_id() to avoid local mrb_value array
2023-06-14 11:41:21 +09:00
Yukihiro "Matz" Matsumoto 347586e400 kernel.c: define respond_to_missing? method 2023-06-14 11:31:55 +09:00
Yukihiro "Matz" Matsumoto e96d90dab2 Merge pull request #6017 from jbampton/standardize-pre-commit-config
Standardize the `pre-commit` config
2023-06-13 15:44:51 +09:00
Yukihiro "Matz" Matsumoto 7125481952 Merge pull request #6021 from jbampton/news-remove-duplicate-cve
NEWS: remove duplicate CVE from list
2023-06-13 14:09:59 +09:00
John Bampton 26659ef76c NEWS: remove duplicate CVE from list 2023-06-13 15:02:57 +10:00
Yukihiro "Matz" Matsumoto 0d863ae85f Merge pull request #6018 from jbampton/configure-dependabot-for-bundler
Configure Dependabot updates for Bundler/Ruby
2023-06-13 13:50:40 +09:00
Yukihiro "Matz" Matsumoto c99403d635 Merge pull request #6020 from jbampton/fix-markdown-link
Enable markdownlint rule MD052
2023-06-13 13:49:49 +09:00
Yukihiro "Matz" Matsumoto a332ea1f67 Merge pull request #6019 from jbampton/docs-remove-duplicate-cve
docs: remove duplicate CVE from list
2023-06-13 13:47:55 +09:00
John Bampton 50e0aad288 Enable markdownlint rule MD052
https://github.com/DavidAnson/markdownlint/blob/main/doc/md052.md
2023-06-13 14:34:52 +10:00
John Bampton 343a633fb0 doc: fix Markdown reference links 2023-06-13 14:31:29 +10:00
John Bampton 36f2d1733b docs: remove duplicate CVE from list 2023-06-13 13:27:23 +10:00
John Bampton 760ce71af0 Configure Dependabot updates for Bundler/Ruby
https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/about-dependabot-version-updates#supported-repositories-and-ecosystems

In future this will keep the Gemfile.lock up to date
2023-06-13 12:44:00 +10:00
John Bampton f14f2ae174 Standardize the pre-commit config 2023-06-13 08:54:17 +10:00
Yukihiro "Matz" Matsumoto 17720c9b7b variable.c (const_get): avoid mrb_funcall if possible
Directly call mrb_const_missing() if const_missing is not overridden.
2023-06-12 23:47:35 +09:00
Yukihiro "Matz" Matsumoto 89f7bb1056 use more lightweight mrb_funcall_argv instead of mrb_funcall_id 2023-06-12 14:22:04 +09:00
Yukihiro "Matz" Matsumoto 39a29a7de1 mruby-bin-debugger/mrbgem.rake: fix defines configuration
`spec.build.defines` should be update inline. Otherwise, configuration
may differ from file to file.
2023-06-12 13:07:57 +09:00
Yukihiro "Matz" Matsumoto a867fb0703 class.c: remove methID from the example and codespell dict 2023-06-09 17:56:21 +09:00
Yukihiro "Matz" Matsumoto b6181ae58a mruby/gc.h: reorder mrb_gc members to reduce alignment gaps 2023-06-09 17:19:09 +09:00
Yukihiro "Matz" Matsumoto 727a2ec793 gc.c (obj_free): use simpler is_dead()
`mrb_object_dead_p()` is heavier if the pointer is (or used to be) an
object in the heaps.
2023-06-07 17:03:32 +09:00
Yukihiro "Matz" Matsumoto 336b7efb41 gc.c (mrb_incremental_gc): clarify the if-condition 2023-06-06 11:29:48 +09:00
Yukihiro "Matz" Matsumoto 8b8e186688 gc.h: rename majorgc_old_threashold to oldgen_threashold
This field means that if you have more old generation objects than
this value, major GC mode will be turned on.
2023-06-06 11:26:35 +09:00
Yukihiro "Matz" Matsumoto b47c8b738a gc.c (clear_all_old): fix a generational GC bug
This issue was caused by 375d22b that introduced a serious mark
leakage in the generational GC mode.
2023-06-06 07:29:41 +09:00
Yukihiro "Matz" Matsumoto 0bb08718b8 gc.c (incremental_marking_phase): clear gcnext for debugging 2023-06-05 23:31:36 +09:00
Yukihiro "Matz" Matsumoto 6958368daa gc.c (gc_mark_children): declare a loop variable in the for-statement 2023-06-05 23:30:33 +09:00
Yukihiro "Matz" Matsumoto 623cda5521 gc.c: make color macros literals for debugging clarity 2023-06-05 16:00:04 +09:00
Yukihiro "Matz" Matsumoto f07281a026 Revert "object.h: make GC color uint8_t that fits in 3 bits"
The change made the size of mruby data types bigger on Win.
This reverts commit afcf7fc86d.
2023-06-03 16:55:58 +09:00
Yukihiro "Matz" Matsumoto 93648fc954 gc.c (mrb_env_unshare): fix a write barrier bug 2023-06-02 11:00:13 +09:00
Yukihiro "Matz" Matsumoto 9369679e36 vm.c: reduce local variables 2023-06-01 09:14:39 +09:00
Yukihiro "Matz" Matsumoto 5b61407414 class.c (prepare_singleton_class): defer method table allocation 2023-06-01 09:13:44 +09:00
Yukihiro "Matz" Matsumoto 0d8545e01b error.c (frozen_error): change specifier from %t to %T
- `%t` prints type (class) of the argument
- `%T` prints real class of the argument, skipping TT_ICLASS, etc.
2023-05-31 08:35:54 +09:00
Yukihiro "Matz" Matsumoto e6c89ef1f9 mruby.h: make mrb_check_frozen to a normal function from inline one 2023-05-31 08:33:58 +09:00
Yukihiro "Matz" Matsumoto ccdf75c1c2 error.c: a new function mrb_check_frozen_value() 2023-05-31 08:31:13 +09:00
Yukihiro "Matz" Matsumoto 8b39a7825d Reduce unnecessary mrb_obj_ptr() to mrb_check_frozen() 2023-05-31 08:29:12 +09:00
Yukihiro "Matz" Matsumoto afcf7fc86d object.h: make GC color uint8_t that fits in 3 bits 2023-05-31 08:27:23 +09:00
Yukihiro "Matz" Matsumoto 8873229312 codedump.c: fix indentation of OP_SCLASS 2023-05-30 16:08:38 +09:00
Yukihiro "Matz" Matsumoto 6eedf1065d numeric.c (flo_idiv): add mrb_check_num_exact 2023-05-30 08:54:44 +09:00
Yukihiro "Matz" Matsumoto 795044f82c internal.h: add mrb_check_num_exact prototype to the header 2023-05-30 08:54:05 +09:00
Yukihiro "Matz" Matsumoto e84060a900 string.c: rename function str_check_too_big -> str_check_length 2023-05-30 08:40:16 +09:00
Yukihiro "Matz" Matsumoto f813b5d1d8 string.c (str_new): add string length check 2023-05-29 23:18:44 +09:00
Yukihiro "Matz" Matsumoto aecaaf011f string.c (mrb_str_resize): refactor string length check 2023-05-29 23:18:19 +09:00
Yukihiro "Matz" Matsumoto 0a6e1c0ffe class.c (copy_class): copy source flags as well (except frozen flag) 2023-05-29 22:59:05 +09:00
Yukihiro "Matz" Matsumoto c0c4219b25 class.c (copy_class): avoid copying method table in some cases
To prevent memory leaks
2023-05-29 22:57:59 +09:00
Yukihiro "Matz" Matsumoto bba2fd84ea class.h: instance type should occupy 5 bits in flags 2023-05-29 09:27:08 +09:00
Yukihiro "Matz" Matsumoto e4e3740688 class.c (init_copy): add an assertion 2023-05-29 09:26:45 +09:00
Yukihiro "Matz" Matsumoto a02894afa3 small cosmetic changes 2023-05-29 09:26:45 +09:00
Yukihiro "Matz" Matsumoto 0ffe9b987a class.c (mrb_prepend_module): c should not be MRB_TT_ICLASS 2023-05-29 09:26:44 +09:00
Yukihiro "Matz" Matsumoto 6ac10a01e4 Merge pull request #6014 from dearblue/setup_debug.1
Fixed visibility of `MRuby::Command::Compiler#setup_debug`
2023-05-29 09:26:32 +09:00
dearblue a7bee69452 Fixed visibility of MRuby::Command::Compiler#setup_debug
In #5977 it was incorrectly set to `private`.
2023-05-26 21:37:29 +09:00
Yukihiro "Matz" Matsumoto 7f887f1928 class.c (mrb_class_initialize): check duplicated initialization 2023-05-26 12:48:34 +09:00
Yukihiro "Matz" Matsumoto 8914c2318c Merge pull request #6013 from CaptainJet/master
Fix Android toolchain
2023-05-26 12:47:08 +09:00
Robert Rowe fb727a169f Spacing fix 2023-05-25 19:47:32 -07:00
Robert Rowe bcb5674676 Update Android building
New minimum SDK. NDK longer supports mips, plain armeabi, nor GCC. Fix tooling.
2023-05-25 19:45:14 -07:00
Yukihiro "Matz" Matsumoto 2ad3f0e34b vm.c (mrb_yield_with_class): keep mid of the callee
Otherwise `super` from within blocks may call wrong methods.
2023-05-26 11:17:51 +09:00
Yukihiro "Matz" Matsumoto 9040baa270 vm.c (mrb_yield_with_class): avoid redundant initialization of mid 2023-05-26 11:14:58 +09:00
Yukihiro "Matz" Matsumoto 2b3ecef66c mruby-data/data.c: use mrb_ary_ref instead of direct memory access
Avoid out-of-bound memory access when actual data object size is smaller
than the number of data members.
2023-05-25 09:05:03 +09:00
Yukihiro "Matz" Matsumoto 9bc9ff771d mruby-data/data.c (mrb_data_s_def): simplify the code 2023-05-25 09:05:03 +09:00
Yukihiro "Matz" Matsumoto 05f4831751 mruby-data/data.c (mrb_data_s_def): add member duplication check 2023-05-25 09:05:03 +09:00
Yukihiro "Matz" Matsumoto eeab289f87 mruby-data/data.c (mrb_data_ref): avoid out-of-bound access 2023-05-25 09:05:02 +09:00
Yukihiro "Matz" Matsumoto de69190df5 mruby-struct/struct.c: need to copy the argument array
Just in case for stack reallocations.
2023-05-25 09:05:02 +09:00
Yukihiro "Matz" Matsumoto e05ac91217 mruby-struct/struct.c: update the behavior when actual size differs
Assertions may be false and terminate the whole process when actual size
for struct objects are different.
2023-05-25 09:05:02 +09:00
Yukihiro "Matz" Matsumoto f50e40f291 mruby-struct/struct.c: use mrb_ary_set to simplify the code
We don't need to do `mrb_struct_modify()` and calling write barriers by
ourselves for the small performance issue.
2023-05-25 09:05:02 +09:00
Yukihiro "Matz" Matsumoto 0295e6a688 mruby-struct/struct.c (struct_aref_int): update index check
Check should use the number of members, not the actual size of the
struct object, which may be smaller than the declared size.
2023-05-25 08:40:46 +09:00
Yukihiro "Matz" Matsumoto 8e579e6552 mruby-data/data.c (mrb_data_ref): check if reader has no argument 2023-05-24 22:45:35 +09:00
Yukihiro "Matz" Matsumoto ed5fbb5d63 mruby-struct.c (mrb_struct_s_def): check duplicate members 2023-05-24 22:43:09 +09:00
Yukihiro "Matz" Matsumoto f80192e8ac mruby-struct/struct.c (struct_s_member): avoid break
Direct `return` is more readable, IMO.
2023-05-24 17:59:32 +09:00
Yukihiro "Matz" Matsumoto c2f3f103bb mruby-struct/struct.c (mrb_struct_ref): update the function
- use `num_members`
- ensure the function takes no argument
- avoid out-of-bound access when struct is failed to initialize
2023-05-24 17:53:41 +09:00
Yukihiro "Matz" Matsumoto 69d33de527 mruby-struct/struct.c (num_members): simplify the code by new argument 2023-05-24 17:51:44 +09:00
Yukihiro "Matz" Matsumoto 52fb2f59d8 mruby-struct/struct.c (struct_aref_sym): simplify the logic 2023-05-24 17:51:03 +09:00
Yukihiro "Matz" Matsumoto 7b7ea70b84 mruby-struct/struct.c (mrb_struct_to_h): RSTRUCT_PTR() may be NULL
Especially when you define a member named `initialize`.
2023-05-24 17:48:51 +09:00
Yukihiro "Matz" Matsumoto 53de96426a mruby-io/io.c (io_init): File.new should not take blocks 2023-05-23 15:34:37 +09:00
Yukihiro "Matz" Matsumoto 67187881c2 mruby-io/io.c (io_init_copy): copy flags before io_buf_init() 2023-05-23 15:17:13 +09:00
Yukihiro "Matz" Matsumoto 8f745b7728 vm.c (OP_ENTER): fix issues by unreferenced kdict and blk
There's short a period where kdict and blk are not pointed from the stack.
2023-05-23 14:54:36 +09:00
Yukihiro "Matz" Matsumoto 2f7f797473 remove extra spaces before ; 2023-05-22 12:05:35 +09:00
Yukihiro "Matz" Matsumoto 6a6c0869dc add a space between for and ( 2023-05-22 11:58:23 +09:00
Yukihiro "Matz" Matsumoto f1a3cfbd3b add a space between if and ( 2023-05-22 11:55:21 +09:00
Yukihiro "Matz" Matsumoto c32f7915fb reformat else clause indentation style 2023-05-20 00:21:01 +09:00
Yukihiro "Matz" Matsumoto eea72ec84a fix spaces in the type cast expressions (cosmetic changes) 2023-05-18 23:29:16 +09:00
Yukihiro "Matz" Matsumoto cead78b394 variable.c (iv_rehash): fixed removed check
This check removed in 70cc2cc was necessary.
2023-05-17 09:52:00 +09:00
Yukihiro "Matz" Matsumoto 49927a7035 mruby-biding/binding.c: unify get_line and get_filename 2023-05-16 23:40:53 +09:00
Yukihiro "Matz" Matsumoto 15be2a24c3 mruby-proc-ext/proc.c: unify get_line and get_filename 2023-05-16 23:39:51 +09:00
Yukihiro "Matz" Matsumoto 5ead26be3d vm.c (ci_bidx): inline the function if possible 2023-05-16 22:41:32 +09:00
Yukihiro "Matz" Matsumoto b10c99bb1b Merge pull request #6012 from sinisterchipmunk/allow-to-skip-tests-for-specific-mgems
Allow tests to be disabled for specific gems; warn about disabled tests
2023-05-16 14:36:40 +09:00
Colin MacKenzie IV 1a0c31130c Allow tests to be disabled for specific gems; warn about disabled tests 2023-05-15 12:43:37 -04:00
Yukihiro "Matz" Matsumoto 33bd6caf31 Merge pull request #6011 from dearblue/presym-escape
Encode and decode escape characters for presym
2023-05-15 00:15:40 +09:00
dearblue 03a42b52ee Encode and decode escape characters for presym
The purpose is to deal with `$"`, which has been treated as three characters including the escape character.
2023-05-14 17:54:13 +09:00
Yukihiro "Matz" Matsumoto cd276715f8 variable.c: move inline function before usage 2023-05-13 22:52:39 +09:00
Yukihiro "Matz" Matsumoto f210d3b106 Merge pull request #6010 from jbampton/add-hook-markdown-link-check 2023-05-12 23:31:34 +09:00
John Bampton ac0e157b89 pre-commit: add hook markdown-link-check
https://github.com/tcort/markdown-link-check
2023-05-11 12:37:38 +10:00
John Bampton de0779d6ca docs: fix links in Markdown 2023-05-11 12:34:59 +10:00
Yukihiro "Matz" Matsumoto 3d5cc1ab8f Merge pull request #6007 from dearblue/define_installer
Correct the `MRuby::Build#define_installer`
2023-05-10 23:54:27 +09:00
Yukihiro "Matz" Matsumoto 2217201603 Merge pull request #6006 from dearblue/mrbc-final_mrbgems
Remove `mrb_final_mrbgems()` in `mrbc.c`
2023-05-09 14:46:51 +09:00
Yukihiro "Matz" Matsumoto 568a7edf1f Merge pull request #6004 from jbampton/add-info-links-to-workflows
yml: document `workflows` with links as comments
2023-05-09 14:45:48 +09:00
Yukihiro "Matz" Matsumoto feb07d1d1a Merge pull request #6002 from jbampton/standardize-whitespace-spec-authors
mrbgems: standardize `spec.authors` for whitespace and author name
2023-05-08 17:01:23 +09:00
Yukihiro "Matz" Matsumoto d3f030f02a Merge pull request #5999 from alpha-netzilla/fix_poppen_mode
lib/mruby/build/command.rb: narrow down poppen mode
2023-05-08 17:00:28 +09:00
Yukihiro "Matz" Matsumoto e545ec3810 Merge pull request #6001 from jbampton/update-docs
docs: fix links, grammar and spelling in Markdown
2023-05-08 17:00:03 +09:00
Yukihiro "Matz" Matsumoto 599982454e Merge pull request #6008 from dearblue/bintest-dirfree 2023-05-07 19:10:59 +09:00
Yukihiro "Matz" Matsumoto 727d83c118 Merge pull request #6009 from dearblue/ghost-bintest
Avoid adding `<MRUBY_ROOT>/bintest` which does not exist
2023-05-06 22:28:41 +09:00
dearblue 5a4c319dd8 Avoid adding <MRUBY_ROOT>/bintest which does not exist
The `<MRUBY_ROOT>/bintest` directory does not exist in current mruby.
2023-05-06 22:08:48 +09:00
dearblue eb4c7d0edf Make "bintest" independent of directory
Previously, "bintest" would fail to run unless `MRUBY_ROOT` and `Dir.pwd` were the same.
2023-05-06 22:00:57 +09:00
dearblue 44f9fa1b61 Correct the MRuby::Build#define_installer
This is a complement to #5928.
The previous PR had the following problem:

  - The `<INSTALL_DIR>/bin/*` file could not be replaced if the destination of the symbolic link was lost.
  - The wrong link destination was written if `MRuby::Build.install_dir` was a relative path.
2023-05-06 21:54:49 +09:00
dearblue e570ca82a8 Remove mrb_final_mrbgems() in mrbc.c
The current `mrb_final_mrbgems()` function is only referenced in the `mrbgem/gem_init.c` file.

Also, the definition in that file makes it a static function.
2023-05-06 21:07:08 +09:00
John Bampton 04a120f7c2 yml: document workflows with links as comments 2023-05-06 08:31:20 +10:00
Yukihiro "Matz" Matsumoto 9033191efa Merge pull request #6003 from jbampton/label-more-files
`.github/labeler.yml`: label more files for `doc`
2023-05-06 06:43:53 +09:00
John Bampton 5fab261d8a .github/labeler.yml: label more files for doc 2023-05-06 07:19:46 +10:00
John Bampton 63e170170e mrbgems: standardize spec.authors for whitespace and author name 2023-05-06 06:06:29 +10:00
John Bampton db3774ea45 docs: fix links, grammar and spelling in Markdown 2023-05-06 04:43:50 +10:00
John Bampton d63115a0f1 docker: use less image layers and update compose version
https://stackoverflow.com/questions/30256386/how-to-copy-multiple-files-in-one-layer-using-a-dockerfile

https://docs.docker.com/compose/compose-file/compose-file-v3/
2023-05-06 01:46:51 +10:00
Yukihiro "Matz" Matsumoto 9b4046f479 Merge pull request #5961 from jbampton/add-docker
Add `Docker` to build and run all `mruby` tests. Run `pre-commit` and generate `YARD` docs with Docker
2023-05-05 22:42:33 +09:00
alpha.netzilla 3409c1f309 lib/mruby/build/command.rb: narrow down poppen mode 2023-05-05 19:23:18 +09:00
Yukihiro "Matz" Matsumoto 28a29c6da1 Merge pull request #5997 from jbampton/pre-commit-autoupdate
Run `rake checkupdate` -> `pre-commit autoupdate`
2023-05-04 08:36:36 +09:00
Yukihiro "Matz" Matsumoto ab0f2297ab Merge pull request #5996 from jbampton/fix-case-of-mruby
Change `MRuby` to `mruby`
2023-05-04 08:34:46 +09:00
John Bampton be722da0d1 pre-commit autoupdate
Run `rake checkupdate`
2023-05-03 22:49:34 +10:00
John Bampton 12f64cc6d9 Update codespell.txt. Disable markdownlint rule MD052 2023-05-03 22:44:58 +10:00
John Bampton 06a765a1c2 Change MRuby to mruby 2023-05-03 22:12:59 +10:00
Yukihiro "Matz" Matsumoto 5956496267 lib/mruby/build/command.rb: remove unnecessary block parameter; fix #5995 2023-05-03 12:41:52 +09:00
Yukihiro "Matz" Matsumoto 077d8ad514 symbol.c (sym_intern): check NUL before calling strlen()
To avoid accidental buffer overrun if a string without NUL termination
is provided.
2023-05-02 09:45:47 +09:00
Yukihiro "Matz" Matsumoto 19b2c1c73d symbol.c: remove unused macro 2023-05-02 09:45:23 +09:00
Yukihiro "Matz" Matsumoto 7fd3108201 README.md: update English description (used ChatGPT) 2023-05-02 09:44:49 +09:00
Yukihiro "Matz" Matsumoto 7154526c04 Merge pull request #5994 from masahino/fix_typo_in_io_c
fix typo in mrbgems/mruby-io/src/io.c
2023-05-02 09:44:13 +09:00
masahino ad318e55c0 fix typo MRB_NO_IO_POEPN -> MRB_NO_IO_POPEN 2023-05-02 07:34:30 +09:00
Yukihiro "Matz" Matsumoto b488f197c5 Merge pull request #5992 from dearblue/doc/directory
Replace "folder" with "directory" for consistency
2023-04-30 23:19:40 +09:00
Yukihiro "Matz" Matsumoto abd1222089 class.h (mrb_class): treat immediate values first 2023-04-30 23:19:00 +09:00
dearblue 5c19b259e4 Replace "folder" with "directory" for consistency
Also, use "x/y/z directory" instead of "directory x/y/z" if there is no problem.
2023-04-30 18:32:54 +09:00
Yukihiro "Matz" Matsumoto 70cc2cc173 variable.c (iv_rehash): remove unnecessary checks 2023-04-29 23:17:08 +09:00
Yukihiro "Matz" Matsumoto 5024c3453d variable.c (iv_put): remove NULL check since t must not be NULL 2023-04-27 17:14:48 +09:00
Yukihiro "Matz" Matsumoto 68d67aee0e mruby-io/io.c: need to adjust buffer limit before searching; fix #5991 2023-04-26 09:09:05 +09:00
Yukihiro "Matz" Matsumoto 01e5f2a3c8 mruby-io/io.c: fix indent 2023-04-25 23:27:59 +09:00
Yukihiro "Matz" Matsumoto 9a5a9b814f mruby-catch/catch.c: remove mrb_ prefix from a static function 2023-04-25 23:27:30 +09:00
Yukihiro "Matz" Matsumoto e0194bba67 mruby-string-ext/string.c: remove mrb_ prefix from static functions 2023-04-25 14:25:15 +09:00
Yukihiro "Matz" Matsumoto 62e8f047b9 mruby-sleep/sleep.c: remove mrb_ prefix from static functions 2023-04-24 12:19:12 +09:00
Yukihiro "Matz" Matsumoto f116808d80 Merge pull request #5435 from jbampton/add-github-pr-labeler
Add the pull request labeler Action
2023-04-23 23:50:06 +09:00
Yukihiro "Matz" Matsumoto 49b887d75f mruby-object-ext/object.c: remove mrb_ prefix from static functions 2023-04-20 22:40:10 +09:00
Yukihiro "Matz" Matsumoto 2810491587 mruby-class-ext/class.c: remove mrb_ prefix from static functions 2023-04-19 00:12:28 +09:00
Yukihiro "Matz" Matsumoto c1010624a4 Merge pull request #5989 from dearblue/integrate-eval
Integrate `mruby-binding-eval` into `mruby-eval`
2023-04-19 00:06:13 +09:00
Yukihiro "Matz" Matsumoto ac7e63ab3b Merge pull request #5986 from dearblue/bytesplice
Fix bugs in `String#bytesplice`
2023-04-17 07:17:00 +09:00
Yukihiro "Matz" Matsumoto ceabb9cac8 Merge pull request #5988 from dearblue/int-inv
Returns the value of `Integer#~` from `mrb_bint_rev()`
2023-04-16 23:55:51 +09:00
dearblue 0e00d8e224 Integrate mruby-binding-eval into mruby-eval
Currently mruby-eval depends on mruby-binding (formerly mruby-binding-core).
Also, `Kernel#eval` can accept `binding` objects.
With this in mind, it would be better if `Binding#eval` could also be handled by `mrbgems/mruby-eval`.
2023-04-16 21:44:00 +09:00
Yukihiro "Matz" Matsumoto a959ce5755 Merge pull request #5985 from dearblue/sign-extension
Sign extension with `OP_LOADI32` in `get_int_operand()`
2023-04-15 23:25:07 +09:00
dearblue 0279067dc4 Returns the value of Integer#~ from mrb_bint_rev()
fixed #5987
2023-04-15 22:39:05 +09:00
dearblue 8665f88791 Allow an empty string for String#bytesplice 2023-04-15 21:26:01 +09:00
dearblue 59931e95c4 Prohibit string lengths less than 0 in String#bytesplice 2023-04-15 21:26:00 +09:00
dearblue 5bc3a48ecb Handling negative indices in String#bytesplice 2023-04-15 21:25:59 +09:00
dearblue dcced0016c Countermeasure to overflow for String#bytesplice 2023-04-15 21:25:58 +09:00
dearblue 73b6c6619c Need type check for replace by String#bytesplice 2023-04-15 21:25:57 +09:00
dearblue 2e9ac8f448 Returns self for String#bytesplice 2023-04-15 21:25:56 +09:00
dearblue c981e151ae Sign extension with OP_LOADI32 in get_int_operand()
Previously, the following code did not give the expected result.

```
% bin/mruby -e 'p "%08X" % ~(-1 << 16)'
"..F0000FFFF"

% ruby32 -e 'p "%08X" % ~(-1 << 24)'
"00FFFFFF"
```

For information: this problem arises in the process of folding numbers through optimisation.
2023-04-15 20:52:43 +09:00
Yukihiro "Matz" Matsumoto 836bebc708 mruby-compar-ext/compar.rb: Comparable#clamp to accept nil as arguments 2023-04-14 01:06:29 +09:00
Yukihiro "Matz" Matsumoto 68c58eac91 Merge pull request #5981 from dearblue/binding-only-ruby
`Kernel#binding` responds only to calls from Ruby
2023-04-14 01:06:16 +09:00
Yukihiro "Matz" Matsumoto c80db85ed5 Merge pull request #5980 from dearblue/binding-noise
Remove noise in new `mruby-binding`
2023-04-14 01:05:05 +09:00
Yukihiro "Matz" Matsumoto 4f125a3f19 mruby-struct/struct.c: allow struct size differ from members
The situation may be caused by `Struct.new(...).alloc` etc.
2023-04-13 07:39:05 +09:00
Yukihiro "Matz" Matsumoto 8af45425d0 mruby-struct/struct.c: Struct.new should take 1+ arguments 2023-04-13 07:39:05 +09:00
Yukihiro "Matz" Matsumoto bb7b4b67ae mruby-struct/struct.c (struct_corrupted): fix error message 2023-04-13 07:39:05 +09:00
Yukihiro "Matz" Matsumoto a7c96edf6f mruby-struct/struct.c: prohibit Struct.allocate; ref #5979 2023-04-13 07:39:05 +09:00
Yukihiro "Matz" Matsumoto 9822c843e9 mruby-array-ext/array.c: remove mrb_ prefix from static functions 2023-04-13 07:39:05 +09:00
John Bampton 00d43ad960 Add Docker to build and run all mruby tests
Run `pre-commit` and  generate `YARD` docs with Docker

Update CONTRIBUTING
2023-04-13 00:12:32 +10:00
John Bampton 976ec87100 Add the pull request labeler Action
https://github.com/actions/labeler
https://github.com/marketplace/actions/labeler

Verified Action

Update labeler.yml
2023-04-12 19:25:51 +10:00
Yukihiro "Matz" Matsumoto 8d014e9f43 Merge pull request #5984 from mruby/dependabot/github_actions/github/super-linter-5.0.0
build(deps): bump github/super-linter from 4.10.1 to 5.0.0
2023-04-12 09:12:00 +09:00
dependabot[bot] 71e78428ea build(deps): bump github/super-linter from 4.10.1 to 5.0.0
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.10.1 to 5.0.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.10.1...v5.0.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-11 14:57:54 +00:00
Yukihiro "Matz" Matsumoto 0df3e68a5d Merge pull request #5979 from dearblue/allocate-undef
Allow `Class#allocate` to be prohibited
2023-04-10 10:45:00 +09:00
dearblue 5cb2764279 Kernel#binding responds only to calls from Ruby
This follows the behavior changed in CRuby 3.2.
2023-04-09 21:15:13 +09:00
dearblue 93e07eec1c Remove noise in new mruby-binding
`Binding#eval` should not be defined in `mruby-binding`.
2023-04-09 21:14:33 +09:00
dearblue d3128ce58a Allow Class#allocate to be prohibited
Calling `Class#allocate` with `UnboundMethod#bind_call` usually succeeds without problems.
If this behavior does not make us happy, we can now prohibit it with `MRB_SET_INSTANCE_TT(klass, MRB_TT_UNDEF)`.

At the same time, it applies to the `Binding`, `Complex`, `Data`, `Float`, `Integer`, `Method`, `Rational` and `UnboundMethod` classes.
2023-04-09 21:14:07 +09:00
Yukihiro "Matz" Matsumoto c3ba76794f Merge pull request #5977 from dearblue/setup_debug
Make `MRuby::Build#enable_debug` compiler flag setting abstract
2023-04-09 15:51:44 +09:00
dearblue 0f2c1caa96 Make MRuby::Build#enable_debug compiler flag setting abstract
Previously, compiler flags were only added for GCC or similar.
The situation has not changed, but it has become easier to improve.

I expect `MRuby::Command::Compiler#setup_debug` to be defined as a singleton method inside the block given to `MRuby::Toolchain.new`.
2023-04-09 11:21:50 +09:00
Yukihiro "Matz" Matsumoto 64536b866b string.c (str_escape): simplify the logic 2023-04-07 13:53:19 +09:00
Yukihiro "Matz" Matsumoto d0653ca908 cdump.c: escape filename debug information; fix #5974
Windows path separator is "\" so that it needs to be escaped.
2023-04-07 13:51:59 +09:00
Yukihiro "Matz" Matsumoto 27a14f0a9a vm.c (OP_CMP): fixed wrong numeric comparison for integers; fix #5975
MRB_TT_INTEGER value may not be fixnum (immediate integer), so we should
not use mrb_fixnum() here.
2023-04-07 10:46:01 +09:00
Yukihiro "Matz" Matsumoto 761816bf8a fmt_fp.c (mrb_format_float): change else indentation style 2023-04-06 16:49:08 +09:00
Yukihiro "Matz" Matsumoto 956d0c5127 fmt_fp.c (mrb_format_float): set minimum precision 1 for "%e" 2023-04-06 16:47:43 +09:00
Yukihiro "Matz" Matsumoto 31c99eb99b debug.c (mrb_debug_get_position): do not keep lp and fp uninitialized 2023-04-06 15:47:24 +09:00
Yukihiro "Matz" Matsumoto ce86040a0f Merge pull request #5973 from dearblue/envadjust
Small improvements to `envadjust()`
2023-04-06 10:48:49 +09:00
Yukihiro "Matz" Matsumoto 9e4b3af553 Merge pull request #5972 from dearblue/simple-mrb_top_run
Simplify `mrb_top_run()`
2023-04-06 10:46:56 +09:00
Yukihiro "Matz" Matsumoto b4d7b269b0 Merge pull request #5971 from dearblue/simple-raise.2
Remove unnecessary branches in `L_RAISE` block
2023-04-06 10:46:02 +09:00
dearblue 17abe548a7 Small improvements to envadjust()
- Calculate the difference between `oldbase` and `newbase` only once outside the loop.
  - To make sure they are within range, the comparison is done only once instead of twice.
2023-04-05 22:29:27 +09:00
dearblue b90f59d36e Simplify mrb_top_run() 2023-04-05 22:11:36 +09:00
dearblue b46a852acb Remove unnecessary branches in L_RAISE block
The previous `while` loop ends if the catch handler pointer `ch` is not `NULL`.

Supplement to #5843.
2023-04-05 21:52:21 +09:00
Yukihiro "Matz" Matsumoto 35a3bab369 Merge pull request #5966 from jbampton/add-mruby-debugger
Update `default.gembox` add mruby debugger `mrdb`
2023-04-05 15:11:29 +09:00
Yukihiro "Matz" Matsumoto 8e9da2130f Merge pull request #5968 from jbampton/add-mruby-logo-to-readme
Add `mruby` logo to the README
2023-04-05 15:10:26 +09:00
Yukihiro "Matz" Matsumoto 730cbe7c0c Merge pull request #5969 from jbampton/docs-fix-grammar
Fix grammar in `mruby-YOUR-bigint/TODO-HINT.md`
2023-04-05 15:08:44 +09:00
Yukihiro "Matz" Matsumoto 19a2145204 Merge pull request #5970 from jbampton/fix-spelling-of-homepage
`README.md` fix spelling: `home-page` -> `homepage`
2023-04-05 15:07:44 +09:00
John Bampton 6467488854 Add mruby logo to the README
Center logo, mruby title and linter badge

Fix for YARD and Doxygen output
2023-04-05 15:53:02 +10:00
John Bampton e9756c77ea README.md fix spelling: home-page -> homepage
https://en.wikipedia.org/wiki/Home_page
2023-04-05 13:39:41 +10:00
John Bampton ebdb03b4d4 Fix grammar in mruby-YOUR-bigint/TODO-HINT.md 2023-04-05 11:26:05 +10:00
Yukihiro "Matz" Matsumoto 8171edc4eb Merge pull request #5967 from jbampton/sort-gitignore
Sort and remove blank lines from `.gitignore`
2023-04-05 08:05:45 +09:00
John Bampton 076520cac1 Sort and remove blank lines from .gitignore 2023-04-05 03:49:49 +10:00
Yukihiro "Matz" Matsumoto 90e3022936 Merge pull request #5965 from jbampton/fix-word-case-yard
Fix word case: `yard` -> `YARD`
2023-04-04 23:12:48 +09:00
John Bampton b486a3c425 Update default.gembox add mruby debugger mrbd 2023-04-04 19:31:42 +10:00
John Bampton 7082e95fa2 Fix word case: yard -> YARD
https://yardoc.org/
2023-04-04 18:20:52 +10:00
Yukihiro "Matz" Matsumoto b44d757b8c Merge pull request #5962 from jbampton/code-blocks-add-languages
docs: add language `console` to code blocks
2023-04-04 12:09:54 +09:00
Yukihiro "Matz" Matsumoto 76df8d737d Merge pull request #5960 from dearblue/gem-init-final.2
Shrink `<BUILD-DIR>/mrbgems/gem_init.c` if possible
2023-04-04 11:30:21 +09:00
Yukihiro "Matz" Matsumoto 5265e35ad2 mruby-time/time.c: remove mrb_ prefix from static functions 2023-04-03 08:58:33 +09:00
Yukihiro "Matz" Matsumoto 3d2cf0d9bf mruby-bigint/bigint.c: fix int64/uint64 conversion
The functions were totally wrong in digit order and sign treatment. We
didn't notice since they are only called from mruby-time in the m64-i32
configuration.
2023-04-03 08:55:48 +09:00
Yukihiro "Matz" Matsumoto 65897145aa mruby-time/time.c (mrb_to_time_t): should always initialize usec 2023-04-03 08:46:30 +09:00
Yukihiro "Matz" Matsumoto 875e0b0b59 mruby-time/time.c (time_value_from_time_t): should raise exception
When time_t does not fit in mrb_int; ref #5958
2023-04-03 08:38:52 +09:00
Yukihiro "Matz" Matsumoto dd453080e0 Merge pull request #5958 from dearblue/fixable_time_t_p
Need `fixable_time_t_p()` always
2023-04-03 07:34:11 +09:00
John Bampton f0d6674352 docs: add language console to code blocks
https://github.com/github/linguist/blob/79c4aa4706e08f9eb36e46535f0e909f51f3b74d/lib/linguist/languages.yml#L6392
2023-04-03 08:28:59 +10:00
dearblue 73b2e0bf76 Shrink <BUILD-DIR>/mrbgems/gem_init.c if possible
If none of the GEMs have `mrblib/` or `src/` directories, generate `mrb_init_mrbgems()` which does nothing, and omit `mrb_final_mrbgems()`.

The impetus was to avoid `gem_funcs[]` becoming a zero-length array, which is not allowed by the C standard.
The problem is caused by #5938.
2023-04-02 20:28:14 +09:00
Yukihiro "Matz" Matsumoto c6e7dfe9e5 Merge pull request #5959 from dearblue/mruby-strip
Need a dependency to `mruby-compiler` for `mruby-bin-strip`
2023-04-02 08:58:58 +09:00
dearblue 96190dba59 Need a dependency to mruby-compiler for mruby-bin-strip
It uses `mrb_irep_remove_lv()` defined in `mrbgems/mruby-compiler/core/codegen.c`.
2023-04-01 23:32:36 +09:00
dearblue bcce4b7141 Need fixable_time_t_p() always 2023-04-01 23:22:08 +09:00
Yukihiro "Matz" Matsumoto 2de602b869 mruby-eval: add dependency to mruby-binding 2023-04-01 10:37:56 +09:00
Yukihiro "Matz" Matsumoto eaaa474630 mruby-method/method.c: fix proc comparison for uncovered case 2023-04-01 10:37:16 +09:00
Yukihiro "Matz" Matsumoto a3fc6ae53c mruby-proc-ext/proc.c: use mrb_debug_get_position() 2023-04-01 10:37:15 +09:00
Yukihiro "Matz" Matsumoto 6629112291 Merge pull request #5957 from jbampton/clean-up-doc-limitations-md
doc/limitations.md: remove whitespace, add code block languages
2023-04-01 10:37:08 +09:00
John Bampton e76525568a doc/limitations.md: remove whitespace, add code block languages 2023-04-01 07:52:29 +10:00
Yukihiro "Matz" Matsumoto 58a83f3b9a codeql-analysis.yml: stop running codeql workflow 2023-03-31 09:43:30 +09:00
Yukihiro "Matz" Matsumoto 85aefa8992 Merge pull request #5955 from LanzaSchneider/master
fix: wrong comment for ```mrb_debug_get_filename```
2023-03-31 08:27:27 +09:00
Yukihiro "Matz" Matsumoto d482eabfa2 mruby-bigint/bigint.c: int.pow(n,m) to take bigint as exponential 2023-03-31 08:26:47 +09:00
Yukihiro "Matz" Matsumoto 62c52d5a28 mruby-bigint/bigint.c: remove unreachable line 2023-03-30 08:18:27 +09:00
Yukihiro "Matz" Matsumoto 35cedfb400 mruby-numeric-ext/numeric.c: Integer#pow fix for 2nd argument type
`int.pow()` takes 2nd argument only if 1st argument is an integer.
2023-03-30 08:18:27 +09:00
Lanza 01b03d852f fix: wrong comment for ``mrb_debug_get_filename`` 2023-03-30 06:57:33 +08:00
Yukihiro "Matz" Matsumoto f1568af0d2 gc.c: fix GC regressions
The past fix was wrong.
2023-03-29 08:46:10 +09:00
Yukihiro "Matz" Matsumoto 1f5a4d5386 mruby-method/method.c (method_eql): simplify the logic 2023-03-27 19:21:40 +09:00
Yukihiro "Matz" Matsumoto 553f9ba802 mruby-method/method.c (method_eql): use mrb_proc_eql 2023-03-27 19:15:03 +09:00
Yukihiro "Matz" Matsumoto fbb3a2426f proc.c (mrb_proc_eql): define == and eql? for Proc class 2023-03-27 19:14:21 +09:00
Yukihiro "Matz" Matsumoto ddb2240b5e proc.c: update ISO section numbers for methods 2023-03-27 11:39:58 +09:00
Yukihiro "Matz" Matsumoto b885d7387d proc.c: no need to define Proc.lambda
Since Kernel is an ancestor of Kernel module itself recursively.
2023-03-27 11:33:13 +09:00
Yukihiro "Matz" Matsumoto 0f63551def mruby-method/method.c (method_p): stricter method type check 2023-03-27 11:32:15 +09:00
Yukihiro "Matz" Matsumoto f4cff664e6 mruby-proc-ext/proc.c: no need to define Kernel.proc
Since Kernel is an ancestor of Kernel module itself recursively.
2023-03-27 00:18:57 +09:00
Yukihiro "Matz" Matsumoto 3e7ced5d63 mruby-proc-ext/proc.c: remove prefix from static functions 2023-03-27 00:12:18 +09:00
Yukihiro "Matz" Matsumoto 0bbfec3e8b mruby-eval: use functions from mruby-binding to simplify the code 2023-03-25 19:12:46 +09:00
Yukihiro "Matz" Matsumoto 11af5db1c3 mruby-binding: renamed from mruby-binding-core
The dependency is now:

mruby-binding-eval:

  - mruby-binding
  - mruby-eval

mruby-proc-binding:

  - mruby-binding

mruby-eval:

  - mruby-binding [new]
2023-03-24 12:25:57 +09:00
Yukihiro "Matz" Matsumoto 3ef41672ab mruby-biding-eval: move essential part of the gem to mruby-eval
This change makes mruby-binding-eval gem nearly empty, but needed to
make `eval(str, binding)` works as well as `binding.eval(str)`.
2023-03-24 07:33:13 +09:00
Yukihiro "Matz" Matsumoto 910afdc691 mruby-binding-eval: modify struct initialization 2023-03-23 22:10:20 +09:00
Yukihiro "Matz" Matsumoto 5914d9e9d4 mruby-binding-eval: remove unused members from binding_eval_prepar_body 2023-03-23 16:16:52 +09:00
Yukihiro "Matz" Matsumoto bf9a2501d1 mruby-binding-eval: move non raising code to the parent function 2023-03-22 23:22:45 +09:00
Yukihiro "Matz" Matsumoto bdbc613ccb parse.y (mrbc_filename): should not raise exceptions 2023-03-22 17:33:49 +09:00
Yukihiro "Matz" Matsumoto feabcfe29e doc/limitations.md: remove an entry regarding binding
Since it's no longer a limitation.
2023-03-22 15:26:29 +09:00
Yukihiro "Matz" Matsumoto 501b22a2ac mruby-binding-eval: renamed from mruby-binding
Since this gem only provides `Binding#eval`.
2023-03-22 15:25:23 +09:00
Yukihiro "Matz" Matsumoto 979e8602dd mruby-binding-core: make mrb_binding_wrap_lvspace static 2023-03-21 16:18:15 +09:00
Yukihiro "Matz" Matsumoto 66ca9722b6 mruby-binding-core (mrb_binding_new): new function
Use this function instead of `mrb_binding_alloc` (removed).
2023-03-21 16:17:08 +09:00
Yukihiro "Matz" Matsumoto 88ae5e8cf8 mruby-binding-core: use mrb_binding_wrap_lvspace if possible 2023-03-21 16:10:15 +09:00
Yukihiro "Matz" Matsumoto 495845443c mruby-binding-core (mrb_binding_p) add new function 2023-03-21 16:10:15 +09:00
Yukihiro "Matz" Matsumoto 35e2779575 Small cosmetic changes (adjust indent, and remove extra space) 2023-03-21 16:10:15 +09:00
Yukihiro "Matz" Matsumoto 0c8404a3e2 mruby-binding: use C implementation of Kernel#eval directly 2023-03-21 16:10:15 +09:00
Yukihiro "Matz" Matsumoto 1c765dc37a Merge pull request #5902 from dearblue/threadedcode
Replace `MRB_NO_DIRECT_THREADING` with `MRB_USE_VM_SWITCH_DISPATCH`
2023-03-18 23:56:04 +09:00
dearblue f6c9191cd0 Replace MRB_NO_DIRECT_THREADING with MRB_USE_VM_SWITCH_DISPATCH
The correct technique now is "Token Threading".
However, the new name was chosen because it was felt that if a different technique was added in the future, there would be no need to replace it.
2023-03-18 17:39:41 +09:00
Yukihiro "Matz" Matsumoto db11e07497 Merge pull request #5951 from dearblue/mrb_yield
Safely retrieve `self` from proc in `mrb_yield()`
2023-03-17 22:54:05 +09:00
dearblue 2675477f07 Safely retrieve self from proc in mrb_yield()
Passing a proc generated by the following method to `mrb_yield()` or `mrb_yield_argv()` no longer causes `SIGSEGV`:

- C functions made into proc objects with `mrb_proc_new_cfunc()`.
- A proc object which is the top level of a program generated by `mrb_load_string_cxt()` etc. with `mrbc_context::no_exec` enabled.

See also: #5932
2023-03-17 21:20:48 +09:00
Yukihiro "Matz" Matsumoto 800cb15fc3 limitation.md: describe mruby limitation for keyword arguments; #5952 2023-03-17 18:58:04 +09:00
Yukihiro "Matz" Matsumoto de70014643 mruby-binding/binding.c: add comment for functions from outer gems 2023-03-16 19:02:23 +09:00
Yukihiro "Matz" Matsumoto 62a8ea7113 mruby-bigint/bigint.c: mrb_bint_add_d, mrb_bint_sub_d only take int
Where mrb_bint_add and mrb_bint_sub may take float numbers.
2023-03-15 19:09:02 +09:00
Yukihiro "Matz" Matsumoto 3f7ea47ec1 Merge pull request #5917 from jbampton/remove-super-linter-folder
Remove `super-linter.report` folder
2023-03-15 19:07:30 +09:00
Yukihiro "Matz" Matsumoto 4fc69ce3bc Revert "mruby/throw.h: do not use __builtin_setjmp for GCC; close #5950"
This reverts commit 9cf49d08b4.

This change caused flaky tests on MinGW. I now remember it was introduced
for MINGW64 to address #5133. Sorry.
2023-03-14 19:50:15 +09:00
Yukihiro "Matz" Matsumoto 0d07af104b internal.h: move function prototypes to <mruby/internal.h> 2023-03-14 11:06:44 +09:00
Yukihiro "Matz" Matsumoto 2d975d59ce Merge branch 'dearblue-binding.4' 2023-03-14 11:05:53 +09:00
Yukihiro "Matz" Matsumoto 6915e75207 Merge branch 'binding.4' of https://github.com/dearblue/mruby into dearblue-binding.4 2023-03-14 11:05:10 +09:00
Yukihiro "Matz" Matsumoto da2cfa62f4 AUTHORS: update entries [ci skip] 2023-03-13 19:01:32 +09:00
Yukihiro "Matz" Matsumoto 0906cd7593 numeric.c: fix rounding function issues with big numbers
- int_ceil
- int_floor
- int_round
- int_truncate
2023-03-13 18:53:17 +09:00
Yukihiro "Matz" Matsumoto 8d1192f8a2 gc.c (mrb_field_write_barrier): change the condition
Minor GC may be suspended with the MRB_GC_STATE_SWEEP.
2023-03-13 18:52:03 +09:00
Yukihiro "Matz" Matsumoto ccca6ec458 gc.c (clear_all_old): simplify the code
The function is called only with generational mode.
2023-03-13 18:50:51 +09:00
Yukihiro "Matz" Matsumoto 9a1e6760a8 mruby-bigint: add new functions mrb_bint_add_d, mrb_bint_sub_d
Those functions do not normalize the return value to avoid repeated
conversions between Bigints and (small) Integers.
2023-03-13 16:07:17 +09:00
Yukihiro "Matz" Matsumoto f7cbb319cb mruby-bigint: remove unused mrb_bint_div_ii() function 2023-03-13 08:10:41 +09:00
Yukihiro "Matz" Matsumoto 33320b08bb mruby-data: fix uninitialized variable error 2023-03-13 08:09:26 +09:00
Yukihiro "Matz" Matsumoto 7327ca898c mruby-struct: fix uninitialized variable error 2023-03-13 08:08:30 +09:00
Yukihiro "Matz" Matsumoto dd0a9e8970 mruby-bigint/bigint.c: remove a condition to stop warnings 2023-03-13 08:06:41 +09:00
Yukihiro "Matz" Matsumoto 9cf49d08b4 mruby/throw.h: do not use __builtin_setjmp for GCC; close #5950
https://gcc.gnu.org/onlinedocs/gcc/Nonlocal-Gotos.html
2023-03-13 08:05:55 +09:00
Yukihiro "Matz" Matsumoto 924d605712 vm.c: remove redundant assignment (already done in cipush) 2023-03-13 08:05:55 +09:00
Yukihiro "Matz" Matsumoto 0edb616f51 gc.c: remove time profiling code for debugging 2023-03-13 08:05:54 +09:00
Yukihiro "Matz" Matsumoto a8d840da19 Merge pull request #5928 from dearblue/task/install
Improved `rake install`
2023-03-13 08:05:20 +09:00
Yukihiro "Matz" Matsumoto 938ad70e1e Merge pull request #5938 from dearblue/reorganize-gem-init-final
Reorganize gem init final
2023-03-13 07:52:20 +09:00
dearblue 1432baec1d Perform chores with mrb_final_mrbgems() function
The main purpose is to ignore exceptions raised by the GEMS finalizer.
2023-03-12 14:31:10 +09:00
dearblue c474ae8cc4 Perform chores with mrb_init_mrbgems() function
Make the `mrb_init_mrbgems()` function do the cleanup and error handling.
Instead, simplify processing in the `GENERATED_TMP_mrb_XXX_gem_init()` function.

Previously, `mrb_load_irep()` or `mrb_load_proc()` would kill the process when an exception occurred.
With this patch, it is now caught by `mrb_core_init_protect()`.
2023-03-12 10:25:54 +09:00
Yukihiro "Matz" Matsumoto 629d81f57b Merge pull request #5937 from dearblue/note-gem-init
Add the generator path to the `build/***/gem_init.c` file
2023-03-12 08:01:38 +09:00
Yukihiro "Matz" Matsumoto 894ce40797 Merge pull request #5946 from dearblue/const-search
Don't switch constant search path from modules to Object
2023-03-11 16:19:53 +09:00
Yukihiro "Matz" Matsumoto 90e53cad39 Merge pull request #5945 from dearblue/env-internal
Avoid exposure for `REnv` objects
2023-03-11 16:18:28 +09:00
Yukihiro "Matz" Matsumoto 7f79ca2cf6 mruby-compiler: need to adjust the line number for do_block; fix #5949 2023-03-11 15:49:35 +09:00
Yukihiro "Matz" Matsumoto 927a9df453 mruby-data/data.c: allow empty Data 2023-03-10 08:52:06 +09:00
Yukihiro "Matz" Matsumoto c212edec5f mruby-struct/struct.c: allow empty Struct when a name is not given 2023-03-10 08:52:06 +09:00
Yukihiro "Matz" Matsumoto fc4fe48a00 mruby-time/time.c: fix error message from localtime_r(3) failure 2023-03-10 08:52:06 +09:00
Yukihiro "Matz" Matsumoto 13cd0e5585 mruby-time/time.c (mrb_time_minus): specify mrb_float directly
The `typedef mrb_sec` does not improve readability at all.
2023-03-10 08:52:06 +09:00
Yukihiro "Matz" Matsumoto e62d672ef3 mruby-time/time.c (mrb_to_time_t): support Bigint if defined 2023-03-10 08:52:06 +09:00
Yukihiro "Matz" Matsumoto 01233f70bd mruby-bigint/bigint.c: add two new functions to convert to 64bit int
- mrb_bint_as_int64()
- mrb_bint_as_uint64()
2023-03-10 08:52:05 +09:00
Yukihiro "Matz" Matsumoto c71408bc0a mruby-time/time.c (mrb_to_time_t): raise error if obj is not time
Or a time-compatible object like a number.
2023-03-10 08:52:05 +09:00
Yukihiro "Matz" Matsumoto 7096d277da mruby-time/time.c: support bigint to time_t if necessary 2023-03-10 08:52:05 +09:00
Yukihiro "Matz" Matsumoto da8c23524f mruby-time/time.c (mrb_to_time_t): use floor instead of llround
Since we should generate `t=(sec+usec)` from a floating point number
`sec` should be `floor(f)` especially for negative numbers, if the place
for `usec` is specified. In contrast, we can `round` the below point
digits if we are going to ignore them. But we now use `round` instead of
`llround` which directly convert `double` to `long long`, to add
boundary check for conversion.
2023-03-10 08:52:05 +09:00
Yukihiro "Matz" Matsumoto 2f0265d078 mruby-io/io.c (check_file_descriptor): stop "unused label" warning 2023-03-10 08:52:05 +09:00
Yukihiro "Matz" Matsumoto 9a3199cadd mruby-io/file.c: atime, ctime, mtime to return Bigint if possible 2023-03-10 08:52:05 +09:00
Yukihiro "Matz" Matsumoto a3b84fbb08 mruby-bigint/bigint.c: add 2 new functions for 64 bit integer
- mrb_bint_new_int64()
- mrb_bint_new_uint64()
2023-03-10 08:52:05 +09:00
Yukihiro "Matz" Matsumoto b1d0a3d3aa etc.c (mrb_float_id): define the function only when necessary 2023-03-10 08:52:04 +09:00
Yukihiro "Matz" Matsumoto e5de08b692 mruby-time/time.c (time_mktime): should allow year before 1900
If the platform use 64 bit time_t, it is possible to represent the year
before 1903. So we should remove this check.
2023-03-10 08:52:04 +09:00
Yukihiro "Matz" Matsumoto bcd595ad1b mruby-bigint/bigint.c: add else to skip if check 2023-03-10 08:52:04 +09:00
Yukihiro "Matz" Matsumoto f1ffedc3fa vm.c: kdict may be converted to a normal argument; fix #5944 2023-03-10 08:52:04 +09:00
Yukihiro "Matz" Matsumoto 18158c96f5 Merge pull request #5948 from dearblue/cinfo
Added note to `CINFO_*` constants
2023-03-10 08:50:26 +09:00
Yukihiro "Matz" Matsumoto 840953b55a Merge pull request #5947 from dearblue/fiber-resume
Remove unreachable codes in `Fiber#resume`
2023-03-10 08:49:12 +09:00
dearblue ddaf3bdc0f Added note to CINFO_* constants 2023-03-09 22:13:52 +09:00
dearblue f4c4809750 Remove unreachable codes in Fiber#resume
ref. #5782
2023-03-09 21:40:03 +09:00
dearblue 9c9be44a98 Don't switch constant search path from modules to Object
Previously, for example, it was possible to retrieve the `String` class as follows:

```console
% bin/mruby -e 'p Comparable::Enumerable::Errno::GC::Kernel::Math::ObjectSpace::String'
String
```

Note that this patch affects the API function `mrb_const_get()`.
2023-03-05 20:32:56 +09:00
dearblue 38d5ed44e1 Avoid exposure for REnv objects
The `REnv` object is difficult to deal with, and it would be ideal if the user did not have to manipulate it directly.
In some previous situations, it was necessary to call `mrb_env_unshare()`, a non-API function, after `mrb_load_string()` or similar.

With this patch, it is no longer necessary for users to use `mrb_env_unshare()` directly, as it is now handled internally simply by using the `mrb_vm_ci_env_clear()` function.
Also, `mrb_vm_ci_env_set()` is demoted from the `MRB_API` function for the same reason.

ref. commit 1ab3da6f08
2023-03-05 17:45:47 +09:00
Yukihiro "Matz" Matsumoto 45ee9cc404 mruby-socket/socket.c: read/write should be redefined on Windows; fix #5943
Since normal file descriptors and sockets cannot be mixed on the
platform.
2023-03-04 09:27:43 +09:00
Yukihiro "Matz" Matsumoto 42d3efee1c mruby-socket/socket.c: read/write should be redefined on Windows; fix #5943
Since normal file descriptors and sockets cannot be mixed on the
platform.
2023-03-03 15:30:51 +09:00
Yukihiro "Matz" Matsumoto 011edf6e99 mruby-io/file.c: hide internal methods in backtraces 2023-03-03 14:23:10 +09:00
Yukihiro "Matz" Matsumoto 5237b2cccc mruby-io/file.c: atime, ctime, mtime check mrb_int overflow
When `sizeof(time_t)` is different from `mrb_int`, overflow may happen.
2023-03-03 14:21:05 +09:00
Yukihiro "Matz" Matsumoto 0e51da81bb mruby-io/file.rb (inspect): include path in the #inspect output 2023-03-03 13:33:30 +09:00
Yukihiro "Matz" Matsumoto a956ef35a4 mruby-io/file.c: atime, ctime, mtime should raise error
For fstat(3) failure.
2023-03-03 13:33:29 +09:00
Yukihiro "Matz" Matsumoto 9c6848a594 mruby-io/io.c (check_file_descriptor): only check EBADF 2023-03-03 13:33:29 +09:00
Yukihiro "Matz" Matsumoto 0529f5fc31 mruby-io/test/file.rb: add tests for File#atime, File#ctime 2023-03-03 13:33:29 +09:00
Yukihiro "Matz" Matsumoto 321cfe9760 mruby-io/file.c: add File#atime and File#ctime 2023-03-03 13:33:29 +09:00
Yukihiro "Matz" Matsumoto 31c1b7bc78 mruby-file: File#mtime has been available for long time 2023-03-03 13:33:29 +09:00
Yukihiro "Matz" Matsumoto 84a4d340a6 mruby-io/file.c (_mtime): return nil instead of false
As a Ruby convention, a method should return nil (not false) for the
exceptional value, e.g. String#index. File#_mtime should follow the
convention too.
2023-03-03 13:33:29 +09:00
Yukihiro "Matz" Matsumoto d86c4a795d mruby-io does not provide to_path method for implicit conversion
mruby does not use implicit type conversion by `to_xxx` (e.g. to_int,
to_str, etc.)
2023-03-03 13:33:29 +09:00
Yukihiro "Matz" Matsumoto d7f4af04ca Merge pull request #5939 from jbampton/appveyor-add-visual-studio-2022
appveyor: add job for Visual Studio 2022
2023-03-02 15:08:50 +09:00
Yukihiro "Matz" Matsumoto bdf39fe4af Merge pull request #5940 from jbampton/remove-misspell
Remove `misspell` and update `CONTRIBUTING.md`
2023-03-01 23:47:41 +09:00
Yukihiro "Matz" Matsumoto 0d35fe072e Merge pull request #5941 from jbampton/simplify-the-editorconfig-file 2023-03-01 23:42:08 +09:00
John Bampton a874b80dae Simplify the .editorconfig file
We already have `trailing-whitespace` set globally in the `pre-commit` config
and we are also using `spaces` instead of `tabs` except for "Makefiles" which have `tab_width = 8`

Perhaps in future we can enforce line lengths.

https://github.com/mruby/mruby/blob/92ca93c885a6e6d2facd8e9ca3dbf85ac3dce8c9/.pre-commit-config.yaml#L29

https://github.com/mruby/mruby/blob/92ca93c885a6e6d2facd8e9ca3dbf85ac3dce8c9/.pre-commit-config.yaml#L33
2023-03-01 21:34:23 +10:00
John Bampton 2559c93b2b Remove misspell and update CONTRIBUTING.md
It looks like `misspell` is no longer maintained and
the last commit was on `Mar 9, 2018`.

We already run `codespell` and it is an active project
with the last commit 5 days ago.

Also updated the CONTRIBUTING guide with more
information on `pre-commit` as well as listed `codespell`
as the spell checker.

https://github.com/codespell-project/codespell
https://github.com/client9/misspell
https://github.com/client9/misspell/issues/197
2023-03-01 17:49:39 +10:00
John Bampton 47dcb393ca appveyor: add job for Visual Studio 2022
Visual Studio 2022 on Windows is now a 64-bit application.

https://www.appveyor.com/docs/build-environment/#build-worker-images

https://learn.microsoft.com/en-us/visualstudio/ide/whats-new-visual-studio-2022?view=vs-2022#visual-studio-2022-is-64-bit
2023-03-01 03:21:46 +10:00
dearblue 396ca2809f Add the generator path to the build/***/gem_init.c file 2023-02-28 22:11:14 +09:00
Yukihiro "Matz" Matsumoto 92ca93c885 Merge pull request #5936 from jbampton/remove-duplicate-method-calls
benchmark: remove duplicate method calls
2023-02-25 22:10:28 +09:00
Yukihiro "Matz" Matsumoto b59832ed26 Merge pull request #5935 from jbampton/upgrade-doxyfile
Upgrade the `Doxyfile`
2023-02-25 22:09:36 +09:00
John Bampton d86f4d220f benchmark: remove duplicate method calls
DuplicateMethodCall: Scene#render calls 'nsf * nsf' 3 times
2023-02-25 15:22:49 +10:00
John Bampton 5dd0f74ecf Upgrade the Doxyfile
```
mruby % doxygen -u
warning: Tag 'CLANG_ASSISTED_PARSING' at line 50 of file 'Doxyfile' belongs to an option that was not enabled at compile time.
         This tag has been removed.
warning: Tag 'CLANG_OPTIONS' at line 51 of file 'Doxyfile' belongs to an option that was not enabled at compile time.
         This tag has been removed.
warning: Tag 'TCL_SUBST' at line 238 of file 'Doxyfile' has become obsolete.
         This tag has been removed.
warning: Tag 'COLS_IN_ALPHA_INDEX' at line 1075 of file 'Doxyfile' has become obsolete.
         This tag has been removed.
warning: Tag 'FORMULA_TRANSPARENT' at line 1481 of file 'Doxyfile' has become obsolete.
         This tag has been removed.
warning: Tag 'LATEX_SOURCE_CODE' at line 1769 of file 'Doxyfile' has become obsolete.
         This tag has been removed.
warning: Tag 'RTF_SOURCE_CODE' at line 1851 of file 'Doxyfile' has become obsolete.
         This tag has been removed.
warning: Tag 'DOCBOOK_PROGRAMLISTING' at line 1949 of file 'Doxyfile' has become obsolete.
         This tag has been removed.
warning: Tag 'PERL_PATH' at line 2094 of file 'Doxyfile' has become obsolete.
         This tag has been removed.
warning: Tag 'CLASS_DIAGRAMS' at line 2107 of file 'Doxyfile' has become obsolete.
         This tag has been removed.
warning: Tag 'MSCGEN_PATH' at line 2116 of file 'Doxyfile' has become obsolete.
         This tag has been removed.
warning: Tag 'DOT_FONTNAME' at line 2158 of file 'Doxyfile' has become obsolete.
         This tag has been removed.
warning: Tag 'DOT_FONTSIZE' at line 2165 of file 'Doxyfile' has become obsolete.
         This tag has been removed.
warning: Tag 'DOT_TRANSPARENT' at line 2391 of file 'Doxyfile' has become obsolete.
         This tag has been removed.

Configuration file 'Doxyfile' updated.
```
2023-02-25 12:55:53 +10:00
Yukihiro "Matz" Matsumoto ee599b25c1 Merge pull request #5934 from jbampton/rake-checkupdate
Run `rake checkupdate`
2023-02-25 09:26:26 +09:00
Yukihiro "Matz" Matsumoto f8a66c88b8 Merge pull request #5933 from jbampton/update-mruby-version-numbers
docs: update mruby version to `3.2.0`
2023-02-25 09:26:03 +09:00
John Bampton d4dd75b82c Run rake checkupdate
`pre-commit autoupdate`
2023-02-25 08:12:50 +10:00
John Bampton 46e42b38f0 docs: update mruby version to 3.2.0 2023-02-25 08:02:45 +10:00
Yukihiro "Matz" Matsumoto 82c67d52fc Merge pull request #5931 from mruby/stable
Merge mruby 3.2.0
2023-02-24 23:19:09 +09:00
mimaki 87260e7bb1 Update version and release date. (mruby 3.2.0 (2023-02-24)) 2023-02-24 19:51:12 +09:00
Yukihiro "Matz" Matsumoto 1ab3da6f08 vm.c (ci_env_set): inline ci_env_set()
Along with making preparing mrb_vm_ci_env_clar() as a replacement of
mrb_vm_ci_env_set(mrb, NULL).
2023-02-23 17:16:10 +09:00
Yukihiro "Matz" Matsumoto 2c046eb512 mruby.h: replace frequently used inline functions with macros
- mrb_gc_arena_save()
- mrb_gc_arena_restore()
2023-02-22 16:35:14 +09:00
Yukihiro "Matz" Matsumoto d8d1fe27f6 vm.c (stack_extend): inline mrb_stack_extend() in vm.c 2023-02-22 12:05:46 +09:00
Yukihiro "Matz" Matsumoto 43922a5bf9 vm.c (mrb_gc_arena_shrink): use local variable 2023-02-21 21:59:42 +09:00
Yukihiro "Matz" Matsumoto a21edf75ad Use mrb_get_arg1() instead of mrb_get_args() for single argument 2023-02-21 16:33:15 +09:00
Yukihiro "Matz" Matsumoto aecbdf72bf vm.c (mrb_env_unshare): remove unnecessary mrb_write_barrier() call
Since this function does not modify references from env, we don't need
to put write barrier here.
2023-02-21 09:45:17 +09:00
Yukihiro "Matz" Matsumoto d4cb136deb kernel.c (mrb_obj_ceqq): skip unnecessary mrb_ary_entry()
We have checked the boundary before the call.
2023-02-20 17:33:52 +09:00
Yukihiro "Matz" Matsumoto 76157c5f78 add inline specifier to frequently called functions
- entry_deleted_p(): hash.c
- ensure_block(): vm.c
2023-02-19 19:06:37 +09:00
Yukihiro "Matz" Matsumoto 7cbe6894b4 debug.c (mrb_debug_get_position): avoid duplicate calls to get_file() 2023-02-19 19:05:54 +09:00
Yukihiro "Matz" Matsumoto 78137f31c8 error.c (mrb_make_exception): reinvent exception creation
The arguments of mrb_make_exception() has changed. I believe no one is
using the function, but beware.
2023-02-18 11:51:33 +09:00
Yukihiro "Matz" Matsumoto 431f83eb8c error.c (mrb_make_exception): make the function internal 2023-02-17 17:04:09 +09:00
Yukihiro "Matz" Matsumoto 515b2fd144 class.c (mrb_method_added): skip mrb_funcall_id() is possible
When `method_added` is not redefined, we don't need to call it since its
default implementation does nothing.
2023-02-16 09:38:26 +09:00
Yukihiro "Matz" Matsumoto 2768fd62a0 Reduce calls to mrb_obj_is_kind_of() 2023-02-15 11:45:10 +09:00
Yukihiro "Matz" Matsumoto 235aaafef2 array.c (mrb_ary_aset): remove unnecessary ary_modify()
The `ary_modify()` is called in subsidiary functions.
2023-02-14 23:45:10 +09:00
Yukihiro "Matz" Matsumoto 4384a87516 class.c, vm.c: use loop variable declaration in for statement 2023-02-13 14:16:53 +09:00
Yukihiro "Matz" Matsumoto 58aefd6010 class.c, vm.c: use NULL instead of 0 for pointers 2023-02-13 14:16:30 +09:00
Yukihiro "Matz" Matsumoto ea0e8f7ea4 numeric.c (flo_mod): use NULL instead of 0
In C, we don't use 0 as NULL representation.
2023-02-13 00:08:40 +09:00
dearblue 7c7ed3c27a Write symbolik links or batch files in INSTALL_DIR
Since `bin/mruby-config` now points to a directory relative to itself, it is no longer possible to reach `include/` or `lib/`.
Therefore, avoid placing entities in them.
2023-02-12 23:25:05 +09:00
dearblue 11513bae43 Make bin/mruby-config output a directory based on itself 2023-02-12 23:25:01 +09:00
dearblue 3d996a84cc Takes the environment variable DESTDIR in rake install
If the environment variable `DESTDIR` is set, the writing destination is `<DESTDIR>/<PREFIX>/...`.
It is assumed to be used for package work.
2023-02-12 21:02:31 +09:00
dearblue 0e9a71e50a Install other build targets with rake install:full
Build targets other than "host" will be installed under `<PREFIX>/mruby/<build-name>`.
This can be changed with `build.install_prefix = dir`.
2023-02-12 21:02:30 +09:00
dearblue 7fd7409bf2 Files copied by task install should be from the build directory 2023-02-12 21:02:29 +09:00
dearblue aac2fd7055 Copy header files to the build directory
This is so that the build directory can be regarded as a temporary installation directory to work in.

Directories set in `MRuby::Gem::Specification#export_include_paths` are used as they are if they are subdirectories placed under `gem.dir`.
Files are placed under `<build-dir>/include/mruby/gems/<gem-name>/<gem-include_paths>` to separate each GEM.

When GEM is compiled by building `libmruby.a`, the same `include_paths` will be set as before, so it is expected that no unintended references will be made.
2023-02-12 21:02:28 +09:00
dearblue c020d8507e Separate rake install related stuff into tasks/install.rake 2023-02-12 21:02:27 +09:00
Yukihiro "Matz" Matsumoto 4f9caea891 range.c (range_num_to_a): add array entries directly
Calling `mrb_ary_push()` is slower.
2023-02-11 16:13:33 +09:00
Yukihiro "Matz" Matsumoto 2adb1043f4 array.c (mrb_ary_push_m): call mrb_ary_push() when argc == 1 2023-02-11 14:23:48 +09:00
Yukihiro "Matz" Matsumoto b4c936b533 use new E_EXCEPTION and E_STANDARD_ERROR; ref #5924 2023-02-10 15:21:38 +09:00
Yukihiro "Matz" Matsumoto 49709a65c7 AUTHORS: update entries [ci skip] 2023-02-10 15:21:38 +09:00
Yukihiro "Matz" Matsumoto bed7a79add Merge pull request #5927 from jbampton/remove-unneeded-whitespace
md/yml: remove unneeded blank lines and whitespace
2023-02-10 14:24:47 +09:00
Yukihiro "Matz" Matsumoto 7373b63919 Merge pull request #5926 from jbampton/update-license-year
Update License year to 2023
2023-02-10 14:23:32 +09:00
John Bampton 07a7d2a6cb md/yml: remove unneeded blank lines and whitespace 2023-02-10 14:02:57 +10:00
John Bampton 8af0aa4905 Update License year to 2023 2023-02-10 11:55:32 +10:00
mimaki 4ca2129889 Update version to 3.2.0RC4. 2023-02-08 10:04:29 +09:00
Yukihiro "Matz" Matsumoto fc53cd20b6 Merge pull request #5925 from jbampton/update-authors-file
AUTHORS: update "as of" info for `year`
2023-02-08 06:38:31 +09:00
Yukihiro "Matz" Matsumoto 75bdb4e0ec Merge pull request #5924 from dearblue/exception-classes
Improve consistency of how error classes are retrieved
2023-02-08 06:30:34 +09:00
Yukihiro "Matz" Matsumoto 8a2bb9eb93 Merge pull request #5923 from dearblue/mrb_f_raise
Demotion `mrb_f_raise()` from `MRB_API`
2023-02-08 06:30:17 +09:00
John Bampton 5189d73d6d AUTHORS: update "as of" info for year
The AUTHORS file was last published on January 8th 2023
2023-02-08 03:29:10 +10:00
dearblue a93807f48f Improve consistency of how error classes are retrieved 2023-02-07 22:46:56 +09:00
dearblue 0898ce982e Demotion mrb_f_raise() from MRB_API
This function is the entity of the `Kernel.#raise` or `Kernel#fail` method.
I don't think users can use it whenever they want, and I don't think there is any need to expose it as an entity of a user-defined method.
2023-02-07 22:37:58 +09:00
Yukihiro "Matz" Matsumoto 056cda72be mruby-bin-mirb: fix multi-line input issue; fix #5922
Bison changed the message for the end-of-file error. `mirb` should
be updated for the new message.
2023-02-07 17:43:14 +09:00
Yukihiro "Matz" Matsumoto 762ca43c16 mruby-bin-mirb: add bintest for multi-line input; ref #5922 2023-02-07 17:42:56 +09:00
Yukihiro "Matz" Matsumoto 78141d17f1 mruby-bin-mirb: fix multi-line input issue; fix #5922
Bison changed the message for the end-of-file error. `mirb` should
be updated for the new message.
2023-02-07 15:45:11 +09:00
Yukihiro "Matz" Matsumoto a25755060c mruby-bin-mirb: add bintest for multi-line input; ref #5922 2023-02-07 15:44:50 +09:00
Yukihiro "Matz" Matsumoto 6ca1b8e4e7 mruby-catch/catch.c: update disasm comment for new output format 2023-02-06 11:21:52 +09:00
Yukihiro "Matz" Matsumoto 7e607c67f2 codedump.c: adjust output format for ireps and literals
- I(%d:%p) -> I[%d]
- L(%d) -> L[%d]

The irep address is not useful, so just print index in reps table.
And use `[]` instead of `()` to clarify they are index.
2023-02-06 11:13:48 +09:00
Yukihiro "Matz" Matsumoto 1e122f7887 mruby-catch/catch.c: add disassembled comment for catch irep 2023-02-05 22:53:11 +09:00
Yukihiro "Matz" Matsumoto acecee0da1 mruby-print/print.c: rename __printstr__ to __printstr
As a convention other internal methods are prefixed by `__`.
2023-02-04 18:58:07 +09:00
Yukihiro "Matz" Matsumoto 1273c04e26 mruby-print/print.rb: update ISO references 2023-02-04 18:57:43 +09:00
Yukihiro "Matz" Matsumoto 8c8bbd94dc error.c: add new error handling API functions; ref #2837
- mrb_clear_error(): clear error status of mrb_state
- mrb_check_error(): check if error caused in the previous API

Note that `mrb_check_error` clears error status, so if you call
`mrb_check_error` more than once, latter calls will return FALSE.
2023-02-03 14:28:24 +09:00
Yukihiro "Matz" Matsumoto f5a7b6aad2 hash.rb: defer local variable initialization 2023-02-02 22:45:30 +09:00
Yukihiro "Matz" Matsumoto 1b299addaf mruby-hash-ext/hash.rb: implement Hash#compact! in C
Using `__compact` method defined in the core, since hash access
functions are private to `src/hash.c`.
2023-02-02 22:44:04 +09:00
Yukihiro "Matz" Matsumoto 9cda737a56 mruby-hash-ext/test: test Hash#compact! returns nil if unmodified 2023-02-02 22:42:36 +09:00
Yukihiro "Matz" Matsumoto 0a1fd07910 mruby-time/time.c: implement weekday methods in C 2023-02-01 14:33:46 +09:00
Yukihiro "Matz" Matsumoto ecd2d8c11e wrap method arguments by parentheses as convention 2023-02-01 14:33:46 +09:00
Yukihiro "Matz" Matsumoto caac15e8e1 Merge pull request #5919 from jbampton/make-rake-add-target
Makefile/Rakefile add target/task for `pre-commit install`
2023-02-01 14:29:40 +09:00
Yukihiro "Matz" Matsumoto 2dcc7346b4 Merge pull request #5918 from jbampton/actions-checkout-name-info
gha: full details for `actions/checkout` name
2023-02-01 14:28:40 +09:00
John Bampton 2bb6eeb7c0 Makefile/Rakefile add target/task for pre-commit install 2023-02-01 13:14:23 +10:00
John Bampton 5532d176e1 gha: full details for actions/checkout name 2023-02-01 02:00:56 +10:00
John Bampton 7d4200df84 Remove super-linter.report folder
The `super-linter.report` folder does not seem to be listed anymore on https://github.com/github/super-linter
2023-01-31 22:46:39 +10:00
Yukihiro "Matz" Matsumoto d41ea96c2a string.c: fix boundary check in String#bytesplice
It should be able to append to the receiver.
2023-01-29 17:10:15 +09:00
Yukihiro "Matz" Matsumoto a2e2e83012 string.c: move String#bytesplice to the core 2023-01-28 16:43:40 +09:00
Yukihiro "Matz" Matsumoto 12e232c006 mruby-string-ext/string.rb: add test for String#bytesplice 2023-01-28 16:41:40 +09:00
Yukihiro "Matz" Matsumoto 52746479a3 mruby-string-ext/string.c: new method String#byteslice 2023-01-27 23:22:02 +09:00
Yukihiro "Matz" Matsumoto 7b27346386 mruby-os-memsize/memsize.c: avoid mrb_get_args() 2023-01-26 11:14:10 +09:00
Yukihiro "Matz" Matsumoto 78bbf75981 mruby-random/random.c: avoid mrb_get_args() 2023-01-26 11:13:48 +09:00
Yukihiro "Matz" Matsumoto 4e85e855cf numeric.c: avoid mrb_get_args() if possible 2023-01-25 14:10:43 +09:00
Yukihiro "Matz" Matsumoto 4e5be5a288 array.c: avoid slower mrb_get_args() if possible 2023-01-25 14:10:03 +09:00
Yukihiro "Matz" Matsumoto 37da677cc8 numeric.c (mrb_int_pow): avoid unnecessary calls to mrb_get_args() 2023-01-24 15:25:06 +09:00
Yukihiro "Matz" Matsumoto d1449c2622 array.c (mrb_ary_times): avoid multiple calls to mrb_get_args() 2023-01-24 15:23:30 +09:00
Yukihiro "Matz" Matsumoto d9bf3235d2 mruby-math/math.c: avoid mrb_get_args() if possible
When a method takes single argument, we can use lighter `mrb_get_arg1()`
instead of `mrb_get_args()`.
2023-01-24 09:15:20 +09:00
mimaki 6b82843e72 Update version to 3.2.0RC3. 2023-01-23 10:16:15 +09:00
mimaki b40ab7bfee Merge branch 'master' into stable 2023-01-23 09:54:02 +09:00
Yukihiro "Matz" Matsumoto aefc5befbd mruby-io/io.c: fix issues with gets; fix #5913
- gets with RS multiple times
- gets with RS with limit
- gets with limit bigger than buffer size
2023-01-23 07:30:40 +09:00
Yukihiro "Matz" Matsumoto be5266fbe6 mruby-io/test: test gets with RS multiple times; ref #5913 2023-01-23 07:26:40 +09:00
Yukihiro "Matz" Matsumoto 4d5aadfc84 class.c (create_method_value): refactor mrb_method_t creation 2023-01-23 00:17:32 +09:00
Yukihiro "Matz" Matsumoto 079244c36a src/class.c: add new function mrb_vm_find_method
The function skips `cp` dereference, and improve performance of method
calls slightly.
2023-01-23 00:17:32 +09:00
Yukihiro "Matz" Matsumoto 6b0efd43da NEWS: copy entries from doc/mruby3.2.md 2023-01-23 00:17:32 +09:00
Yukihiro "Matz" Matsumoto 2e9f62b12c Merge pull request #5914 from dearblue/doc/mruby3.2.md
Update mruby3.2.md for changes behavior of `mrb_vm_run()`
2023-01-22 22:49:57 +09:00
Yukihiro "Matz" Matsumoto 3c02c517ca Merge pull request #5915 from dearblue/doc/mruby3.2.md.1
Update mruby3.2.md for new `mruby-data` gem
2023-01-22 22:49:05 +09:00
dearblue 998ef1711a Update mruby3.2.md for new mruby-data gem 2023-01-22 20:52:09 +09:00
dearblue a223778ee8 Update mruby3.2.md for changes behavior of mrb_vm_run() 2023-01-22 20:45:57 +09:00
Yukihiro "Matz" Matsumoto 882bb0662a Merge pull request #5912 from dearblue/io-popen
Replaced `NO_IO_POPEN` with `MRB_NO_IO_POPEN`
2023-01-22 13:37:39 +09:00
dearblue b0e537c05c Replaced NO_IO_POPEN with MRB_NO_IO_POPEN
ref. commit 9deb52c7b2
2023-01-22 09:20:10 +09:00
Yukihiro "Matz" Matsumoto 97fe582d41 Merge pull request #5911 from dearblue/eval+binding
Fixed `Kernel#.eval` crash when given a custom defined `Binding` instance
2023-01-20 22:44:28 +09:00
dearblue 36f822d9af Fixed Kernel#.eval crash when given a custom defined Binding instance
```console
% bin/mruby -e 'class Binding; end; eval "1", Binding.new'
zsh: segmentation fault (core dumped)  bin/mruby -e 'class Binding; end; eval "1", Binding.new'
```
2023-01-20 21:26:21 +09:00
dearblue e5108a6291 Fixed local variables not separated between copied binding objects
This is because I forgot to implement the `Binding#initialize_copy` method.
2021-08-03 23:20:34 +09:00
KOBAYASHI Shuji 98d091436d Reduce memory usage of instance variable table
## Implementation Summary

* Only keys and only values of hash table are contiguous to eliminate
  structure padding.
* Change upper limit of `iv_tbl` size to `UINT16_MAX` (it seems to be
  acceptable in mruby because the total number of classes/modules
  immediately after starting Redmine is 20,000 or less).
* `iv_tbl*` point hash buckets directly.

## Benchmark Summary

Only the results of typical situations on 64-bit Word-boxing are present
here. For more detailed information, including consideration, see below
report (although most of the body is written in Japanese).

* https://shuujii.github.io/mruby-iv-benchmark

### Memory Usage

Lower value is better.

| iv_tbl Size |    Baseline    |       New      |   Factor   |
|------------:|---------------:|---------------:|-----------:|
|           4 |            88B |            52B |   0.59091x |
|          30 |           536B |           388B |   0.72388x |
|         100 |          2072B |          1540B |   0.74324x |
|         200 |          4120B |          3076B |   0.74660x |

Although not mentioned in the above report, the memory usage of `mrbtest`
(full-core gembox) is as follows in the result by Valgrind.

* Baseline: 108,086 allocs, 16,313,122 bytes allocated
* New:       94,273 allocs, 15,875,214 bytes allocated

### Performance

Higher value is better.

#### `mrb_obj_iv_set`

| iv_tbl Size |    Baseline    |       New      |   Factor   |
|------------:|---------------:|---------------:|-----------:|
|           4 |  88.63003M i/s |  92.60611M i/s |   1.04486x |
|          30 |  32.97066M i/s |  25.25095M i/s |   0.76586x |
|         100 |  16.33224M i/s |  22.74998M i/s |   1.39295x |
|         200 |   5.64484M i/s |   6.79949M i/s |   1.20455x |

#### `mrb_obj_iv_get`

| iv_tbl Size |    Baseline    |      New       |   Factor   |
|------------:|---------------:|---------------:|-----------:|
|           4 | 217.58391M i/s | 237.59912M i/s |   1.09199x |
|          30 | 139.56195M i/s | 160.49470M i/s |   1.14999x |
|         100 | 143.09716M i/s | 190.95047M i/s |   1.33441x |
|         200 |  89.75291M i/s | 134.78717M i/s |   1.50176x |

### Binary Size

Lower value is better.

|    File     |    Baseline    |      New       |   Factor   |
|:------------|---------------:|---------------:|-----------:|
| mruby       |       697,520B |       697,520B |   1.00000x |
| libmruby.a  |     1,046,570B |     1,046,682B |   0.99989x |

## Note

The address in `struct RObject::iv` may change after initialization because
`iv_tbl*` points directly to hash buckets. Therefore, the address cannot be
copied and shared when include/prepend. So, when sharing `iv_tbl`, refer to
it via the sharing source class. As a result, the following bug have also
been fixed.

* [An `iv_tbl` is not shared when a class includes or prepends an empty module](https://gist.github.com/shuujii/0ac23fa24b0c55b2c602b534d81e4a95)
2021-02-03 23:16:09 +09:00
424 changed files with 27852 additions and 25839 deletions
+14
View File
@@ -0,0 +1,14 @@
.DS_Store
.idea
.vscode
.yardoc
*.bak
*.iml
*.ipr
*.swp
*.tmp
bin
build
doc/api
doc/capi
node_modules
+6 -20
View File
@@ -8,37 +8,23 @@ root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 8
indent_style = tab
indent_size = 2
indent_style = space
insert_final_newline = true
tab_width = 8
trim_trailing_whitespace = true
[{Makefile,Makefile.*,makefile,*.mk}]
trim_trailing_whitespace = true
indent_style = tab
#max_line_length = 80
[*.{c,cc,C,cxx,cpp,h,hh,H,hxx,hpp,inc,y}]
indent_size = 2
indent_style = space
trim_trailing_whitespace = true
#[*.{c,cc,C,cxx,cpp,h,hh,H,hxx,hpp,inc,y}]
#max_line_length = 120
[{*.rb,Rakefile,rakefile,*.rake,*.gemspec,*.gembox}]
indent_size = 2
indent_style = space
trim_trailing_whitespace = true
#[{*.rb,Rakefile,rakefile,*.rake,*.gemspec,*.gembox}]
#max_line_length = 120
# limitation to US-ASCII
[*.bat]
end_of_line = crlf
indent_style = space
#max_line_length = 80
[*.{yaml,yml}]
indent_size = 2
indent_style = space
[*.md]
indent_size = 2
indent_style = space
+2
View File
@@ -4,3 +4,5 @@
61e8a540869c57ebddac53cf9d243db407d57fff
# reindent parse.y
650ffb9d8410e1ae2206890ef6e2a8643c600454
# reindent build_config/playstationportable.rb
90ab714fda6825c4e951d47d7e6ecff033dd14e3
+4
View File
@@ -0,0 +1,4 @@
* text=auto eol=lf
*.bat text eol=crlf
*.cmd text eol=crlf
*.png binary
View File
+5 -4
View File
@@ -1,9 +1,10 @@
# Basic set up
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "bundler"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
+78
View File
@@ -0,0 +1,78 @@
# https://github.com/actions/labeler
benchmark:
- any:
- changed-files:
- any-glob-to-any-file:
- benchmark/**/*
build:
- any:
- changed-files:
- any-glob-to-any-file:
- Dockerfile
- Doxyfile
- Makefile
- Rakefile
- appveyor.yml
- build_config.rb
- build_config/**/*
- docker-compose.yml
- lib/**/*
- minirake
- tasks/**/*
- .dockerignore
- .pre-commit-config.yaml
- .travis.yml
- .yardopts
core:
- any:
- changed-files:
- any-glob-to-any-file:
- include/**/*
- mrblib/**/*
- src/**/*
- test/**/*
doc:
- any:
- changed-files:
- any-glob-to-any-file:
- CONTRIBUTING.md
- LEGAL
- LICENSE
- NEWS
- README.md
- SECURITY.md
- TODO.md
- doc/**/*
- examples/**/*
github:
- any:
- changed-files:
- any-glob-to-any-file:
- .github/**/*
miscellaneous:
- any:
- changed-files:
- any-glob-to-any-file:
- .editorconfig
- .git-blame-ignore-revs
- .gitattributes
- .gitignore
- AUTHORS
- Gemfile
- Gemfile.lock
- mruby-source.gemspec
mrbgems:
- any:
- changed-files:
- any-glob-to-any-file:
- mrbgems/**/*
oss-fuzz:
- any:
- changed-files:
- any-glob-to-any-file:
- oss-fuzz/**/*
tools:
- any:
- changed-files:
- any-glob-to-any-file:
- tools/**/*
+4
View File
@@ -0,0 +1,4 @@
failure-threshold: info
ignored:
- DL3008 # https://github.com/hadolint/hadolint/wiki/DL3008
- DL3013 # https://github.com/hadolint/hadolint/wiki/DL3013
+10
View File
@@ -1,4 +1,5 @@
# https://github.com/DavidAnson/markdownlint#rules--aliases
# https://github.com/igorshubovych/markdownlint-cli
# markdownlint -c .github/linters/.markdown-lint.yml .
# MD001 heading-increment/header-increment - Heading levels should only increment by one level at a time
@@ -19,5 +20,14 @@ MD025: false
# MD026 no-trailing-punctuation - Trailing punctuation in heading
MD026: false
# MD029/ol-prefix Ordered list item prefix
MD029: false
# MD033/no-inline-html - Inline HTML
MD033: false
# MD040 fenced-code-language - Fenced code blocks should have a language specified
MD040: false
# MD041 first-line-heading/first-line-h1 - First line in a file should be a top-level heading
MD041: false
+2
View File
@@ -4,6 +4,8 @@
extends: default
rules:
comments:
min-spaces-from-content: 1
document-start: disable
line-length: disable
truthy: false
@@ -1,20 +1,16 @@
ans
ba
celler
clen
creat
delet
disabl
falsy
filetest
fo
hel
hist
ist
methid
nd
quitt
remore
ro
runn
sting
upto
strin
wronly
+10
View File
@@ -0,0 +1,10 @@
{
"ignorePatterns": [
{
"pattern": "^https://github.com/mruby/mruby/commit/"
},
{
"pattern": "^mailto:"
}
]
}
+11 -7
View File
@@ -1,3 +1,4 @@
# https://github.com/actions/runner-images#available-images
name: Build & Test
on: [push, pull_request]
@@ -15,11 +16,12 @@ jobs:
max-parallel: 8
matrix:
include:
- {os: ubuntu-24.04, cc: gcc, cxx: g++}
- {os: ubuntu-24.04, cc: clang, cxx: clang++}
- {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: macos-15, cc: clang, cxx: clang++}
- {os: macos-14, cc: clang, cxx: clang++}
- {os: windows-latest, cc: gcc, cxx: g++, altname: "mingw-gcc"}
env:
MRUBY_CONFIG: ci/gcc-clang
@@ -27,13 +29,14 @@ jobs:
CXX: ${{ matrix.cxx }}
LD: ${{ matrix.cc }}
steps:
- uses: actions/checkout@v3
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
uses: actions/checkout@v4
- 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
run: rake -m test:run:serial
Windows-VC:
runs-on: windows-2022
@@ -41,11 +44,12 @@ jobs:
env:
MRUBY_CONFIG: ci/msvc
steps:
- uses: actions/checkout@v3
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
uses: actions/checkout@v4
- name: Ruby version
run: ruby -v
- name: Build and test
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
rake -m test:build && rake test:run
rake -m test:run:serial
-53
View File
@@ -1,53 +0,0 @@
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@v3
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
# Override language selection by uncommenting this and choosing your languages
# with:
# languages: go, javascript, csharp, python, cpp, java
# 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@v2
# ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
# - run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
+41
View File
@@ -0,0 +1,41 @@
name: Coverage
on: [push, pull_request]
jobs:
coverage:
name: Coverage
runs-on: ubuntu-24.04
env:
MRUBY_CONFIG: ci/gcc-clang
CC: clang-18
CXX: clang++-18
LD: clang-18
CFLAGS: -O0 -g --coverage
CXXFLAGS: -O0 -g --coverage
LDFLAGS: --coverage
steps:
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
uses: actions/checkout@v4
- name: Ruby version
run: ruby -v
- name: Compiler version
run: ${{ env.CC }} --version
- name: Build and test
run: rake test
- name: Install gcovr
run: pip install gcovr
- name: Generate coverage report
run: |
{
echo "# Coverage report"
echo \`\`\`
gcovr --gcov-executable "llvm-cov-18 gcov" -e ".*_test.c" -e ".*/test/.*" -s --html-details -o coverage/ build
echo \`\`\`
} > "$GITHUB_STEP_SUMMARY"
- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-${{ github.sha }}
path: coverage/
retention-days: 3
+15
View File
@@ -0,0 +1,15 @@
# https://github.com/actions/labeler
name: Pull Request Labeler
on:
- pull_request_target
jobs:
triage:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v5
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
sync-labels: true
+5 -14
View File
@@ -1,3 +1,4 @@
# https://pre-commit.com/
name: Lint
on: [pull_request]
@@ -6,29 +7,19 @@ permissions:
contents: read
jobs:
misspell:
name: Check spelling with misspell
runs-on: ubuntu-latest
steps:
- name: Check Out
uses: actions/checkout@v3
- name: Install
run: wget -O - -q https://git.io/misspell | sh -s -- -b .
- name: Run misspell
run: git ls-files --empty-directory | xargs ./misspell -error
pre-commit:
name: Run pre-commit
runs-on: ubuntu-latest
steps:
- name: Check Out
uses: actions/checkout@v3
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
uses: actions/checkout@v4
- 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@v3
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> "$GITHUB_ENV"
- uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
+4 -3
View File
@@ -1,3 +1,4 @@
# https://github.com/google/oss-fuzz
name: CIFuzz
on: [pull_request]
permissions:
@@ -10,16 +11,16 @@ jobs:
- name: Build Fuzzers
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
with:
oss-fuzz-project-name: 'mruby'
oss-fuzz-project-name: "mruby"
dry-run: false
- name: Run Fuzzers
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
with:
oss-fuzz-project-name: 'mruby'
oss-fuzz-project-name: "mruby"
fuzz-seconds: 600
dry-run: false
- name: Upload Crash
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: failure()
with:
name: artifacts
+46
View File
@@ -0,0 +1,46 @@
name: Release Builds
on:
push:
tags:
- "*.*.*"
permissions: read-all
jobs:
source:
name: Source Code Releasing
if: ${{ github.repository == 'mruby/mruby' }}
permissions:
contents: write
runs-on: ubuntu-22.04
timeout-minutes: 10
strategy:
fail-fast: false
steps:
- name: "Checkout ${{ github.ref_name }} ( ${{ github.sha }} )"
uses: actions/checkout@v4
- name: Builds
id: builds
run: |
tagname="$GITHUB_REF_NAME"
packagename="mruby-$tagname"
destdir=packages
mkdir -p "$destdir"
git archive --format zip --prefix "$packagename/" -o "$destdir/$packagename.zip" "$GITHUB_REF"
git archive --format tar.gz --prefix "$packagename/" -o "$destdir/$packagename.tar.gz" "$GITHUB_REF"
gunzip -c "$destdir/$packagename.tar.gz" | xz > "$destdir/$packagename.tar.xz"
(
cd "$destdir" || exit
sha256sum -- * > .sha256
mv .sha256 "$packagename.sha256"
)
- name: Release
uses: softprops/action-gh-release@v2
with:
draft: true
prerelease: ${{ contains(github.ref_name, '-rc') }}
body_path: NEWS
files: packages/*
+8 -8
View File
@@ -1,3 +1,4 @@
# https://github.com/super-linter/super-linter
name: Super-Linter
on: [pull_request]
@@ -8,24 +9,23 @@ permissions:
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
contents: read # for actions/checkout to fetch code
statuses: write # for super-linter/super-linter/slim to mark status of each linter run
name: Lint Code Base
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
uses: actions/checkout@v4
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
uses: super-linter/super-linter/slim@v7.3.0
env:
ERROR_ON_MISSING_EXEC_BIT: true
VALIDATE_BASH: true
# VALIDATE_BASH_EXEC: true
VALIDATE_DOCKERFILE_HADOLINT: true
# VALIDATE_EDITORCONFIG: true
# VALIDATE_SHELL_SHFMT: true
DEFAULT_BRANCH: master
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VALIDATE_ALL_CODEBASE: false
VALIDATE_ALL_CODEBASE: true
+18 -15
View File
@@ -1,8 +1,8 @@
*.lock
*.bak
*.bc
*.d
*.i
*.lock
*.o
*.orig
*.pdb
@@ -13,25 +13,28 @@
*.tmp
*~
.DS_Store
.cache
.ccls*
.ccmalloc
.git
.svn
.vscode
.yardoc
.ccls*
compile_flags.txt
benchmark/**/*.dat
benchmark/*.pdf
benchmark/*.png
bin
build
doc/api
doc/capi
compile_commands.json
compile_flags.txt
cscope.files
cscope.out
gmon.out
mruby-source-*.gem
node_modules
perf.data*
tags
/.git
/bin
/build
/mruby-source-*.gem
/benchmark/**/*.dat
/benchmark/*.pdf
/benchmark/*.png
/doc/api
/doc/capi
!Gemfile.lock
y.tab.c
+76 -20
View File
@@ -1,68 +1,124 @@
---
default_stages: [commit, push]
# https://pre-commit.com/
default_stages: [pre-commit, pre-push]
default_language_version:
# force all unspecified Python hooks to run python3
python: python3
minimum_pre_commit_version: '2.18.1'
node: 22.2.0
minimum_pre_commit_version: "3.2.0"
repos:
- repo: meta
hooks:
- id: identity
name: run identity check
- id: check-hooks-apply
name: check hooks apply to the repository
- repo: local
hooks:
- id: prettier
name: run prettier
description: format files with prettier
entry: prettier --write .
files: \.(json|md|ya?ml)$
language: node
additional_dependencies: ["prettier@3.3.3"]
- repo: https://github.com/gitleaks/gitleaks
rev: v8.24.0
hooks:
- id: gitleaks
name: detect hardcoded secrets
- repo: https://github.com/shssoichiro/oxipng
rev: v9.1.4
hooks:
- id: oxipng
name: run oxipng
args: ["-o", "4", "--strip", "safe", "--alpha"]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-executables-have-shebangs
exclude: ^test/t/lang\.rb$
- id: check-illegal-windows-names
- id: pretty-format-json
args: [--autofix, --no-sort-keys]
- id: check-json
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-vcs-permalinks
- id: check-yaml
- id: destroyed-symlinks
- id: detect-aws-credentials
args: [--allow-missing-credentials]
- id: detect-private-key
- id: end-of-file-fixer
- id: file-contents-sorter
files: ^codespell\.txt$
args: [--unique]
files: ^\.github/linters/codespell\.txt$
- id: fix-byte-order-marker
- id: forbid-submodules
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.3.1
rev: v1.5.5
hooks:
- id: forbid-tabs
exclude: Makefile$|Makefile\..+$|makefile$|\.mk$
name: no-tabs checker
exclude: Makefile$
- id: remove-tabs
args: [--whitespaces-count, '2']
exclude: Makefile$|Makefile\..+$|makefile$|\.mk$
name: tabs remover
args: [--whitespaces-count, "2"]
exclude: Makefile$
- repo: https://github.com/rhysd/actionlint
rev: v1.7.7
hooks:
- id: actionlint
name: run actionlint
description: lint GitHub Actions workflow files
- repo: https://github.com/codespell-project/codespell
rev: v2.2.2
rev: v2.4.1
hooks:
- id: codespell
name: Run codespell
name: run codespell
description: Check spelling with codespell
entry: codespell --ignore-words=codespell.txt
args: [--ignore-words=.github/linters/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
name: run script-must-not-have-extension
description: local policy is to exclude extension from all shell files
types: [shell]
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.33.0
rev: v0.44.0
hooks:
- id: markdownlint
name: Run markdownlint
name: run markdownlint
description: Checks the style of Markdown files
entry: markdownlint -c .github/linters/.markdown-lint.yml .
args: [--config=.github/linters/.markdown-lint.yml]
types: [markdown]
files: \.(md|mdown|markdown)$
files: \.md$
- repo: https://github.com/tcort/markdown-link-check
rev: v3.13.7
hooks:
- id: markdown-link-check
name: run markdown-link-check
description: Checks hyperlinks in Markdown files
args: [--config=.github/linters/mlc_config.json, -q]
types: [markdown]
files: \.md$
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.10.0.1
hooks:
- id: shellcheck
name: run shellcheck
- repo: https://github.com/adrienverge/yamllint
rev: v1.28.0
rev: v1.36.0
hooks:
- id: yamllint
name: Run yamllint
name: run yamllint
description: Check YAML files with yamllint
entry: yamllint --strict -c .github/linters/.yaml-lint.yml
args: [--strict, -c=.github/linters/.yaml-lint.yml]
types: [yaml]
files: \.(yaml|yml)$
files: \.ya?ml$
+4
View File
@@ -0,0 +1,4 @@
# Ignore artifacts:
build
coverage
doc/internal/opcode.md
+3
View File
@@ -0,0 +1,3 @@
{
"bracketSpacing": false
}
+1 -1
View File
@@ -8,4 +8,4 @@ env:
- MRUBY_CONFIG=ci/gcc-clang
script:
- rake -m test:build && rake test:run
- rake -m test:run:serial
+55 -39
View File
@@ -1,90 +1,93 @@
# Authors of mruby (mruby developers)
## The List of Contributors sorted by number of commits (as of 2022-01-08 4462e3d)
## The List of Contributors sorted by number of commits (as of 2025-03-01 8ba2ed6)
8860 Yukihiro "Matz" Matsumoto (@matz)*
586 KOBAYASHI Shuji (@shuujii)
441 dearblue (@dearblue)*
378 Daniel Bovensiepen (@bovi)*
346 Takeshi Watanabe (@take-cheeze)*
334 Masaki Muranaka (@monaka)
328 Tomoyuki Sahara (@tsahara)*
6083 Yukihiro "Matz" Matsumoto (@matz)*
673 dearblue (@dearblue)*
587 KOBAYASHI Shuji (@shuujii)
353 Daniel Bovensiepen (@bovi)*
345 Takeshi Watanabe (@take-cheeze)*
333 Masaki Muranaka (@monaka)
234 Jun Hiroe (@suzukaze)
228 Tomoyuki Sahara (@tsahara)*
220 Cremno (@cremno)*
219 John Bampton (@jbampton)
209 Yuki Kurihara (@ksss)+
151 Yasuhiro Matsumoto (@mattn)*
144 Yasuhiro Matsumoto (@mattn)*
113 Carson McDonald (@carsonmcdonald)
113 John Bampton (@jbampton)
103 Tomasz Dąbrowski (@dabroz)*
84 Akira Yumiyama (@akiray03)*
84 skandhas (@skandhas)
104 Tomasz Pędraszewski (@dabroz)*
83 Akira Yumiyama (@akiray03)*
83 skandhas (@skandhas)
80 Masamitsu MURASE (@masamitsu-murase)
74 Yuichiro MASUI (@masuidrive)
73 Hiroshi Mimaki (@mimaki)*
71 Tatsuhiko Kubo (@cubicdaiya)*
65 Yuichiro Kaneko (@yui-knk)+
64 Paolo Bosetti (@pbosetti)*
71 Yuichiro MASUI (@masuidrive)
69 Hiroshi Mimaki (@mimaki)*
62 Yuichiro Kaneko (@yui-knk)+
59 Kurebayashi, Takahiro (@crimsonwoods)*
56 h2so5 (@h2so5)
52 Ralph Desir (@Mav7)*
48 Paolo Bosetti (@pbosetti)*
45 Rory O'Connell (@RoryO)*
42 fleuria (@flaneur2020)
40 Christopher Aue (@christopheraue)
40 Seba Gamboa (@sagmor)
39 Kouhei Sutou (@kou)*
38 Koji Yoshioka (@kyab)*+
38 Kouhei Sutou (@kou)*
32 Masayoshi Takahashi (@takahashim)+
31 MATSUMOTO Ryosuke (@matsumotory)*
30 Nobuyoshi Nakada (@nobu)
26 Julian Aron Prenner (@furunkel)*
24 Ryan Scott (@ryan-scott-dev)*
26 Hoshiumi Arata (@hoshiumiarata)*
25 Julian Aron Prenner (@furunkel)*
22 Clayton Smith (@clayton-shopify)
22 Uchio Kondo (@udzura)*
22 Zachary Scott (@zzak)*
22 mirichi (@mirichi)
21 Jared Breeden (@jbreeden)*
21 Ryan Lopopolo (@lopopolo)
20 Ryan Scott (@ryan-scott-dev)*
19 Bouke van der Bijl (@bouk)
19 Felix Jones (@felixjones)*
19 Hidetaka Takano (@TJ-Hidetaka-Takano)
19 Jared Breeden (@jbreeden)*
19 go kikuta (@gkta)*
18 Corey Powell (@IceDragon200)
18 Hidetaka Takano (@TJ-Hidetaka-Takano)
18 Jon Maken (@jonforums)+
18 Mitchell Blank Jr (@mitchblank)*
18 mirichi (@mirichi)
17 Mitchell Blank Jr (@mitchblank)*
16 bggd (@bggd)
16 kano4 (@kano4)
15 Felix Jones (@felixjones)*
14 Blaž Hrastnik (@archseer)*
14 Jose Narvaez (@goyox86)
14 Kazuki Tsujimoto (@k-tsj)
14 Tadashi FUKUZAWA (@FUKUZAWA-Tadashi)+
14 fn ⌃ ⌥ (@FnControlOption)
14 leviongit (@leviongit)
13 Jose Narvaez (@goyox86)
13 Patrick Hogan (@pbhogan)
12 Akira Kuroda (@akuroda)
12 Kouki Ooyatsu (kaishuu0123)*
12 NAKAMURA Usaku (@unak)*
12 RIZAL Reckordp (@Reckordp)+
12 Ray Chason (@chasonr)*
12 Takashi Sawanaka (@sdottaka)*
12 Ukrainskiy Sergey (@ukrainskiysergey)
12 Xuejie "Rafael" Xiao (@xxuejie)*
11 Julien Ammous (@schmurfy)
11 Kazuho Oku (@kazuho)
11 RIZAL Reckordp (@Reckordp)+
11 Seeker (@SeekingMeaning)
11 YAMAMOTO Masaya (pandax381)
11 takkaw (@takkaw)
10 Miura Hideki (@miura1729)
10 Narihiro Nakamura (@authorNari)
10 Ray Chason (@chasonr)*
10 YAMAMOTO Masaya (pandax381)
10 Yuichi Nishiwaki (@nyuichi)
9 Akira Mitsui (@murasesyuka)*
9 Frank Celler (@fceller)
9 Tatsuya Matsumoto (@tmash06)*
8 Takashi Sogabe (@sogabe)
8 Wataru Ashihara (@wataash)*
7 Bhargava Shastry (@bshastry)*
7 Kouichi Nakanishi (@keizo042)
7 Rubyist (@expeditiousRubyist)
7 SiZiOUS (@sizious)
7 Simon Génier (@simon-shopify)
7 Terence Lee (@hone)
7 Wataru Ashihara (@wataash)*
7 roco (@rystyle)*
6 Akito Mochizuki (@ak-mochi)
6 Beoran (@beoran)
@@ -96,6 +99,7 @@
6 Kenji Okimoto (@okkez)+
6 Selman ULUG (@selman)
6 Yusuke Endoh (@mame)*
6 masahino (@masahino)
5 Chris Reuter (@suetanvil)
5 Davide D'Agostino (@DAddYE)
5 Eric Hodel (@drbrain)
@@ -104,20 +108,22 @@
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 vickash (@vickash)
5 xuejianqing (@joans321)
4 Dante Catalfamo (@dantecatalfamo)
4 Goro Kikuchi (@gorogit)
4 HASUMI Hitoshi (@hasumikin)
4 Herwin Weststrate (@herwinw)
4 Horimoto Yasuhiro (@komainu8)
4 Jon Moss (@maclover7)
4 Ken Muramatsu (@ken-mu)+
4 Kohei Suzuki (@eagletmt)
4 Lanza (@LanzaSchneider)
4 Li Yazhou (@flaneur2020)
4 Marcus Stollsteimer (@stomar)
4 NARUSE, Yui (@nurse)
@@ -128,21 +134,22 @@
4 kurodash (@kurodash)*
4 wanabe (@wanabe)*
3 Anton Davydov (@davydovanton)
3 Aurora Nockert (@auroranockert)
3 Carlo Prelz (@asfluido)*
3 Daniel K. Sierpiński (@513ry)+
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 Delk (@jethrodaniel)
3 Mark McCurry (@fundamental)
3 Nobuhiro Iwamatsu (@iwamatsu)
3 Per Lundberg (@perlun)*
3 Rob Fors (@robfors)*
3 Robert Rowe (@CaptainJet)
3 Sebastián Katzer (@katzer)*
3 Shouji Kuboyama (@Shokuji)*
3 Shuta Kimura (@kimushu)+
3 TERAJIMA, Motoyuki (@trmmy)
3 Taichi AOKI (@aoki1980taichi)
@@ -173,7 +180,6 @@
2 Kazuhiko Yamashita (@pyama86)+
2 Kazuhiro Sera (@seratch)
2 Kuroda Daisuke (@dycoon)+
2 Lanza (@LanzaSchneider)
2 Lothar Scholz (@llothar)
2 Lukas Joeressen (@kext)
2 Masahiro Wakame (@vvkame)+
@@ -183,26 +189,30 @@
2 Russel Hunter Yukawa (@rhykw)+
2 Ryunosuke SATO (@tricknotes)
2 Santa Zhang (@santazhang)
2 Satoru Naba (@snaba)+
2 Serg Podtynnyi (@shtirlic)
2 Shannen Saez (@shancat)
2 Shouji Kuboyama (@Shokuji)*
2 SouthWolf (@southwolf)
2 TJ Singleton (@tjsingleton)
2 Taiyo Mizuhashi (@taiyoslime)+
2 Tomás Pollak (@tomas)*
2 Yutaka HARA (@yhara)*+
2 Zhang Xiaohui (@hifoolno)
2 buty4649 (@buty4649)
2 icm7216 (@icm7216)
1 A-Sat (@asatou)+
1 Abinoam Praxedes Marques Junior (@abinoam)
1 Alex Wang (@nanamiwang)+
1 AlexDenisov (@AlexDenisov)
1 Andrew Nordman (@cadwallion)
1 Ashish Kurmi (@boahc077)
1 Atsushi Morimoto (@mynz)
1 Ben A Morgan (@BenMorganIO)
1 Benoit Daloze (@eregon)
1 Colin MacKenzie IV (@sinisterchipmunk)
1 Daehyub Kim (@lateau)
1 Daniel Varga (@vargad)
1 Diamond Rivero (@diamant3)
1 Edgar Boda-Majer (@eboda)
1 Fangrui Song (@MaskRay)
1 Flavio Medeiros (@flaviommedeiros)
@@ -239,10 +249,11 @@
1 Lukas Elmer (@lukaselmer)
1 Lukas Stabe (@Ahti)
1 M.Naruoka (@fenrir-naru)
1 Mark Delk (@jethrodaniel)
1 Marcelo Juchem (@juchem)
1 Martin Bosslet (@emboss)+
1 Masahiko Sawada (@MasahikoSawada)
1 Matt Aimonetti (@mattetti)
1 Max Base (@MaxFork)
1 Maxim Abramchuk (@MaximAbramchuck)
1 Megumi Tomita (@tomykaira)+
1 Mitchell Hashimoto (@mitchellh)
@@ -254,18 +265,20 @@
1 Patrick Ellis (@pje)
1 Patrick Pokatilo (@SHyx0rmZ)
1 Pavel Evstigneev (@Paxa)+
1 Pete Kinnecom (@petekinnecom)
1 Prayag Verma (@pra85)
1 Ranmocy (@ranmocy)
1 Robert McNally (@wolfmcnally)
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 Satoru Naba (@snaba)+
1 Sayed Abdelhaleem (@visualsayed)
1 Sergey Ukrainskiy (@ukrainskiysergey)
1 Shugo Maeda (@shugo)
1 Sinkevich Artem (@ArtSin)
1 Sorah Fukumori (@sorah)
1 Stephen Jothen (@sjothen)
1 Stuart Hinson (@stuarth)
@@ -281,10 +294,12 @@
1 Yevhen Viktorov (@yevgenko)
1 Yoji SHIDARA (@darashi)
1 Yoshiori SHOJI (@yoshiori)
1 Yuji Yokoo (@yujiyokoo)
1 Yukang (@chenyukang)
1 Yurii Nakonechnyi (@inobelar)
1 Yusuke Suzuki (@Constellation)+
1 Yusuke Tanaka (@csouls)
1 alpha.netzilla (@alpha-netzilla)
1 arton (@arton)
1 duangsuse (@duangsuse)
1 fl0l0u (@fl0l0u)
@@ -294,6 +309,7 @@
1 liyuray (@liyuray)
1 lucas dicioccio (@lucasdicioccio)
1 n4o847 (@n4o847)
1 niyarin (@niyarin)
1 robert (@R-obert)
1 sbsoftware (@sbsoftware)
1 ssmallkirby (@smallkirby)
+70 -14
View File
@@ -26,8 +26,8 @@ A framework for managing and maintaining multi-language `pre-commit` hooks.
You need to first install `pre-commit` and then install the `pre-commit` hooks with `pre-commit install`.
Now `pre-commit` will run automatically on git commit!
It's usually a good idea to run the hooks against all the files when adding new hooks (usually `pre-commit` will only run on the changed files during git hooks).
Use `pre-commit run --all-files` to check all files.
It's usually a good idea to run the hooks against all the files when adding new hooks (usually `pre-commit`
will only run on the changed files during git hooks). Use `pre-commit run --all-files` to check all files.
To run a single hook use `pre-commit run --all-files <hook_id>`
@@ -37,12 +37,16 @@ Sometimes you might need to skip one or more hooks which can be done with the `S
`$ SKIP=yamllint git commit -m "foo"`
For convenience, we have added `pre-commit run --all-files` and `pre-commit autoupdate`
For convenience, we have added `pre-commit run --all-files`, `pre-commit install` and `pre-commit autoupdate`
to both the Makefile and the Rakefile. Run them with:
- `make check` or `rake check`
- `make checkinstall` or `rake checkinstall`
- `make checkupdate` or `rake checkupdate`
To configure `pre-commit` you can modify the config file [.pre-commit-config.yaml](.pre-commit-config.yaml).
We use [GitHub Actions](.github/workflows/lint.yml) to run `pre-commit` on every pull request.
### pre-commit quick links
- [Quick start](https://pre-commit.com/#quick-start)
@@ -50,21 +54,73 @@ to both the Makefile and the Rakefile. Run them with:
- [pre-commit autoupdate](https://pre-commit.com/#pre-commit-autoupdate)
- [Temporarily disabling hooks](https://pre-commit.com/#temporarily-disabling-hooks)
## Spell Checking
## Docker
We are running [misspell](https://github.com/client9/misspell) which is mainly written in
[Golang](https://golang.org/) to check spelling with [GitHub Actions](.github/workflows/lint.yml).
Correct commonly misspelled English words quickly with `misspell`. You can run `misspell` locally
against all files with:
We have both a `Dockerfile` and `docker-compose.yml` files in the repository root.
You can run these with the command line or use
[Docker Desktop](https://www.docker.com/products/docker-desktop/).
```bash
find . -type f | xargs ./misspell -error
The Docker image is running Debian bullseye with Ruby and Python installed.
You can build the Docker image with:
`$ docker-compose build test`
So far we just have one service: `test`. Running the default `docker-compose`
command will create the Docker image, spin up a container and then build and
run all mruby tests.
The default `docker-compose` command is:
`$ docker-compose -p mruby run test`
You can also use Make or Rake to run the default `docker-compose`
command from above:
- `make composetest`
- `rake composetest`
List your Docker images with:
```console
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mruby-test latest ec60f9536948 29 seconds ago 1.29GB
```
Notable `misspell` help options or flags are:
You can also run any custom `docker-compose` command which will override
the default. For example to run `pre-commit run --all-files` type:
- `-i` string: ignore the following corrections, comma separated
- `-w`: Overwrite file with corrections (default is just to display)
`$ docker-compose -p mruby run test pre-commit run --all-files`
For convenience, you can also run `pre-commit` with:
- `make composecheck`
- `rake composecheck`
The bonus of running `pre-commit` with `docker-compose` is that you won't need
to install `pre-commit` and the hooks on your local machine. And that also
means you won't need to install `brew`, `conda` or `pip`.
Note limitation: currently running `pre-commit` with `docker-compose` we
skip the `check-executables-have-shebangs` hook.
Two more examples of custom `docker-compose` commands are:
- `$ docker-compose -p mruby run test ls`
- `$ docker-compose -p mruby run test rake doc:api`
If you want to test using a different `docker-compose` YAML config file you
can use the `-f` flag:
`$ docker-compose -p mruby -f docker-compose.test.yml run test`
- <https://docs.docker.com/compose/>
- <https://docs.docker.com/engine/reference/commandline/cli/>
## Spell Checking
We are using `pre-commit` to run [codespell](https://github.com/codespell-project/codespell)
to check code for common misspellings. We have a small custom dictionary file [codespell.txt](.github/linters/codespell.txt).
## Coding conventions
@@ -120,7 +176,7 @@ unless there's a clear reason, e.g. the latest Ruby has changed behavior from IS
### 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-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
+13
View File
@@ -0,0 +1,13 @@
FROM ruby:3.2.2-bullseye
RUN apt-get update && apt-get install --no-install-recommends -y python3-pip shellcheck \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY Gemfile Gemfile.lock .pre-commit-config.yaml ./
RUN bundle install && pip3 install --no-cache-dir pre-commit && git init . && pre-commit install-hooks
COPY . .
+653 -320
View File
File diff suppressed because it is too large Load Diff
+8
View File
@@ -0,0 +1,8 @@
# frozen_string_literal: true
source 'https://rubygems.org'
gem 'rake'
gem 'yard'
gem 'yard-coderay'
gem 'yard-mruby'
+25
View File
@@ -0,0 +1,25 @@
GEM
remote: https://rubygems.org/
specs:
coderay (1.1.3)
rake (13.2.1)
yard (0.9.37)
yard-coderay (0.1.0)
coderay
yard
yard-mruby (0.3.0)
yard (~> 0.9.0)
PLATFORMS
ruby
x86_64-darwin-21
x86_64-linux
DEPENDENCIES
rake
yard
yard-coderay
yard-mruby
BUNDLED WITH
2.4.10
+28 -6
View File
@@ -4,17 +4,39 @@ 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/string.c (memsearch_swar): 2 clause BSD license code by Wojciech Muła (@WojciechMula)
- 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]
[src/string.c]
The implementation of mrb_memsearch_ss() is taken from
https://github.com/WojciechMula/sse4-strstr.git
strtod implementation.
author: Yasuhiro Matsumoto (@mattn)
license: public domain
Copyright (c) 2008-2016, Wojciech Muła
All rights reserved.
The original code can be found in https://github.com/mattn/strtod
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
[src/fmt_fp.c]
+1 -1
View File
@@ -1,4 +1,4 @@
Copyright (c) 2010-2022 mruby developers
Copyright (c) 2010- mruby developers
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
+40 -7
View File
@@ -1,23 +1,56 @@
# mruby is using Rake (https://ruby.github.io/rake/) as a build tool.
RAKE = rake
DOCKER_COMPOSE = docker-compose
PRE_COMMIT = pre-commit
all :
define check_command
@command -v $(1) >/dev/null 2>&1 || { \
echo "Error: $(1) is not installed or not in PATH."; \
exit 1; \
}
endef
all : check_rake
$(RAKE)
.PHONY : all
test : all
test : check_rake all
$(RAKE) test
.PHONY : test
clean :
clean : check_rake
$(RAKE) clean
.PHONY : clean
check :
pre-commit run --all-files
check : check_pre_commit
$(PRE_COMMIT) run --all-files
.PHONY : check
checkupdate :
pre-commit autoupdate
checkinstall : check_pre_commit
$(PRE_COMMIT) install
.PHONY : checkinstall
checkupdate : check_pre_commit
$(PRE_COMMIT) autoupdate
.PHONY : checkupdate
composecheck : check_docker_compose check_pre_commit
$(DOCKER_COMPOSE) -p mruby run test $(PRE_COMMIT) run --all-files
.PHONY : composecheck
composetest : check_docker_compose
$(DOCKER_COMPOSE) -p mruby run test
.PHONY : composetest
check_rake:
$(call check_command, $(RAKE))
.PHONY : check_rake
check_docker_compose:
$(call check_command, $(DOCKER_COMPOSE))
.PHONY : check_docker_compose
check_pre_commit:
$(call check_command, $(PRE_COMMIT))
.PHONY : check_pre_commit
+183 -6
View File
@@ -1,12 +1,189 @@
NEWS
----
This document is a list of user visible feature changes made between
releases except for bug fixes.
# User visible changes in `mruby3.3` from `mruby3.2`
Note that each entry is kept so brief that no reason behind or
reference information is supplied with. For a full list of changes
with all sufficient information, see the ChangeLog file.
"**_NOTE_**:" are changes to be aware of.
# The language
** Information about first release v1.0.0
- aliases work properly with `super` ([2ad3f0e](https://github.com/mruby/mruby/commit/2ad3f0e))
- `callee` method work differently with aliases in mruby ([f2dc76e](https://github.com/mruby/mruby/commit/f2dc76e))
- define `Kernel#respond_to_missing?` method ([347586e](https://github.com/mruby/mruby/commit/347586e))
- `_inspect` method (`inspect` with recursive check) is removed
([e2bbf75](https://github.com/mruby/mruby/commit/e2bbf75), [5cb0c74](https://github.com/mruby/mruby/commit/5cb0c74), [113565a](https://github.com/mruby/mruby/commit/113565a),
[0713f2a](https://github.com/mruby/mruby/commit/0713f2a), [6ae6b63](https://github.com/mruby/mruby/commit/6ae6b63), [fc9fffc](https://github.com/mruby/mruby/commit/fc9fffc))
- `__printstr__` method is removed; use `print` instead
([acecee0](https://github.com/mruby/mruby/commit/acecee0), [192e6e3](https://github.com/mruby/mruby/commit/192e6e3))
- New method `String#bytesplice` ([5274647](https://github.com/mruby/mruby/commit/5274647), [a2e2e83](https://github.com/mruby/mruby/commit/a2e2e83))
- Allow `return` in blocks to cross C boundaries ([#6125](https://github.com/mruby/mruby/pull/6125))
# Configuration
- mruby can be built using Docker now. Try `docker-compose build` for example. ([#5961](https://github.com/mruby/mruby/pull/5961))
- New Platform: DJGPP (MS-DOS) ([#6022](https://github.com/mruby/mruby/pull/6022))
- New Platform: Nintendo Wii ([#6086](https://github.com/mruby/mruby/pull/6086))
- Improved Platform: Android ([#6013](https://github.com/mruby/mruby/pull/6013))
- Improved Platform: Dreamcast ([#6130](https://github.com/mruby/mruby/pull/6130))
- Allow tests to be disabled for specific gems; warn about disabled tests ([#6012](https://github.com/mruby/mruby/pull/6012))
- Replace `MRB_NO_DIRECT_THREADING` with `MRB_USE_VM_SWITCH_DISPATCH` ([#5902](https://github.com/mruby/mruby/pull/5902))
# mruby memory API
- `mrb_default_allocf` can be overridden by the application ([34c5d96](https://github.com/mruby/mruby/commit/34c5d96))
- `mrb_open_allocf` will be deprecated ([cfee5c2](https://github.com/mruby/mruby/commit/cfee5c2))
# Changes in C API
- add new error handling API functions ([8c8bbd9](https://github.com/mruby/mruby/commit/8c8bbd9))
- Add `mrb_vm_ci_env_clear()` function with `MRB_API` ([#5945](https://github.com/mruby/mruby/pull/5945))
- a new function `mrb_check_frozen_value()` ([ccdf75c](https://github.com/mruby/mruby/commit/ccdf75c))
- avoid formatting in `mrb_bug()` ([82a48bd](https://github.com/mruby/mruby/commit/82a48bd)) <br>
**_NOTE_**: If you are using it, you must give a simple string or replace it with a call to `mrb_raise()` series.
- stop using `mrbc_` prefix for compiler context ([c5e3cbe](https://github.com/mruby/mruby/commit/c5e3cbe)) <br>
The same names are provided as before, but we recommend replacing them.
- Allow `Class#allocate` to be prohibited
([#5979](https://github.com/mruby/mruby/pull/5979), [#6122](https://github.com/mruby/mruby/pull/6122), [#6123](https://github.com/mruby/mruby/pull/6123)) <br>
To disable `#allocate`, use `MRB_UNDEF_ALLOCATOR()`.
This is also automatically applied when the subclass is created, but to explicitly allow it, use `MRB_DEFINE_ALLOCATOR()`.
# Changes in mrbgems
- **default.gembox**: Add mruby debugger mrdb (`mruby-bin-debugger`) ([#5966](https://github.com/mruby/mruby/pull/5966))
- **mruby-bin-config**: new options `--cxx`, `--cxxflags`, `--as`, `--asflags`, `--objc`, `--objcflags` ([#6054](https://github.com/mruby/mruby/pull/6054))
- **mruby-binding**: renamed from `mruby-binding-core` of mruby3.2 ([11af5db](https://github.com/mruby/mruby/commit/11af5db)) <br>
**_NOTE_**: If using `mruby-binding-core` of mruby 3.2, replace it with `mruby-binding`.
- **mruby-binding**: implemented `Binding#initialize_copy` method ([#5517](https://github.com/mruby/mruby/pull/5517))
- **mruby-binding**: `Kernel#binding` responds only to calls from Ruby ([#5981](https://github.com/mruby/mruby/pull/5981))
- **mruby-compar-ext**: Comparable#clamp to accept nil as arguments ([836bebc](https://github.com/mruby/mruby/commit/836bebc))
- **mruby-compiler**: add print name for identifier tokens ([d7b2e3a](https://github.com/mruby/mruby/commit/d7b2e3a))
- **mruby-data**: allow empty Data ([927a9df](https://github.com/mruby/mruby/commit/927a9df))
- **mruby-enumerator**: remove internal attribute methods `obj`, `args`, `kwd`, `meth`, `fib`. ([735fa24](https://github.com/mruby/mruby/commit/735fa24))
- **mruby-enumerator**: add Enumerator#size ([861f8bd](https://github.com/mruby/mruby/commit/861f8bd))
- **mruby-eval**: merged `mruby-binding` of mruby3.2 ([501b22a](https://github.com/mruby/mruby/commit/501b22a), [#5989](https://github.com/mruby/mruby/pull/5989)) <br>
**_NOTE_**: If using `mruby-binding` of mruby 3.2, replace it with `mruby-eval`.
- **mruby-fiber**: Add a new `mrb_fiber_new()` with `MRB_API` ([#6097](https://github.com/mruby/mruby/pull/6097))
- **mruby-fiber**: Allows calling `Fiber#resume` from C ([#6106](https://github.com/mruby/mruby/pull/6106))
- **mruby-fiber**: `Fiber#to_s` format changed ([#6105](https://github.com/mruby/mruby/pull/6105))
- **mruby-io**: add File#atime and File#ctime ([321cfe9](https://github.com/mruby/mruby/commit/321cfe9))
- **mruby-io**: Add "x" mode option for `IO.open` ([#6081](https://github.com/mruby/mruby/pull/6081))
- **mruby-io**: File.new should not take blocks ([53de964](https://github.com/mruby/mruby/commit/53de964))
- **mruby-method**: `Method#to_s` format changed ([f5bc82f](https://github.com/mruby/mruby/commit/f5bc82f), [02f189c](https://github.com/mruby/mruby/commit/02f189c))
- **mruby-numeric-ext**: `int.pow(n,m)` to take bigint as exponential ([d482eab](https://github.com/mruby/mruby/commit/d482eab))
- **mruby-pack**: support new directives `j`, `J`, `b`, `B`, `#`
([2a1e3a5](https://github.com/mruby/mruby/commit/2a1e3a5), [e7021f1](https://github.com/mruby/mruby/commit/e7021f1), [e17f325](https://github.com/mruby/mruby/commit/e17f325))
- **mruby-range-ext**: new method `Range#overlap?` ([384d0e2](https://github.com/mruby/mruby/commit/384d0e2))
- **mruby-string-ext**: Add `String#valid_encoding?` method ([eabe2d9](https://github.com/mruby/mruby/commit/eabe2d9))
- **mruby-struct**: allow empty Struct when a name is not given ([c212ede](https://github.com/mruby/mruby/commit/c212ede))
- **mruby-time**: should allow year before 1900 ([e5de08b](https://github.com/mruby/mruby/commit/e5de08b))
- **mruby-time**: support bigint to time_t if necessary ([7096d27](https://github.com/mruby/mruby/commit/7096d27))
- **mruby-time**: need to handle negative time_t ([b064d7e](https://github.com/mruby/mruby/commit/b064d7e))
# Changes in build system
- Extended `rake install` task ([#5928](https://github.com/mruby/mruby/pull/5928)) <br>
**_NOTE_**: Due to this impact, executable files in the `mruby/bin/` directory by default are now symbolic links (batch files on Windows).
If previously relied on those executables, should be replaced with direct references to the entity created under the build directory (e.g. `mruby/build/host/bin/`).
- Encode and decode escape characters for presym ([#6011](https://github.com/mruby/mruby/pull/6011))
- Rakefile: remove default build target directories in `deep_clean` ([#6032](https://github.com/mruby/mruby/pull/6032), [1e38569](https://github.com/mruby/mruby/commit/1e38569))
# Other breaking changes
- `mrb_f_raise()` is now an internal function
([#5923](https://github.com/mruby/mruby/pull/5923), [#6070](https://github.com/mruby/mruby/pull/6070))
- `mrb_make_exception()` is now an internal function with different parameters
([431f83e](https://github.com/mruby/mruby/commit/431f83e), [78137f3](https://github.com/mruby/mruby/commit/78137f3))
- The `File#path` method no longer uses the `#to_path` method for implicit conversion
([d86c4a7](https://github.com/mruby/mruby/commit/d86c4a7))
- stop mrb isolation for each test file ([a20fbe5](https://github.com/mruby/mruby/commit/a20fbe5))
- RBreak remembers the CI location ([#6103](https://github.com/mruby/mruby/pull/6103))
# Bugs Fixed
- [#5724](https://github.com/mruby/mruby/issues/5724) Rational#\*\* is missing
- [#5725](https://github.com/mruby/mruby/issues/5725) weird const_missing exceptions in mrblib code
- [#5789](https://github.com/mruby/mruby/issues/5789) No memory release of backtrace information due to stack error
- [#5932](https://github.com/mruby/mruby/issues/5932) How to create a block using the C API? mrb_yield keeps crashing!
- [#5943](https://github.com/mruby/mruby/issues/5943) TCPSocket#write is failed
- [#5944](https://github.com/mruby/mruby/issues/5944) Behavior of calling method with a hash variable
- [#5946](https://github.com/mruby/mruby/pull/5946) Don't switch constant search path from modules to Object
- [#5949](https://github.com/mruby/mruby/issues/5949) Caller appears to report wrong line when block passed and brackets omitted
- [0906cd7](https://github.com/mruby/mruby/commit/0906cd7) numeric.c: fix rounding function issues with big numbers
- [#5974](https://github.com/mruby/mruby/issues/5974) Invalid escape sequences in gem_init.c on windows
- [#5975](https://github.com/mruby/mruby/issues/5975) Equals comparison fails on extreme ends of 64-bit integers
- [#5985](https://github.com/mruby/mruby/issues/5985) Sign extension with OP_LOADI32 in get_int_operand()
- [#5986](https://github.com/mruby/mruby/issues/5986) Fix bugs in String#bytesplice
- [#5987](https://github.com/mruby/mruby/issues/5987) ~(-1 << 64) is incorrect
- [#5991](https://github.com/mruby/mruby/issues/5991) 'gets' method not working in mruby-3.2.0
- [#5994](https://github.com/mruby/mruby/pull/5994) fix typo in mrbgems/mruby-io/src/io.c
- [#5995](https://github.com/mruby/mruby/issues/5995) One seemingly unnecessary parameter is passed in the block parameters
- [#6008](https://github.com/mruby/mruby/pull/6008) Make "bintest" independent of directory
- [b47c8b7](https://github.com/mruby/mruby/commit/b47c8b7) gc.c (clear_all_old): fix a generational GC bug
- [#6029](https://github.com/mruby/mruby/issues/6029) mruby build fails under mrbgems directory
- [a264965](https://github.com/mruby/mruby/commit/a264965) mruby-os-memsize/memsize.c: fix irep size calculation
- [3310e10](https://github.com/mruby/mruby/commit/3310e10) mruby-test/mrbgem.rake: fix mrb_state handling bug
- [#6041](https://github.com/mruby/mruby/issues/6041) GC Performance may have degraded
- [#6044](https://github.com/mruby/mruby/issues/6044) Generated presym/table.h contains invalid characters
- [#6051](https://github.com/mruby/mruby/issues/6051) Null pointer dereference in mrb_addrinfo_unix_path
- [#6052](https://github.com/mruby/mruby/issues/6052) Null pointer dereference while handling the Proc class
- [#6055](https://github.com/mruby/mruby/pull/6055) Fix libmruby name for VisualC++
- [#6060](https://github.com/mruby/mruby/issues/6060) SEGFAULT Issue Related to Fiber Usage in ngx_mruby Development
- [#6061](https://github.com/mruby/mruby/issues/6061) Performance issue in String#codepoints
- [#6064](https://github.com/mruby/mruby/issues/6064) MRUBY_PACKAGE_DIR does not always have a value.
- [#6065](https://github.com/mruby/mruby/issues/6065) Null pointer dereference while handling the Proc class
- [#6066](https://github.com/mruby/mruby/issues/6066) Null pointer dereference involving Struct.new()
- [#6067](https://github.com/mruby/mruby/issues/6067) Null pointer dereference in mrb_string_value_cstr
- [#6068](https://github.com/mruby/mruby/issues/6068) Stack overflow in mrb_vm_exec
- [#6076](https://github.com/mruby/mruby/pull/6076) Fixed unwinding block that could point to invalid PC
- [#6084](https://github.com/mruby/mruby/issues/6084) Incorrect symbolic sinks in binary built on Linux
- [#6087](https://github.com/mruby/mruby/issues/6087) 'Remote branch HEAD not found in upstream origin' error on build
- [#6089](https://github.com/mruby/mruby/issues/6089) binding.eval() handles def expressions differently from CRuby
- [#6098](https://github.com/mruby/mruby/issues/6098) Fails to call superclass of wrapped method
- [#6099](https://github.com/mruby/mruby/issues/6099) `ensure` section is not executed if the function exits via a return in a proc
- [#6108](https://github.com/mruby/mruby/issues/6108) VM crashes with break
- [#6118](https://github.com/mruby/mruby/pull/6118) Fixed IO#read with buf
- [#6120](https://github.com/mruby/mruby/pull/6120) Set EBADF if check_file_descriptor() fails
- [#6126](https://github.com/mruby/mruby/pull/6126) Fixed return value of `OP_RETURN_BLK` called directly under C function
- [#6134](https://github.com/mruby/mruby/issues/6134) String#unpack1 returns an array instead of a single string
- [#6136](https://github.com/mruby/mruby/pull/6136) Fixed when combined `mrb_fiber_resume()` and `Fiber#transfer`
# Pull Requests (User Visible Ones)
- [#5517](https://github.com/mruby/mruby/pull/5517) Fixed local variables not separated between copied binding objects
- [#5902](https://github.com/mruby/mruby/pull/5902) Replace `MRB_NO_DIRECT_THREADING` with `MRB_USE_VM_SWITCH_DISPATCH`
- [#5923](https://github.com/mruby/mruby/pull/5923) Demotion `mrb_f_raise()` from `MRB_API`
- [#5928](https://github.com/mruby/mruby/pull/5928) Improved `rake install`
- [#5945](https://github.com/mruby/mruby/pull/5945) Avoid exposure for `REnv` objects
- [#5946](https://github.com/mruby/mruby/pull/5946) Don't switch constant search path from modules to Object
- [#5966](https://github.com/mruby/mruby/pull/5966) Update default.gembox add mruby debugger mrdb
- [#5979](https://github.com/mruby/mruby/pull/5979) Allow Class#allocate to be prohibited
- [#5981](https://github.com/mruby/mruby/pull/5981) `Kernel#binding` responds only to calls from Ruby
- [#5989](https://github.com/mruby/mruby/pull/5989) Integrate mruby-binding-eval into mruby-eval
- [#5961](https://github.com/mruby/mruby/pull/5961) Add Docker to build and run all mruby tests. Run pre-commit and generate YARD docs with Docker
- [#5994](https://github.com/mruby/mruby/pull/5994) fix typo in mrbgems/mruby-io/src/io.c
- [#6008](https://github.com/mruby/mruby/pull/6008) Make "bintest" independent of directory
- [#6009](https://github.com/mruby/mruby/pull/6009) Avoid adding <MRUBY_ROOT>/bintest which does not exist
- [#6011](https://github.com/mruby/mruby/pull/6011) Encode and decode escape characters for presym
- [#6012](https://github.com/mruby/mruby/pull/6012) Allow tests to be disabled for specific gems; warn about disabled tests
- [#6013](https://github.com/mruby/mruby/pull/6013) Fix Android toolchain
- [#6022](https://github.com/mruby/mruby/pull/6022) Build configuration for MS-DOS and DJGPP
- [#6032](https://github.com/mruby/mruby/pull/6032) Rake: update task clean to remove bin and build folders
- [#6045](https://github.com/mruby/mruby/pull/6045) Fixes escape sequence bug and enhancements in Presym scanning
- [#6054](https://github.com/mruby/mruby/pull/6054) Extends `bin/mruby-config`
- [#6055](https://github.com/mruby/mruby/pull/6055) Fix libmruby name for VisualC++
- [#6070](https://github.com/mruby/mruby/pull/6070) Demotion mrb_f_raise() in kernel.c from MRB_API too
- [#6076](https://github.com/mruby/mruby/pull/6076) Fixed unwinding block that could point to invalid PC
- [#6081](https://github.com/mruby/mruby/pull/6081) Add "x" mode option for IO.open
- [#6086](https://github.com/mruby/mruby/pull/6086) Add build config for Nintendo Wii
- [#6097](https://github.com/mruby/mruby/pull/6097) Add a new mrb_fiber_new() with MRB_API
- [#6103](https://github.com/mruby/mruby/pull/6103) RBreak remembers the CI location
- [#6105](https://github.com/mruby/mruby/pull/6105) Implement `Fiber#to_s` method
- [#6106](https://github.com/mruby/mruby/pull/6106) Ease fiber limitations
- [#6118](https://github.com/mruby/mruby/pull/6118) Fixed IO#read with buf
- [#6120](https://github.com/mruby/mruby/pull/6120) Set EBADF if check_file_descriptor() fails
- [#6122](https://github.com/mruby/mruby/pull/6122) Prohibit `Class#allocate` in a different way
- [#6123](https://github.com/mruby/mruby/pull/6123) Inherit `MRB_FL_UNDEF_ALLOCATE` in subclasses
- [#6125](https://github.com/mruby/mruby/pull/6125) Allow `OP_RETURN_BLK` to cross C boundaries
- [#6126](https://github.com/mruby/mruby/pull/6126) Fixed return value of `OP_RETURN_BLK` called directly under C function
- [#6130](https://github.com/mruby/mruby/pull/6130) `dreamcast_shelf build config`: complete overhaul
- [#6136](https://github.com/mruby/mruby/pull/6136) Fixed when combined `mrb_fiber_resume()` and `Fiber#transfer`
+62 -27
View File
@@ -1,6 +1,16 @@
# mruby
[![GitHub Super-Linter](https://github.com/mruby/mruby/workflows/Lint%20Code%20Base/badge.svg)](https://github.com/marketplace/actions/super-linter)
<div align="center">
<p>
<a href="https://mruby.org/">
<img src="https://avatars.githubusercontent.com/u/1796512?s=200&v=4"
alt="The mruby programming language" title="mruby">
</a>
</p>
<h1>mruby</h1>
<a href="https://github.com/marketplace/actions/super-linter">
<img src="https://github.com/mruby/mruby/actions/workflows/super-linter.yml/badge.svg"
alt="GitHub Super-Linter">
</a>
</div>
## What is mruby
@@ -8,34 +18,36 @@ mruby is the lightweight implementation of the Ruby language complying to (part
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
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
also able to generate compiled byte code in a C source file, see the "mrbtest"
program under the "test" directory for an example.
You can link and embed mruby within your application. The "mruby" interpreter
program and the interactive "mirb" shell are provided as examples. You can also
compile Ruby programs into compiled byte code using the "mrbc" compiler. All
these tools are located in the "bin" directory. "mrbc" can also generate
compiled byte code in a C source file. See the "mrbtest" program under the
"test" directory for an example.
This achievement was sponsored by the Regional Innovation Creation R&D Programs
of the Ministry of Economy, Trade and Industry of Japan.
## How to get mruby
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)
To get mruby, you can download the stable version 3.3.0 from the official mruby
GitHub repository or clone the trunk of the mruby source tree with the "git
clone" command. You can also install and compile mruby using [ruby-install](https://github.com/postmodern/ruby-install), [ruby-build](https://github.com/rbenv/ruby-build) or [rvm](https://github.com/rvm/rvm).
The release candidate version 3.4.0 of mruby can be downloaded via the following URL: [https://github.com/mruby/mruby/archive/3.4.0-rc2.zip](https://github.com/mruby/mruby/archive/3.4.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)
The trunk of the mruby source tree can be checked out with the
following command:
```
```console
$ git clone https://github.com/mruby/mruby.git
```
You can also install and compile mruby using [ruby-install](https://github.com/postmodern/ruby-install), [ruby-build](https://github.com/rbenv/ruby-build) or [rvm](https://github.com/rvm/rvm).
## mruby homepage
## mruby home-page
The URL of the mruby home-page is: <https://mruby.org>.
The URL of the mruby homepage is: <https://mruby.org>.
## Mailing list
@@ -45,7 +57,7 @@ We don't have a mailing list, but you can use [GitHub issues](https://github.com
For the simplest case, type
```
```console
rake all test
```
@@ -53,27 +65,51 @@ 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 and Graphviz)
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
```
```console
rake doc
```
You can also view them in your browser
```
```console
rake view_api
rake view_capi
```
## How to customize mruby (mrbgems)
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/](examples/mrbgems).
mruby contains a package manager called "mrbgems" that you can use to create
extensions in C and/or Ruby. For a guide on how to use mrbgems, consult the
[mrbgems.md](doc/guides/mrbgems.md) file, and for example code, refer to the
[examples/mrbgems/](examples/mrbgems) folder.
## Index of Document
<!--
This section is generated by `rake doc:update-index`.
All manual changes will get lost.
-->
<!-- BEGIN OF MRUBY DOCUMENT INDEX -->
- [About the Limitations of mruby](doc/limitations.md)
- [About the Compile](doc/guides/compile.md)
- [About the Debugger with the `mrdb` Command](doc/guides/debugger.md)
- [About GC Arena](doc/guides/gc-arena-howto.md)
- [About the mruby directory structure](doc/guides/hier.md)
- [About Linking with `libmruby`](doc/guides/link.md)
- [About Memory Allocator Customization](doc/guides/memory.md)
- [About Build-time Configurations](doc/guides/mrbconf.md)
- [About the Build-time Library Manager](doc/guides/mrbgems.md)
- [About the Symbols](doc/guides/symbol.md)
- [Internal Implementation / About Value Boxing](doc/internal/boxing.md)
- [Internal Implementation / About mruby Virtual Machine Instructions](doc/internal/opcode.md)
<!-- END OF MRUBY DOCUMENT INDEX -->
## License
@@ -98,9 +134,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
non-exclusive right to your contributed code under MIT license.
To contribute to mruby, please refer to the [contribution guidelines][contribution-guidelines] and send a pull request to the [mruby GitHub repository](https://github.com/mruby/mruby).
By contributing, you grant non-exclusive rights to your code under the MIT License.
[ISO-standard]: https://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=59579
[contribution-guidelines]: https://github.com/mruby/mruby/blob/master/CONTRIBUTING.md
[contribution-guidelines]: CONTRIBUTING.md
+20 -30
View File
@@ -31,6 +31,7 @@ load "#{MRUBY_ROOT}/tasks/presym.rake"
load "#{MRUBY_ROOT}/tasks/test.rake"
load "#{MRUBY_ROOT}/tasks/benchmark.rake"
load "#{MRUBY_ROOT}/tasks/doc.rake"
load "#{MRUBY_ROOT}/tasks/install.rake"
##############################
# generic build targets, rules
@@ -56,7 +57,7 @@ task :clean do
rm_rf build.build_dir
rm_f build.products
end
puts "Cleaned up target build folder"
puts "Cleaned up target build directory"
end
desc "clean everything!"
@@ -64,35 +65,9 @@ task :deep_clean => %w[clean doc:clean] do
MRuby.each_target do |build|
rm_rf build.gem_clone_dir
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
rm_rf "#{MRUBY_ROOT}/bin"
rm_rf "#{MRUBY_ROOT}/build"
puts "Cleaned up mrbgems build directory"
end
desc "run all pre-commit hooks against all files"
@@ -100,7 +75,22 @@ task :check do
sh "pre-commit run --all-files"
end
desc "install the pre-commit hooks"
task :checkinstall do
sh "pre-commit install"
end
desc "check the pre-commit hooks for updates"
task :checkupdate do
sh "pre-commit autoupdate"
end
desc "run all pre-commit hooks against all files with docker-compose"
task :composecheck do
sh "docker-compose -p mruby run test pre-commit run --all-files"
end
desc "build and run all mruby tests with docker-compose"
task :composetest do
sh "docker-compose -p mruby run test"
end
+1 -1
View File
@@ -11,7 +11,7 @@ We consider the following issues as vulnerabilities:
- Remote code execution
- Crash caused by a valid Ruby script
We *don't* consider the 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
+12 -10
View File
@@ -4,42 +4,44 @@ shallow_clone: true
environment:
matrix:
- job_name: Visual Studio 2019 64bit
- job_name: Visual Studio 2022 64-bit
visualcpp: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat
appveyor_build_worker_image: Visual Studio 2022
- job_name: Visual Studio 2019 64-bit
visualcpp: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat
appveyor_build_worker_image: Visual Studio 2019
- job_name: Visual Studio 2019 32bit
- job_name: Visual Studio 2019 32-bit
visualcpp: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars32.bat
appveyor_build_worker_image: Visual Studio 2019
- job_name: Visual Studio 2017 64bit
- job_name: Visual Studio 2017 64-bit
visualcpp: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat
appveyor_build_worker_image: Visual Studio 2017
- job_name: Visual Studio 2017 32bit
- job_name: Visual Studio 2017 32-bit
visualcpp: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars32.bat
appveyor_build_worker_image: Visual Studio 2017
- job_name: Visual Studio 2015 64bit
- job_name: Visual Studio 2015 64-bit
visualcpp: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat
appveyor_build_worker_image: Visual Studio 2015
machine: x86_amd64
- job_name: Visual Studio 2015 32bit
- job_name: Visual Studio 2015 32-bit
visualcpp: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat
appveyor_build_worker_image: Visual Studio 2015
machine: x86
init:
- call "%visualcpp%" %machine%
# For using RubyInstaller's Ruby 2.6 64bit
# For using RubyInstaller's Ruby 2.6 64-bit
# 2.6 is the highest supported Ruby version across all historical
# Visual Studio AppVeyor images. Ruby 2.7 is only on the 2019 image.
- set PATH=C:\Ruby26-x64\bin;%PATH%
- ruby --version
build_script:
- set MRUBY_CONFIG=ci/msvc
- rake -m test:build
- rake test:run
- rake -m test:run:serial
+4 -3
View File
@@ -253,6 +253,7 @@ class Scene
def render(w, h, nsubsamples)
nsf = nsubsamples.to_f
nsfs = nsf * nsf
h.times do |y|
w.times do |x|
rad = Vec.new(0.0, 0.0, 0.0)
@@ -288,9 +289,9 @@ class Scene
end
end
r = rad.x / (nsf * nsf)
g = rad.y / (nsf * nsf)
b = rad.z / (nsf * nsf)
r = rad.x / nsfs
g = rad.y / nsfs
b = rad.z / nsfs
printf("%c", clamp(r))
printf("%c", clamp(g))
printf("%c", clamp(b))
+57
View File
@@ -0,0 +1,57 @@
# The Computer Language Benchmarks Game
# http://shootout.alioth.debian.org/
#
# contributed by Karl von Laudermann
# modified by Jeremy Echols
size = 600 # ARGV[0].to_i
puts "P4\n#{size} #{size}"
ITER = 49 # Iterations - 1 for easy for..in looping
LIMIT_SQUARED = 4.0 # Presquared limit
byte_acc = 0
bit_num = 0
count_size = size - 1 # Precomputed size for easy for..in looping
# For..in loops are faster than .upto, .downto, .times, etc.
for y in 0..count_size
for x in 0..count_size
zr = 0.0
zi = 0.0
cr = (2.0*x/size)-1.5
ci = (2.0*y/size)-1.0
escape = false
# To make use of the for..in code, we use a dummy variable,
# like one would in C
for dummy in 0..ITER
tr = zr*zr - zi*zi + cr
ti = 2*zr*zi + ci
zr, zi = tr, ti
if (zr*zr+zi*zi) > LIMIT_SQUARED
escape = true
break
end
end
byte_acc = (byte_acc << 1) | (escape ? 0b0 : 0b1)
bit_num += 1
# Code is very similar for these cases, but using separate blocks
# ensures we skip the shifting when it's unnecessary, which is most cases.
if (bit_num == 8)
print byte_acc.chr
byte_acc = 0
bit_num = 0
elsif (x == count_size)
byte_acc <<= (8 - bit_num)
print byte_acc.chr
byte_acc = 0
bit_num = 0
end
end
end
-1
View File
@@ -60,7 +60,6 @@ MRuby::CrossBuild.new("ArduinoDue") do |conf|
conf.disable_cxx_exception
#gems from core
conf.gem :core => "mruby-print"
conf.gem :core => "mruby-math"
conf.gem :core => "mruby-enum-ext"
-1
View File
@@ -56,7 +56,6 @@ MRuby::CrossBuild.new("Galileo") do |conf|
#official mrbgems
conf.gem :core => "mruby-sprintf"
conf.gem :core => "mruby-print"
conf.gem :core => "mruby-math"
conf.gem :core => "mruby-time"
conf.gem :core => "mruby-struct"
-1
View File
@@ -50,7 +50,6 @@ MRuby::CrossBuild.new("RX630") do |conf|
#gems from core
conf.gem :core => "mruby-sprintf"
conf.gem :core => "mruby-print"
conf.gem :core => "mruby-math"
conf.gem :core => "mruby-enum-ext"
conf.gem :core => "mruby-numeric-ext"
+2 -2
View File
@@ -2,8 +2,8 @@
MRuby::CrossBuild.new('android-arm64-v8a') do |conf|
params = {
:arch => 'arm64-v8a',
:sdk_version => 26,
:toolchain => :clang,
:sdk_version => 33,
:toolchain => :clang
}
toolchain :android, params
-11
View File
@@ -1,11 +0,0 @@
# Requires Android NDK r13 or later.
MRuby::CrossBuild.new('android-armeabi') do |conf|
params = {
:arch => 'armeabi',
:sdk_version => 26,
:toolchain => :clang,
}
toolchain :android, params
conf.gembox 'default'
end
@@ -4,8 +4,8 @@ MRuby::CrossBuild.new('android-armeabi-v7a-neon-hard') do |conf|
:arch => 'armeabi-v7a',
:mfpu => 'neon',
:mfloat_abi => 'hard',
:sdk_version => 26,
:toolchain => :clang,
:sdk_version => 33,
:toolchain => :clang
}
toolchain :android, params
-1
View File
@@ -56,7 +56,6 @@ MRuby::CrossBuild.new("chipKITMax32") do |conf|
conf.disable_cxx_exception
#gems from core
conf.gem :core => "mruby-print"
conf.gem :core => "mruby-math"
conf.gem :core => "mruby-enum-ext"
+3 -3
View File
@@ -6,7 +6,7 @@ MRuby::Build.new('full-debug') do |conf|
# include all core GEMs
conf.gembox 'full-core'
conf.cc.defines += %w(MRB_GC_STRESS MRB_USE_DEBUG_HOOK MRB_UTF8_STRING)
conf.cc.defines += %w(MRB_GC_STRESS MRB_USE_DEBUG_HOOK)
conf.enable_test
end
@@ -18,7 +18,7 @@ MRuby::Build.new do |conf|
conf.gembox 'full-core'
conf.gem :core => 'mruby-bin-debugger'
conf.compilers.each do |c|
c.defines += %w(MRB_GC_FIXED_ARENA MRB_UTF8_STRING)
c.defines += %w(MRB_GC_FIXED_ARENA)
end
conf.enable_bintest
conf.enable_test
@@ -30,7 +30,7 @@ MRuby::Build.new('cxx_abi') do |conf|
conf.gembox 'full-core'
conf.cc.flags += %w(-fpermissive -std=gnu++03)
conf.compilers.each do |c|
c.defines += %w(MRB_GC_FIXED_ARENA MRB_UTF8_STRING)
c.defines += %w(MRB_GC_FIXED_ARENA)
end
conf.enable_test
+3
View File
@@ -73,6 +73,9 @@ MRuby::Build.new do |conf|
# file separator
# conf.file_separator = '/'
# change library directory name from the default "lib" if necessary
# conf.libdir_name = 'lib64'
# Turn on `enable_debug` for better debugging
# conf.enable_debug
conf.enable_bintest
+29 -64
View File
@@ -4,31 +4,31 @@
# Requires KallistiOS (KOS)
# http://gamedev.allusion.net/softprj/kos/
#
# Tested on GNU/Linux, macOS and Windows (through MinGW-w64/MSYS2, Cygwin and DreamSDK).
# This configuration has been improved to be used as KallistiOS Port (kos-ports)
# Updated: 2023-12-24
#
# Tested on GNU/Linux, macOS and Windows (MinGW-w64/MSYS2, Cygwin, DreamSDK)
# DreamSDK is based on MinGW/MSYS: https://dreamsdk.org/
#
# Input this command on the directory where mruby is installed:
# make MRUBY_CONFIG=dreamcast_shelf
# Install mruby for Sega Dreamcast using the "mruby" kos-port.
#
MRuby::CrossBuild.new("dreamcast") do |conf|
toolchain :gcc
# Support for DreamSDK (based on MinGW/MSYS)
# To compile mruby with DreamSDK, RubyInstaller for Windows should be installed
DREAMSDK_HOME = ENV["DREAMSDK_HOME"]
MSYS_ROOT = !(DREAMSDK_HOME.nil? || DREAMSDK_HOME.empty?) ? "#{DREAMSDK_HOME}/msys/1.0" : ""
# Getting critical environment variables
KOS_BASE = ENV["KOS_BASE"]
KOS_CC_BASE = ENV["KOS_CC_BASE"]
# Setting paths
DREAMCAST_PATH = "#{MSYS_ROOT}/opt/toolchains/dc"
KOS_PATH = "#{DREAMCAST_PATH}/kos"
BIN_PATH = "#{DREAMCAST_PATH}/sh-elf/bin"
if (KOS_BASE.nil? || KOS_BASE.empty? || KOS_CC_BASE.nil? || KOS_CC_BASE.empty?)
raise "Error: KallistiOS is required; KOS_BASE/KOS_CC_BASE needs to be declared; Stop."
end
# C compiler
# Flags were extracted from KallistiOS environment files
# All flags and settings below were extracted from KallistiOS environment files
conf.cc do |cc|
cc.command = "#{BIN_PATH}/sh-elf-gcc"
cc.include_paths << ["#{KOS_PATH}/include", "#{KOS_PATH}/kernel/arch/dreamcast/include", "#{KOS_PATH}/addons/include", "#{KOS_PATH}/../kos-ports/include"]
cc.flags << ["-O2", "-fomit-frame-pointer", "-ml", "-m4-single-only", "-ffunction-sections", "-fdata-sections", "-Wall", "-g", "-fno-builtin", "-ml", "-m4-single-only", "-Wl,-Ttext=0x8c010000", "-Wl,--gc-sections", "-T#{KOS_PATH}/utils/ldscripts/shlelf.xc", "-nodefaultlibs"]
cc.command = "#{KOS_CC_BASE}/bin/sh-elf-gcc"
cc.include_paths << ["#{KOS_BASE}/include", "#{KOS_BASE}/kernel/arch/dreamcast/include", "#{KOS_BASE}/addons/include", "#{KOS_BASE}/../kos-ports/include"]
cc.flags << ["-O2", "-fomit-frame-pointer", "-fno-builtin", "-ml", "-m4-single-only", "-ffunction-sections", "-fdata-sections", "-matomic-model=soft-imask", "-ftls-model=local-exec", "-Wall", "-g"]
cc.compile_options = %Q[%{flags} -o "%{outfile}" -c "%{infile}"]
cc.defines << %w(_arch_dreamcast)
cc.defines << %w(_arch_sub_pristine)
@@ -39,79 +39,44 @@ MRuby::CrossBuild.new("dreamcast") do |conf|
cxx.command = conf.cc.command.dup
cxx.include_paths = conf.cc.include_paths.dup
cxx.flags = conf.cc.flags.dup
cxx.flags << %w(-fno-rtti -fno-exceptions)
cxx.flags << %w(-fno-operator-names)
cxx.defines = conf.cc.defines.dup
cxx.compile_options = conf.cc.compile_options.dup
end
# Linker
# There is an issue when making the mruby library with KallistiOS:
# 'newlib_kill.o' and 'newlib_getpid.o' aren't found so they are explicitly
# specified here at least for now.
conf.linker do |linker|
linker.command="#{BIN_PATH}/sh-elf-gcc"
linker.flags << ["#{MSYS_ROOT}/opt/toolchains/dc/kos/kernel/build/newlib_kill.o", "#{MSYS_ROOT}/opt/toolchains/dc/kos/kernel/build/newlib_getpid.o", "-Wl,--start-group -lkallisti -lc -lgcc -Wl,--end-group"]
linker.library_paths << ["#{KOS_PATH}/lib/dreamcast", "#{KOS_PATH}/addons/lib/dreamcast", "#{KOS_PATH}/../kos-ports/lib"]
linker.command = "#{KOS_CC_BASE}/bin/sh-elf-gcc"
linker.flags << ["-Wl,-Ttext=0x8c010000", "-Wl,--gc-sections", "-T#{KOS_BASE}/utils/ldscripts/shlelf.xc", "-nodefaultlibs", "-Wl,--start-group -lkallisti -lc -lgcc -Wl,--end-group"]
linker.library_paths << ["#{KOS_BASE}/lib/dreamcast", "#{KOS_BASE}/addons/lib/dreamcast", "#{KOS_BASE}/../kos-ports/lib"]
end
# Archiver
conf.archiver do |archiver|
archiver.command = "#{BIN_PATH}/sh-elf-ar"
archiver.command = "#{KOS_CC_BASE}/bin/sh-elf-ar"
archiver.archive_options = 'rcs "%{outfile}" %{objs}'
end
# No executables
# No executables needed for KallistiOS
conf.bins = []
# Do not build executable test
# Do not build test binaries
conf.build_mrbtest_lib_only
# Disable C++ exception
conf.disable_cxx_exception
# Gemboxes
conf.gembox "default-no-stdio"
conf.gembox "stdlib-ext"
conf.gembox "metaprog"
# Gems from core
# Some Gems are incompatible and were disabled.
conf.gem :core => "mruby-array-ext"
# Additional Gems
# Currently unsupported on KallistiOS: "mruby-io", "mruby-dir", "mruby-socket"
conf.gem :core => "mruby-binding"
conf.gem :core => "mruby-catch"
conf.gem :core => "mruby-class-ext"
conf.gem :core => "mruby-cmath"
conf.gem :core => "mruby-compar-ext"
conf.gem :core => "mruby-compiler"
conf.gem :core => "mruby-complex"
conf.gem :core => "mruby-enum-chain"
conf.gem :core => "mruby-enum-ext"
conf.gem :core => "mruby-enum-lazy"
conf.gem :core => "mruby-enumerator"
conf.gem :core => "mruby-errno"
conf.gem :core => "mruby-error"
conf.gem :core => "mruby-eval"
conf.gem :core => "mruby-exit"
conf.gem :core => "mruby-fiber"
conf.gem :core => "mruby-hash-ext"
# conf.gem :core => "mruby-io"
conf.gem :core => "mruby-kernel-ext"
conf.gem :core => "mruby-math"
conf.gem :core => "mruby-metaprog"
conf.gem :core => "mruby-method"
conf.gem :core => "mruby-numeric-ext"
conf.gem :core => "mruby-object-ext"
conf.gem :core => "mruby-objectspace"
conf.gem :core => "mruby-os-memsize"
conf.gem :core => "mruby-pack"
conf.gem :core => "mruby-print"
conf.gem :core => "mruby-proc-binding"
conf.gem :core => "mruby-proc-ext"
conf.gem :core => "mruby-random"
conf.gem :core => "mruby-range-ext"
conf.gem :core => "mruby-rational"
conf.gem :core => "mruby-sleep"
# conf.gem :core => "mruby-socket"
conf.gem :core => "mruby-sprintf"
conf.gem :core => "mruby-string-ext"
conf.gem :core => "mruby-struct"
conf.gem :core => "mruby-symbol-ext"
# conf.gem :core => "mruby-test"
# conf.gem :core => "mruby-time"
conf.gem :core => "mruby-toplevel-ext"
end
+12
View File
@@ -0,0 +1,12 @@
# Make sure to add these compile options:
# build/emscripten-cxx/host-bin/mruby-config --cxxflags
#
# Make sure to add these link options:
# build/emscripten-cxx/host-bin/mruby-config --ldflags --libs
MRuby::CrossBuild.new('emscripten-cxx') do |conf|
conf.toolchain :emscripten
conf.gembox 'default'
conf.enable_cxx_abi
end
+10
View File
@@ -0,0 +1,10 @@
# Make sure to add these compile options:
# build/emscripten/host-bin/mruby-config --cflags
#
# Make sure to add these link options:
# build/emscripten/host-bin/mruby-config --ldflags --libs
MRuby::CrossBuild.new('emscripten') do |conf|
conf.toolchain :emscripten
conf.gembox 'default'
end
-1
View File
@@ -47,7 +47,6 @@ MRuby::CrossBuild.new("gameboyadvance") do |conf|
conf.gem core: "mruby-metaprog"
conf.gem core: "mruby-pack"
conf.gem core: "mruby-sprintf"
conf.gem core: "mruby-print"
conf.gem core: "mruby-math"
conf.gem core: "mruby-time"
conf.gem core: "mruby-struct"
+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 MRB_UTF8_STRING)
conf.cc.defines = %w(MRB_USE_DEBUG_HOOK MRB_NO_BOXING)
# Generate mruby debugger command (require mruby-eval)
conf.gem :core => "mruby-bin-debugger"
+10 -10
View File
@@ -1,23 +1,20 @@
# NOTE: Currently, this configuration file does not support VisualC++!
# Your help is needed!
MRuby::Build.new do |conf|
# load specific toolchain settings
# Gets set by the VS command prompts.
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
toolchain :visualcpp
else
toolchain :gcc
end
conf.toolchain
# include the GEM box
conf.gembox 'default'
# C compiler settings
conf.cc do |cc|
cc.flags = '-fPIC'
conf.compilers.each do |cc|
cc.flags << '-fPIC'
end
conf.archiver do |archiver|
archiver.command = 'gcc'
archiver.command = cc.command
archiver.archive_options = '-shared -o %{outfile} %{objs}'
end
@@ -29,6 +26,9 @@ MRuby::Build.new do |conf|
# file separator
# conf.file_separator = '/'
# enable this if better compatibility with C++ is desired
#conf.enable_cxx_exception
# Turn on `enable_debug` for better debugging
conf.enable_debug
conf.enable_bintest
+76
View File
@@ -0,0 +1,76 @@
# Cross Compiling configuration for MS-DOS
#
# Requires DJGPP cross-compiler, see
# https://github.com/andrewwutw/build-djgpp/releases
MRuby::CrossBuild.new("i586-pc-msdosdjgpp") do |conf|
toolchain :gcc
# If DJGPP is not in the PATH, set this to the bin directory
DJGPP_PATH = nil
GCC = 'i586-pc-msdosdjgpp-gcc'
GXX = 'i586-pc-msdosdjgpp-g++'
AR = 'i586-pc-msdosdjgpp-ar'
conf.cc do |cc|
cc.command = DJGPP_PATH ? File.join(DJGPP_PATH, GCC) : GCC
cc.defines << 'MRB_NO_IO_PREAD_PWRITE'
cc.defines << 'MRB_UTF8_STRING'
end
conf.cxx do |cxx|
cxx.command = DJGPP_PATH ? File.join(DJGPP_PATH, GXX) : GXX
cxx.defines << 'MRB_NO_IO_PREAD_PWRITE'
cxx.defines << 'MRB_UTF8_STRING'
end
conf.linker do |linker|
linker.command = DJGPP_PATH ? File.join(DJGPP_PATH, GXX) : GXX
linker.libraries = %w(m)
end
conf.archiver do |archiver|
archiver.command = DJGPP_PATH ? File.join(DJGPP_PATH, AR) : AR
end
# All provided gems that can be reasonably made to compile:
# default.gembox, minus mruby-socket and replacing mruby-cmath with mruby-cmath-alt
conf.gembox "stdlib"
conf.gembox "stdlib-ext"
conf.gem :core => 'mruby-io' # stdlib-io.gembox <- default.gembox
# No socket support in DJGPP
# conf.gem :core => 'mruby-socket' # stdlib-io.gembox <- default.gembox
conf.gem :core => 'mruby-errno' # stdlib-io.gembox <- default.gembox
conf.gem :core => 'mruby-dir' # stdlib-io.gembox <- default.gembox
conf.gem :core => 'mruby-bigint' # math.gembox <- default.gembox
conf.gem :core => 'mruby-complex' # math.gembox <- default.gembox
conf.gem :core => 'mruby-math' # math.gembox <- default.gembox
conf.gem :core => 'mruby-rational' # math.gembox <- default.gembox
# Alternative implementation of cmath, not requiring <complex.h>
# conf.gem :github => 'chasonr/mruby-cmath-alt' # math.gembox <- default.gembox
conf.gembox "metaprog"
conf.gem :core => 'mruby-bin-mrbc' # default.gembox
conf.gem :core => 'mruby-bin-debugger' # default.gembox
conf.gem :core => 'mruby-bin-mirb' # default.gembox
conf.gem :core => 'mruby-bin-mruby' # default.gembox
conf.gem :core => 'mruby-bin-strip' # default.gembox
conf.gem :core => 'mruby-bin-config' # default.gembox
# Other compilable gems
conf.gem :core => 'mruby-binding'
conf.gem :core => 'mruby-catch'
conf.gem :core => 'mruby-enum-chain'
conf.gem :core => 'mruby-error'
conf.gem :core => 'mruby-exit'
conf.gem :core => 'mruby-os-memsize'
conf.gem :core => 'mruby-proc-binding'
conf.gem :core => 'mruby-sleep'
# For Onigmo regular expression support
conf.gem :github => 'mattn/mruby-onig-regexp'
end
+106
View File
@@ -0,0 +1,106 @@
# Cross Compiling configuration for Milk-V Duo.
# To build (on Ubuntu 24.04): rake MRUBY_CONFIG=build_config/milkv_duo.rb
#
# Requires: https://github.com/milkv-duo/duo-sdk
#
MRuby::CrossBuild.new("milkv_duo") do |conf|
# Set this string to match your board: milkv_duo, milkv_duo256m, milkv_duos
MILKV_DUO_VARIANT = "milkv_duo256m"
# Expect duo-sdk directory is same level as (next to) mruby top-level directory.
SDK_BASE = File.expand_path("../../../", File.expand_path(__FILE__)) + "/duo-sdk"
TOOLCHAIN_BASE = "#{SDK_BASE}/riscv64-linux-musl-x86_64"
SYSROOT = "#{SDK_BASE}/rootfs"
toolchain :gcc
# C compiler settings
conf.cc do |cc|
cc.command = "#{TOOLCHAIN_BASE}/bin/riscv64-unknown-linux-musl-gcc"
cc.include_paths << "#{TOOLCHAIN_BASE}/lib/gcc/riscv64-unknown-linux/musl/10.2.0/include-fixed"
cc.include_paths << "#{TOOLCHAIN_BASE}/lib/gcc/riscv64-unknown-linux/musl/10.2.0/include"
cc.include_paths << "#{TOOLCHAIN_BASE}/riscv64-unknown-linux/include"
cc.include_paths << "#{TOOLCHAIN_BASE}/include"
cc.include_paths << "#{SYSROOT}/usr/include"
cc.flags << ["-mcpu=c906fdv", "-march=rv64imafdcv0p7xthead", "-mcmodel=medany", "-mabi=lp64d"]
cc.flags << ["-D_LARGEFILE_SOURCE", "-D_LARGEFILE64_SOURCE", "-D_FILE_OFFSET_BITS=64"]
cc.flags << ["-Wl,--copy-dt-needed-entries", "-Wl,-lc,-lgcc_s,-lwiringx"]
cc.defines << "MILKV_DUO_VARIANT=_#{MILKV_DUO_VARIANT}"
end
# Linker settings
conf.linker do |linker|
linker.command = cc.command
linker.library_paths << ["#{SYSROOT}/lib", "#{SYSROOT}/usr/lib"]
linker.flags = cc.flags
end
# Archiver settings
conf.archiver do |archiver|
archiver.command = "#{TOOLCHAIN_BASE}/bin/riscv64-unknown-linux-musl-gcc-ar"
end
# Do not build executable test
conf.build_mrbtest_lib_only
# Disable C++ exception
conf.disable_cxx_exception
# All standard gems.
conf.gem 'mrbgems/mruby-array-ext/'
conf.gem 'mrbgems/mruby-bigint/'
conf.gem 'mrbgems/mruby-bin-config/'
conf.gem 'mrbgems/mruby-bin-debugger/'
conf.gem 'mrbgems/mruby-bin-mirb/'
conf.gem 'mrbgems/mruby-bin-mrbc/'
conf.gem 'mrbgems/mruby-bin-mruby/'
conf.gem 'mrbgems/mruby-bin-strip/'
conf.gem 'mrbgems/mruby-binding/'
conf.gem 'mrbgems/mruby-catch/'
conf.gem 'mrbgems/mruby-class-ext/'
conf.gem 'mrbgems/mruby-cmath/'
conf.gem 'mrbgems/mruby-compar-ext/'
conf.gem 'mrbgems/mruby-compiler/'
conf.gem 'mrbgems/mruby-complex/'
conf.gem 'mrbgems/mruby-data/'
conf.gem 'mrbgems/mruby-dir/'
conf.gem 'mrbgems/mruby-enum-chain/'
conf.gem 'mrbgems/mruby-enum-ext/'
conf.gem 'mrbgems/mruby-enum-lazy/'
conf.gem 'mrbgems/mruby-enumerator/'
conf.gem 'mrbgems/mruby-errno/'
conf.gem 'mrbgems/mruby-error/'
conf.gem 'mrbgems/mruby-eval/'
conf.gem 'mrbgems/mruby-exit/'
conf.gem 'mrbgems/mruby-fiber/'
conf.gem 'mrbgems/mruby-hash-ext/'
conf.gem 'mrbgems/mruby-io/'
conf.gem 'mrbgems/mruby-kernel-ext/'
conf.gem 'mrbgems/mruby-math/'
conf.gem 'mrbgems/mruby-metaprog/'
conf.gem 'mrbgems/mruby-method/'
conf.gem 'mrbgems/mruby-numeric-ext/'
conf.gem 'mrbgems/mruby-object-ext/'
conf.gem 'mrbgems/mruby-objectspace/'
conf.gem 'mrbgems/mruby-os-memsize/'
conf.gem 'mrbgems/mruby-pack/'
conf.gem 'mrbgems/mruby-proc-binding/'
conf.gem 'mrbgems/mruby-proc-ext/'
conf.gem 'mrbgems/mruby-random/'
conf.gem 'mrbgems/mruby-range-ext/'
conf.gem 'mrbgems/mruby-rational/'
conf.gem 'mrbgems/mruby-set/'
conf.gem 'mrbgems/mruby-sleep/'
conf.gem 'mrbgems/mruby-socket/'
conf.gem 'mrbgems/mruby-sprintf/'
conf.gem 'mrbgems/mruby-string-ext/'
conf.gem 'mrbgems/mruby-struct/'
conf.gem 'mrbgems/mruby-symbol-ext/'
# conf.gem 'mrbgems/mruby-test-inline-struct/'
# conf.gem 'mrbgems/mruby-test/'
conf.gem 'mrbgems/mruby-time/'
conf.gem 'mrbgems/mruby-toplevel-ext/'
# GPIO, ADC, PWM, I2C and SPI support for Milk-V Duo
# conf.gem :github => 'denko-rb/mruby-milkv-duo'
end
+95
View File
@@ -0,0 +1,95 @@
# Cross Compiling configuration for the Nintendo Wii
# This configuration requires devkitPPC
# https://devkitpro.org/wiki/Getting_Started
#
#
MRuby::CrossBuild.new("wii") do |conf|
toolchain :gcc
DEVKITPRO_PATH = "/opt/devkitpro"
BIN_PATH = "#{DEVKITPRO_PATH}/devkitPPC/bin"
# C compiler
conf.cc do |cc|
cc.command = "#{BIN_PATH}/powerpc-eabi-gcc"
cc.compile_options = %(%{flags} -o "%{outfile}" -c "%{infile}")
end
# C++ compiler
conf.cxx do |cxx|
cxx.command = "#{BIN_PATH}/powerpc-eabi-g++"
cxx.include_paths = conf.cc.include_paths.dup
cxx.flags = conf.cc.flags.dup
cxx.defines = conf.cc.defines.dup
cxx.compile_options = conf.cc.compile_options.dup
end
# Linker
conf.linker do |linker|
linker.command = "#{BIN_PATH}/powerpc-eabi-gcc"
end
# No executables
conf.bins = []
# Do not build executable test
conf.build_mrbtest_lib_only
# Disable C++ exception
conf.disable_cxx_exception
# All current core gems with ones with build issues commented out
conf.gem 'mrbgems/mruby-array-ext/'
conf.gem 'mrbgems/mruby-bigint/'
conf.gem 'mrbgems/mruby-bin-config/'
conf.gem 'mrbgems/mruby-bin-debugger/'
conf.gem 'mrbgems/mruby-bin-mirb/'
conf.gem 'mrbgems/mruby-bin-mrbc/'
conf.gem 'mrbgems/mruby-bin-mruby/'
conf.gem 'mrbgems/mruby-bin-strip/'
conf.gem 'mrbgems/mruby-binding/'
conf.gem 'mrbgems/mruby-catch/'
conf.gem 'mrbgems/mruby-class-ext/'
conf.gem 'mrbgems/mruby-cmath/'
conf.gem 'mrbgems/mruby-compar-ext/'
conf.gem 'mrbgems/mruby-compiler/'
conf.gem 'mrbgems/mruby-complex/'
conf.gem 'mrbgems/mruby-data/'
#conf.gem 'mrbgems/mruby-dir/'
conf.gem 'mrbgems/mruby-enum-chain/'
conf.gem 'mrbgems/mruby-enum-ext/'
conf.gem 'mrbgems/mruby-enum-lazy/'
conf.gem 'mrbgems/mruby-enumerator/'
conf.gem 'mrbgems/mruby-errno/'
conf.gem 'mrbgems/mruby-error/'
conf.gem 'mrbgems/mruby-eval/'
conf.gem 'mrbgems/mruby-exit/'
conf.gem 'mrbgems/mruby-fiber/'
conf.gem 'mrbgems/mruby-hash-ext/'
#conf.gem 'mrbgems/mruby-io/'
conf.gem 'mrbgems/mruby-kernel-ext/'
conf.gem 'mrbgems/mruby-math/'
conf.gem 'mrbgems/mruby-metaprog/'
conf.gem 'mrbgems/mruby-method/'
conf.gem 'mrbgems/mruby-numeric-ext/'
conf.gem 'mrbgems/mruby-object-ext/'
conf.gem 'mrbgems/mruby-objectspace/'
conf.gem 'mrbgems/mruby-os-memsize/'
conf.gem 'mrbgems/mruby-pack/'
conf.gem 'mrbgems/mruby-proc-binding/'
conf.gem 'mrbgems/mruby-proc-ext/'
conf.gem 'mrbgems/mruby-random/'
conf.gem 'mrbgems/mruby-range-ext/'
conf.gem 'mrbgems/mruby-rational/'
conf.gem 'mrbgems/mruby-set/'
conf.gem 'mrbgems/mruby-sleep/'
#conf.gem 'mrbgems/mruby-socket/'
conf.gem 'mrbgems/mruby-sprintf/'
conf.gem 'mrbgems/mruby-string-ext/'
conf.gem 'mrbgems/mruby-struct/'
conf.gem 'mrbgems/mruby-symbol-ext/'
conf.gem 'mrbgems/mruby-test-inline-struct/'
#conf.gem 'mrbgems/mruby-test/'
conf.gem 'mrbgems/mruby-time/'
conf.gem 'mrbgems/mruby-toplevel-ext/'
end
+17
View File
@@ -0,0 +1,17 @@
# Define cross build settings
MRuby::CrossBuild.new('no-float') do |conf|
conf.toolchain
# Add configuration
conf.compilers.each do |c|
c.defines << "MRB_NO_FLOAT"
end
conf.gem :core => "mruby-bin-mruby"
conf.test_runner.command = 'env'
conf.enable_debug
# conf.enable_bintest
conf.enable_test
end
+78
View File
@@ -0,0 +1,78 @@
# Cross Compiling configuration for the Sony PlayStation Portable.
# This configuration requires toolchain from https://github.com/pspdev
MRuby::CrossBuild.new("playstationportable") do |conf|
toolchain :gcc
PSPDEV_PATH = "#{ENV['PSPDEV']}"
BIN_PATH = "#{PSPDEV_PATH}/bin"
# C compiler
conf.cc do |cc|
cc.command = "#{BIN_PATH}/psp-gcc"
cc.flags << ["-O2", "-D_PSP_FW_VERSION=600"]
cc.include_paths << ["#{PSPDEV_PATH}/psp/include", "#{PSPDEV_PATH}/psp/sdk/include"]
cc.compile_options = %(%{flags} -o "%{outfile}" -c "%{infile}")
end
# C++ compiler
conf.cxx do |cxx|
cxx.command = "#{BIN_PATH}/psp-g++"
cxx.include_paths = conf.cc.include_paths.dup
cxx.flags = conf.cc.flags.dup
cxx.flags << %w[-fno-rtti -fno-exceptions]
cxx.defines = conf.cc.defines.dup
cxx.compile_options = conf.cc.compile_options.dup
end
# Linker
conf.linker do |linker|
linker.command = "#{BIN_PATH}/psp-gcc"
linker.flags << ["-Wl,-zmax-page-size=128"]
end
# No executables
conf.bins = []
# Do not build executable test
conf.build_mrbtest_lib_only
# Gems from core
conf.gem :core => "mruby-metaprog"
conf.gem :core => "mruby-pack"
conf.gem :core => "mruby-sprintf"
conf.gem :core => "mruby-math"
conf.gem :core => "mruby-time"
conf.gem :core => "mruby-struct"
conf.gem :core => "mruby-compar-ext"
conf.gem :core => "mruby-enum-ext"
conf.gem :core => "mruby-string-ext"
conf.gem :core => "mruby-numeric-ext"
conf.gem :core => "mruby-array-ext"
conf.gem :core => "mruby-hash-ext"
conf.gem :core => "mruby-range-ext"
conf.gem :core => "mruby-proc-ext"
conf.gem :core => "mruby-symbol-ext"
conf.gem :core => "mruby-random"
conf.gem :core => "mruby-object-ext"
conf.gem :core => "mruby-objectspace"
conf.gem :core => "mruby-fiber"
conf.gem :core => "mruby-enumerator"
conf.gem :core => "mruby-enum-lazy"
conf.gem :core => "mruby-toplevel-ext"
conf.gem :core => "mruby-kernel-ext"
conf.gem :core => "mruby-class-ext"
conf.gem :core => "mruby-compiler"
conf.gem :core => "mruby-binding"
conf.gem :core => "mruby-catch"
conf.gem :core => "mruby-enum-chain"
conf.gem :core => "mruby-errno"
conf.gem :core => "mruby-error"
conf.gem :core => "mruby-exit"
conf.gem :core => "mruby-os-memsize"
conf.gem :core => "mruby-proc-binding"
conf.gem :core => "mruby-sleep"
conf.gem :core => "mruby-io"
conf.gem :core => "mruby-dir"
#conf.gem :core => "mruby-socket" unsupported
end
+115 -6
View File
@@ -1,3 +1,5 @@
<!-- summary: About the Compile -->
# Compile
mruby uses Rake to compile and cross-compile all libraries and
@@ -80,7 +82,7 @@ conf.toolchain :clang
#### Visual Studio 2010, 2012 and 2013
Toolchain configuration for Visual Studio on Windows. If you use the
[Visual Studio Command Prompt](https://msdn.microsoft.com/en-us/library/ms229859\(v=vs.110\).aspx),
[Visual Studio Command Prompt](<https://msdn.microsoft.com/en-us/library/ms229859(v=vs.110).aspx>),
you normally do not have to specify this manually, since it gets automatically detected by our build process.
```ruby
@@ -117,6 +119,36 @@ set the character via `conf.file_separator`.
conf.file_separator = '/'
```
### Name of library directory
In some environments, the `libmruby.a` file requires a different directory name than `lib`.
You can be changed to any name by the `conf.libdir_name` accessor.
```ruby
conf.libdir_name = 'lib64'
```
Alternatively, it can be changed via the environment variable `MRUBY_SYSTEM_LIBDIR_NAME` when
the `rake` command is run.
```console
$ export MRUBY_SYSTEM_LIBDIR_NAME=lib64
$ rake clean all
```
NOTES:
- This environment variable `MRUBY_SYSTEM_LIBDIR_NAME` does not affect `MRuby::CrossBuild`.
In other words, if you want to change it for `MRuby::CrossBuild`, you must set it with `MRuby::CrossBuild#libdir_name=`.
- If you want to switch this environment variable `MRUBY_SYSTEM_LIBDIR_NAME`, you must do `rake clean`.
A bad usage example is shown below.
```console
$ rake clean all
$ rake MRUBY_SYSTEM_LIBDIR_NAME=lib64 install
```
### C Compiler
Configuration of the C compiler binary, flags and include paths.
@@ -177,7 +209,7 @@ conf.linker do |linker|
linker.flags_before_libraries = ...
linker.libraries = ...
linker.flags_after_libraries = ...
linker.library_paths = ....
linker.library_paths = ...
linker.option_library = ...
linker.option_library_path = ...
linker.link_options = ...
@@ -265,7 +297,7 @@ There is a `RubyGem` (gem for CRuby) named `mgem` that help you to
manage `mrbgems`. Try `gem install mgem`. `mgem` can show you the list
of registered `mrbgems`.
See doc/mrbgems/README.md for more option about mrbgems.
See [doc/guides/mrbgems.md](mrbgems.md) for more option about mrbgems.
### Mrbtest
@@ -376,7 +408,7 @@ end
## Build process
During the build process the directory `build` will be created in the
During the build process the `build` directory will be created in the
root directory. The structure of this directory will look like this:
```
@@ -460,7 +492,7 @@ compile for `i386` a directory called `i386` is created under the
build directory.
The cross compilation workflow starts in the same way as the normal
compilation by compiling all *native* libraries and binaries, except
compilation by compiling all _native_ libraries and binaries, except
for we don't have `host/mrbc` directory (`host` directory itself works
as placeholder for `mrbc`). Afterwards the cross compilation process
proceeds like this:
@@ -527,7 +559,7 @@ After the build, you will get `libmruby.a`. You can link it to your application.
For compiler options and library path, you can use `mruby-config` command for
convenience. `mruby-config` command prints the configuration used for `libmruby.a`.
```
```console
$ mruby-config --help
Usage: mruby-config [switches]
switches:
@@ -557,6 +589,83 @@ LDFLAGS = `$(MRB_CONFIG) --ldflags`
LIBS = `$(MRB_CONFIG) --libs`
```
## Install
To install the files in the `bin`, `include` and `lib` directories generated by the "host" build target into a system directory, do the following:
```console
$ rake install
```
If there are multiple build targets in the build configuration file, to install the products of all build targets, do the following:
```console
$ rake install:full
```
To install only one of several build targets, e.g., the "its-mine" build target, do the following:
```console
$ rake install:full:its-mine
```
To install only the executable files, do the following:
```console
$ rake install_bin # only "host" build target
$ rake install:bin # all build targets
$ rake install:bin:its-mine # only "its-mine" build target
```
### Installation Directory
The installation directory is `/usr/local` for the "host" build target and `/usr/local/mruby/<build-name>` for the others.
To change them, you can set the environment variable `PREFIX` or use `MRuby::Build#install_prefix = dir` in your build configuration file.
The `PREFIX` environment variable affects all build targets and changes the `/usr/local` part.
The `MRuby::Build#install_prefix` can be set for each individual build target.
In this case, the environment variable `PREFIX` is ignored.
Also, if the environment variable `DESTDIR` is set, it will prepend to the path obtained by `install_prefix` to determine the final write directory.
This is intended for temporary file expansion by the user's package work.
---
To summarize:
- The default value of the environment variable `PREFIX` is `/usr/local`.
- For the "host" build target, the default value of `MRuby::Build#install_prefix` is `<PREFIX>`.
- For a build target other than "host", the default value of `MRuby::Build#install_prefix` is `<PREFIX>/mruby/<build-name>`.
- If the environment variable `DESTDIR` is set, the actual write directory is `<DESTDIR>/<MRuby::Build#install_prefix>`.
### Excluded files
In some cases there are files that you do not want to install.
In such cases, add a file path filter to the array object `MRuby::Build#install_excludes` to exclude them.
The following is an object that can be defined as a file path filter.
The `path` variable that appears is a relative path based on `MRuby::Build#build_dir`.
- string objects: files matched by `string.match?(path)` are excluded.
- regexp object: files matched by `regexp.match?(path)` are excluded.
- proc object: files which return true with `proc.call(path)` are excluded.
```ruby
# exclude bin/mrbc
conf.install_excludes << exefile("bin/mrbc")
# exclude all files under lib/ directory
conf.install_excludes << %r(^lib/)
# exclude bin/mrbtest, but in this case it is recommended to use string instead of proc
conf.install_excludes << proc { |path|
path == exefile("bin/mrbtest")
}
```
By default, it contains only a proc object to exclude `libmruby_core`.
## Tips
- If you see compilation troubles, try `rake clean` first.
+18 -16
View File
@@ -1,3 +1,5 @@
<!-- summary: About the Debugger with the `mrdb` Command -->
# How to Use the mruby Debugger
copyright (c) 2014 Specified Non-Profit Corporation mruby Forum
@@ -38,7 +40,7 @@ To confirm mrdb was installed properly, run mrdb with the `--version` option:
```bash
$ mrdb --version
mruby 3.1.0 (2022-05-12)
mruby 3.3.0 (2024-02-14)
```
## 2.2 Basic Operation
@@ -61,20 +63,20 @@ $ mrdb sample.rb
You can execute the shell commands listed below:
|command|description|
|:-:|:--|
|run|execute programs|
|step|execute stepping|
|continue|execute continuing program|
|break|configure the breaking point|
|delete|deleting the breaking points|
|disable|disabling the breaking points|
|enable|enabling the breaking points|
|info breakpoints|showing list of the breaking points|
|print|evaluating and printing the values of the mruby expressions in the script|
|list|displaying the source cords|
|help|showing help|
|quit|terminating the mruby debugger|
| command | description |
| :--------------: | :------------------------------------------------------------------------ |
| run | execute programs |
| step | execute stepping |
| continue | execute continuing program |
| break | configure the breaking point |
| delete | deleting the breaking points |
| disable | disabling the breaking points |
| enable | enabling the breaking points |
| info breakpoints | showing list of the breaking points |
| print | evaluating and printing the values of the mruby expressions in the script |
| list | displaying the source cords |
| help | showing help |
| quit | terminating the mruby debugger |
### 2.2.2 Debugging mruby Binary Files (mrb file) with mrdb
@@ -83,7 +85,7 @@ You can debug the mruby binary files.
#### 2.2.2.1 Debugging the binary files
- notice
To debug mruby binary files, you need to compile mruby files with option `-g`.
To debug mruby binary files, you need to compile mruby files with option `-g`.
```bash
$ mrbc -g sample.rb
+7 -4
View File
@@ -1,9 +1,12 @@
<!-- summary: About GC Arena -->
# How to use `mrb_gc_arena_save()`/`mrb_gc_arena_restore()`/`mrb_gc_protect()`
_This is an English translation of [Matz's blog post][matz blog post]
written in Japanese._
_Some parts are updated to reflect recent changes._
[matz blog post]: <https://www.rubyist.net/~matz/20130731.html>
[matz blog post]: https://www.rubyist.net/~matz/20130731.html
When you are extending mruby using C language, you may encounter
mysterious "arena overflow error" or memory leak or very slow
@@ -62,7 +65,7 @@ memory leak.
As of this writing, mruby automatically extend arena to remember
objects (See `MRB_GC_FIXED_ARENA` and `MRB_GC_ARENA_SIZE` in
doc/guides/mrbconf.md).
[doc/guides/mrbconf.md](mrbconf.md)).
If you create many objects in C functions, memory usage will increase, since
GC never kicks in. This memory usage may look like memory leaks, but will also
@@ -106,7 +109,7 @@ inspect_ary(mrb_state *mrb, mrb_value ary, mrb_value list)
char tail[] = { ']' };
/* check recursive */
for(i=0; i<RARRAY_LEN(list); i++) {
for (i=0; i<RARRAY_LEN(list); i++) {
if (mrb_obj_equal(mrb, ary, RARRAY_PTR(list)[i])) {
return mrb_str_new(mrb, "[...]", 5);
}
@@ -117,7 +120,7 @@ inspect_ary(mrb_state *mrb, mrb_value ary, mrb_value list)
arystr = mrb_str_new_capa(mrb, 64);
mrb_str_cat(mrb, arystr, head, sizeof(head));
for(i=0; i<RARRAY_LEN(ary); i++) {
for (i=0; i<RARRAY_LEN(ary); i++) {
int ai = mrb_gc_arena_save(mrb);
if (i > 0) {
+62
View File
@@ -0,0 +1,62 @@
<!-- summary: About the mruby directory structure -->
# The mruby directory structure
```text
+- 💎 mruby/ The top directory of mruby.
|
+- 📁 .github/ GitHub configuration files for mruby project management.
|
+- 📁 benchmark/ Benchmarking files for mruby.
|
+- 📁 bin/ Links to temporary executables after build. Auto-created.
|
+- 📁 build/ Default build output destination for mruby. Auto-created.
| |
| +- 📁 repos/ The git clone destination directory for GEMs that depend on the build configuration.
| |
| +- 📁 host/ The "host" build output directory.
|
+- 📁 build_config/ Build configuration files for various environments.
|
+- 📁 doc/ Documentation for mruby.
| |
| +- 📁 guides/ Documentation for general users.
| |
| +- 📁 internal/ Documentation for internal implementations for developers.
|
+- 📁 examples/ Examples of mruby usages.
| |
| +- 📁 mrbgems/ Examples for creating custom GEM for mruby.
|
+- 📁 include/ C header files required when using mruby.
|
+- 📁 lib/ Ruby scripts used for building mruby.
|
+- 📁 mrbgems/ A library collection of features not provided by mruby core only.
| | See doc/guides/mrbgems.md file
| |
| +- 📁 mruby-*/ The directory of each GEMs.
| |
| +- 📃 *.gembox A collection of GEMs grouped by features and purposes.
|
+- 📁 mrblib/ The core Ruby scripts that makes up the main body of mruby.
|
+- 📁 oss-fuzz/ Source code for The fuzzing-test.
| See https://github.com/google/oss-fuzz
|
+- 📁 src/ The core C source code that makes up the main body of mruby.
|
+- 📁 tasks/ Rake tasks at build-time.
| |
| +- 📁 toolchains/ Definitions for the compiler, linker, archiver, etc. for each toolchain.
|
+- 📁 test/ Ruby scripts needed for testing mruby.
| |
| +- 📁 t/ mruby test cases.
|
+- 📁 tools/ External programs used for the mruby project.
|
+- 📁 lrama/ LALR parser generator as an alternative to bison.
Import from https://github.com/ruby/lrama
```
+10 -8
View File
@@ -1,3 +1,5 @@
<!-- summary: About Linking with `libmruby` -->
# Linking `libmruby` to your application
You have two ways to link `libmruby` to your application.
@@ -51,10 +53,10 @@ for example:
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
```
```console
$ mruby-config --cflags
-std=gnu99 -g -O3 -Wall -DMRB_GC_FIXED_ARENA -I/home/matz/work/mruby/include -I/home/matz/work/mruby/build/host/include
```
@@ -66,12 +68,12 @@ 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
```
```console
$ mruby-config --ldflags
-L/home/matz/work/mruby/build/host/lib
+23
View File
@@ -0,0 +1,23 @@
<!-- summary: About Memory Allocator Customization -->
# Memory Allocation
There are three methods to customize memory allocation in mruby.
1. Provide your own `realloc()`/`free()`
2. Redefine `mrb_default_allocf()`
3. Specify a function with `mrb_open_allocf()`
## Provide your own `realloc()`/`free()`
On some platforms, especially on microcontrollers, the standard library may not provide `malloc()`, `realloc()`, and `free()`. In such cases, it may be necessary to define memory allocation functions for the specific platform. mruby uses `realloc()` and `free()` from the standard C library for memory management. By defining these two functions of your own, you can make mruby work. However, note the following two points:
First, `realloc(NULL, size)` behaves the same as malloc(size). Second, `free(NULL)` exits without doing anything.
## Redefine `mrb_default_allocf()`
The only function in mruby that uses the standard C library's memory allocation functions is `mrb_default_allocf()`, defined in `alloc.c`. By defining this function within your application, you can customize the memory management of your application.
## Specify a function with `mrb_open_allocf()`
If you want to perform different memory management for each `mrb_state` within your application, you can use the `mrb_open_allocf()` function to create the `mrb_state` structure. This allows you to specify a memory allocation function (which is compatible with `mrb_default_allocf`) for each `mrb_state`. Although this scheme is not recommended. It may become obsolete in the future, since I have never seen per mrb_state memory management use-case.
+14 -18
View File
@@ -1,3 +1,5 @@
<!-- summary: About Build-time Configurations -->
# mruby configuration macros
## The configuration file
@@ -18,14 +20,14 @@ This is the same for `MRuby::CrossBuild`.
# build_config.rb
MRuby::Build.new do |conf|
.....
...
conf.defines << 'MRB_GC_FIXED_ARENA'
conf.defines << 'MRB_NO_METHOD_CACHE'
.....
...
end
```
***NOTE***
**_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.
@@ -105,7 +107,7 @@ end
`MRB_GC_TURN_OFF_GENERATIONAL`
- When defined turns generational GC by default.
- When defined turns generational GC off by default.
`MRB_GC_FIXED_ARENA`
@@ -121,9 +123,9 @@ end
`MRB_HEAP_PAGE_SIZE`
- Defines value is `1024`.
- Default 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`".
- 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,
@@ -135,7 +137,7 @@ end
- Default value is `4`.
- If you're allocating data types that requires alignment more than default value define the
largest value of required alignment.
largest value of required alignment.
`POOL_PAGE_SIZE`
@@ -149,7 +151,7 @@ largest value of required alignment.
- 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`'s value.
`MRB_FIXED_STATE_ATEXIT_STACK_SIZE`
@@ -197,7 +199,7 @@ largest value of required alignment.
`MRB_MALLOC_TRIM`
- call malloc_trim(0) for each mrb_full_gc() call
- call `malloc_trim(0)` for each `mrb_full_gc()` call
`MRB_UTF8_STRING`
@@ -211,7 +213,7 @@ largest value of required alignment.
`MRB_ARY_LENGTH_MAX`
- The maximum length of strings (default 1MB)
- The maximum length of arrays (default 1MB)
- set this value to zero to skip the check
`MRB_FUNCALL_ARGC_MAX`
@@ -236,17 +238,11 @@ largest value of required alignment.
- 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
`MRB_USE_ALL_SYMBOLS`
- Make it available `Symbol.all_symbols` in `mrbgems/mruby-symbol-ext`
- Increase heap memory usage.
`MRB_NO_DIRECT_THREADING`
`MRB_USE_VM_SWITCH_DISPATCH`
- Turn off direct threading optimization in VM loop
- Turn on switch dispatch in VM loop
+26 -9
View File
@@ -1,6 +1,8 @@
<!-- summary: About the Build-time Library Manager -->
# mrbgems
mrbgems is a library manager to integrate C and Ruby extension in an easy and
mrbgems is a library manager to integrate C and Ruby extensions in an easy and
standardised way into mruby. Conventionally, each mrbgem name is prefixed by
`mruby-`, e.g. `mruby-time` for a gem that provides `Time` class functionality.
@@ -92,6 +94,21 @@ end
However, it should be used with caution, as it may deviate from the intent
of the gem's author.
### Gem Testing
If you enable unit tests in your build with `enable_test`, tests will be
generated for all gems and their dependencies by default. If necessary, it is
possible to suppress tests for a specific gem like so:
```ruby
conf.gem 'mruby-noisygem' do |g|
g.skip_test = true
end
```
However, it is considered best practice to leave all tests enabled whenever
possible. A warning message will be generated for each gem with disabled tests.
## GemBox
There are instances when you wish to add a collection of mrbgems into mruby at
@@ -160,9 +177,9 @@ The maximal GEM structure looks like this:
+- test/ <- Test code (Ruby)
```
The folder `mrblib` contains pure Ruby files to extend mruby. The folder `src`
contains C/C++ files to extend mruby. The folder `include` contains C/C++ header
files. The folder `test` contains C/C++ and pure Ruby files for testing purposes
The `mrblib` directory contains pure Ruby files to extend mruby. The `src` directory
contains C/C++ files to extend mruby. The `include` directory contains C/C++ header
files. The `test` directory contains C/C++ and pure Ruby files for testing purposes
which will be used by `mrbtest`. `mrbgem.rake` contains the specification
to compile C and Ruby files. `README.md` is a short description of your GEM.
@@ -233,7 +250,7 @@ Version requirement supports following operators:
- '<=': 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'
- 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.
@@ -349,7 +366,7 @@ mrb_c_extension_example_gem_final(mrb_state* mrb) {
mruby can be extended with pure Ruby. It is possible to override existing
classes or add new ones in this way. Put all Ruby files into the `mrblib`
folder.
directory.
### Pre-Conditions
@@ -377,11 +394,11 @@ none
mruby can be extended with C and Ruby at the same time. It is possible to
override existing classes or add new ones in this way. Put all Ruby files
into the `mrblib` folder and all C files into the `src` folder.
into the `mrblib` directory and all C files into the `src` directory.
mruby codes under `mrblib` directory would be executed after gem init C
function is called. Make sure *mruby script* depends on *C code* and
*C code* doesn't depend on *mruby script*.
function is called. Make sure _mruby script_ depends on _C code_ and
_C code_ doesn't depend on _mruby script_.
### Pre-Conditions
+10 -7
View File
@@ -1,3 +1,5 @@
<!-- summary: About the Symbols -->
# Symbols
Symbols in `mruby` C source code is represented by `mrb_sym` which is alias of
@@ -57,13 +59,14 @@ 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_GVSYM(xor)` //=> $xor (Global Variable)
- `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
+6 -4
View File
@@ -1,3 +1,5 @@
<!-- summary: About Value Boxing -->
# Boxing
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`.
@@ -15,7 +17,7 @@ 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` |
@@ -24,17 +26,17 @@ The Word boxing packing bit patterns are like following:
| 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.
On 64-bit platforms (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`.
## 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-bit pointers are too big to fit in NaN, but practically most OS use 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` |
+111 -109
View File
@@ -1,3 +1,5 @@
<!-- summary: About mruby Virtual Machine Instructions -->
# The new bytecode
We will reimplement the VM to use 8bit instruction code. By
@@ -12,7 +14,7 @@ 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
In the table.1 below, the third field describes the size
of operands.
- B: 8bit
@@ -26,111 +28,111 @@ 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_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` |
| No. | Instruction Name | Operand type | Semantics
| --: | ---------------- | ------------ | ---------------
| 0 | `OP_NOP` | `-` | `no operation`
| 1 | `OP_MOVE` | `BB` | `R(a) = R(b)`
| 2 | `OP_LOADL` | `BB` | `R(a) = Pool(b)`
| 3 | `OP_LOADI8` | `BB` | `R(a) = mrb_int(b)`
| 4 | `OP_LOADINEG` | `BB` | `R(a) = mrb_int(-b)`
| 5 | `OP_LOADI__1` | `B` | `R(a) = mrb_int(-1)`
| 6 | `OP_LOADI_0` | `B` | `R(a) = mrb_int(0)`
| 7 | `OP_LOADI_1` | `B` | `R(a) = mrb_int(1)`
| 8 | `OP_LOADI_2` | `B` | `R(a) = mrb_int(2)`
| 9 | `OP_LOADI_3` | `B` | `R(a) = mrb_int(3)`
| 10 | `OP_LOADI_4` | `B` | `R(a) = mrb_int(4)`
| 11 | `OP_LOADI_5` | `B` | `R(a) = mrb_int(5)`
| 12 | `OP_LOADI_6` | `B` | `R(a) = mrb_int(6)`
| 13 | `OP_LOADI_7` | `B` | `R(a) = mrb_int(7)`
| 14 | `OP_LOADI16` | `BS` | `R(a) = mrb_int(b)`
| 15 | `OP_LOADI32` | `BSS` | `R(a) = mrb_int((b<<16)+c)`
| 16 | `OP_LOADSYM` | `BB` | `R(a) = Syms(b)`
| 17 | `OP_LOADNIL` | `B` | `R(a) = nil`
| 18 | `OP_LOADSELF` | `B` | `R(a) = self`
| 19 | `OP_LOADT` | `B` | `R(a) = true`
| 20 | `OP_LOADF` | `B` | `R(a) = false`
| 21 | `OP_GETGV` | `BB` | `R(a) = getglobal(Syms(b))`
| 22 | `OP_SETGV` | `BB` | `setglobal(Syms(b), R(a))`
| 23 | `OP_GETSV` | `BB` | `R(a) = Special[Syms(b)]`
| 24 | `OP_SETSV` | `BB` | `Special[Syms(b)] = R(a)`
| 25 | `OP_GETIV` | `BB` | `R(a) = ivget(Syms(b))`
| 26 | `OP_SETIV` | `BB` | `ivset(Syms(b),R(a))`
| 27 | `OP_GETCV` | `BB` | `R(a) = cvget(Syms(b))`
| 28 | `OP_SETCV` | `BB` | `cvset(Syms(b),R(a))`
| 29 | `OP_GETCONST` | `BB` | `R(a) = constget(Syms(b))`
| 30 | `OP_SETCONST` | `BB` | `constset(Syms(b),R(a))`
| 31 | `OP_GETMCNST` | `BB` | `R(a) = R(a)::Syms(b)`
| 32 | `OP_SETMCNST` | `BB` | `R(a+1)::Syms(b) = R(a)`
| 33 | `OP_GETUPVAR` | `BBB` | `R(a) = uvget(b,c)`
| 34 | `OP_SETUPVAR` | `BBB` | `uvset(b,c,R(a))`
| 35 | `OP_GETIDX` | `B` | `R(a) = R(a)[R(a+1)]`
| 36 | `OP_SETIDX` | `B` | `R(a)[R(a+1)] = R(a+2)`
| 37 | `OP_JMP` | `S` | `pc+=a`
| 38 | `OP_JMPIF` | `BS` | `if R(a) pc+=b`
| 39 | `OP_JMPNOT` | `BS` | `if !R(a) pc+=b`
| 40 | `OP_JMPNIL` | `BS` | `if R(a)==nil pc+=b`
| 41 | `OP_JMPUW` | `S` | `unwind_and_jump_to(a)`
| 42 | `OP_EXCEPT` | `B` | `R(a) = exc`
| 43 | `OP_RESCUE` | `BB` | `R(b) = R(a).isa?(R(b))`
| 44 | `OP_RAISEIF` | `B` | `raise(R(a)) if R(a)`
| 45 | `OP_SSEND` | `BBB` | `R(a) = self.send(Syms(b),R(a+1)..,R(a+n+1):R(a+n+2)..) (c=n\|k<<4)`
| 46 | `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))`
| 47 | `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)`
| 48 | `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))`
| 49 | `OP_CALL` | `-` | `self.call(*, **, &) (But overlay the current call frame; tailcall)`
| 50 | `OP_SUPER` | `BB` | `R(a) = super(R(a+1),... ,R(a+b+1))`
| 51 | `OP_ARGARY` | `BS` | `R(a) = argument array (16=m5:r1:m5:d1:lv4)`
| 52 | `OP_ENTER` | `W` | `arg setup according to flags (23=m5:o5:r1:m5:k5:d1:b1)`
| 53 | `OP_KEY_P` | `BB` | `R(a) = kdict.key?(Syms(b))`
| 54 | `OP_KEYEND` | `-` | `raise unless kdict.empty?`
| 55 | `OP_KARG` | `BB` | `R(a) = kdict[Syms(b)]; kdict.delete(Syms(b))`
| 56 | `OP_RETURN` | `B` | `return R(a) (normal)`
| 57 | `OP_RETURN_BLK` | `B` | `return R(a) (in-block return)`
| 58 | `OP_BREAK` | `B` | `break R(a)`
| 59 | `OP_BLKPUSH` | `BS` | `R(a) = block (16=m5:r1:m5:d1:lv4)`
| 60 | `OP_ADD` | `B` | `R(a) = R(a)+R(a+1)`
| 61 | `OP_ADDI` | `BB` | `R(a) = R(a)+mrb_int(b)`
| 62 | `OP_SUB` | `B` | `R(a) = R(a)-R(a+1)`
| 63 | `OP_SUBI` | `BB` | `R(a) = R(a)-mrb_int(b)`
| 64 | `OP_MUL` | `B` | `R(a) = R(a)*R(a+1)`
| 65 | `OP_DIV` | `B` | `R(a) = R(a)/R(a+1)`
| 66 | `OP_EQ` | `B` | `R(a) = R(a)==R(a+1)`
| 67 | `OP_LT` | `B` | `R(a) = R(a)<R(a+1)`
| 68 | `OP_LE` | `B` | `R(a) = R(a)<=R(a+1)`
| 69 | `OP_GT` | `B` | `R(a) = R(a)>R(a+1)`
| 70 | `OP_GE` | `B` | `R(a) = R(a)>=R(a+1)`
| 71 | `OP_ARRAY` | `BB` | `R(a) = ary_new(R(a),R(a+1)..R(a+b))`
| 72 | `OP_ARRAY2` | `BBB` | `R(a) = ary_new(R(b),R(b+1)..R(b+c))`
| 73 | `OP_ARYCAT` | `B` | `ary_cat(R(a),R(a+1))`
| 74 | `OP_ARYPUSH` | `BB` | `ary_push(R(a),R(a+1)..R(a+b))`
| 75 | `OP_ARYSPLAT` | `B` | `R(a) = ary_splat(R(a))`
| 76 | `OP_AREF` | `BBB` | `R(a) = R(b)[c]`
| 77 | `OP_ASET` | `BBB` | `R(b)[c] = R(a)`
| 78 | `OP_APOST` | `BBB` | `*R(a),R(a+1)..R(a+c) = R(a)[b..]`
| 79 | `OP_INTERN` | `B` | `R(a) = intern(R(a))`
| 80 | `OP_SYMBOL` | `BB` | `R(a) = intern(Pool(b))`
| 81 | `OP_STRING` | `BB` | `R(a) = str_dup(Pool(b))`
| 82 | `OP_STRCAT` | `B` | `str_cat(R(a),R(a+1))`
| 83 | `OP_HASH` | `BB` | `R(a) = hash_new(R(a),R(a+1)..R(a+b*2-1))`
| 84 | `OP_HASHADD` | `BB` | `hash_push(R(a),R(a+1)..R(a+b*2))`
| 85 | `OP_HASHCAT` | `B` | `R(a) = hash_cat(R(a),R(a+1))`
| 86 | `OP_LAMBDA` | `BB` | `R(a) = lambda(Irep(b),OP_L_LAMBDA)`
| 87 | `OP_BLOCK` | `BB` | `R(a) = lambda(Irep(b),OP_L_BLOCK)`
| 88 | `OP_METHOD` | `BB` | `R(a) = lambda(Irep(b),OP_L_METHOD)`
| 89 | `OP_RANGE_INC` | `B` | `R(a) = range_new(R(a),R(a+1),FALSE)`
| 90 | `OP_RANGE_EXC` | `B` | `R(a) = range_new(R(a),R(a+1),TRUE)`
| 91 | `OP_OCLASS` | `B` | `R(a) = ::Object`
| 92 | `OP_CLASS` | `BB` | `R(a) = newclass(R(a),Syms(b),R(a+1))`
| 93 | `OP_MODULE` | `BB` | `R(a) = newmodule(R(a),Syms(b))`
| 94 | `OP_EXEC` | `BB` | `R(a) = blockexec(R(a),Irep(b))`
| 95 | `OP_DEF` | `BB` | `R(a).newmethod(Syms(b),R(a+1)); R(a) = Syms(b)`
| 96 | `OP_ALIAS` | `BB` | `alias_method(target_class,Syms(a),Syms(b))`
| 97 | `OP_UNDEF` | `B` | `undef_method(target_class,Syms(a))`
| 98 | `OP_SCLASS` | `B` | `R(a) = R(a).singleton_class`
| 99 | `OP_TCLASS` | `B` | `R(a) = target_class`
| 100 | `OP_DEBUG` | `BBB` | `print a,b,c`
| 101 | `OP_ERR` | `B` | `raise(LocalJumpError, Pool(a))`
| 102 | `OP_EXT1` | `-` | `make 1st operand (a) 16bit`
| 103 | `OP_EXT2` | `-` | `make 2nd operand (b) 16bit`
| 104 | `OP_EXT3` | `-` | `make 1st and 2nd operands 16bit`
| 105 | `OP_STOP` | `-` | `stop VM`
+15 -88
View File
@@ -1,3 +1,5 @@
<!-- summary: About the Limitations of mruby -->
# Limitations and Differences
The philosophy of mruby is to be a lightweight implementation of
@@ -64,81 +66,12 @@ p Liste.new "foobar"
#### Ruby [ruby 2.0.0p645 (2015-04-13 revision 50299)]
` [] `
`[]`
#### mruby [3.1.0 (2022-05-12)]
`ArgumentError` is raised.
## Method visibility
For simplicity reasons no method visibility (public/private/protected) is
supported. Those methods are defined, but they are dummy methods.
```ruby
class VisibleTest
def public_method; end
private
def private_method; end
end
p VisibleTest.new.respond_to?(:private_method, false)
p VisibleTest.new.respond_to?(:private_method, true)
```
#### Ruby [ruby 2.0.0p645 (2015-04-13 revision 50299)]
```
false
true
```
#### mruby [3.1.0 (2022-05-12)]
```
true
true
```
### Visibility Declaration
The declaration form of following visibility methods are not implemented.
- `public`
- `private`
- `protected`
- `module_function`
Especially, `module_function` method is not dummy, but no declaration form.
```
module TestModule
module_function
def test_func
p 'test_func called'
end
test_func
end
p 'ok'
```
#### Ruby [ruby 2.5.5p157 (2019-03-15 revision 67260)]
```
ok
```
#### mruby [3.1.0 (2022-05-12)]
```
test.rb:8: undefined method 'test_func' (NoMethodError)
```
## `defined?`
The `defined?` keyword is considered too complex to be fully
@@ -170,7 +103,7 @@ alias $a $__a__
#### Ruby [ruby 2.0.0p645 (2015-04-13 revision 50299)]
` nil `
`nil`
#### mruby [3.1.0 (2022-05-12)]
@@ -196,7 +129,7 @@ The re-defined `+` operator does not accept any arguments.
#### mruby [3.1.0 (2022-05-12)]
` 'ab' `
`'ab'`
Behavior of the operator wasn't changed.
## `Kernel#binding` is not supported until [3.0.0 (2021-03-05)]
@@ -205,26 +138,11 @@ Behavior of the operator wasn't changed.
#### Ruby [ruby 2.5.1p57 (2018-03-29 revision 63029)]
```
```shell
$ ruby -e 'puts Proc.new {}.binding'
#<Binding:0x00000e9deabb9950>
```
#### mruby [3.0.0 (2021-03-05)]
```
$ ./bin/mruby -e 'puts Proc.new {}.binding'
trace (most recent call last):
[0] -e:1
-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.
@@ -259,3 +177,12 @@ f(1,[2,3])
```
CRuby gives `[1,2,3,nil]`. mruby raises `NoMethodError` for `b`.
Keyword argument expansion has similar restrictions. The following example, gives `[1, 1]` for CRuby, mruby raises `NoMethodError` for `b`.
```ruby
def g(a: 1, b: a)
p [a,b]
end
g(a:1)
```
+8 -7
View File
@@ -9,7 +9,7 @@ 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
- `host-m32`: compiles in gcc 32-bit mode on 64-bit platforms
- `boxing`: compiles all three boxing options
- `clang-asan`: compiles with `clang`'s Address Sanitizer
@@ -42,10 +42,10 @@ We have ported some new syntax from CRuby.
## Renamed for consistency
Some configuration macro names are changed for consistency (use `MRB_USE_XXX`
or `MRB_NO_XXX`).
or `MRB_NO_XXX`).
| mruby2 | mruby3 |
|--------------------------------|---------------------------|
| mruby2 | mruby3 |
| ------------------------------ | ------------------------- |
| `MRB_ENABLE_ALL_SYMBOLS` | `MRB_USE_ALL_SYMBOLS` |
| `MRB_ENABLE_CXX_ABI` | `MRB_USE_CXX_ABI` |
| `MRB_ENABLE_CXX_EXCEPTION` | `MRB_USE_CXX_EXCEPTION` |
@@ -62,7 +62,7 @@ Some configuration macro names are changed for consistency (use `MRB_USE_XXX`
- `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.
portable but consumes more memory. Turned on by default on 32-bit platforms.
- `MRB_` prefix is added to those without.
## `MRB_NO_BOXING`
@@ -149,7 +149,8 @@ No more operand extension
## Changed Instructions
Jump addresses used to be specified by absolute offset from the start of `iseq`. Now they are relative offset from the address of the next instruction.
Jump addresses used to be specified by absolute offset from the start of `iseq`. Now they are relative offset from the
address of the next instruction.
## `Random` now use `xoshiro128++`.
@@ -159,4 +160,4 @@ For better and faster random number generation.
Preallocated symbols are interned at compile-time. They can be accessed via symbols macros (e.g. `MRB_SYM()`).
See [Symbols](https://github.com/mruby/mruby/blob/master/doc/guides/symbol.md).
See [Symbols](guides/symbol.md).
+26 -26
View File
@@ -37,7 +37,7 @@ We have added several new build configurations in the `build_config` directory.
- `nintendo_switch.rb`
- `serenity.rb`
- `minimal`: minimal configuration
- `host-f32`: compiles with `mrb_float` as 32 bit `float`
- `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`
@@ -141,8 +141,8 @@ Method calling instructions are unified. Now `OP_SEND` and `OP_SENDB` (method ca
The brief description of the instructions:
|`OP_SEND` | BBB | `R[a] = R[a].call(Syms[b],R[a+1..n],R[a+n+1],R[a+n+2]..nk) c=n|nk<<4` |
|`OP_SENDB` | BBB | `R[a] = R[a].call(Syms[b],R[a+1..n],R[a+n+1..nk],R[a+n+2..nk],&R[a+n+2*nk+2]) c=n|nk<<4` |
|`OP_SEND` | BBB | `R[a] = R[a].call(Syms[b],R[a+1..n],R[a+n+1],R[a+n+2]..nk) c=n|nk<<4` |
|`OP_SENDB` | BBB | `R[a] = R[a].call(Syms[b],R[a+1..n],R[a+n+1..nk],R[a+n+2..nk],&R[a+n+2*nk+2]) c=n|nk<<4` |
Operand C specifies the number of arguments. Lower 4 bits (`n`) represents the number of ordinal arguments, and higher 4 bits (`nk`) represents the number of keyword arguments.
When `n == 15`, the method takes arguments packed in an array. When `nk == 15`, the method takes keyword arguments are packed in a hash.
@@ -225,31 +225,31 @@ For better and faster hash values.
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)
- [CVE-2021-4110](https://www.cve.org/CVERecord?id=CVE-2021-4110)
- [CVE-2021-4188](https://www.cve.org/CVERecord?id=CVE-2021-4188)
- [CVE-2022-0080](https://www.cve.org/CVERecord?id=CVE-2022-0080)
- [CVE-2022-0240](https://www.cve.org/CVERecord?id=CVE-2022-0240)
- [CVE-2022-0326](https://www.cve.org/CVERecord?id=CVE-2022-0326)
- [CVE-2022-0481](https://www.cve.org/CVERecord?id=CVE-2022-0481)
- [CVE-2022-0631](https://www.cve.org/CVERecord?id=CVE-2022-0631)
- [CVE-2022-0632](https://www.cve.org/CVERecord?id=CVE-2022-0632)
- [CVE-2022-0890](https://www.cve.org/CVERecord?id=CVE-2022-0890)
- [CVE-2022-1071](https://www.cve.org/CVERecord?id=CVE-2022-1071)
- [CVE-2022-1106](https://www.cve.org/CVERecord?id=CVE-2022-1106)
- [CVE-2022-1201](https://www.cve.org/CVERecord?id=CVE-2022-1201)
- [CVE-2022-1427](https://www.cve.org/CVERecord?id=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)
- [CVE-2022-0481](https://www.cve.org/CVERecord?id=CVE-2022-0481)
- [CVE-2022-0525](https://www.cve.org/CVERecord?id=CVE-2022-0525)
- [CVE-2022-0570](https://www.cve.org/CVERecord?id=CVE-2022-0570)
- [CVE-2022-0614](https://www.cve.org/CVERecord?id=CVE-2022-0614)
- [CVE-2022-0623](https://www.cve.org/CVERecord?id=CVE-2022-0623)
- [CVE-2022-0630](https://www.cve.org/CVERecord?id=CVE-2022-0630)
- [CVE-2022-0717](https://www.cve.org/CVERecord?id=CVE-2022-0817)
- [CVE-2022-1212](https://www.cve.org/CVERecord?id=CVE-2022-1212)
- [CVE-2022-1276](https://www.cve.org/CVERecord?id=CVE-2022-1276)
- [CVE-2022-1286](https://www.cve.org/CVERecord?id=CVE-2022-1286)
+40 -22
View File
@@ -32,30 +32,48 @@
## 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]
- 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>
- mruby-data
# Breaking Changes
## `mrb_vm_run()` may detach top-level local variables referenced from blocks
When the `mrb_vm_run()` function (including `mrb_top_run()`) is called,
the previous top-level local variables referenced from blocks is detached under either of the following conditions.
- If the `stack_keep` parameter is given as 0.
- If the number of variables in `irep` to be executed is less than the number of previous top-level local variables.
This change also affects API functions such as `mrb_load_string()` and `mrb_load_file()`.
The conditions under which the previous top-level local variables referenced from blocks is detached in these functions are as follows:
- If the function has no `mrbc_context` pointer parameter, or the `mrbc_context` pointer parameter is set to `NULL`.
- If the number of variables held in the `mrbc_context` pointer is less than the number of previous top-level local variables.
Intentional reliance on previous behavior may cause compatibility problems in your application.
# 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)
- [CVE-2022-0080](https://www.cve.org/CVERecord?id=CVE-2022-0080)
- [CVE-2022-0240](https://www.cve.org/CVERecord?id=CVE-2022-0240)
- [CVE-2022-0326](https://www.cve.org/CVERecord?id=CVE-2022-0326)
- [CVE-2022-0481](https://www.cve.org/CVERecord?id=CVE-2022-0481)
- [CVE-2022-0525](https://www.cve.org/CVERecord?id=CVE-2022-0525)
- [CVE-2022-0570](https://www.cve.org/CVERecord?id=CVE-2022-0570)
- [CVE-2022-0614](https://www.cve.org/CVERecord?id=CVE-2022-0614)
- [CVE-2022-0623](https://www.cve.org/CVERecord?id=CVE-2022-0623)
- [CVE-2022-0630](https://www.cve.org/CVERecord?id=CVE-2022-0630)
- [CVE-2022-0631](https://www.cve.org/CVERecord?id=CVE-2022-0631)
- [CVE-2022-0632](https://www.cve.org/CVERecord?id=CVE-2022-0632)
- [CVE-2022-0717](https://www.cve.org/CVERecord?id=CVE-2022-0717)
- [CVE-2022-0890](https://www.cve.org/CVERecord?id=CVE-2022-0890)
- [CVE-2022-1106](https://www.cve.org/CVERecord?id=CVE-2022-1106)
- [CVE-2022-1212](https://www.cve.org/CVERecord?id=CVE-2022-1212)
- [CVE-2022-1276](https://www.cve.org/CVERecord?id=CVE-2022-1276)
- [CVE-2022-1286](https://www.cve.org/CVERecord?id=CVE-2022-1286)
- [CVE-2022-1934](https://www.cve.org/CVERecord?id=CVE-2022-1934)
+186
View File
@@ -0,0 +1,186 @@
# User visible changes in `mruby3.3` from `mruby3.2`
"**_NOTE_**:" are changes to be aware of.
# The language
- aliases work properly with `super` ([2ad3f0e](https://github.com/mruby/mruby/commit/2ad3f0e))
- `callee` method work differently with aliases in mruby ([f2dc76e](https://github.com/mruby/mruby/commit/f2dc76e))
- define `Kernel#respond_to_missing?` method ([347586e](https://github.com/mruby/mruby/commit/347586e))
- `_inspect` method (`inspect` with recursive check) is removed
([e2bbf75](https://github.com/mruby/mruby/commit/e2bbf75), [5cb0c74](https://github.com/mruby/mruby/commit/5cb0c74), [113565a](https://github.com/mruby/mruby/commit/113565a),
[0713f2a](https://github.com/mruby/mruby/commit/0713f2a), [6ae6b63](https://github.com/mruby/mruby/commit/6ae6b63), [fc9fffc](https://github.com/mruby/mruby/commit/fc9fffc))
- `__printstr__` method is removed; use `print` instead
([acecee0](https://github.com/mruby/mruby/commit/acecee0), [192e6e3](https://github.com/mruby/mruby/commit/192e6e3))
- New method `String#bytesplice` ([5274647](https://github.com/mruby/mruby/commit/5274647), [a2e2e83](https://github.com/mruby/mruby/commit/a2e2e83))
- Allow `return` in blocks to cross C boundaries ([#6125](https://github.com/mruby/mruby/pull/6125))
# Configuration
- mruby can be built using Docker now. Try `docker-compose build` for example. ([#5961](https://github.com/mruby/mruby/pull/5961))
- New Platform: DJGPP (MS-DOS) ([#6022](https://github.com/mruby/mruby/pull/6022))
- New Platform: Nintendo Wii ([#6086](https://github.com/mruby/mruby/pull/6086))
- Improved Platform: Android ([#6013](https://github.com/mruby/mruby/pull/6013))
- Improved Platform: Dreamcast ([#6130](https://github.com/mruby/mruby/pull/6130))
- Allow tests to be disabled for specific gems; warn about disabled tests ([#6012](https://github.com/mruby/mruby/pull/6012))
- Replace `MRB_NO_DIRECT_THREADING` with `MRB_USE_VM_SWITCH_DISPATCH` ([#5902](https://github.com/mruby/mruby/pull/5902))
# mruby memory API
- `mrb_default_allocf` can be overridden by the application ([34c5d96](https://github.com/mruby/mruby/commit/34c5d96))
- `mrb_open_allocf` will be deprecated ([cfee5c2](https://github.com/mruby/mruby/commit/cfee5c2))
# Changes in C API
- add new error handling API functions ([8c8bbd9](https://github.com/mruby/mruby/commit/8c8bbd9))
- Add `mrb_vm_ci_env_clear()` function with `MRB_API` ([#5945](https://github.com/mruby/mruby/pull/5945))
- a new function `mrb_check_frozen_value()` ([ccdf75c](https://github.com/mruby/mruby/commit/ccdf75c))
- avoid formatting in `mrb_bug()` ([82a48bd](https://github.com/mruby/mruby/commit/82a48bd)) <br>
**_NOTE_**: If you are using it, you must give a simple string or replace it with a call to `mrb_raise()` series.
- stop using `mrbc_` prefix for compiler context ([c5e3cbe](https://github.com/mruby/mruby/commit/c5e3cbe)) <br>
The same names are provided as before, but we recommend replacing them.
- Allow `Class#allocate` to be prohibited
([#5979](https://github.com/mruby/mruby/pull/5979), [#6122](https://github.com/mruby/mruby/pull/6122), [#6123](https://github.com/mruby/mruby/pull/6123)) <br>
To disable `#allocate`, use `MRB_UNDEF_ALLOCATOR()`.
This is also automatically applied when the subclass is created, but to explicitly allow it, use `MRB_DEFINE_ALLOCATOR()`.
# Changes in mrbgems
- **default.gembox**: Add mruby debugger mrdb (`mruby-bin-debugger`) ([#5966](https://github.com/mruby/mruby/pull/5966))
- **mruby-bin-config**: new options `--cxx`, `--cxxflags`, `--as`, `--asflags`, `--objc`, `--objcflags` ([#6054](https://github.com/mruby/mruby/pull/6054))
- **mruby-binding**: renamed from `mruby-binding-core` of mruby3.2 ([11af5db](https://github.com/mruby/mruby/commit/11af5db)) <br>
**_NOTE_**: If using `mruby-binding-core` of mruby 3.2, replace it with `mruby-binding`.
- **mruby-binding**: implemented `Binding#initialize_copy` method ([#5517](https://github.com/mruby/mruby/pull/5517))
- **mruby-binding**: `Kernel#binding` responds only to calls from Ruby ([#5981](https://github.com/mruby/mruby/pull/5981))
- **mruby-compar-ext**: Comparable#clamp to accept nil as arguments ([836bebc](https://github.com/mruby/mruby/commit/836bebc))
- **mruby-compiler**: add print name for identifier tokens ([d7b2e3a](https://github.com/mruby/mruby/commit/d7b2e3a))
- **mruby-data**: allow empty Data ([927a9df](https://github.com/mruby/mruby/commit/927a9df))
- **mruby-enumerator**: remove internal attribute methods `obj`, `args`, `kwd`, `meth`, `fib`. ([735fa24](https://github.com/mruby/mruby/commit/735fa24))
- **mruby-enumerator**: add Enumerator#size ([861f8bd](https://github.com/mruby/mruby/commit/861f8bd))
- **mruby-eval**: merged `mruby-binding` of mruby3.2 ([501b22a](https://github.com/mruby/mruby/commit/501b22a), [#5989](https://github.com/mruby/mruby/pull/5989)) <br>
**_NOTE_**: If using `mruby-binding` of mruby 3.2, replace it with `mruby-eval`.
- **mruby-fiber**: Add a new `mrb_fiber_new()` with `MRB_API` ([#6097](https://github.com/mruby/mruby/pull/6097))
- **mruby-fiber**: Allows calling `Fiber#resume` from C ([#6106](https://github.com/mruby/mruby/pull/6106))
- **mruby-fiber**: `Fiber#to_s` format changed ([#6105](https://github.com/mruby/mruby/pull/6105))
- **mruby-io**: add File#atime and File#ctime ([321cfe9](https://github.com/mruby/mruby/commit/321cfe9))
- **mruby-io**: Add "x" mode option for `IO.open` ([#6081](https://github.com/mruby/mruby/pull/6081))
- **mruby-io**: File.new should not take blocks ([53de964](https://github.com/mruby/mruby/commit/53de964))
- **mruby-method**: `Method#to_s` format changed ([f5bc82f](https://github.com/mruby/mruby/commit/f5bc82f), [02f189c](https://github.com/mruby/mruby/commit/02f189c))
- **mruby-numeric-ext**: `int.pow(n,m)` to take bigint as exponential ([d482eab](https://github.com/mruby/mruby/commit/d482eab))
- **mruby-pack**: support new directives `j`, `J`, `b`, `B`, `#`
([2a1e3a5](https://github.com/mruby/mruby/commit/2a1e3a5), [e7021f1](https://github.com/mruby/mruby/commit/e7021f1), [e17f325](https://github.com/mruby/mruby/commit/e17f325))
- **mruby-range-ext**: new method `Range#overlap?` ([384d0e2](https://github.com/mruby/mruby/commit/384d0e2))
- **mruby-string-ext**: Add `String#valid_encoding?` method ([eabe2d9](https://github.com/mruby/mruby/commit/eabe2d9))
- **mruby-struct**: allow empty Struct when a name is not given ([c212ede](https://github.com/mruby/mruby/commit/c212ede))
- **mruby-time**: should allow year before 1900 ([e5de08b](https://github.com/mruby/mruby/commit/e5de08b))
- **mruby-time**: support bigint to time_t if necessary ([7096d27](https://github.com/mruby/mruby/commit/7096d27))
- **mruby-time**: need to handle negative time_t ([b064d7e](https://github.com/mruby/mruby/commit/b064d7e))
# Changes in build system
- Extended `rake install` task ([#5928](https://github.com/mruby/mruby/pull/5928)) <br>
**_NOTE_**: Due to this impact, executable files in the `mruby/bin/` directory by default are now symbolic links (batch files on Windows).
If previously relied on those executables, should be replaced with direct references to the entity created under the build directory (e.g. `mruby/build/host/bin/`).
- Encode and decode escape characters for presym ([#6011](https://github.com/mruby/mruby/pull/6011))
- Rakefile: remove default build target directories in `deep_clean` ([#6032](https://github.com/mruby/mruby/pull/6032), [1e38569](https://github.com/mruby/mruby/commit/1e38569))
# Other breaking changes
- `mrb_f_raise()` is now an internal function
([#5923](https://github.com/mruby/mruby/pull/5923), [#6070](https://github.com/mruby/mruby/pull/6070))
- `mrb_make_exception()` is now an internal function with different parameters
([431f83e](https://github.com/mruby/mruby/commit/431f83e), [78137f3](https://github.com/mruby/mruby/commit/78137f3))
- The `File#path` method no longer uses the `#to_path` method for implicit conversion
([d86c4a7](https://github.com/mruby/mruby/commit/d86c4a7))
- stop mrb isolation for each test file ([a20fbe5](https://github.com/mruby/mruby/commit/a20fbe5))
- RBreak remembers the CI location ([#6103](https://github.com/mruby/mruby/pull/6103))
# Bugs Fixed
- [#5724](https://github.com/mruby/mruby/issues/5724) Rational#\*\* is missing
- [#5725](https://github.com/mruby/mruby/issues/5725) weird const_missing exceptions in mrblib code
- [#5789](https://github.com/mruby/mruby/issues/5789) No memory release of backtrace information due to stack error
- [#5932](https://github.com/mruby/mruby/issues/5932) How to create a block using the C API? mrb_yield keeps crashing!
- [#5943](https://github.com/mruby/mruby/issues/5943) TCPSocket#write is failed
- [#5944](https://github.com/mruby/mruby/issues/5944) Behavior of calling method with a hash variable
- [#5946](https://github.com/mruby/mruby/pull/5946) Don't switch constant search path from modules to Object
- [#5949](https://github.com/mruby/mruby/issues/5949) Caller appears to report wrong line when block passed and brackets omitted
- [0906cd7](https://github.com/mruby/mruby/commit/0906cd7) numeric.c: fix rounding function issues with big numbers
- [#5974](https://github.com/mruby/mruby/issues/5974) Invalid escape sequences in gem_init.c on windows
- [#5975](https://github.com/mruby/mruby/issues/5975) Equals comparison fails on extreme ends of 64-bit integers
- [#5985](https://github.com/mruby/mruby/issues/5985) Sign extension with OP_LOADI32 in get_int_operand()
- [#5986](https://github.com/mruby/mruby/issues/5986) Fix bugs in String#bytesplice
- [#5987](https://github.com/mruby/mruby/issues/5987) ~(-1 << 64) is incorrect
- [#5991](https://github.com/mruby/mruby/issues/5991) 'gets' method not working in mruby-3.2.0
- [#5994](https://github.com/mruby/mruby/pull/5994) fix typo in mrbgems/mruby-io/src/io.c
- [#5995](https://github.com/mruby/mruby/issues/5995) One seemingly unnecessary parameter is passed in the block parameters
- [#6008](https://github.com/mruby/mruby/pull/6008) Make "bintest" independent of directory
- [b47c8b7](https://github.com/mruby/mruby/commit/b47c8b7) gc.c (clear_all_old): fix a generational GC bug
- [#6029](https://github.com/mruby/mruby/issues/6029) mruby build fails under mrbgems directory
- [a264965](https://github.com/mruby/mruby/commit/a264965) mruby-os-memsize/memsize.c: fix irep size calculation
- [3310e10](https://github.com/mruby/mruby/commit/3310e10) mruby-test/mrbgem.rake: fix mrb_state handling bug
- [#6041](https://github.com/mruby/mruby/issues/6041) GC Performance may have degraded
- [#6044](https://github.com/mruby/mruby/issues/6044) Generated presym/table.h contains invalid characters
- [#6051](https://github.com/mruby/mruby/issues/6051) Null pointer dereference in mrb_addrinfo_unix_path
- [#6052](https://github.com/mruby/mruby/issues/6052) Null pointer dereference while handling the Proc class
- [#6055](https://github.com/mruby/mruby/pull/6055) Fix libmruby name for VisualC++
- [#6060](https://github.com/mruby/mruby/issues/6060) SEGFAULT Issue Related to Fiber Usage in ngx_mruby Development
- [#6061](https://github.com/mruby/mruby/issues/6061) Performance issue in String#codepoints
- [#6064](https://github.com/mruby/mruby/issues/6064) MRUBY_PACKAGE_DIR does not always have a value.
- [#6065](https://github.com/mruby/mruby/issues/6065) Null pointer dereference while handling the Proc class
- [#6066](https://github.com/mruby/mruby/issues/6066) Null pointer dereference involving Struct.new()
- [#6067](https://github.com/mruby/mruby/issues/6067) Null pointer dereference in mrb_string_value_cstr
- [#6068](https://github.com/mruby/mruby/issues/6068) Stack overflow in mrb_vm_exec
- [#6076](https://github.com/mruby/mruby/pull/6076) Fixed unwinding block that could point to invalid PC
- [#6084](https://github.com/mruby/mruby/issues/6084) Incorrect symbolic sinks in binary built on Linux
- [#6087](https://github.com/mruby/mruby/issues/6087) 'Remote branch HEAD not found in upstream origin' error on build
- [#6089](https://github.com/mruby/mruby/issues/6089) binding.eval() handles def expressions differently from CRuby
- [#6098](https://github.com/mruby/mruby/issues/6098) Fails to call superclass of wrapped method
- [#6099](https://github.com/mruby/mruby/issues/6099) `ensure` section is not executed if the function exits via a return in a proc
- [#6108](https://github.com/mruby/mruby/issues/6108) VM crashes with break
- [#6118](https://github.com/mruby/mruby/pull/6118) Fixed IO#read with buf
- [#6120](https://github.com/mruby/mruby/pull/6120) Set EBADF if check_file_descriptor() fails
- [#6126](https://github.com/mruby/mruby/pull/6126) Fixed return value of `OP_RETURN_BLK` called directly under C function
- [#6134](https://github.com/mruby/mruby/issues/6134) String#unpack1 returns an array instead of a single string
- [#6136](https://github.com/mruby/mruby/pull/6136) Fixed when combined `mrb_fiber_resume()` and `Fiber#transfer`
# Pull Requests (User Visible Ones)
- [#5517](https://github.com/mruby/mruby/pull/5517) Fixed local variables not separated between copied binding objects
- [#5902](https://github.com/mruby/mruby/pull/5902) Replace `MRB_NO_DIRECT_THREADING` with `MRB_USE_VM_SWITCH_DISPATCH`
- [#5923](https://github.com/mruby/mruby/pull/5923) Demotion `mrb_f_raise()` from `MRB_API`
- [#5928](https://github.com/mruby/mruby/pull/5928) Improved `rake install`
- [#5945](https://github.com/mruby/mruby/pull/5945) Avoid exposure for `REnv` objects
- [#5946](https://github.com/mruby/mruby/pull/5946) Don't switch constant search path from modules to Object
- [#5966](https://github.com/mruby/mruby/pull/5966) Update default.gembox add mruby debugger mrdb
- [#5979](https://github.com/mruby/mruby/pull/5979) Allow Class#allocate to be prohibited
- [#5981](https://github.com/mruby/mruby/pull/5981) `Kernel#binding` responds only to calls from Ruby
- [#5989](https://github.com/mruby/mruby/pull/5989) Integrate mruby-binding-eval into mruby-eval
- [#5961](https://github.com/mruby/mruby/pull/5961) Add Docker to build and run all mruby tests. Run pre-commit and generate YARD docs with Docker
- [#5994](https://github.com/mruby/mruby/pull/5994) fix typo in mrbgems/mruby-io/src/io.c
- [#6008](https://github.com/mruby/mruby/pull/6008) Make "bintest" independent of directory
- [#6009](https://github.com/mruby/mruby/pull/6009) Avoid adding <MRUBY_ROOT>/bintest which does not exist
- [#6011](https://github.com/mruby/mruby/pull/6011) Encode and decode escape characters for presym
- [#6012](https://github.com/mruby/mruby/pull/6012) Allow tests to be disabled for specific gems; warn about disabled tests
- [#6013](https://github.com/mruby/mruby/pull/6013) Fix Android toolchain
- [#6022](https://github.com/mruby/mruby/pull/6022) Build configuration for MS-DOS and DJGPP
- [#6032](https://github.com/mruby/mruby/pull/6032) Rake: update task clean to remove bin and build folders
- [#6045](https://github.com/mruby/mruby/pull/6045) Fixes escape sequence bug and enhancements in Presym scanning
- [#6054](https://github.com/mruby/mruby/pull/6054) Extends `bin/mruby-config`
- [#6055](https://github.com/mruby/mruby/pull/6055) Fix libmruby name for VisualC++
- [#6070](https://github.com/mruby/mruby/pull/6070) Demotion mrb_f_raise() in kernel.c from MRB_API too
- [#6076](https://github.com/mruby/mruby/pull/6076) Fixed unwinding block that could point to invalid PC
- [#6081](https://github.com/mruby/mruby/pull/6081) Add "x" mode option for IO.open
- [#6086](https://github.com/mruby/mruby/pull/6086) Add build config for Nintendo Wii
- [#6097](https://github.com/mruby/mruby/pull/6097) Add a new mrb_fiber_new() with MRB_API
- [#6103](https://github.com/mruby/mruby/pull/6103) RBreak remembers the CI location
- [#6105](https://github.com/mruby/mruby/pull/6105) Implement `Fiber#to_s` method
- [#6106](https://github.com/mruby/mruby/pull/6106) Ease fiber limitations
- [#6118](https://github.com/mruby/mruby/pull/6118) Fixed IO#read with buf
- [#6120](https://github.com/mruby/mruby/pull/6120) Set EBADF if check_file_descriptor() fails
- [#6122](https://github.com/mruby/mruby/pull/6122) Prohibit `Class#allocate` in a different way
- [#6123](https://github.com/mruby/mruby/pull/6123) Inherit `MRB_FL_UNDEF_ALLOCATE` in subclasses
- [#6125](https://github.com/mruby/mruby/pull/6125) Allow `OP_RETURN_BLK` to cross C boundaries
- [#6126](https://github.com/mruby/mruby/pull/6126) Fixed return value of `OP_RETURN_BLK` called directly under C function
- [#6130](https://github.com/mruby/mruby/pull/6130) `dreamcast_shelf build config`: complete overhaul
- [#6136](https://github.com/mruby/mruby/pull/6136) Fixed when combined `mrb_fiber_resume()` and `Fiber#transfer`
+251
View File
@@ -0,0 +1,251 @@
# User visible changes in `mruby3.4` from `mruby3.3`
"**_NOTE_**:" are changes to be aware of.
# The language
- mruby now supports `private` and `protected` visibitily ([b0db0bd](https://github.com/mruby/mruby/commit/b0db0bd))
- Maximum length of inlined symbols reduced from 5 to 4 characters to provide space for visibility flags ([6442a01](https://github.com/mruby/mruby/commit/6442a01))
- Many methods are made private according to CRuby visibility ([4a0e806](https://github.com/mruby/mruby/commit/4a0e806))
- Generate OP_SSEND for `self.method` type calls ([111fe4b](https://github.com/mruby/mruby/commit/111fe4b))
- `initialize` method will be always private ([eb8b412](https://github.com/mruby/mruby/commit/eb8b412))
- Add new hooks `method_removed`, `method_undefined` ([9c74f6e](https://github.com/mruby/mruby/commit/9c74f6e))
- Add new hooks `singleton_method_removed`, `singleton_method_undefined` ([0863c08](https://github.com/mruby/mruby/commit/0863c08))
- Updated `OP_DEF` output from codedump ([3a3e877](https://github.com/mruby/mruby/commit/3a3e877))
- Better handling of binary strings, e.g. String#b ([b0127f0](https://github.com/mruby/mruby/commit/b0127f0))
- Hash `to_s` format has changed ([baeeb5e](https://github.com/mruby/mruby/commit/baeeb5e))
- Some encoding related method such as `#force_encoding` ([e47b4ca](https://github.com/mruby/mruby/commit/e47b4ca)), `#b` ([b0127f0](https://github.com/mruby/mruby/commit/b0127f0))
- Constant folding for `String#+` ([6687bdd](https://github.com/mruby/mruby/commit/6687bdd))
- Remove Float bit-operation ([db8368f](https://github.com/mruby/mruby/commit/db8368f))
- use SWAR technique for strlen performance ([cbb31e6](https://github.com/mruby/mruby/commit/cbb31e6))
- use merge sort for `Array#sort` ([5bd63d6](https://github.com/mruby/mruby/commit/5bd63d6))
# Changes in C API
- pool.c renamed to mempool.c (and mrb_pool to mrb_mempool) ([49525fa](https://github.com/mruby/mruby/commit/49525fa))
- mrb_pool_value renamed to mrb_irep_pool to reduce confusion ([62ef5db](https://github.com/mruby/mruby/commit/62ef5db))
- rename BOXNIX_SET_VALUE to BOXNO_SET_VALUE ([#6397](https://github.com/mruby/mruby/pull/6397))
- `MRB_FROZEN_P()` is replaced by `mrb_frozen_p()` ([c11d18e](https://github.com/mruby/mruby/commit/c11d18e))
- rename `color` to `gc_color` ([0e79f6b](https://github.com/mruby/mruby/commit/0e79f6b), [1e36d76](https://github.com/mruby/mruby/commit/1e36d76))
- add `obj->frozen` instead of flags `MRB_SET_FROZEN_FLAG`/`MRB_UNSET_FROZEN_FLAG` ([8276143](https://github.com/mruby/mruby/commit/8276143))
# Build & Configuration
- New Build Target: `test:run:serial`, `test:run:serial:lib`, `test:run:serial:bin` ([#6423](https://github.com/mruby/mruby/pull/6423))
- New Platform: Playstation Portable ([#6022](https://github.com/mruby/mruby/pull/6465))
- New Platform: emscripten ([#6487](https://github.com/mruby/mruby/pull/6487))
- New Config: no-float (with MRB_NO_FLOAT) ([32200f1](https://github.com/mruby/mruby/commit/32200f1))
# Changes in mrbgems
- **mruby-print**: removed; if you do not use `mruby-io`, mruby use `#print` etc. in the core ([8c8bbd9](https://github.com/mruby/mruby/commit/8c8bbd9))
- **mruby-enum-lazy**: Add Enumerable::Lazy#grep_v to mruby-enum-lazy ([#6171](https://github.com/mruby/mruby/pull/6171))
- **mruby-io**: Add `level` argument to `File.dirname` ([#6463](https://github.com/mruby/mruby/pull/6463))
- **mruby-io**: File.absolute_path? ([#6482](https://github.com/mruby/mruby/pull/6482))
- **mruby-io**: File.absolute_path ([96113a2](https://github.com/mruby/mruby/commit/96113a2))
- **mruby-toplevel-ext**: top-level public/private/protected moved to the core ([2a876d2](https://github.com/mruby/mruby/commit/2a876d2))
- **mruby-metaprog**: method list methods now works according to the visibility ([9229da1](https://github.com/mruby/mruby/commit/9229da1))
- **mruby-metaprog**: `public_instance_methods`, `private_instance_methods`, `protected_instance_methods` ([9e3e7b2](https://github.com/mruby/mruby/commit/9e3e7b2))
- **mruby-encoding**: MRB_UTF8_STRING turned on automatically with this gem ([74bdae9](https://github.com/mruby/mruby/commit/74bdae9))
# Fixed GitHub Issues
- [#6173](https://github.com/mruby/mruby/issues/6173) Fails to build with tcc(Tiny C Compiler)
- [#6156](https://github.com/mruby/mruby/issues/6156) '/LIBPATH' issue
- [#6183](https://github.com/mruby/mruby/issues/6183) ".e".to_f returns NAN
- [#6182](https://github.com/mruby/mruby/issues/6182) mrb_read_float() converts "0.3" with a small error compared to strtod()
- [#6210](https://github.com/mruby/mruby/issues/6210) Unary minus seems broken
- [#6255](https://github.com/mruby/mruby/issues/6255) Wrong number of characters in broken UTF-8 string
- [#4038](https://github.com/mruby/mruby/issues/4038) Heap buffer overflow in OP_ENTER
- [#6262](https://github.com/mruby/mruby/issues/6262) Unable to define == for objects when using Array#delete
- [#6267](https://github.com/mruby/mruby/issues/6267) When MRB_UTF8_STRING is enabled, giving byte characters for String#index and String#split gives wrong results
- [#6277](https://github.com/mruby/mruby/issues/6277) MSVC: can't use malloc() in string.c with WIN32_LEAN_AND_MEAN
- [#6240](https://github.com/mruby/mruby/issues/6240) Differentiate between lib and lib64 in the build settings.
- [#6304](https://github.com/mruby/mruby/issues/6304) Calling method_missing with only Kwargs passes arguments incorrectly
- [#6317](https://github.com/mruby/mruby/issues/6317) mrb_gc_register() may cause GC and collect the object being protected
- [#6307](https://github.com/mruby/mruby/issues/6307) Planned change patch for mrb_vm_exec()
- [#6298](https://github.com/mruby/mruby/issues/6298) foo :bar {} is legal in mruby?
- [#6326](https://github.com/mruby/mruby/issues/6326) Detect “Use-after-free” with address sanitizer
- [#5358](https://github.com/mruby/mruby/issues/5358) static warning from getpwnam
- [#6339](https://github.com/mruby/mruby/issues/6339) mrb_ary_delete() may refer to an invalid address (use-after-free)
- [#6346](https://github.com/mruby/mruby/issues/6346) Block kwargs are passed as last positional arg when using yield
- [#6365](https://github.com/mruby/mruby/issues/6365) powl() not available when compiling for Dreamcast
- [#6369](https://github.com/mruby/mruby/issues/6369) 100x Performance Regression from 3.1
- [#6270](https://github.com/mruby/mruby/issues/6270) NODE_ZSUPER from deeply nested blocks will result in a truncated digits for block index in OP_ARGARY
- [#6297](https://github.com/mruby/mruby/issues/6297) Assigning to a block variable changes the actual block (thus affecting block_given? and yield)
- [#6389](https://github.com/mruby/mruby/issues/6389) instance_exec named block args don't work properly
- [#6388](https://github.com/mruby/mruby/issues/6388) Recent commit broke my windows build
- [#6411](https://github.com/mruby/mruby/issues/6411) Wrong function unwinding when using return in a block
- [#6439](https://github.com/mruby/mruby/issues/6439) OP_JMPUW does not call the ensure block when it jumps to the beginning of the begin block
- [#6441](https://github.com/mruby/mruby/issues/6441) break inside while loop will execute the ensure block outside of the while loop
- [#6453](https://github.com/mruby/mruby/issues/6453) Bigint: incorrect behavior of ^ operator
- [#6452](https://github.com/mruby/mruby/issues/6452) Bigint: weird mod behavior
- [#6451](https://github.com/mruby/mruby/issues/6451) Bigint: incorrect division behavior
- [#6456](https://github.com/mruby/mruby/issues/6456) bigint: bug with division of a small number by a bigint
- [#6466](https://github.com/mruby/mruby/issues/6466) mruby-bin-mruby using Kernel#p and Kernel#print in bintest fails test
- [#6467](https://github.com/mruby/mruby/issues/6467) Heap-Use-After-Free due to Recursive group_by Calls
- [#6471](https://github.com/mruby/mruby/issues/6471) Discrepancy in codegen for binary operations between master branch and 3.3.0
- [#6477](https://github.com/mruby/mruby/issues/6477) heap-buffer-overflow in mrb_vm_exec
- [#6485](https://github.com/mruby/mruby/issues/6485) Hash#rehash does not check if the hash is frozen
- [#6483](https://github.com/mruby/mruby/issues/6483) Hash#default_proc= accepts arbitrary objects that are not callable
- [#6491](https://github.com/mruby/mruby/issues/6491) Destroy existing string literals when composing string literals
# Merged Pull Requests (User Visible Ones)
- [#6171](https://github.com/mruby/mruby/pull/6171) Add Enumerable::Lazy#grep_v to mruby-enum-lazy
- [#6174](https://github.com/mruby/mruby/pull/6174) Fix MRUBY_PACKAGE_DIR in mruby-config.bat
- [#6175](https://github.com/mruby/mruby/pull/6175) Corrected strange conditional in mrb_vm_run()
- [#6176](https://github.com/mruby/mruby/pull/6176) Stop assuming alias proc in CI_PROC_SET()
- [#6177](https://github.com/mruby/mruby/pull/6177) gha: add macOS 14 to the build
- [#6184](https://github.com/mruby/mruby/pull/6184) Remove the L_STOP label
- [#6185](https://github.com/mruby/mruby/pull/6185) Added mrb_callinfo::u.keep_context for clarity
- [#6186](https://github.com/mruby/mruby/pull/6186) Omit NULL check of e->cxt in OP_RETURN_BLK
- [#6191](https://github.com/mruby/mruby/pull/6191) Speed up symbol equality comparison
- [#6192](https://github.com/mruby/mruby/pull/6192) Fix `OP_STOP` with exception
- [#6193](https://github.com/mruby/mruby/pull/6193) Fix wrong assertion in `OP_SENDB`.
- [#6194](https://github.com/mruby/mruby/pull/6194) Simplify the calculation of the number of closures in `MRB_TT_FIBER`
- [#6197](https://github.com/mruby/mruby/pull/6197) Fix int_xor to call flo_xor.
- [#6201](https://github.com/mruby/mruby/pull/6201) tasks/doc.rake: standardize the `rake doc` error messages
- [#6202](https://github.com/mruby/mruby/pull/6202) Remove the `.yardoc` folder with `rake doc:clean:api`
- [#6204](https://github.com/mruby/mruby/pull/6204) Clean up the `.editorconfig` file
- [#6209](https://github.com/mruby/mruby/pull/6209) Minor `.gitignore` clean up
- [#6211](https://github.com/mruby/mruby/pull/6211) Minor `.gitignore` clean up; order entries
- [#6216](https://github.com/mruby/mruby/pull/6216) Shared empty `iv_tbl` of module
- [#6217](https://github.com/mruby/mruby/pull/6217) Strict declaration for `mrb_istruct_size()`
- [#6219](https://github.com/mruby/mruby/pull/6219) Avoid assigning a fixed value in the loop
- [#6220](https://github.com/mruby/mruby/pull/6220) Reorganize `mrb_cache_entry` and `mrb_method_t` types
- [#6221](https://github.com/mruby/mruby/pull/6221) Arranging `each_backtrace()`
- [#6222](https://github.com/mruby/mruby/pull/6222) Need to synchronize `dbg->regs` after VM call in `mrdb`
- [#6224](https://github.com/mruby/mruby/pull/6224) `mrb_env_unshare()` to break the link to fiber
- [#6225](https://github.com/mruby/mruby/pull/6225) Revert "Adjust environment when `mrb_exec_irep` happened."
- [#6227](https://github.com/mruby/mruby/pull/6227) fix: `Array#shuffle(!)` result distribution
- [#6228](https://github.com/mruby/mruby/pull/6228) Revert "`env` referred from top-level callinfo should not be unshared; fix #4019"
- [#6230](https://github.com/mruby/mruby/pull/6230) Fix status of fiber after switched by exception raised
- [#6231](https://github.com/mruby/mruby/pull/6231) Add a way to let other gems handle closing of fds in mruby-io
- [#6232](https://github.com/mruby/mruby/pull/6232) Fold the code for freeing `env`
- [#6233](https://github.com/mruby/mruby/pull/6233) Free stack memory at end of fiber
- [#6235](https://github.com/mruby/mruby/pull/6235) fix `Array#delete` always firing the block when deleting `nil`
- [#6236](https://github.com/mruby/mruby/pull/6236) unify the code for filter methods (and speed up `#reject!`)
- [#6237](https://github.com/mruby/mruby/pull/6237) Stricter env objects to attach to ci
- [#6238](https://github.com/mruby/mruby/pull/6238) Minimize zero initialization of the stack
- [#6243](https://github.com/mruby/mruby/pull/6243) Fixed base64 decoding in `mruby-pack`
- [#6244](https://github.com/mruby/mruby/pull/6244) Revise scope of role of `mrb_vm_run()`
- [#6246](https://github.com/mruby/mruby/pull/6246) Fix typo in `test/t/hash.rb`
- [#6249](https://github.com/mruby/mruby/pull/6249) Fix grammar in `src/vm.c`; `catched` -> `caught`
- [#6250](https://github.com/mruby/mruby/pull/6250) Fix spelling
- [#6251](https://github.com/mruby/mruby/pull/6251) Clean up root move `CODEOWNERS` to `.github` directory
- [#6253](https://github.com/mruby/mruby/pull/6253) Allow recycling fibers by GC if not referenced directly
- [#6256](https://github.com/mruby/mruby/pull/6256) Update documentation for `mrb_top_run()`
- [#6257](https://github.com/mruby/mruby/pull/6257) fix some mrbconf.md typos
- [#6260](https://github.com/mruby/mruby/pull/6260) Remove `exc_caught` from `mrb_vm_exec()`
- [#6261](https://github.com/mruby/mruby/pull/6261) fix: `to_a` integer ranges with `begin > end` failing
- [#6263](https://github.com/mruby/mruby/pull/6263) fix: `Array#delete` mistakenly calling block even if not passed
- [#6264](https://github.com/mruby/mruby/pull/6264) Must pass keyword arguments for `Kernel#to_enum`
- [#6265](https://github.com/mruby/mruby/pull/6265) Fixes `Dir.children` and `Dir.each_child`
- [#6266](https://github.com/mruby/mruby/pull/6266) Passes the nonexistent key as a block argument in `Array#delete`
- [#6273](https://github.com/mruby/mruby/pull/6273) Improvements to `mrb_protect_atexit()`
- [#6275](https://github.com/mruby/mruby/pull/6275) Fixed `Binding#eval` that failed to assign to the same variable
- [#6276](https://github.com/mruby/mruby/pull/6276) Always run `atexit` on the top-level call frame
- [#6279](https://github.com/mruby/mruby/pull/6279) Include headers for malloc() explicitly; fix #6277
- [#6280](https://github.com/mruby/mruby/pull/6280) Remove `MRB_ENV_CLOSED` flag
- [#6281](https://github.com/mruby/mruby/pull/6281) Fixes local variables in `mruby-binding`.
- [#6283](https://github.com/mruby/mruby/pull/6283) Simplify `uvenv()`
- [#6288](https://github.com/mruby/mruby/pull/6288) Detach `env` of ci explicitly on atexit
- [#6289](https://github.com/mruby/mruby/pull/6289) Simplify `OP_RETURN_BLK` and `OP_BREAK`
- [#6290](https://github.com/mruby/mruby/pull/6290) Allow to change the output directory name of the `libmruby` file
- [#6293](https://github.com/mruby/mruby/pull/6293) Changed the instruction table in `opcode.md`
- [#6294](https://github.com/mruby/mruby/pull/6294) Optimise `mrb_iv_get`
- [#6302](https://github.com/mruby/mruby/pull/6302) Minor cleanup in mrb_str_init
- [#6303](https://github.com/mruby/mruby/pull/6303) mrb_str_aset_m() should return replace instead of str
- [#6305](https://github.com/mruby/mruby/pull/6305) Protect keyword arguments in `prepare_missing()`
- [#6308](https://github.com/mruby/mruby/pull/6308) Assume that `MRB_CATCH()` has `mrb->exc` set
- [#6310](https://github.com/mruby/mruby/pull/6310) Doubling the call stack when extending it
- [#6311](https://github.com/mruby/mruby/pull/6311) Added fast-path for positional arguments less than 15 in `OP_SEND`
- [#6312](https://github.com/mruby/mruby/pull/6312) Omit error checking at `OP_RETURN`, `OP_RETURN_BLK` and `OP_BREAK`
- [#6313](https://github.com/mruby/mruby/pull/6313) Fix wrong column number in opcode.md
- [#6314](https://github.com/mruby/mruby/pull/6314) Optimize even?/odd? for big integers
- [#6318](https://github.com/mruby/mruby/pull/6318) Shrink variables in `mrb_vm_exec()`
- [#6320](https://github.com/mruby/mruby/pull/6320) Shrinking the code in `OP_BREAK` and `OP_RETURN_BLK`
- [#6321](https://github.com/mruby/mruby/pull/6321) Avoid warnings in `lib/**/*.rb`
- [#6322](https://github.com/mruby/mruby/pull/6322) Fix mrb_ro_data_p on Intel Mac
- [#6324](https://github.com/mruby/mruby/pull/6324) Remove `localjump_error()`
- [#6327](https://github.com/mruby/mruby/pull/6327) fix ncurses linking issues
- [#6328](https://github.com/mruby/mruby/pull/6328) Fix use-after-free in `obj_free()` for env objects
- [#6329](https://github.com/mruby/mruby/pull/6329) Fix use-after-free in `mrb_obj_alloc()`
- [#6330](https://github.com/mruby/mruby/pull/6330) Add a precondition to call `mrb_env_unshare()`.
- [#6331](https://github.com/mruby/mruby/pull/6331) Restore the GC arena with tests
- [#6332](https://github.com/mruby/mruby/pull/6332) Must not depend on the “host” build to generate `mruby-compiler/core/y.tab.c`
- [#6333](https://github.com/mruby/mruby/pull/6333) Reduce the number of branch instructions in the `heap_p()`
- [#6335](https://github.com/mruby/mruby/pull/6335) Add `return_ci` in `CHECKPOINT_MAIN()` of `OP_RETURN`
- [#6338](https://github.com/mruby/mruby/pull/6338) Need to place static proc objects into 8-byte alignments
- [#6340](https://github.com/mruby/mruby/pull/6340) Fix use-after-free for `Array#<=>`
- [#6341](https://github.com/mruby/mruby/pull/6341) Need to restore the GC arena after some function calls
- [#6344](https://github.com/mruby/mruby/pull/6344) prefer using `mrb_yield` to call block arguments
- [#6347](https://github.com/mruby/mruby/pull/6347) codegen.c,parse.y: remove flattening of `yield` arguments; fix #6346
- [#6348](https://github.com/mruby/mruby/pull/6348) Cancel the warning disablement
- [#6349](https://github.com/mruby/mruby/pull/6349) Perform GC before deleting directories
- [#6350](https://github.com/mruby/mruby/pull/6350) Fixed character encoding conversion function mismatch
- [#6351](https://github.com/mruby/mruby/pull/6351) Remove unnecessary `mrb_gc_arena_restore()`
- [#6353](https://github.com/mruby/mruby/pull/6353) Fix use-after-free in `mrb_ary_delete()`
- [#6356](https://github.com/mruby/mruby/pull/6356) Making splat argument objects invisible from Ruby side
- [#6373](https://github.com/mruby/mruby/pull/6373) Add build config for Milk-V Duo (RISC-V Linux) board
- [#6382](https://github.com/mruby/mruby/pull/6382) Make array objects invisible in `mrb_gc_register()`
- [#6385](https://github.com/mruby/mruby/pull/6385) Small improvements for `mrb_gc_register()`
- [#6386](https://github.com/mruby/mruby/pull/6386) Avoid calling `mrb_gv_set()` from `mrb_gc_unregister()`
- [#6387](https://github.com/mruby/mruby/pull/6387) Small improvements for `mrb_gc_unregister()`
- [#6390](https://github.com/mruby/mruby/pull/6390) Fix use-after-free by `mrb_gc_unregistor()`
- [#6391](https://github.com/mruby/mruby/pull/6391) Fixed argument forwarding in `instance_exec`
- [#6392](https://github.com/mruby/mruby/pull/6392) Fix argument forwarding in `mrb_exec_irep()`
- [#6393](https://github.com/mruby/mruby/pull/6393) Follow-up to #6391
- [#6395](https://github.com/mruby/mruby/pull/6395) Storing method-id inside Symbol#to_proc
- [#6396](https://github.com/mruby/mruby/pull/6396) Milk-V Build Config: update GPIO gem URL
- [#6397](https://github.com/mruby/mruby/pull/6397) boxing_no.h: rename BOXNIX_SET_VALUE -> BOXNO_SET_VALUE
- [#6399](https://github.com/mruby/mruby/pull/6399) Add macOS 15 to the build
- [#6405](https://github.com/mruby/mruby/pull/6405) `io_read`: use `%i` instead of `%d` in call to `mrb_raisef`
- [#6407](https://github.com/mruby/mruby/pull/6407) Allow to exclude specific files in `rake install`
- [#6408](https://github.com/mruby/mruby/pull/6408) Improve compliance with C++ standards
- [#6410](https://github.com/mruby/mruby/pull/6410) Put `#include <stdlib.h>` in `parse.y`
- [#6412](https://github.com/mruby/mruby/pull/6412) Distinguish the call frame of the generator with `OP_RETURN_BLK`
- [#6413](https://github.com/mruby/mruby/pull/6413) Add links to documentation in `README.md`
- [#6415](https://github.com/mruby/mruby/pull/6415) Fix numbered parameters when used as a singleton
- [#6416](https://github.com/mruby/mruby/pull/6416) Optimize the "new" method's iseq
- [#6419](https://github.com/mruby/mruby/pull/6419) Follow Ruby's behavior for numbered parameters in -> {}
- [#6420](https://github.com/mruby/mruby/pull/6420) Update `labeler.yml`: add label for the `tools` directory
- [#6422](https://github.com/mruby/mruby/pull/6422) Add annotations for function names defined in the preprocessor
- [#6423](https://github.com/mruby/mruby/pull/6423) Adding a serialized test task
- [#6427](https://github.com/mruby/mruby/pull/6427) Need to update `ci` variable after re-entry to VM
- [#6428](https://github.com/mruby/mruby/pull/6428) Change the limits of OP_ADDI and OP_SUBI from 0-127 to 0-255.
- [#6429](https://github.com/mruby/mruby/pull/6429) Fix numbered parameters when used as hash keys
- [#6432](https://github.com/mruby/mruby/pull/6432) Moving code in macro arguments out of macros
- [#6434](https://github.com/mruby/mruby/pull/6434) Added document "Layout of the mruby filesystem"
- [#6436](https://github.com/mruby/mruby/pull/6436) Make `rake doc:update-index` prettier friendly
- [#6437](https://github.com/mruby/mruby/pull/6437) Add more details to the pre-commit config
- [#6438](https://github.com/mruby/mruby/pull/6438) Remove unused `MRuby::Build#list_install_excludes` method
- [#6440](https://github.com/mruby/mruby/pull/6440) Fix `redo` keyword
- [#6442](https://github.com/mruby/mruby/pull/6442) Fixed wrong range condition in `OP_JMPUW`
- [#6443](https://github.com/mruby/mruby/pull/6443) Fix NODE_NEGATE for bigints
- [#6444](https://github.com/mruby/mruby/pull/6444) Add test cases for bigints
- [#6446](https://github.com/mruby/mruby/pull/6446) Omit the `_WIN64` definition check
- [#6447](https://github.com/mruby/mruby/pull/6447) Fixed `File.expand_path`
- [#6448](https://github.com/mruby/mruby/pull/6448) Suppress presym in `mruby/ext/io.h` file
- [#6449](https://github.com/mruby/mruby/pull/6449) Using presym in the `mruby-io/src/file_test.c` file
- [#6450](https://github.com/mruby/mruby/pull/6450) Change `MRB_WITH_IO_PREAD_PWRITE` configuration name
- [#6454](https://github.com/mruby/mruby/pull/6454) mruby-bigint: handle rhs bigint in int_mod and int_divmod functions
- [#6455](https://github.com/mruby/mruby/pull/6455) mruby-bigint: fix rounding behavior in mpz_mdiv and mpz_mdivmod functions
- [#6457](https://github.com/mruby/mruby/pull/6457) bigint: fix bug with division of a small number by a bigint
- [#6459](https://github.com/mruby/mruby/pull/6459) `FileTest` is a module
- [#6461](https://github.com/mruby/mruby/pull/6461) To create a release package file in draft
- [#6462](https://github.com/mruby/mruby/pull/6462) Properly cast the return value of `memchr()`
- [#6463](https://github.com/mruby/mruby/pull/6463) Add `level` argument to `File.dirname`
- [#6465](https://github.com/mruby/mruby/pull/6465) Add initial playstation portable crossbuild support
- [#6468](https://github.com/mruby/mruby/pull/6468) Fixed missing changes to `IB_FIND_BY_KEY()` parameter names
- [#6469](https://github.com/mruby/mruby/pull/6469) Add more `const` qualifier for `RProc`
- [#6472](https://github.com/mruby/mruby/pull/6472) Moved tests for `Integer#quo`
- [#6473](https://github.com/mruby/mruby/pull/6473) Hide `mpz_and()` symbol
- [#6473](https://github.com/mruby/mruby/pull/6473) Hide mpz_and() symbol
- [#6474](https://github.com/mruby/mruby/pull/6474) Avoid array object creation with “unknown keyword” error
- [#6475](https://github.com/mruby/mruby/pull/6475) Don't include deleted mruby-print
- [#6478](https://github.com/mruby/mruby/pull/6478) Fixed buffer overrun in function `chars2bytes()`
- [#6479](https://github.com/mruby/mruby/pull/6479) Reimplementation of `File.expand_path` method
- [#6482](https://github.com/mruby/mruby/pull/6482) Add `File.absolute_path?` method
- [#6487](https://github.com/mruby/mruby/pull/6487) Add Emscripten toolchain & build_config
Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.4 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

+13
View File
@@ -0,0 +1,13 @@
version: "3.8"
services:
test:
build:
context: .
command: sh -c 'rake deep_clean && rake -m test:run:serial'
environment:
- MRUBY_CONFIG=ci/gcc-clang
- CC=gcc
- CXX=g++
- LD=gcc
- SKIP=check-executables-have-shebangs
working_dir: /app
@@ -35,7 +35,7 @@ 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) {
if (f == NULL) {
mrb_raise(mrb, E_RUNTIME_ERROR, "uninitialized data");
}
@@ -49,7 +49,7 @@ mrb_foo_set_bar(mrb_state *mrb, mrb_value self)
int v;
f = (struct Foo*)mrb_data_get_ptr(mrb, self, &mrb_foo_type);
if(f == NULL) {
if (f == NULL) {
mrb_raise(mrb, E_RUNTIME_ERROR, "uninitialized data");
}
@@ -10,7 +10,7 @@ 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.
+- TODO-HINT.md <- You are currently viewing this file.
| Remove this from copied directory.
|
+- core/
@@ -21,19 +21,19 @@ The file structure in this example is as follows:
May be depended on by other GEMs.
```
Implementors of own bigints should copy below this directory to another directory and do the following:
Implementers of their 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.
- Rewrite `spec.author`, `spec.license`, `spec.homepage` and `spec.summary` in `<gem-dir>/mrbgem.rake` file to those of your own implementers.
- 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.
It is recommended to use `mrb_static_assert_object_size()` to ensure that the size of the object structure is within six 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.
The name of the top directory of the 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.
Note that there is no need for an initialization function as there is in a 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.
@@ -11,8 +11,6 @@ MRuby::Gem::Specification.new('ruby_extension_example') do |spec|
# Add libraries
# spec.linker.libraries << 'external_lib'
spec.add_dependency('mruby-print', :core => 'mruby-print')
# 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")) }
+7 -20
View File
@@ -18,7 +18,7 @@
#endif
#if defined(MRB_32BIT) && defined(MRB_64BIT)
#error Cannot build for 32 and 64 bit architecture at the same time
#error Cannot build for 32 and 64-bit architecture at the same time
#endif
/* configuration options: */
@@ -48,16 +48,6 @@
//#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 */
#ifndef MRB_USE_METHOD_T_STRUCT
// can't use highest 2 bits of function pointers at least on 32bit
// Windows and 32bit Linux.
# ifdef MRB_32BIT
# define MRB_USE_METHOD_T_STRUCT
# endif
#endif
/* define on big endian machines; used by MRB_NAN_BOXING, etc. */
#ifndef MRB_ENDIAN_BIG
# if (defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN) || \
@@ -83,21 +73,21 @@
/* if defined mruby allocates Float objects in the heap to keep full precision if needed */
//#define MRB_WORDBOX_NO_FLOAT_TRUNCATE
/* add -DMRB_INT32 to use 32bit integer for mrb_int; conflict with MRB_INT64;
/* add -DMRB_INT32 to use 32-bit integer for mrb_int; conflict with MRB_INT64;
Default for 32-bit CPU mode. */
//#define MRB_INT32
/* add -DMRB_INT64 to use 64bit integer for mrb_int; conflict with MRB_INT32;
/* add -DMRB_INT64 to use 64-bit integer for mrb_int; conflict with MRB_INT32;
Default for 64-bit CPU mode (unless using MRB_NAN_BOXING). */
//#define MRB_INT64
/* if no specific integer type is chosen */
#if !defined(MRB_INT32) && !defined(MRB_INT64)
# if defined(MRB_64BIT) && !defined(MRB_NAN_BOXING)
/* Use 64bit integers on 64bit architecture (without MRB_NAN_BOXING) */
/* Use 64-bit integers on 64-bit architecture (without MRB_NAN_BOXING) */
# define MRB_INT64
# else
/* Otherwise use 32bit integers */
/* Otherwise use 32-bit integers */
# define MRB_INT32
# endif
#endif
@@ -170,14 +160,11 @@
//#define MRB_USE_ALL_SYMBOLS /* Symbol.all_symbols */
/* obsolete configurations */
#ifdef MRB_METHOD_T_STRUCT
# define MRB_USE_METHOD_T_STRUCT
#endif
#if defined(DISABLE_STDIO) || defined(MRB_DISABLE_STDIO)
# define MRB_NO_STDIO
#endif
#ifdef MRB_DISABLE_DIRECT_THREADING
# define MRB_NO_DIRECT_THREADING
#if defined(MRB_DISABLE_DIRECT_THREADING) || defined(MRB_NO_DIRECT_THREADING)
# define MRB_USE_VM_SWITCH_DISPATCH
#endif
#if defined(ENABLE_DEBUG) || defined(MRB_ENABLE_DEBUG_HOOK)
# define MRB_USE_DEBUG_HOOK
+69 -53
View File
@@ -1,7 +1,7 @@
/*
** mruby - An embeddable Ruby implementation
**
** Copyright (c) mruby developers 2010-2022
** Copyright (c) mruby developers 2010-
**
** Permission is hereby granted, free of charge, to any person obtaining
** a copy of this software and associated documentation files (the
@@ -139,7 +139,7 @@
#endif
/**
* MRuby C API entry point
* mruby C API entry point
*/
MRB_BEGIN_DECL
@@ -162,11 +162,11 @@ struct mrb_state;
*
* The function pointing it must behave similarly as realloc except:
* - If ptr is NULL it must allocate new space.
* - If s is NULL, ptr must be freed.
* - If size is zero, ptr must be freed.
*
* See @see mrb_default_allocf for the default implementation.
*/
typedef void* (*mrb_allocf) (struct mrb_state *mrb, void*, size_t, void *ud);
typedef void* (*mrb_allocf) (struct mrb_state *mrb, void *ptr, size_t size, void *ud);
#ifndef MRB_FIXED_STATE_ATEXIT_STACK_SIZE
#define MRB_FIXED_STATE_ATEXIT_STACK_SIZE 5
@@ -176,6 +176,7 @@ typedef struct {
uint8_t n:4; /* (15=*) c=n|nk<<4 */
uint8_t nk:4; /* (15=*) */
uint8_t cci; /* called from C function */
uint8_t vis; /* visibility in the current scope */
mrb_sym mid;
const struct RProc *proc;
struct RProc *blk;
@@ -184,6 +185,7 @@ typedef struct {
union {
struct REnv *env;
struct RClass *target_class;
const void *keep_context; /* if NULL, it means that the fiber has switched; for internal use */
} u;
} mrb_callinfo;
@@ -229,22 +231,19 @@ mrb_static_assert_powerof2(MRB_METHOD_CACHE_SIZE);
*/
typedef mrb_value (*mrb_func_t)(struct mrb_state *mrb, mrb_value self);
#ifndef MRB_USE_METHOD_T_STRUCT
typedef uintptr_t mrb_method_t;
#else
typedef struct {
uint8_t flags;
uint32_t flags; /* compatible with mt keys in class.c */
union {
struct RProc *proc;
const struct RProc *proc;
mrb_func_t func;
};
} as;
} mrb_method_t;
#endif
#ifndef MRB_NO_METHOD_CACHE
struct mrb_cache_entry {
struct RClass *c, *c0;
mrb_sym mid;
/* mrb_sym mid; // mid is stored in mrb_method_t::flags */
mrb_method_t m;
};
#endif
@@ -298,7 +297,7 @@ typedef struct mrb_state {
mrb_sym symhash[256];
size_t symcapa;
#ifndef MRB_USE_ALL_SYMBOLS
char symbuf[8]; /* buffer for small symbol names */
char symbuf[8]; /* buffer for small symbol names */
#endif
#ifdef MRB_USE_DEBUG_HOOK
@@ -420,14 +419,17 @@ MRB_API void mrb_prepend_module(mrb_state *mrb, struct RClass *cla, struct RClas
* mrb_define_method(mrb, mrb->kernel_module, "example_method", example_method, MRB_ARGS_NONE());
* }
*
* @param mrb The MRuby state reference.
* @param mrb The mruby state reference.
* @param cla The class pointer where the method will be defined.
* @param name The name of the method being defined.
* @param func The function pointer to the method definition.
* @param aspec The method parameters declaration.
*/
MRB_API void mrb_define_method(mrb_state *mrb, struct RClass *cla, const char *name, mrb_func_t func, mrb_aspec aspec);
MRB_API void mrb_define_method_id(mrb_state *mrb, struct RClass *c, mrb_sym mid, mrb_func_t func, mrb_aspec aspec);
MRB_API void mrb_define_private_method(mrb_state *mrb, struct RClass *cla, const char *name, mrb_func_t func, mrb_aspec aspec);
MRB_API void mrb_define_private_method_id(mrb_state *mrb, struct RClass *c, mrb_sym mid, mrb_func_t func, mrb_aspec aspec);
/**
* Defines a class method.
@@ -448,7 +450,7 @@ MRB_API void mrb_define_method_id(mrb_state *mrb, struct RClass *c, mrb_sym mid,
* foo = mrb_define_class(mrb, "Foo", mrb->object_class);
* mrb_define_class_method(mrb, foo, "bar", bar_method, MRB_ARGS_NONE());
* }
* @param mrb The MRuby state reference.
* @param mrb The mruby state reference.
* @param cla The class where the class method will be defined.
* @param name The name of the class method being defined.
* @param fun The function pointer to the class method definition.
@@ -484,7 +486,7 @@ MRB_API void mrb_define_singleton_method_id(mrb_state *mrb, struct RObject *cla,
* foo = mrb_define_module(mrb, "Foo");
* mrb_define_module_function(mrb, foo, "bar", bar_method, MRB_ARGS_NONE());
* }
* @param mrb The MRuby state reference.
* @param mrb The mruby state reference.
* @param cla The module where the module function will be defined.
* @param name The name of the module function being defined.
* @param fun The function pointer to the module function definition.
@@ -514,7 +516,7 @@ MRB_API void mrb_define_module_function_id(mrb_state *mrb, struct RClass *cla, m
* mrb_value
* mrb_example_gem_final(mrb_state* mrb){
* }
* @param mrb The MRuby state reference.
* @param mrb The mruby state reference.
* @param cla A class or module the constant is defined in.
* @param name The name of the constant being defined.
* @param val The value for the constant.
@@ -798,6 +800,8 @@ MRB_API struct RClass * mrb_module_get_under_id(mrb_state *mrb, struct RClass *o
MRB_API void mrb_notimplement(mrb_state*);
/* a function to be replacement of unimplemented method */
MRB_API mrb_value mrb_notimplement_m(mrb_state*, mrb_value);
/* just return it self */
MRB_API mrb_value mrb_obj_itself(mrb_state*, mrb_value);
/**
* Duplicate an object.
@@ -1017,7 +1021,7 @@ struct mrb_kwargs
/**
* Retrieve arguments from mrb_state.
*
* @param mrb The current MRuby state.
* @param mrb The current mruby state.
* @param format is a list of format specifiers
* @param ... The passing variadic arguments must be a pointer of retrieving type.
* @return the number of arguments retrieved.
@@ -1081,7 +1085,7 @@ MRB_API mrb_bool mrb_block_given_p(mrb_state *mrb);
*
* #include <stdio.h>
* #include <mruby.h>
* #include "mruby/compile.h"
* #include <mruby/compile.h>
*
* int
* main()
@@ -1112,7 +1116,7 @@ MRB_API mrb_value mrb_funcall_id(mrb_state *mrb, mrb_value val, mrb_sym mid, mrb
*
* #include <stdio.h>
* #include <mruby.h>
* #include "mruby/compile.h"
* #include <mruby/compile.h>
* int
* main()
* {
@@ -1141,8 +1145,9 @@ MRB_API mrb_value mrb_funcall_argv(mrb_state *mrb, mrb_value val, mrb_sym name,
*/
MRB_API mrb_value mrb_funcall_with_block(mrb_state *mrb, mrb_value val, mrb_sym name, mrb_int argc, const mrb_value *argv, mrb_value block);
/**
* Create a symbol from C string. But usually it's better to use MRB_SYM,
* MRB_OPSYM, MRB_CVSYM, MRB_IVSYM, MRB_SYM_B, MRB_SYM_Q, MRB_SYM_E macros.
* Create a symbol from C string. But usually it's better to
* use MRB_SYM, MRB_OPSYM, MRB_CVSYM, MRB_IVSYM, MRB_GVSYM,
* MRB_SYM_B, MRB_SYM_Q, MRB_SYM_E macros.
*
* Example:
*
@@ -1248,7 +1253,7 @@ MRB_API mrb_state* mrb_open(void);
MRB_API mrb_state* mrb_open_allocf(mrb_allocf f, void *ud);
/**
* Create new mrb_state with just the MRuby core
* Create new mrb_state with just the mruby core
*
* @param f
* Reference to the allocation function.
@@ -1277,7 +1282,29 @@ MRB_API void mrb_close(mrb_state *mrb);
MRB_API void* mrb_default_allocf(mrb_state*, void*, size_t, void*);
MRB_API mrb_value mrb_top_self(mrb_state *mrb);
/**
* Enter the mruby VM and execute the proc.
*
* @param mrb
* The current mruby state.
* @param proc
* An object containing `irep`.
* If supplied an object containing anything other than `irep`, it will probably crash.
* @param self
* `self` on the execution context of `proc`.
* @param stack_keep
* Specifies the number of values to hold from the stack top.
* Values on the stack outside this range will be initialized to `nil`.
*
* @note
* When called from a C function defined as a method, the current stack is destroyed.
* If you want to use arguments obtained by `mrb_get_args()` or other methods after `mrb_top_run()`,
* you must protect them by `mrb_gc_protect()` or other ways before this function.
* Or consider using `mrb_yield()` family functions.
*/
MRB_API mrb_value mrb_top_run(mrb_state *mrb, const struct RProc *proc, mrb_value self, mrb_int stack_keep);
MRB_API mrb_value mrb_vm_run(mrb_state *mrb, const struct RProc *proc, mrb_value self, mrb_int stack_keep);
MRB_API mrb_value mrb_vm_exec(mrb_state *mrb, const struct RProc *proc, const mrb_code *iseq);
/* compatibility macros */
@@ -1303,26 +1330,17 @@ MRB_API mrb_bool mrb_eql(mrb_state *mrb, mrb_value obj1, mrb_value obj2);
/* mrb_cmp(mrb, obj1, obj2): 1:0:-1; -2 for error */
MRB_API mrb_int mrb_cmp(mrb_state *mrb, mrb_value obj1, mrb_value obj2);
MRB_INLINE int
mrb_gc_arena_save(mrb_state *mrb)
{
return mrb->gc.arena_idx;
}
MRB_INLINE void
mrb_gc_arena_restore(mrb_state *mrb, int idx)
{
mrb->gc.arena_idx = idx;
}
#define mrb_gc_arena_save(mrb) ((mrb)->gc.arena_idx)
#define mrb_gc_arena_restore(mrb, idx) ((mrb)->gc.arena_idx = (idx))
MRB_API void mrb_garbage_collect(mrb_state*);
MRB_API void mrb_full_gc(mrb_state*);
MRB_API void mrb_incremental_gc(mrb_state *);
MRB_API void mrb_incremental_gc(mrb_state*);
MRB_API void mrb_gc_mark(mrb_state*,struct RBasic*);
#define mrb_gc_mark_value(mrb,val) do {\
if (!mrb_immediate_p(val)) mrb_gc_mark((mrb), mrb_basic_ptr(val)); \
} while (0)
MRB_API void mrb_field_write_barrier(mrb_state *, struct RBasic*, struct RBasic*);
MRB_API void mrb_field_write_barrier(mrb_state*, struct RBasic*, struct RBasic*);
#define mrb_field_write_barrier_value(mrb, obj, val) do{\
if (!mrb_immediate_p(val)) mrb_field_write_barrier((mrb), (obj), mrb_basic_ptr(val)); \
} while (0)
@@ -1366,7 +1384,7 @@ MRB_API mrb_noreturn void mrb_name_error(mrb_state *mrb, mrb_sym id, const char
MRB_API mrb_noreturn void mrb_frozen_error(mrb_state *mrb, void *frozen_obj);
MRB_API mrb_noreturn void mrb_argnum_error(mrb_state *mrb, mrb_int argc, int min, int max);
MRB_API void mrb_warn(mrb_state *mrb, const char *fmt, ...);
MRB_API mrb_noreturn void mrb_bug(mrb_state *mrb, const char *fmt, ...);
MRB_API mrb_noreturn void mrb_bug(mrb_state *mrb, const char *mesg);
MRB_API void mrb_print_backtrace(mrb_state *mrb);
MRB_API void mrb_print_error(mrb_state *mrb);
/* function for `raisef` formatting */
@@ -1378,6 +1396,8 @@ MRB_API mrb_value mrb_vformat(mrb_state *mrb, const char *format, va_list ap);
+ exception objects obtained from those macros are local to mrb
*/
#define MRB_ERROR_SYM(sym) mrb_intern_lit(mrb, #sym)
#define E_EXCEPTION mrb->eException_class
#define E_STANDARD_ERROR mrb->eStandardError_class
#define E_RUNTIME_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(RuntimeError))
#define E_TYPE_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(TypeError))
#define E_ZERODIV_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(ZeroDivisionError))
@@ -1436,12 +1456,8 @@ MRB_API mrb_value mrb_ensure_int_type(mrb_state *mrb, mrb_value val);
/* string type checking (contrary to the name, it doesn't convert) */
MRB_API void mrb_check_type(mrb_state *mrb, mrb_value x, enum mrb_vtype t);
MRB_INLINE void mrb_check_frozen(mrb_state *mrb, void *o)
{
if (mrb_frozen_p((struct RBasic*)o)) mrb_frozen_error(mrb, o);
}
MRB_API void mrb_check_frozen(mrb_state *mrb, void *);
MRB_API void mrb_check_frozen_value(mrb_state *mrb, mrb_value v);
MRB_API void mrb_define_alias(mrb_state *mrb, struct RClass *c, const char *a, const char *b);
MRB_API void mrb_define_alias_id(mrb_state *mrb, struct RClass *c, mrb_sym a, mrb_sym b);
MRB_API const char *mrb_class_name(mrb_state *mrb, struct RClass* klass);
@@ -1450,20 +1466,25 @@ MRB_API void mrb_define_global_const(mrb_state *mrb, const char *name, mrb_value
MRB_API mrb_value mrb_attr_get(mrb_state *mrb, mrb_value obj, mrb_sym id);
MRB_API mrb_bool mrb_respond_to(mrb_state *mrb, mrb_value obj, mrb_sym mid);
MRB_API mrb_bool mrb_obj_is_instance_of(mrb_state *mrb, mrb_value obj, struct RClass* c);
MRB_API mrb_bool mrb_obj_is_instance_of(mrb_state *mrb, mrb_value obj, const struct RClass* c);
MRB_API mrb_bool mrb_func_basic_p(mrb_state *mrb, mrb_value obj, mrb_sym mid, mrb_func_t func);
/* obsolete function(s); will be removed */
#define mrb_int(mrb, val) mrb_as_int(mrb, val)
/**
* Create a new Fiber from proc object
*
* Implemented in mruby-fiber
*/
MRB_API mrb_value mrb_fiber_new(mrb_state *mrb, const struct RProc *proc);
/**
* 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);
@@ -1498,13 +1519,6 @@ MRB_API mrb_value mrb_fiber_alive_p(mrb_state *mrb, mrb_value fib);
#define E_FIBER_ERROR mrb_exc_get_id(mrb, MRB_ERROR_SYM(FiberError))
MRB_API void mrb_stack_extend(mrb_state*, mrb_int);
/* memory pool implementation */
typedef struct mrb_pool mrb_pool;
MRB_API struct mrb_pool* mrb_pool_open(mrb_state*);
MRB_API void mrb_pool_close(struct mrb_pool*);
MRB_API void* mrb_pool_alloc(struct mrb_pool*, size_t);
MRB_API void* mrb_pool_realloc(struct mrb_pool*, void*, size_t oldlen, size_t newlen);
MRB_API mrb_bool mrb_pool_can_realloc(struct mrb_pool*, void*, size_t);
/* temporary memory allocation, only effective while GC arena is kept */
MRB_API void* mrb_alloca(mrb_state *mrb, size_t);
@@ -1546,6 +1560,8 @@ mrbmemset(void *s, int c, size_t n)
#define memset(a,b,c) mrbmemset(a,b,c)
#endif
#define mrb_int_hash_func(mrb,key) (uint32_t)((key)^((key)<<2)^((key)>>2))
MRB_END_DECL
#endif /* MRUBY_H */
+10
View File
@@ -98,6 +98,16 @@ mrb_type(mrb_value o)
}
}
MRB_INLINE enum mrb_vtype
mrb_unboxed_type(mrb_value o)
{
if (!mrb_float_p(o) && mrb_nb_tt(o) == MRB_NANBOX_TT_OBJECT && o.u != 0) {
return ((struct RBasic*)(uintptr_t)o.u)->tt;
} else {
return MRB_TT_FALSE;
}
}
#define NANBOX_SET_MISC_VALUE(r,t,i) NANBOX_SET_VALUE(r, MRB_NANBOX_TT_MISC, ((uint64_t)(t)<<32) | (i))
#define mrb_float(o) mrb_nan_boxing_value_float(o)
+20 -19
View File
@@ -26,33 +26,34 @@ typedef struct mrb_value {
enum mrb_vtype tt;
} mrb_value;
#define mrb_ptr(o) (o).value.p
#define mrb_cptr(o) mrb_ptr(o)
#define mrb_ptr(o) (o).value.p
#define mrb_cptr(o) mrb_ptr(o)
#ifndef MRB_NO_FLOAT
#define mrb_float(o) (o).value.f
#define mrb_float(o) (o).value.f
#endif
#define mrb_fixnum(o) (o).value.i
#define mrb_integer(o) mrb_fixnum(o)
#define mrb_symbol(o) (o).value.sym
#define mrb_type(o) (o).tt
#define mrb_fixnum(o) (o).value.i
#define mrb_integer(o) mrb_fixnum(o)
#define mrb_symbol(o) (o).value.sym
#define mrb_type(o) (o).tt
#define mrb_unboxed_type(o) (o).tt
#define BOXNIX_SET_VALUE(o, ttt, attr, v) do {\
#define BOXNO_SET_VALUE(o, ttt, attr, v) do {\
(o).tt = ttt;\
(o).attr = v;\
} while (0)
#define SET_NIL_VALUE(r) BOXNIX_SET_VALUE(r, MRB_TT_FALSE, value.i, 0)
#define SET_FALSE_VALUE(r) BOXNIX_SET_VALUE(r, MRB_TT_FALSE, value.i, 1)
#define SET_TRUE_VALUE(r) BOXNIX_SET_VALUE(r, MRB_TT_TRUE, value.i, 1)
#define SET_BOOL_VALUE(r,b) BOXNIX_SET_VALUE(r, b ? MRB_TT_TRUE : MRB_TT_FALSE, value.i, 1)
#define SET_INT_VALUE(mrb,r,n) BOXNIX_SET_VALUE(r, MRB_TT_INTEGER, value.i, (n))
#define SET_FIXNUM_VALUE(r,n) BOXNIX_SET_VALUE(r, MRB_TT_INTEGER, value.i, (n))
#define SET_NIL_VALUE(r) BOXNO_SET_VALUE(r, MRB_TT_FALSE, value.i, 0)
#define SET_FALSE_VALUE(r) BOXNO_SET_VALUE(r, MRB_TT_FALSE, value.i, 1)
#define SET_TRUE_VALUE(r) BOXNO_SET_VALUE(r, MRB_TT_TRUE, value.i, 1)
#define SET_BOOL_VALUE(r,b) BOXNO_SET_VALUE(r, b ? MRB_TT_TRUE : MRB_TT_FALSE, value.i, 1)
#define SET_INT_VALUE(mrb,r,n) BOXNO_SET_VALUE(r, MRB_TT_INTEGER, value.i, (n))
#define SET_FIXNUM_VALUE(r,n) BOXNO_SET_VALUE(r, MRB_TT_INTEGER, value.i, (n))
#ifndef MRB_NO_FLOAT
#define SET_FLOAT_VALUE(mrb,r,v) BOXNIX_SET_VALUE(r, MRB_TT_FLOAT, value.f, (v))
#define SET_FLOAT_VALUE(mrb,r,v) BOXNO_SET_VALUE(r, MRB_TT_FLOAT, value.f, (v))
#endif
#define SET_SYM_VALUE(r,v) BOXNIX_SET_VALUE(r, MRB_TT_SYMBOL, value.sym, (v))
#define SET_OBJ_VALUE(r,v) BOXNIX_SET_VALUE(r, (((struct RObject*)(v))->tt), value.p, (v))
#define SET_CPTR_VALUE(mrb,r,v) BOXNIX_SET_VALUE(r, MRB_TT_CPTR, value.p, v)
#define SET_UNDEF_VALUE(r) BOXNIX_SET_VALUE(r, MRB_TT_UNDEF, value.i, 0)
#define SET_SYM_VALUE(r,v) BOXNO_SET_VALUE(r, MRB_TT_SYMBOL, value.sym, (v))
#define SET_OBJ_VALUE(r,v) BOXNO_SET_VALUE(r, (((struct RObject*)(v))->tt), value.p, (v))
#define SET_CPTR_VALUE(mrb,r,v) BOXNO_SET_VALUE(r, MRB_TT_CPTR, value.p, v)
#define SET_UNDEF_VALUE(r) BOXNO_SET_VALUE(r, MRB_TT_UNDEF, value.i, 0)
#endif /* MRUBY_BOXING_NO_H */
+15 -2
View File
@@ -80,7 +80,7 @@ enum mrb_special_consts {
/*
* mrb_value representation:
*
* 64bit word with inline float:
* 64-bit word with inline float:
* nil : ...0000 0000 (all bits are 0)
* false : ...0000 0100 (mrb_fixnum(v) != 0)
* true : ...0000 1100
@@ -90,7 +90,7 @@ enum mrb_special_consts {
* float : ...FFFF FF10 (51 bit significands; require MRB_64BIT)
* object: ...PPPP P000
*
* 32bit word with inline float:
* 32-bit word with inline float:
* nil : ...0000 0000 (all bits are 0)
* false : ...0000 0100 (mrb_fixnum(v) != 0)
* true : ...0000 1100
@@ -228,4 +228,17 @@ mrb_type(mrb_value o)
mrb_val_union(o).bp->tt;
}
MRB_INLINE enum mrb_vtype
mrb_unboxed_type(mrb_value o)
{
if (mrb_nil_p(o)) {
return MRB_TT_FALSE;
} else if ((o.w & WORDBOX_IMMEDIATE_MASK) == 0) {
return mrb_val_union(o).bp->tt;
} else {
return MRB_TT_FALSE;
}
}
#endif /* MRUBY_BOXING_WORD_H */
+17 -10
View File
@@ -26,6 +26,10 @@ struct RClass {
MRB_INLINE struct RClass*
mrb_class(mrb_state *mrb, mrb_value v)
{
if (!mrb_immediate_p(v)) {
return mrb_obj_ptr(v)->c;
}
switch (mrb_type(v)) {
case MRB_TT_FALSE:
if (mrb_fixnum(v))
@@ -43,20 +47,19 @@ mrb_class(mrb_state *mrb, mrb_value v)
#endif
case MRB_TT_CPTR:
return mrb->object_class;
case MRB_TT_ENV:
return NULL;
default:
return mrb_obj_ptr(v)->c;
return NULL;
}
}
/* flags:
20: frozen
19: is_prepended
18: is_origin
17: is_inherited (used by method cache)
16: unused
0-15: instance type
20: frozen
19: is_prepended
18: is_origin
17: is_inherited (used by method cache)
7-16: unused
6: prohibit Class#allocate
0-5: instance type
*/
#define MRB_FL_CLASS_IS_PREPENDED (1 << 19)
#define MRB_FL_CLASS_IS_ORIGIN (1 << 18)
@@ -69,9 +72,13 @@ mrb_class(mrb_state *mrb, mrb_value v)
}\
} while (0)
#define MRB_FL_CLASS_IS_INHERITED (1 << 17)
#define MRB_INSTANCE_TT_MASK (0xFF)
#define MRB_INSTANCE_TT_MASK (0x1F)
#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)
#define MRB_FL_UNDEF_ALLOCATE (1 << 6)
#define MRB_UNDEF_ALLOCATOR(c) (mrb_assert((c)->tt == MRB_TT_CLASS), (c)->flags |= MRB_FL_UNDEF_ALLOCATE)
#define MRB_UNDEF_ALLOCATOR_P(c) ((c)->flags & MRB_FL_UNDEF_ALLOCATE)
#define MRB_DEFINE_ALLOCATOR(c) ((c)->flags &= ~MRB_FL_UNDEF_ALLOCATE)
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);
+21 -1
View File
@@ -59,6 +59,26 @@ MRB_BEGIN_DECL
# define mrb_deprecated
#endif
/** Declare a type or object as an alignment requirement. */
#ifndef mrb_alignas
# if defined(__cplusplus) && __cplusplus >= 201103L
# // https://en.cppreference.com/w/cpp/language/alignas
# define mrb_alignas(n) alignas(n)
# elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
# // https://en.cppreference.com/w/c/language/_Alignas
# define mrb_alignas(n) _Alignas(n)
# elif defined(_MSC_VER) || defined(__INTEL_COMPILER)
# // https://learn.microsoft.com/en-us/cpp/cpp/align-cpp?view=msvc-170
# define mrb_alignas(n) __declspec(align(n))
# elif defined(__GNUC__) || defined(__clang__)
# // https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#index-aligned-type-attribute
# define mrb_alignas(n) __attribute__((aligned(n)))
# else
# // `mrb_alignas` defined as dummy. If necessary, send issues to https://github.com/mruby/mruby .
# define mrb_alignas(n)
# endif
#endif
/** Declare a function as always inlined. */
#if defined _MSC_VER && _MSC_VER < 1900
# ifndef __cplusplus
@@ -67,7 +87,7 @@ MRB_BEGIN_DECL
#endif
#define MRB_INLINE static inline
/** Declare a public MRuby API function. */
/** Declare a public mruby API function. */
#ifndef MRB_API
#if defined(MRB_BUILD_AS_DLL)
#if defined(MRB_CORE) || defined(MRB_LIB)
+44 -28
View File
@@ -8,9 +8,10 @@
#define MRUBY_COMPILE_H
#include "common.h"
#include "mruby/mempool.h"
/**
* MRuby Compiler
* mruby Compiler
*/
MRB_BEGIN_DECL
@@ -18,7 +19,7 @@ MRB_BEGIN_DECL
struct mrb_parser_state;
/* load context */
typedef struct mrbc_context {
typedef struct mrb_ccontext {
mrb_sym *syms;
int slen;
char *filename;
@@ -35,13 +36,21 @@ typedef struct mrbc_context {
const struct RProc *upper;
size_t parser_nerr;
} mrbc_context;
} mrb_ccontext; /* compiler context */
MRB_API mrbc_context* mrbc_context_new(mrb_state *mrb);
MRB_API void mrbc_context_free(mrb_state *mrb, mrbc_context *cxt);
MRB_API const char *mrbc_filename(mrb_state *mrb, mrbc_context *c, const char *s);
MRB_API void mrbc_partial_hook(mrb_state *mrb, mrbc_context *c, int (*partial_hook)(struct mrb_parser_state*), void*data);
MRB_API void mrbc_cleanup_local_variables(mrb_state *mrb, mrbc_context *c);
MRB_API mrb_ccontext* mrb_ccontext_new(mrb_state *mrb);
MRB_API void mrb_ccontext_free(mrb_state *mrb, mrb_ccontext *cxt);
MRB_API const char *mrb_ccontext_filename(mrb_state *mrb, mrb_ccontext *c, const char *s);
MRB_API void mrb_ccontext_partial_hook(mrb_state *mrb, mrb_ccontext *c, int (*partial_hook)(struct mrb_parser_state*), void*data);
MRB_API void mrb_ccontext_cleanup_local_variables(mrb_state *mrb, mrb_ccontext *c);
/* compatibility macros */
#define mrbc_context mrb_ccontext
#define mrbc_context_new mrb_ccontext_new
#define mrbc_context_free mrb_ccontext_free
#define mrbc_filename mrb_ccontext_filename
#define mrbc_partial_hook mrb_ccontext_partial_hook
#define mrbc_cleanup_local_variables mrb_ccontext_cleanup_local_variables
/* AST node structure */
typedef struct mrb_ast_node {
@@ -114,14 +123,14 @@ struct mrb_parser_heredoc_info {
/* parser structure */
struct mrb_parser_state {
mrb_state *mrb;
struct mrb_pool *pool;
struct mrb_mempool *pool;
mrb_ast_node *cells;
const char *s, *send;
#ifndef MRB_NO_STDIO
/* If both f and s are non-null, it will be taken preferentially from s until s < send. */
FILE *f;
#endif
mrbc_context *cxt;
mrb_ccontext *cxt;
mrb_sym filename_sym;
uint16_t lineno;
int column;
@@ -168,38 +177,45 @@ struct mrb_parser_state {
MRB_API struct mrb_parser_state* mrb_parser_new(mrb_state*);
MRB_API void mrb_parser_free(struct mrb_parser_state*);
MRB_API void mrb_parser_parse(struct mrb_parser_state*,mrbc_context*);
MRB_API void mrb_parser_parse(struct mrb_parser_state*,mrb_ccontext*);
MRB_API void mrb_parser_set_filename(struct mrb_parser_state*, char const*);
MRB_API mrb_sym mrb_parser_get_filename(struct mrb_parser_state*, uint16_t idx);
/* utility functions */
#ifndef MRB_NO_STDIO
MRB_API struct mrb_parser_state* mrb_parse_file(mrb_state*,FILE*,mrbc_context*);
MRB_API struct mrb_parser_state* mrb_parse_file(mrb_state*,FILE*,mrb_ccontext*);
#endif
MRB_API struct mrb_parser_state* mrb_parse_string(mrb_state*,const char*,mrbc_context*);
MRB_API struct mrb_parser_state* mrb_parse_nstring(mrb_state*,const char*,size_t,mrbc_context*);
MRB_API struct mrb_parser_state* mrb_parse_string(mrb_state*,const char*,mrb_ccontext*);
MRB_API struct mrb_parser_state* mrb_parse_nstring(mrb_state*,const char*,size_t,mrb_ccontext*);
MRB_API struct RProc* mrb_generate_code(mrb_state*, struct mrb_parser_state*);
MRB_API mrb_value mrb_load_exec(mrb_state *mrb, struct mrb_parser_state *p, mrbc_context *c);
MRB_API mrb_value mrb_load_exec(mrb_state *mrb, struct mrb_parser_state *p, mrb_ccontext *c);
/** program load functions
* Please note! Currently due to interactions with the GC calling these functions will
* leak one RProc object per function call.
* To prevent this save the current memory arena before calling and restore the arena
* right after, like so
* int ai = mrb_gc_arena_save(mrb);
* mrb_value status = mrb_load_string(mrb, buffer);
* mrb_gc_arena_restore(mrb, ai);
*/
/**
* program load functions
*
* Please note! Currently due to interactions with the GC calling these functions will
* leak one RProc object per function call.
* To prevent this save the current memory arena before calling and restore the arena
* right after, like so
*
* int ai = mrb_gc_arena_save(mrb);
* mrb_value status = mrb_load_string(mrb, buffer);
* mrb_gc_arena_restore(mrb, ai);
*
* Also, when called from a C function defined as a method, the current stack is destroyed.
* If processing continues after this function, the objects obtained from the arguments
* must be protected as needed before this function.
*/
#ifndef MRB_NO_STDIO
MRB_API mrb_value mrb_load_file(mrb_state*,FILE*);
MRB_API mrb_value mrb_load_file_cxt(mrb_state*,FILE*, mrbc_context *cxt);
MRB_API mrb_value mrb_load_detect_file_cxt(mrb_state *mrb, FILE *fp, mrbc_context *c);
MRB_API mrb_value mrb_load_file_cxt(mrb_state*,FILE*, mrb_ccontext *cxt);
MRB_API mrb_value mrb_load_detect_file_cxt(mrb_state *mrb, FILE *fp, mrb_ccontext *c);
#endif
MRB_API mrb_value mrb_load_string(mrb_state *mrb, const char *s);
MRB_API mrb_value mrb_load_nstring(mrb_state *mrb, const char *s, size_t len);
MRB_API mrb_value mrb_load_string_cxt(mrb_state *mrb, const char *s, mrbc_context *cxt);
MRB_API mrb_value mrb_load_nstring_cxt(mrb_state *mrb, const char *s, size_t len, mrbc_context *cxt);
MRB_API mrb_value mrb_load_string_cxt(mrb_state *mrb, const char *s, mrb_ccontext *cxt);
MRB_API mrb_value mrb_load_nstring_cxt(mrb_state *mrb, const char *s, size_t len, mrb_ccontext *cxt);
/** @} */
MRB_END_DECL
+2 -2
View File
@@ -41,12 +41,12 @@ MRB_API struct RData *mrb_data_object_alloc(mrb_state *mrb, struct RClass* klass
#define Data_Make_Struct(mrb,klass,strct,type,sval,data_obj) do { \
(data_obj) = Data_Wrap_Struct(mrb,klass,type,NULL);\
(sval) = (strct *)mrb_malloc(mrb, sizeof(strct)); \
(sval) = (strct*)mrb_malloc(mrb, sizeof(strct)); \
{ static const strct zero = { 0 }; *(sval) = zero; };\
(data_obj)->data = (sval);\
} while (0)
#define RDATA(obj) ((struct RData *)(mrb_ptr(obj)))
#define RDATA(obj) ((struct RData*)(mrb_ptr(obj)))
#define DATA_PTR(d) (RDATA(d)->data)
#define DATA_TYPE(d) (RDATA(d)->type)
MRB_API void mrb_data_check_type(mrb_state *mrb, mrb_value, const mrb_data_type*);
+8 -2
View File
@@ -10,7 +10,7 @@
#include "common.h"
/**
* MRuby Debugging.
* mruby Debugging.
*/
MRB_BEGIN_DECL
@@ -46,7 +46,7 @@ typedef struct mrb_irep_debug_info {
} mrb_irep_debug_info;
/*
* get line from irep's debug info and program counter
* get filename from irep's debug info and program counter
* @return returns NULL if not found
*/
MRB_API const char *mrb_debug_get_filename(mrb_state *mrb, const mrb_irep *irep, uint32_t pc);
@@ -57,6 +57,12 @@ MRB_API const char *mrb_debug_get_filename(mrb_state *mrb, const mrb_irep *irep,
*/
MRB_API int32_t mrb_debug_get_line(mrb_state *mrb, const mrb_irep *irep, uint32_t pc);
/*
* get line and filename from irep's debug info and program counter
* @return returns FALSE if not found
*/
MRB_API mrb_bool mrb_debug_get_position(mrb_state *mrb, const mrb_irep *irep, uint32_t pc, int32_t *lp, const char **fp);
MRB_API mrb_irep_debug_info *mrb_debug_info_alloc(mrb_state *mrb, mrb_irep *irep);
MRB_API mrb_irep_debug_info_file *mrb_debug_info_append_file(
mrb_state *mrb, mrb_irep_debug_info *info,
+2 -2
View File
@@ -19,11 +19,11 @@ MRB_BEGIN_DECL
/* flags for mrb_dump_irep{,_binary,_cfunc,_cstruct} */
#define MRB_DUMP_DEBUG_INFO 1
#define MRB_DUMP_STATIC 2
#define DUMP_DEBUG_INFO MRB_DUMP_DEBUG_INFO /* deprecated */
#define MRB_DUMP_NO_LVAR 4
#ifndef MRB_NO_STDIO
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_API mrb_value mrb_load_irep_file_cxt(mrb_state*, FILE*, mrb_ccontext*);
mrb_irep *mrb_read_irep_file(mrb_state*, FILE*);
int mrb_dump_irep_binary(mrb_state*, const mrb_irep*, uint8_t, FILE*);
#endif
+1 -1
View File
@@ -34,7 +34,7 @@ static inline int
check_little_endian(void)
{
unsigned int n = 1;
return (*(unsigned char *)&n == 1);
return (*(unsigned char*)&n == 1);
}
# define littleendian check_little_endian()
#endif
+30 -16
View File
@@ -10,15 +10,15 @@
#include "common.h"
/**
* MRuby error handling.
* mruby error handling.
*/
MRB_BEGIN_DECL
struct RException {
MRB_OBJECT_HEADER;
struct iv_tbl *iv;
struct RObject *mesg; // NULL or probably RString
struct RObject *backtrace; // NULL, RArray or RData
struct RBasic *mesg; // NULL or probably RString
struct RBasic *backtrace; // NULL, RArray or RData
};
/* error that should terminate execution */
@@ -34,26 +34,33 @@ struct RException {
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))
MRB_API mrb_value mrb_make_exception(mrb_state *mrb, mrb_int argc, const mrb_value *argv);
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 */
MRB_API mrb_value mrb_f_raise(mrb_state*, mrb_value);
#if defined(MRB_64BIT) || defined(MRB_USE_FLOAT32) || defined(MRB_NAN_BOXING) || defined(MRB_WORD_BOXING)
#undef MRB_USE_RBREAK_VALUE_UNION
#else
#define MRB_USE_RBREAK_VALUE_UNION 1
#endif
/*
* flags:
* 0..7: enum mrb_vtype (only when defined MRB_USE_RBREAK_VALUE_UNION)
* 8..10: RBREAK_TAGs in src/vm.c (otherwise, set to 0)
*/
struct RBreak {
MRB_OBJECT_HEADER;
const struct RProc *proc;
uintptr_t ci_break_index; // The top-level ci index to break. One before the return destination.
#ifndef MRB_USE_RBREAK_VALUE_UNION
mrb_value val;
#else
union mrb_value_union value;
#endif
};
#ifndef MRB_USE_RBREAK_VALUE_UNION
#define mrb_break_value_get(brk) ((brk)->val)
#define mrb_break_value_set(brk, v) ((brk)->val = v)
#else
struct RBreak {
MRB_OBJECT_HEADER;
const struct RProc *proc;
union mrb_value_union value;
};
#define RBREAK_VALUE_TT_MASK ((1 << 8) - 1)
static inline mrb_value
mrb_break_value_get(struct RBreak *brk)
@@ -70,9 +77,16 @@ mrb_break_value_set(struct RBreak *brk, mrb_value val)
brk->flags &= ~RBREAK_VALUE_TT_MASK;
brk->flags |= val.tt;
}
#endif /* MRB_64BIT || MRB_USE_FLOAT32 || MRB_NAN_BOXING || MRB_WORD_BOXING */
#define mrb_break_proc_get(brk) ((brk)->proc)
#define mrb_break_proc_set(brk, p) ((brk)->proc = p)
#endif /* MRB_USE_RBREAK_VALUE_UNION */
/**
* Error check
*
*/
/* clear error status in the mrb_state structure */
MRB_API void mrb_clear_error(mrb_state *mrb);
/* returns TRUE if error in the previous call; internally calls mrb_clear_error() */
MRB_API mrb_bool mrb_check_error(mrb_state *mrb);
/**
* Protect
+20 -42
View File
@@ -34,55 +34,33 @@ typedef enum {
MRB_GC_STATE_SWEEP
} mrb_gc_state;
/* Disable MSVC warning "C4200: nonstandard extension used: zero-sized array
* in struct/union" when in C++ mode */
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4200)
#endif
typedef struct mrb_heap_page {
struct RBasic *freelist;
struct mrb_heap_page *prev;
struct mrb_heap_page *next;
struct mrb_heap_page *free_next;
struct mrb_heap_page *free_prev;
mrb_bool old:1;
/* Flexible array members area a C99 feature, not C++ compatible */
/* void* objects[]; */
} mrb_heap_page;
#ifdef _MSC_VER
#pragma warning(pop)
#endif
typedef struct mrb_gc {
mrb_heap_page *heaps; /* heaps for GC */
mrb_heap_page *sweeps;
mrb_heap_page *free_heaps;
size_t live; /* count of live objects */
struct mrb_heap_page *heaps; /* all heaps pages */
struct mrb_heap_page *free_heaps;/* heaps for allocation */
struct mrb_heap_page *sweeps; /* page where sweep starts */
struct RBasic *gray_list; /* list of gray objects to be traversed incrementally */
struct RBasic *atomic_gray_list; /* list of objects to be traversed atomically */
size_t live; /* count of live objects */
size_t live_after_mark; /* old generation objects */
size_t threshold; /* threshold to start GC */
size_t oldgen_threshold; /* threshold to kick major GC */
mrb_gc_state state; /* current state of gc */
int interval_ratio;
int step_ratio;
int current_white_part :2; /* make white object by white_part */
mrb_bool iterating :1; /* currently iterating over objects */
mrb_bool disabled :1; /* GC disabled */
mrb_bool generational :1; /* generational GC mode */
mrb_bool full :1; /* major GC mode */
mrb_bool out_of_memory :1; /* out-of-memory error occurred */
#ifdef MRB_GC_FIXED_ARENA
struct RBasic *arena[MRB_GC_ARENA_SIZE]; /* GC protection array */
#else
struct RBasic **arena; /* GC protection array */
int arena_capa;
int arena_capa; /* size of protection array */
#endif
int arena_idx;
mrb_gc_state state; /* state of gc */
int current_white_part; /* make white object by white_part */
struct RBasic *gray_list; /* list of gray objects to be traversed incrementally */
struct RBasic *atomic_gray_list; /* list of objects to be traversed atomically */
size_t live_after_mark;
size_t threshold;
int interval_ratio;
int step_ratio;
mrb_bool iterating :1;
mrb_bool disabled :1;
mrb_bool full :1;
mrb_bool generational :1;
mrb_bool out_of_memory :1;
size_t majorgc_old_threshold;
} mrb_gc;
MRB_API mrb_bool mrb_object_dead_p(struct mrb_state *mrb, struct RBasic *object);
+58 -13
View File
@@ -12,6 +12,8 @@ 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
mrb_bool mrb_inspect_recursive_p(mrb_state *mrb, mrb_value self);
#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);
@@ -22,11 +24,17 @@ 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);
mrb_method_t mrb_vm_find_method(mrb_state *mrb, struct RClass *c, struct RClass **cp, mrb_sym mid);
mrb_value mrb_mod_const_missing(mrb_state *mrb, mrb_value mod);
mrb_value mrb_const_missing(mrb_state *mrb, mrb_value mod, mrb_sym sym);
size_t mrb_class_mt_memsize(mrb_state*, struct RClass*);
#endif
mrb_value mrb_obj_equal_m(mrb_state *mrb, mrb_value);
/* 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);
size_t mrb_packed_int_encode(uint32_t num, uint8_t *p);
uint32_t mrb_packed_int_decode(const uint8_t *p, const uint8_t **newpos);
/* dump */
@@ -50,23 +58,35 @@ 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);
mrb_value mrb_f_raise(mrb_state*, mrb_value);
mrb_value mrb_make_exception(mrb_state *mrb, mrb_value exc, mrb_value mesg);
struct RBacktrace {
MRB_OBJECT_HEADER;
size_t len;
struct mrb_backtrace_location *locations;
};
struct mrb_backtrace_location {
mrb_sym method_id;
int32_t idx;
const mrb_irep *irep;
};
/* gc */
void mrb_gc_mark_mt(mrb_state*, struct RClass*);
size_t mrb_gc_mark_mt_size(mrb_state*, struct RClass*);
size_t mrb_gc_mark_mt(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*);
size_t mrb_gc_mark_hash(mrb_state*, struct RHash*);
void mrb_gc_free_hash(mrb_state*, struct RHash*);
mrb_value mrb_hash_first_key(mrb_state*, mrb_value);
/* 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)
@@ -88,6 +108,9 @@ 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);
#ifndef MRB_NO_FLOAT
void mrb_check_num_exact(mrb_state *mrb, mrb_float num);
#endif
#ifdef MRB_USE_COMPLEX
mrb_value mrb_complex_new(mrb_state *mrb, mrb_float x, mrb_float y);
@@ -103,20 +126,27 @@ 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);
mrb_value mrb_as_rational(mrb_state *mrb, mrb_value x);
void mrb_rational_copy(mrb_state *mrb, mrb_value x, mrb_value y);
int mrb_rational_mark(mrb_state *mrb, struct RBasic *rat);
#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);
void mrb_proc_copy(mrb_state *mrb, struct RProc *a, const 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);
void mrb_proc_merge_lvar(mrb_state *mrb, mrb_irep *irep, struct REnv *env, int num, const mrb_sym *lv, const mrb_value *stack);
mrb_value mrb_proc_local_variables(mrb_state *mrb, const struct RProc *proc);
const struct RProc *mrb_proc_get_caller(mrb_state *mrb, struct REnv **env);
mrb_value mrb_proc_get_self(mrb_state *mrb, const struct RProc *p, struct RClass **target_class_p);
mrb_bool mrb_proc_eql(mrb_state *mrb, mrb_value self, mrb_value other);
#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);
size_t mrb_gc_mark_range(mrb_state *mrb, struct RRange *r);
#endif
/* string */
@@ -152,41 +182,50 @@ 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);
mrb_value mrb_exc_const_get(mrb_state *mrb, mrb_sym sym);
/* 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*);
size_t mrb_gc_mark_iv(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_exec_irep(mrb_state *mrb, mrb_value self, const struct RProc *p);
mrb_value mrb_obj_instance_eval(mrb_state*, mrb_value);
mrb_value mrb_object_exec(mrb_state *mrb, mrb_value self, struct RClass *target_class);
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);
#ifdef MRB_INT64
#define mrb_bint_new_int64(mrb,x) mrb_bint_new_int((mrb),(mrb_int)(x))
#else
mrb_value mrb_bint_new_int64(mrb_state *mrb, int64_t x);
#endif
mrb_value mrb_bint_new_uint64(mrb_state *mrb, uint64_t 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_add_n(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_bint_sub_n(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_powm(mrb_state *mrb, mrb_value x, mrb_value 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_neg(mrb_state *mrb, mrb_value x);
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);
@@ -197,6 +236,12 @@ 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);
#ifdef MRB_INT64
#define mrb_bint_as_int64(mrb, x) mrb_bint_as_int((mrb), (x))
#else
int64_t mrb_bint_as_int64(mrb_state *mrb, mrb_value x);
#endif
uint64_t mrb_bint_as_uint64(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);
+53 -43
View File
@@ -16,19 +16,19 @@
MRB_BEGIN_DECL
enum irep_pool_type {
IREP_TT_STR = 0, /* string (need free) */
IREP_TT_SSTR = 2, /* string (static) */
IREP_TT_INT32 = 1, /* 32bit integer */
IREP_TT_INT64 = 3, /* 64bit integer */
IREP_TT_BIGINT = 7, /* big integer (not yet supported) */
IREP_TT_FLOAT = 5, /* float (double/float) */
IREP_TT_STR = 0, /* string (need free) */
IREP_TT_SSTR = 2, /* string (static) */
IREP_TT_INT32 = 1, /* 32-bit integer */
IREP_TT_INT64 = 3, /* 64-bit integer */
IREP_TT_BIGINT = 7, /* big integer (not yet supported) */
IREP_TT_FLOAT = 5, /* float (double/float) */
};
#define IREP_TT_NFLAG 1 /* number (non string) flag */
#define IREP_TT_SFLAG 2 /* static string flag */
#define IREP_TT_NFLAG 1 /* number (non string) flag */
#define IREP_TT_SFLAG 2 /* static string flag */
typedef struct mrb_pool_value {
uint32_t tt; /* packed type and length (for string) */
typedef struct mrb_irep_pool {
uint32_t tt; /* packed type and length (for string) */
union {
const char *str;
int32_t i32;
@@ -37,7 +37,7 @@ typedef struct mrb_pool_value {
mrb_float f;
#endif
} u;
} mrb_pool_value;
} mrb_irep_pool;
enum mrb_catch_type {
MRB_CATCH_RESCUE = 0,
@@ -45,32 +45,33 @@ enum mrb_catch_type {
};
struct mrb_irep_catch_handler {
uint8_t type; /* enum mrb_catch_type */
uint8_t begin[4]; /* The starting address to match the handler. Includes this. */
uint8_t end[4]; /* The endpoint address that matches the handler. Not Includes this. */
uint8_t target[4]; /* The address to jump to if a match is made. */
uint8_t type; /* enum mrb_catch_type */
uint8_t begin[4]; /* The starting address to match the handler. Includes this. */
uint8_t end[4]; /* The endpoint address that matches the handler. Not Includes this. */
uint8_t target[4]; /* The address to jump to if a match is made. */
};
/* Program data array struct */
struct mrb_irep {
uint16_t nlocals; /* Number of local variables */
uint16_t nregs; /* Number of register variables */
uint16_t clen; /* Number of catch handlers */
uint16_t nlocals; /* Number of local variables */
uint16_t nregs; /* Number of register variables */
uint16_t clen; /* Number of catch handlers */
uint8_t flags;
const mrb_code *iseq;
/*
* A catch handler table is placed after the iseq entity.
* The reason it doesn't add fields to the structure is to keep the mrb_irep structure from bloating.
* The catch handler table can be obtained with `mrb_irep_catch_handler_table(irep)`.
* The reason it doesn't add fields to the structure is to keep the mrb_irep
* structure from bloating. The catch handler table can be obtained with
* `mrb_irep_catch_handler_table(irep)`.
*/
const mrb_pool_value *pool;
const mrb_irep_pool *pool;
const mrb_sym *syms;
const struct mrb_irep * const *reps;
const struct mrb_irep *const *reps;
const mrb_sym *lv;
/* debug info */
struct mrb_irep_debug_info* debug_info;
struct mrb_irep_debug_info *debug_info;
uint32_t ilen;
uint16_t plen, slen;
@@ -80,37 +81,46 @@ struct mrb_irep {
#define MRB_ISEQ_NO_FREE 1
#define MRB_IREP_NO_FREE 2
#define MRB_IREP_STATIC (MRB_ISEQ_NO_FREE | MRB_IREP_NO_FREE)
#define MRB_IREP_STATIC (MRB_ISEQ_NO_FREE | MRB_IREP_NO_FREE)
MRB_API mrb_irep *mrb_add_irep(mrb_state *mrb);
/** load mruby bytecode functions
* Please note! Currently due to interactions with the GC calling these functions will
* leak one RProc object per function call.
* To prevent this save the current memory arena before calling and restore the arena
* right after, like so
* int ai = mrb_gc_arena_save(mrb);
* mrb_value status = mrb_load_irep(mrb, buffer);
* mrb_gc_arena_restore(mrb, ai);
*/
/**
* load mruby bytecode functions
*
* Please note! Currently due to interactions with the GC calling these
* functions will leak one RProc object per function call. To prevent this save
* the current memory arena before calling and restore the arena right after,
* like so
*
* int ai = mrb_gc_arena_save(mrb);
* mrb_value status = mrb_load_irep(mrb, buffer);
* mrb_gc_arena_restore(mrb, ai);
*
* Also, when called from a C function defined as a method, the current stack is
* destroyed. If processing continues after this function, the objects obtained
* from the arguments must be protected as needed before this function.
*/
/* @param [const uint8_t*] irep code, expected as a literal */
MRB_API mrb_value mrb_load_irep(mrb_state*, const uint8_t*);
MRB_API mrb_value mrb_load_irep(mrb_state *, const uint8_t *);
/*
* @param [const void*] irep code
* @param [size_t] size of irep buffer.
*/
MRB_API mrb_value mrb_load_irep_buf(mrb_state*, const void*, size_t);
MRB_API mrb_value mrb_load_irep_buf(mrb_state *, const void *, size_t);
/* @param [const uint8_t*] irep code, expected as a literal */
MRB_API mrb_value mrb_load_irep_cxt(mrb_state*, const uint8_t*, mrbc_context*);
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.
*/
MRB_API mrb_value mrb_load_irep_buf_cxt(mrb_state*, const void*, size_t, mrbc_context*);
MRB_API mrb_value mrb_load_irep_buf_cxt(mrb_state *, const void *, size_t,
mrbc_context *);
struct mrb_insn_data {
uint8_t insn;
@@ -120,13 +130,13 @@ struct mrb_insn_data {
const mrb_code *addr;
};
#define mrb_irep_catch_handler_pack(n, v) uint32_to_bin(n, v)
#define mrb_irep_catch_handler_unpack(v) bin_to_uint32(v)
#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*);
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 */
#endif /* MRUBY_IREP_H */
+1 -1
View File
@@ -30,7 +30,7 @@ struct RIStruct {
#define RISTRUCT(obj) ((struct RIStruct*)(mrb_ptr(obj)))
#define ISTRUCT_PTR(obj) (RISTRUCT(obj)->inline_data)
MRB_INLINE mrb_int mrb_istruct_size()
MRB_INLINE mrb_int mrb_istruct_size(void)
{
return ISTRUCT_DATA_SIZE;
}

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