Compare commits

...

5613 Commits

Author SHA1 Message Date
google-labs-jules[bot] 71e8dbcd97 Refactor str_succ_bang for in-place modification
This commit refactors the str_succ_bang function in mrbgems/mruby-string-ext/src/string.c to perform string succession in-place.

The previous implementation used an intermediate temporary string, which incurred memory and performance overhead.
This change aims to reduce memory usage and improve performance by modifying the string buffer directly, using mrb_str_resize and memmove when prepending characters is necessary (e.g., '9' -> '10').

Formatting changes (newlines before 'else') have also been applied as per user request.
2025-06-23 09:23:54 +00:00
Yukihiro "Matz" Matsumoto 791b374155 khash.h: reduce KHASH_DEFAULT_SIZE from 32 to 8 2025-06-23 17:07:31 +09:00
Yukihiro "Matz" Matsumoto c152f3a79a mruby-set: add comprehensive tests for Set operations: +, -, & 2025-06-23 17:07:31 +09:00
Yukihiro "Matz" Matsumoto 18b45c7ab5 mruby-set: change string representation from #<Set: {1}> to Set[1] 2025-06-23 17:07:31 +09:00
Yukihiro "Matz" Matsumoto 561a3eac82 mruby-set: make eql? an alias of == method 2025-06-23 17:07:30 +09:00
Yukihiro "Matz" Matsumoto 20b32531ea mruby-set: Fix memory leak in Set#flatten! and simplify implementation
- Remove circular reference check in favor of max depth check only
- Fix memory leak by properly handling errors in set_flatten_bang
- Simplify code by reducing variables and unifying error handling
2025-06-23 17:07:30 +09:00
Yukihiro "Matz" Matsumoto 9d739cdad8 mruby-set: use set_is_set extensively 2025-06-23 17:07:30 +09:00
Yukihiro "Matz" Matsumoto f47609574a mruby-set: remove some AI generated work-log comments 2025-06-23 17:07:30 +09:00
Yukihiro "Matz" Matsumoto ea0ceff7fb mruby-set: implement Set#flatten and flatten! in C
The code is generated by Cursor.
2025-06-23 17:07:30 +09:00
Yukihiro "Matz" Matsumoto 73c61e4a60 mruby-set: optimize inspect/to_s to avoid intermediate array 2025-06-23 17:07:29 +09:00
Yukihiro "Matz" Matsumoto e2982bdb57 mruby-set: optimize join method to avoid intermediate array 2025-06-23 17:07:29 +09:00
Yukihiro "Matz" Matsumoto 0430f1e9b8 mruby-set: optimize eql? by checking fast path 2025-06-23 17:07:29 +09:00
Yukihiro "Matz" Matsumoto d7a0d5687e mruby-set: optimize equal by checking fast path 2025-06-23 17:07:29 +09:00
Yukihiro "Matz" Matsumoto 83fc43e71d mruby-set: improve Set#hash by using FNV-1 hashing 2025-06-23 17:07:29 +09:00
Yukihiro "Matz" Matsumoto 3a5d0a1840 mruby-set: simplify the code with KHASH_FOREACH macro 2025-06-23 17:07:28 +09:00
Yukihiro "Matz" Matsumoto eb1820d75e symbol.c: remove unused <mruby/khash.h> header 2025-06-23 17:07:28 +09:00
Yukihiro "Matz" Matsumoto e30ec3da42 mruby-metaprog: use KHASH_FOREACH macro 2025-06-23 17:07:28 +09:00
Yukihiro "Matz" Matsumoto bce8cee8f9 khash.h (KHASH_FOREACH): a new macro to iterate over khash table 2025-06-23 17:07:28 +09:00
Yukihiro "Matz" Matsumoto d41d477e22 mruby-set: add type checking helper functions
Add two helper functions to improve code clarity and maintainability:
- set_check_type: Checks if a value is a Set and raises an error if not
- set_is_set: Checks if a value is a Set and returns a boolean result

Update all relevant methods to use these helper functions, reducing
code duplication and centralizing type checking logic.
2025-06-23 17:07:27 +09:00
Yukihiro "Matz" Matsumoto deb5c47fc6 mruby-set: implement comparison methods in C for better performance
Reimplemented the following methods in C for improved efficiency:
- superset? and proper_superset? (>= and >)
- subset? and proper_subset? (<= and <)
- intersect? and disjoint?
- <=> comparison operator
2025-06-23 17:07:27 +09:00
Yukihiro "Matz" Matsumoto 60f06e7a0f mruby-set: Add comprehensive method documentation 2025-06-23 17:07:27 +09:00
Yukihiro "Matz" Matsumoto 091e48159a mruby-set: Use numbered parameters for block arguments 2025-06-23 17:07:27 +09:00
Yukihiro "Matz" Matsumoto 04b38c2c47 mruby-set: rename internal methods
Renaming all internal C methods from __set_* to a cleaner __* convention
(e.g., __set_merge is now __merge), and updating their call sites in the
Ruby code accordingly.
2025-06-23 17:07:26 +09:00
Yukihiro "Matz" Matsumoto e096eeed1a mruby-set: reimplement #initialize in Ruby again
And we have eliminated mrb_funcall* from set.c.
2025-06-23 17:07:26 +09:00
Yukihiro "Matz" Matsumoto 5e2a7568e2 mruby-set: move #replace to Ruby again
Since it does only clear() and merge(), there is little use of the C
implemented fast path. This change also reduce memory consumption.
2025-06-23 17:07:26 +09:00
Yukihiro "Matz" Matsumoto 100ba913f2 mruby-set: extensive refactor in set.c
We refactor out loop by set_khash_foreach() function, so that we don't
need to repeat for loop. it makes the code simpler. The code is written
by Atlassian Rovodev.
2025-06-23 17:07:26 +09:00
Yukihiro "Matz" Matsumoto f210772465 mruby-set: optimize Set operations to use mrb_get_arg1()
Replace mrb_get_args() with more efficient mrb_get_arg1() for
single-argument functions. The code is written by Atlassian Rovodev.
2025-06-23 17:07:26 +09:00
Yukihiro "Matz" Matsumoto c117674cfe mruby-set: refactor Set#replace
The code is written by Atlassian Rovodev.
2025-06-23 17:07:25 +09:00
Yukihiro "Matz" Matsumoto 8538c79f3f mruby-set: refactor Set#merge
The code is written by Atlassian Rovodev.
2025-06-23 17:07:25 +09:00
Yukihiro "Matz" Matsumoto 169654ad9b mruby-set: refactor Set#subtract
The code is written by Atlassian Rovodev.
2025-06-23 17:07:25 +09:00
Yukihiro "Matz" Matsumoto c188b9a1aa mruby-set: refactor Set#difference
The code is written by Atlassian Rovodev.
2025-06-23 17:07:25 +09:00
Yukihiro "Matz" Matsumoto 10ea05d3aa mruby-set: refactor Set#union (+, |)
The code is written by Atlassian Rovodev.
2025-06-23 17:07:24 +09:00
Yukihiro "Matz" Matsumoto d9f0c5a3a4 mruby-set: refactor Set#xor (^)
According to the similar strategy as Set#intersection.
The code is mostly written by Atlassian Rovodev.
2025-06-23 17:07:24 +09:00
Yukihiro "Matz" Matsumoto 56a41b844e mruby-set: refactor Set#intersection
Define generic operation method in Ruby, then prepare fast-path function
in C as a general structure. Some methods will follow this pattern.
The code is generated by Atlassian Rovodev.
2025-06-23 17:07:24 +09:00
Yukihiro "Matz" Matsumoto 4ae3068b2a mruby-set: replace mrb_funcall_id() by set_to_a() 2025-06-23 17:07:24 +09:00
Yukihiro "Matz" Matsumoto 73a1eb03e8 mruby-set: remove mrb_funcall_id() from set_join() 2025-06-23 17:07:24 +09:00
Yukihiro "Matz" Matsumoto abae5a5ff5 mruby-set: remove __equal_fallback that no longer used 2025-06-23 17:07:23 +09:00
Yukihiro "Matz" Matsumoto a2339a7fde mruby-set: refactor set_equal() function
Made not to use mrb_funcall() as well.
2025-06-23 17:07:23 +09:00
Yukihiro "Matz" Matsumoto 72b51c4e92 mruby-set: I prefer newline before else keyword 2025-06-23 17:07:23 +09:00
Yukihiro "Matz" Matsumoto 655981c6ed mruby-set: remove unused object allocation
AI added this allocation to avoid memory leaks, but actually this extra
allocation does nothing useful. We see more room for AI improvement.
2025-06-23 17:07:23 +09:00
Yukihiro "Matz" Matsumoto e4ed04ba8b mruby-set (set_init): adjust a local variable declaration 2025-06-23 17:07:23 +09:00
Yukihiro "Matz" Matsumoto 52285161e7 mruby-set: remove methods added by AI hallucination 2025-06-23 17:07:22 +09:00
Yukihiro "Matz" Matsumoto 1238fb2808 mruby-set (flatten_merge): remove unnecessary assignment 2025-06-23 17:07:22 +09:00
Yukihiro "Matz" Matsumoto f44a7bc5db mruby-set: remove statistic measurement code 2025-06-23 17:07:22 +09:00
Yukihiro "Matz" Matsumoto 7a1732d438 mruby-set: make #initialize_copy private 2025-06-23 17:07:22 +09:00
Yukihiro "Matz" Matsumoto 11106525c4 mruby-set (__get_hash): remove no longer used method 2025-06-23 17:07:22 +09:00
Yukihiro "Matz" Matsumoto 7ffe6a3a9a mruby-set: re-implement Set class in C
The code is mostly developed by Atlassian Rovodev.
2025-06-23 17:07:21 +09:00
Yukihiro "Matz" Matsumoto e87bd7fcc1 mruby-set: update README.md
The document is written by Google Jules.
2025-06-23 17:07:21 +09:00
Yukihiro "Matz" Matsumoto 695207be68 hash.c (mrb_obj_hash_code): expose hash function 2025-06-23 17:07:21 +09:00
Yukihiro "Matz" Matsumoto d73e337442 mruby-bigint: update README.md
The document is written by Google Jules.
2025-06-23 17:07:20 +09:00
Yukihiro "Matz" Matsumoto 4cd7f523fb Merge pull request #6555 from dearblue/mt_foreach 2025-06-21 06:33:35 +09:00
Yukihiro "Matz" Matsumoto e2e2b5d35b Merge pull request #6556 from dearblue/iv_foreach 2025-06-21 06:33:18 +09:00
dearblue 5931aeb825 mrb_mt_foreach() needs to update the pointer at each loop
When calling a user function, a pointer retrieved outside of a loop may be invalidated.
2025-06-19 22:35:09 +09:00
dearblue afd5805224 iv_foreach() needs to update the pointer at each loop
When calling a user function, a pointer retrieved outside of a loop may be invalidated.
2025-06-19 22:25:13 +09:00
Yukihiro "Matz" Matsumoto 2edfd96cbe mruby-rational: add README.md
The document is written by Google Jules.
2025-06-17 16:22:19 +09:00
Yukihiro "Matz" Matsumoto ef1cdbc0c7 mruby-complex: add README.md
The document is written by Google Jules.
2025-06-17 16:19:44 +09:00
Yukihiro "Matz" Matsumoto 67dbaf856f mruby-pack: add README.md
The document is written by Google Jules.
2025-06-16 12:45:18 +09:00
Yukihiro "Matz" Matsumoto 0fc6288ae2 mruby-binding: make Binding#initialize_copy private 2025-06-16 12:44:06 +09:00
Yukihiro "Matz" Matsumoto 085adaf408 mruby-date: make Data#initialize_copy private 2025-06-16 12:43:34 +09:00
Yukihiro "Matz" Matsumoto 783bc526e4 mruby-enumerator: make Enumerator#initialize_copy private 2025-06-16 12:42:56 +09:00
Yukihiro "Matz" Matsumoto 35fafe57fb mruby-io: make IO#initialize_copy private 2025-06-16 12:42:22 +09:00
Yukihiro "Matz" Matsumoto 10c40c4e87 mruby-set: make Set#initialize_copy private 2025-06-16 12:41:54 +09:00
Yukihiro "Matz" Matsumoto 0a306b81ed mruby-struct: make Struct#initialize_copy private 2025-06-16 12:41:19 +09:00
Yukihiro "Matz" Matsumoto d015d91c12 mruby-time: make Time#initialize_copy private 2025-06-16 12:40:29 +09:00
Yukihiro "Matz" Matsumoto 262d3715f5 proc.c: make Proc#initialize_copy private 2025-06-15 14:14:24 +09:00
Yukihiro "Matz" Matsumoto 8cb427b75c hash.c: make Hash#initialize_copy private 2025-06-15 14:13:56 +09:00
Yukihiro "Matz" Matsumoto a25a896caf range.c: make Range#initialize_copy private 2025-06-15 14:12:58 +09:00
Yukihiro "Matz" Matsumoto 65369ca1e6 array.c: make Array#initialize_copy private 2025-06-15 14:12:12 +09:00
Yukihiro "Matz" Matsumoto ff2464e879 string.c: make String#initialize_copy private 2025-06-15 14:11:54 +09:00
Yukihiro "Matz" Matsumoto f7813268d6 mruby-socket: inline #_new_with_prelude that is only called once. 2025-06-14 13:39:12 +09:00
Yukihiro "Matz" Matsumoto ebd9f29b38 The method #initialize_copy should be private, no direct call
Fixed test/t/array.rb and test/t/string.rb in standard tests.
And mrbgems/mruby-struct/test/struct.rb as well.
2025-06-14 13:38:22 +09:00
Yukihiro "Matz" Matsumoto bf0f37833d mruby-socket: fixed raising RuntimeError from #accept; #6554
In mruby, bare `raise` in rescue clause does not re-raise the last
exception. You should explicitly specify the exception.
2025-06-14 01:56:43 +09:00
Yukihiro "Matz" Matsumoto 12c124e1d4 mruby-time: add README.md
The document is written by Google Jules.
2025-06-14 01:06:55 +09:00
Yukihiro "Matz" Matsumoto ac8d5c6ae6 mruby-sprintf: add README.md
The document is written by Google Jules.
2025-06-14 01:04:23 +09:00
Yukihiro "Matz" Matsumoto 1b189bc1a2 mruby-random: add README.md
The document is written by Google Jules.
2025-06-14 01:02:52 +09:00
Yukihiro "Matz" Matsumoto 8ef1d1e104 mruby-enum-lazy: add README.md
The document is written by Google Jules.
2025-06-13 04:45:48 +09:00
Yukihiro "Matz" Matsumoto 74f46a05fd mruby-enum-chain: add README.md
The document is written by Google Jules.
2025-06-13 04:42:17 +09:00
Yukihiro "Matz" Matsumoto 6b64447f0e mruby-enumerator: add README.md
The document is written by Google Jules.
2025-06-13 04:40:29 +09:00
Yukihiro "Matz" Matsumoto 04b769b5ca mruby-os-memsize: add README.md
The document is written by Google Jules.
2025-06-12 21:29:20 +09:00
Yukihiro "Matz" Matsumoto 91ec6ea9cc mruby-objectspace: add REAME.md
The document is written by Google Jules.
2025-06-12 21:28:42 +09:00
Yukihiro "Matz" Matsumoto 0b52b33597 mruby-proc-binding: add README.md
The document is written by Google Jules.
2025-06-11 18:38:14 +09:00
Yukihiro "Matz" Matsumoto 18f65c6652 mruby-method: update README.md
Updated document is written by Google Jules.
2025-06-11 18:35:59 +09:00
Yukihiro "Matz" Matsumoto 84c308aedc mruby-metaprog: add README.md
The document is written by Google Jules.
2025-06-11 18:33:35 +09:00
Yukihiro "Matz" Matsumoto 0a45941337 mruby-eval: add README.md
The document is written by Google Jules.
2025-06-11 18:31:52 +09:00
Yukihiro "Matz" Matsumoto b5197c22f6 mruby-socket: should not directly call private #initialize; fix #6554 2025-06-10 14:28:26 +09:00
Yukihiro "Matz" Matsumoto 2f00046758 mruby-toplevel-ext: add README.md
The document is written by Google Jules.
2025-06-10 11:28:18 +09:00
Yukihiro "Matz" Matsumoto 3a27a868a1 mruby-symbol-ext: add README.md
The document is written by Google Jules.
2025-06-10 11:25:45 +09:00
Yukihiro "Matz" Matsumoto 4e711fe0ef mruby-string-ext: add README.md
The document is written by Google Jules.
2025-06-10 11:23:50 +09:00
Yukihiro "Matz" Matsumoto 396a85de9a mruby-range-ext: add README.md
The document is written by Google Jules.
2025-06-10 11:09:16 +09:00
Yukihiro "Matz" Matsumoto 59902a94ab mruby-proc-ext: add README.md
The document is written by Google Jules.
2025-06-10 11:07:16 +09:00
Yukihiro "Matz" Matsumoto 3814cbc539 mruby-object-ext: add README.md
The document is written by Google Jules.
2025-06-10 11:03:19 +09:00
Yukihiro "Matz" Matsumoto 5e5b4445ff mruby-numeric-ext: add README.md
The document is written by Google Jules.
2025-06-10 10:58:22 +09:00
Yukihiro "Matz" Matsumoto 97ad019707 mruby-kernel-ext: add README.md
The document is written by Google Jules.
2025-06-10 10:56:01 +09:00
Yukihiro "Matz" Matsumoto 8fbe5523cf mruby-hash-ext: add README.md
The document is written by Google Jules.
2025-06-10 10:53:57 +09:00
Yukihiro "Matz" Matsumoto 470c1dc184 mruby-errno: add README.md
The document is written by Google Jules.
2025-06-09 17:14:02 +09:00
Yukihiro "Matz" Matsumoto 813dc8eae5 mruby-error: add README.md
The document is written by Google Jules.
2025-06-09 17:13:20 +09:00
Yukihiro "Matz" Matsumoto 5cdd394c6d mruby-encoding: add README.md
The document is written by Google Jules.
2025-06-09 17:11:46 +09:00
Yukihiro "Matz" Matsumoto 6509f52642 mruby-struct: add README.md
The document is written by Google Jules.
2025-06-09 11:01:48 +09:00
Yukihiro "Matz" Matsumoto acf3656e49 mruby-data: add README.md
The document is written by Google Jules.
2025-06-09 11:01:05 +09:00
Yukihiro "Matz" Matsumoto 1beecb9670 mruby-cmath: add README.md
The document is written by Google Jules.
2025-06-08 17:04:05 +09:00
Yukihiro "Matz" Matsumoto d7f7ea0d82 mruby-math: add README.md
The document is written by Google Jules.
2025-06-08 17:02:55 +09:00
Yukihiro "Matz" Matsumoto 6bcee69c9c mruby-catch: add README.md
The document is written by Google Jules.
2025-06-08 17:00:07 +09:00
Yukihiro "Matz" Matsumoto 5731fbf17c mruby-binding: add README.md
The document is written by Google Jules.
2025-06-08 16:59:25 +09:00
Yukihiro "Matz" Matsumoto f835b86d10 mruby-enum-ext: add README.md
The document is written by Google Jules.
2025-06-07 11:53:04 +09:00
Yukihiro "Matz" Matsumoto 50945bec68 mruby-compar-ext: add README.md
The document is written by Google Jules.
2025-06-07 11:50:53 +09:00
Yukihiro "Matz" Matsumoto 5cc5a8a9c3 mruby-class-ext: add README.md
The document is written by Google Jules.
2025-06-07 11:48:40 +09:00
Yukihiro "Matz" Matsumoto c7ffb0cc55 mruby-array-ext: add README.md
The document is written by Google Jules.
2025-06-07 11:46:11 +09:00
Yukihiro "Matz" Matsumoto 35d073a986 vm.c: fix unintended argument renaming by Google Jules; #6533 2025-06-06 11:53:14 +09:00
Yukihiro "Matz" Matsumoto 2b75da7335 Merge pull request #6553 from mruby/add-vm-comments 2025-06-06 08:15:41 +09:00
google-labs-jules[bot] da9365f98e Add descriptive comments for MRB_API functions in src/vm.c
This commit adds Doxygen-style comments to several MRB_API functions
in src/vm.c to improve code readability and documentation.

The following functions were commented:
- mrb_stack_extend
- mrb_protect_error
- mrb_funcall
- mrb_funcall_id
- mrb_funcall_with_block
- mrb_funcall_argv
- mrb_yield_with_class
- mrb_yield_argv
- mrb_yield
- mrb_vm_run
- mrb_vm_exec
- mrb_top_run

Additionally, the parameter name 'self' in mrb_yield_with_class was
renamed to 'self_obj' for better clarity and consistency with the new comment.
2025-06-05 23:14:43 +00:00
Yukihiro "Matz" Matsumoto e55b3f0c55 Merge pull request #6552 from mruby/fix-comments-variable-c 2025-06-06 08:14:17 +09:00
google-labs-jules[bot] b4826fdbcf Fix: Correct placement of comments in src/variable.c
This commit corrects the placement of C-style block comments
for MRB_API functions in src/variable.c. Comments are now
placed directly before each function definition as per standard
documentation practices.
2025-06-05 23:13:42 +00:00
Yukihiro "Matz" Matsumoto 2f19fe1e36 Merge pull request #6551 from mruby/add-comments-state 2025-06-06 08:13:11 +09:00
google-labs-jules[bot] 19ddbdcf4b Add descriptive comments for MRB_API functions in src/state.c
This commit adds descriptive comments to the following MRB_API functions in src/state.c, clarifying their purpose and functionality:

- mrb_open_core
- mrb_open
- mrb_free_context
- mrb_close
- mrb_add_irep
- mrb_top_self
- mrb_state_atexit
2025-06-05 23:12:50 +00:00
Yukihiro "Matz" Matsumoto bdd379bc8c Merge pull request #6550 from mruby/add-comments-to-proc-c 2025-06-06 08:12:32 +09:00
google-labs-jules[bot] ddbbf3bd82 Add descriptive comments for MRB_API functions in src/proc.c
This commit adds Doxygen-style comments to the following MRB_API functions in src/proc.c:
- mrb_proc_new_cfunc
- mrb_proc_new_cfunc_with_env
- mrb_closure_new_cfunc
- mrb_proc_cfunc_env_get

The comments describe the purpose, parameters, and return value of each function.
2025-06-05 23:12:02 +00:00
Yukihiro "Matz" Matsumoto 64d390b9e0 numeric.c : add descriptive comments for public functions
- mrb_int_overflow
- mrb_int_zerodiv
- mrb_int_pow
- mrb_div_int
- mrb_div_int_value
- mrb_float_to_str
- mrb_check_num_exact
- mrb_int_mul
- mrb_num_shift
- mrb_float_to_integer
- mrb_int_add
- mrb_int_sub
- mrb_int_to_cstr
- mrb_integer_to_str
- mrb_cmp

The comments were written by Google Jules.
2025-06-06 08:11:37 +09:00
Yukihiro "Matz" Matsumoto d3f339062b Merge pull request #6549 from mruby/add-kernel-comments 2025-06-05 10:36:52 +09:00
google-labs-jules[bot] 1e3295d93e Add descriptive comments to kernel functions
This commit adds descriptive C-style comments to the following functions
in `src/kernel.c`:

- `mrb_func_basic_p`: Explains that the function checks if an object's method is implemented by a specific C function.
- `mrb_obj_freeze`: Explains that the function freezes an object, preventing further modifications.
- `mrb_obj_is_instance_of`: Explains that the function checks if an object is an instance of a given class.
2025-06-05 01:35:27 +00:00
Yukihiro "Matz" Matsumoto 24a84a5a37 Merge pull request #6548 from mruby/add-comments-etc 2025-06-05 10:34:17 +09:00
google-labs-jules[bot] 52d56fe443 Add descriptive comments to MRB_API functions in src/etc.c
This commit adds Doxygen-style comments to several MRB_API functions
in the `src/etc.c` file. These comments explain the purpose,
parameters, and return values of these functions, improving code
readability and maintainability.

The following functions were commented:
- mrb_data_object_alloc
- mrb_data_check_type
- mrb_data_check_get_ptr
- mrb_data_get_ptr
- mrb_obj_to_sym
- mrb_obj_id
- mrb_word_boxing_float_value
- mrb_word_boxing_value_float
- mrb_word_boxing_cptr_value
- mrb_boxing_int_value
2025-06-05 01:33:38 +00:00
Yukihiro "Matz" Matsumoto 576a104a77 Merge pull request #6546 from mruby/dependabot/github_actions/ls-lint/action-2.3.1 2025-06-05 10:18:26 +09:00
dependabot[bot] ad015f14a8 build(deps): bump ls-lint/action from 2.3.0 to 2.3.1
Bumps [ls-lint/action](https://github.com/ls-lint/action) from 2.3.0 to 2.3.1.
- [Commits](https://github.com/ls-lint/action/compare/v2.3.0...v2.3.1)

---
updated-dependencies:
- dependency-name: ls-lint/action
  dependency-version: 2.3.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-04 14:33:09 +00:00
Yukihiro "Matz" Matsumoto 1ff94c5e00 AUTHORS: update entries [ci skip] 2025-06-04 13:20:08 +09:00
Yukihiro "Matz" Matsumoto a3e72804cd range.c: add descriptive comments to MRB_API functions in src/range.c
This commit adds descriptive comments to the following functions:

- mrb_range_ptr
- mrb_range_new
- mrb_range_beg_len

The comments were written by Google Jules.
2025-06-04 11:03:35 +09:00
Yukihiro "Matz" Matsumoto 99d9568aeb Merge pull request #6544 from zenspider/zenspider/frozen_strings 2025-06-04 11:03:26 +09:00
Yukihiro "Matz" Matsumoto 851f9f61a9 Merge pull request #6545 from mruby/add-comments-class-c 2025-06-04 11:00:55 +09:00
google-labs-jules[bot] e68eafd511 Add descriptive comments for MRB_API functions in src/class.c
This commit adds C-style block comments to all MRB_API functions
defined in the src/class.c file. The comments explain the purpose
of each function, its parameters, and its return value, aiming to
improve code readability and maintainability.
2025-06-04 01:59:44 +00:00
Ryan Davis 59f08ff148 Fix build strings that must be mutable. Tested with RUBYOPT=--enable-frozen-string-literal make 2025-06-03 18:18:29 -07:00
Yukihiro "Matz" Matsumoto 8e0081923f Merge pull request #6543 from mruby/add-comments-dump-c-partial 2025-06-03 09:01:56 +09:00
google-labs-jules[bot] c837d386de Add descriptive comments to several functions in src/dump.c
This commit adds Doxygen-style comments to the following functions
in src/dump.c, ensuring "@brief" is not used:

Non-static functions (comments reviewed/updated):
- mrb_dump_irep
- mrb_dump_irep_binary
- mrb_dump_irep_cfunc

Static functions (new comments added):
- write_irep_header
- write_iseq_block
- dump_float (if compiled)
- get_pool_block_size
- write_pool_block
- get_syms_block_size
- write_syms_block
- get_irep_record_size

This work is part of a larger effort to document all non-trivial
functions in this file as per your feedback. The remaining functions
will be documented in subsequent commits.
2025-06-03 00:01:24 +00:00
Yukihiro "Matz" Matsumoto c3d2b903c6 error.c: add descriptive comments
The comments are written by Google Jules.
2025-06-03 08:53:06 +09:00
Yukihiro "Matz" Matsumoto 83b21e8fd6 Merge pull request #6542 from mruby/add-symbol-comments 2025-06-03 08:43:23 +09:00
google-labs-jules[bot] e8458f9c22 Add descriptive comments to MRB_API functions in src/symbol.c
This commit adds descriptive comments to all functions marked with MRB_API
in the `src/symbol.c` file. The comments explain the purpose, parameters,
and return values of these functions, improving code readability and
maintainability.

The following functions were commented:
- mrb_intern
- mrb_intern_static
- mrb_intern_cstr
- mrb_intern_str
- mrb_intern_check
- mrb_check_intern
- mrb_intern_check_cstr
- mrb_check_intern_cstr
- mrb_intern_check_str
- mrb_check_intern_str
- mrb_sym_name_len
- mrb_sym_str
- mrb_sym_name
- mrb_sym_dump
2025-06-02 23:42:40 +00:00
Yukihiro "Matz" Matsumoto d2728fb0ae mruby-time (mrb_to_time_t): separate into smaller functions
The code was written by Google Jules.
2025-06-02 16:05:44 +09:00
Yukihiro "Matz" Matsumoto 70956e9683 mruby-time: add descriptive comments
The comments were written by Google Jules.
2025-06-02 16:04:54 +09:00
Yukihiro "Matz" Matsumoto 91c59ced99 mruby-time: replace magic numbers to C macros
The code is written by Google Jules.
2025-06-02 15:55:44 +09:00
Yukihiro "Matz" Matsumoto 46b8e80d9e Merge pull request #6541 from mruby/add-api-comments-array 2025-06-02 08:48:57 +09:00
google-labs-jules[bot] 7f3329e393 Add descriptive comments for MRB_API functions in src/array.c
This change adds C-style multiline comments to all functions
marked with MRB_API in the src/array.c file.

The comments explain each function's purpose, its parameters,
and what it returns, where applicable. This improves the
readability and maintainability of the C API for mruby arrays.

The `@brief` markup was intentionally avoided as per your
requirements.
2025-06-01 23:48:11 +00:00
Yukihiro "Matz" Matsumoto 9c5d1cdaa9 Merge branch 'jules_wip_7626599795303680331' 2025-06-01 17:58:39 +09:00
google-labs-jules[bot] 493cc64902 hash.c: add descriptive comments to C-facing MRB_API hash functions
This commit adds C-style descriptive comments to MRB_API functions
in `src/hash.c` that are intended for use as part of mruby's C API.
The comments are targeted at C developers using these functions directly.

Comments were added or updated for the following functions:
- mrb_hash_new: Added comment.
- mrb_hash_new_capa: Updated existing comment to be more C API user-centric.
- mrb_hash_dup: Added comment.
- mrb_hash_get: Added comment.
- mrb_hash_fetch: Added comment.
- mrb_hash_set: Added comment.
- mrb_hash_delete_key: Added comment.
- mrb_hash_size: Added comment.
- mrb_hash_merge: Added comment.
- mrb_hash_foreach: Comment updated in a previous phase of work.

This work aligns with the guideline to comment C-facing MRB_API functions,
while avoiding adding new C-API comments to those MRB_API functions
that solely implement Ruby methods and already have extensive Ruby
method documentation (call-seq) in the source. The @brief markup
was avoided as per the original issue request.
2025-06-01 17:57:30 +09:00
Yukihiro "Matz" Matsumoto 273e7325c9 Merge pull request #6538 from mruby/dependabot/bundler/rake-13.3.0 2025-05-31 22:48:52 +09:00
Yukihiro "Matz" Matsumoto ec68497a39 Merge pull request #6540 from mruby/add-comments-object-c 2025-05-31 22:48:02 +09:00
Yukihiro "Matz" Matsumoto 05c7aa2fe2 Merge pull request #6539 from mruby/add-string-comments 2025-05-31 22:47:45 +09:00
google-labs-jules[bot] f4b56a5e56 Add descriptive comments to MRB_API functions in object.c
This commit adds and updates C-style block comments for all functions marked with MRB_API in src/object.c.

The comments explain the purpose, parameters, and return values of these functions, adhering to the project's documentation style and avoiding the use of '@brief' markup.

Existing comments were also reviewed and updated for clarity and consistency.
2025-05-31 13:45:31 +00:00
google-labs-jules[bot] 5924a23b8d Here's the rewritten message:
Add descriptive comments for MRB_API functions in src/string.c

This commit adds descriptive comments to various MRB_API functions
within the src/string.c file. These comments aim to improve code
readability and maintainability by explaining the purpose,
parameters, and return values of these functions.
2025-05-31 13:44:19 +00:00
dependabot[bot] bbb5d28530 build(deps): bump rake from 13.2.1 to 13.3.0
Bumps [rake](https://github.com/ruby/rake) from 13.2.1 to 13.3.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.2.1...v13.3.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-30 14:40:20 +00:00
Yukihiro "Matz" Matsumoto df62559ddb Merge pull request #6537 from mruby/add-cdump-comments 2025-05-30 07:24:00 +09:00
Yukihiro "Matz" Matsumoto b925d6fee4 Merge pull request #6536 from mruby/add-debug-comments 2025-05-30 07:23:45 +09:00
google-labs-jules[bot] bee56a8634 The comments in cdump.c have been updated to remove the @brief tag from the Doxygen-style comment for the mrb_dump_irep_cstruct function. This change was made based on your feedback.
The rest of the comment, which details the function's purpose, parameters, return values, and conditional compilation, remains unchanged.
2025-05-29 22:22:07 +00:00
Yukihiro "Matz" Matsumoto 0011ee2267 Merge pull request #6535 from mruby/add-mempool-comments 2025-05-29 10:06:32 +09:00
Yukihiro "Matz" Matsumoto 70614ba82a Merge pull request #6534 from mruby/add-readfloat-comment 2025-05-29 09:25:39 +09:00
google-labs-jules[bot] a668834b2d Add descriptive comments to public functions in src/debug.c
This change adds Doxygen-style comments to the public API functions
in `src/debug.c`, including mrb_packed_int_len, mrb_packed_int_encode,
and mrb_packed_int_decode. The comments explain the purpose of each function,
its parameters, and its return value. This improves the readability
and maintainability of the code.
2025-05-28 22:06:18 +00:00
google-labs-jules[bot] e0d1f99744 I've added descriptive comments for functions/macros in src/mempool.c.
This commit adds Doxygen-style comments to the public functions,
internal static functions, and structs within the `src/mempool.c` file.
These comments clarify the purpose, parameters, and return values (where applicable)
of these code elements, improving code readability and maintainability.

The following elements were commented:
- struct mempool_page
- struct mempool
- ALIGN_PADDING macro
- mempool_open()
- mempool_close()
- page_alloc()
- mempool_alloc()
- mempool_realloc()
2025-05-28 22:02:53 +00:00
google-labs-jules[bot] 224d0c8933 Add descriptive comment to mrb_read_float function
This commit adds a descriptive comment at the beginning of the `mrb_read_float` function in `src/readfloat.c`.

The comment explains the function's purpose, its parameters (`str`, `endp`, `fp`), and its return value (`TRUE` or `FALSE`). This improves code readability and understanding.
2025-05-28 22:01:17 +00:00
Yukihiro "Matz" Matsumoto e5905fe1dc Merge pull request #6533 from katafrakt/fix-extended-callback 2025-05-28 11:13:38 +09:00
Yukihiro "Matz" Matsumoto eb5fbfbb40 class.c: Remove MRB_INLINE_METHOD_CACHE support from mt_tbl
The sorted array binary search implementation no longer uses the inline
cache array, so remove all MRB_INLINE_METHOD_CACHE definitions and
related code.
2025-05-28 08:33:21 +09:00
Yukihiro "Matz" Matsumoto e8ebeb151d class.c: Switch mt_tbl to sorted array binary search for method lookups
By replacing the open‐addressing hash with a sorted array and binary
search, we eliminate tombstone management and improve cache locality of
method entries. This preserves the original contiguous values+keys
layout and peak memory usage, while simplifying growth logic and
delivering lookup performance gains.
2025-05-28 07:54:42 +09:00
Paweł Świątkowski bdcd496bc2 Fix calling extended callback
The callback of extending module should be called, not of a singleton
class of an extended object.
2025-05-27 23:03:10 +02:00
Yukihiro "Matz" Matsumoto bec5dbc4e9 variable.c (iv_copy): just memcpy sorted array; no iv_put 2025-05-27 10:58:41 +09:00
Yukihiro "Matz" Matsumoto 63a09ee336 variable.c (iv_rehash): just memcpy sorted array; no need to call iv_put 2025-05-27 10:53:58 +09:00
Yukihiro "Matz" Matsumoto 9cee6ead4c variable.c: use binary search for iv_tbl lookups
Preserve the original iv_tbl heap layout and allocation pattern, but
switch iv_put to maintain sorted keys and iv_get/iv_del to perform
binary search. This eliminates extra probing overhead, improves
read-heavy lookup performance for small tables, and incurs zero
additional allocations.
2025-05-27 10:33:09 +09:00
Yukihiro "Matz" Matsumoto ca6dc4ec2d variable.c (iv_size): refactor the function
Along with removing an obsolete comment line.
2025-05-27 10:16:12 +09:00
Yukihiro "Matz" Matsumoto 7c02e17e25 variable.c (mrb_mod_cv_get): initialize local variable
To silence compiler warning.
2025-05-26 22:59:04 +09:00
Yukihiro "Matz" Matsumoto 11bf789730 array.c: remove unnecessary blank line 2025-05-26 14:32:19 +09:00
Yukihiro "Matz" Matsumoto 9537d9b75a Merge pull request #6532 from mruby/improve-mt-hash-load-factor 2025-05-25 20:57:36 +09:00
google-labs-jules[bot] e82f49adf7 I've reverted method table optimizations to prioritize memory savings for you.
My previous attempts to improve method table (mt_tbl) performance by introducing a load factor and adjusting the initial allocation size unfortunately led to undesirable increases in memory consumption.

Given that memory usage is a primary concern, I've reverted the following changes:
- Removed the load factor based rehashing logic.
- Removed the related definitions for the load factor.
- Ensured the initial allocation size is 8.

This restores the method table to its original behavior, where it rehashes only when the table is completely full or during initial allocation. This should bring memory usage back to its baseline level prior to these optimization attempts.
2025-05-25 11:40:43 +00:00
Yukihiro "Matz" Matsumoto ed8ec097a2 Merge pull request #6531 from mruby/improve-mt-hash-load-factor 2025-05-25 20:12:46 +09:00
google-labs-jules[bot] 8a91c91a69 Improve method table performance by rehashing at 75% load factor.
The method table (mt_tbl) in src/class.c previously only rehashed when it became completely full. With linear probing, this could lead to significant performance degradation for lookups and insertions as the table approached full capacity.

This change introduces a load factor (MT_LOAD_FACTOR_NUM/MT_LOAD_FACTOR_DEN, set to 3/4 or 0.75). The mt_put function now checks if adding a new element would cause the table's size to meet or exceed this load factor relative to its allocated capacity. If so, it triggers a rehash before inserting the new element.

This helps maintain more empty slots in the hash table, improving the average-case performance of linear probing and reducing the likelihood of worst-case scenarios. The existing initial allocation size and doubling strategy for rehashing are retained.
2025-05-24 22:50:29 +00:00
Yukihiro "Matz" Matsumoto 0c51a72bfe string.c (popcount): support when sizeof(int) == 4
This function is used when the compiler does not support builtin
popcount operation (namely VC++).
2025-05-23 23:10:45 +09:00
Yukihiro "Matz" Matsumoto ca526044d3 vm.c (stack_init): clear initial stack 2025-05-23 23:09:53 +09:00
Yukihiro "Matz" Matsumoto 86ef7a912d mruby-rational (int_lshift): check before actual left bit shift 2025-05-21 13:25:08 +09:00
Yukihiro "Matz" Matsumoto f4b01ed19e mruby-rational (int_lshift): exponential may be bigger than int bits 2025-05-21 10:40:02 +09:00
Yukihiro "Matz" Matsumoto 1fa9eaa2b5 mruby-eval (binding_eval_error_check): re-raise Exception in parsing 2025-05-21 10:25:35 +09:00
Yukihiro "Matz" Matsumoto 77d08772a5 error.c (mrb_vformat): prevent SEGV from %s with NULL 2025-05-21 09:52:10 +09:00
Yukihiro "Matz" Matsumoto 1726b61481 mruby-compiler (gen_move): avoid unnecessary goto's 2025-05-20 18:31:51 +09:00
Yukihiro "Matz" Matsumoto d329d9af79 mruby-compiler (gen_move): avoid optimization of ADDI/SUBI
ADDI/SUBI may fall back to method call that may clear block argument
place holder, which may be a live register. So we cannot directly call
ADDI/SUBI over local variables.
2025-05-20 18:31:21 +09:00
Yukihiro "Matz" Matsumoto d08276a052 codedump.c: remove unnecessary tab character from OP_MOVE 2025-05-19 23:36:16 +09:00
Yukihiro "Matz" Matsumoto 82d03b32f2 codedump.c: skip string body if it's empty 2025-05-19 23:34:02 +09:00
Yukihiro "Matz" Matsumoto f9414456a5 codedump.c: output format for OP_ARRAY has changed 2025-05-19 23:09:03 +09:00
Yukihiro "Matz" Matsumoto 1d426c50bf range.c (range_num_to_a): C++ compiler eagerly warns goto statement 2025-05-19 19:41:01 +09:00
Yukihiro "Matz" Matsumoto 94d9f6cfc7 range.c (range_num_to_a): support big integer beg/end in ranges 2025-05-19 17:36:54 +09:00
Yukihiro "Matz" Matsumoto ff4109735f range.c (range_num_to_a): improved float support 2025-05-19 17:36:45 +09:00
Yukihiro "Matz" Matsumoto 18c43c2a5a mruby-io: provide Kernel#p in this gem
To prevent ordering instability when output from mruby-io and Kernel#p
mixed.
2025-05-19 13:31:01 +09:00
Yukihiro "Matz" Matsumoto 65247613b9 Merge pull request #6530 from dearblue/visibility 2025-05-19 08:11:18 +09:00
Yukihiro "Matz" Matsumoto 31ebcb349e mruby-compiler: add y.tab.c in the repository again; close #6515
Since we have introduced lrama, everyone can generate same `y.tab.c`
on any platform, without installing Bison. That was the reason we have
removed `y.tab.c` from the repository. But this change cause #6515 and
bothered out-of-tree builds. So we (reluctantly) added `y.tab.c` again.
2025-05-19 08:00:37 +09:00
Yukihiro "Matz" Matsumoto c356e8f2ff .gitignore: no longer ignore y.tab.c; ref #6515 2025-05-19 08:00:36 +09:00
Yukihiro "Matz" Matsumoto 96cbde7988 mruby-compiler: remove mrb_free dependency from codegen.c 2025-05-19 08:00:36 +09:00
Yukihiro "Matz" Matsumoto bb712f9467 mruby-compiler: remove mrb_calloc dependency from parse.y 2025-05-19 08:00:36 +09:00
Yukihiro "Matz" Matsumoto 9fc58852e3 mruby-compiler: removed mrb_state dependency from two functions
- mrb_ccontext_partial_hook
- mrb_ccontext_cleanup_local_variables
2025-05-19 08:00:36 +09:00
Yukihiro "Matz" Matsumoto fa19d7d3b5 stdlib.gembox: add mruby-catch to the gembox 2025-05-19 08:00:36 +09:00
dearblue 36df859333 Revert "class.c (find_visibility_scope): when callinfo returns, *ep == NULL; #6512"
This reverts commit 3879b95a62.

This is because the code first reported in #6494 no longer works.
2025-05-18 18:52:32 +09:00
dearblue 4417321d1c Add more test code for method visibility
This test corresponds to the first issue of #6494.
Complement to #6512.
2025-05-18 18:50:02 +09:00
Yukihiro "Matz" Matsumoto b952ca30cd Merge pull request #6529 from mruby/dependabot/github_actions/super-linter/super-linter-7.4.0 2025-05-15 05:46:57 +09:00
dependabot[bot] ef840eced0 build(deps): bump super-linter/super-linter from 7.3.0 to 7.4.0
Bumps [super-linter/super-linter](https://github.com/super-linter/super-linter) from 7.3.0 to 7.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/v7.3.0...v7.4.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-14 14:19:47 +00:00
Yukihiro "Matz" Matsumoto 923b1c9e37 stdlib.gembox: add mruby-enum-chain gem 2025-05-14 15:58:24 +09:00
Yukihiro "Matz" Matsumoto 9e6ddbb2ad metaprog.gembox: add two binding gems
- mruby-binding
- mruby-proc-binding
2025-05-14 15:58:24 +09:00
Yukihiro "Matz" Matsumoto d414e3f912 math.gembox: exclude mruby-cmath from math gembox 2025-05-14 15:58:23 +09:00
Yukihiro "Matz" Matsumoto 34bd571a65 Merge pull request #6528 from jbampton/fix-grammar-spelling 2025-05-14 15:58:05 +09:00
Yukihiro "Matz" Matsumoto 1fcaa3995e Merge pull request #6418 from jbampton/add-ls-lint 2025-05-14 15:55:33 +09:00
John Bampton 781edbd446 misc: fix spelling 2025-05-14 02:01:02 +10:00
John Bampton 4f2f2cfd20 Add ls-lint with GitHub Actions
Rename files in the `mrbgems` directory
2025-05-14 01:14:02 +10:00
Yukihiro "Matz" Matsumoto 93a7e5ec26 Merge pull request #6526 from vickash/luckfox-pico 2025-05-13 16:46:23 +09:00
Yukihiro "Matz" Matsumoto 75466f9aab mruby-compiler: use mrb_basic_alloc_func() directly from compiler
As a side effect, memory allocation failure may cause segmentation
fault. Maybe we have to add error detection later.
2025-05-13 13:20:06 +09:00
Yukihiro "Matz" Matsumoto 9ef2f551b7 mruby-compiler: use new mempool API 2025-05-13 08:13:48 +09:00
Yukihiro "Matz" Matsumoto dbc9d12254 mempool.c (mempool_open): avoid using old API in mempool.c 2025-05-12 13:04:22 +09:00
Yukihiro "Matz" Matsumoto ebca0cbf6a Merge pull request #6525 from hasse09052/skip-empty-mirb-history 2025-05-12 12:59:28 +09:00
Yukihiro "Matz" Matsumoto c2d5a402ba compile.h: change struct mrb_mempool to mrb_mempool
So that compatibility layer can be used without macro definition.
2025-05-12 12:30:15 +09:00
vickash 6700c327ac Luckfox Pico config: Use realpath, comment flags and cmath exclusion 2025-05-11 23:25:32 -04:00
vickash f98a05c738 Add build config for Luckfox Pico embedded SBC 2025-05-11 22:35:05 -04:00
Yukihiro "Matz" Matsumoto 6566099dbb mempool.c: remove mrb_state dependency from mempool library
mempool.h provide compatibility layer so that existing programs does not
need to update (but update recommended anyway, since compatibility layer
takes mrb_state that is not used at all).
2025-05-12 08:26:18 +09:00
Yukihiro "Matz" Matsumoto 6766fcb905 class.c (mt_rehash): Fix mrb_calloc argument order
Since mrb_calloc() (along with mrb_calloc) takes two arguments: nmemb
which is number of array elements, and size which is size of the array.
Of course, revsersing does not change the behavior, but we'd like to
respect the original design intention of calloc(3).
2025-05-11 20:11:56 +09:00
Yukihiro "Matz" Matsumoto 4704a7700a Merge pull request #6521 from jbampton/add-codespell-config 2025-05-11 20:09:25 +09:00
hasse 6df8096af2 mruby-bin-mirb: skip adding empty input to mirb history 2025-05-11 02:44:04 +09:00
Yukihiro "Matz" Matsumoto c6e3ae7e74 doc/guides/memory.md: update the document
- new API
- detailed hook description
- migration path from old API
2025-05-10 09:34:20 +09:00
Yukihiro "Matz" Matsumoto 7e4810658e allocf.c: update and enhance documentation in the comment 2025-05-10 09:07:35 +09:00
Yukihiro "Matz" Matsumoto 5522c94bb3 mruby.h: remove mrb_allocf type
As a result, we removed (already obsoleted) `mrb_open_allocf()', and
made `mrb_open_core()` take no argument. [incompatible changes]
2025-05-10 08:59:18 +09:00
Yukihiro "Matz" Matsumoto 5c71681d82 allocf.c (mrb_basic_alloc_func): remove ud argument 2025-05-10 08:59:18 +09:00
Yukihiro "Matz" Matsumoto c3cc559dfc allocf.c: rename mrb_default_alloc to mrb_basic_alloc_func
Along with removing mrb_state first argument from the function. From
mruby 3.2, this function is *not* the default function, but the entry
point that can be redefined for the application. The function in
`src/allocf.c` is the default *implementation* (using malloc / realloc /
free) of the function.
2025-05-09 21:50:18 +09:00
John Bampton f515669ce3 Add codespell config file .codespellrc
Add `.codespellrc` to the GitHub labeler

Can now run codespell from the command line standalone and it will use
our standard config file. Running codespell with pre-commit will also use this config.

Useful when regenerating the ignored words file on the command line.

https://github.com/codespell-project/codespell?tab=readme-ov-file#using-a-config-file

https://github.com/codespell-project/codespell?tab=readme-ov-file#pre-commit-hook
2025-05-09 20:54:27 +10:00
Yukihiro "Matz" Matsumoto 0bdd529430 mruby.h: remove allocf and allocf_ud from mrb_state
This is preparation for memory allocation restructuring.
2025-05-09 18:13:28 +09:00
Yukihiro "Matz" Matsumoto 3d2f848e64 mruby-random: Random#rand(nil) should raise TypeError 2025-05-08 17:37:05 +09:00
Yukihiro "Matz" Matsumoto 88e86ee62e mruby-random: update error messages to be compatible with CRuby; #6523 2025-05-08 16:42:33 +09:00
Yukihiro "Matz" Matsumoto 21d6bfb6dd test/kernel.rb: disable some Kernel#p tests; ref #6524 2025-05-08 16:21:01 +09:00
Yukihiro "Matz" Matsumoto 37b84f40e0 Merge pull request #6523 from leviongit/rand-range 2025-05-08 16:06:02 +09:00
Yukihiro "Matz" Matsumoto 5b10fdf684 Merge pull request #6524 from hasumikin/fix/Kernel#p 2025-05-08 16:01:35 +09:00
Yukihiro "Matz" Matsumoto 147af9d669 Merge pull request #6522 from jbampton/label-more-files 2025-05-08 15:59:47 +09:00
Yukihiro "Matz" Matsumoto 3879b95a62 class.c (find_visibility_scope): when callinfo returns, *ep == NULL; #6512 2025-05-08 12:02:32 +09:00
Yukihiro "Matz" Matsumoto 2b0d866da1 class.c (find_visibility_scope): rename the function; ref #6512
Since the function returns either callinfo or env, thus the name does
not describe the current behavior. In addition, we did some refactoring
on the function.
2025-05-08 12:02:00 +09:00
Yukihiro "Matz" Matsumoto 50c8e180d8 class.c (find_visibility_ci): refactor to reduce complexity; ref #6512 2025-05-08 07:57:35 +09:00
Yukihiro "Matz" Matsumoto dbc4768758 mruby/internal.h: rename visibility separation macros; ref #6512 2025-05-08 07:32:36 +09:00
Yukihiro "Matz" Matsumoto c9a36e5d39 mruby/value.h: rename flag check macros; ref #6512 2025-05-08 07:27:30 +09:00
Yukihiro "Matz" Matsumoto 41e91a2ca8 vm.c (mrb_exec_irep): remove recently added separate_module argument
The argument was added in #6512
2025-05-08 07:27:23 +09:00
Yukihiro "Matz" Matsumoto ef0cbc2981 mruby-eval (exec_irep): cache mrb->c->ci to a local variable 2025-05-07 23:30:41 +09:00
Yukihiro "Matz" Matsumoto 567617ceb5 Merge branch 'dearblue-visibility' 2025-05-07 15:37:37 +09:00
Yukihiro "Matz" Matsumoto aec8d0c58b Merge branch 'visibility' of github.com:dearblue/mruby into dearblue-visibility 2025-05-07 15:37:08 +09:00
Yukihiro "Matz" Matsumoto 81f5f5b8d4 mruby-bin-debugger: should not use Exception#inspect to print errors
Use mrb_exc_get_output() instead.
2025-05-07 12:34:13 +09:00
Yukihiro "Matz" Matsumoto c36d9b7732 mruby-bin-mirb: should not use Exception#inspect to print errors
Use mrb_exc_get_output() instead.
2025-05-07 12:32:12 +09:00
Yukihiro "Matz" Matsumoto 6eb969ff04 backtrace.c (print_backtrace): use mrb_exc_get_output()
To keep the old error print even after Exception#inspect format changed.
2025-05-07 12:22:11 +09:00
Yukihiro "Matz" Matsumoto 33d9ad6c44 error.c (mrb_exc_get_output): a new function for old inspect format 2025-05-07 12:19:05 +09:00
Yukihiro "Matz" Matsumoto 85d048c1fb mruby-error: update tests for new Exception#inspect format 2025-05-07 12:19:05 +09:00
Yukihiro "Matz" Matsumoto a87b4b6bc3 test/exception.rb: update for new Exception#inspect 2025-05-07 12:19:05 +09:00
Yukihiro "Matz" Matsumoto 333c364d5f error.c (mrb_exc_inspect): Update format to match CRuby 2025-05-07 12:19:04 +09:00
Yukihiro "Matz" Matsumoto b5ad35d8ef proc.h (MRB_SET_VISIBILITY_FLAGS): rename macro 2025-05-07 12:19:04 +09:00
Yukihiro "Matz" Matsumoto 0da5e0e190 AUTHORS: update entries [ci skip] 2025-05-07 12:19:04 +09:00
Yukihiro "Matz" Matsumoto abfef2c38d Merge pull request #6520 from jbampton/update-pre-commit 2025-05-04 23:19:54 +09:00
leviongit 7be940942c random.c : treat ranges where r.begin > r.end the same way cruby does 2025-05-04 04:10:39 +02:00
leviongit 98906d5ac9 random.c : fix Random#rand not returning value 2025-05-04 03:48:22 +02:00
HASUMI Hitoshi fdfd67ff40 Fix Kernel#p when no argument
## Expected
```ruby
p
=> nil
```

## Actual
```ruby
p
=> []
```
2025-05-04 10:17:37 +09:00
leviongit 202c213fe1 random.c : add some tests 2025-05-04 02:44:19 +02:00
leviongit 4390aeb78d random.c : add rand(Range) 2025-05-04 02:44:19 +02:00
Yukihiro "Matz" Matsumoto 0723e10dcd Merge pull request #6519 from jbampton/update-prettier-ignore 2025-05-03 14:42:24 +09:00
John Bampton 757c0472d0 gha: label more files 2025-05-03 04:47:04 +10:00
John Bampton ddae958405 pre-commit: autoupdate and update node LTS version
https://nodejs.org/en

https://pre-commit.com/#pre-commit-autoupdate
2025-05-03 02:00:44 +10:00
John Bampton 7a3eebc1d5 Add tools/lrama to .prettierignore
Prettier uses an ignore file to exclude files from formatting when
running with pre-commit and also when running standalone from the command line.

This is detailed on the CLI docs page:

https://prettier.io/docs/cli
2025-05-03 01:42:36 +10:00
Yukihiro "Matz" Matsumoto 30d1db4528 10error.rb: move 2 more classes to error.c
- FloatDomainError
- RegexpError
2025-05-02 08:50:20 +09:00
Yukihiro "Matz" Matsumoto 0fb280adbf 10error.rb: move some error class definitions to error.c
- Exception
- ArgumentError
- LocalJumpError
- RangeErrpr
- TypeError
- IndexError
- KeyError
- NotImplementError
- FrozenError
- ZeroDivisionError
2025-05-01 15:10:55 +09:00
Yukihiro "Matz" Matsumoto 1bc16676a1 class.c: implement BasicObject#!= in C file
The method is defined in inline bytecode. As a side-effect, `00class.rb`
was removed.
2025-05-01 10:23:03 +09:00
Yukihiro "Matz" Matsumoto 683ecc09b5 codedump.c: do not print extra ';' if operands are not local vars 2025-04-30 07:54:40 +09:00
Yukihiro "Matz" Matsumoto 789d350da9 codedump.c: put parenthesis around virtual operand
Some operands are virtual (e.g. `a` and `a+1`). It is easier to count
instructions if you can distinguish virtual and real operands.
2025-04-29 07:49:59 +09:00
Yukihiro "Matz" Matsumoto 08f74dd2be class.c: move alias attr attr_reader from 00class.rb 2025-04-28 14:20:07 +09:00
Yukihiro "Matz" Matsumoto 1b39c7d7da mruby-compiler (codegen): private backquote should be called; fix #6516 2025-04-28 10:40:05 +09:00
Yukihiro "Matz" Matsumoto e9d20a1590 doc/limitations.md: document double dispatch removal
We have removed `append_features`/`prepend_features`/`extend_object`.
It is incompatible with CRuby, but simpler.
2025-04-28 10:30:01 +09:00
Yukihiro "Matz" Matsumoto 6c72f8b378 class.c (extend_object): remove method; implement Kernel#extend in C 2025-04-28 10:30:00 +09:00
Yukihiro "Matz" Matsumoto 6c25b5896a class.c (prepend_features): remove the method
Just like `#append_features`, we remove `#prepend_features` and
implemented `#prepend` directly in C.
2025-04-28 10:30:00 +09:00
Yukihiro "Matz" Matsumoto 9387cd382e class.c (append_features): remove the method
The technique is called "double dispatch" (that was popular in
Smalltalk), but it does not work well with mruby. It's slower and
consumes more memory. Even thought `#append_features` defined in ISO
standard (15.2.2.4.11), we decided to remove it. Strictly speaking, it
is mruby limitation. And it should be documented clearly.
2025-04-28 10:30:00 +09:00
Yukihiro "Matz" Matsumoto 5fe406d59c vm.c (send_method): should not use C++ keyword public 2025-04-28 10:30:00 +09:00
Yukihiro "Matz" Matsumoto a6ef3a45d1 vm.c (mrb_f_public_send): define #public_send method
The method itself is available when mruby-metaprog is loaded.
2025-04-25 17:39:12 +09:00
Yukihiro "Matz" Matsumoto dd96afd5a8 variable.c (mrb_const_set): call const_added hook 2025-04-25 16:25:36 +09:00
Yukihiro "Matz" Matsumoto e5478c2b40 class.c (setup_class): simplified using mrb_const_set() 2025-04-25 16:23:02 +09:00
Yukihiro "Matz" Matsumoto 8f120971b5 variable.c: merge mrb_vm_const_set to mrb_const_set
Inline vm part to the VM itself.
2025-04-25 16:12:06 +09:00
Yukihiro "Matz" Matsumoto 03719490eb class.c: define const_added method (with empty body) 2025-04-25 15:56:57 +09:00
Yukihiro "Matz" Matsumoto 6e1538ce3a Merge pull request #6518 from HirohitoHigashi/master 2025-04-25 15:51:36 +09:00
Yukihiro "Matz" Matsumoto 279855985f Merge pull request #6517 from jbampton/remove-unneeded-semicolon 2025-04-25 15:46:14 +09:00
HirohitoHigashi 586ff7a694 Change mrbc_args.flags bit width from 2 to 3. 2025-04-25 12:05:01 +09:00
John Bampton fe201dc72f core/codegen.c: remove unneeded duplicate semicolon 2025-04-25 05:10:24 +10:00
Yukihiro "Matz" Matsumoto 9c6349c769 Merge pull request #6513 from mruby/stable 2025-04-21 13:57:27 +09:00
Hiroshi Mimaki d4097716b3 NEWS: remove wrong spelling from the pull-request description 2025-04-21 10:24:03 +09:00
mimaki 99f5668243 Merge branch 'master' into stable 2025-04-20 13:25:22 +09:00
mimaki a309524d0b Update version and release date. (mruby 3.4.0 (2025-04-20)) 2025-04-20 13:08:22 +09:00
Yukihiro "Matz" Matsumoto baea6e284e mruby-bigint (mpz_bits): use lzb() 2025-04-17 08:11:27 +09:00
Yukihiro "Matz" Matsumoto 061521ead5 mruby-bigint (mpz_bits): renamed from mpz_bit_length() 2025-04-17 08:10:34 +09:00
Yukihiro "Matz" Matsumoto 16198dc985 mruby-numeric-ext (int_sqrt): translate Japanese comment (oops) 2025-04-17 01:43:03 +09:00
Yukihiro "Matz" Matsumoto e42523fcf4 mruby-numeric-ext: add test for Integer.sqrt() 2025-04-16 23:30:23 +09:00
Yukihiro "Matz" Matsumoto ddfe65763e mruby-numeric-ext (int_sqrt): support bigint 2025-04-16 23:08:23 +09:00
Yukihiro "Matz" Matsumoto dee661913f mruby-numeric-ext (int_sqrt): Integer.sqrt implemented
This is the first version. It should support bigint eventually.
2025-04-16 22:37:06 +09:00
Yukihiro "Matz" Matsumoto 9a0f96e617 pre-commit autoupdate 2025-04-16 22:34:27 +09:00
Yukihiro "Matz" Matsumoto 8b213c4fbf string.c (sub_replace): check if found argument is within proper range
Since it is an internal method, we didn't check the argument range, but
if it's called directly, out-of-range argument could cause SEGV.
2025-04-15 07:11:09 +09:00
Yukihiro "Matz" Matsumoto 9cc6d39956 test/module.rb: add test for #6506 2025-04-14 22:09:35 +09:00
Yukihiro "Matz" Matsumoto 1969100fb4 variable.c (mrb_vm_get_const): seek singleton class superclass; fix #6506
Also ensure we don't revive #2515, #3003, #3598
2025-04-14 22:09:35 +09:00
Yukihiro "Matz" Matsumoto 953ebdf334 variable.c (mrb_vm_const_get): refactoring for singleton classes 2025-04-14 22:09:35 +09:00
Yukihiro "Matz" Matsumoto 95f9de4877 mruby-metaprog (mrb_mod_s_constants): Module.constants implemented
The method returns the list of all constants accessible from the point
of call.
2025-04-14 22:09:35 +09:00
Yukihiro "Matz" Matsumoto e08452585e variable.c (mrb_mod_cv_get): c must not be NULL as an argument 2025-04-14 22:09:34 +09:00
Yukihiro "Matz" Matsumoto 90d77e71f5 variable.c (mrb_mod_cv_set): small refactoring
The argument c should not be NULL.
2025-04-14 22:09:34 +09:00
Yukihiro "Matz" Matsumoto 118e13d85c variable.c: a new function mrb_mod_const_at()
And mrb_mod_constants() use the new function now.
2025-04-14 22:09:34 +09:00
Yukihiro "Matz" Matsumoto cda551ce25 mruby-metaprog (mrb_mod_s_constants): call Module#constants if possible
When the optional argument is given or the receiver is not `Module`.
2025-04-14 22:09:34 +09:00
Yukihiro "Matz" Matsumoto 82522a2e71 mruby-bigint (mrb_bint_to_s): add check for MRB_32BIT and MRB_INT64 2025-04-14 22:09:33 +09:00
Yukihiro "Matz" Matsumoto 29964b3ba7 mruby-io (mrb_file_size): add check for MRB_32BIT and MRB_INT64 2025-04-14 22:09:33 +09:00
Yukihiro "Matz" Matsumoto 0d5fecf833 variable.c (mrb_const_get): adjust local variable scope 2025-04-14 22:09:33 +09:00
dearblue 3fd5e1c250 Fixed visibility at method definition
There was a problem with visibility state from proc that straddles a fiber or is independent.

Therefore, it has been changed to give priority to env objects, if any.
Also, added "separate module" flag to block traversal to a higher level env object.

Note that the "separate module" flag is now set when calling blocks with the `mrb_yield_with_class()` function.

fixed https://github.com/mruby/mruby/issues/6494
2025-04-11 21:36:26 +09:00
Yukihiro "Matz" Matsumoto 52de3b7e10 Merge pull request #6511 from dearblue/precommit
Exclude the external project "lrama" from pre-commit
2025-04-08 23:44:31 +09:00
dearblue 40095bf755 Exclude the external project "lrama" from pre-commit 2025-04-08 22:11:32 +09:00
Yukihiro "Matz" Matsumoto 46aa35a117 Merge pull request #6510 from dearblue/visibility
Fixed class method visibility via `module_function`
2025-04-08 17:18:19 +09:00
dearblue 84e1b0045c Fixed class method visibility via module_function
The following code should work

```ruby
module M
  def me
    p self
  end

  module_function :me
end

M.me
```
2025-04-07 21:40:56 +09:00
Yukihiro "Matz" Matsumoto 1fdd961041 mruby-compiler (scope_new): need to initialize nregs; fix #6509
`nregs` should not be smaller than `nlocals`.
2025-04-07 11:35:19 +09:00
Yukihiro "Matz" Matsumoto 8c2ea232ea Revert "mruby-enum-ext (cycle): need to splat block parameters; #6508"
This reverts commit 6c4b799b42.
2025-04-07 08:23:52 +09:00
Yukihiro "Matz" Matsumoto 6c4b799b42 mruby-enum-ext (cycle): need to splat block parameters; #6508 2025-04-06 22:05:57 +09:00
Yukihiro "Matz" Matsumoto 96855d31b5 mruby-enum-ext (sum): need to honor index; fix #6508 2025-04-06 22:04:56 +09:00
Yukihiro "Matz" Matsumoto dd68681002 mruby-enum-ext: tally should respect multi-values; fix #6507 2025-04-05 22:12:51 +09:00
Yukihiro "Matz" Matsumoto cb8cd9388c mruby-enum-ext: filter_map should not ignore index; fix #6504 2025-04-05 21:44:49 +09:00
Yukihiro "Matz" Matsumoto 9750513c25 mruby-bigint (mpz_get_str): add type cast to stop warning 2025-04-04 23:55:44 +09:00
Yukihiro "Matz" Matsumoto bf36ba9d10 Merge pull request #6505 from jbampton/fix-spelling
mrbgems: fix spelling
2025-04-04 17:33:32 +09:00
John Bampton b1d910f6f4 mrbgems: fix spelling 2025-04-04 15:05:13 +10:00
Yukihiro "Matz" Matsumoto 76f7678db2 AUTHORS: update entries [ci skip] 2025-04-04 07:56:52 +09:00
Yukihiro "Matz" Matsumoto 07d7aa6fdb mruby-pack: fix int and mrb_int mixture 2025-04-02 16:45:11 +09:00
Yukihiro "Matz" Matsumoto b88680ee9e mruby-pack (pack_unpack): use mrb_bool instead of int 2025-04-02 16:44:06 +09:00
Yukihiro "Matz" Matsumoto 3684a27209 tools/lrama: update to lrama 0.7.0; close #6384 2025-04-02 00:16:23 +09:00
Yukihiro "Matz" Matsumoto 5c2c77c71c mruby-string (str_succ_bang): fixed sample string; close #6500
To avoid spellcheck failure in pre-commit.
2025-04-01 11:00:25 +09:00
Yukihiro "Matz" Matsumoto 4af6fe87c4 doc/mruby3.4.md: remove wrong spelling from the pull-request description 2025-03-31 21:42:01 +09:00
Yukihiro "Matz" Matsumoto 9405702e02 Merge pull request #6503 from jbampton/misc-typo-fixes
misc: fix typos
2025-03-31 16:16:55 +09:00
Yukihiro "Matz" Matsumoto 206eccb828 boxing_word.h: allow 4 byte alignment of object pointers
Only if MRB_WORDBOX_NO_FLOAT_TRUNCATE or MRB_NO_FLOAT is defined.
2025-03-30 23:23:02 +09:00
John Bampton b56f984c25 misc: fix typos 2025-03-30 14:04:34 +10:00
Yukihiro "Matz" Matsumoto 39fbc96eaf Merge pull request #6502 from jbampton/patch-2
pre-commit: update prettier to the latest version
2025-03-29 19:02:42 +09:00
John Bampton 14f2e6db5a pre-commit: update prettier to the latest version
https://www.npmjs.com/package/prettier
2025-03-29 16:31:58 +10:00
Yukihiro "Matz" Matsumoto a317b744f4 Merge pull request #6501 from jbampton/patch-2
Update pre-commit Node.js version to `v22.14.0 LTS`
2025-03-29 14:09:15 +09:00
John Bampton 14de644234 Update pre-commit Node.js version to v22.14.0 LTS 2025-03-29 07:32:47 +10:00
Yukihiro "Matz" Matsumoto 6a3e5b87f8 Merge pull request #6497 from jbampton/patch-2
gha: update `build.yml` try `windows-2025` image
2025-03-28 12:40:40 +09:00
Yukihiro "Matz" Matsumoto a9353c4f73 Merge pull request #6498 from jbampton/pre-commit-clean-up
Clean up and standardize the pre-commit config
2025-03-28 09:02:57 +09:00
Yukihiro "Matz" Matsumoto 2ce0606f14 guides/symbol.md: 'punctuation' is uncountable; close #6488
Issue #6488 is addressed by fixing spelling.
2025-03-28 08:22:53 +09:00
John Bampton c1a0a6193b pre-commit autoupdate 2025-03-28 08:04:21 +10:00
John Bampton 1ae4f94844 Clean up and standardize the pre-commit config 2025-03-28 07:39:59 +10:00
Yukihiro "Matz" Matsumoto 7538ee8f5d gperf: remove obsolete command line options -p and -g 2025-03-28 06:16:00 +09:00
John Bampton 68a0ecc782 gha: update build.yml try windows-2025 image
https://github.com/actions/runner-images?tab=readme-ov-file#available-images

https://github.com/actions/runner-images/blob/main/images/windows/Windows2025-Readme.md
2025-03-28 04:24:32 +10:00
Yukihiro "Matz" Matsumoto 0090e2cd01 github/workflows/coverage.yml: measure coverage on push only 2025-03-26 16:22:37 +09:00
Yukihiro "Matz" Matsumoto 7351f1127b vm.c: ci_bidx() returns mrb_int, that may be different in size from int 2025-03-26 16:19:26 +09:00
Yukihiro "Matz" Matsumoto d908daa8b9 mruby-rational (rational_hash): hash value is uint32_t 2025-03-25 08:10:49 +09:00
Yukihiro "Matz" Matsumoto b446b0d547 mruby-compiler: add type cast to silence warning 2025-03-25 08:10:04 +09:00
Yukihiro "Matz" Matsumoto a574034cb2 hash.c (hash_set_default_proc): mrb_proc_arity() returns mrb_int 2025-03-25 08:09:21 +09:00
Yukihiro "Matz" Matsumoto 4ca61298ac mruby-sprintf: add type cast to silence warning 2025-03-25 08:08:26 +09:00
Yukihiro "Matz" Matsumoto 7e18b1dadb mruby-fiber/fibertest.c: use ptrdiff_t for pointer difference 2025-03-24 22:31:27 +09:00
Yukihiro "Matz" Matsumoto b8351d6191 mruby-io/file.c: use ptrdiff_t for pointer difference 2025-03-24 22:30:53 +09:00
Yukihiro "Matz" Matsumoto dd2950211c mruby-io/mruby_io_test.c: use -1 for length (means strlen(s)) 2025-03-24 15:19:54 +09:00
Yukihiro "Matz" Matsumoto 4aae7be949 mruby-io (path_gethome): move local variable declarations 2025-03-24 14:03:13 +09:00
Yukihiro "Matz" Matsumoto a33426da15 mruby-io (mrb_file_s_chmod): check string type before casting 2025-03-23 20:04:25 +09:00
Yukihiro "Matz" Matsumoto 11f6251d23 mruby-io (mrb_file_basename): fixed a silly mistake 2025-03-22 13:01:38 +09:00
Yukihiro "Matz" Matsumoto cde0b7edeb Merge pull request #6495 from dearblue/cleanup
Remove `MRB_ENDIAN_LOHI()` that is no longer in use
2025-03-22 11:15:36 +09:00
Yukihiro "Matz" Matsumoto aa06aff50d mruby-io/file.c: use mrb_sys_fail instead of mrb_raise (w/ errno info) 2025-03-22 11:02:05 +09:00
dearblue 4e7399d4f4 Remove MRB_ENDIAN_LOHI() that is no longer in use 2025-03-21 21:56:42 +09:00
Yukihiro "Matz" Matsumoto f3b79fcc23 mruby-io (mrb_file_s_readlink): increase buffer size linearly 2025-03-21 19:34:05 +09:00
Yukihiro "Matz" Matsumoto ca693dec30 mruby-io (mrb_file_s_readlink): when rc == bufsize, rc never be -1 2025-03-21 19:31:12 +09:00
Yukihiro "Matz" Matsumoto 9e315af2a5 mruby-io (mrb_file_basename): fixed wrong strncmp usage 2025-03-21 10:37:05 +09:00
Yukihiro "Matz" Matsumoto 90d4805f5b mruby-io (mrb_file_realpath): use mrb_str_cat instead of mrb_str_append 2025-03-20 22:04:49 +09:00
Yukihiro "Matz" Matsumoto 5bc391e170 mruby-io (mrb_file_basename): use mrb_str_cat() instead of snprintf(3) 2025-03-20 22:03:30 +09:00
Yukihiro "Matz" Matsumoto ed00879923 Merge pull request #6493 from hasumikin/patch-1
Fix TYPO in memory.md
2025-03-20 14:42:56 +09:00
Yukihiro "Matz" Matsumoto dbafada7be mruby-io (mrb_file_basename): use "z" specifier for mrb_get_args() 2025-03-20 13:39:38 +09:00
HASUMI Hitoshi 1ec84a2874 Fix TYPO in memory.md
No `alloc.c` in the source tree. It'd be `allocf.c`
2025-03-20 10:15:20 +09:00
Yukihiro "Matz" Matsumoto 226acdc540 hash.c (mrb_hash_set_default_proc): avoid repeated calls for mrb_nil_p() 2025-03-19 14:57:02 +09:00
Yukihiro "Matz" Matsumoto a55e3685a9 string.c: rename local variable indx to idx
`indx` seems not to be a common abbreviation.
2025-03-18 10:40:30 +09:00
Yukihiro "Matz" Matsumoto c0024e1077 Merge pull request #6492 from jethrodaniel/fix-typo
fix a typo, update specs
2025-03-18 10:40:00 +09:00
Mark Delk 6396aac434 fix a typo, update specs 2025-03-17 10:47:33 -05:00
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
mimaki b4f36b1ad9 Merge branch 'master' into stable 2023-01-18 10:45:35 +09:00
Yukihiro "Matz" Matsumoto 3a7e138c05 mruby/internal.h: add mrb_env_new to the internal function header 2023-01-18 10:37:48 +09:00
Yukihiro "Matz" Matsumoto e6cf932d38 fixup! mruby/internal.h: add codedump functions to the internal function header 2023-01-18 10:37:48 +09:00
Yukihiro "Matz" Matsumoto 55eea005c8 mruby/internal.h: add codedump functions to the internal function header
ref #5906
2023-01-18 10:37:48 +09:00
mimaki 23aa5f91bc Update version to 3.2.0RC2. 2023-01-18 10:26:58 +09:00
mimaki 830f88c5a0 Merge commit '9deb52c7b2ba6028d996172bfdd6cf8a0405ce1c' into stable 2023-01-18 09:45:23 +09:00
Yukihiro "Matz" Matsumoto 3639feb047 Merge pull request #5908 from dearblue/env-unshare.2
Make `mrb_env_unshare()` call in `mrb_vm_run()`
2023-01-18 08:05:00 +09:00
Yukihiro "Matz" Matsumoto 63597cbbd1 Merge pull request #5910 from mruby/dependabot/github_actions/github/super-linter-4.10.1
build(deps): bump github/super-linter from 4.10.0 to 4.10.1
2023-01-18 07:53:11 +09:00
Yukihiro "Matz" Matsumoto faa6a5cb4f Merge pull request #5906 from AlexDenisov/codedump-to-file
Add ability to dump bytecode into an arbitrary file
2023-01-18 07:37:12 +09:00
AlexDenisov e15288e460 Add ability to dump bytecode into an arbitrary file 2023-01-17 19:01:55 +01:00
dependabot[bot] 823b8e4148 build(deps): bump github/super-linter from 4.10.0 to 4.10.1
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.10.0 to 4.10.1.
- [Release notes](https://github.com/github/super-linter/releases)
- [Changelog](https://github.com/github/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/github/super-linter/compare/v4.10.0...v4.10.1)

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

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

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

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

    env stack       |                           |

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

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

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

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

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

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

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

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

  mrb_close(mrb);

  return 0;
}

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

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

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

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

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

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

A lot more quick links and statistics.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Fix up

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

    Merge branch 'master' into ruby-remove-parenthesis

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

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

```mermaid
flowchart LR

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

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

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

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

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

This patch makes the catch handler search first:

```mermaid
flowchart LR

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

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

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

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

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

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

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

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

The Google shell style guide states:

Executables should have no extension (strongly preferred)

This hook checks for conformance.

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

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

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

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

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

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

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

macOS uses the `open` command.

Add info to install doxygen on macOS with Homebrew.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

The main purpose on this patch is:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Other changes:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

```c
// code.c

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

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

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

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

  return self;
}

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

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

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

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

  mrb_close(mrb);

  return 0;
}
```

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

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

Also run `pre-commit autoupdate`

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

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

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

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

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

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

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

The following is an example of an actual crash:

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

File.readlink("/404")

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

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

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

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

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

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

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

ref. #2485
2022-04-01 23:25:20 +09:00
Yukihiro "Matz" Matsumoto 00acae117d vm.c: target class may be NULL. 2022-04-01 16:40:06 +09:00
Yukihiro "Matz" Matsumoto d1f1b4ea38 cdump.c: add const qualifier for line number arrays. 2022-04-01 15:02:39 +09:00
Yukihiro "Matz" Matsumoto 9de6065ae2 Merge pull request #5680 from jbampton/pre-commit-autoupdate
pre-commit autoupdate
2022-04-01 14:57:08 +09:00
John Bampton cc380c6546 pre-commit autoupdate
https://pre-commit.com/#pre-commit-autoupdate
2022-04-01 08:26:40 +10:00
mimaki 7d3bc5c3d7 Update version to 3.1.0RC2. 2022-03-31 15:17:17 +09:00
Yukihiro "Matz" Matsumoto f71d389649 codegen.c: fix the negative division regression; fix #5678 2022-03-31 13:05:06 +09:00
Yukihiro "Matz" Matsumoto eaadc5e79f parse.y: empty here-doc delimiter caused infinite loop; fix #5676 2022-03-31 13:01:27 +09:00
Yukihiro "Matz" Matsumoto c627e3b2ab codegen.c: fix a bug in super with keyword arguments; fix #5660 2022-03-31 13:00:34 +09:00
Yukihiro "Matz" Matsumoto 9424e4d4cf parse.y: revert 9e064f2; fix #5647
Need to declare unnamed parameter when argument decomposition used.
2022-03-31 12:59:44 +09:00
Yukihiro "Matz" Matsumoto 64d3f4c730 vm.c: need to adjust argument after packing keyword args; fix #5632
It was caused by #5628.
2022-03-31 12:58:48 +09:00
Yukihiro "Matz" Matsumoto a3f2c95334 codegen.c: skip overwritten MOVE instructions. 2022-03-30 15:34:40 +09:00
Yukihiro "Matz" Matsumoto 60cf382ff9 codegen.c: peephole optimize consecutive MOVE instructions. 2022-03-29 22:36:40 +09:00
Yukihiro "Matz" Matsumoto 9593c15603 AUTHORS: update entries [ci skip] 2022-03-28 17:21:10 +09:00
Yukihiro "Matz" Matsumoto bb5f6a8b56 Merge pull request #5679 from dearblue/expiration-code
Remove old compatibility code
2022-03-27 19:13:26 +09:00
dearblue f9d72908ca Remove old compatibility code
The `mrb_voidp()` related macros have been removed in mruby-1.1.0.
2022-03-27 11:26:43 +09:00
Yukihiro "Matz" Matsumoto 91255c7e9f mrblib/array.rb: Array#<=> to handle NoMethodError exception.
Array element may not respond to `<=>` method.
2022-03-26 22:57:41 +09:00
Yukihiro "Matz" Matsumoto 7f5a490d09 vm.c: vm.c: stack may be reallocated in functions calls; aaa28a5
`mrb_range_new()` also calls VM recursively.
2022-03-26 21:06:02 +09:00
Yukihiro "Matz" Matsumoto bf5bbf0a4b test/integer: test negative integer divisions; ref #5678 2022-03-26 11:26:57 +09:00
Yukihiro "Matz" Matsumoto a91b55f5ca codegen.c: allow constant folding for multiply with zero. 2022-03-26 11:20:59 +09:00
Yukihiro "Matz" Matsumoto 90969cef4c codegen.c: fix the negative division regression; fix #5678 2022-03-26 11:20:59 +09:00
Yukihiro "Matz" Matsumoto 8afdf78928 Merge pull request #5677 from mruby/dependabot/github_actions/github/super-linter-4.9.1
build(deps): bump github/super-linter from 4.9.0 to 4.9.1
2022-03-26 10:52:24 +09:00
dependabot[bot] 4b118fcb0c build(deps): bump github/super-linter from 4.9.0 to 4.9.1
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.9.0 to 4.9.1.
- [Release notes](https://github.com/github/super-linter/releases)
- [Changelog](https://github.com/github/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/github/super-linter/compare/v4.9.0...v4.9.1)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

This following is a behavior from CRuby 1.8.7 to 3.1.0.

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

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

### Before (mruby 3.0.0)

mruby unexpectedly gives the TypeError.

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

### After

This PR makes mruby behave compatible with CRuby.

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

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

## Additional Information

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

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

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

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

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

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

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

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

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-01-27 14:09:18 +00:00
Yukihiro "Matz" Matsumoto c5bdfe1bd4 mruby-errno: add errno constants to known_errors.def.
Add unlisted errno constants found in macOS and FreeBSD.
If you see unlisted errno, please report.
2022-01-26 12:58:52 +09:00
Yukihiro "Matz" Matsumoto b7cdb59f26 errno.c: stop generating Errno::Exxx error classes on the fly. 2022-01-26 12:29:19 +09:00
Yukihiro "Matz" Matsumoto dd93dd7419 errno.c: refactor _sys_fail to avoid mrb_funcall. 2022-01-25 16:01:33 +09:00
Yukihiro "Matz" Matsumoto 9892742d27 errno.c: use C array instead of a hash table to lookup a errno class.
To reduce memory consumption by avoiding allocating Ruby objects.
2022-01-25 11:15:34 +09:00
Yukihiro "Matz" Matsumoto 194d0c6f46 mruby-errno: change the format of known_errors_e2c.cstub. 2022-01-25 11:08:52 +09:00
Yukihiro "Matz" Matsumoto 4176e8e88f error.c: use MRB_SYM() in mrb_sys_fail. 2022-01-25 11:08:05 +09:00
Yukihiro "Matz" Matsumoto 5c7338491c errno.c: use mrb_fixnum_p() instead of mrb_type(). 2022-01-25 10:39:13 +09:00
Yukihiro "Matz" Matsumoto 6744d69d3d errno.c: replace string literals by MRB_SYM(). 2022-01-25 10:39:13 +09:00
Yukihiro "Matz" Matsumoto 1e866dffc4 errno.c: bundled mrbgem need not to support mruby 1.x. 2022-01-25 10:28:50 +09:00
Yukihiro "Matz" Matsumoto 0f5829795e errno.c: use MRB_SYM() instead of mrb_intern_lit(). 2022-01-25 10:26:34 +09:00
Yukihiro "Matz" Matsumoto 3b5486e3ae mruby-errno/test: update test suites not to report warnings. 2022-01-25 10:22:28 +09:00
Yukihiro "Matz" Matsumoto 3a15d18ebb errno.c: hide internal _sys_fail from backtrace. 2022-01-24 18:14:28 +09:00
Yukihiro "Matz" Matsumoto c8d96ed782 stdlib.gembox: add mruby-errno 2022-01-24 18:13:28 +09:00
Yukihiro "Matz" Matsumoto a60073d7b9 mruby-errno: remove .gitkeep. 2022-01-24 18:07:59 +09:00
Yukihiro "Matz" Matsumoto 0a6d57ab3c Merge remote-tracking branch 'mruby-errno/master' 2022-01-24 17:58:41 +09:00
Yukihiro "Matz" Matsumoto 2adf32a3f4 add mruby-errno directory 2022-01-24 16:42:36 +09:00
Yukihiro "Matz" Matsumoto 7bedd5e05d codegen.c: generate OP_SETIDX from attribute assignments. 2022-01-24 11:18:27 +09:00
Yukihiro "Matz" Matsumoto cda4d9bcb4 codegen.c: refactor gen_call and gen_values.
Remove no longer used arguments from the functions.
2022-01-22 16:40:21 +09:00
Yukihiro "Matz" Matsumoto b611c43a5d codegen.c: no OP_HASHADD required when val is false. 2022-01-21 15:42:51 +09:00
Yukihiro "Matz" Matsumoto adb16fc6df codegen.c: adjust indentation after OP_STRCAT. 2022-01-21 10:51:07 +09:00
Yukihiro "Matz" Matsumoto ebb5287e29 codedump.c: omit raw c operand for OP_SEND etc. 2022-01-21 10:41:14 +09:00
Yukihiro "Matz" Matsumoto b53cd3ce25 codegen.c: fix evaluation order of attribute assignment. 2022-01-21 10:41:14 +09:00
Yukihiro "Matz" Matsumoto f8944792be parse.y: consistent argument pass for new_call(). 2022-01-21 10:41:13 +09:00
Yukihiro "Matz" Matsumoto ef98eb2c29 codegen.c: fix evaluation order of constant initialization.
`a::B = c` should evaluate `a` then `c`. It used to be `c` then `a`. The
`OP_SETMCNST` instruction operands are designed for older order in mind.
Should we changed the operand order?
2022-01-21 10:41:13 +09:00
Yukihiro "Matz" Matsumoto b68ba2df49 Merge pull request #5634 from hasumikin/fix_mruby-bin-example_tree
Fix tree of mruby-bin-example
2022-01-17 23:27:29 +09:00
HASUMI Hitoshi fb9bba34fb Fix tree of mruby-bin-example 2022-01-17 22:36:41 +09:00
mimaki 6f2efebbb9 Merge commit '7e7f1b2' into stable 2022-01-17 21:36:52 +09:00
Yukihiro "Matz" Matsumoto 31fa330404 class.c: add obj->c check before prepare_singleton_class(). 2022-01-16 22:22:46 +09:00
Yukihiro "Matz" Matsumoto 475b868b72 time.c: remove duplicated UTC condition check. 2022-01-15 18:24:39 +09:00
Yukihiro "Matz" Matsumoto 171d32c007 time.c: 1969-12-31 23:59:59 is a valid time.
But `mktime(3)` for the date returns `-1` which happen to be the
error value.
2022-01-14 11:40:52 +09:00
Yukihiro "Matz" Matsumoto 8f09d8feb4 time.c: check year range before creating Time object. 2022-01-13 15:40:09 +09:00
Yukihiro "Matz" Matsumoto 9f012724fb vm.c: need to adjust argument after packing keyword args; fix #5632
It was caused by #5628.
2022-01-12 12:44:23 +09:00
Yukihiro "Matz" Matsumoto 7e7f1b2f1d parse.y: numbered parameters should not appear on toplevel.
Toplevel includes the top of the method/class/module definitions.
2022-01-11 14:52:05 +09:00
Yukihiro "Matz" Matsumoto 3a30cc27da parse.y: move numbered parameter indexing to lexer. 2022-01-11 14:49:41 +09:00
Yukihiro "Matz" Matsumoto 5dfbfb3ecd parse.y: p->nvar (numbered argument index list) may be NULL. 2022-01-10 15:44:15 +09:00
Yukihiro "Matz" Matsumoto 8c7b995962 AUTHORS: update entries [ci skip] 2022-01-10 12:33:01 +09:00
Yukihiro "Matz" Matsumoto 69b1667b5b Merge pull request #5630 from dearblue/dumps
Fixes file header in src/{cdump,dump}.c [ci skip]
2022-01-09 21:46:40 +09:00
dearblue 178daf1a75 Fixes file header in src/{cdump,dump}.c [ci skip]
The file headers were pointing to each other's files.
2022-01-09 16:30:06 +09:00
mimaki f29924c838 Update version to 3.1.0RC. 2022-01-07 14:15:50 +09:00
Yukihiro "Matz" Matsumoto 696589cf27 Merge pull request #5628 from dearblue/super-kwargs
Fixing keyword arguments with `super`
2022-01-06 10:05:05 +09:00
Yukihiro "Matz" Matsumoto b1fc0dd5a4 Merge pull request #5629 from dearblue/nanbox
Allows handling of unaligned cptrs for `MRB_NAN_BOXING`
2022-01-06 10:02:49 +09:00
Yukihiro "Matz" Matsumoto dfa21f2e58 class.c: cancel #5620 which is no longer needed since #5622
This reverts commit d3b7601af9.
2022-01-05 19:40:55 +09:00
Yukihiro "Matz" Matsumoto aaa3bd0e80 mrbc.c: simplify place holder functions; #5622 2022-01-05 19:39:39 +09:00
Yukihiro "Matz" Matsumoto c088af87b8 object.c: Call functions directly from mrb_ensure_int_type(); #5622 2022-01-05 19:00:14 +09:00
dearblue 88b1654725 Allows handling of unaligned cptrs for MRB_NAN_BOXING
It seems to be preferable to be able to handle pointers of type `char` as well.
For this purpose, `mrb_nanbox_tt_inline` has been reorganized.

- `MRB_NANBOX_TT_POINTER` has been split into `MRB_NANBOX_TT_OBJECT` and `MRB_NANBOX_TT_CPTR`
- `MRB_NANBOX_TT_SYMBOL` has been merged into `MRB_NANBOX_TT_MISC`
2022-01-05 17:23:35 +09:00
dearblue 55b2e45a26 Fixing keyword arguments with super
fix #5627
2022-01-05 16:40:13 +09:00
Yukihiro "Matz" Matsumoto d34e1cb84c Merge pull request #5623 from dearblue/more-presym
Improves presym scanning
2022-01-04 11:54:09 +09:00
Yukihiro "Matz" Matsumoto 6c68b516ff Merge pull request #5624 from dearblue/powerof2
Assert that `MRB_METHOD_CACHE_SIZE` is a power of 2
2022-01-04 11:51:00 +09:00
Yukihiro "Matz" Matsumoto 5c75dc9edc Merge pull request #5625 from dearblue/proc_new
Assign after `mrb_irep_incref()` in `mrb_proc_new()`
2022-01-03 08:54:01 +09:00
Yukihiro "Matz" Matsumoto 4e0b162253 Merge pull request #5622 from dearblue/to_f
Call functions directly from `mrb_ensure_float_type()`
2022-01-02 18:04:18 +09:00
Yukihiro "Matz" Matsumoto ab4baba283 Merge pull request #5620 from dearblue/adjust-stacks
Adjusting the stack for after it enters the virtual machine
2022-01-02 18:01:53 +09:00
dearblue bee9665400 Assign after mrb_irep_incref() in mrb_proc_new()
ref. 28ccc664e5
2022-01-02 16:43:43 +09:00
dearblue 82a1b00eb6 Assert that MRB_METHOD_CACHE_SIZE is a power of 2
The `mrb_static_assert_powerof2()` macro has been introduced for this purpose.
2022-01-02 14:59:55 +09:00
dearblue f2d19aaaac Improves presym scanning
The main purpose is to increase the chances of finding presym and to prevent errors due to C++11 lambda expressions.

- The argument to receive the class may be written, for example, `mrb_class_get()`.
- The argument that receives the implementation function of the method may be a C++ lambda expression.
  In this case, if multiple variable declarations are separated by colons, the preprocessor will recognize them as argument delimiters and report an error.
  This patch prevents it from happening.

  ```c++
  // When preprocessing...
  func([] { int x, y, z; })
    // ^^^^^^^^^^          1st argument?
    //             ^       2nd argument?
    //                ^^^^ 3rd argument?
  ```
2022-01-02 11:52:19 +09:00
Yukihiro "Matz" Matsumoto 28ccc664e5 proc.c: should not reference irep when copying failed.
It may cause broken reference count numbers.
2022-01-01 21:02:58 +09:00
dearblue ac22a63ae3 Call functions directly from mrb_ensure_float_type()
ref. commit 7f40b645d2

Currently, the build configurations `MRB_USE_COMPLEX` and `MRB_USE_RATIONAL` are not listed in the documentation.
In other words, they are hidden settings.
They are defined in `mrbgems/mruby-{complex,rational}/mrbgem.rake`.
So this patch assumes that it is safe to refer to these functions in core-gems directly from core functions.

However, applications that link with `libmruby_core.a` will have compatibility issues.
In fact, `mrbgems/mruby-bin-mrbc` links with `libmruby_core.a`, so I had to prepare a dummy function.
2021-12-31 19:12:11 +09:00
Yukihiro "Matz" Matsumoto 3de9ddfb39 vm.c: use prepare_missing in mrb_funcall_with_block
Remove code duplication.
2021-12-31 18:15:41 +09:00
Yukihiro "Matz" Matsumoto 5ca17c2dce Merge pull request #5621 from dearblue/ci-cygwin
Extend the Cygwin CI time limit to 15 minutes.
2021-12-31 16:32:33 +09:00
Yukihiro "Matz" Matsumoto 9fc26eacd1 Merge pull request #5619 from dearblue/properties
Get object properties after `mrb_get_args()`
2021-12-31 15:28:11 +09:00
Yukihiro "Matz" Matsumoto b9e1b9b328 numeric.c: merge mrb_as_float implementation to mrb_ensure_float_type.
Since they are basically duplicated functionality. `mrb_as_float` is now
a macro defined using `mrb_ensure_float_type`; #5620
2021-12-31 15:14:37 +09:00
Yukihiro "Matz" Matsumoto 566a8d3fcb object.c: add conversion to Float from Rational, Complex; #5620 2021-12-31 15:13:04 +09:00
Yukihiro "Matz" Matsumoto 7f40b645d2 numeric.c: mrb_as_float should not call to_f for generic objects.
It should only call `to_f` for Rational and Complex numbers.
Ref #5540 #5613 #5620
2021-12-31 10:54:28 +09:00
Yukihiro "Matz" Matsumoto eea418bcce class.c, variable,c: replace size_t by int.
That reduce memory consumption by iv/mt tables.
2021-12-31 10:54:28 +09:00
dearblue 4c8a8818ec Extend the Cygwin CI time limit to 15 minutes.
The main reason for failure is to exceed the time limit, and even when it succeeds, there is less than a minute left.
The 10-minute time limit seems to be too short.
2021-12-30 22:58:41 +09:00
dearblue d3b7601af9 Adjusting the stack for after it enters the virtual machine
ref. #5613.

I mentioned in #5540 that there was no reentrant to the virtual machine, but in fact it was still a possibility at that point.
Also, the variable `ci` needs to be recalculated at the same time.
2021-12-30 22:45:19 +09:00
dearblue a137ef12f9 Get object properties after mrb_get_args()
ref. #5613

I checked with Valgrind, and the methods that can cause use-after-free are `Array#rotate`, `Array#rotate!`, and `String#byteslice`.
Since `String#rindex` uses `RSTRING_LEN()` indirectly inside the function, no reference to the out-of-bounds range is generated.
2021-12-30 22:34:22 +09:00
Yukihiro "Matz" Matsumoto 77f4a8b669 object.c: move string to float conversion to mrb_f_float. 2021-12-29 16:58:05 +09:00
Yukihiro "Matz" Matsumoto 66a099b1b3 string.c: reorganize str_convert_range using mrb_ensure_int_type 2021-12-29 16:44:35 +09:00
Yukihiro "Matz" Matsumoto b6d31810fe string.c: use mrb_as_int macro. 2021-12-29 16:39:56 +09:00
Yukihiro "Matz" Matsumoto 4f297ac29c object.c: introduce mrb_ensure_{int,float}_type.
Since `mrb_to_integer` and `mrb_to_float` does not convert the object
but checks types, they are named so by historical reason. We introduced
properly named functions.

This commit obsoletes the following functions:

* mrb_to_integer()
* mrb_to_int()
* mrb_to_float()

Use `mrb_ensure_int_type()` instead for the first 2 functions. Use
`mrb_ensure_float_type()` for the last.
2021-12-29 16:39:29 +09:00
Yukihiro "Matz" Matsumoto b6283978c5 object.c: avoid implicit to_i and to_f calls.
mruby have removed `to_int` implicit conversion, so `mrb_to_integer`
should not call `to_i` for conversion.
2021-12-29 16:21:29 +09:00
Yukihiro "Matz" Matsumoto 41e8b210b8 common.h: include <sys/types.h> for ssize_t; #5617 2021-12-29 15:57:45 +09:00
Yukihiro "Matz" Matsumoto 27d1e0132a array.c: fix mrb_ary_shift_m initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
2021-12-29 15:50:28 +09:00
Yukihiro "Matz" Matsumoto 83f2e75d17 Merge pull request #5616 from mimaki/refine-ssize_t-on-msvc
Fix build error and refine definition of `ssize_t` on MSVC.
2021-12-29 12:58:43 +09:00
mimaki 1f3a385ec5 Fix build error and refine definition of ssize_t on MSVC. 2021-12-28 17:18:59 +09:00
Yukihiro "Matz" Matsumoto 6f5c211c78 Merge pull request #5614 from jbampton/patch-1
Fix word casing in the README
2021-12-28 16:19:52 +09:00
Yukihiro "Matz" Matsumoto 8933a6fcbf Merge pull request #5615 from jbampton/pre-commit-autoupdate
pre-commit autoupdate
2021-12-28 16:19:14 +09:00
John Bampton 69affd6983 pre-commit autoupdate
https://pre-commit.com/#pre-commit-autoupdate
2021-12-28 10:28:14 +10:00
John Bampton c997229ecf Fix word casing in the README
Changed `Actual` to `actual` mid sentence
2021-12-28 10:22:20 +10:00
Yukihiro "Matz" Matsumoto 6de0fcbda2 class.c: remove mt_elem structure to avoid alignment gaps. 2021-12-27 11:15:34 +09:00
Yukihiro "Matz" Matsumoto a388d609ae variable.c: need to initialize size of iv table. 2021-12-27 10:55:17 +09:00
Yukihiro "Matz" Matsumoto 27e57aad0b parse.y: prohibit numbered parameters as arguments; fix #5605 2021-12-27 10:55:17 +09:00
Yukihiro "Matz" Matsumoto e6b6413932 Merge pull request #5612 from dearblue/compar-ext
Fix summary typo for `mrbgems/mruby-compar-ext`
2021-12-26 08:13:23 +09:00
dearblue 65195cd784 Fix summary typo for mrbgems/mruby-compar-ext 2021-12-25 20:46:25 +09:00
Yukihiro "Matz" Matsumoto 39191cd9fa parse.y: allow arguments start with _ to appear multiple times; fix #5604 2021-12-24 07:41:37 +09:00
Yukihiro "Matz" Matsumoto 3b59c95ead pack.c: check integer overflow in unpacking BER; fix #5611 2021-12-23 07:57:58 +09:00
Yukihiro "Matz" Matsumoto 42a6872c2b parse.y: adjust void_expr_error(); fix #5606
Allow void expression on some places e.g. right hand of `rescue`
modifier. In addition, checks added on some places, e.g. left hand of
logical operators.
2021-12-22 14:08:04 +09:00
Yukihiro "Matz" Matsumoto 4e8d376417 Merge pull request #5610 from mruby/dependabot/github_actions/github/super-linter-4.8.5
build(deps): bump github/super-linter from 4.8.4 to 4.8.5
2021-12-21 23:13:43 +09:00
dependabot[bot] 916fbcce2c build(deps): bump github/super-linter from 4.8.4 to 4.8.5
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.8.4 to 4.8.5.
- [Release notes](https://github.com/github/super-linter/releases)
- [Changelog](https://github.com/github/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/github/super-linter/compare/v4.8.4...v4.8.5)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-12-21 14:11:38 +00:00
Yukihiro "Matz" Matsumoto 8a5f18a1d8 codegen.c: generate OP_SETIDX; close #5608
Note that the current implantation only calls `[]=` method. No
performance improvement. Just 2 bytes less byte code per assignment.
2021-12-20 17:46:57 +09:00
Yukihiro "Matz" Matsumoto a42b676ae9 vm.c: fix a half-baked implementation of OP_SETIDX; ref #5608 2021-12-20 17:45:10 +09:00
Yukihiro "Matz" Matsumoto 5774a7a38b codedump.c: adjust the position of local variable labels. 2021-12-20 17:44:31 +09:00
Yukihiro "Matz" Matsumoto a17955259e Merge pull request #5602 from dearblue/no-ext-ops
Add `bin/mrbc --no-ext-ops` switch
2021-12-19 19:11:51 +09:00
Yukihiro "Matz" Matsumoto d7812bd3d6 Merge pull request #5603 from dearblue/codegen_error
Print error before cleanup in `codegen_error()`
2021-12-18 19:42:31 +09:00
dearblue 26338fe640 Print error before cleanup in codegen_error()
Previously, it always pointed to the highest scope as the location of the error.

  - example code `code.rb`

    ```ruby
    huge_num = "1" + "0" * 300; eval <<CODE, nil, "test.rb", 1
    class Object
      module A
        #{huge_num}
      end
    end
    CODE
    ```

  - Before this patch

    ```console
    % bin/mruby code.rb
    test.rb:1: integer too big
    trace (most recent call last):
            [1] code.rb:1
    code.rb:1:in eval: codegen error (ScriptError)
    ```

  - After this patch

    ```console
    % bin/mruby code.rb
    test.rb:3: integer too big
    trace (most recent call last):
            [1] code.rb:1
    code.rb:1:in eval: codegen error (ScriptError)
    ```
2021-12-17 23:03:27 +09:00
dearblue 6b8582c95d Add bin/mrbc --no-ext-ops switch
Print an error if `OP_EXT[123]` is needed when generating mruby binary.
This may be useful for mruby/c.

Inspired by #5590.
2021-12-17 23:02:04 +09:00
Yukihiro "Matz" Matsumoto 9b65d0dc86 Merge pull request #5601 from mruby/dependabot/github_actions/actions/upload-artifact-2.3.1
build(deps): bump actions/upload-artifact from 2.2.4 to 2.3.1
2021-12-17 07:49:53 +09:00
dependabot[bot] a7aa0b1da2 build(deps): bump actions/upload-artifact from 2.2.4 to 2.3.1
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 2.2.4 to 2.3.1.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v2.2.4...v2.3.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-12-16 14:08:05 +00:00
Yukihiro "Matz" Matsumoto 57d93c4d76 string-ext.c: fix memory leak in tr_parse_pattern. 2021-12-16 11:39:35 +09:00
Yukihiro "Matz" Matsumoto 0fbdd71dcf boxing_nan.h: remove false description in the comment [ci skip]
Ref #5597
2021-12-15 23:07:34 +09:00
Yukihiro "Matz" Matsumoto a3d240c2ed Merge pull request #5599 from dearblue/loss-digits
Avoid losing the upper digits for mruby binary
2021-12-15 23:07:13 +09:00
Yukihiro "Matz" Matsumoto f5e10c5a79 proc.c: add mrb_state argument to mrb_proc_copy().
The function may invoke the garbage collection and it requires
`mrb_state` to run.
2021-12-14 13:35:18 +09:00
dearblue fa33a5bb0c Avoid losing the upper digits for mruby binary
- `rlen` keeps 16 bits.
- `ilen` keeps 32 bits.

Note that this change will break mruby binary format compatibility.
2021-12-13 22:58:57 +09:00
Yukihiro "Matz" Matsumoto 8a74b2a25d string-ext/string.c: fixed memory leak from tr on exception.
With some refactoring.

* `ret` argument is always non-nil, so no check needed.
* move allocation check right after malloc().
* simplify conditions.
2021-12-13 10:29:16 +09:00
Yukihiro "Matz" Matsumoto d01707d4cf benchmark/bm_ao_render.rb: enable specifying the size of the image. 2021-12-13 10:29:16 +09:00
Yukihiro "Matz" Matsumoto 7b84fd4ce8 variable.c: resurrect size member in iv_tbl.
The existence of this member reduces memory and execution time.
2021-12-13 10:29:15 +09:00
Yukihiro "Matz" Matsumoto 786156d48c class.c: increase first allocated page size. 2021-12-13 10:29:15 +09:00
Yukihiro "Matz" Matsumoto bd4268210e class.c: implement method cache (off by default). 2021-12-13 10:29:15 +09:00
Yukihiro "Matz" Matsumoto 523197c831 Merge pull request #5598 from dearblue/array-combinations
Add `Array#{repeated_combination,repeated_permutation}` methods
2021-12-13 10:28:50 +09:00
Jonas Minnberg c6f0452d13 Added comments about removal of objects[]
Made mrb_get_args_v() static
2021-12-12 16:14:53 +01:00
dearblue 586525f99a Add Array#{repeated_combination,repeated_permutation} methods
Ruby 1.9.2 feature.

ref: https://docs.ruby-lang.org/ja/3.1.0/method/Array/i/repeated_combination.html
ref: https://docs.ruby-lang.org/ja/3.1.0/method/Array/i/repeated_permutation.html
2021-12-12 21:28:03 +09:00
Jonas Minnberg b1cf973186 Added mrb_get_args_a() - an array version of mrb_get_args() 2021-12-11 14:24:36 +01:00
Jonas Minnberg 24939723d7 Remove zero length array since it is not C++ compatible 2021-12-11 14:23:59 +01:00
Yukihiro "Matz" Matsumoto 7349902d5b irep.h: c operand may require 16 bits for BSS operand type.
fix #5593
2021-12-09 14:28:47 +09:00
Yukihiro "Matz" Matsumoto d2a904c884 vm.c (check_method_noarg): the value at kidx may not be a hash. 2021-12-08 16:43:02 +09:00
Yukihiro "Matz" Matsumoto c593e3e30a vm.c: use check_method_noarg() to reduce code duplication; ref #5584 2021-12-08 16:42:23 +09:00
Yukihiro "Matz" Matsumoto 5bad1c7429 vm.c: fix mrb_ci_kidx.
It used to return wrong value for 14 positional arguments.
2021-12-08 16:22:24 +09:00
Yukihiro "Matz" Matsumoto 0b6b042fe8 variable.c: fix clang integer warning. 2021-12-08 13:27:10 +09:00
Yukihiro "Matz" Matsumoto 47092ccfa5 mruby-compiler/mrbgem.rake: fix regexp pattern; close #5591 2021-12-07 23:57:32 +09:00
Yukihiro "Matz" Matsumoto 9935cf1aef variable.c: avoid redundant iv scan in mrb_mod_cv_set().
Now `iv_get()` returns `pos+1` if it finds the entry, so you don't need
to call `iv_put()`. You can replace the entry value by assigning to
`t->ptr[pos-1]`.
2021-12-07 08:19:16 +09:00
Yukihiro "Matz" Matsumoto 856ae52021 bm_ao_rendar.rb: use instance variables instead of class variables.
Class variables are slower than instance variables of classes.
2021-12-06 21:12:23 +09:00
Yukihiro "Matz" Matsumoto e5810db1ad variable.c: reduce array access in iv hash table. 2021-12-04 10:43:58 +09:00
Yukihiro "Matz" Matsumoto 9d554017f0 variable.c: avoid mrb_undef_value() for delete entries.
Instead embed deleted flag in the key (`mrb_sym` only occupies 30bits).
2021-12-03 18:36:29 +09:00
Yukihiro "Matz" Matsumoto 4f2a153ada variable.c: remove size member from iv_tbl to reduce memory.
`iv_size()` is approximated by the allocated table size.
2021-12-03 16:06:25 +09:00
Yukihiro "Matz" Matsumoto d3ebe4894b variable.c: first iv allocation size should be 4 instead of 1. 2021-12-03 15:38:16 +09:00
Yukihiro "Matz" Matsumoto a20c2a08ab variable.c: should not access NULL[0] to avoid asan warnings. 2021-12-03 15:04:14 +09:00
Yukihiro "Matz" Matsumoto 6ac26e4442 parse.y: support anonymous block argument introduced by Ruby3.1. 2021-12-02 18:24:48 +09:00
Yukihiro "Matz" Matsumoto bd88870afb codegen.c: ADDI/SUBI should not be prefixed by OP_EXT; fix #5590
As a general principles numeric instructions should not be prefixed by
`OP_EXT` instructions since they are not supported by "mruby/c".
2021-12-01 14:33:52 +09:00
Yukihiro "Matz" Matsumoto 76659a66ae codegen.c: skip ADDI/SUBI for zero operand. 2021-12-01 14:29:44 +09:00
Yukihiro "Matz" Matsumoto 7d6b8024b5 codegen.c: fix a bug in OP_ADDI and OP_SUBI regarding negative values. 2021-12-01 14:28:27 +09:00
Yukihiro "Matz" Matsumoto 2e2f81a443 codegen.c: get_int_operand to retrieve negative values correctly. 2021-12-01 14:26:22 +09:00
Yukihiro "Matz" Matsumoto 7a31a1743a codedump.c: print OP_EXT explicitly again for debugging purpose. 2021-12-01 13:42:40 +09:00
Yukihiro "Matz" Matsumoto b5842dea58 variable.c: reduce memory usage of instance variable table
This is a fundamentally simplified reimplementation of #5317
by @shuujii

Instead of having array of `struct iv_elem`, we have sequences of keys
and values packed in single chunk of malloc'ed memory. We don't have to
worry about gaps from alignment, especially on 64 bit architecture,
where `sizeof(struct iv_elem)` probably consumes 16 bytes, but
`sizeof(mrb_sym)+sizeof(mrb_value)` is 12 bytes.

In addition, this change could improve memory access locality.

close #5317
2021-12-01 12:27:19 +09:00
Yukihiro "Matz" Matsumoto b137eb2678 vm.c: remove duplicate code in VM. 2021-11-29 23:18:57 +09:00
Yukihiro "Matz" Matsumoto a245c34210 Merge pull request #5589 from dearblue/argerr
Align "wrong number of arguments" messages
2021-11-29 10:14:59 +09:00
Yukihiro "Matz" Matsumoto a0f38005fb Merge pull request #5588 from dearblue/cmath+clang++
Fixed compile error for `mrbgems/mruby-cmath` with `clang++`
2021-11-28 19:04:57 +09:00
Yukihiro "Matz" Matsumoto 6bb2af9666 Merge pull request #5587 from dearblue/args-pass.1
Fix `args_unshift()` in `mrbgems/mruby-method`
2021-11-28 19:03:33 +09:00
dearblue c4bca7cbb3 Align "wrong number of arguments" messages
Make "N for M" into the form "given N, expected M".

As I worked, I noticed that the `argnum_error()` function had a part to include the method name in the message.
I think this part is no longer needed by https://github.com/mruby/mruby/pull/5394.

  - Before this patch

    ```console
    % bin/mruby -e '[1, 2, 3].each 0'
    trace (most recent call last):
            [1] -e:1
    -e:1:in each: 'each': wrong number of arguments (1 for 0) (ArgumentError)
    ```

  - After this patch

    ```console
    % bin/mruby -e '[1, 2, 3].each 0'
    trace (most recent call last):
            [1] -e:1
    -e:1:in each: wrong number of arguments (given 1, expected 0) (ArgumentError)
    ```
2021-11-28 18:21:29 +09:00
dearblue f81bc3de38 Fixed compile error for mrbgems/mruby-cmath with clang++
If the preprocessor check part is only `__clang__`, CI's such as `Ubuntu-2004-clang` will fail to compile.
This is why we limited the addition to FreeBSD and OpenBSD, which have `clang++` in their base systems.
DragonFly BSD and NetBSD have GCC built into their base systems, so nothing is changed.
2021-11-28 17:28:44 +09:00
dearblue 58a9621df7 Fix args_unshift() in mrbgems/mruby-method
Both keyword arguments and block arguments were being destroyed when there were no arguments.
The cause of this is #5585. I' m sorry.
2021-11-28 14:10:37 +09:00
Yukihiro "Matz" Matsumoto e4d6917786 test/kernel.rb: remove duplicate tests; ref #5584 2021-11-26 12:18:41 +09:00
dearblue 668b12e756 Check more MRB_ARGS_NONE()
The `__id__` method implemented in the C function has `MRB_ARGS_NONE()` specified, but it is also effective in the following cases.

```ruby
p nil.__id__ opts: 1 rescue p :a
p nil.method(:__id__).call 1 rescue p :b
p nil.method(:__id__).call opts: 1 rescue p :c
p nil.method(:__id__).to_proc.call 1 rescue p :d
p nil.method(:__id__).to_proc.call opts: 1 rescue p :e
p nil.method(:__id__).unbind.bind_call nil, 1 rescue p :f
p nil.method(:__id__).unbind.bind_call nil, opts: 1 rescue p :g
p nil.__send__ :__id__, 1 rescue p :h
p nil.__send__ :__id__, opts: 1 rescue p :i
```

After applying this patch, all items will output symbols in the same way as CRuby.

For this purpose, add `MRB_PROC_NOARG` to `struct RProc::flags`.
2021-11-26 12:18:41 +09:00
Yukihiro "Matz" Matsumoto b631c226eb Merge pull request #5585 from dearblue/args-pass
Fixed some methods where keyword arguments are not passed
2021-11-25 17:08:32 +09:00
dearblue 16e388863a Fixed some methods where keyword arguments are not passed 2021-11-24 23:35:42 +09:00
Yukihiro "Matz" Matsumoto d6e1114f71 Merge pull request #5581 from mruby/dependabot/github_actions/actions/cache-2.1.7
build(deps): bump actions/cache from 2.1.6 to 2.1.7
2021-11-24 09:39:50 +09:00
dependabot[bot] 9ae657520b build(deps): bump actions/cache from 2.1.6 to 2.1.7
Bumps [actions/cache](https://github.com/actions/cache) from 2.1.6 to 2.1.7.
- [Release notes](https://github.com/actions/cache/releases)
- [Commits](https://github.com/actions/cache/compare/v2.1.6...v2.1.7)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-11-23 14:12:20 +00:00
Yukihiro "Matz" Matsumoto d627c22924 AUTHORS: update entries [ci skip] 2021-11-23 10:05:16 +09:00
Yukihiro "Matz" Matsumoto 4a84fa5db5 Merge pull request #5580 from dearblue/static-proc
Fixed occurs `SIGSEGV` with `mrbgems/mruby-method`
2021-11-23 10:03:44 +09:00
dearblue b02bd63dc5 Fixed occurs SIGSEGV with mrbgems/mruby-method
Calling the `Method#{parameters,source_location}` method on a static `Proc` object resulted in `SIGSEGV`.
The trigger is https://github.com/mruby/mruby/pull/5402.

The original implementation of the `Method#{parameters,source_location}` method was to temporarily rewrite the object and then call the method of the same name in `Proc`.
Rewriting of objects placed in the ROM section by #5402 above is prohibited by hardware such as the CPU.
This caused a `SIGSEGV`.
2021-11-22 21:55:02 +09:00
Yukihiro "Matz" Matsumoto 01cadd3e70 parse.y: check duplicated argument names; fix #5575 2021-11-21 19:05:50 +09:00
Yukihiro "Matz" Matsumoto f69eafc6bd doc/internal/opcode.md: moved from doc/opcode.md 2021-11-20 14:56:59 +09:00
Yukihiro "Matz" Matsumoto 28f00b23bf doc/opcode.md: update according to #5579 2021-11-20 14:55:09 +09:00
Yukihiro "Matz" Matsumoto a04d2a8865 fixup! parse.y: unnamed rest argument should be mul (*). 2021-11-20 08:50:52 +09:00
Yukihiro "Matz" Matsumoto 2e41b20590 parse.y: unnamed rest argument should be mul (*). 2021-11-20 08:50:52 +09:00
Yukihiro "Matz" Matsumoto 9e064f2353 parse.y: skip unnecessary local_add_f(p, 0). 2021-11-20 08:50:51 +09:00
Yukihiro "Matz" Matsumoto 4c28356b71 Merge pull request #5578 from dearblue/OP_SENDB
Fixes keywords are lost with the `OP_SENDB`
2021-11-20 08:50:42 +09:00
Yukihiro "Matz" Matsumoto c6c789d2e8 Merge pull request #5579 from dearblue/OP_ASET
Fixed a discrepancy in `OP_ASET`
2021-11-20 08:48:05 +09:00
dearblue 6fba0dbece Fixed a discrepancy in OP_ASET
There was a discrepancy in the actual behavior, assertions, and documentation.
Therefore, I modified it based on the actual behavior.
2021-11-19 22:53:01 +09:00
dearblue 279e0122da Fixes keywords are lost with the OP_SENDB
If a splat argument was passed, it could write out of range on the VM stack.

```console
% bin/mruby -e 'def m(*args, **opts, &blk) p [args, opts, blk] end; m(*%w(X Y Z), r: 1, g: 2, b: 3) {}'
[["X", "Y", "Z"], {}, #<Proc:0x80077d7d0>]
```
2021-11-19 22:35:47 +09:00
Yukihiro "Matz" Matsumoto 1a1ff6b3ff Merge pull request #5577 from mruby/dependabot/github_actions/github/super-linter-4.8.4
build(deps): bump github/super-linter from 4.8.3 to 4.8.4
2021-11-18 10:28:35 +09:00
dependabot[bot] a66db89a5d build(deps): bump github/super-linter from 4.8.3 to 4.8.4
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.8.3 to 4.8.4.
- [Release notes](https://github.com/github/super-linter/releases)
- [Changelog](https://github.com/github/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/github/super-linter/compare/v4.8.3...v4.8.4)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-11-17 14:09:11 +00:00
Yukihiro "Matz" Matsumoto f4e18a5d84 codegen.c: fixed a bug in post mandatory arguments. 2021-11-17 16:34:44 +09:00
Yukihiro "Matz" Matsumoto f5d9aab372 codegen.c: should not emit the MOVE instruction to the same register. 2021-11-17 16:33:53 +09:00
Yukihiro "Matz" Matsumoto e3e54453a7 Merge pull request #5576 from mruby/dependabot/github_actions/github/super-linter-4.8.3
build(deps): bump github/super-linter from 4.8.1 to 4.8.3
2021-11-16 16:59:10 +09:00
dependabot[bot] 927812a7e6 build(deps): bump github/super-linter from 4.8.1 to 4.8.3
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.8.1 to 4.8.3.
- [Release notes](https://github.com/github/super-linter/releases)
- [Changelog](https://github.com/github/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/github/super-linter/compare/v4.8.1...v4.8.3)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-11-15 14:08:13 +00:00
Yukihiro "Matz" Matsumoto e0a3800e5d string-ext/string.c: fixed a memory leak. 2021-11-15 09:49:05 +09:00
Yukihiro "Matz" Matsumoto a0b58eed46 doc/internal/boxing.md: describe how mrb_value represents values. 2021-11-14 17:45:21 +09:00
Yukihiro "Matz" Matsumoto 1fe722cd78 boxing_word.h: fix the error in the comment [ci skip] 2021-11-13 20:59:54 +09:00
Yukihiro "Matz" Matsumoto 4e3df65d6f test/syntax.rb: test argument forwarding without parentheses. 2021-11-12 15:02:49 +09:00
Yukihiro "Matz" Matsumoto 7c1878669a parse.y: should allow newline after .... 2021-11-12 15:02:04 +09:00
Yukihiro "Matz" Matsumoto 885a87e408 parse.y: allow ... in formal arguments without parentheses. 2021-11-10 22:25:02 +09:00
Yukihiro "Matz" Matsumoto 2e0c1b4361 etc.c: improve mrb_obj_id with NaN boxing and Word boxing. 2021-11-09 17:24:53 +09:00
Yukihiro "Matz" Matsumoto a5567fbad4 boxing_nan.h: update mrb_immediate_p and related macros. 2021-11-08 14:33:50 +09:00
Yukihiro "Matz" Matsumoto 5dc91029d1 TODO.md: update. 2021-11-08 14:33:50 +09:00
Yukihiro "Matz" Matsumoto 5c8e184fcf Merge pull request #5437 from dearblue/parse.y
Run the task only once when `parse.y` is updated
2021-11-06 19:58:28 +09:00
Yukihiro "Matz" Matsumoto c3a1456cc8 mruby3.1.md: update. 2021-11-06 18:18:38 +09:00
Yukihiro "Matz" Matsumoto 879f074cd0 mruby3.1.md: update new methods description. 2021-11-05 15:08:44 +09:00
Yukihiro "Matz" Matsumoto d6f6467ad7 boxing_nan.h (mrb_float_p): wrap macro argument by parenthesis. 2021-11-04 20:49:19 +09:00
Yukihiro "Matz" Matsumoto c21a094a7f hash.c: avoid mrb_obj_id to get the hash value if possible. 2021-11-04 15:54:31 +09:00
Yukihiro "Matz" Matsumoto 877e82eb92 Merge pull request #5570 from dearblue/random-bytes
Added `Random.#bytes` method
2021-11-04 15:54:22 +09:00
Yukihiro "Matz" Matsumoto 8f67a0d0e1 Merge pull request #5569 from dearblue/array-product
Added `Array#product` method
2021-11-04 15:54:09 +09:00
Yukihiro "Matz" Matsumoto b940ed69d9 Merge pull request #5571 from mruby/dependabot/github_actions/actions/checkout-2.4.0
build(deps): bump actions/checkout from 2.3.5 to 2.4.0
2021-11-04 07:48:14 +09:00
dependabot[bot] b8b5d4094f build(deps): bump actions/checkout from 2.3.5 to 2.4.0
Bumps [actions/checkout](https://github.com/actions/checkout) from 2.3.5 to 2.4.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2.3.5...v2.4.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-11-03 14:06:38 +00:00
Yukihiro "Matz" Matsumoto 36efd018e2 Merge pull request #5565 from dearblue/class.new
Improved `Class#new` method
2021-11-03 19:38:11 +09:00
Yukihiro "Matz" Matsumoto 59b7846ab0 Merge pull request #5568 from dearblue/nan+cxx_abi
Fix failed build with `MRB_NAN_BOXING` and `enable_cxx_abi`
2021-11-01 13:54:15 +09:00
Yukihiro "Matz" Matsumoto a0dd466840 object.c: fast implementation of mrb_obj_eq.
For `MRB_NAN_BOXING` and `MRB_WORD_BOXING`.
2021-11-01 13:35:10 +09:00
dearblue 7bb4a57e56 Added Random.#bytes method
ref: https://docs.ruby-lang.org/ja/3.0.0/method/Random/i/bytes.html
2021-10-31 23:36:10 +09:00
dearblue 5ea26260fa Added Array#product method
Ruby-1.9.0 feature.

ref: https://docs.ruby-lang.org/ja/3.0.0/method/Array/i/product.html
2021-10-31 23:02:37 +09:00
dearblue 1de662cb8b Fix failed build with MRB_NAN_BOXING and enable_cxx_abi
```console
% c++ -xc++ -std=c++03 -S -Iinclude -DMRB_NAN_BOXING -DMRB_NO_PRESYM -o- src/array.c > /dev/null
In file included from src/array.c:7:
In file included from include/mruby.h:115:
In file included from include/mruby/value.h:201:
include/mruby/boxing_nan.h:95:12: error: cannot initialize return object of type 'enum mrb_vtype' with an rvalue of type 'int'
    return (enum mrb_vtype)(o.u >> 8) & 0x1f;
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
```
2021-10-31 22:17:15 +09:00
Yukihiro "Matz" Matsumoto d8204d51af Merge pull request #5566 from dearblue/no_float_truncate
Avoid redefining `MRB_WORDBOX_NO_FLOAT_TRUNCATE`
2021-10-31 17:29:20 +09:00
Yukihiro "Matz" Matsumoto f0b0f9d69d Merge pull request #5567 from dearblue/mrb_static_assert.1
Avoid violations of the `mrb_static_assert()` standard
2021-10-30 17:46:40 +09:00
Yukihiro "Matz" Matsumoto 9f0410789d boxing_nan.h: allow MRB_INT64 with MRB_NAN_BOXING.
Integers out of 32 bit range will be allocated in the heap.
2021-10-30 17:44:46 +09:00
Yukihiro "Matz" Matsumoto 85fcd2dc6f boxing_nan.h: implement Favor pointer NaN Boxing.
Favor pointer means encode NaN boxed values to keep pointer values
unmodified, to reduce the cost of far frequent pointer value retrievals.
2021-10-30 17:43:35 +09:00
dearblue 61ee857178 Avoid violations of the mrb_static_assert() standard
ref: #5564

```console
% cc -pedantic -S -Iinclude -DMRB_NO_PRESYM -o- src/array.c > /dev/null
In file included from src/array.c:7:
In file included from include/mruby.h:115:
In file included from include/mruby/value.h:204:
include/mruby/boxing_word.h:133:1: warning: must specify at least one argument for '...' parameter of variadic macro [-Wgnu-zero-variadic-macro-arguments]
mrb_static_assert(sizeof(mrb_value) == sizeof(union mrb_value_));
^
include/mruby.h:109:108: note: expanded from macro 'mrb_static_assert'
    mrb_static_assert_expand(mrb_static_assert_selector(__VA_ARGS__, mrb_static_assert2, mrb_static_assert1)(__VA_ARGS__))
                                                                                                           ^
include/mruby.h:100:10: note: macro 'mrb_static_assert_selector' defined here
# define mrb_static_assert_selector(a, b, name, ...) name
         ^
1 warning generated.
```
2021-10-30 13:22:35 +09:00
dearblue fa8bd00b57 Avoid redefining MRB_WORDBOX_NO_FLOAT_TRUNCATE
Adding `MRB_WORDBOX_NO_FLOAT_TRUNCATE` to the build configuration in 32-bit CPU mode had a double definition.

```console
% cat myconf.rb
MRuby::Build.new do
  toolchain "clang"
  defines << "MRB_WORDBOX_NO_FLOAT_TRUNCATE"
  cc.flags << "-m32"
  linker.flags << "-m32"
  enable_debug
end

% rake CONFIG=myconf.rb
CPP   src/array.c -> build/host/src/array.pi
In file included from /var/tmp/mruby/src/array.c:7:
In file included from /var/tmp/mruby/include/mruby.h:115:
In file included from /var/tmp/mruby/include/mruby/value.h:203:
/var/tmp/mruby/include/mruby/boxing_word.h:11:10: warning:
      'MRB_WORDBOX_NO_FLOAT_TRUNCATE' macro redefined [-Wmacro-redefined]
# define MRB_WORDBOX_NO_FLOAT_TRUNCATE
         ^
<command line>:3:9: note: previous definition is here
#define MRB_WORDBOX_NO_FLOAT_TRUNCATE 1
        ^
1 warning generated.
...SNIP...
```
2021-10-30 09:55:35 +09:00
dearblue 33792c2a02 Improved Class#new method
The number of registers used is reduced.

Also, previously `R6` and` R7` were used, which exceeded the limit of `new_irep.nregs = 6`.
This could cause the VM stack to overrun.
2021-10-29 22:20:20 +09:00
Yukihiro "Matz" Matsumoto 0069e6738a boxing_nan.h: refactor NaN Boxing.
Preparation for:

* 64 bit integer with NaN Boxing
* Favor pointer NaN Boxing
2021-10-28 12:22:21 +09:00
Yukihiro "Matz" Matsumoto fca63c6060 boxing_nan.h: revert part of dccd66f
WIP code was mistakenly committed.
2021-10-26 17:33:49 +09:00
Yukihiro "Matz" Matsumoto abf2d653d7 Merge pull request #5564 from dearblue/static_assert
Make `mrb_static_assert()` a variable argument
2021-10-25 07:59:01 +09:00
dearblue b774832ee1 Make mrb_static_assert() a variable argument
`mrb_static_assert()` extends the macro function to take one or two arguments.
If the argument is other than that, an error will occur.

References:
- static_assert のメッセージ省略を許可 - cpprefjp C++日本語リファレンス
  https://cpprefjp.github.io/lang/cpp17/extending_static_assert.html
- c - Overloading Macro on Number of Arguments - Stack Overflow
  https://stackoverflow.com/a/11763277
2021-10-24 23:11:52 +09:00
Yukihiro "Matz" Matsumoto 5c6e8b32a3 doc/mruby3.1.h: separate mruby3.0 changes and mruby3.1 changes. 2021-10-24 13:21:54 +09:00
Yukihiro "Matz" Matsumoto 7850549a5e string.c: use FNV1a algorithm for the string hash function. 2021-10-23 09:31:01 +09:00
Yukihiro "Matz" Matsumoto 74b02fba81 Merge pull request #5563 from suetanvil-misc/project-bintest-emulator-4-flat
Added testing support for cross-MinGW builds.
2021-10-22 13:41:50 +09:00
Chris Reuter 5c4273f944 Added testing support for cross-MinGW builds.
This adds a build_config that will cross-build a Windows executable
using the MinGW cross-compiler and will also run the unit (i.e.
'rake test') using Wine.

For this to work, I made some modifications to the underlying test
scripts as well as some minor changes to a couple of the tests
themselves.
2021-10-21 21:58:45 -04:00
Yukihiro "Matz" Matsumoto fabe8212fe codedump.c: add indentation for OP_MOVE. 2021-10-21 15:35:25 +09:00
Yukihiro "Matz" Matsumoto dc0d5db699 doc/mruby3.md: updated to the most recent mruby3.1 (to be). 2021-10-20 09:40:17 +09:00
Yukihiro "Matz" Matsumoto f653556731 dump.h: bump RITE_BINARY_MAJOR_VER to 03.
Since we have added several new instructions.
2021-10-19 15:27:29 +09:00
Yukihiro "Matz" Matsumoto d965d90edf codedump.c: remove OP_ prefix from disasm output. 2021-10-19 12:29:06 +09:00
Yukihiro "Matz" Matsumoto 90484cac63 codegen.c: skip OP_LOADSELF using OP_SSEND. 2021-10-19 12:13:05 +09:00
Yukihiro "Matz" Matsumoto 5d5e4f5214 ops.h: add new instructions OP_SSEND and OP_SSENDB.
These instructions call methods of the receiver.
2021-10-19 12:03:12 +09:00
Yukihiro "Matz" Matsumoto 45491cdd8c ops.h: update descriptions for array-like accesses.
* `R(a)` -> `R[a]`
* `Pool(a)` -> `Pool[a]`
* `Syms(a)` -> `Syms[a]`
* `Irep(a)` -> `Irep[a]`
2021-10-19 11:49:02 +09:00
Yukihiro "Matz" Matsumoto ab986ff108 ops.h: update OP_SEND description. 2021-10-19 11:37:59 +09:00
Yukihiro "Matz" Matsumoto b6b4ac8270 Merge pull request #5560 from mruby/dependabot/github_actions/actions/checkout-2.3.5
build(deps): bump actions/checkout from 2.3.4 to 2.3.5
2021-10-19 08:06:28 +09:00
dependabot[bot] cdccb5ea13 build(deps): bump actions/checkout from 2.3.4 to 2.3.5
Bumps [actions/checkout](https://github.com/actions/checkout) from 2.3.4 to 2.3.5.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2.3.4...v2.3.5)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-18 14:05:53 +00:00
Yukihiro "Matz" Matsumoto 10edda9698 Merge pull request #5559 from igrep/fix-commented-out-example
Fix a syntax error in commented-out code
2021-10-18 13:07:32 +09:00
YAMAMOTO Yuji 66e61c5ab8 Fix a syntax error in commented-out code
By uncommenting the line changed by this commit, `ruby -c build_config/default.rb` complains of a syntax error due to the illegally nested double quotes
2021-10-18 12:45:55 +09:00
Yukihiro "Matz" Matsumoto 0d08f89159 codegen.c: Reduce MRB_CODEGEN_LEVEL_MAX from 1024 to 256.
1024 was too big.  Some deep recursion could not be detected before
actual stack overflow.
2021-10-18 12:01:07 +09:00
Yukihiro "Matz" Matsumoto de2b4bd0dc codegen.c: fixed a bug regarding attribute assignment with kargs. 2021-10-18 08:01:26 +09:00
Yukihiro "Matz" Matsumoto be189ae9f9 codegen.c: forgot to check s2 extensively in super codegen. 2021-10-17 08:03:24 +09:00
Yukihiro "Matz" Matsumoto 2b19a6c1b4 AUTHORS: update. 2021-10-17 08:02:36 +09:00
Yukihiro "Matz" Matsumoto 36bca25e58 codegen.c: s2 may be NULL.
Since `s2` is `NULL` on top-level, it will be an error. No need to
generate strict bytecode.
2021-10-16 11:09:52 +09:00
Yukihiro "Matz" Matsumoto 0dc5fcec7b parse.y: check car part of return node. 2021-10-16 10:33:35 +09:00
Yukihiro "Matz" Matsumoto 0b095406bf Merge pull request #5558 from jbampton/fix-grammar
Fix grammar in doc/guides/mrbgems.md
2021-10-15 09:47:23 +09:00
Yukihiro "Matz" Matsumoto a9a2dcd3cc rational.c: avoid recursion between rational_eq and complex_eq. 2021-10-14 22:48:54 +09:00
Yukihiro "Matz" Matsumoto 7010ed0f0a vm.c: need to ensure the stack size is sufficient.
Need to add `n` because the stack will be shifted in the `mrb_funcall`.
2021-10-14 22:47:19 +09:00
John Bampton a3da482683 Fix grammar in doc/guides/mrbgems.md 2021-10-14 19:55:57 +10:00
Yukihiro "Matz" Matsumoto 6b3b1012ca codegen.c: skip OP_ARGARY before super if the method has no arguments. 2021-10-13 07:06:17 +09:00
Yukihiro "Matz" Matsumoto a1027812bd error.c: small refactoring regarding #2485 2021-10-12 22:38:59 +09:00
Yukihiro "Matz" Matsumoto 3c8f0ac14b Merge branch 'take-cheeze-exc_mesg' 2021-10-12 22:16:21 +09:00
Yukihiro "Matz" Matsumoto 291234c7aa Merge branch 'exc_mesg' of https://github.com/take-cheeze/mruby into take-cheeze-exc_mesg 2021-10-12 22:14:11 +09:00
Yukihiro "Matz" Matsumoto 5004d9a282 codegen.c: should not assign negative number to ainfo (size_t). 2021-10-12 20:16:36 +09:00
Yukihiro "Matz" Matsumoto dccd66f9ef Support Ruby3.0 keyword arguments.
The Difference

Since Ruby1.9, the keyword arguments were emulated by Ruby using the hash
object at the bottom of the arguments. But we have gradually moved toward
keyword arguments separated from normal (positinal) arguments.

At the same time, we value compatibility, so that Ruby3.0 keyword
arguments are somewhat compromise. Basically, keyword arguments are
separated from positional arguments, except when the method does not
take any formal keyword arguments, given keyword arguments (packed
in the hash object) are considered as the last argument.

And we also allow non symbol keys in the keyword arguments. In that
case, those keys are just passed in the `**` hash (or raise
`ArgumentError` for unknown keys).

The Instruction Changes

We have changed `OP_SEND` instruction. `OP_SEND` instruction used to
take 3 operands, the register, the symbol, the number of (positional)
arguments. The meaning of the third operand has been changed. It is now
considered as `n|(nk<<4)`, where `n` is the number of positional
arguments, and `nk` is the number of keyword arguments, both occupies
4 bits in the operand.

The number `15` in both `n` and `nk` means variable sized arguments are
packed in the object. Positional arguments will be packed in the array,
and keyword arguments will be packed in the hash object. That means
arguments more than 14 values are always packed in the object.

Arguments information for other instructions (`OP_SENDB` and `OP_SUPER`)
are also changed. It works as the third operand of `OP_SEND`. the
difference between `OP_SEND` and `OP_SENDB` is just trivial. It assigns
`nil` to the block hidden arguments (right after arguments).

The instruction `OP_SENDV` and `OP_SENDVB` are removed. Those
instructions are replaced by `OP_SEND` and `OP_SENDB` respectively with
the `15` (variable sized) argument information.

Calling Convention

When calling a method, the stack elements shall be in the order of the
receiver of the method, positional arguments, keyword arguments and the
block argument. If the number of positional or keyword arugument (`n` or
`nk`) is zero, corresponding arguments will be empty. So when `n=0` and
`nk=0` the stack layout (from bottom to top) will be:

+-----------------------+
| recv | block (or nil) |
+-----------------------+

The last elements `block` should be explicitly filled before `OP_SEND`
or assigned to `nil` by `OP_SENDB` internally. In other words, the
following have exactly same behavior:

OP_SENDB clears `block` implicitly:

```
OP_SENDB reg sym 0
```

OP_SEND clears `block` implicitly:

```
OP_LOADNIL  R2
OP_SEND     R2 sym 0
```

When calling a method with only positional arguments (n=0..14) without
keyword arguments, the stack layout will be like following:

+--------------------------------------------+
| recv | arg1 | ... | arg_n | block (or nil) |
+--------------------------------------------+

When calling a method with arguments packed in the array (n=15) which
means argument splat (*) is used in the actual arguments, or more than
14 arguments are passed the stack layout will be like following:

+-------------------------------+
| recv | array | block (or nil) |
+-------------------------------+

The number of the actual arguments is determined by the length of the
argument array.

When keyword arguments are given (nk>0), keyword arguments are passed
between positional arguments and the block argument. For example, when
we pass one positional argument `1` and one keyword argument `a: 2`,
the stack layout will be like:

+------------------------------------+
| recv | 1 | :a | 2 | block (or nil) |
+------------------------------------+

Note that keyword arguments consume `2*nk` elements in the stack when
`nk=0..14` (unpacked).

When calling a method with keyword arguments packed in the hash object
(nk=15) which means keyword argument splat (**) is used or more than
14 keyword arguments in the actual arguments, the stack layout will
be like:

+------------------------------+
| recv | hash | block (or nil) |
+------------------------------+

Note for mruby/c

When mruby/c authors try to support new keyword arguments, they need
to handle the new meaning of the argument information operand. If they
choose not to support keyword arguments in mruby/c, it just raise
error when `nk` (taken by `(c>>4)&0xf`) is not zero. And combine
`OP_SENDV` behavior with `OP_SEND` when `n` is `15`.

If they want to support keyword arguments seriously, contact me at
<matz@ruby.or.jp> or `@yukihiro_matz`. I can help you.
2021-10-12 20:16:36 +09:00
Yukihiro "Matz" Matsumoto c6df4bf9a8 Merge pull request #5557 from jbampton/pre-commit-autoupdate
pre-commit autoupdate
2021-10-12 20:16:18 +09:00
John Bampton 843d3d4e41 pre-commit autoupdate
https://pre-commit.com/index.html#pre-commit-autoupdate
2021-10-12 19:03:35 +10:00
Yukihiro "Matz" Matsumoto 8e5d89df7f vm.c: unify mrb_gc_arena_restore and mrb_gc_arena_shrink. 2021-10-10 20:12:11 +09:00
Yukihiro "Matz" Matsumoto 5cdf1eabdd Merge pull request #5555 from dearblue/str-ref-regexp
Partially allow overriding of `String#[]` methods
2021-10-09 14:15:06 +09:00
Yukihiro "Matz" Matsumoto 07f805aa88 Merge pull request #5556 from dearblue/setidx
Fix typo for `OP_SETIDX`
2021-10-09 14:00:09 +09:00
dearblue e8205ec906 Fix typo for OP_SETIDX 2021-10-09 13:36:19 +09:00
Yukihiro "Matz" Matsumoto 87b673fc9a codegen.c: peephole optimization OP_MOVE after OP_AREF. 2021-10-09 13:31:07 +09:00
dearblue 8c355ec7e3 Partially allow overriding of String#[] methods
This is for the purpose of supporting `Regexp`.

- configuration and build

  ```console
  % cat regexp_config.rb
  MRuby::Lockfile.disable
  MRuby::Build.new do
    toolchain "clang"
    enable_debug
    gem core: "mruby-bin-mruby"
    gem core: "mruby-print"
    gem mgem: "mruby-onig-regexp"
    #gem mgem: "mruby-regexp-pcre"
  end

  % rake MRUBY_CONFIG=regexp_config.rb
  ```

- mruby HEAD (bec074e)

  ```console
  % build/host/bin/mruby -e 'p "abcdefg"[/.(?=...$)/]'
  -e:1: can't convert OnigRegexp into Integer (TypeError)
  ```

- with this patch

  ```console
  % build/host/bin/mruby -e 'p "abcdefg"[/.(?=...$)/]'
  "d"
  ```
2021-10-09 13:28:10 +09:00
Yukihiro "Matz" Matsumoto bec074e6a3 vm.c: check call stack depth before pushing the frame.
Existing call stack depth checks are unified into this check in
`cipush()`. The maximum depth is now specified by `MRB_CALL_LEVEL_MAX`
(the default is 512).  The older `MRB_FUNCALL_DEPTH_MAX` is no longer
used.
2021-10-08 15:35:33 +09:00
Yukihiro "Matz" Matsumoto fd6d911b53 codegen.c: peephole optimize OP_MOVE after OP_ARRAY or OP_HASH.
When the length operand is zero, we don't need `OP_MOVE` but adjust the
destination operand instead.
2021-10-08 12:09:05 +09:00
Yukihiro "Matz" Matsumoto 7018286453 Merge pull request #5554 from mruby/dependabot/github_actions/github/super-linter-4.8.1
build(deps): bump github/super-linter from 4.8.0 to 4.8.1
2021-10-07 10:30:12 +09:00
Yukihiro "Matz" Matsumoto 376e84c9d7 codedump.c: remove trailing extra newline.
The bug was introduced in 8be78bd.
2021-10-06 07:36:44 +09:00
Yukihiro "Matz" Matsumoto 9aa3c26221 io.c: hide internal method names in backtrace. 2021-10-05 07:11:59 +09:00
dependabot[bot] 4ef612a586 build(deps): bump github/super-linter from 4.8.0 to 4.8.1
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.8.0 to 4.8.1.
- [Release notes](https://github.com/github/super-linter/releases)
- [Changelog](https://github.com/github/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/github/super-linter/compare/v4.8.0...v4.8.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-04 14:08:09 +00:00
Yukihiro "Matz" Matsumoto ab1047b445 codegen.c: no OP_ARGARY is needed here. 2021-10-04 07:45:46 +09:00
Yukihiro "Matz" Matsumoto 09336c5d49 mruby/ops.h: add new instructions OP_GETIDX and OP_SETIDX.
Which represent `obj[int]` and `obj[int]=val` respectively where `obj`
is either `string`, `array` or `hash`, so that index access could be
faster. When `obj` is not assumed type or `R(a+1)` is not integer, the
instructions fallback to method calls.
2021-10-03 17:14:00 +09:00
Yukihiro "Matz" Matsumoto d64d8ca8e4 Merge branch 'dearblue-inline-struct-gem' 2021-10-02 20:11:32 +09:00
Yukihiro "Matz" Matsumoto 31e3dbc5a8 Merge branch 'inline-struct-gem' of https://github.com/dearblue/mruby into dearblue-inline-struct-gem 2021-10-02 20:09:20 +09:00
Yukihiro "Matz" Matsumoto 4e504eaca1 SECURITY.md: add scope description. 2021-10-01 19:13:07 +09:00
Yukihiro "Matz" Matsumoto d96f53f8f8 TODO.md: update. 2021-09-30 17:15:29 +09:00
Yukihiro "Matz" Matsumoto eea605bfc5 dreamcast_shelf.rb: remove unnecessary gem lines.
- `mruby-binding-core` should be handle through dependency
- `mruby-inline-struct` is only for tests
2021-09-30 12:46:45 +09:00
Yukihiro "Matz" Matsumoto bb3cd69aff value.h: introduce MRB_TT_STRUCT for mruby-struct. 2021-09-30 12:46:45 +09:00
Yukihiro "Matz" Matsumoto f1a5c050f4 Merge pull request #5553 from mruby/dependabot/github_actions/github/super-linter-4.8.0
build(deps): bump github/super-linter from 4.7.3 to 4.8.0
2021-09-28 23:14:39 +09:00
dependabot[bot] 1b53b973e5 build(deps): bump github/super-linter from 4.7.3 to 4.8.0
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.7.3 to 4.8.0.
- [Release notes](https://github.com/github/super-linter/releases)
- [Changelog](https://github.com/github/super-linter/blob/master/docs/release-process.md)
- [Commits](https://github.com/github/super-linter/compare/v4.7.3...v4.8.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-28 14:07:15 +00:00
Yukihiro "Matz" Matsumoto 906f9f2ba7 parse.y: __ENCODING__ should be determined in run-time; fix #5552
It used to be compiled to the static string in the compiler. But the
encoding status actually depends on the runtime configuration. A new
method `Kernel#__ENCODING__` is introduced to implement the feature.
2021-09-27 10:10:35 +09:00
Yukihiro "Matz" Matsumoto 368e8ce3d5 codegen.c: should not loop_push() before constant folding.
Otherwise, the following code will crash:

```ruby
1.times{{}until 1; break}
```
2021-09-26 16:58:40 +09:00
Yukihiro "Matz" Matsumoto 89ea41f15e mrbconf.h: rename a configuration macro for no truncate floats.
Rename `MRB_WORDBOX_USE_HEAP_FLOAT` to `MRB_WORDBOX_NO_FLOAT_TRUNCATE'.
2021-09-25 14:44:43 +09:00
Yukihiro "Matz" Matsumoto c70159b356 Revert "vm.c: add assertions instead of mrb_ensure_hash_type()."
This reverts commit 913a0a5a03.
In some cases, `OP_HASHADD` operand may not be `Hash`. We should check
explicitly in those cases.
2021-09-24 17:10:11 +09:00
Yukihiro "Matz" Matsumoto ab54ca272a codegen.c: refactor NODE_WHILE and NODE_UNTIL. 2021-09-24 11:39:00 +09:00
Yukihiro "Matz" Matsumoto 7c6c4ebb56 codegen.c: add short circuit constant folding for NODE_AND, NODE_OR. 2021-09-24 11:38:02 +09:00
Yukihiro "Matz" Matsumoto 863671c89f codegen.c: refactor NODE_IF generation for boolean constants.
In addition, add `NODE_SYM` for always true expression.
2021-09-24 11:36:27 +09:00
Yukihiro "Matz" Matsumoto a844f89655 codegen.c: need to check no_peephole() before constant folding. 2021-09-23 21:19:36 +09:00
Yukihiro "Matz" Matsumoto 4c196dbba5 codegen.c: separate maximum stack size from GEN_LIT_ARY_MAX. 2021-09-23 20:11:30 +09:00
Yukihiro "Matz" Matsumoto fd7896e579 error.c: stop calling initialize from VM exceptions.
The invocation of `initialize` hook can cause infinite recursion too
easily. We stop invoking the method for safety, at the cost of less
flexibility.

The `initialize` methods (e.g. ones defined in `mrblib/10error.rb`) are
called only from `NoMethodError.new(args..)` forms.
2021-09-22 11:41:38 +09:00
Yukihiro "Matz" Matsumoto 913a0a5a03 vm.c: add assertions instead of mrb_ensure_hash_type(). 2021-09-21 16:47:55 +09:00
Yukihiro "Matz" Matsumoto dd0caf8728 Create SECURITY.md 2021-09-20 19:44:41 +09:00
Yukihiro "Matz" Matsumoto d6dd6f0e7b Update struct initializer to work with relatively older C++. 2021-09-20 19:13:17 +09:00
Yukihiro "Matz" Matsumoto 8be78dbf9d codedump.c: add cosmetic tabs before variable labels. 2021-09-20 17:33:07 +09:00
Yukihiro "Matz" Matsumoto c29822f80c codegen.c (gen_addsub): use mrb_int_sub_overflow(). 2021-09-20 17:32:38 +09:00
Yukihiro "Matz" Matsumoto 0455313a9b codegen.c: avoid constant folding OP_LOADI16 across branch target. 2021-09-20 17:30:14 +09:00
Yukihiro "Matz" Matsumoto ca7228ad42 codegen.c: gen_move should generate proper OP_LOADI16. 2021-09-20 16:58:27 +09:00
Yukihiro "Matz" Matsumoto 1baf08f174 codegen.c: rename loopinfo->acc to reg.
`acc` meant `accumulator` but it is not an accumulator but just a
register position.
2021-09-20 10:40:30 +09:00
Yukihiro "Matz" Matsumoto 2083d99392 codegen.c: check no_peephole(s) before mrb_last_insn(s). 2021-09-20 10:37:11 +09:00
Yukihiro "Matz" Matsumoto f85c50543b codegen.c (mrb_last_insn): no previous instruction on top. 2021-09-20 10:35:01 +09:00
Yukihiro "Matz" Matsumoto 938af8a8ff vm.c: add array assertions. 2021-09-19 23:17:19 +09:00
Yukihiro "Matz" Matsumoto 8bfa99975c codegen.c: unify OP_ARYPUSH and OP_ARYPUSH_N.
- `OP_ARYPUSH` now takes operand for the number of pushing elements
- the code generator consume the stack no more than `64` for `mruby/c`
2021-09-19 09:07:20 +09:00
Yukihiro "Matz" Matsumoto 7c99df8416 ops.h: add OP_ARYPUSH_N instruction.
Add n elements at once. Reduces instructions for huge array
initialization. In addition, `gen_value` function in `codegen.c` was
refactored and clarified.
2021-09-17 07:49:47 +09:00
Yukihiro "Matz" Matsumoto 6f044de578 AUTHORS: update. [ci skip] 2021-09-17 07:47:45 +09:00
Yukihiro "Matz" Matsumoto f7063ccd1b AUTHORS: update. [ci skip] 2021-09-16 20:24:29 +09:00
Yukihiro "Matz" Matsumoto 8619ba6a38 Use struct initializer instead of memset. 2021-09-15 13:02:15 +09:00
Yukihiro "Matz" Matsumoto e5e7bd29ef sprintf.c: width may have been INT_MAX.
Now `width` is limited to `INT16_MIN..INT16_MAX`.
2021-09-14 14:12:56 +09:00
Yukihiro "Matz" Matsumoto 6dbf49fdb4 parse.y: cons_free unused node (empty string node). 2021-09-13 12:20:11 +09:00
Yukihiro "Matz" Matsumoto 100eac3fec parse.y: allow non-local variable access from hash value omission.
For example, `{p:}` (means `{p:p}`) and `{String:}` (`{String:String}`)
should be allowed like CRuby.
2021-09-13 12:15:10 +09:00
Yukihiro "Matz" Matsumoto 6c76926d05 parse.y: allow value omission in Hash literals introduced in Ruby3.1.
`{x:, y:}` now is a syntax sugar of `{x: x, y: y}`.

This fix also includes the update of #4815 fix.
2021-09-13 11:04:27 +09:00
Yukihiro "Matz" Matsumoto 31fc74f5a8 parse.y: fix nint (int to node) and intn (node to int). 2021-09-12 23:14:43 +09:00
Yukihiro "Matz" Matsumoto 9e86d204e5 parse.y: avoid adding zero length strings. 2021-09-12 07:58:57 +09:00
Yukihiro "Matz" Matsumoto e1a865f272 codedump.c: avoid printing OP_EXT? prefix. 2021-09-11 11:00:11 +09:00
Yukihiro "Matz" Matsumoto 648a774ef6 ops.h: update OP_HASHADD description. 2021-09-10 19:11:56 +09:00
Yukihiro "Matz" Matsumoto da749d870f array.c: forgot to adjust tail position in mrb_ary_splice. 2021-09-10 17:34:40 +09:00
Yukihiro "Matz" Matsumoto cd0ffd6f1c codegen.c: fixed gen_setxv bug with taking assignment value; fix #5550 2021-09-10 15:39:24 +09:00
Yukihiro "Matz" Matsumoto 69da192eec codegen.c: gen_move refactoring. 2021-09-10 15:38:51 +09:00
Yukihiro "Matz" Matsumoto 7df31d9451 mruby.h: remove acc from callinfo; add cci instead.
`acc` was used as an index of the receiver (if positive), or a flag for
methods implemented in C. We replace `regs[ci->acc]` by `ci[1].stack[0]`.
And renamed `acc` (originally meant accumulator position) to `cci`
(means callinfo for C implemented method).
2021-09-10 12:39:51 +09:00
Yukihiro "Matz" Matsumoto 3050630b69 vm.c, codedump.c: add IREP_TT_NFLAG assertions.
The pool specified by `OP_STRING` (and `OP_SYMBOL`) should represent a
string, so that `IREP_TT_NFLAG` should be zero.
2021-09-10 10:25:07 +09:00
Yukihiro "Matz" Matsumoto 28b5c30b96 ops.h: add OP_SYMBOL instruction.
It generates a symbol by interning from the pool string.
2021-09-10 10:23:28 +09:00
Yukihiro "Matz" Matsumoto b34713304a fixup! codegen.c: resurrect s->lastpc to reduce iseq scans. 2021-09-10 10:22:49 +09:00
Yukihiro "Matz" Matsumoto 5fbea87fe5 codegen.c: resurrect s->lastpc to reduce iseq scans.
When parsing scripts frequent scans could cost too much.
2021-09-10 10:15:55 +09:00
Yukihiro "Matz" Matsumoto 3693187beb vm.c: ci->acc (int16_t) may overflow. 2021-09-10 10:15:32 +09:00
Yukihiro "Matz" Matsumoto c0f39bcaaf Merge pull request #5549 from mruby/dependabot/github_actions/github/super-linter-4.7.3
build(deps): bump github/super-linter from 4.7.2 to 4.7.3
2021-09-10 10:15:20 +09:00
dependabot[bot] a7e85bb7e9 build(deps): bump github/super-linter from 4.7.2 to 4.7.3
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.7.2 to 4.7.3.
- [Release notes](https://github.com/github/super-linter/releases)
- [Changelog](https://github.com/github/super-linter/blob/master/docs/release-process.md)
- [Commits](https://github.com/github/super-linter/compare/v4.7.2...v4.7.3)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-09 14:04:06 +00:00
Yukihiro "Matz" Matsumoto 7e612b1c89 string.c: check integer overflow in str_replace_partial. 2021-09-09 19:12:59 +09:00
Yukihiro "Matz" Matsumoto 8a41d2b876 string.c: check integer overflow in mrb_str_aset(). 2021-09-09 19:12:36 +09:00
Yukihiro "Matz" Matsumoto 5777e33c2a doc/guides/mrbconf.rb: add RO_DATA configuration description; #5547 2021-09-09 16:20:29 +09:00
Yukihiro "Matz" Matsumoto 49602f636d value.h: add configuration macros around mrb_ro_data_p(); close #5547
- `MRB_USE_ETEXT_RO_DATA_P`: use `etext` and `edata`
- `MRB_NO_DEFAULT_RO_DATA_P`: not use the default `mrb_ro_data_p()`
2021-09-09 16:15:25 +09:00
Yukihiro "Matz" Matsumoto 5dd8b04d91 load.c: no need for conditional compilation; #5547
`mrb_ro_data_p()` is available anyway.
2021-09-09 11:07:19 +09:00
Yukihiro "Matz" Matsumoto a503484cb3 value.h: use etext and edata which are more widely available; #5547 2021-09-09 10:12:50 +09:00
Yukihiro "Matz" Matsumoto a3fe04eda2 Merge pull request #5548 from mruby/dependabot/github_actions/github/super-linter-4.7.2
build(deps): bump github/super-linter from 4.7.1 to 4.7.2
2021-09-09 07:34:02 +09:00
dependabot[bot] ddf2a49622 build(deps): bump github/super-linter from 4.7.1 to 4.7.2
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.7.1 to 4.7.2.
- [Release notes](https://github.com/github/super-linter/releases)
- [Changelog](https://github.com/github/super-linter/blob/master/docs/release-process.md)
- [Commits](https://github.com/github/super-linter/compare/v4.7.1...v4.7.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-08 14:04:32 +00:00
Yukihiro "Matz" Matsumoto e4a0728b24 array.c: refactor mrb_ary_splice. 2021-09-08 07:33:08 +09:00
Yukihiro "Matz" Matsumoto 1d1a89874f value.h: fixed address comparison on macOS. 2021-09-07 18:51:04 +09:00
Yukihiro "Matz" Matsumoto cbfaa5e20f object.c: rename mrb_to_int to mrb_to_integer.
Consistent naming: `integer` to represent integer packed in `mrb_value`
instead of `int`.
2021-09-07 14:31:56 +09:00
Yukihiro "Matz" Matsumoto 79bc8e2539 string.h: rename mrb_str_to_inum to mrb_str_to_integer.
Consistent naming: `integer` to represent integer packed in `mrb_value`
instead of `inum`.
2021-09-07 14:31:56 +09:00
Yukihiro "Matz" Matsumoto 674d841ead eval.c: if the parser raises an exception without an error message
`eval` would have crashed in formatting.
2021-09-07 07:37:19 +09:00
Yukihiro "Matz" Matsumoto 711f06a562 eval.c: check length of the file name.
It should be lexx than `UINT16_MAX`. If you don't check here, the parser
would raise an exception.
2021-09-07 07:35:35 +09:00
Yukihiro "Matz" Matsumoto 6fc6880f1f codegen.c: improve exception handling in generate_code.
- remove `mrb_jmpbuf` from `codegen_scope`
- unify exception handling of `mrb_state` and `codegen_scope`
2021-09-07 07:33:28 +09:00
Yukihiro "Matz" Matsumoto 2fb06aabe6 parse.y: refactor mrb_parser_parse().
- remove `mrb_jmpbuf` from `truct mrb_parser_state`
- unify exception handling of `mrb_state` and `mrb_parser_state`.
2021-09-07 07:31:21 +09:00
Yukihiro "Matz" Matsumoto ad3404229f parse.y: refactoring mrb_parser_parser(). 2021-09-06 13:58:01 +09:00
Yukihiro "Matz" Matsumoto fc1f7c4bf0 numeric.c: shortcut overflowing operation when ndigit is too small. 2021-09-06 10:21:42 +09:00
Yukihiro "Matz" Matsumoto ab3db07752 boxing_word.h: avoid mrb_float_p() when MRB_NO_FLOAT is on; fix #5546 2021-09-05 20:59:49 +09:00
Yukihiro "Matz" Matsumoto 43abf36f00 array.c: check integer overflow before addition. 2021-09-05 16:41:08 +09:00
Yukihiro "Matz" Matsumoto 7552b9322a codegen.c: avoid integer overflow. 2021-09-05 09:25:44 +09:00
Yukihiro "Matz" Matsumoto 28c4f2f683 kernel.c: add __method__; ref #4468 2021-09-04 17:57:35 +09:00
Yukihiro "Matz" Matsumoto 09f686cd7b Merge branch 'shuujii-rename-Kernel-__method__-to-Kernel-__callee__' 2021-09-04 16:18:20 +09:00
KOBAYASHI Shuji 8a9f891fd3 Rename Kernel#__method__ to Kernel#__callee__
Because the current behavior of `__method__` is equivalent to `__callee__`.

Example:

  # example.rb
  def src
    __send__(ARGV[0])
  end
  alias dst src
  %w[src dst].each {|n| puts "call #{n} => #{__send__(n).inspect}"}

  Ruby:

    $ ruby example.rb __method__
    call src => :src
    call dst => :src

    $ ruby example.rb __callee__
    call src => :src
    call dst => :dst

  mruby:

    $ mruby example.rb __method__
    call src => :src
    call dst => :dst
2021-09-04 16:17:06 +09:00
Yukihiro "Matz" Matsumoto 2d8f4fa92f proc.c: need to preserve target_class in callinfo.
Otherwise `target_class` can be lost when it differs from `proc`'s
`target_class`, e.g. when called from `instance_eval`.

Also we should not pass `target_class` to `MRB_OBJ_ALLOC` since it
checks instance type from the class, and `target_class` may not have
proper information. ref #5272
2021-09-04 13:50:32 +09:00
Yukihiro "Matz" Matsumoto 5acf7e7cf7 vm.c: remove duplicated calls of mrb_vm_ci_target_class(). 2021-09-04 12:54:04 +09:00
Yukihiro "Matz" Matsumoto e02350dd02 range.c: len = b - a may overflow. 2021-09-03 16:30:42 +09:00
Yukihiro "Matz" Matsumoto dc4b60291a range.c: hide internal `__num_to_a' method from backtrace. 2021-09-03 16:30:42 +09:00
Yukihiro "Matz" Matsumoto 161f2403b3 Merge pull request #5545 from mruby/dependabot/github_actions/github/super-linter-4.7.1
build(deps): bump github/super-linter from 4.6.3 to 4.7.1
2021-09-02 07:26:25 +09:00
dependabot[bot] a6bb53f65a build(deps): bump github/super-linter from 4.6.3 to 4.7.1
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.6.3 to 4.7.1.
- [Release notes](https://github.com/github/super-linter/releases)
- [Changelog](https://github.com/github/super-linter/blob/master/docs/release-process.md)
- [Commits](https://github.com/github/super-linter/compare/v4.6.3...v4.7.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-01 14:06:39 +00:00
Yukihiro "Matz" Matsumoto de9bf86432 Merge pull request #5544 from stuarth/change-language
Use gender-neutral pronouns
2021-09-01 13:59:04 +09:00
Stuart Hinson 2c167361d5 use gender-neutral pronouns 2021-08-31 19:17:49 -07:00
Yukihiro "Matz" Matsumoto 5211a3f209 Merge pull request #5543 from mruby/dependabot/github_actions/github/super-linter-4.6.3
build(deps): bump github/super-linter from 4.6.2 to 4.6.3
2021-09-01 07:03:01 +09:00
Yukihiro "Matz" Matsumoto 41d0b343e6 string.c: need to adjust index for UTF-8. 2021-09-01 07:00:56 +09:00
Yukihiro "Matz" Matsumoto 7ffffbfe01 build_config/ci/gcc-clang.rb: enable MRB_UTF8_STRING. 2021-09-01 07:00:55 +09:00
Yukihiro "Matz" Matsumoto 3622f2c4b5 string.c: implement __sub_replace() in C.
To reduce number of string allocation.
2021-09-01 07:00:55 +09:00
Yukihiro "Matz" Matsumoto 2c41739b66 mruby.h: obsolete mrb_to_str().
Replace them by `mrb_ensure_string_type()`.
2021-09-01 07:00:55 +09:00
Yukihiro "Matz" Matsumoto 082882da69 string.rb: avoid internal __to_str calls.
`__to_str` was a mere type check method despite its name.
2021-09-01 07:00:55 +09:00
Yukihiro "Matz" Matsumoto 8c296a3818 object.c: remove `mrb_convert_to_integer()' function.
And merged to `mrb_f_integer()` which is only usage of the function.
2021-09-01 07:00:54 +09:00
Yukihiro "Matz" Matsumoto 37a7ff228b string-ext/string.c: implement casecmp in C.
* should not raise error for non-string arguments
* avoid allocating case converted string internally
2021-09-01 07:00:54 +09:00
Yukihiro "Matz" Matsumoto f6e5c902f0 string.h: obsolete mrb_str_to_str(), even from examples. 2021-09-01 07:00:54 +09:00
Yukihiro "Matz" Matsumoto e86c9cb57c Do no use return values from mrb_ensure_ functions.
They return the checking argument without modification, so the values
are already there. Maybe we should change the return type to `void` but
keep them unchanged for compatibility.
2021-09-01 07:00:54 +09:00
Yukihiro "Matz" Matsumoto 572a43de84 mruby.h: reorganize mrb_ensure/check functions in headers. 2021-09-01 07:00:53 +09:00
dependabot[bot] ad5c90e556 build(deps): bump github/super-linter from 4.6.2 to 4.6.3
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.6.2 to 4.6.3.
- [Release notes](https://github.com/github/super-linter/releases)
- [Commits](https://github.com/github/super-linter/compare/v4.6.2...v4.6.3)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-31 14:07:23 +00:00
Yukihiro "Matz" Matsumoto 64d5a40cde Merge pull request #5542 from dearblue/mrb_get_args-cI
Allow `nil` for `c!` and `I!` specifiers of `mrb_get_args()`
2021-08-30 07:38:45 +09:00
Yukihiro "Matz" Matsumoto 84e36d748c Merge pull request #5541 from dearblue/mrb_get_args-oCSAH
Integrate the processing of similar specifiers of `mrb_get_args()`
2021-08-29 08:32:05 +09:00
dearblue f99620436d Allow nil for c! and I! specifiers of mrb_get_args() 2021-08-28 15:54:30 +09:00
dearblue c9f7bcc0cf Integrate the processing of similar specifiers of mrb_get_args()
It is `o`, `C`, `S`, `A` and `H` specifiers that are integrated.
As a side effect, the `C!` Specifier can now be used.
2021-08-28 15:52:37 +09:00
Yukihiro "Matz" Matsumoto 07f12fe890 Merge pull request #5540 from dearblue/mrb_get_args
Refactor the `mrb_get_args()` function
2021-08-28 12:50:47 +09:00
dearblue 6ac8d14b7b Refactor the mrb_get_args() function
- Removed the `ARGV` macro.
  The current path doesn't go into the mruby VM and there's also no need to separate variables.
- Use common functions to check object types.
  - Use `mrb_ensure_string_type()` to check the string instead of `mrb_to_str()`.
    This is for consistency with array and hash.
  - Use `mrb_ensure_array_type()` to check the array instead of `to_ary()`.
  - Use `mrb_ensure_hash_type()` to check the hash instead of `to_hash()`.
  - Add and use `ensure_class_type()` to check class and module.
- Changed the argument index type from `mrb_int` to `int`.
  Even if it is `int16_t`, it is enough.
  `mrb_int` is overkill, especially if `MRB_32BIT` and `MRB_INT64` are defined.
2021-08-27 22:43:25 +09:00
Yukihiro "Matz" Matsumoto 12a483c1bc Merge pull request #5539 from mruby/dependabot/github_actions/github/super-linter-4.6.2
build(deps): bump github/super-linter from 4.6.1 to 4.6.2
2021-08-27 07:43:48 +09:00
dependabot[bot] 86c5414dc1 build(deps): bump github/super-linter from 4.6.1 to 4.6.2
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.6.1 to 4.6.2.
- [Release notes](https://github.com/github/super-linter/releases)
- [Commits](https://github.com/github/super-linter/compare/v4.6.1...v4.6.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-26 14:05:40 +00:00
Yukihiro "Matz" Matsumoto 4654de9074 etc.c: keep full float32 with MRB_64BIT and MRB_USE_FLOAT32. 2021-08-26 16:06:02 +09:00
Yukihiro "Matz" Matsumoto ba6e121537 boxing_nan.h: rename prefix BOXNAN to NANBOX. 2021-08-26 16:06:02 +09:00
Yukihiro "Matz" Matsumoto 9d6755569e boxing_word.h: rename prefix BOXWORD to WORDBOX. 2021-08-26 16:06:01 +09:00
Yukihiro "Matz" Matsumoto fdfa0caa46 boxing_word.h: rename configuration macro name.
`MRB_WORDBOX_USE_HEAP_FLOAT` instead of `MRB_USE_FLOAT_FULL_PRECISION`.
2021-08-26 16:06:01 +09:00
Yukihiro "Matz" Matsumoto e9c6e52f5b value.h: reconstruct mrb_ro_data_p().
* use predefined `mrb_ro_data_p()` for user-mode Linux and macOS
* define `MRB_LINK_TIME_RO_DATA_P` if predefined one is used
* configure macro `MRB_USE_LINK_TIME_RO_DATA_P` is no longer used
* contributions for new platforms are welcome
2021-08-26 16:06:01 +09:00
Yukihiro "Matz" Matsumoto d00ae8d166 Merge pull request #5538 from jbampton/pre-commit-autoupdate
pre-commit autoupdate
2021-08-26 11:11:04 +09:00
John Bampton db884a05e8 pre-commit autoupdate
https://pre-commit.com/#pre-commit-autoupdate
2021-08-25 18:24:02 +10:00
Yukihiro "Matz" Matsumoto b8b86d1976 Merge pull request #5535 from dearblue/get-args-frozen
Checks the frozen object with `mrb_get_args()`
2021-08-24 16:33:15 +09:00
dearblue 66aa184a82 Checks the frozen object with mrb_get_args()
This now works with the `+` modifier that can be added after each specifier.

- `nil` is bypassed.
- The `s` and `z` specifiers are received in C as a `const char *`, so adding a `+` modifier will raise an exception.
- The `a` specifier is received in C as `const mrb_value *`, so adding a `+` modifier will raise an exception.
- The `|`, `*`, `&`, `?` and `:` specifiers with `+` modifier raises an exception.

If `!`/`+` exceeds one for each specifier, an exception will occur in the subsequent processing.
This is the same behavior as before.
2021-08-23 21:58:57 +09:00
dearblue 6415faabaa Integrate each element expansion process of the argument
The previously used `given` variable will be merged into the `pickarg` pointer variable, which points to the argument currently being processed for each loop.
2021-08-23 21:58:51 +09:00
Yukihiro "Matz" Matsumoto 6f46f88873 numeric.c: fix: -0.0.abs returned -0.0. 2021-08-23 10:53:23 +09:00
Yukihiro "Matz" Matsumoto 11cfe77eb1 Merge pull request #5537 from dearblue/header-files
Organize the include of header files
2021-08-23 07:34:37 +09:00
Yukihiro "Matz" Matsumoto 0f36710445 Merge pull request #5536 from dearblue/random-seed
Stirs internal state when `seed` is set in `Random`
2021-08-22 12:37:34 +09:00
dearblue 5a57602860 Organize the include of header files
- `#include <math.h>` is done in `mruby.h`.
  Eliminate the need to worry about the `MRB_NO_FLOAT` macro.

- Include mruby header files before standard header files.
  If the standard header file is already placed before `mruby.h`, the standard header file added in the future tends to be placed before `mruby.h`.

This change should some reduce the chances of macros that must be defined becoming undefined in C++ or including problematic header files in a particular mruby build configuration.
2021-08-21 15:42:57 +09:00
dearblue 2121b6e689 Stirs internal state when seed is set in Random
This is to avoid the approximation of `Random#rand` when `seed`s are close together.

For example, the first `#rand` values after doing `Random#srand(0)` and `Random#srand(1)` are very similar.

Below is the sequence of mruby before this patch was given a `seed` of `0...20`:

```console
% bin/mruby -e 'r = Random.new; 20.times { |i| r.srand(i); puts "seed=%2d  %s" % [i, 10.times.map { "%0.3f" % r.rand }.join(" ")] }'
seed= 0  0.643 0.585 0.198 0.732 0.087 0.605 0.548 0.468 0.573 0.966
seed= 1  0.643 0.585 0.198 0.607 0.370 0.605 0.633 0.593 0.395 0.439
seed= 2  0.643 0.585 0.197 0.981 0.652 0.730 0.875 0.713 0.529 0.269
seed= 3  0.643 0.585 0.198 0.857 0.934 0.730 0.960 0.216 0.286 0.523
seed= 4  0.643 0.585 0.197 0.231 0.217 0.605 0.959 0.958 0.478 0.482
seed= 5  0.643 0.585 0.197 0.106 0.249 0.605 0.044 0.330 0.925 0.047
seed= 6  0.643 0.585 0.197 0.481 0.781 0.731 0.285 0.960 0.804 0.725
seed= 7  0.643 0.585 0.197 0.356 0.813 0.731 0.370 0.711 0.937 0.448
seed= 8  0.643 0.585 0.198 0.732 0.329 0.108 0.243 0.974 0.766 0.936
seed= 9  0.643 0.585 0.198 0.607 0.611 0.108 0.827 0.102 0.962 0.597
seed=10  0.643 0.585 0.198 0.981 0.393 0.233 0.569 0.723 0.472 0.805
seed=11  0.643 0.585 0.198 0.857 0.676 0.233 0.154 0.222 0.603 0.371
seed=12  0.643 0.585 0.198 0.231 0.458 0.108 0.654 0.979 0.928 0.577
seed=13  0.643 0.585 0.198 0.106 0.490 0.108 0.239 0.355 0.749 0.831
seed=14  0.643 0.585 0.198 0.481 0.523 0.233 0.981 0.486 0.505 0.131
seed=15  0.643 0.585 0.198 0.356 0.555 0.234 0.565 0.233 0.011 0.666
seed=16  0.643 0.585 0.197 0.730 0.573 0.611 0.904 0.512 0.971 0.153
seed=17  0.643 0.585 0.197 0.605 0.855 0.611 0.240 0.636 0.041 0.509
seed=18  0.643 0.585 0.196 0.979 0.137 0.736 0.229 0.765 0.674 0.832
seed=19  0.643 0.585 0.197 0.855 0.420 0.736 0.566 0.268 0.183 0.219
```
2021-08-21 15:37:12 +09:00
Yukihiro "Matz" Matsumoto 886055b3fb etc.c: clear mrb_value if sizeof(void*) is bigger than sizeof(mrb_float). 2021-08-21 15:25:59 +09:00
Yukihiro "Matz" Matsumoto 8ca40da3fe test/float.rb: avoid 1.0e16 in tests without precision specified. 2021-08-21 15:25:59 +09:00
Yukihiro "Matz" Matsumoto 3b4c4caddc mruby-test/driver.c: change FLOAT_TOLERANCE bigger for inline floats. 2021-08-21 15:25:59 +09:00
Yukihiro "Matz" Matsumoto 36632f55f4 boxing_word.h: embed mrb_float in mrb_value if possible.
Embedding reduce memory consumption, sacrificing precision. It clips least
significant 2 bits from `mrb_float`, so if you need to keep float precision,
define `MRB_USE_FLOAT_FULL_PRECISION`.

`MRB_WORD_BOXING` and `MRB_INT64`:

`mrb_float` (`double`) is embedded in `mrb_value` clipped last 2 bits.

`MRB_WORD_BOXING` and `MRB_INT64` and `MRB_USE_FLOAT_FULL_PRECISION`:

`mrb_float` is allocated in the heaps wrapped by `struct RFloat`.

`MRB_WORD_BOXING` and `MRB_INT32` and `MRB_USE_FLOAT32`:

`mrb_float` (`float`) is embedded in `mrb_value` clipped last 2 bits.
In addition, to reserve bit space in the `mrb_value`, maximum inline
symbol length become 4 (instead of 5) in the configuration.

`MRB_WORD_BOXING` and `MRB_INT32`:

Assume `MRB_USE_FLOAT_FULL_PRECISION` and allocate Float values in heap.
2021-08-21 15:25:58 +09:00
Yukihiro "Matz" Matsumoto 4ea80913c2 Merge pull request #5533 from dantecatalfamo/serenity-32bit-crossbuild
Add SerenityOS crossbuild
2021-08-21 15:25:46 +09:00
Dante Catalfamo 7f290bebaf Specify potential values for SERENITY_ARCH 2021-08-20 22:27:50 -04:00
Dante Catalfamo 5e030491e7 Replace 32-bit serenity config with 64-bit compatible version. 2021-08-20 14:48:49 -04:00
Dante Catalfamo 124c4d617f Add serenity-32bit crossbuild
Cross compile mruby for SerenityOS (https://github.com/SerenityOS/serenity)
2021-08-19 23:34:30 -04:00
Yukihiro "Matz" Matsumoto ca295a2c23 symbol.c: reduce memory by avoiding alignment gaps.
In additions:

* use bitmap for flags
* BER integer compression for length
2021-08-19 20:39:34 +09:00
Yukihiro "Matz" Matsumoto 7f8b30261f gc.c: remove unused structs from RVALUE. 2021-08-19 16:06:17 +09:00
Yukihiro "Matz" Matsumoto 6f305c01a2 value.h: fixed warnings on __APPLE__. 2021-08-19 13:08:39 +09:00
Yukihiro "Matz" Matsumoto 959383df75 value.h: enable mrb_ro_data_p() on __linux__ and __APPLE__.
Probably we should add conditions for FreeBSD, etc.
2021-08-19 12:52:10 +09:00
Yukihiro "Matz" Matsumoto ef66406c50 string.c: mrb_str_to_cstr() should always return a mutable string. 2021-08-18 21:40:10 +09:00
Yukihiro "Matz" Matsumoto 20635e6bdc debug.c: export integer compressing functions.
- mrb_packed_int_len()
- mrb_packed_int_encode()
- mrb_packed_int_decode()
2021-08-18 17:18:04 +09:00
Yukihiro "Matz" Matsumoto 96a8703ca8 boxing_word.h: simplifies inline symbols on MRB_64BIT. 2021-08-17 16:03:42 +09:00
Yukihiro "Matz" Matsumoto 80cf293bf6 pack.c: rename pack/unpack functions for readability. 2021-08-17 13:04:11 +09:00
Yukihiro "Matz" Matsumoto 57b347088d fixup! pack.c: reduce dispatch in pack_unpack(). 2021-08-17 13:04:06 +09:00
Yukihiro "Matz" Matsumoto 4385590d31 pack.c: reduce dispatch in pack_unpack(). 2021-08-17 12:52:56 +09:00
Yukihiro "Matz" Matsumoto bfe2bd4960 pack.c: fix M packing bug. 2021-08-16 10:56:44 +09:00
Yukihiro "Matz" Matsumoto 8d85d4ac9b AUTHORS: update. [ci skip] 2021-08-15 07:07:08 +09:00
Yukihiro "Matz" Matsumoto 40c4c5d344 random.c: use I specifier for mrb_get_args(); ref #5530 2021-08-14 15:28:38 +09:00
Yukihiro "Matz" Matsumoto 8e5e96239c pack.c: fixed a overwriting bug in pack_w and pack_M. 2021-08-14 14:58:09 +09:00
Yukihiro "Matz" Matsumoto ad194bd46b error.c: the error message may contain NUL character. 2021-08-14 13:01:47 +09:00
Yukihiro "Matz" Matsumoto 73798bff65 Merge pull request #5532 from dantecatalfamo/rhel-doxygen
Add instructions for installing doxygen on RHEL/Fedora/CentOS
2021-08-14 08:18:11 +09:00
Dante Catalfamo 89ea8fa34a Add instructions for installing doxygen on RHEL/Fedora/CentOS 2021-08-13 14:53:20 -04:00
Yukihiro "Matz" Matsumoto 32c30c35b2 Merge pull request #5530 from dearblue/mrb_get_args-I
Check the class with `I` specifier of `mrb_get_args()`
2021-08-13 18:11:26 +09:00
dearblue 01da5e1392 Check the class with I specifier of mrb_get_args()
Previously, the `I` specifier only checked if the object was `MRB_TT_ISTRUCT`.
So it was at risk of getting pointers to different C structs if multiple classes were to use the `MRB_TT_ISTRUCT` instance.

Change this behavior and change the C argument corresponding to the `I` specifier to `(void *, struct RClass)`.

This change is not compatible with the previous mruby.
Please note that if the user uses the previous specifications, `SIGSEGV` may occur or the machine stack may be destroyed.

resolve #5527
2021-08-13 15:04:19 +09:00
Yukihiro "Matz" Matsumoto 9e74aad43c codegen.c: fixed a bug in mrb_decode_insn(). 2021-08-13 12:38:10 +09:00
Yukihiro "Matz" Matsumoto 7907c184be codegen.c: add a comment that notice rewind_pc calling convention.
`rewind_pc` should not be called when `s->pc` is `0` (top).
2021-08-13 10:11:36 +09:00
Yukihiro "Matz" Matsumoto 9c3d305530 codegen.c: refactor mrb_last_insn().
Last commit made `mrb_decode_insn()` to take `NULL` as `pc`.
2021-08-13 10:10:17 +09:00
Yukihiro "Matz" Matsumoto cbdc4f2c5c codegen.c: mrb_prev_pc can return NULL at the top of iseq. 2021-08-13 10:02:01 +09:00
Yukihiro "Matz" Matsumoto 013365498d test/eval.c: add test for #5528 2021-08-12 11:57:56 +09:00
Yukihiro "Matz" Matsumoto 43f9901ec2 Revert "Drop unnecessary upper procs linked from class/module/def syntax"
Fix #5528
This reverts commit 59201b59046b9e73c309508350cd3c0fafd20e4d; #5497
2021-08-12 11:42:27 +09:00
Yukihiro "Matz" Matsumoto 80893811c0 class.c: const_missing do not have to be in the backtrace; ref #5528 2021-08-12 08:10:09 +09:00
Yukihiro "Matz" Matsumoto e1b170160b codegen.c: avoid signedness warning of int comparison. 2021-08-11 16:10:32 +09:00
Yukihiro "Matz" Matsumoto a85f2299c0 codegen.c: avoid cross initialization of mrb_insn_data. 2021-08-11 16:09:51 +09:00
Yukihiro "Matz" Matsumoto fd597d2655 codedump.c: print local variable name for `ADDI/SUBI/ instructions.
Recent peephole optimization made `ADDI/SUBI` destinations possibly
local variables.
2021-08-11 10:48:18 +09:00
Yukihiro "Matz" Matsumoto b1b9b157f8 codegen.c: more peephole optimization.
`a=10; a+=1` to generate:

```
    1 000 OP_LOADI      R1      11              ; R1:a
```

instead of:

```
    1 000 OP_LOADI      R1      10              ; R1:a
    1 003 OP_MOVE       R2      R1              ; R1:a
    1 006 OP_ADDI       R2      1
    1 009 OP_MOVE       R1      R2              ; R1:a
```
2021-08-11 10:48:18 +09:00
Yukihiro "Matz" Matsumoto 52eb2af7d0 Merge pull request #5526 from mruby/dependabot/github_actions/github/super-linter-4.6.1
build(deps): bump github/super-linter from 4.6.0 to 4.6.1
2021-08-11 06:27:53 +09:00
dependabot[bot] b83eb8dcff build(deps): bump github/super-linter from 4.6.0 to 4.6.1
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.6.0 to 4.6.1.
- [Release notes](https://github.com/github/super-linter/releases)
- [Commits](https://github.com/github/super-linter/compare/v4.6.0...v4.6.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-10 14:06:15 +00:00
Yukihiro "Matz" Matsumoto 3909281126 Merge pull request #5524 from dearblue/gem-headers
Expose all header files of the gems for small compilation
2021-08-10 06:21:18 +09:00
dearblue 4c25ace8b3 Expose all header files of the gems for small compilation
After building mruby, if the user compiles and links to `libmruby.a`, expose the included directory of the captured gems.
This is a change to the `<build-dir> /lib/libmruby.flags.mak` file and will result in being added to `bin/mruby-config --cflags`.
This eliminates the need for the user to look up the path and add the compiler flag if the user wants to take advantage of her gems publishing features.

In the main build with `rake CONFIG=...`, there is no problem because it can only be seen from the gems that depends directly and indirectly as before.
However, when compiling independently by the user using `bin/mruby-config`, a header file name collision may occur if a unique header directory is added.
2021-08-09 21:16:45 +09:00
Yukihiro "Matz" Matsumoto e8dbf1db9a Merge pull request #5525 from jbampton/pre-commit-autoupdate
pre-commit autoupdate
2021-08-09 11:38:31 +09:00
John 530a91752f pre-commit autoupdate
https://pre-commit.com/#pre-commit-autoupdate
2021-08-09 10:10:09 +10:00
Yukihiro "Matz" Matsumoto 0b2ebf4868 Merge pull request #5522 from dearblue/pack-EOF
Fixed compilation error of "mruby-pack" with `MRB_NO_STDIO`
2021-08-09 08:39:12 +09:00
Yukihiro "Matz" Matsumoto 1e1d296497 Merge pull request #5523 from jbampton/patch-1
docs: fix case of mruby
2021-08-08 09:25:23 +09:00
John Bampton 0516d94c83 docs: fix case of mruby 2021-08-07 16:51:04 +10:00
dearblue 18ef4e35f3 Fixed compilation error of "mruby-pack" with MRB_NO_STDIO 2021-08-07 14:29:55 +09:00
Yukihiro "Matz" Matsumoto 35d230a669 codedump.c: print two operands R(x) and R(x+1) for clarity. 2021-08-07 12:12:24 +09:00
Yukihiro "Matz" Matsumoto 06f49b3f84 codegen.c: need to push the value when the loop was eliminated. 2021-08-07 12:11:38 +09:00
Yukihiro "Matz" Matsumoto cd02cef465 array.h: avoid duplicated defined of MRB_ARY_NO_EMBED; fix #5520 2021-08-07 06:48:03 +09:00
Yukihiro "Matz" Matsumoto ce0b38fb72 Merge pull request #5521 from mruby/dependabot/github_actions/github/super-linter-4.6.0
build(deps): bump github/super-linter from 4.5.1 to 4.6.0
2021-08-07 06:46:35 +09:00
dependabot[bot] d0b214c269 build(deps): bump github/super-linter from 4.5.1 to 4.6.0
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.5.1 to 4.6.0.
- [Release notes](https://github.com/github/super-linter/releases)
- [Commits](https://github.com/github/super-linter/compare/v4.5.1...v4.6.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-06 14:05:46 +00:00
Yukihiro "Matz" Matsumoto 46a1c40fe3 numeric_ext.c: fix a bug regarding MRB_INT_MIN. 2021-08-06 11:16:12 +09:00
Yukihiro "Matz" Matsumoto ff2da0b66e numeric.c: fix a bug regarding MRB_INT_MIN. 2021-08-06 11:15:46 +09:00
Yukihiro "Matz" Matsumoto 37dbb91b96 codegen.c: -9223372036854775808 % -1 overflows 64 bit integer. 2021-08-06 10:35:06 +09:00
Yukihiro "Matz" Matsumoto 7ecc16f97a codegen.c: remove code duplication from NODE_ARRAY. 2021-08-05 16:59:32 +09:00
Yukihiro "Matz" Matsumoto 9cb44f5ae3 codegen.c: detect integer overflow in division.
`MRB_INT_MIN / -1` overflows.
2021-08-04 12:25:14 +09:00
Yukihiro "Matz" Matsumoto 9f37733382 numeric.c: fix a bug in left shift of negative integer.
`-1 * (1<<63)` causes overflow, but `-1<<63` is a valid value.
2021-08-04 12:05:09 +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
Yukihiro "Matz" Matsumoto 9b3b2a4c95 numeric.c: check zero division before modulo. 2021-08-03 16:45:08 +09:00
Yukihiro "Matz" Matsumoto caaa07f2da codegen.c: check zero division before constant folding. 2021-08-03 16:43:50 +09:00
Yukihiro "Matz" Matsumoto c480ac4457 numeric_ext.c: modulo and remainder should handle infinite argument. 2021-08-03 16:35:31 +09:00
Yukihiro "Matz" Matsumoto e75572af6a numeric_ext.c: add Float#modulo and #remainder methods. 2021-08-03 16:30:47 +09:00
Yukihiro "Matz" Matsumoto f4afcbef67 numeric_ext.c: update Integer#remainder method.
- need to detect zero division error
- support floating point number argument (as `%`)
2021-08-03 16:28:11 +09:00
Yukihiro "Matz" Matsumoto b70fd09f47 Revert "numeric.c: simplifies int_mod definition."
This reverts commit 3738d62a86.
The change changed the behavior with floating point numbers.
2021-08-03 16:11:02 +09:00
Yukihiro "Matz" Matsumoto 2092bc7fe8 codegen.c: avoid division by zero in constant folding. 2021-08-03 15:57:01 +09:00
Yukihiro "Matz" Matsumoto fad47a98a7 numeric_ext.c: use mrb_integer instead of mrb_as_int.
`mrb_as_int` implicitly converts the value into the integer, but those
methods are defined for Integer class so that the value should always be
integers.
2021-08-03 13:15:34 +09:00
Yukihiro "Matz" Matsumoto 3738d62a86 numeric.c: simplifies int_mod definition. 2021-08-03 13:14:23 +09:00
Yukihiro "Matz" Matsumoto df6ef39d1c numeric_ext.c: define modulo and remainder methods for Integer. 2021-08-03 13:13:42 +09:00
Yukihiro "Matz" Matsumoto b9d2b47f16 Replace mrb_fixnum_value() with mrb_int_value().
Use `mrb_fixnum_value()` only when you are absolutely sure that the
value is within `Fixnum` range, i.e. 31 bits signed integer at least.
2021-08-03 13:00:11 +09:00
Yukihiro "Matz" Matsumoto 23e7cb41e5 Replace fixnum references with int.
The `Fixnum` class is no longer provided by `mruby`.
2021-08-03 13:00:10 +09:00
Yukihiro "Matz" Matsumoto 019b006ee5 numeric_ext.c: remove unnecessary prefix mrb_ from static functions. 2021-08-03 10:33:04 +09:00
Yukihiro "Matz" Matsumoto 1f0238a928 numeric.c: rename fixdivmod to intdivmod. 2021-08-03 07:30:59 +09:00
Yukihiro "Matz" Matsumoto 4fa24e4ff9 codegen.c: allow constant folding for negative integer modulo. 2021-08-02 16:48:16 +09:00
Yukihiro "Matz" Matsumoto 81d56477f2 numeric.c: simpler integer modulo calculation. 2021-08-02 16:47:50 +09:00
Yukihiro "Matz" Matsumoto 504d05232d mrdb.c: do not skip OP_JMP on step execution. 2021-08-02 16:19:08 +09:00
Yukihiro "Matz" Matsumoto e93642d53f codegen.c: refactor readint() to read MRB_INT_MIN. 2021-08-02 14:10:38 +09:00
Yukihiro "Matz" Matsumoto 6ea0c04c06 numeric.c: use C's modulo operator if both operands are positive. 2021-08-02 14:09:38 +09:00
Yukihiro "Matz" Matsumoto a5ac9c8790 test/driver.c: remove unused constants related to FIXNUM. 2021-08-02 08:56:38 +09:00
Yukihiro "Matz" Matsumoto 9902ab50fc codegen.c: fix a bug in bit shift constant folding. 2021-08-02 08:53:50 +09:00
Yukihiro "Matz" Matsumoto a9d721ea8f numeric.c: refactor integer bit shift operations. 2021-08-02 08:53:14 +09:00
Yukihiro "Matz" Matsumoto 907df715ef codegen.c: refactor unary operator optimization. 2021-08-02 08:51:39 +09:00
Yukihiro "Matz" Matsumoto 188c150f44 codegen.c: constant folding binary operators, <<, >>, %, &, |, ^. 2021-08-02 07:34:54 +09:00
Yukihiro "Matz" Matsumoto 1315e8751e codegen.c: eliminate loop if condition is constant.
For example, `while false; ...; end` should be removed.
2021-08-01 20:33:41 +09:00
Yukihiro "Matz" Matsumoto 9dc801a798 codegen.c: peephole optimize OP_JMPxxx. 2021-08-01 20:31:19 +09:00
Yukihiro "Matz" Matsumoto b1cb6c3c69 codegen.c: allow constant folding for mul / div. 2021-07-31 21:14:54 +09:00
Yukihiro "Matz" Matsumoto 43999492a7 codegen.c: mrb_prev_pc() to take previous instruction position.
It rescans `s->iseq` so that peephole optimizer can take multiple
previous instructions for constant folding, etc.
2021-07-31 21:11:36 +09:00
Yukihiro "Matz" Matsumoto 4306893971 codedump.c: instruction length should be ilen, not iseq. 2021-07-30 17:50:24 +09:00
Yukihiro "Matz" Matsumoto 517071e3fa codegen.c: order instructions in natural order for loops.
`while` and `until` generates in `cond` `jmpif` `body` `jmp` order.
It used to be in `jmp` `body` `cond` `jmpif` order.
2021-07-29 17:38:18 +09:00
Yukihiro "Matz" Matsumoto 5cde5983d9 debug.c: uses most space efficient packed map for line information. 2021-07-28 23:08:58 +09:00
Yukihiro "Matz" Matsumoto 64358c09d9 codegen.c: labels should be uint32_t. 2021-07-28 23:08:58 +09:00
Yukihiro "Matz" Matsumoto adfd29c1b0 codegen.c: fix loopinfo structure members.
- `pc0`: `next` destination
- `pc1`: `redo` destination (renamed from `pc2`)
- `pc3`: `break` destination (renamed from `pc3`)

old `pc1` was unused so removed.
2021-07-28 23:08:58 +09:00
Yukihiro "Matz" Matsumoto e81d497155 codegen.c: removed bytecode when the value of while is not used. 2021-07-28 23:08:58 +09:00
Yukihiro "Matz" Matsumoto 2910af0010 codegen.c: fixed a bug when value is taken from while and until.
```ruby
p ((while true; p 1; break; end))
```

should print `1 nil` but was `1`.
2021-07-28 23:08:57 +09:00
Yukihiro "Matz" Matsumoto 9dd3e23fc9 Merge pull request #5518 from jbampton/pre-commit-autoupdate
pre-commit autoupdate
2021-07-28 23:08:10 +09:00
John Bampton cbd54782c6 pre-commit autoupdate
https://pre-commit.com/#pre-commit-autoupdate
2021-07-28 21:21:57 +10:00
Yukihiro "Matz" Matsumoto 1f1dca1746 parse.y: fix an integer cast warning. 2021-07-26 11:46:22 +09:00
Yukihiro "Matz" Matsumoto 984161e6bb parse.y: mrb_int_read() returns mrb_int not unsigned long.
Also, now too big capture group index just gives `nil`, not error.
2021-07-26 11:20:59 +09:00
Yukihiro "Matz" Matsumoto 4803718b14 parse.y: unify redundant functions yywarn() and yywarning(). 2021-07-26 11:12:10 +09:00
Yukihiro "Matz" Matsumoto f6b37ff44d debug.c: small refactoring. 2021-07-26 11:10:20 +09:00
Yukihiro "Matz" Matsumoto b4696c3935 debug.c: remove type cast warnings. 2021-07-26 11:09:42 +09:00
Yukihiro "Matz" Matsumoto 642497fe19 fmt_fp.c: add implicit cast from mrb_float to int8_t. 2021-07-26 10:57:42 +09:00
Yukihiro "Matz" Matsumoto 966aa476d1 vm.c: fix integer type error in mrb_protect_error. 2021-07-26 10:49:12 +09:00
Yukihiro "Matz" Matsumoto 6175db2746 irep.h: operand c should be fit in uint8_t. 2021-07-26 10:47:40 +09:00
Yukihiro "Matz" Matsumoto 22b24d5d76 test/binding.rb: remove a duplicated test. 2021-07-26 10:46:36 +09:00
Yukihiro "Matz" Matsumoto 26340a8818 time.c: fixed a potential buffer overflow in time_zonename. 2021-07-25 16:43:00 +09:00
Yukihiro "Matz" Matsumoto c2c0250063 time.c: fixed time_zonename buffer size bug. 2021-07-25 16:38:37 +09:00
Yukihiro "Matz" Matsumoto 368b75d81b time.c: stop returning LOCAL for the zone name from Time.zone. 2021-07-25 13:07:11 +09:00
Yukihiro "Matz" Matsumoto 2bed2fabae time.c: update the document for Time#usec; close #5515 2021-07-25 13:07:11 +09:00
Yukihiro "Matz" Matsumoto 47eca476e8 pack.c: fixed sign comparison warning. 2021-07-25 13:07:11 +09:00
Yukihiro "Matz" Matsumoto 8de8521cb6 parse.y: replace strtoul() by mrb_int_read(). 2021-07-25 13:07:10 +09:00
Yukihiro "Matz" Matsumoto 5c804cf68f Remove redundant include headers.
- stdlib.h
- stddef.h
- stdint.h
- stdarg.h
- limits.h
- float.h
2021-07-25 13:07:10 +09:00
Yukihiro "Matz" Matsumoto 1f90a39799 Merge pull request #5514 from mruby/dependabot/github_actions/github/super-linter-4.5.1
build(deps): bump github/super-linter from 4.5.0 to 4.5.1
2021-07-24 13:21:08 +09:00
dependabot[bot] 5b3a4b36c7 build(deps): bump github/super-linter from 4.5.0 to 4.5.1
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.5.0 to 4.5.1.
- [Release notes](https://github.com/github/super-linter/releases)
- [Commits](https://github.com/github/super-linter/compare/v4.5.0...v4.5.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-07-23 14:06:33 +00:00
Yukihiro "Matz" Matsumoto 9c43276eb5 codegen.c: fixed a bug in OP_LOADI32 peephole optimization. 2021-07-23 11:20:18 +09:00
Yukihiro "Matz" Matsumoto 598c97ef76 codegen.c: get_int_operand() to support OP_LOADL (int in pool). 2021-07-22 11:49:47 +09:00
Yukihiro "Matz" Matsumoto d0fed63414 codegen.c: add constant folding for unary numeric operators (+, -, ~). 2021-07-22 11:39:52 +09:00
Yukihiro "Matz" Matsumoto 3e9ed1cca2 codegen.c: compare symbol names directly avoiding string conversion. 2021-07-22 11:21:00 +09:00
Yukihiro "Matz" Matsumoto e42f192827 codegen.c: skip -@ call if the argument is a literal integer. 2021-07-21 13:20:34 +09:00
Yukihiro "Matz" Matsumoto 2ef6e94489 codegen.c: move gen_setxv() after new_sym(). 2021-07-21 13:15:27 +09:00
Yukihiro "Matz" Matsumoto 81b384e3fb codegen.c: introduce gen_int() to generate integer instructions. 2021-07-21 13:15:27 +09:00
Yukihiro "Matz" Matsumoto 47fca90069 codegen.c: add peephole optimization for OP_LOADI32 before OP_MOVE. 2021-07-21 08:00:02 +09:00
Yukihiro "Matz" Matsumoto 28bf950e01 codegen.c: add peephole optimization for OP_LOADI16 before OP_MOVE. 2021-07-21 07:54:08 +09:00
Yukihiro "Matz" Matsumoto 275fe8c94b codegen.c: a new function get_int_operand. 2021-07-21 07:52:39 +09:00
Yukihiro "Matz" Matsumoto 5066e2370d codegen.c: negative zero equals to positive zero.
`OP_LOADI Rn -0` should be `OP_LOADI_0`.
2021-07-20 18:24:33 +09:00
Yukihiro "Matz" Matsumoto cdf54f3159 codegen.c: allow OP_EXT before OP_ADDI and OP_SUBI.
This is preparation for integer constant folding.
2021-07-20 11:07:37 +09:00
Yukihiro "Matz" Matsumoto 43f6f765b0 Remove unused prototypes for mrb_proc_merge_lvar(); ref #5511 2021-07-19 07:42:49 +09:00
Yukihiro "Matz" Matsumoto ed2a6a160e Merge pull request #5511 from dearblue/binding.3
Explicit write barrier for binding
2021-07-19 07:40:22 +09:00
Yukihiro "Matz" Matsumoto 71c778dbfc Merge pull request #5510 from dearblue/check-stdint
Output an error if the `INTPTR_MAX` macro is undefined in C++
2021-07-18 14:34:48 +09:00
Yukihiro "Matz" Matsumoto 86f8edca64 Merge pull request #5509 from dearblue/cast-c++
Avoid implicit casting from void pointers for C++
2021-07-17 20:55:18 +09:00
dearblue de4523f793 Explicit write barrier for binding 2021-07-17 20:43:19 +09:00
dearblue dbd249cace Output an error if the INTPTR_MAX macro is undefined in C++
When doing `conf.enable_cxx_abi` and compiling with FreeBSD + clang or MinGW, such as `INTPTR_MAX` constant macro is not defined if `#include <stdint.h>` precedes `#include <mruby.h>`.
Currently I get a warning when I use an undefined macro, but if I don't notice it I get confused in a link error.
It can be expected that the problem will be easier to understand by making a clear error.

Adding `-Werror=undef` as a compiler flag can also result in an error, but this can be a problem if the system header file itself uses undefined macros, for example.
This patch does minimal confirmation only, but has no side effects.
2021-07-17 20:32:38 +09:00
dearblue c8750048be Avoid implicit casting from void pointers for C++ 2021-07-17 20:21:30 +09:00
Yukihiro "Matz" Matsumoto d4e22c2cec codedump.c: update some instructions.
- OP_GETGV
- OP_SETGV
- OP_GETSV
- OP_SETSV
- OP_GETIV
- OP_SETIV
- OP_GETCV
- OP_SETCV
- OP_GETCONST
- OP_SETCONST
- OP_GETMCNST
- OP_SETMCNST
- OP_GETUPVAR
- OP_SETUPVAR
2021-07-17 19:51:25 +09:00
Yukihiro "Matz" Matsumoto 887df090cb codegen.c: optimize variable assignments after OP_MOVE.
- `OP_SETGV`
- `OP_SETIV`
- `OP_SETCV`
- `OP_SETCONST`
2021-07-17 19:51:25 +09:00
Yukihiro "Matz" Matsumoto 4dda97502b codegen.c: optimize OP_SETUPVAR after OP_MOVE. 2021-07-17 19:51:24 +09:00
Yukihiro "Matz" Matsumoto 3401396a16 Merge pull request #5508 from mruby/dependabot/github_actions/github/super-linter-4.5.0
build(deps): bump github/super-linter from 4.4.1 to 4.5.0
2021-07-16 07:57:58 +09:00
Yukihiro "Matz" Matsumoto 70f31d4bb4 codegen.c: add new peephole optimization for OP_MOVE.
If `OP_MOVE` comes after `OP_GETUPVAR`, you can skip move and redirect
the destination register of `OP_GETUPVAR`.
2021-07-16 07:55:25 +09:00
Yukihiro "Matz" Matsumoto 1a3564f2f1 codegen.c: add new peephole optimization for OP_GETUPVAR.
When `OP_GETUPVAR` is generated right after `OP_SETUPVAR`, there is no
need to read the upvar back to the register, e.g.

    3 008 OP_ADDI       R2      1
    3 011 OP_SETUPVAR   R2      1       0
    4 015 OP_GETUPVAR   R2      1       0
    4 019 OP_LOADI_2    R3

`OP_GETUPVAR` at the address `015` is useless. We can skip it like:

    3 008 OP_ADDI       R2      1
    3 011 OP_SETUPVAR   R2      1      0
    4 015 OP_LOADI_2    R3
2021-07-16 07:52:21 +09:00
dependabot[bot] 1284c0615e build(deps): bump github/super-linter from 4.4.1 to 4.5.0
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.4.1 to 4.5.0.
- [Release notes](https://github.com/github/super-linter/releases)
- [Commits](https://github.com/github/super-linter/compare/v4.4.1...v4.5.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-07-15 14:06:05 +00:00
Yukihiro "Matz" Matsumoto d4abbf1b77 test/syntax.rb: add tests for break and redo. 2021-07-15 15:22:23 +09:00
Yukihiro "Matz" Matsumoto b7d75591f3 codegen.c: gen_jmpdst always needs to generate relative address. 2021-07-15 14:08:17 +09:00
Yukihiro "Matz" Matsumoto b8863c69dc Merge pull request #4141 from udzura/add-test-for-attr-nil-guard
Add a testcase of #4137 fix
2021-07-15 07:27:48 +09:00
Yukihiro "Matz" Matsumoto f5eeb76a85 Merge pull request #5507 from mruby/dependabot/github_actions/github/super-linter-4.4.1
build(deps): bump github/super-linter from 4.3.0 to 4.4.1
2021-07-15 07:25:53 +09:00
dependabot[bot] b2f3327ade build(deps): bump github/super-linter from 4.3.0 to 4.4.1
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.3.0 to 4.4.1.
- [Release notes](https://github.com/github/super-linter/releases)
- [Commits](https://github.com/github/super-linter/compare/v4.3.0...v4.4.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-07-14 14:05:53 +00:00
Yukihiro "Matz" Matsumoto 70aee96050 Merge pull request #5506 from mruby/dependabot/github_actions/github/super-linter-4.3.0
build(deps): bump github/super-linter from 4.2.2 to 4.3.0
2021-07-14 08:11:56 +09:00
dependabot[bot] b89678b30d build(deps): bump github/super-linter from 4.2.2 to 4.3.0
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.2.2 to 4.3.0.
- [Release notes](https://github.com/github/super-linter/releases)
- [Commits](https://github.com/github/super-linter/compare/v4.2.2...v4.3.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-07-13 14:06:38 +00:00
Yukihiro "Matz" Matsumoto 0712a5406a load.c: call mrb_top_run() from mrb_load_proc(); fix #5504
So that the function behave consistently with `mrb_load_proc()`.
2021-07-12 08:17:43 +09:00
Yukihiro "Matz" Matsumoto bb94082fa5 TODO.md: update. 2021-07-11 18:16:17 +09:00
Yukihiro "Matz" Matsumoto ce2d7c2e01 numeric.c: self should always be an integer in __coerce_step_counter. 2021-07-10 17:04:57 +09:00
Yukihiro "Matz" Matsumoto be6d559853 Update internal methods not to be listed in backtraces.
- String#__lines
- Array#__ary_eq
- Array#__ary_cmp
- Hash#__delete
- Kernel#__case_eqq
- Integer#__coerce_step_counter
2021-07-10 14:15:43 +09:00
Yukihiro "Matz" Matsumoto ce6319af61 Merge pull request #5503 from ntl/correct-header-files-when-cdump-disabled
Mrbgem gem_init.c: add headers for irep loading when cdump is disabled, but presym is enabled
2021-07-10 07:53:53 +09:00
Yukihiro "Matz" Matsumoto 13c0dc98f7 Merge pull request #5505 from dearblue/stdint
Do not include `stdint.h` before `mruby.h`
2021-07-10 07:42:25 +09:00
dearblue a7e41c74de Do not include stdint.h before mruby.h 2021-07-09 23:20:30 +09:00
Nathan Ladd 6598607fea Mrbgem gem_init.c compilation correction
When `disable_cdump` is declared on a Mrbgem spec, the procedure for
loading MRuby code from the gem's `mrblib` directory is slightly
different; instead of loading the mrblib code as a Proc built from the
compiled irep, the compiled irep is loaded directly. The header files
`mruby.h` and `mruby/proc.h` are needed only when the irep is loaded
directly. They are currently included only when presym is disabled, they
should be included whenever either presym is disabled *or* when
`disable_cdump` is called. The `cdump?` predicate method happens to
return true in either case (presym disabled *or* cdump disabled), so
this change should be safe.
2021-07-09 08:16:12 -05:00
Yukihiro "Matz" Matsumoto 93cce94e06 debug.h: use uint8_t instead of char for BER compressed binary.
A change in `load.c` is left uncommitted.
2021-07-09 21:11:28 +09:00
Yukihiro "Matz" Matsumoto b5039fdb6c debug.h: use uint8_t instead of char for BER compressed binary. 2021-07-09 14:10:48 +09:00
Yukihiro "Matz" Matsumoto 29556a49a0 cdump.c: avoid uninitialized local variable. 2021-07-09 14:10:17 +09:00
Yukihiro "Matz" Matsumoto b5aa08fc9e range.c: avoid implicit conversion from mrb_float to mrb_int. 2021-07-09 09:10:06 +09:00
Yukihiro "Matz" Matsumoto a1ba6cb728 codegen.c: avoid uninitialized local variable. 2021-07-09 09:09:11 +09:00
Yukihiro "Matz" Matsumoto b3fe9da329 range.c: should not include internal __num_to_a in the backtrace. 2021-07-08 10:07:18 +09:00
Yukihiro "Matz" Matsumoto 38c9c5c627 backtrace.c: skip C method without mid set.
That means it's a method not to be included in the backtrace, for
example `raise`.
2021-07-08 10:06:01 +09:00
Yukihiro "Matz" Matsumoto f9303699d1 pack.c: fix integer signedness mixture. 2021-07-08 09:59:14 +09:00
Yukihiro "Matz" Matsumoto 06b1662807 mruby-bin-debugger: remove unused local variables. 2021-07-08 09:58:44 +09:00
Yukihiro "Matz" Matsumoto c572165292 mruby-bin-debugger: support mrb_debug_line_packed_map. 2021-07-08 09:54:11 +09:00
Yukihiro "Matz" Matsumoto f16ea05a17 debug.c: new debug line information format mrb_debug_line_packed_map.
It uses BER number compression of delta of instruction positions and line
numbers. BER compression is a variable length number representation.

* `mrb_debug_line_ary`: array of line numbers represented in `uint16_t`.
  `[lineno, lineno, ...]`

* `mrb_debug_line_flat_map`: array of `mrb_irep_debug_info_line`, which
  is `struct {uint32_t pos; uint16_t lineno}`, for each line.

* `mrb_debug_line_packed_map` [new]: sequence of BER compressed 2
  numbers, `pos_delta, lineno_delta`. Deltas are differences from
  previous values (starting `0`). `line_entry_counts` represents total
  length of a packed map string for this type.
2021-07-08 07:24:12 +09:00
Yukihiro "Matz" Matsumoto fb1d4ff682 mruby-bin-debugger: rename prefix 'mrb_debug_' to mrdb_. 2021-07-08 07:24:12 +09:00
Yukihiro "Matz" Matsumoto 5f61b36a21 Merge pull request #5502 from jbampton/add-docs-yamllint
Add information on yamllint as comments
2021-07-08 07:24:00 +09:00
John Bampton 6b892e652b Add information on yamllint as comments 2021-07-07 23:18:00 +10:00
Yukihiro "Matz" Matsumoto 9079082b88 Merge pull request #5501 from jbampton/update-contributing-guide
Style the CONTRIBUTING guide
2021-07-07 22:05:50 +09:00
John Bampton c9db3ec7c3 Style the CONTRIBUTING guide 2021-07-07 22:26:19 +10:00
Yukihiro "Matz" Matsumoto 17748ecd1a Merge branch 'cremno-mrb_debug_strdup-and-strndup' 2021-07-06 17:02:31 +09:00
Yukihiro "Matz" Matsumoto 7c362ee723 Merge branch 'mrb_debug_strdup-and-strndup' of https://github.com/cremno/mruby into cremno-mrb_debug_strdup-and-strndup 2021-07-06 17:01:37 +09:00
Yukihiro "Matz" Matsumoto 7fa0a704e0 Make LocalJumpError a direct subclass of StandardError.
To be compatible with CRuby.
2021-07-05 11:57:04 +09:00
Yukihiro "Matz" Matsumoto a6657afab9 codegen.c: jump address should be generated by gen_jmpdst(). 2021-07-04 00:08:17 +09:00
Yukihiro "Matz" Matsumoto 39aed39139 ops.h: made terms consistent.
- `Lit` -> `Pool`
- `SEQ` -> `Irep`
2021-07-03 12:06:44 +09:00
Yukihiro "Matz" Matsumoto 2519659100 Update .git-blame-ignore-revs to skip a reformatting commit. 2021-07-03 06:51:35 +09:00
Yukihiro "Matz" Matsumoto 61e8a54086 doc/opcode.md: table reformatted. 2021-07-03 06:42:26 +09:00
Yukihiro "Matz" Matsumoto d9a8981c26 vm.c: OP_DEF to push a symbol to a register.
The code generator no longer need to emit `OP_LOADSYM` after `OP_DEF`.
`doc/opcode.md` is also updated.
2021-07-03 06:40:05 +09:00
Yukihiro "Matz" Matsumoto a624da6fdb vm.c: need to adjust pc for OP_EXT[123]. 2021-07-02 21:57:52 +09:00
Yukihiro "Matz" Matsumoto 040d1799ec error.c: mrb_obj_as_string and mrb_inspect may return non-object (undef). 2021-07-02 14:24:20 +09:00
Yukihiro "Matz" Matsumoto e60ddc431d AUTHORS: update. 2021-07-01 07:35:11 +09:00
Yukihiro "Matz" Matsumoto 99dbcec89c Revert "Remove OP_EXT[123] from operands."
This reverts commit fd10c72319.

I thought it was OK to restrict index value within 1 byte, but in some
cases index value could be 16 bits (2 bytes). I had several ideas to
address the issue, but reverting `fd10c72` is the easiest way. The
biggest reason is `mruby/c` still supports `OP_EXT[123]`, so that they
don't need any additional work.
2021-06-30 22:41:13 +09:00
Yukihiro "Matz" Matsumoto b2b0329d29 string.rb: upto to break when the string length is longer than end. 2021-06-29 16:49:16 +09:00
Yukihiro "Matz" Matsumoto f09eb196da Merge pull request #5497 from dearblue/drop-upper
Drop unnecessary upper procs linked from class/module/def syntax
2021-06-29 09:49:59 +09:00
Yukihiro "Matz" Matsumoto f05f6963f8 Merge pull request #5498 from dearblue/ruby-warns
Avoid warnings with `ruby -cw`
2021-06-29 09:48:32 +09:00
dearblue 2d0b50f6f3 Avoid warnings with ruby -cw
```console
% for rb in `git ls-files '*/mrblib/*.rb' 'mrblib'`; do ruby30 -cw $rb > /dev/null; done
mrbgems/mruby-array-ext/mrblib/array.rb:389: warning: assigned but unused variable - ary
mrbgems/mruby-array-ext/mrblib/array.rb:663: warning: assigned but unused variable - len
mrbgems/mruby-hash-ext/mrblib/hash.rb:119: warning: possibly useless use of a variable in void context
mrbgems/mruby-hash-ext/mrblib/hash.rb:259: warning: assigned but unused variable - keys
mrbgems/mruby-io/mrblib/io.rb:229: warning: literal in condition
mrbgems/mruby-io/mrblib/io.rb:280: warning: literal in condition
mrbgems/mruby-string-ext/mrblib/string.rb:347: warning: assigned but unused variable - len
mrbgems/mruby-toplevel-ext/mrblib/toplevel.rb:2: warning: parentheses after method name is interpreted as an argument list, not a decomposed argument
```
2021-06-28 23:21:47 +09:00
dearblue 59201b5904 Drop unnecessary upper procs linked from class/module/def syntax
It does not need to hold an anonymous proc for constant search.
Also, this change can be expected to cause an anonymous proc to be GC'd.

This is useful for metaprogramming that makes heavy use of the `class`/`module`/`def` syntax in the `class_eval`/`eval` method.

Example:

- code

  ```ruby
  p ObjectSpace.count_objects

  String.class_eval do
    def a
    end
  end

  p ObjectSpace.count_objects

  String.class_eval do
    eval <<~CODE
      def b
      end
    CODE
  end

  p ObjectSpace.count_objects
  ```

- result of building mruby-head (d63c0df6b) with `build_config/default.rb`

  ```
  {:TOTAL=>1024, :FREE=>262, :T_PROC=>495, :T_ENV=>61, ...}
  {:TOTAL=>1024, :FREE=>259, :T_PROC=>497, :T_ENV=>62, ...}
  {:TOTAL=>1024, :FREE=>255, :T_PROC=>500, :T_ENV=>63, ...}
  ```

- result of building mruby with this patch and `build_config/default.rb`

  ```
  {:TOTAL=>1024, :FREE=>264, :T_PROC=>494, :T_ENV=>60, ...}
  {:TOTAL=>1024, :FREE=>262, :T_PROC=>495, :T_ENV=>61, ...}
  {:TOTAL=>1024, :FREE=>261, :T_PROC=>496, :T_ENV=>61, ...}
  ```
2021-06-28 23:04:43 +09:00
Yukihiro "Matz" Matsumoto d63c0df6bc Merge pull request #5493 from dearblue/binding.2
Fixed finding variables from `proc` in `binding.eval` failed
2021-06-28 09:13:54 +09:00
Yukihiro "Matz" Matsumoto e462b42ff0 Merge pull request #5495 from dearblue/eval.2
Fixed finding variables defined in the upper proc failed
2021-06-27 14:32:43 +09:00
dearblue c182903ea0 Fixed finding variables from proc in binding.eval failed
Previously the following code did not produce the expected results:
```ruby
bx = binding
block = bx.eval("a = 1; proc { a }")
bx.eval("a = 2")
p block.call  # Expect 2 but return 1 due to a bug
```

The previous implementation of `Binding#eval` evaluated the code and then merged the top layer variables.
This patch will parse and expand the variable space before making a call to `eval`.
This means that the call to `Binding#eval` will do the parsing twice.

In addition, the following changes will be made:
- Make `mrb_parser_foreach_top_variable()`, `mrb_binding_extract_proc()` and `mrb_binding_extract_env()` functions private global functions.
- Remove the `posthook` argument from `mrb_exec_irep()`.
  The `posthook` argument was introduced to implement the `binding` method.
  This patch is unnecessary because it uses a different implementation method.

ref #5362
fixed #5491
2021-06-26 13:43:36 +09:00
Yukihiro "Matz" Matsumoto 912b2f8df3 Merge pull request #5494 from dearblue/eval.1
Fix memory leak in `Kernel#eval`
2021-06-26 12:17:14 +09:00
dearblue 52b29f41a3 Fixed finding variables defined in the upper proc failed
If no new variable was defined in the `eval` method, the variable was hidden from the nested `eval` method.

```ruby
a = 1
p eval %(b = 2; eval %(a)) # => 1 (good)
p eval %(eval %(a)) # => undefined method 'a' (NoMethodError)
```

This issue has occurred since mruby 3.0.0.
2021-06-26 11:00:32 +09:00
dearblue cf38fc2f9e Fix memory leak in Kernel#eval
The `mrbc_context` remained unreleased when the `mrb_parse_nstring()` function returned `NULL`.
2021-06-26 10:59:39 +09:00
Yukihiro "Matz" Matsumoto 5fc301f07d class.c: call method_added hooks on alias definitions; #2339 2021-06-25 10:10:34 +09:00
Yukihiro "Matz" Matsumoto 888be9611b class.c: call hook methods on method definitions; close #2339
- `Module#method_added`
- `BasicObject#singleton_method_added`
2021-06-24 13:13:59 +09:00
Yukihiro "Matz" Matsumoto f314a5132e Remove unused build configuration file benchmark/build_config_cc.rb. 2021-06-24 13:13:59 +09:00
Yukihiro "Matz" Matsumoto d0e07b5fdb Merge pull request #5492 from jbampton/add-file-contents-sorter-pre-commit
Add official pre-commit file-contents-sorter
2021-06-23 10:54:51 +09:00
John Bampton 7d2a2e10b3 Add official pre-commit file-contents-sorter
Remove unneeded bash script sort-codespell-wordlist.sh

https://github.com/pre-commit/pre-commit-hooks#file-contents-sorter
2021-06-23 10:55:26 +10:00
Yukihiro "Matz" Matsumoto 388bcb15e8 Rename two files for consistency; close #5488
* android_arm64-v8a.rb -> android_arm64_v8a.rb
* no-float.rb -> host-nofloat.rb
2021-06-22 16:36:26 +09:00
Yukihiro "Matz" Matsumoto fc6210763c Merge pull request #5487 from jbampton/lint-markdown
Enable markdownlint rules MD003,MD005,MD007
2021-06-22 13:14:34 +09:00
Yukihiro "Matz" Matsumoto 40ca240c4c Merge pull request #5489 from jbampton/pre-commit-autoupdate
pre-commit autoupdate
2021-06-22 13:13:13 +09:00
John Bampton 34b8dc211d pre-commit autoupdate
https://pre-commit.com/#pre-commit-autoupdate
2021-06-22 13:17:40 +10:00
John Bampton 188e9b6fb0 Enable markdownlint rules MD003,MD005,MD007
Lint Markdown

https://github.com/DavidAnson/markdownlint#rules--aliases
2021-06-22 06:57:03 +10:00
Yukihiro "Matz" Matsumoto 8416e706ba numeric.c: add optional ndigits argument to rounding methods.
- `truncate`
- `floor`
- `ceil`

`round` already takes `ndigits`.
2021-06-21 10:24:55 +09:00
Yukihiro "Matz" Matsumoto e893f805b1 Merge pull request #5486 from dearblue/alloc-castfree
Added `MRB_OBJ_ALLOC()` macro that does not require a cast
2021-06-21 10:24:44 +09:00
dearblue 0c5c04d7c8 Use MRB_VTYPE_FOREACH() in src/object.c 2021-06-20 11:11:37 +09:00
dearblue cc95e346fd Added MRB_OBJ_ALLOC() macro that does not require a cast
The `MRB_OBJ_ALLOC()` macro function returns a pointer of the type corresponding to the constant literal defined in `enum mrb_vtype`.
2021-06-20 11:08:28 +09:00
Yukihiro "Matz" Matsumoto f678620a43 Merge branch 'dearblue-block_given' 2021-06-19 21:19:42 +09:00
Yukihiro "Matz" Matsumoto 1fca58f7ca codegen.c: stop uninitialized warning. 2021-06-19 21:18:27 +09:00
dearblue c40802865a Added MRB_API function to get block arguments info.
- ` mrb_block_given_p()` -- The name comes from CRuby's `rb_block_given_p ()`

At the same time, it applies to `f_instance_eval()` and `f_class_eval()` of `mruby-eval`.
2021-06-19 21:15:02 +09:00
Yukihiro "Matz" Matsumoto 43eddfd4d5 Merge pull request #5484 from jbampton/enable-markdownlint-rule
Enable markdownlint rule MD046 code-block-style
2021-06-19 11:06:03 +09:00
John Bampton 625210f67c Enable markdownlint rule MD046 code-block-style
Fix C Markdown code block style
2021-06-19 08:38:58 +10:00
Yukihiro "Matz" Matsumoto e1637e716a Merge pull request #5434 from jbampton/add-markdownlint-rules-as-comments
Add the rules to the markdownlint config file as comments
2021-06-18 10:55:04 +09:00
Yukihiro "Matz" Matsumoto e812b1ccb3 Merge pull request #5483 from mruby/dependabot/github_actions/actions/upload-artifact-2.2.4
build(deps): bump actions/upload-artifact from 2.2.3 to 2.2.4
2021-06-18 07:26:35 +09:00
dependabot[bot] d3be93129e build(deps): bump actions/upload-artifact from 2.2.3 to 2.2.4
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 2.2.3 to 2.2.4.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v2.2.3...v2.2.4)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-17 14:05:11 +00:00
Yukihiro "Matz" Matsumoto 4fcb5e8e4f variable.c: add skip argument to skip base class in lookup.
`mrb_vm_const_get` function looks up the constant first in the base
class, so that fallback `const_get` need not to search from the base.
2021-06-17 16:53:54 +09:00
Yukihiro "Matz" Matsumoto 63bafca7f5 variable.c: refactor mrb_vm_const_get function. 2021-06-17 16:53:21 +09:00
Yukihiro "Matz" Matsumoto 090356ec3b variable.c: skip prepended module for constant lookup.
```ruby
module M
  FOO = 'm'
end
class A
  FOO = 'a'
  prepend M
end
class B < A
  def foo
    p FOO
  end
end
B.new.foo  # should print `m` not `a`
```
2021-06-17 16:35:39 +09:00
Yukihiro "Matz" Matsumoto 62754a4739 class.c: use MRB_FLAG_TEST() macro. 2021-06-17 16:34:51 +09:00
Yukihiro "Matz" Matsumoto 02aed7af10 Merge pull request #5480 from jbampton/add-more-pre-commit-hooks
Add two more pre-commit hooks
2021-06-17 11:44:21 +09:00
Yukihiro "Matz" Matsumoto dee895ae79 Merge pull request #5482 from jbampton/standardize-backtick-commands
Standardize commands inside backticks
2021-06-17 11:43:07 +09:00
John Bampton d08ea8a92c Standardize commands inside backticks
Remove whitespace
2021-06-17 12:02:21 +10:00
Yukihiro "Matz" Matsumoto 7b0eb1f9b3 Merge pull request #5481 from jbampton/fix-shebang
Fix shebang by removing whitespace
2021-06-17 10:26:47 +09:00
John Bampton 233366a00c Fix shebang by removing whitespace 2021-06-17 10:26:38 +10:00
John Bampton f1aaa5ee2b Add two more pre-commit hooks 2021-06-17 10:13:56 +10:00
John Bampton 96bc39e527 Add the rules to the markdownlint config file as comments
Enable MD011 no-reversed-links - Reversed link syntax
2021-06-17 09:46:52 +10:00
Yukihiro "Matz" Matsumoto a528834df7 Revert "instance_eval for classes and modules should behave as class_eval."
This reverts commit ee3017496b.

I misunderstood something and the new behavior was different from CRuby.
The issue was reported by @dearblue, regarding #5478
2021-06-17 07:54:54 +09:00
Yukihiro "Matz" Matsumoto 7893cbb523 Merge pull request #5444 from jbampton/add-misspell-docs
Add documentation on spell checking with misspell
2021-06-16 09:17:36 +09:00
Yukihiro "Matz" Matsumoto 2341e4f5e5 Merge pull request #5445 from jbampton/add-codespell-pre-commit-hook
Run pre-commit with GitHub Actions
2021-06-16 09:15:07 +09:00
Yukihiro "Matz" Matsumoto 651c234f9c eval.c: implement class_eval with string; close #5478 2021-06-16 09:12:03 +09:00
John Bampton dab5502e8a Run pre-commit with GitHub Actions
Running pre-commit with GitHub Actions now gives us more tests and coverage

Remove duplicate GitHub Actions for merge conflicts and trailing whitespace

Remove duplicate checks for markdownlint and yamllint from the GitHub Super-Linter

Add new custom pre-commit hook running with a shell script to sort alphabetically and uniquify codespell.txt

Add new pre-commit hook to check spelling with codespell

https://github.com/codespell-project/codespell

Fix spelling
2021-06-16 08:34:54 +10:00
Yukihiro "Matz" Matsumoto 7c8a91ff5a numeric.c: restore fmt argument for backward compatibility.
`mrb_float_to_str()` used to take `fmt` argument. We thought no one used
the function, and OK to remove the argument. But at least `mruby-redis`
gem used the function.
2021-06-15 16:19:16 +09:00
Yukihiro "Matz" Matsumoto 50b6fafddf pack.c: support `w' directive (BER integer compression). 2021-06-14 11:20:52 +09:00
Yukihiro "Matz" Matsumoto 1ed01a8d47 pack.c: count should not be negative for directives xX@. 2021-06-13 20:13:50 +09:00
Yukihiro "Matz" Matsumoto bf2b06ced7 pack.c: raise error for unsupported w directive. 2021-06-13 14:21:51 +09:00
Yukihiro "Matz" Matsumoto eaaa9148b5 readint.c: fixed typo. 2021-06-12 16:18:45 +09:00
Yukihiro "Matz" Matsumoto 96ad60b9aa pack.c: support `@' directive (absolute position). 2021-06-12 16:18:45 +09:00
Yukihiro "Matz" Matsumoto 952e7efdd7 pack.c: refactor pack/unpack 'X'. 2021-06-12 16:18:45 +09:00
Yukihiro "Matz" Matsumoto 3ddc57ed6e pack.c: add X directive (back up byte). 2021-06-12 16:18:44 +09:00
Yukihiro "Matz" Matsumoto fb013595ed pack.c: count should be always positive. no check needed. 2021-06-12 16:18:44 +09:00
Yukihiro "Matz" Matsumoto 203495ccea pack.c: fix long/int mixtures. 2021-06-12 16:18:44 +09:00
Yukihiro "Matz" Matsumoto 72ea85c8da pack.c: remove unused arguments from static functions. 2021-06-12 16:18:44 +09:00
Yukihiro "Matz" Matsumoto f764467c19 pack.c: wrong position after count read. 2021-06-12 16:18:43 +09:00
Yukihiro "Matz" Matsumoto 56593764c8 Merge pull request #5476 from dearblue/eval+super
Raise `TypeError` with `super` inside `instance_eval` / `class_eval`
2021-06-12 16:18:35 +09:00
dearblue b45d95fa9e Raise TypeError with super inside instance_eval / class_eval
Commit d0f60182af introduced an exception as a limitation of mruby.

Subsequent CRuby-2.7 has changed its behavior to raise an exception.
ref: https://github.com/ruby/ruby/commit/55b7ba368696033f2e89b77cbcd4a05dec97b139
2021-06-12 16:08:21 +09:00
Yukihiro "Matz" Matsumoto f7777f64e6 codegen.c: refactor readint()
* renamed from redundant `readint_mrb_int()`
* supports only base upto 16
* no base validation (already done in parser)
* no negative read (negate after read)
* overflow detection using `mrb_int_{mul,add}_overflow()`
2021-06-11 16:44:47 +09:00
Yukihiro "Matz" Matsumoto 49af1fca03 readint.c: add new function mrb_int_read.
Difference from `strtoul(3)`:

* reads `mrb_int` based on configuration
* specifies the end of the string
* no sign interpretation
* base 10 only
2021-06-11 15:14:17 +09:00
Yukihiro "Matz" Matsumoto 14a69c6ffd Merge pull request #5475 from mruby/dependabot/github_actions/github/super-linter-4.2.2
build(deps): bump github/super-linter from 4.2.1 to 4.2.2
2021-06-11 15:14:00 +09:00
dependabot[bot] 0271972e0f build(deps): bump github/super-linter from 4.2.1 to 4.2.2
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.2.1 to 4.2.2.
- [Release notes](https://github.com/github/super-linter/releases)
- [Commits](https://github.com/github/super-linter/compare/v4.2.1...v4.2.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-11 05:50:49 +00:00
Yukihiro "Matz" Matsumoto 62f4cc8cd1 sprintf.c: check value range before type casting. 2021-06-10 18:42:51 +09:00
Yukihiro "Matz" Matsumoto df549c12e5 readflt.c: renamed from strtod.c
The file provides `mrb_read_float()` renamed from `vim_strtod()`.
2021-06-10 15:04:35 +09:00
Yukihiro "Matz" Matsumoto f2f6f2179b Merge pull request #5474 from mruby/dependabot/github_actions/github/super-linter-4.2.1
build(deps): bump github/super-linter from 4.2.0 to 4.2.1
2021-06-10 15:04:10 +09:00
dependabot[bot] d46e7c759f build(deps): bump github/super-linter from 4.2.0 to 4.2.1
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.2.0 to 4.2.1.
- [Release notes](https://github.com/github/super-linter/releases)
- [Commits](https://github.com/github/super-linter/compare/v4.2.0...v4.2.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-10 05:55:58 +00:00
Yukihiro "Matz" Matsumoto 82428de5f9 Merge pull request #5473 from mruby/dependabot/github_actions/github/super-linter-4.2.0
build(deps): bump github/super-linter from 4.1.0 to 4.2.0
2021-06-09 17:11:23 +09:00
dependabot[bot] 670fa8607b build(deps): bump github/super-linter from 4.1.0 to 4.2.0
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.1.0 to 4.2.0.
- [Release notes](https://github.com/github/super-linter/releases)
- [Commits](https://github.com/github/super-linter/compare/v4.1.0...v4.2.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-09 06:03:03 +00:00
Yukihiro "Matz" Matsumoto 3acc09ae61 string.c: make mrb_str_len_{inum,dbl}() static. 2021-06-08 17:19:31 +09:00
Yukihiro "Matz" Matsumoto d8ec544564 string.c: remove two unused functions.
* `mrb_cstr_to_inum()`
* `mrb_cstr_to_dbl()`
2021-06-08 17:00:54 +09:00
Yukihiro "Matz" Matsumoto a5f323835e string.c: add base>36 check to String#to_i. 2021-06-08 16:59:57 +09:00
Yukihiro "Matz" Matsumoto 972cc8b5a8 sprintf.c: fix mrb_int and int mixture errors. 2021-06-07 23:26:06 +09:00
Yukihiro "Matz" Matsumoto b10a6fd472 pack.c: fix 'void* to char*` assignment. 2021-06-07 22:42:31 +09:00
Yukihiro "Matz" Matsumoto 32e96a1d4a pack.c: add default to switch statement to silence warnings. 2021-06-07 09:06:37 +09:00
Yukihiro "Matz" Matsumoto 0afa651363 pack.c: support M specifier (quoted-printable). 2021-06-07 09:03:25 +09:00
Yukihiro "Matz" Matsumoto bba044cfc8 test/pack.c: reorganize test suits. 2021-06-07 08:54:54 +09:00
Yukihiro "Matz" Matsumoto cd64ddf372 pack.c: raise exception for unsupported specifiers. 2021-06-07 07:18:17 +09:00
Yukihiro "Matz" Matsumoto e112c46281 pack.c: check overflow before calling pack_x. 2021-06-06 08:01:58 +09:00
Yukihiro "Matz" Matsumoto d518294f20 pack.c: check overflow before reading count. 2021-06-06 08:01:01 +09:00
Yukihiro "Matz" Matsumoto af3e0ddfc0 pack.c: failed to detect overflow when ch is zero in read_tmpl. 2021-06-06 08:00:24 +09:00
Yukihiro "Matz" Matsumoto f01c29b0ec pack.c: hold enum values in enum variables not int. 2021-06-05 20:04:59 +09:00
Yukihiro "Matz" Matsumoto abb288f5cb codedump.c: fix a compiler condition bug with MRB_NO_FLOAT. 2021-06-05 08:09:04 +09:00
Yukihiro "Matz" Matsumoto cb7d351bfb ops.h: fix term consistency. Lit -> Pool. 2021-06-05 08:08:25 +09:00
Yukihiro "Matz" Matsumoto c2d3718b6e Merge branch 'mirichi-test' 2021-06-04 22:26:57 +09:00
mirichi a997e41d17 add block argument test #2144 2021-06-04 22:25:33 +09:00
Yukihiro "Matz" Matsumoto 001fb58698 Merge branch 'test' of https://github.com/mirichi/mruby into mirichi-test 2021-06-04 22:22:16 +09:00
Yukihiro "Matz" Matsumoto 45dd6b140a Merge pull request #5469 from mruby/dependabot/github_actions/github/super-linter-4.1.0
build(deps): bump github/super-linter from 4.0.2 to 4.1.0
2021-06-04 16:41:18 +09:00
dependabot[bot] 8d6f3595c3 build(deps): bump github/super-linter from 4.0.2 to 4.1.0
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.0.2 to 4.1.0.
- [Release notes](https://github.com/github/super-linter/releases)
- [Commits](https://github.com/github/super-linter/compare/v4.0.2...v4.1.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-04 06:54:20 +00:00
Yukihiro "Matz" Matsumoto 01a21085f6 add a few regressions test from #2313
The code was contributed from Carson McDonald (@carsonmcdonald)
2021-06-03 16:47:04 +09:00
Yukihiro "Matz" Matsumoto 9775315240 vm.c: unify JUMP instructions in OP_SEND. 2021-06-02 18:53:22 +09:00
Yukihiro "Matz" Matsumoto 843abc5c7b cdump.c: rename dump_ prefix to cdump for static functions. 2021-06-01 22:21:04 +09:00
Yukihiro "Matz" Matsumoto ff93854c4a cdump.c: separate irep dump in C feature. 2021-06-01 16:47:06 +09:00
Yukihiro "Matz" Matsumoto a41174aa86 Merge pull request #5464 from shuujii/fix-typo-in-lib-mruby-presym.rb
Fix typo in `lib/mruby/presym.rb`
2021-05-31 09:16:34 +09:00
KOBAYASHI Shuji 2a4d340ce4 Fix typo in lib/mruby/presym.rb 2021-05-31 08:25:42 +09:00
Yukihiro "Matz" Matsumoto cf2e78de44 numeric.c: fixed a silly bug related to pointer decrement. 2021-05-31 02:59:33 +09:00
Yukihiro "Matz" Matsumoto be647acd3e sprintf.c: avoid object allocation in integer formatting. 2021-05-30 19:57:56 +09:00
Yukihiro "Matz" Matsumoto 8a4bcc58c9 numeric.c: introduce mrb_int_to_cstr() to dump mrb_int.
* refactor `mrb_integer_to_str()`
* refactor `mrb_str_format()`
2021-05-30 08:15:51 +09:00
Yukihiro "Matz" Matsumoto 60aa2192a8 codegen.c: just raise the exception on broken node for assignments. 2021-05-29 15:46:30 +09:00
Yukihiro "Matz" Matsumoto 8aa15b0096 Merge pull request #5463 from mruby/dependabot/github_actions/actions/cache-2.1.6
build(deps): bump actions/cache from 2.1.5 to 2.1.6
2021-05-28 16:33:09 +09:00
dependabot[bot] fc7a00f12f build(deps): bump actions/cache from 2.1.5 to 2.1.6
Bumps [actions/cache](https://github.com/actions/cache) from 2.1.5 to 2.1.6.
- [Release notes](https://github.com/actions/cache/releases)
- [Commits](https://github.com/actions/cache/compare/v2.1.5...v2.1.6)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-28 06:02:32 +00:00
Yukihiro "Matz" Matsumoto 269470babc kernel.c: avoid recursive VM call in mrb_f_caller. 2021-05-28 07:39:34 +09:00
Yukihiro "Matz" Matsumoto 4e683c20a2 kernel.c: caller should not include the frame for itself. 2021-05-28 07:38:21 +09:00
Yukihiro "Matz" Matsumoto 2a717cf2aa backtrace.c: do not skip frames for C function calls. 2021-05-28 07:36:20 +09:00
Yukihiro "Matz" Matsumoto cefbc21e67 vm.c: skip actual method_missing call unless it's overridden.
So that `mruby -e 'a'` does not print backtrace history, i.e.

```
% mruby -e 'a'
-e:1: undefined method 'a' (NoMethodError)
```

Instead of

```
% mruby -e 'a'
trace (most recent call last):
        [1] -e:1
-e:1: undefined method 'a' (NoMethodError)
```
2021-05-28 07:30:43 +09:00
Yukihiro "Matz" Matsumoto d9c8626bb1 kernel.c: clear mid for raise and method_missing
Method names need not to be printed in backtrace history.
2021-05-27 21:48:26 +09:00
Yukihiro "Matz" Matsumoto cb92f9ce0b backtrace.c: do not print trace line if there's no backtrace history 2021-05-27 21:44:55 +09:00
Yukihiro "Matz" Matsumoto 48b08fecba array.c: unify mrb_ary_ref and mrb_ary_entry
Use only `mrb_ary_entry` hereafter.
2021-05-27 21:43:43 +09:00
Yukihiro "Matz" Matsumoto 9a72869043 array.c: check for negative shift size. 2021-05-27 08:13:49 +09:00
Yukihiro "Matz" Matsumoto c019d8d34d fmt_fp.c: move mruby specific mrb_float_to_str to numeric.c 2021-05-26 17:29:18 +09:00
Yukihiro "Matz" Matsumoto 05cc3a8d99 Merge pull request #5461 from mruby/dependabot/github_actions/github/super-linter-4.0.2
build(deps): bump github/super-linter from 3.17.1 to 4.0.2
2021-05-26 15:09:52 +09:00
dependabot[bot] 705632c99d build(deps): bump github/super-linter from 3.17.1 to 4.0.2
Bumps [github/super-linter](https://github.com/github/super-linter) from 3.17.1 to 4.0.2.
- [Release notes](https://github.com/github/super-linter/releases)
- [Commits](https://github.com/github/super-linter/compare/v3.17.1...v4.0.2)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-26 05:58:37 +00:00
Yukihiro "Matz" Matsumoto 063b49ab8e fmt_fp.c: truncate precision to prevent buffer overflow. 2021-05-25 13:32:29 +09:00
Yukihiro "Matz" Matsumoto afbc199ed3 fmt_fp.c: use constant that depends on mrb_float size. 2021-05-25 13:31:41 +09:00
Yukihiro "Matz" Matsumoto 5ed3a3475e fmt_fp.c: use a const int instead of a macro constant. 2021-05-25 13:30:17 +09:00
Yukihiro "Matz" Matsumoto bf523b71d1 strtod.c: new public domain implementation of strtod; ref #5448
Instead of using copyrighted `strtod`, now use the public domain
implementation of `strtod` by Yasuhiro Matsumoto (@mattn). The function
has been renamed to `mrb_float_read()`; ref #5460 as well.
2021-05-24 12:10:14 +09:00
Yukihiro "Matz" Matsumoto a44ca2e9be fmt_fp.c: exponential may be bigger than 100. 2021-05-24 11:50:30 +09:00
Yukihiro "Matz" Matsumoto d121075e49 class.c: no need to create aliases if both symbols are same. 2021-05-24 11:50:30 +09:00
Yukihiro "Matz" Matsumoto e323cd0c6e class.c: add write barrier for aliases. 2021-05-24 11:50:29 +09:00
Yukihiro "Matz" Matsumoto a3f779c5b6 Merge pull request #5459 from shuujii/fix-typo-in-src-fmt_fp.c
Fix typo in `src/fmt_fp.c` [ci skip]
2021-05-23 00:02:55 +09:00
KOBAYASHI Shuji 6cfe184d39 Fix typo in src/fmt_fp.c [ci skip] 2021-05-22 17:00:14 +09:00
Yukihiro "Matz" Matsumoto b9bde0c918 mruby-sprintf: reduce float digits to avoid test failure.
Too many digits to fit in single precision float numbers, so that tests
fail when `MRB_USE_FLOAT32` defined.
2021-05-22 14:46:37 +09:00
Yukihiro "Matz" Matsumoto 5c7fe225a6 fp_fmt.c: remove mrb_float_to_cstr().
The function was intended to be a utility function for `mruby-sprintf`.
The functionality was integrated into `sprintf.c`.
2021-05-22 14:16:55 +09:00
Yukihiro "Matz" Matsumoto 328563995f fmt_fp.c: replace with public domain float format routine; ref #5448
The original code can be found in `https://github.com/dhylands/format-float`.

Changes:
- support `double`
- support `#` (alt_form) modifier
- small refactoring
2021-05-22 09:35:27 +09:00
Yukihiro "Matz" Matsumoto fa29bb3bb4 fmt_fp.c: remove fmt argument from mrb_float_to_str().
With major refactoring to prepare removing `snprintf(3) calls.
2021-05-21 08:13:38 +09:00
Yukihiro "Matz" Matsumoto beaf365dd4 numeric.h: remove 2 functions from MRB_API
- `mrb_float_to_str()`
- `mrb_float_to_cstr()`

Both functions will be replaced to support new coming `format-float.c`.
2021-05-21 08:13:38 +09:00
Yukihiro "Matz" Matsumoto 03c4e114a9 test/syntax.rb: fix endless def warning (no assertion). 2021-05-21 08:13:37 +09:00
Yukihiro "Matz" Matsumoto f0e1d575f2 sprintf.c: remove specifiers %a and %A.
`fmt_fp.c` does not support those specifiers. In addition, I believe no
one uses hexadecimal representation of float values.
2021-05-21 08:13:37 +09:00
Yukihiro "Matz" Matsumoto 8f73ee2e82 Merge pull request #5456 from shuujii/support-load-64-bit-integer-from-mrb-format-with-MRB_32BIT-and-MRB_INT64
Support load 64-bit integer from mrb format with MRB_32BIT and MRB_INT64
2021-05-21 08:12:54 +09:00
KOBAYASHI Shuji e9e720eab9 Support load 64-bit integer from mrb format with MRB_32BIT and MRB_INT64 2021-05-20 19:39:08 +09:00
Yukihiro "Matz" Matsumoto 07c8470278 parse.y: allow "command" syntax in endless method definition.
This change allows `def hello = puts "Hello"` without parentheses.
This syntax has been introduced since Ruby3.1.
2021-05-18 16:26:36 +09:00
Yukihiro "Matz" Matsumoto d50c83cca7 parse.y: endless singleton method definition can omit parens. 2021-05-18 16:25:53 +09:00
Yukihiro "Matz" Matsumoto 5eebbd7df2 Global renaming regarding integer and float.
Consistent number conversion function names:
* `mrb_value` to immediate (C) value
  * `mrb_int()` -> `mrb_as_int()`
  * `mrb_to_flo()` -> `mrb_as_float()`
* `mrb_value` to `mrb_value` (converted)
  * `mrb_to_int()'
  * `mrb_Integer()` - removed
  * `mrb_Float()` -> `mrb_to_float`

Consistent function name (avoid `_flo` suffix):
* `mrb_div_flo()` -> `mrb_div_float`
2021-05-17 15:07:05 +09:00
Yukihiro "Matz" Matsumoto ea7f1953c3 Rename mrb_fixnum_to_str to mrb_integer_to_str. 2021-05-17 13:59:01 +09:00
Yukihiro "Matz" Matsumoto 080fdbf9e8 Rename mrb_flo_to_fixnum to mrb_float_to_integer. 2021-05-17 13:58:54 +09:00
Yukihiro "Matz" Matsumoto fbbcee835f rational.c: update function prefixes.
To be consistent, functions with `rational_` prefix implements methods,
functions with `rat_` prefix are utility functions.
2021-05-17 13:39:51 +09:00
Yukihiro "Matz" Matsumoto e7db158321 numeric.h: reduce conditional compilation branch on MRB_NO_FLOAT. 2021-05-16 18:21:08 +09:00
Yukihiro "Matz" Matsumoto 361b380eaf AUTHORS: update authors information as of 2021-05-15. 2021-05-15 17:27:23 +09:00
Yukihiro "Matz" Matsumoto ae4c952d2e mruby-array-ext/array.c: implement Array#rotate in C.
The Ruby version of `Array#rotate!` generated a rotated array and
replaced the receiver, but the C version rotates the receiver array
in-place. So the performance is improved a lot both in speed and memory
consumption. Look for the comments in `array.c` for the in-place rotating
algorithm, if you are interested.
2021-05-15 17:26:36 +09:00
Yukihiro "Matz" Matsumoto 9422fdbc87 mruby-array-ext/array.c: implement Array#compact in C. 2021-05-14 10:39:41 +09:00
Yukihiro "Matz" Matsumoto bdb5d85adc array.rb: replace can't with cannot.
To avoid editor coloring failures.
2021-05-14 10:34:11 +09:00
Yukihiro "Matz" Matsumoto 364f275997 range.c: implement (part of) Range#to_a in C.
Mostly for performance reason.
2021-05-14 08:39:14 +09:00
Yukihiro "Matz" Matsumoto 99f0adc3f4 range.c: refactor conditional compilation code.
So that auto indentation works.
2021-05-14 08:28:27 +09:00
Yukihiro "Matz" Matsumoto dfac706ac2 range.c: rename RANGE_INITIALIZED_MASK to RANGE_INITIALIZED_FLAG. 2021-05-14 08:27:21 +09:00
Yukihiro "Matz" Matsumoto 1d0cfb359c Update mrb_bool definition; close #2385
- move `TRUE/FALSE` definition from `mrbconf.h` (not configurable)
- use C/C++ definition of boolean type for `mrb_bool`

The fix is originally written by @take-cheeze.
2021-05-13 19:30:41 +09:00
Yukihiro "Matz" Matsumoto 3a3761ec69 string.c: remove unnecessary branch in the internal method. 2021-05-13 16:08:25 +09:00
Yukihiro "Matz" Matsumoto 5c7aa4f299 Simplify module inclusion for Array, Hash and Range. 2021-05-13 16:07:09 +09:00
Yukihiro "Matz" Matsumoto 2597e5192f Merge pull request #5451 from mruby/dependabot/github_actions/github/super-linter-3.17.1
build(deps): bump github/super-linter from 3.17.0 to 3.17.1
2021-05-13 15:55:34 +09:00
Yukihiro "Matz" Matsumoto 2bed750eb0 range.c: avoid use of mrb_fixnum_p.
`mrb_int` may not fit in `fixnum` (inline integer).
2021-05-13 15:35:34 +09:00
Yukihiro "Matz" Matsumoto 4d6f5be1df mruby-test: MRB_INT_MAX etc. may not fit in Fixnum (inline int). 2021-05-13 15:34:20 +09:00
dependabot[bot] 649600ba9f build(deps): bump github/super-linter from 3.17.0 to 3.17.1
Bumps [github/super-linter](https://github.com/github/super-linter) from 3.17.0 to 3.17.1.
- [Release notes](https://github.com/github/super-linter/releases)
- [Commits](https://github.com/github/super-linter/compare/v3.17.0...v3.17.1)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-13 06:24:44 +00:00
Yukihiro "Matz" Matsumoto 5f9f26f6e6 backtrace.c: stop skipping frame with file/line information.
Instead, copy them from the outer frame as CRuby does.
2021-05-13 08:00:05 +09:00
Yukihiro "Matz" Matsumoto bd04630710 Merge pull request #5450 from mruby/dependabot/github_actions/actions/checkout-2.3.4
build(deps): bump actions/checkout from 2 to 2.3.4
2021-05-12 16:49:02 +09:00
dependabot[bot] 800b534a35 build(deps): bump actions/checkout from 2 to 2.3.4
Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 2.3.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/v2...v2.3.4)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-12 05:53:03 +00:00
Yukihiro "Matz" Matsumoto 032d11de1b range.rb: add Range#entries as an alias to Range#to_a. 2021-05-12 11:09:03 +09:00
Yukihiro "Matz" Matsumoto 955c7f703e array.rb: add Array#entries as an alias to Array#to_a.
The performance of `Enumerable#entries` are significantly slower than
`Array#to_a`.
2021-05-12 07:17:49 +09:00
Yukihiro "Matz" Matsumoto 2a280a8f70 Remove the obsolete term Fixnum.
Except for compatibility code.
2021-05-11 07:36:34 +09:00
Yukihiro "Matz" Matsumoto 23019213b7 doc/limitation.md: update the limitation.
- `puts` behavior changed as CRuby
- fix wrong behavior in re-raising in `rescue`
2021-05-10 17:39:50 +09:00
Yukihiro "Matz" Matsumoto 033aa98cf4 time.c: Windows API provides clock_gettime.
`gettimeofday` emulation needed no longer.
2021-05-08 10:34:38 +09:00
Yukihiro "Matz" Matsumoto f8345dbc44 Add .git-blame-ignore-revs file to ignore whitespace fixes. 2021-05-07 17:28:52 +09:00
Yukihiro "Matz" Matsumoto 6eedb6173b Merge pull request #5447 from dearblue/tab
Extend the tab with 8 whitespace
2021-05-07 17:25:44 +09:00
Yukihiro "Matz" Matsumoto bc620824be Merge pull request #5443 from jbampton/order-editorconfig-properties
Order the EditorConfig properties
2021-05-07 17:25:05 +09:00
Yukihiro "Matz" Matsumoto 4458000404 symbol.c: add Symbol#name method
`Symbol#name` is similar to `#to_s` but returns a frozen string.
2021-05-06 16:45:54 +09:00
Yukihiro "Matz" Matsumoto a93d9d8585 symbol.c: rename sym_name to sym_cstr. 2021-05-06 16:45:27 +09:00
dearblue 6fc5dc986a Extend the tab with 8 whitespace
This work was done as follows:
- check:   `git grep $'\011' -- :^oss-fuzz`
- convert: `ruby -pi -e 'nil while $_.sub!(/^(.*?)\t/) { $1 + " " * (8 - $1.size % 8) }'`

The `doc/guide/{compile,mrbgems}.md` file adds and removes whitespace to make the directory tree look the same.
In `mrbgems/mruby-socket/src/socket.c`, there is a part where the indent is changed from 4 to 2 at the same time as the tab is changed.
2021-05-05 22:16:03 +09:00
Yukihiro "Matz" Matsumoto 1c9260db6b Merge pull request #5446 from mruby/dependabot/github_actions/github/super-linter-v3.17.0
build(deps): bump github/super-linter from v3 to v3.17.0
2021-05-05 19:05:39 +09:00
dependabot[bot] 7460e165dc build(deps): bump github/super-linter from v3 to v3.17.0
Bumps [github/super-linter](https://github.com/github/super-linter) from v3 to v3.17.0.
- [Release notes](https://github.com/github/super-linter/releases)
- [Commits](https://github.com/github/super-linter/compare/v3...28cfebb84fd6dd9e8773b5efe5ac0f8f3714f228)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-05 07:11:09 +00:00
Yukihiro "Matz" Matsumoto 35a6dfe905 Merge pull request #5442 from dearblue/mruby-pack
Fix documents for `mruby-io`
2021-05-05 09:38:45 +09:00
Yukihiro "Matz" Matsumoto b50be31d2b Merge pull request #5441 from dearblue/mruby-sleep
Update gem spec for `mruby-sleep`
2021-05-05 09:38:18 +09:00
John Bampton f4d9a9beec Add documentation on spell checking with misspell 2021-05-04 09:16:22 +10:00
Yukihiro "Matz" Matsumoto b517274921 Merge pull request #5440 from jbampton/fix-whitespace-in-src-symbol-c
Fix whitespace in `src/symbol.c`
2021-05-04 07:59:55 +09:00
John Bampton 1d5d912148 Order the EditorConfig properties 2021-05-04 08:14:12 +10:00
dearblue 8eb5a8867b Fix documents for mruby-io 2021-05-03 23:27:40 +09:00
dearblue eca990b2ec Update gem spec for mruby-sleep
To align the spec like any other core mrbgems:
- Delete `spec.version`
- Set `spec.summary`
2021-05-03 23:17:04 +09:00
John Bampton 356e1740f2 Fix whitespace in src/symbol.c 2021-05-03 21:15:29 +10:00
Yukihiro "Matz" Matsumoto 0c8cd60097 symbol.c: remove id2name reference from documents. 2021-05-03 15:33:39 +09:00
Yukihiro "Matz" Matsumoto ce054bd078 symbol.c: remove Symbol#id2sym.
In the ancient Ruby, symbols are represented by integers. In that era,
to get string representation from integers, we used `Integer#id2sym`
method. Later, `Symbol` was introduced, and `id2sym` was used for
compatibility. Today, no one uses `id2sym` any longer. It is described
in ISO 30170:2012 standard but I consider it as a mistake.
2021-05-03 15:30:59 +09:00
Yukihiro "Matz" Matsumoto 24dcd252f8 Merge pull request #5439 from dearblue/opcode.md
Enclose the table contents of `opcode.md` as code
2021-05-02 20:41:43 +09:00
Yukihiro "Matz" Matsumoto 4626348e47 array.c: mrb_ary_shift_m should be static. 2021-05-02 20:30:41 +09:00
dearblue 3e5ff7543a Enclose the table contents of opcode.md as code 2021-05-02 20:06:16 +09:00
dearblue ce973685d0 Rename mrbgems/mruby-inline-struct with mrbgems/mruby-test-inline-struct
This gem contains only tests.
2021-05-02 18:25:00 +09:00
Yukihiro "Matz" Matsumoto 14c13bb4d2 symbol.c: remove mrb_sym_static_p() function that no one use. 2021-05-02 17:57:34 +09:00
dearblue 66a55fb4df Run the task only once when parse.y is updated
Previously, the task was executed as many times as there were targets, including `mruby-compiler`.

```console
% rm mrbgems/mruby-compiler/core/y.tab.c
% rake `pwd`/mrbgems/mruby-compiler/core/y.tab.c
YACC  mrbgems/mruby-compiler/core/parse.y -> mrbgems/mruby-compiler/core/y.tab.c
YACC  mrbgems/mruby-compiler/core/parse.y -> mrbgems/mruby-compiler/core/y.tab.c
```
2021-05-02 16:52:50 +09:00
Yukihiro "Matz" Matsumoto 8f362eaf8a io.rb,print.rb: puts to expand array arguments.
As CRuby behaves.
2021-05-01 00:00:14 +09:00
Yukihiro "Matz" Matsumoto 519dc3d19c Merge pull request #5432 from shuujii/fix-typo-in-mrbgems-mruby-io-mrblib-io.rb
Fix typo in `mrbgems/mruby-io/mrblib/io.rb`; ref cb55e7eca
2021-04-29 11:17:41 +09:00
KOBAYASHI Shuji a633f0f9f6 Fix typo in mrbgems/mruby-io/mrblib/io.rb; ref cb55e7eca 2021-04-29 09:27:12 +09:00
Yukihiro "Matz" Matsumoto 2ad5d4f53d string.c: add a new method String#center. 2021-04-28 21:44:19 +09:00
Yukihiro "Matz" Matsumoto e5e5acefaf string.{c,rb}: fix type of return values from some methods as Ruby3.0
When the receiver is the instance of subclass of `String`.

- `String#each_char`
- `String#each_line`
- `String#partition`
2021-04-28 21:41:01 +09:00
Yukihiro "Matz" Matsumoto 6666b4fa62 doc/opcode.md: stop reversed link syntax check from markdownlint. 2021-04-28 21:37:06 +09:00
Yukihiro "Matz" Matsumoto cb55e7eca9 io.rb: reimplement IO#each_char.
It used to be an alias to `IO#each_byte` but those methods should have
behave differently.
2021-04-28 21:37:05 +09:00
Yukihiro "Matz" Matsumoto aff3743c12 array.rb: Array#uniq to return always Array.
Even called for subclass of `Array`, according to new Ruby3.0 behavior.
Other methods of `Array` behave as Ruby3.0 from the first hand.
2021-04-28 17:45:19 +09:00
Yukihiro "Matz" Matsumoto 9f77232b71 array.c: update Array#shift to take optional argument; close #5428 2021-04-27 16:37:24 +09:00
Yukihiro "Matz" Matsumoto 2e165b9e20 Merge pull request #5425 from dearblue/exc_to_s
Fix symbol leak in `exc_to_s()`
2021-04-26 23:13:22 +09:00
Yukihiro "Matz" Matsumoto f22535045a mruby.c: specify file names for libraries set by -r; fix #5427 2021-04-26 19:00:49 +09:00
Yukihiro "Matz" Matsumoto 14bd07f831 backtrace.c: skip innermost frame only when the method is in C; #5394 2021-04-26 16:46:44 +09:00
Yukihiro "Matz" Matsumoto b937463706 Merge pull request #5424 from dearblue/new_iseq
Fix annotations for inline iseq of `Class.new` [ci skip]
2021-04-26 14:29:46 +09:00
Yukihiro "Matz" Matsumoto 2ead8a0520 Merge pull request #5423 from dearblue/gc-red
Introduce `MRB_GC_RED`
2021-04-26 07:29:08 +09:00
Yukihiro "Matz" Matsumoto 8cd51578fb build_config/no-float.rb: unify two build configurations; #5421
- stop cross building
- add more gems for tests
- add `bintest`
2021-04-26 07:25:21 +09:00
Yukihiro "Matz" Matsumoto 767577efb1 Merge pull request #5422 from dearblue/binding1
Avoid ill-advised `goto`
2021-04-25 14:36:17 +09:00
dearblue c0cd004b21 Fix symbol leak in exc_to_s() 2021-04-25 10:49:33 +09:00
dearblue 8f66dd278b Fix annotations for inline iseq of Class.new [ci skip] 2021-04-24 21:31:50 +09:00
Yukihiro "Matz" Matsumoto 4d249c28d9 Skip tests that use Float inside; ref #5421 2021-04-24 12:04:08 +09:00
Yukihiro "Matz" Matsumoto f46b4056f8 numeric.c: remove duplicated definitions; #5421
Following functions are defined in `mrblib/numeric.c`:

- `Integer#ceil`
- `Integer#floor`
- `Integer#round`
- `Integer#truncate`
2021-04-24 11:56:50 +09:00
Yukihiro "Matz" Matsumoto 4b4622f711 time.c: fixable_time_t_p is not used with MRB_NO_FLOAT; #5421 2021-04-24 11:38:56 +09:00
Yukihiro "Matz" Matsumoto 237f3339bf random.c: refactoring; #5421
- `Random.rand` with `MRB_NO_FLOAT` behaves as `Random.rand(100)`
- `Random.rand(i)` where `i<0` raises `ArgumentError`
2021-04-24 11:15:53 +09:00
Yukihiro "Matz" Matsumoto 2e49a25740 build_config/nofloat.rb: build configuration with MRB_NO_FLOAT; #5421 2021-04-24 10:54:42 +09:00
dearblue 94c5c8f44c Introduce MRB_GC_RED
Replaces the magic number `7` except in `src/gc.c`.
2021-04-24 10:31:21 +09:00
Yukihiro "Matz" Matsumoto 90a59efbec numeric.c: fix errors from MRB_NO_FLOAT; close #5421 2021-04-24 10:23:40 +09:00
dearblue b18fd23cef Avoid ill-advised goto
ref #5362
2021-04-23 22:54:12 +09:00
Yukihiro "Matz" Matsumoto 39dc7b7901 vm.c: fix errors with MRB_NO_FLOAT; fix #5421 2021-04-23 11:28:17 +09:00
Yukihiro "Matz" Matsumoto dc88a87f9b time.c: time_t may be unsigned on some platforms. 2021-04-23 07:53:17 +09:00
Yukihiro "Matz" Matsumoto 1a82bab1b0 error.h: rename mrb_protect_raw to mrb_protect_error; #5415
- `_raw` does not describe the nature of the function
- the function protect errors during C function execution
2021-04-22 17:01:33 +09:00
Yukihiro "Matz" Matsumoto 91c4ac8d66 numeric.c: update error messages in int_pow; ref #5420 2021-04-21 22:08:07 +09:00
Yukihiro "Matz" Matsumoto 5cf1de5b31 numeric.c: fix int_pow to detect integer overflow; fix #5420 2021-04-21 22:05:52 +09:00
Yukihiro "Matz" Matsumoto 2268405fe6 test/math.rb: 10**30 could cause integer overflow; ref #5420 2021-04-21 22:04:20 +09:00
Yukihiro "Matz" Matsumoto bf11f87599 Merge pull request #5419 from shuujii/remove-unused-struct-in-include-mruby-variable.h
Remove unused struct in `include/mruby/variable.h`
2021-04-20 17:41:26 +09:00
Yukihiro "Matz" Matsumoto bd66115257 Merge pull request #5418 from shuujii/remove-unused--include-in-complex.c-and-rational.c
Remove unused `#include` in `complex.c` and `rational.c`
2021-04-20 17:41:01 +09:00
Yukihiro "Matz" Matsumoto ca744e77c4 Merge pull request #5417 from shuujii/remove-MRB_API-from-mrb_get_backtrace-definition
Remove `MRB_API` from `mrb_get_backtrace` definition
2021-04-20 17:40:33 +09:00
KOBAYASHI Shuji 903fbd767a Remove unused struct in include/mruby/variable.h 2021-04-20 16:53:11 +09:00
KOBAYASHI Shuji c6911c54e5 Remove unused #include in complex.c and rational.c 2021-04-20 16:42:40 +09:00
KOBAYASHI Shuji 0d8b025d9b Remove MRB_API from mrb_get_backtrace definition 2021-04-20 16:07:48 +09:00
Yukihiro "Matz" Matsumoto ff366b65eb Merge pull request #5415 from dearblue/unwind-mrb_protect
Introducing the `mrb_protect_raw()` API function
2021-04-19 22:34:20 +09:00
dearblue 891e852286 Introducing the mrb_protect_raw() API function
The purpose is two-fold:

 1. to be able to specify a pointer directly when user data is used

    When using `mrb_protect()`, it is necessary to allocate objects by `mrb_obj_cptr()` function when using user data.

    Adding `mrb_protect_raw()` will make it simpler to reimplement `mrbgems/mruby-error`.

 2. to correctly unwind callinfo when an exception is raised from a C function defined as a method (the main topic)

    If a method call is made directly under `mrb_protect()` and a C function is called, control is returned from `mrb_protect()` if an exception occurs there.
    In this case, callinfo is not restored, so it is out of sync.
    Moreover, returning to mruby VM (`mrb_vm_exec()` function) in this state will indicate `ci->pc` of C function which is equal to `NULL`, and subsequent `JUMP` will cause `SIGSEGV`.

    Following is an example that actually causes `SIGSEGV`:

    - `crash.c`

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

      static mrb_value
      level1_body(mrb_state *mrb, mrb_value self)
      {
        return mrb_funcall(mrb, self, "level2", 0);
      }

      static mrb_value
      level1(mrb_state *mrb, mrb_value self)
      {
        return mrb_protect(mrb, level1_body, self, NULL);
      }

      static mrb_value
      level2(mrb_state *mrb, mrb_value self)
      {
        mrb_raise(mrb, E_RUNTIME_ERROR, "error!");
        return mrb_nil_value();
      }

      int
      main(int argc, char *argv[])
      {
        mrb_state *mrb = mrb_open();
        mrb_define_method(mrb, mrb->object_class, "level1", level1, MRB_ARGS_NONE());
        mrb_define_method(mrb, mrb->object_class, "level2", level2, MRB_ARGS_NONE());
        mrb_p(mrb, mrb_load_string(mrb, "p level1"));
        mrb_close(mrb);
        return 0;
      }
      ```

    - compile & run

      ```console
      % `bin/mruby-config --cc --cflags --ldflags` crash.c `bin/mruby-config --libs`

      % ./a.out
      zsh: segmentation fault (core dumped)  ./a.out
      ```

    After applying this patch, it will print exception object and exit normally.

The `mrb_protect()`, `mrb_ensure()` and `mrb_rescue_exceptions()` in `mrbgems/mruby-error` have been rewritten using `mrb_protect_raw()`.
2021-04-19 22:11:57 +09:00
Yukihiro "Matz" Matsumoto 9d362f2c27 backtrace.c: remove MRB_API from internal functions.
- `mrb_exc_backtrace` to implement `Exception#backtrace`
- `mrb_get_backtrace` to implement `#caller`
2021-04-19 15:49:51 +09:00
Yukihiro "Matz" Matsumoto 13eba43100 backtrace.c: small refactoring in mrb_exc_backtrace(); ref #5394
- add comment for unpacking
- avoid saving the symbol in a local variable
2021-04-19 15:49:51 +09:00
Yukihiro "Matz" Matsumoto 2275e76262 backtrace.c: pedantic check for empty backtrace; ref #5394 2021-04-19 15:49:50 +09:00
Yukihiro "Matz" Matsumoto 85808e50b0 backtrace.c: should skip first (innermost) frame w/out position; #5394
Otherwise we suffer `(unknown):0:` errors.
2021-04-19 15:49:50 +09:00
Yukihiro "Matz" Matsumoto 049ec9056e time.c: add integer boundary check for year.
On configurations where `sizeof(mrb_int) > sizeof(int)`.
2021-04-19 15:49:50 +09:00
Yukihiro "Matz" Matsumoto 713fb53bbf Merge pull request #5414 from shuujii/mRubyPresym-no-longer-needs-RakeDSL
`MRuby::Presym` no longer needs `Rake::DSL`
2021-04-18 08:24:15 +09:00
Yukihiro "Matz" Matsumoto 737254588b array.rb: add Array#intersect? from Ruby3.0.1. 2021-04-17 17:38:44 +09:00
KOBAYASHI Shuji f0318aca23 MRuby::Presym no longer needs Rake::DSL 2021-04-17 16:42:08 +09:00
John Bampton 9d32d440eb feat(CI): add the GitHub Super Linter
The GitHub Super Linter is a more robust and better supported
tool than the current GitHub Actions we are using.

Running these checks:

ERROR_ON_MISSING_EXEC_BIT: true
VALIDATE_BASH: true
VALIDATE_BASH_EXEC: true
VALIDATE_EDITORCONFIG: true
VALIDATE_MARKDOWN: true
VALIDATE_SHELL_SHFMT: true
VALIDATE_YAML: true

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

Added the GitHub Super Linter badge to the README.

Also updated the pre-commit framework and added
more documentation on pre-commit.

Added one more pre-commit check: check-executables-have-shebangs

Added one extra check for merge conflicts to our
GitHub Actions.

EditorConfig and Markdown linting.

Minor grammar and spelling fixes.

Update linter.yml
2021-04-16 16:37:52 +09:00
Yukihiro "Matz" Matsumoto ac9038121b Merge pull request #5413 from shuujii/fix-enable_debug_info-in-mrbgems-mruby-proc-ext-test-proc.rb
Fix `enable_debug_info?` in `mrbgems/mruby-proc-ext/test/proc.rb`
2021-04-15 16:55:43 +09:00
KOBAYASHI Shuji 35b2798a5d Fix enable_debug_info? in mrbgems/mruby-proc-ext/test/proc.rb 2021-04-15 15:49:23 +09:00
Yukihiro "Matz" Matsumoto 3c5467af63 Merge pull request #5411 from artichoke/mrb_protect_atexit_prototype_mismatch
Fix incorrect prototype on declaration of mrb_protect_atexit
2021-04-14 07:27:12 +09:00
Yukihiro "Matz" Matsumoto 5a8f0bdaf2 Merge pull request #5410 from mruby/dependabot/github_actions/actions/cache-v2.1.5
build(deps): bump actions/cache from v2.1.4 to v2.1.5
2021-04-14 07:25:07 +09:00
Ryan Lopopolo 7fe6f3976e Fix incorrect prototype on declaration of mrb_protect_atexit
`state.c` makes a prototype declaration for the private
`mrb_protect_atexit` which is defined in `error.c`. `error.c` defines
this function with a void return type, but `state.c` defines the
prototype with an `int` return type.

This mismatch prevents mruby from compiling on stricter compilers like
emscripten.
2021-04-13 07:57:09 -07:00
dependabot[bot] 99bd84e76b build(deps): bump actions/cache from v2.1.4 to v2.1.5
Bumps [actions/cache](https://github.com/actions/cache) from v2.1.4 to v2.1.5.
- [Release notes](https://github.com/actions/cache/releases)
- [Commits](https://github.com/actions/cache/compare/v2.1.4...1a9e2138d905efd099035b49d8b7a3888c653ca8)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-13 07:16:35 +00:00
Yukihiro "Matz" Matsumoto 1a3846b492 mrbgem.rake: avoid implicit receivers in mrbgem.rake. 2021-04-13 07:35:39 +09:00
Yukihiro "Matz" Matsumoto dd89a618b3 mruby-io: fix IO#ungetbyte; ref #5389
- remove `Integer#chr` (thus `mruby-sting-ext`) dependency
- fix the behavior when `c.is_a? String`
- fix the behavior when `c > 255`
2021-04-13 07:24:56 +09:00
Yukihiro "Matz" Matsumoto 9a9c842cb0 Rakefile: remove GitLab configuration; close #5409
This CI could consume too much CPU time on GitLab. Maybe we should add
resource concious CI configuration on GitLab.
2021-04-13 07:16:21 +09:00
Yukihiro "Matz" Matsumoto 475fc6ed26 AUTHORS: update authors information as of 2021-04-12. 2021-04-12 19:04:57 +09:00
Yukihiro "Matz" Matsumoto ff2ffe3b07 proc.h: add type cast to silence warning; ref #5402 2021-04-12 15:21:54 +09:00
Yukihiro "Matz" Matsumoto 2cb9a0653a Merge branch 'io_getbyte' close #5389 2021-04-10 19:08:51 +09:00
Yukihiro "Matz" Matsumoto 5cac9c8478 io.rb: fix IO#getbyte to work with UTF-8 characters; ref #5389 2021-04-10 19:08:15 +09:00
Yukihiro "Matz" Matsumoto 8fa1ff9a03 io.rb: add IO#readbyte; ref #5389 2021-04-10 19:08:15 +09:00
Yukihiro "Matz" Matsumoto 167e0b3f4f io.c: add assertions to mrb_io_bufread(); ref #5389 2021-04-10 19:08:14 +09:00
Yukihiro "Matz" Matsumoto 5342b5cfef io.rb: @buf should be empty on EOF; #4983, #5389 2021-04-10 19:08:14 +09:00
take-cheeze bf455fd582 Add IO#getbyte 2021-04-10 19:08:14 +09:00
Yukihiro "Matz" Matsumoto 44d5e214cc Rename some internal functions; ref #5401 2021-04-10 17:33:50 +09:00
Yukihiro "Matz" Matsumoto f7493b73cb Merge pull request #5400 from jbampton/fix-spelling
chore: fix spelling
2021-04-09 22:07:50 +09:00
Yukihiro "Matz" Matsumoto c2c37e1451 Merge pull request #5401 from dearblue/mcall
Reorganize `mcall()` in `mruby-method`
2021-04-09 21:46:09 +09:00
Yukihiro "Matz" Matsumoto 6d3c022749 mruby-config.bat: update as the shell version. [ci skip] 2021-04-08 07:32:35 +09:00
Yukihiro "Matz" Matsumoto cbe061c2f4 codeql-analysis.yml: remove git checkout HEAD^2.
According to CodeQL instruction, `HEAD^2` is no longer needed.
2021-04-08 07:32:34 +09:00
Yukihiro "Matz" Matsumoto 77405e11b6 Merge pull request #5407 from mruby/dependabot/github_actions/actions/upload-artifact-v2.2.3
build(deps): bump actions/upload-artifact from v2.2.2 to v2.2.3
2021-04-07 16:22:08 +09:00
dependabot[bot] 2544e7f0d1 build(deps): bump actions/upload-artifact from v2.2.2 to v2.2.3
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from v2.2.2 to v2.2.3.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v2.2.2...ee69f02b3dfdecd58bb31b4d133da38ba6fe3700)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-07 07:12:15 +00:00
Yukihiro "Matz" Matsumoto fa2ad34792 Removing trailing white spaces; ref #5406 [ci skip] 2021-04-07 11:02:47 +09:00
Yukihiro "Matz" Matsumoto 32ae96af1f Merge pull request #5406 from sizious/dreamcast-shelf-build-config-update
Updating dreamcast_shelf build configuration.
2021-04-07 11:00:51 +09:00
SiZiOUS 03f7e88ee9 dreamcast_shelf: typo fix. 2021-04-06 20:49:03 +02:00
SiZiOUS 7ad2827900 Updating dreamcast_shelf build configuration. 2021-04-06 17:30:02 +02:00
Yukihiro "Matz" Matsumoto 71bf362a5b doc/link.md: update mruby-config description. 2021-04-06 17:25:54 +09:00
Yukihiro "Matz" Matsumoto 58ab97e300 mruby-config: add --cc and --ld options.
* `--cc` print compiler name
* `--ld` print linker name
2021-04-06 17:25:53 +09:00
Yukihiro "Matz" Matsumoto e19346fd8b Merge pull request #5405 from shuujii/fix-heading-level-in-doc-guides-link.md
Fix heading level in `doc/guides/link.md` [ci skip]
2021-04-06 13:14:34 +09:00
Yukihiro "Matz" Matsumoto 339216b5ec Merge pull request #5404 from shuujii/fix-typo-in-doc-guides-link.md
Fix typo in `doc/guides/link.md` [ci skip]
2021-04-06 12:52:14 +09:00
KOBAYASHI Shuji 6844ef7131 Fix heading level in doc/guides/link.md [ci skip] 2021-04-06 12:52:07 +09:00
KOBAYASHI Shuji 516756d538 Fix typo in doc/guides/link.md [ci skip] 2021-04-06 12:44:58 +09:00
Yukihiro "Matz" Matsumoto 1f03d34fd7 link.md: add new document for linking libmruby; ref #5393 2021-04-05 22:26:15 +09:00
Yukihiro "Matz" Matsumoto 27d3747faa Merge pull request #5402 from dearblue/catch1
Making a proc object static for a method with static irep
2021-04-04 17:56:25 +09:00
dearblue caeacea86e Making a proc object static for a method with static irep
The following methods will be made static.

  - `Class#new`
  - `Proc#call`
  - `Kernel#catch`

Previously, static const RProc could not be registered as a method, but this has been changed to allow it.
2021-04-04 15:44:19 +09:00
dearblue 4c196dcdaa Reorganize mcall() in mruby-method.
Use `mrb_exec_irep()`. If possible, re-entry into the VM will be suppressed.

Note that due to the effect of being a tail-call, the backtrace of `Method#call` will be lost, and it will look as if the target method was called directly.

This change fixes the problem of infinite loops when redefining methods that make block calls using `mruby-method`.

```console
% bin/mruby -e 'mm = method(:proc); define_method(:proc, ->(*a, &b) { mm.call(*a, &b) }); p proc { 1 }'
trace (most recent call last):
        [257] -e:1
        [256] -e:1:in proc
        [255] -e:1:in proc
        ...SNIP...
        [1] -e:1:in proc
-e:1:in proc: stack level too deep (SystemStackError)
```
2021-04-03 21:20:59 +09:00
dearblue dd34ac647f Make mrb_exec_irep() allow non-VM to enter.
Change the old `mrb_exec_irep()` as-is to static `mrb_exec_irep_vm()`.
Extract the VM entry part from the old `exec_irep()` in `mruby-eval/src/eval.c` and make it the core of the new `mrb_exec_irep()`.
2021-04-03 21:17:48 +09:00
John Bampton d8622fc68b chore: fix spelling 2021-04-03 19:51:01 +10:00
Yukihiro "Matz" Matsumoto fb8e12f37c Merge pull request #5397 from dearblue/c++dump
Fix build failures with `enable_debug` and `enable_cxx_abi`
2021-04-03 18:44:17 +09:00
Yukihiro "Matz" Matsumoto 474ec3e5c6 Merge pull request #5398 from jbampton/fix-authors-link
Fix the Authors link in the README
2021-04-03 17:58:30 +09:00
Yukihiro "Matz" Matsumoto 7561bed32a Merge pull request #5399 from jbampton/fix-spelling
chore: fix spelling
2021-04-03 17:57:08 +09:00
John Bampton ce2b8aa05e chore: fix spelling 2021-04-03 18:14:25 +10:00
John Bampton 049c1d0a45 Fix the Authors link in the README 2021-04-03 17:43:04 +10:00
dearblue 3e48f4eebc Fix build failures with enable_debug and enable_cxx_abi
Under C++, there is no implicit conversion from `int` to `enum`, which caused a compilation error.
2021-04-03 16:22:40 +09:00
Yukihiro "Matz" Matsumoto aca59de88e Merge branch 'shuujii-define-MRB_NO_GEMS-if-disable_libmruby-is-specified' 2021-04-02 07:55:43 +09:00
Yukihiro "Matz" Matsumoto ade9368510 Merge branch 'define-MRB_NO_GEMS-if-disable_libmruby-is-specified' of https://github.com/shuujii/mruby into shuujii-define-MRB_NO_GEMS-if-disable_libmruby-is-specified 2021-04-02 07:53:27 +09:00
Yukihiro "Matz" Matsumoto f68c0d092c Merge pull request #5396 from shuujii/fix-build-with-MRB_USE_ALL_SYMBOLS
Fix build with `MRB_USE_ALL_SYMBOLS`
2021-04-02 07:44:14 +09:00
Yukihiro "Matz" Matsumoto bda242a135 vm.c: change the default error message for undefined super method.
- (old) `undefined method 'foo'`
- (new) `no superclass method 'foo'`
2021-04-01 08:42:30 +09:00
KOBAYASHI Shuji 4309a5b1f4 Fix build with MRB_USE_ALL_SYMBOLS 2021-03-31 19:10:39 +09:00
Yukihiro "Matz" Matsumoto d5a4d5e393 codegen.c: s->ainfo should be zero along with OP_ENTER(0). 2021-03-31 17:20:14 +09:00
Yukihiro "Matz" Matsumoto 9f85c5e483 codegen.c: yield outside of method is now SyntaxError. 2021-03-31 15:57:43 +09:00
Yukihiro "Matz" Matsumoto a7ca5a9b6e backtrace.c: change missing-lineno to 0 for cosmetic reason; #5394 2021-03-31 15:41:19 +09:00
Yukihiro "Matz" Matsumoto f2da051367 Merge pull request #5394 from fundamental/partial-backtrace
Add support for partial backtraces
2021-03-31 15:39:47 +09:00
Yukihiro "Matz" Matsumoto b7c23a4a14 vm.c: resolve int and mrb_int mixture. 2021-03-31 11:46:21 +09:00
Yukihiro "Matz" Matsumoto 9038a1ca40 rational.c: add explicit cast from mrb_int to mrb_float. 2021-03-31 11:39:59 +09:00
Yukihiro "Matz" Matsumoto 590c1073fc should have removed codegen error: prefix from the test. 2021-03-31 11:35:56 +09:00
Yukihiro "Matz" Matsumoto cb8dabeb8c codegen.c: remove codegen error: prefix from error messages. 2021-03-31 10:48:18 +09:00
Yukihiro "Matz" Matsumoto 4428ce6050 codegen.c: ainfo may be negative.
When argument information is not available. So it should not happen for
`yield` (error). In contrast, the error from `super` should be handled
in run time (ignored).
2021-03-31 10:48:17 +09:00
Yukihiro "Matz" Matsumoto 87f113e19d Merge pull request #5395 from fundamental/mrbc-debug-cstruct
mrbc: Dump debug info with -g option
2021-03-31 10:48:01 +09:00
fundamental c146e81c4a Disable tests on backtraces w/ unknown line numbers 2021-03-30 20:26:10 -04:00
fundamental 5266f76346 mrbc: Dump debug info with -g option
Adds debug source information (line/file) when mrbc uses -g.
This commit results in usable backtraces for all gems when build_config
is setup with enable_debug.
2021-03-30 19:26:12 -04:00
fundamental 49f0da6821 Add support for partial backtraces
When debug information is omitted within ireps, show that a stack
frame existed rather than silently hiding it.
2021-03-30 19:16:15 -04:00
Yukihiro "Matz" Matsumoto a963e29b67 src/vm.c: calling C function may raise global jumps; fix #5391 2021-03-29 17:28:32 +09:00
Yukihiro "Matz" Matsumoto 3c2186f050 Merge pull request #5392 from mruby/revert-5391-throw
Revert "Fix `SIGSEGV` with mruby-method + mruby-catch"
2021-03-29 17:27:17 +09:00
Yukihiro "Matz" Matsumoto 4d3a1198f8 Revert "Fix SIGSEGV with mruby-method + mruby-catch" 2021-03-29 17:26:42 +09:00
Yukihiro "Matz" Matsumoto 76e4de7486 Merge pull request #5391 from dearblue/throw
Fix `SIGSEGV` with mruby-method + mruby-catch
2021-03-29 17:11:21 +09:00
Yukihiro "Matz" Matsumoto a5244b02c5 numeric.c: function renaming.
- `mrb_num_div_int(mrb,x,y)` -> `mrb_div_int(mrb,x,y)`
- `mrb_num_div_flo(mrb,x,y)` -> `mrb_div_flo(x,y)`

They are internal function not supposed to be used outside of the core.
2021-03-28 08:35:29 +09:00
dearblue 6c097c7113 Fix SIGSEGV with mruby-method + mruby-catch
Previously, the following code would cause a `SIGSEGV`.

```ruby
mm = method(:throw)
define_method(:throw, ->(*args) { mm.call(*args) })
catch { |tag| throw tag }
```

I think the reason is in the `mrb_yield_with_class()` function:
- Even if a C function is called, `CI_ACC_SKIP` is used
- `cipop()` is not done if globally jumping from a C function
2021-03-27 17:35:02 +09:00
Yukihiro "Matz" Matsumoto c2f929ad0f Move default Integer#/ from rational.c to complex.c. 2021-03-27 12:38:16 +09:00
Yukihiro "Matz" Matsumoto 01a8edea35 complex.rb: add test for arithmetic operators. [ci skip]
Tests for (`Float` or `Integer`) `op` `Complex`. Also added test
dependency to `mruby-rational` since `int_div` definition relies on
`Rational` when `MRB_USE_RATIONAL` is defined.
2021-03-26 17:20:25 +09:00
Yukihiro "Matz" Matsumoto 9492e389b8 rational.rb: add test for arithmetic operators.
Tests for (`Float` or `Integer`) `op` `Rational`.
2021-03-26 07:37:50 +09:00
Yukihiro "Matz" Matsumoto 6d89047637 rational.c: fix wrong funcall method in rational_mul. 2021-03-25 22:31:32 +09:00
Yukihiro "Matz" Matsumoto 0aff83dcdc rational.c: inline mrb_rational_eq().
It removes non-static function, so that strictly saying, it's
an incompatible change. But the function was added recently and I am
sure no one uses it yet.
2021-03-25 08:28:41 +09:00
Yukihiro "Matz" Matsumoto 4a0c14e3bd rational.c: implement Rational#<=> in C. 2021-03-24 19:49:20 +09:00
Yukihiro "Matz" Matsumoto 3a2075343c rational.c: implement Rational#/ and #quo in C. 2021-03-24 19:21:38 +09:00
Yukihiro "Matz" Matsumoto f05f6f4d11 rational.c: implement Rational#* in C. 2021-03-24 19:11:02 +09:00
Yukihiro "Matz" Matsumoto 9d058342a5 rational.c: implement Rational#- in C. 2021-03-24 19:01:58 +09:00
Yukihiro "Matz" Matsumoto 7a35b64251 fixup! rational.c: prepare utility function rat_to_flo(). 2021-03-24 19:01:38 +09:00
Yukihiro "Matz" Matsumoto ac4fe26fbb rational.c: prepare utility function rat_to_flo().
This function takes `struct mrb_rational*` and returns converted
`mrb_float` value.
2021-03-24 18:59:35 +09:00
Yukihiro "Matz" Matsumoto 7ca7bee9b3 rational.c: implement Rational#+ in C. 2021-03-24 13:57:49 +09:00
Yukihiro "Matz" Matsumoto 5a4958af26 complex.c: use mrb_num_div_flo to avoid copying function.
This change relies that `mrb_num_div_flo` does not use `mrb` inside.
2021-03-24 13:56:08 +09:00
Yukihiro "Matz" Matsumoto 092bba64e7 rational.c: check integer overflow in rational_minus. 2021-03-24 13:28:01 +09:00
Yukihiro "Matz" Matsumoto 49f75703cc complex.rb: unary plus (+@) to return self avoiding copying. 2021-03-24 11:06:48 +09:00
Yukihiro "Matz" Matsumoto 9ed212ef9e complex.c: implement Complex addition and subtraction in C. 2021-03-24 11:06:14 +09:00
Yukihiro "Matz" Matsumoto fa3ac351ff complex.c: override float division to support Complex. 2021-03-24 11:04:58 +09:00
Yukihiro "Matz" Matsumoto afb3c00e8c Use div_flo (copy of mrb_num_div_flo) for float division. 2021-03-24 10:56:01 +09:00
Yukihiro "Matz" Matsumoto ec456e5b18 Use mrb_num_div_flo for float division.
This function handles zero division properly. Also fixed bugs that multiply
numbers instead of division.
2021-03-24 10:54:24 +09:00
Yukihiro "Matz" Matsumoto 98799aa6b8 Fix infinite recursive call bugs in integer division. 2021-03-24 10:52:31 +09:00
Yukihiro "Matz" Matsumoto 3deb62d653 complex.c: implement Complex#/ and #quo in C. 2021-03-24 10:27:49 +09:00
Yukihiro "Matz" Matsumoto 5573707d7f complex.c: implement Complex#* in C. 2021-03-24 09:53:39 +09:00
Yukihiro "Matz" Matsumoto dc5d74dda8 rational.rb: avoid 'NaNi` representation.
Use `NaN*i` as CRuby does.
2021-03-24 09:52:15 +09:00
Yukihiro "Matz" Matsumoto 6e1a13360f Add `timeout-minutes' to GitHub workflow. [ci skip] 2021-03-23 15:02:48 +09:00
Yukihiro "Matz" Matsumoto 30576bf3c6 Merge pull request #5387 from shuujii/use-global-defines-for-mruby-bin-debugger
Use global defines for `mruby-bin-debugger`
2021-03-22 12:43:58 +09:00
Yukihiro "Matz" Matsumoto 2e87d83d8d Merge pull request #5388 from shuujii/reorganize-types-for-ObjectSpace.count_objects
Reorganize types for `ObjectSpace.count_objects`
2021-03-22 12:43:13 +09:00
Yukihiro "Matz" Matsumoto 7479ae307b nintendo_switch.rb: remove trailing white spaces; #5386 2021-03-22 12:39:48 +09:00
KOBAYASHI Shuji c0fb675526 Reorganize types for ObjectSpace.count_objects
#### Addition

- T_COMPLEX
- T_RATIONAL

#### Deletion

- T_FALSE
- T_FREE
- T_TRUE
- T_SYMBOL
- T_UNDEF
2021-03-22 12:24:42 +09:00
Yukihiro "Matz" Matsumoto dc6e7d5414 Merge pull request #5386 from LanzaSchneider/master
Add example for cross-compiling to Nintendo Switch
2021-03-22 12:06:59 +09:00
Yukihiro "Matz" Matsumoto cd047b2989 Merge pull request #5385 from shuujii/add-configuration-for-MinGW-cross-compilation
Add configuration for MinGW cross compilation [ci skip]
2021-03-22 12:05:03 +09:00
KOBAYASHI Shuji 00a13e22dd Use global defines for mruby-bin-debugger 2021-03-22 12:02:26 +09:00
Yukihiro "Matz" Matsumoto 68cf8346cd Use global defines for Rational and Complex. 2021-03-22 10:59:35 +09:00
Yukihiro "Matz" Matsumoto 384865997d build: provide global defines by build.defines. 2021-03-22 10:58:47 +09:00
Yukihiro "Matz" Matsumoto fbc629c56f codegen.c: fix integer size warnings.
along with repeated calls of `strlen()`.
2021-03-22 10:57:36 +09:00
Lanza ad09c39514 Add example for cross-compiling to Nintendo Switch
Cross Compiling configuration for the Nintendo Switch, it requires Nintendo SDK
2021-03-21 16:58:42 +08:00
KOBAYASHI Shuji b2c3ab8f3f Add configuration for MinGW cross compilation [ci skip]
With this cross compiler configuration, all tests for full-core gembox on
Windows on GitHub Actions were successful.
2021-03-21 16:43:04 +09:00
Yukihiro "Matz" Matsumoto 5764ff0740 command.rb: replace %w() to plain []. 2021-03-21 13:23:35 +09:00
Yukihiro "Matz" Matsumoto 73056aeb2b complex.c: define Complex#== in C.
This change also fixes the error caused by `rational.c` that calls
`mrb_complex_eq()`, which had been undefined.
2021-03-21 08:30:52 +09:00
Yukihiro "Matz" Matsumoto a6d4477a09 memsize.c: handle MRB_TT_RATIONAL and MRB_TT_COMPLEX. 2021-03-21 08:29:05 +09:00
Yukihiro "Matz" Matsumoto e21f293de5 rational.c: fix MRB_TT_RATIONAL and MRB_TT_COMPLEX confusion. 2021-03-20 18:03:11 +09:00
Yukihiro "Matz" Matsumoto 98821d2725 random.c: fixed seed underflow bug.
`MRB_INT_MIN` does not have a corresponding positive value.
2021-03-20 14:40:54 +09:00
Yukihiro "Matz" Matsumoto d3184e4a6d complex.c: overhaul complex operators.
- define `MRB_TT_COMPLEX`
- change object structure (`struct RComplex`)
- add memory management for `MRB_TT_COMPLEX`
- avoid operator overloading as much as possible
- as a result, performance improved a log
- should work with and without `Rational` defined
2021-03-19 10:37:10 +09:00
Yukihiro "Matz" Matsumoto 08f9d5bab5 rational.c: overhaul rational operators.
- define `MRB_TT_RATIONAL`
- change object structure (`struct RRational`)
- add memory management for `MRB_TT_RATIONAL`
- avoid operator overloading as much as possible
- implement division overloading in C
- as a result, performance improved a lot
2021-03-19 10:37:10 +09:00
Yukihiro "Matz" Matsumoto eb07030308 numeric.c: avoid integer overflow; close #5384
Since `mruby` does not have `Bignum`, `Float#divmod` could overflow, so
it will return `Float` values when the divided value does not fit in
`mrb_int`. This behavior will be changed when `Bignum` is introduced to
`mruby` in the future.
2021-03-19 07:15:05 +09:00
Yukihiro "Matz" Matsumoto 087e1719e4 Float#divmod with zero should cause ZeroDivisionError; #5384 2021-03-19 07:13:19 +09:00
Yukihiro "Matz" Matsumoto 0d96c1bb40 Merge branch 'dearblue-break-in-conf' 2021-03-18 22:48:11 +09:00
Yukihiro "Matz" Matsumoto 0e4f438eca lib/mruby/build.rb: refactoring ensure clause; ref #5381 2021-03-18 22:47:00 +09:00
Yukihiro "Matz" Matsumoto 99f00de040 Merge branch 'break-in-conf' of https://github.com/dearblue/mruby into dearblue-break-in-conf 2021-03-18 22:34:31 +09:00
Yukihiro "Matz" Matsumoto e5a3a37ae9 Merge pull request #5383 from shuujii/floatNAN-0-should-be-FloatNAN
`Float::NAN/0` should be `Float::NAN`; ref a0b3378b3
2021-03-18 20:54:56 +09:00
KOBAYASHI Shuji 6731f935cc Float::NAN/0 should be Float::NAN; ref a0b3378b3
#### Before this patch:

```console
$ bin/mruby -e 'p(Float::NAN/0)'
Infinity
```

#### After this patch (same as Ruby):

```console
$ bin/mruby -e 'p(Float::NAN/0)'
NaN
```
2021-03-18 17:10:51 +09:00
Yukihiro "Matz" Matsumoto a0b3378b36 numeric.c: float zero division should be infinity with sign kept; fix #5382 2021-03-18 15:24:31 +09:00
dearblue 199bbd73a3 Allow break in build_config.
If I break out of a block given to `MRuby::Build.new` with `break` or `throw`, I will get a seemingly inexplicable error because the `presym`-related initialization is not done.

```console
% cat build_config1.rb
MRuby::Build.new do
  toolchain
  break
end

% rake CONFIG=build_config1.rb
rake aborted!
external mrbc or mruby-bin-mrbc gem in current('host') or 'host' build is required
/var/tmp/mruby/lib/mruby/build.rb:332:in `mrbcfile'
/var/tmp/mruby/tasks/mrblib.rake:9:in `block in <top (required)>'
/var/tmp/mruby/lib/mruby/build.rb:18:in `instance_eval'
/var/tmp/mruby/lib/mruby/build.rb:18:in `block in each_target'
/var/tmp/mruby/lib/mruby/build.rb:17:in `each'
/var/tmp/mruby/lib/mruby/build.rb:17:in `each_target'
/var/tmp/mruby/tasks/mrblib.rake:1:in `<top (required)>'
/var/tmp/mruby/Rakefile:27:in `load'
/var/tmp/mruby/Rakefile:27:in `<top (required)>'
(See full trace by running task with --trace)
```

If a non-exceptional global jump occurs, it can be initialized by `ensure` to solve this problem.
2021-03-17 23:01:52 +09:00
Yukihiro "Matz" Matsumoto c0d63ea09f hash.c: Hash#shift to return nil when a hash is empty.
It used to be return the default value if available, but it should
ignore the default value for behavior consistency. CRuby will adopt
this behavior too in the future. [ruby-bugs:16908]
2021-03-17 15:14:23 +09:00
Yukihiro "Matz" Matsumoto 75ae3d3e23 range.c: fixed a begin-less ranges issue. 2021-03-17 09:48:27 +09:00
Yukihiro "Matz" Matsumoto 80f6b14ac1 AUTHORS: add the commit hash as of we counted. 2021-03-16 19:32:08 +09:00
Yukihiro "Matz" Matsumoto f576482082 Merge pull request #5379 from shuujii/fix-typo-in-AUTHORS
Fix typo in `AUTHORS` [ci skip]
2021-03-15 12:41:33 +09:00
KOBAYASHI Shuji def2ba56fd Fix typo in AUTHORS [ci skip] 2021-03-15 12:29:30 +09:00
Yukihiro "Matz" Matsumoto 266eccdf91 AUTHOR: fixed typos. 2021-03-15 11:57:49 +09:00
Yukihiro "Matz" Matsumoto d433a4e825 AUTHORS: add 2 new GitHub accounts. 2021-03-15 11:23:41 +09:00
Yukihiro "Matz" Matsumoto a3e73de2ba AUTHORS: re-renamed from AUTHOR.md. 2021-03-15 11:03:26 +09:00
Yukihiro "Matz" Matsumoto 5158b73ab4 AUTHORS.md: add GitHub accounts if available. 2021-03-15 10:32:55 +09:00
Yukihiro "Matz" Matsumoto be2bdce17d Remove mail addresses from AUTHORS.md. 2021-03-14 19:14:43 +09:00
Yukihiro "Matz" Matsumoto bf524e7002 time.c: calendar clock should use CLOCK_REALTIME; 5e95f11
The issue was reported by @shuujii
2021-03-14 14:54:53 +09:00
Yukihiro "Matz" Matsumoto f92a27f918 codegen.c: fix memory leak from new_litbn(). 2021-03-13 09:33:16 +09:00
Yukihiro "Matz" Matsumoto bf2110d206 codegen.c: need to preserve neg info. 2021-03-12 18:34:29 +09:00
Yukihiro "Matz" Matsumoto 01fdf03bce codegen.c: fixed a typo. 2021-03-12 18:34:09 +09:00
Yukihiro "Matz" Matsumoto b52078aa92 codegen.c: avoid integer comparison of different sign. 2021-03-12 16:26:51 +09:00
Yukihiro "Matz" Matsumoto 4ae5ae3535 codegen.c: no integer overflow error in codegen; close #5376
Add new pool value type `IREP_TT_BIGINT` and generate integer overflow
error in the VM. In the future, `mruby` will support `Bignum` for
integers bigger than `mrb_int` (probably using `mpz`).
2021-03-12 16:21:32 +09:00
Yukihiro "Matz" Matsumoto 84e27d3b51 Rename AUTHORS to AUTHORS.md. 2021-03-11 10:37:48 +09:00
Yukihiro "Matz" Matsumoto c45fc556f5 AUTHORS: update according to git log commit entries. 2021-03-11 10:34:10 +09:00
Yukihiro "Matz" Matsumoto 14f531355f Use relative path for files under doc directory [ci skip] 2021-03-10 18:39:21 +09:00
Yukihiro "Matz" Matsumoto a62a07f40e Merge pull request #5375 from artichoke/mrb_cmp-presym-op-maro
bug(presym): Fix mrb_cmp declaration of <=> symbol for funcall
2021-03-09 16:09:58 +09:00
Yukihiro "Matz" Matsumoto adbdbbb779 Merge pull request #5378 from jbampton/update-node-version
chore: upgrade markdownlint GitHub Action node version to 14
2021-03-09 15:29:21 +09:00
Yukihiro "Matz" Matsumoto 405b5225ae Merge pull request #5377 from jbampton/fix-grammar
chore: fix grammar
2021-03-09 15:03:35 +09:00
John Bampton 32261c96fa chore: upgrade markdownlint GitHub Action node version to 14
Upgrade to  markdownlint-cli version 0.27.1
2021-03-09 05:05:17 +10:00
John Bampton 3c1ce680a3 chore: fix grammar 2021-03-09 04:35:03 +10:00
Yukihiro "Matz" Matsumoto f2b3529441 time.c: fix errors on Windows and macOS; ref #5354
`gmtime_r` detection logic was too strict.
2021-03-08 15:23:29 +09:00
Ryan Lopopolo b199f6fc5a bug(presym): Fix mrb_cmp declaration of <=> symbol for funcall 2021-03-07 21:29:11 -08:00
Yukihiro "Matz" Matsumoto cb3a6dd168 ISO C99 doesn't support unnamed unions; fix #5354 2021-03-08 11:50:52 +09:00
Yukihiro "Matz" Matsumoto 833f556c70 Merge pull request #5374 from jbampton/fix-spelling
chore: fix spelling
2021-03-07 18:12:16 +09:00
John Bampton 15f7b0182d chore: fix spelling 2021-03-07 04:58:15 +10:00
Yukihiro "Matz" Matsumoto 111e4e1ba8 Merge pull request #5373 from mruby/stable
Merge mruby 3.0.0
2021-03-05 17:36:12 +09:00
mimaki 0f45836b59 Update version and release date. (mruby 3.0.0 (2021-03-05)) 2021-03-05 17:07:35 +09:00
Yukihiro "Matz" Matsumoto a712755036 Merge pull request #5372 from shuujii/fix-load-64-bit-integer-from-mrb-format
Fix load 64-bit integer from mrb format; fix #5369
2021-03-05 14:39:42 +09:00
KOBAYASHI Shuji cb10469dee Fix load 64-bit integer from mrb format; fix #5369 2021-03-05 13:41:13 +09:00
Yukihiro "Matz" Matsumoto 25f604635d Merge pull request #5371 from shuujii/update-minimal-build-configuration
Update minimal build configuration [ci skip]
2021-03-04 22:47:09 +09:00
Yukihiro "Matz" Matsumoto 32f66d4616 Merge pull request #5370 from shuujii/remove-unused-mrblib-init_mrblib.c
Remove unused `mrblib/init_mrblib.c`
2021-03-04 22:46:09 +09:00
KOBAYASHI Shuji 5296e0f5af Update minimal build configuration [ci skip] 2021-03-04 22:18:26 +09:00
KOBAYASHI Shuji c065002b51 Remove unused mrblib/init_mrblib.c 2021-03-04 21:54:00 +09:00
Yukihiro "Matz" Matsumoto 2f335e1a58 Fix mrb_pool_value to keep int64 on 32 bit platforms; fix #5366 2021-03-04 17:17:13 +09:00
Takashi Kokubun f5d3d89ac2 Skip --depth=1 when it's locked 2021-03-04 15:50:13 +09:00
Yukihiro "Matz" Matsumoto 2be1a9c3c7 time.c: timespec_get() never fails. 2021-03-03 12:01:49 +09:00
Yukihiro "Matz" Matsumoto 42afafbd23 time.c: fixed wrong condition to include unistd.h. 2021-03-03 10:15:50 +09:00
Yukihiro "Matz" Matsumoto 79e2ad9a44 time.c: Windows does not have unistd.h. 2021-03-03 10:01:32 +09:00
Yukihiro "Matz" Matsumoto 5e95f11756 time.c: use clock_gettime() if possible. 2021-03-03 09:53:11 +09:00
Yukihiro "Matz" Matsumoto 0c631a4c08 time.c: adjust buffer size in mrb_time_asctime(). 2021-03-03 09:52:26 +09:00
Yukihiro "Matz" Matsumoto 384209b8dd time.c: fix compile errors in mrb_time_asctime(). 2021-03-03 09:51:27 +09:00
Yukihiro "Matz" Matsumoto 187384124b Merge pull request #5368 from jbampton/add-pre-commit-framework
feat: add pre-commit framework
2021-03-02 16:53:33 +09:00
Yukihiro "Matz" Matsumoto 55ac5dba86 dump.c: remove operator_table if MRB_NO_STDIO is defined. 2021-03-01 14:57:58 +09:00
Yukihiro "Matz" Matsumoto 37e206472a minimal.rb: add minimal configuration; ref #1225 2021-03-01 14:54:29 +09:00
Yukihiro "Matz" Matsumoto f3507818e7 binding-core.c: add cast to remove warnings; ref #5362 2021-03-01 11:38:30 +09:00
Yukihiro "Matz" Matsumoto 935a135553 time.c: fixed a bug on no builtin overflow (e.g. VC). 2021-03-01 11:35:15 +09:00
John Bampton 1c9b1bfeb7 feat: add pre-commit framework 2021-03-01 10:06:17 +10:00
Yukihiro "Matz" Matsumoto 65add8c650 time.c: avoid using mrb_int_{add,sub}_overflow().
The size and signedness of `mrb_int` and `time_t` may differ.
2021-03-01 07:58:14 +09:00
Yukihiro "Matz" Matsumoto eb68adafa1 Merge pull request #5367 from dearblue/libedit
Support libedit on mirb for FreeBSD
2021-02-28 20:26:33 +09:00
Yukihiro "Matz" Matsumoto 03eb3b5e87 time.c: check overflow in addition and subtraction of Time. 2021-02-28 19:33:57 +09:00
Yukihiro "Matz" Matsumoto 8684abd697 Remove periods from error messages according to the convention. 2021-02-28 19:32:52 +09:00
Yukihiro "Matz" Matsumoto b61766473b time.c: change RuntimeError to ArgumentError. 2021-02-28 19:26:40 +09:00
dearblue 15a7d5be3d Support libedit on mirb for FreeBSD 2021-02-28 16:23:37 +09:00
Yukihiro "Matz" Matsumoto 4dbbe14117 state.c: remove stdint.h inclusion.
Fixes C++03 compilation.
2021-02-27 16:40:05 +09:00
Yukihiro "Matz" Matsumoto 3da372b30f pack.c: add more checks for pack_pack(). 2021-02-27 12:00:24 +09:00
Yukihiro "Matz" Matsumoto 30b1287df5 state.c: check irep reference count overflow. 2021-02-26 22:16:07 +09:00
Yukihiro "Matz" Matsumoto 5d37160455 Use MRB_SYM() more extensively. 2021-02-26 15:05:55 +09:00
Yukihiro "Matz" Matsumoto 192f3df9a1 Merge pull request #5362 from dearblue/binding
Binding
2021-02-25 21:15:24 +09:00
Yukihiro "Matz" Matsumoto f1c2096f8e parse.y: endless_method_name should allow ==.
e.g. `def ==(v) = true`. The issue is reported by @shuujii
2021-02-24 22:20:16 +09:00
Yukihiro "Matz" Matsumoto 386b53e6d9 parse.y: upgrade endless def syntax.
- prohibit defining setter method
- allow endless def without parentheses
2021-02-24 16:56:55 +09:00
Yukihiro "Matz" Matsumoto a9ebd4703f Merge pull request #5364 from mruby/dependabot/github_actions/actions/setup-node-v2.1.5
Bump actions/setup-node from v2.1.4 to v2.1.5
2021-02-23 16:43:37 +09:00
dependabot[bot] 09ebfc43a6 Bump actions/setup-node from v2.1.4 to v2.1.5
Bumps [actions/setup-node](https://github.com/actions/setup-node) from v2.1.4 to v2.1.5.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/v2.1.4...46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea)

Signed-off-by: dependabot[bot] <support@github.com>
2021-02-23 07:17:23 +00:00
dearblue 927615e1f0 Added other methods for Binding
- Added to `mruby-binding-core`
  - `Binding#local_variable_defined?`
  - `Binding#local_variable_get`
  - `Binding#local_variable_set`
  - `Binding#local_variables`
  - `Binding#receiver`
  - `Binding#source_location`
  - `Binding#inspect`
- Added to `mruby-proc-binding`
  - `Proc#binding`

The reason for separating `Proc#binding` is that core-mrbgems has a method that returns a closure object to minimize possible problems with being able to manipulate internal variables.
By separating it as different mrbgem, each user can judge this problem and incorporate it arbitrarily.
2021-02-22 23:32:43 +09:00
dearblue 792f6ac670 Adjustment of the current HEAD and bindings, and separation
Make changes to make `Binding` work.
At the same time, it separates `Binding#eval`, which depends on `mruby-eval`, from `mruby-binding-core`.
2021-02-22 23:32:18 +09:00
dearblue 935ffa46a3 Change mruby-binding to mruby-binding-core 2021-02-22 22:15:46 +09:00
dearblue 297c5ac598 Merge branch 'binding' of https://github.com/ksss/mruby into HEAD 2021-02-22 22:14:46 +09:00
Yukihiro "Matz" Matsumoto d64c7330bc print.c: fix a compilation errors with MRB_NO_STDIO; fix #5361 2021-02-22 13:39:37 +09:00
Yukihiro "Matz" Matsumoto 60f9028612 Merge pull request #5360 from dearblue/opcode
Updated `doc/opcode.md` to match `include/mruby/ops.h` [ci skip]
2021-02-21 20:26:28 +09:00
dearblue 07874a3d29 Updated doc/opcode.md to match include/mruby/ops.h [ci skip] 2021-02-21 19:30:19 +09:00
Yukihiro "Matz" Matsumoto 6b8393081a Merge pull request #5359 from dearblue/warn
Comment out `warn` used in the `Array#fetch` method
2021-02-20 20:56:30 +09:00
dearblue 7ef4e54370 Comment out warn used in the Array#fetch method
I get an error because the current mruby does not have a `Kernel#warn` method.
But the warning itself is useful and I'll just comment it out in case it's implemented in the future.
2021-02-20 18:19:00 +09:00
Yukihiro "Matz" Matsumoto 0d7f5b8216 metaprog.c: fix a methods() bug with false argument; fix #5351 2021-02-20 14:56:55 +09:00
Yukihiro "Matz" Matsumoto 8ed15c078b metaprog.c: remove unused argument from a private function. 2021-02-20 13:20:14 +09:00
Yukihiro "Matz" Matsumoto 16fe040479 mruby/value.h: MRB_TT_CPTR is immediate with MRB_NO_BOXING.
The issue is reported by @shuujii.
2021-02-19 23:23:18 +09:00
Yukihiro "Matz" Matsumoto e5559184e0 Fix mrb_immediate_p() definition for MRB_NO_BOXING; ref #5352 2021-02-19 21:02:31 +09:00
Yukihiro "Matz" Matsumoto 787487b16d Check MRB_TT_* before object allocation; ref #5352 2021-02-19 15:36:41 +09:00
Yukihiro "Matz" Matsumoto ce0a381406 Merge pull request #5352 from shuujii/fix-type-tag-that-set-to-NilClass-and-FalseClass
Fix type tag that set to `NilClass` and `FalseClass`
2021-02-18 21:51:07 +09:00
Yukihiro "Matz" Matsumoto bdf2cf005e Merge pull request #5357 from k0kubun/lock-depth
Skip --depth=1 when it's locked
2021-02-17 15:23:24 +09:00
Takashi Kokubun 6ac79a2c44 Skip --depth=1 when it's locked 2021-02-16 20:56:13 -08:00
Yukihiro "Matz" Matsumoto cb43dda009 Merge pull request #5347 from shuujii/add--s-option-to-mrbc-for-make-variable-static
Add `-s` option to `mrbc` for make variable static
2021-02-17 12:43:45 +09:00
Yukihiro "Matz" Matsumoto dee9168882 Merge pull request #5356 from mruby/dependabot/github_actions/actions/upload-artifact-v2.2.2
Bump actions/upload-artifact from v1 to v2.2.2
2021-02-16 13:54:24 +09:00
Yukihiro "Matz" Matsumoto cb9225bcbf Merge pull request #5355 from mruby/dependabot/github_actions/actions/cache-v2.1.4
Bump actions/cache from v2 to v2.1.4
2021-02-16 13:54:00 +09:00
dependabot[bot] cf2fce93ec Bump actions/upload-artifact from v1 to v2.2.2
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from v1 to v2.2.2.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v1...e448a9b857ee2131e752b06002bf0e093c65e571)

Signed-off-by: dependabot[bot] <support@github.com>
2021-02-16 04:23:03 +00:00
dependabot[bot] 1c8e1e20e4 Bump actions/cache from v2 to v2.1.4
Bumps [actions/cache](https://github.com/actions/cache) from v2 to v2.1.4.
- [Release notes](https://github.com/actions/cache/releases)
- [Commits](https://github.com/actions/cache/compare/v2...26968a09c0ea4f3e233fdddbafd1166051a095f6)

Signed-off-by: dependabot[bot] <support@github.com>
2021-02-16 04:23:03 +00:00
Yukihiro "Matz" Matsumoto e2d4bedb7b Merge pull request #5343 from jbampton/add-dependabot-config
feat: add Dependabot config file
2021-02-16 13:08:39 +09:00
Yukihiro "Matz" Matsumoto d6164817f5 Use full-core gembox for clang-asan configuration.
For better coverage.
2021-02-16 12:55:19 +09:00
Yukihiro "Matz" Matsumoto 7470337a82 Update URL explaining alignment issue; close #5344 2021-02-16 12:50:31 +09:00
Yukihiro "Matz" Matsumoto 61370ca98c Merge pull request #5350 from shuujii/refine-checking-for-trailing-whitespace
Refine checking for trailing whitespace [skip travis][skip appveyor]
2021-02-15 13:49:52 +09:00
Yukihiro "Matz" Matsumoto 2725755bc5 Merge pull request #5349 from shuujii/remove-trailing-tab-in-build_config-dreamcast_shelf.rb
Remove trailing tab in `build_config/dreamcast_shelf.rb` [ci skip]
2021-02-15 10:54:29 +09:00
Yukihiro "Matz" Matsumoto 330dd3f450 Merge pull request #5353 from dearblue/editorconfig
Introduce EditorConfig [skip ci]
2021-02-15 10:53:48 +09:00
dearblue 9b38dddc61 Introduce EditorConfig [skip ci] 2021-02-14 22:19:20 +09:00
KOBAYASHI Shuji 68daa3bf96 Fix type tag that set to NilClass and FalseClass 2021-02-14 20:55:46 +09:00
Yukihiro "Matz" Matsumoto 3217febfe9 Merge pull request #5348 from dearblue/optable
Place optable in ROM
2021-02-14 17:49:00 +09:00
KOBAYASHI Shuji 4203e574e3 Refine checking for trailing whitespace [skip travis][skip appveyor]
* Include tabs in checking.
* Use `git grep` to avoid including `.git` directory.
* Avoid running `grep` multiple times.
2021-02-14 16:07:04 +09:00
KOBAYASHI Shuji 29dfadf0de Remove trailing tab in build_config/dreamcast_shelf.rb [ci skip] 2021-02-14 16:02:02 +09:00
dearblue 297df70bc1 Place optable in ROM 2021-02-14 13:53:51 +09:00
KOBAYASHI Shuji a6a76d8fd2 Add -s option to mrbc for make variable static 2021-02-14 11:55:53 +09:00
Yukihiro "Matz" Matsumoto c3ec5861ac Merge pull request #5346 from jbampton/clean-up-linters
refactor: add the spell checker Action to the Lint Action file
2021-02-13 18:25:27 +09:00
John Bampton c263aec748 refactor: add the spell checker Action to the Lint Action file
Order jobs in workflow.
2021-02-13 18:58:48 +10:00
Yukihiro "Matz" Matsumoto da6c4ed169 Merge pull request #5345 from jbampton/fix-missing-https-on-links
chore: fix missing HTTPS on links
2021-02-13 17:21:12 +09:00
John Bampton 6204244b41 chore: fix missing HTTPS on links 2021-02-13 18:17:47 +10:00
Yukihiro "Matz" Matsumoto d04c651405 Merge pull request #5342 from jbampton/fix-spelling
chore: fix spelling
2021-02-13 16:38:02 +09:00
John Bampton d52da3fe77 feat: add Dependabot config file
Set for GitHub Actions to check for update everyday.

When you add or update the dependabot.yml file, this triggers an immediate check for version updates. Any options that also affect security updates are used the next time a security alert triggers a pull request for a security update.

https://docs.github.com/en/github/administering-a-repository/configuration-options-for-dependency-updates
2021-02-13 17:37:30 +10:00
John Bampton be40e9c783 chore: fix spelling
Normally a single spell checker can't find all the mistakes or check all types of code.

These mistakes were found by another spell checker inside my editor with a more manual sift / find.
2021-02-13 17:21:17 +10:00
Yukihiro "Matz" Matsumoto 9a9c95986a Merge pull request #5341 from jbampton/check-for-trailing-whitespace
feat(CI): check for trailing whitespace
2021-02-13 15:46:51 +09:00
John Bampton d55a74c418 feat(CI): check for trailing whitespace
Run on pull request only.
Use a shell script to check for trailing whitespace in all files.
Fail if trailing whitespace is found.
2021-02-13 16:37:46 +10:00
Yukihiro "Matz" Matsumoto 8e01fc8933 Merge pull request #5340 from jbampton/use-certified-actions
refactor: only use certified GitHub Actions to increase security
2021-02-13 15:19:34 +09:00
John Bampton 4c7ecbb8a6 refactor: only use certified GitHub Actions to increase security
Official -> "The individual jobs in a workflow can interact with (and compromise) other jobs. For example, a job querying the environment variables used by a later job, writing files to a shared directory that a later job processes, or even more directly by interacting with the Docker socket and inspecting other running containers and executing commands in them.

This means that a compromise of a single action within a workflow can be very significant, as that compromised action would have access to all secrets configured on your repository, and can use the GITHUB_TOKEN to write to the repository. Consequently, there is significant risk in sourcing actions from third-party repositories on GitHub. "

https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
2021-02-13 16:13:30 +10:00
Yukihiro "Matz" Matsumoto acdd939d80 Merge pull request #5339 from shuujii/update-compile-prerequisites-in-doc-guides-compile.md
Update compile prerequisites in `doc/guides/compile.md` [ci skip]
2021-02-13 14:17:58 +09:00
Yukihiro "Matz" Matsumoto 94fb86f89b parse.y: string buffer (tokbuf) can overflow.
Check if `esclen` is smaller than `len` (original string length).
2021-02-13 14:06:37 +09:00
KOBAYASHI Shuji d470163b22 Update compile prerequisites in doc/guides/compile.md [ci skip]
Bison and gperf are optional.
2021-02-13 11:53:52 +09:00
Yukihiro "Matz" Matsumoto adb50df71a Update GitHub Actions.
- Remove Ubuntu-16.04
- Add Ubuntu-20.04 {gcc,clang}
2021-02-12 21:14:06 +09:00
Yukihiro "Matz" Matsumoto 5ba37db981 Merge pull request #5336 from shuujii/fix-build-mruby-catch-gem-without-presym
Fix build `mruby-catch` gem without presym
2021-02-12 21:11:59 +09:00
Yukihiro "Matz" Matsumoto d3fbac4d53 Merge pull request #5335 from shuujii/add-UncaughtThrowError-tagvalue-for-Ruby-compatibility
Add `UncaughtThrowError#{tag,value}` for Ruby compatibility
2021-02-12 21:10:53 +09:00
Yukihiro "Matz" Matsumoto 5f71e0e754 Merge pull request #5337 from shuujii/remove-skip-ci-hack-to-GitHub-Actions
Remove "skip ci" hack to GitHub Actions [skip travis][skip appveyor]
2021-02-12 21:09:07 +09:00
KOBAYASHI Shuji 28729deed6 Remove "skip ci" hack to GitHub Actions [skip travis][skip appveyor]
GitHub Actions now supports "skip ci" natively:
https://github.blog/changelog/2021-02-08-github-actions-skip-pull-request-and-push-workflows-with-skip-ci/
2021-02-12 19:44:41 +09:00
KOBAYASHI Shuji 8ba7be0999 Fix build mruby-catch gem without presym 2021-02-12 19:19:32 +09:00
KOBAYASHI Shuji 955464ca3c Add UncaughtThrowError#{tag,value} for Ruby compatibility 2021-02-12 19:09:18 +09:00
Yukihiro "Matz" Matsumoto 2af8e16cc6 include/mruby/array.h: ARY_LEN() should return mrb_int.
It used to return `mrb_ssize` but its size may differ from `mrb_int`,
e.g. `MRB_INT64` on `MRB_32BIT` architecture.
2021-02-12 16:57:33 +09:00
Yukihiro "Matz" Matsumoto 31051fd656 doc/mruby3.md: use relative path. 2021-02-12 15:39:19 +09:00
Yukihiro "Matz" Matsumoto ca7cac8b31 Merge pull request #5334 from shuujii/avoid-possibility-of-reading-uninitialized-areas-in-h_check_modified
Avoid possibility of reading uninitialized areas in `h_check_modified()`
2021-02-12 15:38:59 +09:00
KOBAYASHI Shuji 453296a729 Avoid possibility of reading uninitialized areas in h_check_modified()
In `h_check_modified()`, in the case of `MRB_NO_BOXING`, `ht_ea()` or
`ht_ea_capa()` for AR may read uninitialized area. Therefore, do not use
those macros for AR in `MRB_NO_BOXING` (but in the case of `MRB_64BIT`,
`ht_ea_capa()` is the same as `ar_ea_capa()`, so use it).

fix #5332
2021-02-12 15:00:06 +09:00
Yukihiro "Matz" Matsumoto 22ffc1108b src/print.c: stop warning with MRB_NO_STDIO. 2021-02-12 11:14:25 +09:00
Yukihiro "Matz" Matsumoto 793fbab7d5 Rename mrb_sleep.c to sleep.c in mruby-sleep gem. 2021-02-12 11:11:10 +09:00
Yukihiro "Matz" Matsumoto a96bd02127 Update docs/guides/mrbgems.md; ref #5210
Binary gems description added, along with a few cosmetic changes.
2021-02-12 11:07:45 +09:00
Yukihiro "Matz" Matsumoto 5c130e8e7b Do not collect linker options from binary gems; close #5210
Binary gems are mrbgems that set `spec.bins` in their `mrbgem.rake`,
and usually their names are prefixed with `mruby-bin-`.
2021-02-12 10:33:53 +09:00
Yukihiro "Matz" Matsumoto 69f8a52866 Update docs/guides/compile.md.
Especially description regarding the build process and `build` directory
structures, along with some typo fixes and cosmetic changes.
2021-02-12 10:27:10 +09:00
Yukihiro "Matz" Matsumoto 0db6e3eb6f Rename mruby-catch.c to catch.c; ref #5328 2021-02-12 10:09:19 +09:00
Yukihiro "Matz" Matsumoto d178e147f5 Merge pull request #5333 from shuujii/fix-heap-buffer-overflow-for-small-Hash-HT-in-Hash-rehash
Fix heap-buffer-overflow for small `Hash` (HT) in `Hash#rehash`
2021-02-11 08:26:33 +09:00
Yukihiro "Matz" Matsumoto 5735d7c2fd Merge branch 'dearblue-mruby-catch' 2021-02-10 20:11:40 +09:00
Yukihiro "Matz" Matsumoto c7809ca025 Refactor mruby-catch; ref #5328
- Move `#catch` definition to `mruby-catch.c` to avoid tweaking
- Remove `#__preserve_catch_method`
- Implement whole `#throw` method in C
2021-02-10 20:09:00 +09:00
KOBAYASHI Shuji 28eb6271ba Fix heap-buffer-overflow for small Hash (HT) in Hash#rehash
### Example

##### example.rb

```ruby
h = {}
(1..17).each{h[_1] = _1}
(1..16).each{h.delete(_1)}
h.rehash
```

##### ASAN report

```console
$ bin/mruby example.rb
==52587==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000006998 at pc 0x55a29cddf96b bp 0x7fff7b1b1720 sp 0x7fff7b1b1710
READ of size 4 at 0x602000006998 thread T0
    #0 0x55a29cddf96a in ib_it_next /mruby/src/hash.c:639
    #1 0x55a29cde2ca2 in ht_rehash /mruby/src/hash.c:900
    #2 0x55a29cde379f in h_rehash /mruby/src/hash.c:996
    #3 0x55a29cde7f3d in mrb_hash_rehash /mruby/src/hash.c:1735
    #4 0x55a29ce77b62 in mrb_vm_exec /mruby/src/vm.c:1451
    #5 0x55a29ce5fa88 in mrb_vm_run /mruby/src/vm.c:981
    #6 0x55a29ceb87e1 in mrb_top_run /mruby/src/vm.c:2874
    #7 0x55a29cf36bdf in mrb_load_exec mrbgems/mruby-compiler/core/parse.y:6805
    #8 0x55a29cf36f25 in mrb_load_detect_file_cxt mrbgems/mruby-compiler/core/parse.y:6848
    #9 0x55a29cdba0a2 in main /mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c:347
    #10 0x7f24ef43b0b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
    #11 0x55a29cdb4a6d in _start (/mruby/bin/mruby+0x2a3a6d)

0x602000006998 is located 0 bytes to the right of 8-byte region [0x602000006990,0x602000006998)
allocated by thread T0 here:
    #0 0x7f24f01cfffe in __interceptor_realloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10dffe)
    #1 0x55a29ceb9440 in mrb_default_allocf /mruby/src/state.c:68
    #2 0x55a29cdba747 in mrb_realloc_simple /mruby/src/gc.c:228
    #3 0x55a29cdba928 in mrb_realloc /mruby/src/gc.c:242
    #4 0x55a29cde12e5 in ht_init /mruby/src/hash.c:749
    #5 0x55a29cde2b8e in ht_rehash /mruby/src/hash.c:897
    #6 0x55a29cde379f in h_rehash /mruby/src/hash.c:996
    #7 0x55a29cde7f3d in mrb_hash_rehash /mruby/src/hash.c:1735
    #8 0x55a29ce77b62 in mrb_vm_exec /mruby/src/vm.c:1451
    #9 0x55a29ce5fa88 in mrb_vm_run /mruby/src/vm.c:981
    #10 0x55a29ceb87e1 in mrb_top_run /mruby/src/vm.c:2874
    #11 0x55a29cf36bdf in mrb_load_exec mrbgems/mruby-compiler/core/parse.y:6805
    #12 0x55a29cf36f25 in mrb_load_detect_file_cxt mrbgems/mruby-compiler/core/parse.y:6848
    #13 0x55a29cdba0a2 in main /mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c:347
    #14 0x7f24ef43b0b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
```
2021-02-10 20:03:34 +09:00
Yukihiro "Matz" Matsumoto f0e25121fd Merge branch 'mruby-catch' of https://github.com/dearblue/mruby into dearblue-mruby-catch 2021-02-10 15:43:24 +09:00
Yukihiro "Matz" Matsumoto 20342714ea Upgrade supported Ruby version to 2.5.
Ruby 2.5 is the oldest maintained version.
2021-02-09 22:29:42 +09:00
Yukihiro "Matz" Matsumoto aa5b7fbd80 i_gcd() does not work for MRB_INT_MIN. 2021-02-08 21:18:50 +09:00
Yukihiro "Matz" Matsumoto db1172b48c Allow the case MRB_32BIT and MRB_NO_BOXING and MRB_USE_FLOAT32; #4382 2021-02-08 17:46:38 +09:00
Yukihiro "Matz" Matsumoto bc21278a7c Merge pull request #5331 from shuujii/explicit-top-level-task-to-clarify-in-tasks-test.rake
Explicit top level task to clarify in `tasks/test.rake`
2021-02-08 07:19:05 +09:00
KOBAYASHI Shuji 3cf0e85ed7 Explicit top level task to clarify in tasks/test.rake 2021-02-07 19:11:54 +09:00
Yukihiro "Matz" Matsumoto 530afca2d7 Move F(x) definition inside of #ifdef; fix #5330 2021-02-07 15:28:23 +09:00
Yukihiro "Matz" Matsumoto 1cc20978cf Enlarge tolerance limit for float32; close #5329
Along with some refactoring on `mruby-math` tests.
2021-02-07 14:56:34 +09:00
Yukihiro "Matz" Matsumoto 3252518a3c Fix tests to work with MRB_USE_FLOAT32; fix #5329 2021-02-07 14:55:45 +09:00
Yukihiro "Matz" Matsumoto 70b7ebd72f Add host-f32 config to test MRB_USE_FLOAT32; ref #5329 2021-02-07 14:54:01 +09:00
dearblue 232e07ad61 Reimplement mruby-catch; ref #5321
When there is a corresponding tag, the `RBreak` object is used to make a global jump.

Like CRuby, it can't be caught by `rescue`.
It is also the same as CRuby that it can be canceled in the middle by `ensure`.

 ### How to find the corresponding tag with `throw`

The called `catch` method remains in the call stack, and the tag also remains in the stack at that time.
So it is possible to find the called location by searching the two.

Note that no method can be given to the `proc` object specified in `RBreak`.
Therefore, inside the `catch` method, the argument block is called in a seemingly meaningless closure.

Also, as a countermeasure against `alias` etc., the `proc` object, which is the body of the `catch` method, is saved when mrbgem is initialized.
2021-02-06 21:41:08 +09:00
Yukihiro "Matz" Matsumoto ef8f475722 MinGW does not need MSVC hack.
Both MinGW and MSVC provide _WIN32 macro.
2021-02-06 19:30:59 +09:00
Yukihiro "Matz" Matsumoto c6c632cf97 Merge pull request #5325 from dearblue/c++-exc.2
`compile_as_cxx` should generate a path under` conf.build_dir`
2021-02-06 18:36:25 +09:00
Yukihiro "Matz" Matsumoto 94d8dfed66 Merge pull request #5327 from dearblue/notest
Ignore if `conf.enable_test` does not exist
2021-02-06 18:28:53 +09:00
Yukihiro "Matz" Matsumoto 6d0b5102cf Merge pull request #5326 from dearblue/struct
No need to check class definition
2021-02-06 18:25:49 +09:00
dearblue 9d1a659bc7 Ignore if conf.enable_test does not exist
Because if the configuration file didn't contain any `conf.enable_test`, `rake test` would report an exception and exit.

```console
% cat my_config.rb
MRuby::Build.new { toolchain }

% rake MRUBY_CONFIG=my_config.rb test

  ...SNIP...

rake aborted!
NoMethodError: undefined method `invoke' for nil:NilClass
/var/tmp/mruby/tasks/test.rake:24:in `block (3 levels) in <top (required)>'
Tasks: TOP => test => test:build => test:build:lib
(See full trace by running task with --trace)
```
2021-02-06 18:09:27 +09:00
dearblue 0f8d3d8777 No need to check class definition
Because now the `Struct` class is always defined when this file is included.
2021-02-06 18:05:05 +09:00
dearblue e0d2f4e0ae compile_as_cxx should generate a path under conf.build_dir
If the current directory is different from `MRUBY_ROOT` and it has` conf.build_dir` and `conf.enable_cxx_exception` set, it was generating a pathname outside of` build_dir`.
As a result, in some cases files unrelated to mruby could be linked.

```console
% pwd
/tmp/mruby/1/2/3/4/5/6

% mruby_dir=/tmp/mruby/a/b/c/d/mruby

% cat my_config.rb
MRuby::Build.new("host", "build/to/custom/directory") do
  toolchain
  enable_cxx_exception
end

% rake MRUBY_CONFIG=my_config.rb -f $mruby_dir/Rakefile > logs
% grep CXX logs
CXX   a/b/c/d/mruby/src/error-cxx.cxx -> a/b/c/d/mruby/src/error-cxx.o
CXX   a/b/c/d/mruby/src/gc-cxx.cxx -> a/b/c/d/mruby/src/gc-cxx.o
CXX   a/b/c/d/mruby/src/vm-cxx.cxx -> a/b/c/d/mruby/src/vm-cxx.o
CXX   a/b/c/d/mruby/mrbgems/mruby-compiler/core/codegen-cxx.cxx -> a/b/c/d/mruby/mrbgems/mruby-compiler/core/codegen-cxx.o
CXX   a/b/c/d/mruby/mrbgems/mruby-compiler/core/y.tab-cxx.cxx -> a/b/c/d/mruby/mrbgems/mruby-compiler/core/y.tab-cxx.o
CXX   ../a/b/c/d/mruby/src/error-cxx.cxx -> ../a/b/c/d/mruby/src/error-cxx.o
CXX   ../a/b/c/d/mruby/src/gc-cxx.cxx -> ../a/b/c/d/mruby/src/gc-cxx.o
CXX   ../a/b/c/d/mruby/src/vm-cxx.cxx -> ../a/b/c/d/mruby/src/vm-cxx.o
```
2021-02-06 17:27:23 +09:00
Yukihiro "Matz" Matsumoto 88113df098 Fixed compile errors in cmath.c in MinGW and macOS. 2021-02-06 17:00:03 +09:00
Yukihiro "Matz" Matsumoto 2a69f5105c Merge pull request #5324 from dearblue/c++-exc
Exclude `<build-dir>/mrbc/**/*` from rake target rules
2021-02-06 16:58:27 +09:00
Yukihiro "Matz" Matsumoto 0bd01c545f Merge pull request #5323 from shuujii/make-the-argument-of-Kernel-catch-optional-as-Ruby-does
Make the argument of `Kernel#catch` optional as Ruby does
2021-02-06 16:57:36 +09:00
dearblue 5c3b5f4221 Exclude <build-dir>/mrbc/**/* from rake target rules
Prevents the auto-generated mrbc target source code from being compiled under host conditions.

This is because a build error occurred when `conf.enable_cxx_exception` was set.
2021-02-06 16:37:15 +09:00
KOBAYASHI Shuji 1ea4c51245 Make the argument of Kernel#catch optional as Ruby does
Also implement the following changes.

* Add tests
* Use `Object#equal?` to compare tags for Ruby compatibility
* Use `attr_reader`
2021-02-06 13:28:47 +09:00
Yukihiro "Matz" Matsumoto 4bf4650321 Avoid implicit conversion from mrb_float to mrb_complex. 2021-02-06 00:50:13 +09:00
Yukihiro "Matz" Matsumoto 8945afe38e Merge pull request #5322 from shuujii/fix-message-of-ThrowCatchJump-in-mruby-catch-gem
Fix message of `ThrowCatchJump` in `mruby-catch` gem
2021-02-06 00:42:51 +09:00
Yukihiro "Matz" Matsumoto 8ecd38d648 Reimplement complex division. 2021-02-06 00:40:18 +09:00
Yukihiro "Matz" Matsumoto ea0737ecfd Define M_E for some platforms. 2021-02-06 00:39:53 +09:00
Yukihiro "Matz" Matsumoto a6994f51c8 Update mruby-cmath to support MSVC complex.
* Use `_Complex` instead of `complex` (MSYS2 do not support `complex`)
* Use `_Dcomplex` instead of `_Complex` on MSCV
* Avoid operator division and multiplication of complex
2021-02-06 00:08:25 +09:00
KOBAYASHI Shuji 80965fe2d7 Fix message of ThrowCatchJump in mruby-catch gem
### Example

```ruby
begin
  throw 1
rescue Exception => e
  puts e.message
end
```

#### Before this patch:

```console
$ bin/mruby example.rb
uncaught throw :1
```
#### After this patch (same as Ruby):

```console
$ bin/mruby example.rb
uncaught throw 1
```
2021-02-05 23:14:58 +09:00
Yukihiro "Matz" Matsumoto a0050541d1 Add mruby-cmath gem to the core.
This gem uses C99 `_Complex` features. You need a C compiler that
supports `_Complex` to enable this gem. All `gcc`, `clang`, `VC` support
`_Complex` so there should not be a big problem.
2021-02-05 22:27:27 +09:00
Yukihiro "Matz" Matsumoto d898002096 Add a few new API for complex access. 2021-02-05 21:54:49 +09:00
Yukihiro "Matz" Matsumoto c6149370b0 Refactor method overriding.
* Use `class_eval` instead of `instance_eval`.
* Reduce `class_eval` calls
* define `Numeric#i`
* undefine `Complex#i`
2021-02-05 21:54:11 +09:00
Yukihiro "Matz" Matsumoto 7ce03e32b7 Add Complex#to_c method. 2021-02-05 21:42:42 +09:00
Yukihiro "Matz" Matsumoto ee3017496b instance_eval for classes and modules should behave as class_eval. 2021-02-05 21:39:44 +09:00
KOBAYASHI Shuji 5e814ea912 Define MRB_NO_GEMS if disable_libmruby is specified 2021-02-05 18:52:00 +09:00
Yukihiro "Matz" Matsumoto 043fe9d9f5 Merge pull request #5319 from shuujii/check-if-.pi-build-rules-are-defined
Check if `.pi` build rules are defined
2021-02-04 22:19:19 +09:00
KOBAYASHI Shuji 67a28b56ab Check if .pi build rules are defined
`.pi` files are created for `.o` files that `build.products` depends on, but
an error will occur if the build rule is unknown, so add a check.

I don't think this situation would normally arise. However, in
`mattn/mruby-onig-regexp`, when using bundled onigmo, onigmo's `.o` files
are added to dependency of `libmruby.a` in the second and subsequent builds,
and mruby does not know the build rule, so the following error had occured.

```console
rake aborted!
Don't know how to build task '/mruby/build/host/mrbgems/mruby-onig-regexp/onigmo-6.2.0/libonig_objs/ascii.pi' (See the list of available tasks with `rake --tasks`)
```
2021-02-04 21:17:58 +09:00
Yukihiro "Matz" Matsumoto 6f354322a8 Merge pull request #5318 from shuujii/fix-breakage-where-builds-except-host-dont-refer-mrbc-in-host
Fix breakage where builds except `host` don't refer` mrbc` in `host`
2021-02-04 15:24:05 +09:00
KOBAYASHI Shuji f92c1f1b7f Fix breakage where builds except host don't refer mrbc in host
Build error occurred under the following conditions.

* `host` build is presym enabled and unspecified `mruby-bin-mrbc` gem.
* Build except `host` unspecified `mruby-bin-mrbc` gem and mrbcfile.

### Example

#### Build configuration

```ruby
MRuby::Build.new{|conf| conf.toolchain}
MRuby::Build.new("host2"){|conf| conf.toolchain}
```

#### Error

```console
rake aborted!
external mrbc or mruby-bin-mrbc gem in current('host2') or 'host' build is required
/mruby/lib/mruby/build.rb:326:in `mrbcfile'
/mruby/tasks/mrblib.rake:9:in `block in <top (required)>'
/mruby/lib/mruby/build.rb:18:in `instance_eval'
/mruby/lib/mruby/build.rb:18:in `block in each_target'
/mruby/lib/mruby/build.rb:17:in `each'
/mruby/lib/mruby/build.rb:17:in `each_target'
/mruby/tasks/mrblib.rake:1:in `<top (required)>'
/mruby/Rakefile:27:in `load'
/mruby/Rakefile:27:in `<top (required)>'
```
2021-02-04 14:57:37 +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
mimaki ea3874ed3c Update version to 3.0.0RC. 2021-02-03 16:45:11 +09:00
Yukihiro "Matz" Matsumoto c43dd75ea9 Avoid Heap Overflow in heredoc_remove_indent; fix #5316 2021-02-03 13:06:13 +09:00
Yukihiro "Matz" Matsumoto 810d13dacd Move MRB_TRY part of mrb_close to src/error.c; ref 6cc52b3
We don't want to increase number of files that should be compiled by C++
compiler when `enable_cxx_exception` is turned on.
2021-02-03 09:43:41 +09:00
Yukihiro "Matz" Matsumoto 6cc52b3210 Ignore errors from atexit finalizers. 2021-02-02 10:57:32 +09:00
Yukihiro "Matz" Matsumoto d759a73525 Allow more than 256 child irep; fix #5310
We have introduced following new instructions.

 * `OP_LAMBDA16`
 * `OP_BLOCK16`
 * `OP_METHOD16`
 * `OP_EXEC16`

Each instruction uses 16 bits operand for `reps` index. Since new
instructions are added, `mruby/c` VM should be updated.

Due to new instructions, dump format compatibility is lost, we have
increased `RITE_BINARY_MAJOR_VER`.

In addition, we have decreased the size of `refcnt` in `mrb_irep` from
`uint32_t` to `uint16_t`, which is reasonably big enough.
2021-02-01 16:20:58 +09:00
Yukihiro "Matz" Matsumoto bd6b48fa3b Copy iv table with #prepend; fix #5309
In addition, stop eager allocation of `mt` table.
2021-02-01 14:33:28 +09:00
Yukihiro "Matz" Matsumoto d0ba7b95a9 Merge pull request #5314 from dearblue/presym_init
Introduced `MRB_PRESYM_INIT_SYMBOLS()`
2021-02-01 11:19:13 +09:00
Yukihiro "Matz" Matsumoto 5cce4ad433 Merge pull request #5315 from shuujii/use-mrb_open_core-instead-of-mrb_open--in-mrbc
Use `mrb_open_core()` instead of `mrb_open()`  in `mrbc`
2021-02-01 10:12:29 +09:00
Yukihiro "Matz" Matsumoto 874f828a7a Merge pull request #5313 from dearblue/diet-5272
Remove unnecessary `ci0` variables; ref #5272
2021-02-01 09:36:11 +09:00
KOBAYASHI Shuji 1fc8e00e4a Use mrb_open_core() instead of mrb_open() in mrbc 2021-01-31 22:37:27 +09:00
Yukihiro "Matz" Matsumoto 406159d412 Merge pull request #5312 from dearblue/diet-5060
Remove unnecessary configuration macros; ref #5060
2021-01-31 19:57:31 +09:00
dearblue a9949f5da4 Introduced MRB_PRESYM_INIT_SYMBOLS()
The `init_SYMBOLS()` function implicitly defined in `MRB_PRESYM_DEFINE_VAR_AND_INITER()` requires some familiarity when trying to find it from the caller.
By introducing `MRB_PRESYM_INIT_SYMBOLS()`, it is possible to find directly from the identifier.
2021-01-31 18:13:28 +09:00
dearblue d824488915 Remove unnecessary ci0 variables; ref #5272 2021-01-31 17:24:16 +09:00
dearblue 5ede25c40f Remove unnecessary configuration macros; ref #5060
The following macros will be removed:
- `ENSURE_STACK_INIT_SIZE`
- `RESCUE_STACK_INIT_SIZE`
- `MRB_ECALL_DEPTH_MAX`
2021-01-31 17:22:27 +09:00
Yukihiro "Matz" Matsumoto cee916ab0f Merge pull request #5311 from shuujii/change-.o.d-back-to-.d-because-.pi.d-is-no-longer-created
Change `.o.d` back to `.d` because `.pi.d` is no longer created
2021-01-31 15:25:58 +09:00
KOBAYASHI Shuji d90abc648e Change .o.d back to .d because .pi.d is no longer created 2021-01-31 15:08:37 +09:00
Yukihiro "Matz" Matsumoto 02e336ee27 Merge pull request #5308 from dearblue/internal-mrbc
Build internal mrbc in an internal directory
2021-01-30 15:43:50 +09:00
Yukihiro "Matz" Matsumoto dd603d494d Merge pull request #5306 from dearblue/unpack
Fixed `String#unpack` to handle the highest range of integer values
2021-01-29 23:51:26 +09:00
dearblue 14e07f721a Build internal mrbc in an internal directory 2021-01-29 23:02:17 +09:00
dearblue b500e82950 Remove unnecessary range confirmation
This is a correction based on the review by @matz.
https://github.com/mruby/mruby/pull/5306#pullrequestreview-578378401
2021-01-29 22:33:03 +09:00
dearblue 9c36499e31 Fixed String#unpack to handle the highest range of integer values
Previously, problems occurred when the `fixnum` was exceeded.

- 32-bit cpu mode with `MRB_WORD_BOXING` and `MRB_INT32`:

  ```console
  % bin/mruby -e 'p [0x7fffffff].pack("N").unpack("N")'
  trace (most recent call last):
  -e:1: cannot unpack to Integer: 2147483647 (RangeError)
  ```

- 64-bit cpu mode with `MRB_WORD_BOXING` and `MRB_INT64`:

  ```console
  % bin/mruby -e 'p [0x7fffffff_ffffffff].pack("q").unpack("q")'
  trace (most recent call last):
  -e:1: cannot unpack to Integer: 9223372036854775807 (RangeError)
  ```
2021-01-29 22:27:36 +09:00
Yukihiro "Matz" Matsumoto 825241205f Replace mrb_intern_cstr to mrb_intern_lit. 2021-01-29 18:32:26 +09:00
Yukihiro "Matz" Matsumoto 4a7309d327 Merge pull request #5307 from dearblue/stackerr
Raise SystemStackError if mruby VM stack expansion fails
2021-01-28 23:01:40 +09:00
Yukihiro "Matz" Matsumoto 0030417ace Merge pull request #5305 from dearblue/symbol0
Check first `0` when converting symbols into strings
2021-01-28 22:56:27 +09:00
dearblue 0dbb9e6e41 Raise SystemStackError if mruby VM stack expansion fails 2021-01-28 22:04:47 +09:00
dearblue 3d8a8fb661 Check first 0 when converting symbols into strings
This was because it caused `SIGSEGV` when `mruby -v` displayed an unnamed variable.

```console
% bin/mruby -ve 'call { |(a, b)| }'

  ...SNIP...

irep 0x8007d0050 nregs=3 nlocals=1 pools=0 syms=1 reps=1 iseq=12
file: -e
    1 000 OP_LOADSELF   R1
    1 002 OP_BLOCK      R2      I(0:0x8007d00a0)
    1 005 OP_SENDB      R1      :call   0
    1 009 OP_RETURN     R1
    1 011 OP_STOP

irep 0x8007d00a0 nregs=6 nlocals=5 pools=0 syms=0 reps=0 iseq=29
local variable names:
zsh: segmentation fault (core dumped)  bin/mruby -ve 'call { |(a, b)| }'
```
2021-01-28 21:15:31 +09:00
Yukihiro "Matz" Matsumoto bb42c1b286 Merge pull request #5304 from shuujii/refine-preprocess_options
Refine `preprocess_options`; ref d95ffb036
2021-01-28 19:57:16 +09:00
Yukihiro "Matz" Matsumoto d42d308620 Remove duplicated --cflags; [ci skip] 2021-01-28 19:55:05 +09:00
KOBAYASHI Shuji c858cba3e9 Refine preprocess_options; ref d95ffb036
If we modify an option that may have been specified by users, we may
make unintended changes, so it is better not to modify it as much as
possible, IMO.
2021-01-28 18:42:19 +09:00
Yukihiro "Matz" Matsumoto 1c05764ba3 Update limitation.md for integer division change in 3.0. 2021-01-28 17:08:30 +09:00
Yukihiro "Matz" Matsumoto 56842628b9 Stop mentioning MRB_NO_PRESYM in the doc.
It's for internal use. Please use `conf.disable_presym`.
2021-01-28 16:47:02 +09:00
Yukihiro "Matz" Matsumoto 07d4498613 Silence VC warning. 2021-01-28 16:35:22 +09:00
Yukihiro "Matz" Matsumoto d95ffb0362 Stop generating build/<build>/src/*.pi.d. 2021-01-28 15:58:35 +09:00
Yukihiro "Matz" Matsumoto 1e009061f8 Describe disabling preallocated symbols in the doc. 2021-01-28 15:47:51 +09:00
Yukihiro "Matz" Matsumoto 4063af90e2 Update TODO after mruby3.0. 2021-01-28 15:06:22 +09:00
Yukihiro "Matz" Matsumoto 2e33c2d120 Remove unnecessary bit shift in rational_new_f. 2021-01-28 08:47:16 +09:00
Yukihiro "Matz" Matsumoto f5e10e294c Add symbol names as comments to presym_length_table; ref #5303 2021-01-27 23:47:32 +09:00
Yukihiro "Matz" Matsumoto 69f9460075 Add static modifiers to preallocated symbols tables; ref #5303 2021-01-27 23:44:04 +09:00
Yukihiro "Matz" Matsumoto f0eb50a55d Merge pull request #5303 from shuujii/split-presym_table-for-reduced-program-size
Split `presym_table` for reduced program size
2021-01-27 23:41:03 +09:00
KOBAYASHI Shuji 3104aed8c6 Split presym_table for reduced program size
Because a structure that is an element of `presym_table` has padding, split
it into individual arrays for name and length.

#### Result (64-bit CPU with full-core gembox)

|        |   mruby    | libmruby.a |
|--------|------------|------------|
| Before | 1,087,444B | 1,476,872B |
| After  | 1,079,340B | 1,469,784B |
2021-01-27 20:47:10 +09:00
Yukihiro "Matz" Matsumoto 251fd74315 Merge pull request #5302 from shuujii/rename-.i-created-for-presym-scan-to-.pi
Rename `.i` created for presym scan to `.pi`
2021-01-27 18:08:58 +09:00
KOBAYASHI Shuji d6a9ffa2b5 Rename .i created for presym scan to .pi
This is because compiler's `-save-temps=obj` option creates `.i` with the
same name.
2021-01-27 16:09:12 +09:00
Yukihiro "Matz" Matsumoto bf56ecd2bf Merge pull request #5301 from shuujii/fix-typos-in-mruby-presym-disableenable.h
Fix typos in `mruby/presym/{disable,enable}.h` [ci skip]
2021-01-27 12:32:42 +09:00
KOBAYASHI Shuji 826e0b108f Fix typos in mruby/presym/{disable,enable}.h [ci skip] 2021-01-27 12:18:41 +09:00
Yukihiro "Matz" Matsumoto 5e479c66d5 Merge pull request #5300 from shuujii/avoid-possible-loss-of-data-casting-in-binary-search
Avoid 'possible loss of data' casting in binary search
2021-01-27 12:15:58 +09:00
Yukihiro "Matz" Matsumoto 89cd742506 Merge pull request #5299 from shuujii/fix-Use-MRB_SYM-for-error-class-retrieval
Fix "Use `MRB_SYM()` for error class retrieval"; ref 2ddfd50df
2021-01-27 12:02:34 +09:00
KOBAYASHI Shuji 504788bf89 Avoid 'possible loss of data' casting in binary search
Because it may not be expected result.
example: https://wandbox.org/permlink/F5Mp7IEJ1VY3CFLp
2021-01-27 11:42:18 +09:00
KOBAYASHI Shuji dd07067067 Fix "Use MRB_SYM() for error class retrieval"; ref 2ddfd50df
The new macro (`MRB_E_SYM`) was not being used, so it is being used. Also
`MRB_E_SYM` is confusing with `MRB_SYM_E`, so change it to `MRB_ERROR_SYM`.
2021-01-27 11:23:08 +09:00
Yukihiro "Matz" Matsumoto efa0314731 Adjust spaces after list markers. 2021-01-26 21:21:26 +09:00
Yukihiro "Matz" Matsumoto d4101d0a08 Revert "Fix the wrong directory host-bin to host/bin."
This reverts commit 34f82f24e9.
Ref #5282
2021-01-26 21:17:28 +09:00
Yukihiro "Matz" Matsumoto f3d5deb981 Clarify that contributors agree with MIT license in CONTRIBUTING.md. 2021-01-26 18:21:49 +09:00
Yukihiro "Matz" Matsumoto 04d5e7da39 Update doc/mruby3.md. 2021-01-26 17:16:22 +09:00
Yukihiro "Matz" Matsumoto 73418a90fa Add doc/symbols.md. [ci skip]
To describe how to use symbols, especially preallocated symbols from C.
2021-01-26 12:42:36 +09:00
Yukihiro "Matz" Matsumoto 63b7439ddf Change mruby-config to print usage on invalid arguments.
Or no argument at all.
2021-01-26 11:37:01 +09:00
Yukihiro "Matz" Matsumoto 34f82f24e9 Fix the wrong directory host-bin to host/bin.
Where `mruby-config` command should be generated.
2021-01-26 11:35:59 +09:00
Yukihiro "Matz" Matsumoto 2ddfd50df3 Use MRB_SYM() for error class retrieval; ref #5277
Note that `MRB_SYM()` is only available when `mruby/presym.h` is
included. Use `mrb_intern_lit()` otherwise.
2021-01-26 11:13:06 +09:00
Yukihiro "Matz" Matsumoto 17ecf14511 Revert "Minimize the changes in #5277"
This reverts commit dc51d89ac2.
2021-01-26 10:57:07 +09:00
Yukihiro "Matz" Matsumoto 165f79c877 Silence 'loss of data' warnings in symbol.c. 2021-01-25 23:27:32 +09:00
Yukihiro "Matz" Matsumoto c68258f454 Merge pull request #5297 from hasumikin/fix-typo-in-rite-binary-header
Fix TYPO and checking minor version in RITE BINARY HEADER
2021-01-25 22:50:29 +09:00
HASUMI Hitoshi d5ed73379f fix comparison of minor version 2021-01-25 22:29:11 +09:00
HASUMI Hitoshi da65d35d7a fix TYPO in RITE BINARY HEADER 2021-01-25 22:11:54 +09:00
Yukihiro "Matz" Matsumoto 0903e2a72e Silence 'loss of data' warnings. 2021-01-25 15:45:32 +09:00
Yukihiro "Matz" Matsumoto efef4541aa Fix a bug for the case frexp() return Infinity. 2021-01-25 15:44:59 +09:00
Yukihiro "Matz" Matsumoto 23e5c08e31 Should use a limit for 32 bit platform; ref 05a8cc44 2021-01-25 15:44:59 +09:00
Yukihiro "Matz" Matsumoto 73ce5db170 Add description for mruby-config in compile.md. [ci skip]
For easier compiling and linking of the application embedding `mruby`
2021-01-25 10:45:57 +09:00
Yukihiro "Matz" Matsumoto 05a8cc44cc Define RAT_INT_LIMIT for 32 bit platforms. 2021-01-24 22:21:56 +09:00
Yukihiro "Matz" Matsumoto f20e10686c Prohibit r suffix after scientific notation (e.g. 1e10).
As CRuby does.
2021-01-24 21:43:20 +09:00
Yukihiro "Matz" Matsumoto cc59860e40 Detect integer overflow in rational_new_f(). 2021-01-24 21:42:34 +09:00
Yukihiro "Matz" Matsumoto 48b214f0b5 Remove test debug lines in fallback presym.inc
ref dc51d89ac2
2021-01-23 18:12:04 +09:00
Yukihiro "Matz" Matsumoto baa1ee1faa Fixed typo; ref #5296 2021-01-23 10:24:53 +09:00
Yukihiro "Matz" Matsumoto 8b590b5ec7 Merge pull request #5296 from yevgenko/patch-1
Fix typo
2021-01-23 10:20:21 +09:00
Yevhen Viktorov 2cab36c289 Fix typo 2021-01-23 00:25:23 +00:00
Yukihiro "Matz" Matsumoto dc51d89ac2 Minimize the changes in #5277
Instead of including `mruby/presym.h` everywhere, we provided the
fallback `mruby/presym.inc` under `include/mruby` directory, and specify
`-I<build-dir>/include` before `-I<top-dir>/include` in `presym.rake`.
So even when someone drops `-I<build-dir>/include` in compiler options,
it just compiles without failure.
2021-01-22 18:38:53 +09:00
Yukihiro "Matz" Matsumoto c5c156a6dd Reduce size of mrb_callinfo by rearranging members.
From 48 bytes to 40 bytes on 64 bit platforms (unchanged on 32 bit).
2021-01-21 21:11:32 +09:00
Yukihiro "Matz" Matsumoto 33deeae9eb Merge branch 'shuujii-avoid-including-presym.inc-in-existing-header-files' 2021-01-21 14:55:44 +09:00
Yukihiro "Matz" Matsumoto 6c5ccd5abe Merge branch 'avoid-including-presym.inc-in-existing-header-files' of https://github.com/shuujii/mruby into shuujii-avoid-including-presym.inc-in-existing-header-files 2021-01-21 14:53:18 +09:00
Yukihiro "Matz" Matsumoto 438d114917 Fix a bug that :_1 to cause syntax error; fix #5295 2021-01-21 14:45:06 +09:00
Yukihiro "Matz" Matsumoto 56fdc449eb Better error messages with yacc tokens. 2021-01-21 14:42:39 +09:00
Yukihiro "Matz" Matsumoto 5e0f51c906 Silence gcc warning from strncpy(). 2021-01-21 12:22:54 +09:00
Yukihiro "Matz" Matsumoto 47a68e89ff Remove CRC16 from dumped mruby binary.
`calc_crc_16_ccitt()` consumes a lot of clock cycles in programs like
`mrbtest` which loads a lot of dumped binary. Error detection for flaky
channels should be done in the higher level.

Note: `mruby/c` should be updated to support this change.
2021-01-20 23:12:43 +09:00
Yukihiro "Matz" Matsumoto e91dfd07be Compile mruby-bin-debugger with ci/gcc-clang.rb. 2021-01-19 12:05:16 +09:00
Yukihiro "Matz" Matsumoto 0661ebb669 Merge pull request #5294 from shuujii/fix-that-Hash-may-not-contain-any-empty-buckets
Fix that Hash may not contain any empty buckets
2021-01-18 23:19:47 +09:00
KOBAYASHI Shuji dd81de49a6 Fix that Hash may not contain any empty buckets
The Hash implementation assumed that there were always empty buckets, but
sometimes there were only active or deleted buckets (no empty buckets).
Therefore, fix it so that this situation does not occur.

### Example

```ruby
# example.rb
class A
  attr_reader :v
  def initialize(v) @v = v end
  def ==(o) @v == o.v end
  def hash; @v end
  def to_s; "#{self.class}[#{@v}]" end
  alias eql? ==
  alias inspect to_s
end

keys = (0..31).map{A.new(_1)}
h = {}
(0..16).each{h[keys[_1]] = _1}
(17..31).each do
  k = keys[_1]
  h[k] = _1
  h.delete(k)
end
p h.keys
```

#### Before this patch:

```console
$ bin/mruby example.rb
[A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[8], A[9], A[10], A[11], A[12], A[13], A[14], A[15], A[16], A[30], A[31]]
```

#### After this patch:

```console
$ bin/mruby example.rb
[A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[8], A[9], A[10], A[11], A[12], A[13], A[14], A[15], A[16]]
```
2021-01-18 21:32:10 +09:00
Yukihiro "Matz" Matsumoto e4fc42ea11 Merge pull request #5293 from dearblue/fix-5272.2
Fix build error for mruby-bin-debugger
2021-01-18 00:23:13 +09:00
dearblue 04a4e59c83 Fix build error for mruby-bin-debugger
This is a missing change in #5272.

This issue was reported by @shuujii.
https://github.com/mruby/mruby/pull/5272#issuecomment-761819737
2021-01-18 00:00:53 +09:00
Yukihiro "Matz" Matsumoto f4a3dc4f07 Add tests for Integer#quo and Float#quo; #5268 2021-01-17 23:02:36 +09:00
Yukihiro "Matz" Matsumoto 12ff88563d Fix int_quo to do float division; fix #5268 2021-01-17 23:02:36 +09:00
Yukihiro "Matz" Matsumoto c7452ff61f Define Rational#quo; fix #5268 2021-01-17 23:02:35 +09:00
Yukihiro "Matz" Matsumoto b4817a54f0 Make mrb_to_flo() to convert objects, not integer, not float; #5268
Thinking `Ratinal` and `Complex` in mind.
2021-01-17 23:02:35 +09:00
Yukihiro "Matz" Matsumoto 126f0f0563 Merge pull request #5292 from dearblue/objspace-memsize
Fix NULL pointer dereference with mruby-os-memsize and mruby-method
2021-01-16 17:55:43 +09:00
dearblue 0fdf5d9bb9 Fix NULL pointer dereference with mruby-os-memsize and mruby-method
If it gets an insubstantial method object with `obj.method`, it will raise a `SIGSEGV` with `ObjectSpace.memsize_of(method)`.
2021-01-16 15:52:52 +09:00
Yukihiro "Matz" Matsumoto 0aa8db9a06 Merge pull request #5291 from dearblue/fix-5272
Fixed stack position of return value; ref #5272
2021-01-16 13:56:26 +09:00
dearblue 414a61a9d2 Fixed stack position of return value; ref #5272
When I `#call` the "proc" object created by the `mrb_proc_new_cfunc()` function from Ruby space, the return value did not go into the correct stack position.
This can destroy the calling variable.

This issue is now caused by #5272. sorry.
2021-01-16 11:05:15 +09:00
Yukihiro "Matz" Matsumoto 4bba769b95 Avoid syntax error regarding colons in the expression; fix #5290
Reported and inspired by @hasumikin; based on CRuby's `parse.y`.
2021-01-15 22:49:40 +09:00
Yukihiro "Matz" Matsumoto 28d5dabacd Merge pull request #5273 from dearblue/fiber
Capture the return value of `Fiber.yield` via C; ref #5261
2021-01-14 23:47:25 +09:00
Yukihiro "Matz" Matsumoto a639a39883 Rational denominator should not be zero. 2021-01-13 09:17:20 +09:00
dearblue 0229446a30 Capture the return value of Fiber.yield via C; ref #5261 2021-01-12 23:04:36 +09:00
Yukihiro "Matz" Matsumoto c7d96dbf84 Merge pull request #5289 from dearblue/sockaddr_un
Initialize all area of `struct sockaddr_un`
2021-01-12 22:22:44 +09:00
Yukihiro "Matz" Matsumoto 9d950818ce Merge branch 'dearblue-reorganize-ci' 2021-01-12 22:14:53 +09:00
dearblue 8928bc2dce Initialize all area of struct sockaddr_un
Members of `struct sockaddr_un` are requesting the definitions of `sun_family` and `sun_path`.
https://pubs.opengroup.org/onlinepubs/009696699/basedefs/sys/un.h.html

But the other members are optional and environment dependent.

In fact, other members are defined in the BSD series.
from NetBSD-9.1 <https://github.com/NetBSD/src/blob/da504f75982b244b2288bc9970bbc203bd77a9c1/sys/sys/un.h#L49-L53>

```c
struct  sockaddr_un {
        unsigned char   sun_len;        /* sockaddr len excluding NUL */
        sa_family_t     sun_family;     /* AF_UNIX */
        char    sun_path[104];          /* path name (gag) */
};
```
2021-01-12 21:35:18 +09:00
Yukihiro "Matz" Matsumoto bec4d30dc6 Merge branch 'reorganize-ci' of https://github.com/dearblue/mruby into dearblue-reorganize-ci 2021-01-12 18:38:42 +09:00
Yukihiro "Matz" Matsumoto e13f34e308 Merge pull request #5288 from shuujii/fix-that-sometimes-parallel-build-of-test-code-fails
Fix that sometimes parallel build of test code fails; fix #5284
2021-01-12 16:29:02 +09:00
Yukihiro "Matz" Matsumoto b64ec814d6 Fix a signed shift bug on 32 bit platforms; ref e1c9e7e 2021-01-12 16:26:05 +09:00
Yukihiro "Matz" Matsumoto 1310368b3f Silence Windows warnings (cast and setmode). 2021-01-12 16:25:30 +09:00
KOBAYASHI Shuji 02121cbd65 Fix that sometimes parallel build of test code fails; fix #5284
The cause is that `mrbgem.rake` of` mruby-test` gem is loaded when test
code is requested to be built, but when `mrbgem.rake` is loaded,
`MRuby::Gem.current` is updated, which is not thread safe.

Address this by not loading `mrbgem.rake` in parallel.
2021-01-12 15:41:22 +09:00
Yukihiro "Matz" Matsumoto a8b8d316ab Save NOARG information in struct mt_elem; fix #5257 2021-01-12 14:51:34 +09:00
Yukihiro "Matz" Matsumoto e1c9e7efab Changed packing format of inline symbols.
To make inline symbols packed in 30 bits.
2021-01-12 14:51:33 +09:00
Yukihiro "Matz" Matsumoto 974e245ae0 Merge pull request #5285 from dearblue/io-unimps
Remove functions for unimplemented methods
2021-01-11 23:49:54 +09:00
Yukihiro "Matz" Matsumoto cdbcade041 Merge pull request #5286 from dearblue/io-popen
Integrate the argument parsing part of `IO.popen`
2021-01-11 23:48:41 +09:00
dearblue 0c96c4c34a Integrate the argument parsing part of IO.popen 2021-01-11 23:07:25 +09:00
dearblue 01897f8456 Remove functions for unimplemented methods
- Use `mrb_notimplement_m()` instead.
- Hide the unused `option_to_fd()` when `TARGET_OS_IPHONE` is enabled.
2021-01-11 23:01:53 +09:00
Yukihiro "Matz" Matsumoto d531636584 Merge pull request #5283 from shuujii/add-missing-cast-in-ea_next_capa_for
Add missing cast in `ea_next_capa_for`
2021-01-11 21:17:44 +09:00
Yukihiro "Matz" Matsumoto f8b938435c Merge pull request #5282 from dearblue/mruby-config-cross
Create a `mruby-config` that can be run on the host by cross-building
2021-01-11 20:34:38 +09:00
KOBAYASHI Shuji 87ba84b048 Add missing cast in ea_next_capa_for 2021-01-11 20:19:55 +09:00
dearblue 66df8c619a Create a mruby-config that can be run on the host by cross-building
The output directory will be `host-bin`, so it will be output as `<build-dir>/host-bin/mruby-config`.

It's still not available for target devices.
2021-01-11 17:07:05 +09:00
Yukihiro "Matz" Matsumoto 672e016b13 Merge pull request #5281 from shuujii/remove-the-definition-of-mrb_uint-in-numeric.h-that-is-no-longer-needed
Remove the definition of `mrb_uint` in `numeric.h` that is no longer needed
2021-01-11 16:35:42 +09:00
Yukihiro "Matz" Matsumoto 9577e6ca6a Merge pull request #5280 from shuujii/remove-unneeded-check-to-mrbtest-in-tasks-presym.rake
Remove unneeded check to `mrbtest` in `tasks/presym.rake`
2021-01-11 16:34:05 +09:00
KOBAYASHI Shuji 48feda0692 Remove the definition of mrb_uint in numeric.h that is no longer needed 2021-01-11 16:20:27 +09:00
KOBAYASHI Shuji 123d15c5ab Remove unneeded check to mrbtest in tasks/presym.rake
With the change in #5267, `build.products` no longer contains `mrbtest` when
`tasks/presym.rake` is loaded.
2021-01-11 16:15:12 +09:00
Yukihiro "Matz" Matsumoto 0290f06681 Merge pull request #5279 from shuujii/remove-unneeded-mruby-test-gem-in-build_config-no-float.rb
Remove unneeded `mruby-test` gem in `build_config/no-float.rb` [ci skip]
2021-01-11 12:53:17 +09:00
KOBAYASHI Shuji 2ddd66cc4b Remove unneeded mruby-test gem in build_config/no-float.rb [ci skip]
Use `enable_test` to enable the test.
2021-01-11 12:07:08 +09:00
Yukihiro "Matz" Matsumoto ffea200075 Merge pull request #5278 from dearblue/annotation
Fix annotations [ci skip]
2021-01-11 11:57:09 +09:00
dearblue a0662a16a3 Fix annotations [ci skip] 2021-01-11 11:33:39 +09:00
KOBAYASHI Shuji 90b53f4c29 Avoid including presym.inc in existing header files
Addressed an issue where existing programs linking `libmruby.a` could only
be built by adding `<build-dir>/include` to compiler's include path.
2021-01-11 09:21:07 +09:00
Yukihiro "Matz" Matsumoto 3deb3a7aac Fix CI failure on Windows environment.
`1L` on Windows means `32 bit int`.
2021-01-10 22:52:41 +09:00
Yukihiro "Matz" Matsumoto e66c6edaba Fix mixture of inline int declaration in for statement. 2021-01-10 22:52:40 +09:00
Yukihiro "Matz" Matsumoto 80a7655b10 Merge pull request #5271 from shuujii/fix-build-error-in-cross-build-with-presym
Fix build error in cross-build with presym
2021-01-10 22:15:52 +09:00
Yukihiro "Matz" Matsumoto dc5ade3729 Merge pull request #5275 from dearblue/read_irep
Replace `tempirep` with `RProc`
2021-01-10 22:13:51 +09:00
Yukihiro "Matz" Matsumoto 596b542720 Merge pull request #5274 from shuujii/fix-the-condition-to-remove-mrbtest-when-rake-clean
Fix the condition to remove `mrbtest` when `rake clean`
2021-01-10 22:07:22 +09:00
dearblue 3fc848b545 Replace tempirep with RProc
Previously I used the `RData` object to avoid a memory leak in `mrb_irep` if `src/load.c` failed.
ref: https://github.com/mruby/mruby/pull/4250
commit: f1523d2404

Considering that the `RProc` object will be created in the subsequent process, it is preferable to create the `RProc` object from the beginning.
Along with this, the inside of `read_irep()` is replaced with the processing centered on the `RProc` object.

The global function that returns the `mrb_irep` pointer is still provided for compatibility.
2021-01-10 21:41:51 +09:00
Yukihiro "Matz" Matsumoto e8e28eacc7 Revert "Revert "Simplify full-core.gembox""
This reverts commit 37d795dec7.
This reapplies e20d652 (#4202), which is reverted, but its issue was solved
by 1d8456f.
2021-01-10 20:29:49 +09:00
KOBAYASHI Shuji fe28e8617e Fix the condition to remove mrbtest when rake clean 2021-01-10 16:28:14 +09:00
dearblue 9877f4ca3c Revert "Save&restore execution point (pc) in c->cibase->pc; fix #5261"
This reverts commit a0c1e075e3.

This is because the `mrb_callinfo::pc` has been reorganized, resulting in over-correction.
2021-01-10 13:33:17 +09:00
dearblue ced89c25ff Unified pc and err of mrb_callinfo
This enhances self-containment.

- Changed the `mrb_callinfo::pc` field to point to itself.
  Previously it indicated the return destination of the previous call level.
  `mrb_callinfo::pc` will now hold the address to its own `proc->body.irep->iseq`.
- Removed `mrb_callinfo::err` field.
  This is because `mrb_callinfo::pc - 1` is semantically the same as the previous `err`.
- The `pc0` and `pc_save` variables in `mrb_vm_exec()` are no longer needed and have been deleted.
- It removes the argument because `cipush()` doesn't need to save the previous `pc`.
2021-01-10 13:23:43 +09:00
dearblue 16baea0677 Changes stackent to stack of mrb_callinfo
This enhances self-containment.

Previously `mrb_context::stack` had the current call level stack, but now it owns it.
The `mrb_context::stack` field, which is no longer needed, will be removed.
2021-01-10 13:23:35 +09:00
dearblue 58e9442737 Unified target_class and env of mrb_callinfo
If there is `env`, `env->c` means `target_class`.
2021-01-10 13:23:28 +09:00
dearblue b210cfa34e Use uint16_t for argc and acc of mrb_callinfo
This is because it is enough to express the range up to (-1..255) or (-3..255).
2021-01-10 13:22:28 +09:00
KOBAYASHI Shuji f80d5ece27 Fix build error in cross-build with presym
Fix the following issues.

* https://github.com/mruby/mruby/pull/5220#issuecomment-757204258
* https://github.com/mruby/mruby/pull/5220#issuecomment-757205572
2021-01-10 10:21:45 +09:00
Yukihiro "Matz" Matsumoto 6f6eabf05a Fix wrong float to rational conversion in 32 bit mode. 2021-01-09 23:39:36 +09:00
Yukihiro "Matz" Matsumoto f81591ceb6 Detect invalid first byte of UTF-8 char; fix #5269
The first byte of UTF-8 character should not be `80..c1`.
2021-01-09 19:09:57 +09:00
Yukihiro "Matz" Matsumoto 62e5247300 Convert float number to rational by decoding mantissa. 2021-01-09 19:09:57 +09:00
Yukihiro "Matz" Matsumoto 92cc6b4996 Introduce mrb_uint which is unsigned integer with size of mrb_int. 2021-01-09 19:09:56 +09:00
Yukihiro "Matz" Matsumoto 12cc959998 Remove khash.h leftovers. 2021-01-09 19:09:56 +09:00
Yukihiro "Matz" Matsumoto fb4767a3b7 Merge pull request #5270 from shuujii/remove-unnecessary--include-in-generated-files
Remove unnecessary `#include` in generated files
2021-01-09 16:34:11 +09:00
KOBAYASHI Shuji 892bf15cd7 Remove unnecessary #include in generated files 2021-01-09 14:50:23 +09:00
Yukihiro "Matz" Matsumoto 69482dbc8e Merge pull request #5265 from shuujii/reapply-116e128b-because-it-is-back-at-456878ba
Reapply 116e128b because it is back at 456878ba
2021-01-08 23:10:49 +09:00
Yukihiro "Matz" Matsumoto 6587269af8 Merge pull request #5267 from shuujii/delay-test-code-build-until-rake-test
Delay test code build until `rake test`
2021-01-08 21:14:19 +09:00
Yukihiro "Matz" Matsumoto a0c1e075e3 Save&restore execution point (pc) in c->cibase->pc; fix #5261
`mrb_fiber_resume()` can be called from C; ref #3056
2021-01-08 21:03:41 +09:00
KOBAYASHI Shuji 3a8d7bdf82 Delay test code build until rake test
With this change, the test code will not be built unless `rake test` is
run, so there will be almost no side effects even if `enable_test` is
always set (but, gems specified by `add_test_dependency` are included
in `libmruby.a`).

Also added are `test: build` task, which only builds the test code
(including the main code), and `test: run` task, which only runs tests
independent of build. Therefore, the idiom for building in parallel and
not running tests in parallel is `rake -m test:build && rake test:run`.
2021-01-08 20:36:54 +09:00
Yukihiro "Matz" Matsumoto 04561cd999 Merge pull request #5266 from shuujii/stop-immediate-flush-to-stdout-stderr-when-running-in-parallel-on-CI
Stop immediate flush to stdout/stderr when running in parallel on CI
2021-01-08 16:37:50 +09:00
KOBAYASHI Shuji dbe387a9d8 Stop immediate flush to stdout/stderr when running in parallel on CI
During parallel execution (build), it is sometimes flushed before line
breaks, and lines are concatenated.
2021-01-08 15:59:08 +09:00
KOBAYASHI Shuji f7ff4810f0 Reapply 116e128b because it is back at 456878ba 2021-01-08 15:23:50 +09:00
Yukihiro "Matz" Matsumoto 1cc1ade610 Merge pull request #5263 from shuujii/use-namespaces-according-to-Rake-conventions
Use namespaces according to Rake conventions
2021-01-07 20:22:35 +09:00
Yukihiro "Matz" Matsumoto 76241a9630 Merge pull request #5264 from shuujii/immediately-flush-output-to-stdout-stderr-so-that-logs-are-not-mixed-on-CI
Immediately flush output to stdout/stderr so that logs are not mixed on CI
2021-01-07 20:21:13 +09:00
KOBAYASHI Shuji 35c85cb21f Immediately flush output to stdout/stderr so that logs are not mixed on CI
Set in build configuration to enable on all CI platforms.
2021-01-07 19:46:03 +09:00
KOBAYASHI Shuji 0dfcaaed63 Use namespaces according to Rake conventions
Change the Rake task to one that uses namespaces as follows (previous task
names can also be used for compatibility).

| Previous Task  |    New Task    |
|----------------|----------------|
| api_doc        | doc:api        |
| capi_doc       | doc:capi       |
| clean_doc      | doc:clean      |
| clean_api_doc  | doc:clean:api  |
| clean_capi_doc | doc:clean:capi |
| view_api       | doc:view:api   |
| view_capi      | doc:view:capi  |
| gitlab_config  | gitlab:config  |
| gitlab_dockers | gitlab:dockers |
2021-01-07 17:31:05 +09:00
Yukihiro "Matz" Matsumoto a435cc94ec Merge pull request #5262 from shuujii/add-scan-target-functions-for-presym
Add scan target functions for presym
2021-01-07 17:12:06 +09:00
KOBAYASHI Shuji d35cd42dc8 Add scan target functions for presym
Add the following functions:

- mrb_intern_cstr
- mrb_define_singleton_method
- mrb_define_class_under
- mrb_define_module_under
2021-01-07 16:38:46 +09:00
Yukihiro "Matz" Matsumoto ec6f46c05d Use nint() for implicit cast; ref #5260 2021-01-07 11:49:50 +09:00
Yukihiro "Matz" Matsumoto 7e116b5e8b Merge pull request #5260 from SeekingMeaning/squiggly-fix-5
Fix line continuations with mixed indentation in squiggly heredocs
2021-01-07 11:45:24 +09:00
Yukihiro "Matz" Matsumoto 5e752caf67 Merge pull request #5259 from shuujii/consider-the-case-a-local-variable-name-does-not-become-a-named-presym
Consider the case a local variable name does not become a named presym
2021-01-07 10:22:10 +09:00
Seeker d52c82d648 Add heredoc_push_indented helper function 2021-01-06 16:46:44 -08:00
Seeker e279528ff3 Fix line continuations with mixed indentation in squiggly heredocs 2021-01-06 16:35:46 -08:00
KOBAYASHI Shuji b8486d73e2 Consider the case a local variable name does not become a named presym
Non-ASCII characters are allowed to local variable names, so they are not
always named presym.
2021-01-06 23:29:45 +09:00
Yukihiro "Matz" Matsumoto 676054c8df Merge pull request #5258 from shuujii/fix-build-with-enable_cxx_exception
Fix build with `enable_cxx_exception`
2021-01-06 19:50:03 +09:00
KOBAYASHI Shuji 90283432a4 Fix build with enable_cxx_exception 2021-01-06 19:03:10 +09:00
Yukihiro "Matz" Matsumoto 01aa2a990f Specify receivers for gembox methods; ref #5241 2021-01-06 18:10:21 +09:00
Yukihiro "Matz" Matsumoto aecb3a33e6 Merge pull request #5241 from dearblue/gembox
Take advantage of gembox
2021-01-06 18:06:18 +09:00
Yukihiro "Matz" Matsumoto 0d76b90758 Use ~0U instead of ~0 to avoid sign comparison warnings. 2021-01-06 17:15:21 +09:00
Yukihiro "Matz" Matsumoto 8e048ae25d Merge branch 'shuujii-improve-source-scanning-for-presym' 2021-01-06 17:14:12 +09:00
Yukihiro "Matz" Matsumoto 74c9502bd4 Merge branch 'improve-source-scanning-for-presym' of https://github.com/shuujii/mruby into shuujii-improve-source-scanning-for-presym 2021-01-06 17:06:07 +09:00
Yukihiro "Matz" Matsumoto 1341e53961 Avoid comparing -1 with size_t (unsigned); Use ~0 instead. 2021-01-06 14:23:12 +09:00
Yukihiro "Matz" Matsumoto ca3a6156bf Allow context switch from C using mrb_fiber_resume().
But you still cannot cross C function boundary.
2021-01-06 14:16:56 +09:00
Yukihiro "Matz" Matsumoto 4585c360e4 Remove duplicated remove_sign_bits() call. 2021-01-05 21:09:46 +09:00
Yukihiro "Matz" Matsumoto bb5c451dd4 Fix mirb not to be terminated by codegen error. 2021-01-04 07:42:21 +09:00
Yukihiro "Matz" Matsumoto 7c9d9b1c89 Merge pull request #5255 from shuujii/avoid-64-bit-operations-in-src-hash.c
Avoid 64-bit operations in `src/hash.c`; close #5201
2021-01-03 20:28:00 +09:00
Yukihiro "Matz" Matsumoto 0d22e11b75 Merge pull request #5254 from SeekingMeaning/squiggly-fix-4
Fix for escaped newlines in squiggly heredocs
2021-01-03 20:25:34 +09:00
Yukihiro "Matz" Matsumoto 5798c03de6 Merge pull request #5256 from katsuyoshi/master
replace ; to : of OPT_SETGV in codedump.c
2021-01-03 20:25:02 +09:00
Katsuyoshi Ito f23918f61a replace ; to : of OPT_SETGV in codedump.c
Maybe it's a typo.
2021-01-03 19:47:30 +09:00
KOBAYASHI Shuji eb9d9e3425 Avoid 64-bit operations in src/hash.c; close #5201
The idea of using `size_t` in `ea_next_capa_for` is by @dearblue.
2021-01-03 18:42:22 +09:00
Seeker 8286e6052a Fix for escaped newlines in squiggly heredocs 2021-01-03 00:48:10 -08:00
Yukihiro "Matz" Matsumoto c52efe7be8 Avoid double inclusion on <mruby.h>. 2021-01-02 23:50:18 +09:00
Yukihiro "Matz" Matsumoto 17cb50f8d0 Avoid int64_t on 32 bit platforms. 2021-01-02 23:49:41 +09:00
Yukihiro "Matz" Matsumoto 757902c497 Check NaN and Infinity before converting Float to Rational. 2021-01-02 23:36:41 +09:00
Yukihiro "Matz" Matsumoto 392aff7099 Use Jenkins One At A Time Hash for mrb_str_hash(). 2021-01-02 20:28:29 +09:00
Yukihiro "Matz" Matsumoto d55367582c Allow negative integer value formatting in base 8 and 16. 2021-01-02 20:28:29 +09:00
Yukihiro "Matz" Matsumoto b151a697e0 Fixed wrong casting in OP_LOADI32.
Negative integer `>-65535` had wrong value, e,g, `p(-40550)` printed
`4294926746` since Nov. 2020, sigh.
2021-01-02 20:28:28 +09:00
Yukihiro "Matz" Matsumoto c1f05a7fb3 Avoid uint64_t in string-to-integer conversion; ref #5201 2021-01-02 20:28:27 +09:00
Yukihiro "Matz" Matsumoto 4ac73307fd Reduce strength of the hash function; ref #5201
Also avoid using `uint64_t`.
2021-01-02 20:28:27 +09:00
Yukihiro "Matz" Matsumoto 6323c995f3 Use type casting macros; ref #5246 #5247 2021-01-02 20:28:26 +09:00
Yukihiro "Matz" Matsumoto 15e7b3e8fe Merge pull request #5251 from SeekingMeaning/squiggly-fix-3
Fix regression for squiggly heredocs
2021-01-02 20:28:13 +09:00
Yukihiro "Matz" Matsumoto 12cb7207ec Merge pull request #5253 from shuujii/refine-wrong-number-of-arguments-message-in-mrb_get_args
Refine "wrong number of arguments" message in `mrb_get_args`
2021-01-02 19:45:09 +09:00
KOBAYASHI Shuji 1a9ac02d8d Refine "wrong number of arguments" message in mrb_get_args
#### Before this patch:

```ruby
__send__         #=> wrong number of arguments
{}.default(1,2)  #=> wrong number of arguments
```

#### After this patch:

```ruby
__send__         #=> wrong number of arguments (given 0, expected 1+)
{}.default(1,2)  #=> wrong number of arguments (given 2, expected 0..1)
```
2021-01-02 19:15:34 +09:00
Seeker 1099050377 Treat tabs as 8 spaces in squiggly heredocs 2020-12-31 19:09:38 -08:00
Seeker 4683a196d9 Fix regression for squiggly heredocs 2020-12-31 19:08:44 -08:00
Yukihiro "Matz" Matsumoto 1fbabe207d Merge pull request #5245 from jbampton/for-mruby-for-2021
Update copyright year for 2021
2021-01-01 00:24:53 +09:00
Yukihiro "Matz" Matsumoto db2a7a1e6e Merge pull request #5252 from dearblue/rm-gc_test
Removed unusable `GC.test`
2021-01-01 00:24:12 +09:00
dearblue ae72feb468 Removed unusable GC.test
The substance of the method was removed in commit 15ceb35e05.
2020-12-31 22:22:45 +09:00
Yukihiro "Matz" Matsumoto aabfe31d98 Merge pull request #5250 from shuujii/refine-error-message-from-mrb_get_arg1
Refine error message from `mrb_get_arg1`
2020-12-29 22:44:43 +09:00
KOBAYASHI Shuji 1fae7c0a69 Refine error message from mrb_get_arg1
#### Before this patch:

```console
$ bin/mruby -e '{}.key?'
trace (most recent call last):
-e:1: wrong number of arguments (ArgumentError)
```

#### After this patch:

```console
$ bin/mruby -e '{}.key?'
trace (most recent call last):
-e:1: wrong number of arguments (given 0, expected 1) (ArgumentError)
```
2020-12-29 19:04:19 +09:00
Yukihiro "Matz" Matsumoto d44a1de8f4 Merge pull request #5249 from SeekingMeaning/squiggly-fix-2
Fix mixed indentation and escaped tabs in squiggly heredocs
2020-12-29 13:51:41 +09:00
Seeker 49b01f23a4 Fix mixed indentation and escaped tabs in squiggly heredocs 2020-12-28 18:22:13 -08:00
Yukihiro "Matz" Matsumoto 9b501ab507 Merge pull request #5247 from SeekingMeaning/squiggly-fix
Fix for empty lines in squiggly heredocs
2020-12-28 17:03:52 +09:00
Seeker 3a2ff9824e Fix for empty lines in squiggly heredocs 2020-12-27 23:10:08 -08:00
Yukihiro "Matz" Matsumoto 6d98ae57f2 Merge pull request #5248 from SeekingMeaning/hash-except
Add `Hash#except` [Ruby 3.0]
2020-12-28 15:19:13 +09:00
Seeker 14a92f9705 Add Hash#except [Ruby 3.0] 2020-12-27 16:33:12 -08:00
Yukihiro "Matz" Matsumoto d57d6e2b5b Merge pull request #5246 from SeekingMeaning/squiggly-heredocs
Add support for squiggly heredocs
2020-12-27 20:05:45 +09:00
Seeker 6312a50045 Fix operand types error 2020-12-27 00:20:02 -08:00
Seeker 6491d8dd28 Commit y.tab.c 2020-12-27 00:09:39 -08:00
Seeker 54bfcaf1ff Add support for squiggly heredocs 2020-12-26 23:48:20 -08:00
John Bampton 38de04c4f7 Update copyright year for 2021 2020-12-27 01:11:47 +10:00
Yukihiro "Matz" Matsumoto dad43359cb Merge pull request #5244 from dearblue/eval-nomem
Improves out of memory messages for `eval`
2020-12-26 08:44:08 +09:00
dearblue 88a11d81b0 Improves out of memory messages for eval
The comment says that if `mrb_parse_nstring()` returns `NULL`, it is only out of memory.
I'm worried about compatibility if I set the exception class to `NoMemoryError`, so it's still `RuntimeError`.
2020-12-25 23:24:20 +09:00
Yukihiro "Matz" Matsumoto 825c14a0c5 Reset paren_nest at tAREF and tASET. 2020-12-24 23:30:42 +09:00
Yukihiro "Matz" Matsumoto 2850b58dd9 Check integer overflow in float bit operations. 2020-12-24 23:17:18 +09:00
Yukihiro "Matz" Matsumoto 3419426dbf Avoid division by zero in rational_to_f(). 2020-12-24 23:16:49 +09:00
Yukihiro "Matz" Matsumoto 4e90d6938a Merge pull request #5242 from jbampton/add-codeowners
Create CODEOWNERS file
2020-12-23 15:59:30 +09:00
Yukihiro "Matz" Matsumoto 7f73af079a Merge pull request #5243 from boatrite/add-gba-build-config
Add example for cross-compiling to Nintendo GameBoyAdvance
2020-12-23 15:55:38 +09:00
Gwen Boatrite 3bfafd198c Add example for cross-compiling to Nintendo GameBoyAdvance 2020-12-23 00:26:49 -06:00
Yukihiro "Matz" Matsumoto 0bb4afe942 Fix the integer overflow in mrb_str_len_to_inum(). 2020-12-23 10:35:15 +09:00
John Bampton e96620cd23 Create CODEOWNERS file
- You can use a CODEOWNERS file to define individuals or teams that are responsible for code in a repository.
- Code owners are automatically requested for review when someone opens a pull request that modifies code that they own. Code owners are not automatically requested to review draft pull requests.
- https://docs.github.com/en/free-pro-team@latest/github/creating-cloning-and-archiving-repositories/about-code-owners
- This creates a bit more automation so that after you merge this PR, next time someone submits a PR @matz will be automatically assigned as the PR reviewer as CODEOWNER
- CODEOWNERS can even be assigned directories or file types
2020-12-22 16:09:41 +10:00
Yukihiro "Matz" Matsumoto 8b2fd45d46 Merge pull request #5239 from jbampton/fix-links
refactor: fix Rake link and fix missing HTTPS on links
2020-12-21 23:11:40 +09:00
dearblue 6c1c2041ef Take advantage of gembox
I think that it is easy to use if it is divided according to the type of library and the general purpose.
It is a subdivision from the previous `default.gembox`.

By type gembox:
- `stdlib`: Add some standard Ruby methods not provided by core.
- `stdlib-ext`: Add some standard Ruby methods that are not provided by `stdlib`.
- `stdlib-io`: Provides `IO`, `File`, `Socket`, `print`, etc. Conflict with `MRB_NO_STDIO`
- `math`: Add a class related to math. Conflict with `MRB_NO_FLOAT`
- `metaprog`: Adds features related to metaprogramming.

Purpose gembox:
- `default.gembox`: Import the same gems as before
- `default-no-stdio.gembox`: Import the` stdlib` and `math`
- `default-no-fpu.gembox`: Import the` stdlib` only
2020-12-21 21:48:50 +09:00
John Bampton 16cb81c727 refactor: fix Rake link and fix missing HTTPS on links 2020-12-21 18:46:38 +10:00
Yukihiro "Matz" Matsumoto 788ee38bdf Merge pull request #5238 from shuujii/fix-typo-in-.github-workflows-build.yml
Fix typo in `.github/workflows/build.yml` [skip travis][skip appveyor]
2020-12-21 17:07:20 +09:00
KOBAYASHI Shuji 366780f0bc Fix typo in .github/workflows/build.yml [skip travis][skip appveyor] 2020-12-21 16:12:02 +09:00
Yukihiro "Matz" Matsumoto 3069299200 Merge pull request #5237 from shuujii/use-git-ls-files-instead-of-find-to-avoid-including-.git
Use `git ls-files` instead of `find` in `spell-checker.yml` [ci skip]
2020-12-21 08:33:42 +09:00
KOBAYASHI Shuji 01a6cdb882 Use git ls-files instead of find in spell-checker.yml [ci skip]
To avoid including `.git` directory.
2020-12-20 22:52:33 +09:00
Yukihiro "Matz" Matsumoto a65c33c487 Merge pull request #5236 from shuujii/reorganize-GitHub-Actions-configuration
Reorganize GitHub Actions configuration [skip travis][skip appveyor]
2020-12-20 18:13:48 +09:00
Yukihiro "Matz" Matsumoto 5337e9375c Merge pull request #5235 from jbampton/fix-link-and-fix-word-case
refactor: fix case of GitHub and fix missing HTTPS on link
2020-12-20 18:12:23 +09:00
KOBAYASHI Shuji 74e1d1ea02 Reorganize GitHub Actions configuration [skip travis][skip appveyor]
* Skip if commit message contains `ci skip`, `skip ci`, or `skip gha`
  ENCLOSED WITH BRACKETS (excluding lint job).
* Separate build and test. This is because builds can be run in parallel,
  but running tests in parallel can cause logs to get mixed up or not
  finished.
* Don't use Chocolatey because it seems to take 1-2 minutes to start up.
* Use the cache better.
* Use `actions/checkout@v2` instead of `actions/checkout@v1`.
* Remove unnecessary package installation.
* Remove unnecessary flag settings.
* Remove `-j` for rake because it doesn't seem to have any effect.
* Rename `main.yml` to `oss-fuzz.yml` to clarify.
2020-12-20 15:31:15 +09:00
John Bampton 68af0cca65 refactor: fix case of GitHub and fix missing HTTPS on link
- changed `github` to `GitHub`
2020-12-19 23:55:10 +10:00
Yukihiro "Matz" Matsumoto a528312542 Merge pull request #5234 from jbampton/remove-whitespace
refactor: remove trailing whitespace
2020-12-19 22:44:23 +09:00
Yukihiro "Matz" Matsumoto c17f1be52a Merge pull request #5233 from jbampton/update-authors
Add my name to the AUTHORS file
2020-12-19 22:43:58 +09:00
John Bampton bc90635e83 refactor: remove trailing whitespace 2020-12-19 22:37:47 +10:00
John Bampton 2a42cc2d69 Add my name to the AUTHORS file 2020-12-19 20:28:17 +10:00
Yukihiro "Matz" Matsumoto 8f06789cb3 Merge pull request #5232 from jbampton/lint-markdown
feat(CI): add a GitHub Action to lint the Markdown
2020-12-19 17:31:54 +09:00
Yukihiro "Matz" Matsumoto fcc9b7fc2a Merge pull request #5230 from dearblue/mruby-config.2
Ignore `mruby-bin-config` in cross-building
2020-12-19 17:28:53 +09:00
John Bampton 97eed4493f feat(CI): add a GitHub Action to lint the Markdown
Run on pull request only
Using https://www.npmjs.com/package/markdownlint-cli
Lint Markdown for rules:
- MD009/no-trailing-spaces
- MD012/no-multiple-blanks
- MD022/blanks-around-headings
- MD031/blanks-around-fences
- MD032/blanks-around-lists
2020-12-19 18:22:08 +10:00
Yukihiro "Matz" Matsumoto 340f1f0094 Merge pull request #5231 from jbampton/fix-links
🔒 Fix missing HTTPS on links
2020-12-19 16:59:11 +09:00
John Bampton 6f6149509a 🔒 Fix missing HTTPS on links 2020-12-19 17:52:16 +10:00
Yukihiro "Matz" Matsumoto 563ebbf083 Merge pull request #5229 from jbampton/fix-links
🔒 Fix missing HTTPS on links
2020-12-19 16:42:40 +09:00
John Bampton f7c5c00d6e 🔒 Fix missing HTTPS on links 2020-12-19 17:36:39 +10:00
dearblue 36376eba5f Warn that it was ignored in crossbuild 2020-12-19 15:53:01 +09:00
dearblue db1b78820d Avoid using MRuby::CrossBuild.current
This is because `MRuby::Build.currrent` and `MRuby::CrossBuild.current` are assignments to different instance variables.
2020-12-19 15:53:01 +09:00
Yukihiro "Matz" Matsumoto 08d4365252 Merge pull request #5228 from jbampton/spell-checker
feat(CI): add a GitHub Action to check spelling
2020-12-18 23:43:11 +09:00
John Bampton d21d5993b9 feat(CI): add a GitHub Action to check spelling
- Fix spelling
- Run only on pull request
- Using https://github.com/client9/misspell
2020-12-17 16:22:31 +10:00
Yukihiro "Matz" Matsumoto fbe5033f80 Merge pull request #5224 from jbampton/lint-yaml
feat(CI): add a GitHub Action to lint the YAML
2020-12-16 22:26:21 +09:00
Yukihiro "Matz" Matsumoto 8f8e832767 Merge pull request #5227 from shuujii/rename-build-configuration-files-for-CI
Rename build configuration files for CI
2020-12-16 22:25:58 +09:00
KOBAYASHI Shuji d432688d9f Rename build configuration files for CI
Currently, there are build configuration files for CI, `travis.rb` and
`appveyor.rb`, but they are used for GCC/Clang and MSVC, not for Travis CI
and Appveyor, respectively.

Therefore, rename them to `gcc-clang.rb` and `msvc.rb`, respectively, and
move them under `build_config/ci/` to clarify that they are for CI.
2020-12-16 21:56:32 +09:00
Yukihiro "Matz" Matsumoto 1b7197622f Merge pull request #5226 from shuujii/guess-toolchain-when-MRubyBuild-toolchain-argument-is-omitted
Guess toolchain when `MRuby::Build#toolchain` argument is omitted
2020-12-16 20:25:35 +09:00
KOBAYASHI Shuji 0396f3f0fd Guess toolchain when MRuby::Build#toolchain argument is omitted 2020-12-16 19:17:44 +09:00
John Bampton aa6fc8c38e feat(CI): add a GitHub Action to lint the YAML
- Run only on pull request
- Add a `.yamllint` config file
- Lint YAML
2020-12-15 23:39:36 +10:00
Yukihiro "Matz" Matsumoto c1c8c25e70 Merge pull request #5223 from shuujii/ensure-initialization-of-RVALUE_zero-in-mrb_obj_alloc
Ensure initialization of `RVALUE_zero` in `mrb_obj_alloc`
2020-12-15 22:32:32 +09:00
Yukihiro "Matz" Matsumoto aec8eba076 Merge pull request #5225 from shuujii/output-build-log-at-the-time-of-installation
Output build log at the time of installation
2020-12-15 22:31:26 +09:00
Yukihiro "Matz" Matsumoto 2f177dcd72 Merge pull request #5222 from jbampton/remove-trailing-whitespace
refactor: remove trailing whitespace from C, Header, Ruby and YAML files
2020-12-15 22:30:38 +09:00
KOBAYASHI Shuji c6364edd96 Output build log at the time of installation 2020-12-15 21:54:19 +09:00
John Bampton 4fa3359d44 refactor: remove trailing whitespace from C, Header, Ruby and YAML files
Lint
2020-12-15 19:44:02 +10:00
KOBAYASHI Shuji d5cb54d4df Ensure initialization of RVALUE_zero in mrb_obj_alloc
Union initialization initializes the first member. The first member of
`RVALUE` is `struct free_obj`, but because it is only 4-words, it seems that
initialization after the 5th word is not ensured.

Therefore, I created 6-words `struct RVALUE_initializer` for initialization
and made it the first member.
2020-12-15 17:48:06 +09:00
Yukihiro "Matz" Matsumoto e9fe337b95 Merge pull request #5221 from jbampton/fix-spelling
Fix spelling
2020-12-13 23:36:18 +09:00
John Bampton 940dec5e7d Fix spelling 2020-12-13 18:38:22 +10:00
KOBAYASHI Shuji 456878ba06 Improve source scanning for presym
The accuracy is greatly improved by using the C preprocessor to scan C
sources for presym. C preprocessor can perfectly interpret all comments and
preprocessor directives, so it can detect all symbols defined, for example
`mrbgems/mruby-socket/src/const.cstub`.

Also, as described later, this change will greatly improve the accuracy of
presym detection from Ruby sources.

## Result

The number of lines in the `presym` file for all gems is as follows:

  ```console
  Previous:   999 (false positive = 89, undetected = 297)
  New:       1207
  ```

## Build process

The new build process (with presym) is as follows:

1. Build `mrbc` without presym (more on building without presym later).
2. Compile Ruby sources to C struct format with the `mrbc` created in
   step 1, and create` mrblib.c` and `gem_init.c`. Note that the symbols
   in the created files are output as `MRB_SYM` family macros or
   `mrb_intern_lit` instead of IDs (details will be described later).
3. C preprocessor processes C sources including the created files of
   step 2 and outputs them as `.i` files. In these files, for example,
   `MRB_IVSYM(foo)` is converted to `<@! "@" "foo" !@>` and
   `mrb_define_module(mrb, "Foo")` is converted to `<@! "Foo" !@>`.
4. Scan the files created in step 3 and create `presym` and` presym.inc`
   files.

The files created in step 2 should output all static symbols defined in Ruby
sources, including local variables, so we can detect all presyms by just
scanning C sources without scanning Ruby sources directly.

Further, by this process, the files to be scanned becomes the same as the
files to be compiled, so that there is no excess or deficiency.

## Related changes

The following changes have been made in relation to realizing this feature.

### Allow build without presym

It enables build without presym to achieve the "Build process: 1". This
incorporates #5202, see its issue for details.

Note that when presym is enabled, even adding a local variable to a Ruby
source may change contents of presym and require recompilation of almost
all C sources. This is inconvenient, especially during trial and error in
development, but this feature is also useful because it does not cause
this problem if presym is disabled.

### Automatically create build target for `mrbc` without presym

The `mrbc` used in the "Build process: 1" will be built by automatically
creating a build target for it. The build name is `SOURCE_BUILD_NAME/mrbc`.

### Constantize output of C struct format by `mrbc`

To realizing the "Build process: 2", as mentioned above, symbol IDs are not
output directly in C struct format output by `mrbc`. As a result, the output
becomes constant regardless of the state of presym at the time of `mrbc`
build, and it is possible to detect symbols of Ruby sources in the same way
as other C sources.

Note that `mrb_intern_lit` is used for symbols that do not become presym,
but in this state, the corresponding element in the symbol array cannot be
statically initialized, so it is initialized at run time (therefore, in this
case, the `const` qualifier is not added to the symbol array).

### Specify arbitrary `mrbc` file

To realizing the "Build process: 2", enabled to specify `mrbc` created by
another build target or pre-built` mrbc`. Use `MRuby::Build#mrbcfile =` to
specify it explicitly. You can omit the "Build process: 1" by specifying
pre-built `mrbc`, and you can always use an optimized build to compile Ruby
sources faster. I think changes that affect the output of `mrbc` are rare,
so in many cases it helps to improve efficiency.

With presym, the build will be a little slower due to more build steps, but
this feature will improve it a bit.

### Create presym files for each build target

This feature was proposed at #5194 and merged once, but was reverted in
5c205e6e due to problems especially with cross-compilation. It has been
introduced again because this change solves the problem.

The presym files will be created below.

* `build/NAME/presym`
* `build/NAME/include/mruby/presym.inc`

### Other changes

* Because presym detection accuracy is greatly improved as mentioned above,
  `MRuby::Gem::Specification#cdump?` is set to true by default, and
  `disable_cdump` is added instead of `enable_cdump`. Also, support for gem
  specific presym files has been discontinued (https://github.com/mruby/mruby/issues/5151#issuecomment-730967232).
* Previously, `mrbc` was automatically created for the `host` build, but it
  will not be created if the build target for `mrbc` mentioned above is
  automatically created. At this time, `mrbc` file of the `mrbc` build is
  copied to` bin/`.
* Two types of `.d` files will be created, `.o.d` and `.i.d`. oThis is
  because if `.i` depends on `presym.inc`, the dependency will circulate, so
  the `.d` file cannot be shared.
* Changed file created with `enable_cxx_exception` to `X-cxx.cxx` from
  `X.cxx` to use the mruby standard Rake rule.

### Note

Almost all C sources will need to be recompiled if there are any changes to
`persym.inc` (if not recompiled properly, it will often result in run-time
error). If `gcc` toolchain is used, dependencies are resolved by the `.d`
file, so it become automatically recompile target, but if not (e.g. MSVC),
it is necessary to manually make it recompile target.

Also, even if `gcc` toolchain is used, it may not become recompile target if
external gems does not use the mruby standard Rake rule. In particular, if
the standard rule is overwritten, such as
https://github.com/mruby/mruby/pull/5112/files, `.d` file will not be read,
so be careful.
2020-12-13 15:27:53 +09:00
Yukihiro "Matz" Matsumoto 116e128b1a Remove positive check for unsigned integer; close #5218 2020-12-12 18:25:47 +09:00
Yukihiro "Matz" Matsumoto 092dd4a667 Argument forwarding with ... now supports leading arguments.
```ruby
def method_missing(meth, ...)
  send(:"do_#{meth}", ...)
end
```
2020-12-09 11:56:54 +09:00
Yukihiro "Matz" Matsumoto 2e9b8f0d9b Fix a bug caused by tBDOT3 (argument forwarding). 2020-12-08 22:01:47 +09:00
Yukihiro "Matz" Matsumoto ed29d74bfd Make type of pc arguments in debug.c consistent; close #5218
They used to be `size_t`, `uint32_t` and `ptrdiff_t`. Now all of them
made to be `uint32_t`.
2020-12-07 13:59:00 +09:00
Yukihiro "Matz" Matsumoto 8b52c67be9 Merge pull request #5217 from shuujii/call-super-before-creating-host-build-in-MRubyCrossBuild-initialize
Call `super` before creating `host` build in `MRuby::CrossBuild#initialize`
2020-12-06 17:30:34 +09:00
KOBAYASHI Shuji de03e97a50 Call super before creating host build in MRuby::CrossBuild#initialize
Call `super` (`block`) ahead so that creation of the `host` build can be
skipped if pre-built `mrbc` can be specified in the future.

close #5213.
2020-12-06 15:14:09 +09:00
Yukihiro "Matz" Matsumoto 9e41ae4909 Merge pull request #5214 from shuujii/allow-obsoluted-MRB_METHOD_T_STRUCT
Allow obsoluted `MRB_METHOD_T_STRUCT`
2020-12-05 22:22:18 +09:00
Yukihiro "Matz" Matsumoto 9cffacdf0d Merge pull request #5216 from shuujii/remove-unused-@endian-in-MRubyCrossBuild-initialize
Remove unused `@endian` in `MRuby::CrossBuild#initialize`
2020-12-05 22:20:11 +09:00
Yukihiro "Matz" Matsumoto 1b6efeef57 Merge pull request #5215 from shuujii/update-Configuration-Options-Changed-in-doc-mruby3.md
Update "Configuration Options Changed" in `doc/mruby3.md` [ci skip]
2020-12-05 22:19:41 +09:00
KOBAYASHI Shuji 07668b067b Remove unused @endian in MRuby::CrossBuild#initialize 2020-12-05 19:52:07 +09:00
KOBAYASHI Shuji f84668f8d5 Update "Configuration Options Changed" in doc/mruby3.md [ci skip] 2020-12-05 19:26:38 +09:00
KOBAYASHI Shuji 58ef897696 Allow obsoluted MRB_METHOD_T_STRUCT 2020-12-05 17:37:39 +09:00
Yukihiro "Matz" Matsumoto 6e5a0f623f Fixed a memory leak bug on codegen_error() when irep->rlen>255. 2020-12-05 15:28:58 +09:00
Yukihiro "Matz" Matsumoto 63d82142a8 Merge pull request #5212 from shuujii/make-it-possible-that-libmruby.a-is-not-created
Make it possible that `libmruby.a` is not created
2020-12-05 14:08:29 +09:00
KOBAYASHI Shuji 73b4152574 Make it possible that libmruby.a is not created
Previously, `libmruby.a` was created even if only `mruby-bin-mrbc` or`
mruby-compiler` was specified for gem, but by specifying `disable_libmruby`,
the creation of `libmruby.a` can be suppressed.

### Note

The https://github.com/mruby/mruby/pull/5084#issuecomment-723521971
incompatibility seems to be difficult for users to avoid, so the original
behavior has been restored. Therefore, if we need `mrbc` other than the
`host` build, we need to explicitly specify `mruby-bin-mrbc` gem.

Due to the above changes, `build_config/boxing.rb` etc. will not work, but I
have added` mruby-bin-mrbc` to `default.gembox` to fix it. I don't think
this change is a big deal because originally `mruby-compiler` was included.
2020-12-05 09:16:08 +09:00
Yukihiro "Matz" Matsumoto 00d1fd0e6f Fixed a bug with modules prepended many times.
Adjust insertion point in `fix_prepend_module()`.
2020-12-05 08:01:05 +09:00
Yukihiro "Matz" Matsumoto 3972df57fe Make Module#include and Module#prepend behave like Ruby3.0.
Module#include and Module#prepend now affect classes and modules
that have already included or prepended the receiver, mirroring the
behavior if the arguments were included in the receiver before
the other modules and classes included or prepended the receiver.

```ruby
class C; end
module M1; end
module M2; end
C.include M1
M1.include M2
p C.ancestors #=> [C, M1, M2, Object, Kernel, BasicObject]
```
2020-12-04 22:02:37 +09:00
Yukihiro "Matz" Matsumoto 4cd3493737 Merge pull request #5211 from shuujii/move-mrbc-test-to-mruby-bin-mrbc-gem-from-mruby-compiler-gem
Move `mrbc` test to `mruby-bin-mrbc` gem from `mruby-compiler` gem
2020-12-04 12:50:48 +09:00
KOBAYASHI Shuji 4452041ebb Move mrbc test to mruby-bin-mrbc gem from mruby-compiler gem 2020-12-04 09:22:13 +09:00
Yukihiro "Matz" Matsumoto f6ad163841 Merge pull request #5209 from shuujii/remove-build-presym.inc-by-rake-clean
Remove `build/presym{,.inc}` by `rake clean` [ci skip]
2020-12-03 07:17:37 +09:00
KOBAYASHI Shuji e1fa01b9c8 Remove build/presym{,.inc} by rake clean [ci skip]
Currently, adding gems to build configuration and rebuilding does not
regenerate `presym`, which can lead to build errors.

Therefore in this case we need to remove the `presym` file and then rebuild
mruby, but when the` presym` file is regenerated we will need to recompile
most of the files, so it seems useful to have the `presym` file deleted by
`rake clean`.
2020-12-02 23:15:29 +09:00
Yukihiro "Matz" Matsumoto 42f33fd51a Merge pull request #5208 from shuujii/fix-build-for-C++11-when-enable_cxx_exception
Fix build for C++ version >= C++11 when `enable_cxx_exception`; close #5199
2020-12-02 21:35:21 +09:00
KOBAYASHI Shuji 00df809609 Fix build for C++ version >= C++11 when enable_cxx_exception; close #5199 2020-12-02 19:15:42 +09:00
Yukihiro "Matz" Matsumoto 661081a072 Merge pull request #5198 from shuujii/remove-unused-Rake-rules
Remove unused Rake rules
2020-12-02 11:07:37 +09:00
Yukihiro "Matz" Matsumoto 504b731af6 Use JMPLINK_START instead of zero for a link start marker. 2020-12-02 09:48:08 +09:00
Yukihiro "Matz" Matsumoto affb18b85b Remove assertions to check catch handler offset to be in 16bits. 2020-12-02 09:47:13 +09:00
Yukihiro "Matz" Matsumoto 826fe1bc36 Fixed memory leaks from codegen_error. 2020-12-02 09:46:08 +09:00
Yukihiro "Matz" Matsumoto dd0715fd58 Print implicit operands for some instructions. 2020-12-02 09:44:34 +09:00
Yukihiro "Matz" Matsumoto 25985876b8 Remove a newline. 2020-12-02 09:44:07 +09:00
Yukihiro "Matz" Matsumoto 9ba0ebec0e Fix a `OP_JMP bug from 0 marker and address 0. 2020-12-01 16:48:24 +09:00
Yukihiro "Matz" Matsumoto a7d84382f8 Merge pull request #5207 from shuujii/revert-Create-presym-files-for-each-build-target
Revert "Create presym files for each build target" (58ba883e)
2020-12-01 16:46:19 +09:00
KOBAYASHI Shuji 5c205e6ea1 Revert "Create presym files for each build target" (58ba883e)
Due to the above changes, it may not work with the existing build
configurations in cross-compilation (even if we can build without presym),
therefore revert it once (ref https://github.com/mruby/mruby/pull/5202#issuecomment-735412643). Sorry for the lack of consideration.
2020-12-01 12:16:55 +09:00
Yukihiro "Matz" Matsumoto 98d5aa8d74 Fix OP_JMPUW address bug. 2020-12-01 00:25:09 +09:00
Yukihiro "Matz" Matsumoto 1c361f8a22 Merge pull request #5206 from dearblue/dumpirep
Improves dump irep
2020-11-30 23:21:19 +09:00
Yukihiro "Matz" Matsumoto d56db2296d Merge pull request #5205 from dearblue/codedump
Fixed print catch handler address in codedump; ref #5200
2020-11-30 23:19:59 +09:00
dearblue 3bc9453c9a Integrate the output of the catch handler table into iseq
Alleviates confusingness.

ref #5203
2020-11-30 22:56:59 +09:00
dearblue a56b601f56 Fixed irep size measurement by dump; ref #5203 2020-11-30 22:56:41 +09:00
dearblue 0ecb0fd97b Fixed print catch handler address in codedump; ref #5200
It became 32 bits in #5200, but only the upper 16 bits were printed.
2020-11-30 22:36:26 +09:00
Yukihiro "Matz" Matsumoto 9f5c0777f1 Merge pull request #5204 from shuujii/use-MRB_SYM-in-src-gc.c
Use `MRB_SYM` in `src/gc.c`
2020-11-29 20:15:48 +09:00
KOBAYASHI Shuji 82f3e4d31b Use MRB_SYM in src/gc.c 2020-11-29 19:01:48 +09:00
Yukihiro "Matz" Matsumoto d4439479cf Merge pull request #5203 from komainu8/fix-heap-buffer-overflow
Fix heap buffer overflow when dump irep
2020-11-29 16:24:30 +09:00
Horimoto Yasuhiro df13d418c3 Fix heap buffer overflow when dump irep
Currently, the size of writing in heap by write_irep_record() is
bigger than The size that is calculated by get_irep_record_size.

Therefore, irep is dumped over the size of allocating memory when we
execute dump_irep().
2020-11-29 15:57:44 +09:00
Yukihiro "Matz" Matsumoto c6071335a1 Merge pull request #5200 from dearblue/catchhandler32
Change the catch handler address to 32 bits
2020-11-29 14:50:22 +09:00
dearblue b0cea30f32 Change the catch handler address to 32 bits
Follow commit 7150c67539 .
2020-11-29 13:48:45 +09:00
KOBAYASHI Shuji 8da2c11243 Remove unused Rake rules
Currently, the source file language in the core is C only, and C++,
Objective-C, and Assembly are not used, so Rake rules for them are removed.
2020-11-28 12:38:46 +09:00
Yukihiro "Matz" Matsumoto 6d07d9b3d7 Merge pull request #5197 from shuujii/fix-incorrect-regexp-creation-in-tasks-presym.rake
Fix incorrect regexp creation in `tasks/presym.rake`
2020-11-27 22:08:25 +09:00
KOBAYASHI Shuji cb7eb202ce Fix incorrect regexp creation in tasks/presym.rake 2020-11-27 20:07:16 +09:00
Yukihiro "Matz" Matsumoto 6059834244 Merge pull request #5196 from shuujii/fix-build-failure
Fix build failure; ref #5194
2020-11-27 08:57:03 +09:00
KOBAYASHI Shuji fdce0e712b Fix build failure; ref #5194
Fix the following two issues:

1. Compile failure when external gem is specified.
   * https://github.com/mruby/mruby/pull/5194#issuecomment-734303442
2. When there are multiple build targets, presym parsing sometimes fails or
   output result of presym is broken.
   * https://github.com/mruby/mruby/pull/5194#issuecomment-734322142

The root cause of 2 is unknown, but it seems to occur when presym parsing is
performed in parallel, therefore I change them so that they are not run in
parallel.
2020-11-27 07:59:57 +09:00
Yukihiro "Matz" Matsumoto 13fc503434 Merge pull request #5195 from shuujii/add-tools-to-target-directory-for-presym-parsing
Add `tools/*` to target directory for presym parsing
2020-11-26 22:47:22 +09:00
KOBAYASHI Shuji 0cb3a7186c Add tools/* to target directory for presym parsing 2020-11-26 22:05:59 +09:00
Yukihiro "Matz" Matsumoto 521c16d738 Merge pull request #5194 from shuujii/create-presym-files-for-each-build-target
Create presym files for each build target
2020-11-26 21:17:47 +09:00
Yukihiro "Matz" Matsumoto 7f5e257f77 Use __builtin_setjmp(), __builtin_longjmp() on MinGW; fix #5133 2020-11-26 20:48:26 +09:00
Yukihiro "Matz" Matsumoto e0b8876640 Avoid integer overflow in rational_new. 2020-11-26 20:48:25 +09:00
KOBAYASHI Shuji 58ba883ee9 Create presym files for each build target
Previously, presym files were always created in `build/{presym,presym.inc}`.
However, this constraint is inconvenient because it is common to use
multiple build configurations and build targets in a single mruby tree.
Therefore, change to create presym file for each build target.
2020-11-26 19:05:07 +09:00
Yukihiro "Matz" Matsumoto 79af3f30b4 Merge pull request #5193 from shuujii/fix-loop-condition-in-mrb_sym_all_symbols
Fix loop condition in `mrb_sym_all_symbols`
2020-11-26 14:20:11 +09:00
KOBAYASHI Shuji 3c63d38058 Fix loop condition in mrb_sym_all_symbols 2020-11-26 13:47:45 +09:00
Yukihiro "Matz" Matsumoto 63d4e8eca2 Fix a bug in find_symbol(); fix #5192 2020-11-26 13:18:45 +09:00
Yukihiro "Matz" Matsumoto 7150c67539 Make OP_JMP* operand address to be relative.
Jump target address is `operand (16bit)` + `address of next instruction`.

In addition, `ilen` was made `uint32_t` so that `iseq` length limitation
of 65536 is removed. Only jump target address should be within signed
16bit (-32768 .. 32767).
2020-11-26 10:34:31 +09:00
Yukihiro "Matz" Matsumoto 6dedd6a940 Fix Symbol.all_symbols to include preallocated symbols; ref #5116 2020-11-26 10:33:15 +09:00
Yukihiro "Matz" Matsumoto 66f2e733e5 Symbols should work with MRB_USE_ALL_SYMBOLS; fix #5116 2020-11-26 10:32:19 +09:00
Yukihiro "Matz" Matsumoto a33f9d7b65 Small refactoring regarding symbols for clarity. 2020-11-26 09:42:08 +09:00
Yukihiro "Matz" Matsumoto 50b57f6ff1 Include mruby.h instead of mrbconf.h directly. 2020-11-26 09:14:12 +09:00
Yukihiro "Matz" Matsumoto 2daf1987f9 Avoid memory leak when mrb_read_irep() fails. 2020-11-26 09:04:30 +09:00
Yukihiro "Matz" Matsumoto 71f9add1c5 Move inline iseq in array.c to array.rb.
There's no efficiency difference since `cdump` is implemented.
2020-11-25 23:14:38 +09:00
Yukihiro "Matz" Matsumoto fba7874a68 Replace mere enable_debug by clearer conf.enable_debug [ci skip] 2020-11-25 21:42:10 +09:00
Yukihiro "Matz" Matsumoto 6e17122c6d Merge pull request #5190 from shuujii/allow-compiler-name-in-build-log-to-be-customized
Allow compiler name in build log to be customized
2020-11-25 15:31:39 +09:00
KOBAYASHI Shuji 038bad2f41 Allow compiler name in build log to be customized
For example, in the case of the C++ compiler, it is output as
`CXX  build/host/src/gc.cxx -> build/host/src/gc.cxx.o` (FYI, in the case
of `enable_cxx_abi`, it outputs `CC ...` because the option to compile as
C++ is added to C compiler).
2020-11-25 15:11:36 +09:00
Yukihiro "Matz" Matsumoto 6a284872ce Merge pull request #5189 from shuujii/fix-C-source-compilation-with-MRB_USE_ALL_SYMBOLS
Fix C source compilation with `MRB_USE_ALL_SYMBOLS`; ref #5187
2020-11-25 14:33:03 +09:00
KOBAYASHI Shuji a7b50be35b Fix C source compilation with MRB_USE_ALL_SYMBOLS; ref #5187
However, compiling by `mrbc` fails with another issue (#5116).
2020-11-25 10:17:52 +09:00
Yukihiro "Matz" Matsumoto fc98aa290f Remove no longer used `MRB_IV_SEGMENT_SIZE; close #5188 [ci skip] 2020-11-25 08:31:10 +09:00
Yukihiro "Matz" Matsumoto 40235f3050 Use more mrb_int_value() instead of mrb_fixnum_value(). 2020-11-24 20:52:25 +09:00
Yukihiro "Matz" Matsumoto 2e30c68562 Move MRB_NO_FLOAT detection in mruby-math; #5185 2020-11-24 20:43:56 +09:00
Yukihiro "Matz" Matsumoto 4d21a68d35 Add #include <mrbconf.h> at the head of fmt_fp.c; #5185 2020-11-24 20:01:24 +09:00
Yukihiro "Matz" Matsumoto 9e114fc913 Merge pull request #5186 from shuujii/optimize-presym_find
Optimize `presym_find`
2020-11-24 16:58:09 +09:00
Yukihiro "Matz" Matsumoto e55abd2390 Fix compiler errors from MRB_NO_FLOAT; #5185
Also added `no-float.rb` target in `build_config`.
2020-11-24 16:54:39 +09:00
KOBAYASHI Shuji db00fb238b Optimize presym_find
Chang to compare string length first.

### Benchmark

#### Code

* https://github.com/shuujii/mruby-presym_find-benchmark

#### Result

```console
Previous: 10.240772M i/s (25M times in 2.441222s)
     New: 16.412985M i/s (25M times in 1.523184s)
```
2020-11-24 16:30:52 +09:00
Yukihiro "Matz" Matsumoto 36e3c4404a Should not use mrb_float if MRB_NO_FLOAT is defined; fix #5185 2020-11-24 13:50:15 +09:00
Yukihiro "Matz" Matsumoto 67f3626b5c Merge pull request #5178 from abinoam/fix_mruby_config_setting
Fix #5177 by setting MRUBY_CONFIG early
2020-11-24 09:44:21 +09:00
Abinoam Praxedes Marques Junior 4803c872e2 Fix #5177 - set MRUBY_CONFIG early 2020-11-23 15:18:22 -03:00
Yukihiro "Matz" Matsumoto e4e4eeb0c3 Merge pull request #5184 from dearblue/embedded-directive
Avoid warnings from clang's "-Wembedded-directive"
2020-11-23 22:07:48 +09:00
dearblue 3a92a4e3d8 Avoid warnings from clang's "-Wembedded-directive"
If it gives clang-11.0 `-Wembedded-directive`, a warning will be reported in `include/mruby/boxing_nan.h`.

```
include/mruby/boxing_nan.h:48:2: warning: embedding a directive within macro arguments has undefined behavior [-Wembedded-directive]
include/mruby/boxing_nan.h:52:2: warning: embedding a directive within macro arguments has undefined behavior [-Wembedded-directive]
```

The cause of this is #5117.
ref. e993b83c50
2020-11-23 21:22:50 +09:00
Yukihiro "Matz" Matsumoto 6f53e2c059 Merge pull request #5180 from wataash/fix-unintended-variable-shadowing
Fix unintended variable shadowing
2020-11-23 17:05:27 +09:00
Yukihiro "Matz" Matsumoto c6c0b796e1 Merge pull request #5181 from shuujii/raise-an-exception-instead-of-exiting-when-mrbc-fails
Raise an exception instead of exiting when `mrbc` fails
2020-11-23 17:02:44 +09:00
Yukihiro "Matz" Matsumoto b1ee892818 Merge pull request #5183 from shuujii/change-output-condition-in-_pp
Change output condition in `_pp`
2020-11-23 17:01:59 +09:00
Yukihiro "Matz" Matsumoto e6b06eafb3 Merge pull request #5182 from shuujii/use-local-variables-instead-of-top-level-constants-in-boxing.rb
Use local variables instead of top level constants in `boxing.rb` [ci skip]
2020-11-23 17:01:01 +09:00
KOBAYASHI Shuji 2f85290065 Change output condition in _pp
* Output even with `rake -v` (to help debugging)
* Not output when `rake -s`
2020-11-23 16:50:15 +09:00
KOBAYASHI Shuji 0d8b1eaee5 Use local variables instead of top level constants in boxing.rb [ci skip] 2020-11-23 16:35:36 +09:00
KOBAYASHI Shuji 2b0f908017 Raise an exception instead of exiting when mrbc fails 2020-11-23 16:32:10 +09:00
Wataru Ashihara 01dc2265ff Fix unintended variable shadowing 2020-11-23 14:48:14 +09:00
Yukihiro "Matz" Matsumoto 39a11f323e Remove mrb_str_buf_new() and MRB_STR_BUF_MIN_SIZE; close #5171 2020-11-22 22:54:21 +09:00
Yukihiro "Matz" Matsumoto abdd006df3 Strictly speaking NULL + 0 is a undefined behavior; ref #5157 2020-11-22 22:44:22 +09:00
Yukihiro "Matz" Matsumoto 2d9bf22730 Merge pull request #5173 from shuujii/refine-build-log-for-generated-files
Refine build log for generated files
2020-11-22 22:38:33 +09:00
Yukihiro "Matz" Matsumoto 17532874a8 Merge pull request #5174 from dearblue/doc
Add brief explanation about `bin/mruby`; ref #5157 [ci skip]
2020-11-22 22:37:29 +09:00
dearblue a67b88e223 Add brief explanation about bin/mruby; ref #5157 [ci skip] 2020-11-22 20:49:59 +09:00
KOBAYASHI Shuji 2a97e97db4 Refine build log for generated files
* Output `GEN` log for generated files
* `MRBC` log is outputted one for each `mrbc` execution

#### Before this patch:

```console
CC    src/array.c -> build/host/src/array.o
(snip)
GEN   mrblib/*.rb -> build/host/mrblib/mrblib.c
      MRBC mrblib/00class.rb
      MRBC mrblib/10error.rb
(snip)
CC    mrbgems/mruby-time/src/time.c -> build/host/mrbgems/mruby-time/src/time.o
      MRBC mrbgems/mruby-time/mrblib/time.rb
(snip)
CC    mrbgems/mruby-socket/test/sockettest.c -> build/host/mrbgems/mruby-socket/test/sockettest.o
      MRBC mrbgems/mruby-socket/test/addrinfo.rb
      MRBC mrbgems/mruby-socket/test/basicsocket.rb
(snip)
```

#### After this patch:

```console
GEN   build/presym
GEN   build/presym.inc
CC    src/array.c -> build/host/src/array.o
(snip)
GEN   mrblib/*.rb -> build/host/mrblib/mrblib.c
      MRBC mrblib/00class.rb
           mrblib/10error.rb
(snip)
CC    mrbgems/mruby-time/src/time.c -> build/host/mrbgems/mruby-time/src/time.o
GEN   build/host/mrbgems/mruby-time/gem_init.c
      MRBC mrbgems/mruby-time/mrblib/time.rb
(snip)
CC    mrbgems/mruby-socket/test/sockettest.c -> build/host/mrbgems/mruby-socket/test/sockettest.o
GEN   build/host/mrbgems/mruby-socket/gem_test.c
      MRBC mrbgems/mruby-socket/test/addrinfo.rb
      MRBC mrbgems/mruby-socket/test/basicsocket.rb
(snip)
```
2020-11-22 20:31:01 +09:00
Yukihiro "Matz" Matsumoto 76b036a627 Merge pull request #5172 from shuujii/move-global-function-for-build-to-lib-mruby-core_ext.rb
Move global function for build to `lib/mruby/core_ext.rb`
2020-11-22 18:03:29 +09:00
Yukihiro "Matz" Matsumoto ac2dfa8c47 Merge pull request #5170 from dearblue/gcmark
Fix GC mark leaks for `MRB_TT_BREAK`; fix #5168
2020-11-22 18:00:53 +09:00
KOBAYASHI Shuji 1c7a1926a3 Move global function for build to lib/mruby/core_ext.rb
Because `_pp` is originally defined in `lib/mruby/core_ext.rb`, other global
functions are moved to the file.
2020-11-22 16:53:13 +09:00
dearblue fd3576e888 Fix GC mark leaks for MRB_TT_BREAK; fix #5168 2020-11-22 15:09:01 +09:00
Yukihiro "Matz" Matsumoto 1cd8b4c933 Merge pull request #5169 from shuujii/fix-size-of-local-variable-array-in-struct-dumped-file
Fix size of local variable array in struct dumped file
2020-11-22 14:41:48 +09:00
KOBAYASHI Shuji 1864816d1e Fix size of local variable array in struct dumped file 2020-11-22 13:32:45 +09:00
Yukihiro "Matz" Matsumoto e02d0ff78c Merge pull request #5167 from dearblue/singleton-method
Improved `Object#define_singleton_method`
2020-11-22 00:02:34 +09:00
Yukihiro "Matz" Matsumoto 049e749c8b Merge pull request #5166 from shuujii/rename-MRB_ENABLE-DISABLE_-to-MRB_USE-NO_
Rename `MRB_{ENABLE,DISABLE}_` to `MRB_{USE,NO}_`; close #5163
2020-11-21 23:59:32 +09:00
dearblue b2bfcabae2 Improved Object#define_singleton_method
Integrate the implementation with `Module#define_method`.

- Introduce the internal function `mrb_mod_define_method_m()` (no static)
- The `Object#define_singleton_method` method can now accept a second argument
2020-11-21 22:31:13 +09:00
KOBAYASHI Shuji 3d056d084a Rename MRB_{ENABLE,DISABLE}_ to MRB_{USE,NO}_; close #5163
|        Previous Name         |        New Name         |
|------------------------------|-------------------------|
| MRB_ENABLE_ALL_SYMBOLS       | MRB_USE_ALL_SYMBOLS     |
| MRB_ENABLE_SYMBOLL_ALL       | MRB_USE_ALL_SYMBOLS     |
| MRB_ENABLE_CXX_ABI           | MRB_USE_CXX_ABI         |
| MRB_ENABLE_CXX_EXCEPTION     | MRB_USE_CXX_EXCEPTION   |
| MRB_ENABLE_DEBUG_HOOK        | MRB_USE_DEBUG_HOOK      |
| MRB_DISABLE_DIRECT_THREADING | MRB_NO_DIRECT_THREADING |
| MRB_DISABLE_STDIO            | MRB_NO_STDIO            |
| ENABLE_LINENOISE             | MRB_USE_LINENOISE       |
| ENABLE_READLINE              | MRB_USE_READLINE        |
| DISABLE_MIRB_UNDERSCORE      | MRB_NO_MIRB_UNDERSCORE  |
| DISABLE_GEMS                 | MRB_NO_GEMS             |

* `MRB_ENABLE_SYMBOLL_ALL` seems to be a typo, so it is fixed.
* `MRB_` prefix is added to those without.
* The previous names can also be used for compatibility.
2020-11-21 21:14:40 +09:00
Yukihiro "Matz" Matsumoto 544784effd Merge pull request #5157 from dearblue/detect-rb-mrb
Allow to mixed and specify `*.rb` and `*.mrb` in `bin/mruby`
2020-11-21 19:22:49 +09:00
dearblue a045b6b8d9 Allow to mixed and specify *.rb and *.mrb in bin/mruby
It is not decides by the extension.
In order to be recognized as a `.mrb` file, the following three points must be satisfied:
- File starts with "RITE"
- At least `sizeof(struct rite_binary_header)` bytes can be read
- `NUL` is included in the first 64 bytes of the file
If these are not met, it is judged as a text file and it is processed as a Ruby script.

The `bin/mruby -b` switch is still available which treats the given file as a `.mrb` file.

New `MRB_API` function:
- `include/mruby/compile.h` and `mrbgems/mruby-compiler/core/parse.y`
  - `mrb_load_detect_file_cxt()` (remove with `MRB_DISABLE_STDIO`)

NOTE:
- Even script files now always open in binary mode for `bin/mruby`.
  The `\r\n` is handled by the `nextc()` function already, so there is no problem even on Windows.
- The `nextc0()` function in `mrbgems/mruby-compiler/core/parse.y` can now specify a string buffer and a file pointer at the same time.
  In this case, get it from the string buffer first.

This patch includes modifies by comment of https://github.com/mruby/mruby/pull/5157.
2020-11-21 19:05:46 +09:00
Yukihiro "Matz" Matsumoto e3b91b8d41 Merge pull request #5165 from shuujii/fix-incorrect-build-name-and-simplify-build_config-boxing.rb
Fix incorrect build name and simplify `build_config/boxing.rb` [ci skip]
2020-11-21 17:53:42 +09:00
KOBAYASHI Shuji a3685c4c04 Fix incorrect build name and simplify build_config/boxing.rb [ci skip]
`boxing-nan-m64` was duplicated.
2020-11-21 17:50:44 +09:00
Yukihiro "Matz" Matsumoto a3221bf8cd Merge pull request #5164 from shuujii/automatically-enable-MRB_ENABLE_DEBUG_HOOK-if-mruby-bin-debugger-is-used
Automatically enable `MRB_ENABLE_DEBUG_HOOK` if `mruby-bin-debugger` is used
2020-11-21 17:41:36 +09:00
KOBAYASHI Shuji 3179944e81 Automatically enable MRB_ENABLE_DEBUG_HOOK if mruby-bin-debugger is used 2020-11-21 17:15:47 +09:00
Yukihiro "Matz" Matsumoto 66d044ec3e Remove -Wdeclaration-after-statement from gcc options; #5159 2020-11-21 17:05:16 +09:00
Yukihiro "Matz" Matsumoto 734f6b1cc4 Remove 2 restrictions from CONTRIBUTING.md; close #5159
* Allow mixed declarations, especially loop variables
* Allow C++ style commends `//`
2020-11-21 16:55:40 +09:00
Yukihiro "Matz" Matsumoto 55e1275778 Merge pull request #5161 from dearblue/ary-splice
Fix documents for `mrb_ary_splice()` [ci skip]
2020-11-21 16:08:44 +09:00
Yukihiro "Matz" Matsumoto c6c18c32b0 Merge pull request #5162 from shuujii/move-some-.rake-files-to-tasks-directory-for-consistency
Move some `.rake` files to `tasks` directory for consistency
2020-11-21 16:07:03 +09:00
Yukihiro "Matz" Matsumoto 00751ccbcd Reserve OP_SENDVK for the future keyword arguments like Ruby3.0. 2020-11-21 15:50:17 +09:00
Yukihiro "Matz" Matsumoto 59e581ed78 Fix infinite loop bug from super when method is prepended. 2020-11-21 15:50:16 +09:00
Yukihiro "Matz" Matsumoto a7bcbd8bdc Fix module order of #include; ruby-bug:7844 2020-11-21 15:50:16 +09:00
Yukihiro "Matz" Matsumoto 33f1970df2 Merge pull request #5160 from dearblue/cptr-obj
Unable for the `MRB_TT_CPTR` object to have a singleton class
2020-11-21 15:50:03 +09:00
Yukihiro "Matz" Matsumoto 07053e5654 Merge pull request #5158 from dearblue/typo
Fix typo "overfow" to "overflow" [ci skip]
2020-11-21 15:49:29 +09:00
dearblue 3ac6c3f090 Fix documents for mrb_ary_splice() [ci skip] 2020-11-21 15:47:59 +09:00
dearblue 7f9b4e056d Unable for the MRB_TT_CPTR object to have a singleton class
This object is treated as an immediate value.
2020-11-21 15:36:56 +09:00
KOBAYASHI Shuji 551bf0c635 Move some .rake files to tasks directory for consistency 2020-11-21 15:36:46 +09:00
dearblue 1e340cf869 Fix typo "overfow" to "overflow" [ci skip] 2020-11-21 15:19:28 +09:00
Yukihiro "Matz" Matsumoto eb52c29b2d Test each combination of boxing, mrb_int size, and archtecture.
Boxing:

* `MRB_NO_BOXING`   (`mrb_value` packed in `struct`)
* `MRB_WORD_BOXING` (`mrb_value` packed in `struct`) default
* `MRB_NAN_BOXING`  (`mrb_value` packed in `double`)

`mrb_int` size

* `MRB_INT32`       (`int32_t` as `mrb_int`)
* `MRB_INT64`       (`int64` as `mrb_int`) conflict with `MRB_NAN_BOXING'

Architecture

* `MRB_64BIT`      (`sizeof(void*)` is 64 bits)
* `MRB_32BIT`      (`sizeof(void*)` is 32 bits)
2020-11-21 14:38:14 +09:00
Yukihiro "Matz" Matsumoto 8258b7b5b3 Specify conf explicitly for enable_debug. 2020-11-21 14:38:14 +09:00
Yukihiro "Matz" Matsumoto 1974aa0f72 Update Float#to_s to keep trailing zero as CRuby does; ref 68cebb6 2020-11-21 14:38:13 +09:00
Yukihiro "Matz" Matsumoto 5f7eb20256 Merge pull request #5156 from shuujii/improve-determining-C++-compiler-in-tasks-toolchains-gcc.rake
Improve determining C++ compiler in `tasks/toolchains/gcc.rake`
2020-11-21 14:38:00 +09:00
KOBAYASHI Shuji 98d0f1b98e Improve determining C++ compiler in tasks/toolchains/gcc.rake
* Consider CC envvar as C compiler on which to make the decision.
* Consider the case where C compiler is `ccache gcc`, etc.
2020-11-21 12:25:50 +09:00
Yukihiro "Matz" Matsumoto fb028b47aa Merge pull request #5155 from shuujii/refactor-mrblib-mrblib.rake
Refactor `mrblib/mrblib.rake`
2020-11-20 23:13:08 +09:00
KOBAYASHI Shuji 1088feb110 Refactor mrblib/mrblib.rake 2020-11-20 22:55:49 +09:00
Yukihiro "Matz" Matsumoto ebf380474c Merge pull request #5153 from shuujii/refactor-src-mruby_core.rake
Refactor `src/mruby_core.rake`
2020-11-20 22:23:29 +09:00
Yukihiro "Matz" Matsumoto 749ac0a021 Merge pull request #5152 from shuujii/move-lib-mruby-core-ext.rb-to-lib-mruby-core_ext.rb-for-consistency
Move `lib/mruby-core-ext.rb` to `lib/mruby/core_ext.rb` for consistency
2020-11-20 22:22:14 +09:00
KOBAYASHI Shuji aaa12911e2 Refactor src/mruby_core.rake 2020-11-20 17:55:26 +09:00
KOBAYASHI Shuji 56a60fa7b7 Move lib/mruby-core-ext.rb to lib/mruby/core_ext.rb for consistency 2020-11-20 16:58:08 +09:00
Yukihiro "Matz" Matsumoto 5dc9a8249f Merge pull request #5150 from shuujii/allow-bintest-even-if-build-name-is-not-host
Allow `bintest` even if build name is not `host`
2020-11-19 12:41:53 +09:00
KOBAYASHI Shuji fd113da3aa Allow bintest even if build name is not host 2020-11-19 11:37:00 +09:00
Yukihiro "Matz" Matsumoto 15d6e172e9 Merge pull request #5146 from shuujii/fix-integer-overflow-error-in-mrdb-test
Fix integer overflow error in mrdb test
2020-11-18 19:19:48 +09:00
KOBAYASHI Shuji f50cde9924 Fix integer overflow error in mrdb test 2020-11-18 18:54:00 +09:00
Yukihiro "Matz" Matsumoto 25e76ee5ce Merge pull request #5149 from mruby/revert-5147-patch1
Revert "Check if irep->reps is NULL in lv_defined_p"
2020-11-18 18:48:17 +09:00
Yukihiro "Matz" Matsumoto a211a326de Revert "Check if irep->reps is NULL in lv_defined_p" 2020-11-18 18:47:46 +09:00
Yukihiro "Matz" Matsumoto e7d0baaf3b Use mrb_int_value() instead of mrb_fixnum_value(); fix #5142 2020-11-18 18:38:53 +09:00
Yukihiro "Matz" Matsumoto b9c80a5357 Merge pull request #5147 from hifoolno/patch1
Check if irep->reps is NULL in lv_defined_p
2020-11-18 18:13:31 +09:00
Zhang Xiaohui d3e17eedee Check if irep->reps is NULL in lv_defined_p 2020-11-18 17:07:20 +08:00
Yukihiro "Matz" Matsumoto e0df303547 Merge pull request #5143 from shuujii/use-mrb_int_value-instead-of-mrb_fixnum_value-in-src-hash.c
Use `mrb_int_value` instead of `mrb_fixnum_value` in `src/hash.c`
2020-11-18 17:29:34 +09:00
Yukihiro "Matz" Matsumoto 557e0645bf Merge pull request #5145 from shuujii/remove-unused-MRubyBuild-enable_bintest=
Remove unused `MRuby::Build#enable_{bin,}test=`
2020-11-18 17:28:47 +09:00
Yukihiro "Matz" Matsumoto 26dd35be59 Merge pull request #5144 from hifoolno/master
Check if irep->reps is NULL
2020-11-18 17:27:49 +09:00
KOBAYASHI Shuji dbb6010d8e Remove unused MRuby::Build#enable_{bin,}test=
The writers seem to be unnecessary because `MRuby::Build#enable_{bin,}test`
are used from the beginning.
2020-11-18 15:41:56 +09:00
Zhang Xiaohui eca6266524 Check if irep->reps is NULL 2020-11-18 14:41:27 +08:00
KOBAYASHI Shuji 4cea788970 Use mrb_int_value instead of mrb_fixnum_value in src/hash.c 2020-11-18 15:13:42 +09:00
Yukihiro "Matz" Matsumoto 3d8350f920 Retrieve irep from proc after MRB_PROC_CFUNC_P check; ref #5140 2020-11-18 10:07:26 +09:00
Yukihiro "Matz" Matsumoto 7c80edb577 Revert half of 9fbf0ef8.
I misunderstand the meaning of #4483. Sorry.
2020-11-17 22:47:25 +09:00
Yukihiro "Matz" Matsumoto 5abb283dd7 Check division overflow (MRB_INT_MIN and -1). 2020-11-17 22:41:43 +09:00
Yukihiro "Matz" Matsumoto 1f12525154 Merge pull request #5141 from shuujii/fix-deprecated-set-env-command-error-on-GitHub-Actions
Fix deprecated `set-env` command error on GitHub Actions [ci skip]
2020-11-17 22:07:33 +09:00
KOBAYASHI Shuji bed04414d7 Fix deprecated set-env command error on GitHub Actions [ci skip]
I tried `$GITHUB_PATH` and `$GITHUB_ENV` instead of `set-env`, but
for some reason path was not recognized, so I changed to using
`ACTIONS_ALLOW_UNSECURE_COMMANDS`.
2020-11-17 18:40:59 +09:00
Yukihiro "Matz" Matsumoto 68cebb6331 Overflown integers should not be fall back to float values. 2020-11-17 16:20:54 +09:00
Yukihiro "Matz" Matsumoto a8cd364ece Detect overflow in flo_shift(). 2020-11-17 16:20:53 +09:00
Yukihiro "Matz" Matsumoto 9fbf0ef886 Refactoring integer ranges.
- Remove `mrb_ssize`
- Fix `MRB_FIXNUM_{MIN,MAX}` to 32 bits on `MRB_NAN_BOXING`
2020-11-17 12:41:10 +09:00
Yukihiro "Matz" Matsumoto aae8237335 Scan all active C source files; ref 600e333
In addition, `include/mruby.h` will be scanned for error class symbols.
2020-11-17 09:00:06 +09:00
Yukihiro "Matz" Matsumoto 354934d398 Refactor integer division. 2020-11-17 07:10:31 +09:00
Yukihiro "Matz" Matsumoto 37a1884749 Simplify mrb_num_div_int(). 2020-11-17 00:24:43 +09:00
Yukihiro "Matz" Matsumoto 3107d1caae Allow int size combinations for MRB_WORD_BOXING.
- `MRB_64BIT` and `MRB_INT32`
- `MRB_32BIT` and `MRB_INT64`
2020-11-16 22:49:55 +09:00
Yukihiro "Matz" Matsumoto 3bb419aeab Merge pull request #5137 from shuujii/use-uintptr_t-instead-of-unsigned-long-in-include-mruby-boxing_word.h
Use `uintptr_t` instead of `unsigned long` in `include/mruby/boxing_word.h`
2020-11-16 22:49:42 +09:00
Yukihiro "Matz" Matsumoto 2609f0a2b3 Merge pull request #5139 from shuujii/avoid-undefined-behavior
Avoid undefined behavior
2020-11-16 22:49:03 +09:00
Yukihiro "Matz" Matsumoto 5156ea997f Merge pull request #5138 from shuujii/simplify-obj_free
Simplify `obj_free`
2020-11-16 22:48:05 +09:00
KOBAYASHI Shuji 7c470e25b8 Avoid undefined behavior
### ASAN report (`MRB_INT32`)

  ```console
  $ bin/mruby -ve '-0x40000000'
  mruby 3.0.0preview (2020-10-16)
  00001 NODE_SCOPE:
  00001   NODE_BEGIN:
  00001     NODE_NEGATE:
  00001       NODE_INT 40000000 base 16
  irep 0x6070000001e0 nregs=2 nlocals=1 pools=0 syms=0 reps=0 iseq=9
  file: -e
  /mruby/src/codedump.c:173:49: runtime error: left shift of 49152 by 16 places cannot be represented in type 'int'
  SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /mruby/src/codedump.c:173:49 in
      1 000 OP_LOADI32	R1	-1073741824
      1 006 OP_RETURN	R1
      1 008 OP_STOP

  /mruby/src/vm.c:1138:7: runtime error: left shift of 49152 by 16 places cannot be represented in type 'mrb_int' (aka 'int')
  SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /mruby/src/vm.c:1138:7 in
  ```
2020-11-16 20:20:30 +09:00
KOBAYASHI Shuji cbc3dbedb4 Simplify obj_free 2020-11-16 16:40:37 +09:00
KOBAYASHI Shuji 8a019106c0 Use uintptr_t instead of unsigned long in include/mruby/boxing_word.h
`mrb_bool`  on LLP64 environment seems to become false if, for example,
`mrb_value` is a pointer whose lower 32 bits are 0.
2020-11-16 16:04:05 +09:00
Yukihiro "Matz" Matsumoto 8a6614d30e Merge pull request #5135 from shuujii/fix-paths-of-gem-files-to-be-scanned-for-presym
Fix paths of gem files to be scanned for presym
2020-11-15 23:15:34 +09:00
Yukihiro "Matz" Matsumoto 144cf6cd58 Merge pull request #5134 from shuujii/fix-that-large-integer-is-not-GCed-with-Word-boxing
Fix that large integer is not GCed with Word-boxing
2020-11-15 23:14:59 +09:00
KOBAYASHI Shuji e334c02a50 Fix paths of gem files to be scanned for presym
When building from outside `MRUBY_ROOT` (e.g. `rake -f`), gem files were not
scanned.
2020-11-15 20:16:12 +09:00
KOBAYASHI Shuji acc114003b Fix that large integer is not GCed with Word-boxing
### Example (32-bit Word-boxing)

  ```ruby
  # example.rb
  int_count = ObjectSpace.count_objects[:T_INTEGER]||0
  int = 1<<30
  p (ObjectSpace.count_objects[:T_INTEGER]||0) - int_count
  int = nil
  GC.start
  p (ObjectSpace.count_objects[:T_INTEGER]||0) - int_count
  ```

#### Before this patch:

  ```console
  $ bin/mruby example.rb
  1
  1
  ```

#### After this patch:

  ```console
  $ bin/mruby example.rb
  1
  0
  ```
2020-11-15 16:45:03 +09:00
Yukihiro "Matz" Matsumoto a6119b0077 Fixed further wrong condition in overflow detection. 2020-11-15 08:08:55 +09:00
Yukihiro "Matz" Matsumoto bb1fb2f43d Fixed wrong condition in mrb_int_mul_overflow(). 2020-11-14 23:34:43 +09:00
Yukihiro "Matz" Matsumoto 2c6a5d3a77 Change the fallback mrb_int_mul_overflow(). 2020-11-14 23:28:05 +09:00
Yukihiro "Matz" Matsumoto 10c1c9d6f8 Change the type of rlen to uint8_t in mrb_irep. 2020-11-14 23:27:28 +09:00
Yukihiro "Matz" Matsumoto 8a5dfa92ab Integer overflow in operations should cause RangeError. 2020-11-14 20:44:07 +09:00
Yukihiro "Matz" Matsumoto dd3ed8d99c Allow full mrb_int operations in overflow detection.
Fix overflow detection in integer operations with `MRB_WORD_BOXING`.
This bug made `1073741824 == 1073741824+0` to be `false` on 32bit
platforms.
2020-11-14 20:40:06 +09:00
Yukihiro "Matz" Matsumoto 19450df41e Integer operation should result in Integer.
Should raise `RangeError` if the operation overflows.
2020-11-14 19:38:27 +09:00
Yukihiro "Matz" Matsumoto 600e3330b3 Scan source files only from cdump enabled gems. 2020-11-14 18:52:57 +09:00
Yukihiro "Matz" Matsumoto 4dcd8dd7ce Merge pull request #5132 from shuujii/remove-redundant-command-execution-in-header_search_paths
Remove redundant command execution in `header_search_paths`
2020-11-14 18:52:48 +09:00
KOBAYASHI Shuji e941fb7866 Remove redundant command execution in header_search_paths
There is no need to execute command in duplicate for the same
reason as #5128.
2020-11-14 17:19:38 +09:00
Yukihiro "Matz" Matsumoto 8398020d0a Merge pull request #5131 from shuujii/remove-unused-constant-in-lib-mruby-build-command.rb
Remove unused constant in `lib/mruby/build/command.rb`
2020-11-14 17:01:37 +09:00
Yukihiro "Matz" Matsumoto 69dbe8cfa5 Merge pull request #5130 from shuujii/workaround-to-build-mirb-with-Homebrews-readline-on-Mac
Workaround to build `mirb` with Homebrew's readline on Mac; fix #4537
2020-11-14 16:53:23 +09:00
KOBAYASHI Shuji 08df172e91 Remove unused constant in lib/mruby/build/command.rb 2020-11-14 16:50:00 +09:00
KOBAYASHI Shuji 06a8e502fa Workaround to build mirb with Homebrew's readline on Mac; fix #4537 2020-11-14 16:30:45 +09:00
Yukihiro "Matz" Matsumoto fdbb1731ce Merge pull request #5128 from shuujii/simplify-MRubyCommand-_run-to-avoid-duplicated-compilation
Simplify `MRuby::Command#_run` to avoid duplicated compilation
2020-11-14 16:08:10 +09:00
Yukihiro "Matz" Matsumoto 5edac8b885 Merge pull request #5129 from dearblue/mrb_mt_foreach
Don't use private structs with `mrb_mt_foreach()`
2020-11-14 16:06:47 +09:00
dearblue 368f8a5da6 Don't use private structs with mrb_mt_foreach()
The `MRB_API` function `mrb_mt_foreach()` previously used the private structure `struct mt_elem`.
Therefore, use `mrb_method_t` instead.
2020-11-14 11:30:34 +09:00
KOBAYASHI Shuji 0c55b85fb0 Simplify MRuby::Command#_run to avoid duplicated compilation
ref: https://github.com/mruby/mruby/pull/4959#discussion_r402086196

Compiles twice because it falls back to `build.filename(command)` when
`command` fails. This process was added at 9968af4 to support `ccache gcc`
etc. At that time, it seems that it was necessary because
`build.filename(command)` quoted the whole `command`, but now it does not
quote, so we can just run `build.filename(command)`.

### Example

  ```console
  $ echo 1 > src/a.c
  $ rake -v
  ```

#### Before this patch:

  ```console
  (snip)
  gcc -std=gnu99 -g -O3 -Wall -Wundef -Wdeclaration-after-statement -Werror-implicit-function-declaration -Wwrite-strings -I"/mruby/mruby/include" -MMD -o "/mruby/mruby/build/host/src/a.o" -c "/mruby/mruby/src/a.c"
  /mruby/mruby/src/a.c:1:1: error: expected identifier or '('
  1
  ^
  1 error generated.
  gcc -std=gnu99 -g -O3 -Wall -Wundef -Wdeclaration-after-statement -Werror-implicit-function-declaration -Wwrite-strings -I"/mruby/mruby/include" -MMD -o "/mruby/mruby/build/host/src/a.o" -c "/mruby/mruby/src/a.c"
  /mruby/mruby/src/a.c:1:1: error: expected identifier or '('
  1
  ^
  1 error generated.
  rake aborted!
  (snip)
  ```

#### After this patch:

  ```console
  (snip)
  gcc -std=gnu99 -g -O3 -Wall -Wundef -Wdeclaration-after-statement -Werror-implicit-function-declaration -Wwrite-strings -I"/mruby/mruby/include" -MMD -o "/mruby/mruby/build/host/src/a.o" -c "/mruby/mruby/src/a.c"
  /mruby/mruby/src/a.c:1:1: error: expected identifier or '('
  1
  ^
  1 error generated.
  rake aborted!
  (snip)
  ```
2020-11-13 21:49:12 +09:00
Yukihiro "Matz" Matsumoto 7fb62670a9 Merge pull request #5127 from shuujii/include-size-of-iv-table-in-ObjectSpace.memsize_of-to-Hash-object
Include size of iv table in `ObjectSpace.memsize_of` to `Hash` object
2020-11-13 18:13:46 +09:00
KOBAYASHI Shuji 292a096118 Include size of iv table in ObjectSpace.memsize_of to Hash object 2020-11-13 16:59:45 +09:00
Yukihiro "Matz" Matsumoto 75beb55c2a Merge pull request #5126 from shuujii/use-enable_sanitizer-to-simplify-build_config-clang-asan.rb
Use `enable_sanitizer` to simplify `build_config/clang-asan.rb`
2020-11-13 16:47:20 +09:00
Yukihiro "Matz" Matsumoto f8ce3bec13 Merge pull request #5125 from shuujii/rename-mrb_os_memsize_of_hash_table-to-mrb_hash_memsize
Rename `mrb_os_memsize_of_hash_table` to `mrb_hash_memsize`
2020-11-13 16:45:52 +09:00
KOBAYASHI Shuji bad6223914 Use enable_sanitizer to simplify build_config/clang-asan.rb 2020-11-13 16:30:18 +09:00
KOBAYASHI Shuji ac4eb99629 Rename mrb_os_memsize_of_hash_table to mrb_hash_memsize
* The term `hash_table` can be misleading because the return value of this
  function includes memory usage of entire `Hash` object, including not only
  hash table part but also entry list part, etc.
* This function takes a `Hash` object as a receiver and is defined in
  `src/hash.c`, so it is natural to have a `mrb_hash_` prefix.
2020-11-13 16:18:32 +09:00
Yukihiro "Matz" Matsumoto af13cfb7d5 Merge pull request #5122 from shuujii/change-name-and-usage-of-presym-macros
Change name and usage of presym macros
2020-11-13 14:05:26 +09:00
KOBAYASHI Shuji 89f591485b Change name and usage of presym macros
To be also able to build mruby without presym in the future. However,
`MRB_QSYM` has been removed and changed as follows:

### Example

|       Type                | Symbol |  Previous Style  |   New Style    |
|---------------------------|--------|------------------|----------------|
| Operator                  | &      | MRB_QSYM(and)    | MRB_OPSYM(and) |
| Class Variable            | @@foo  | MRB_QSYM(00_foo) | MRB_CVSYM(foo) |
| Instance Variable         | @foo   | MRB_QSYM(0_foo)  | MRB_IVSYM(foo) |
| Method with Bang          | foo!   | MRB_QSYM(foo_b)  | MRB_SYM_B(foo) |
| Method with Question mark | foo?   | MRB_QSYM(foo_p)  | MRB_SYM_Q(foo) |
| Mmethod with Equal        | foo=   | MRB_QSYM(foo_e)  | MRB_SYM_E(foo) |

This change makes it possible to define, for example, `MRB_IVSYM(foo)` as
`mrb_intern_lit(mrb, "@" "foo")`, which is useful if we support building
without presym in the future.
2020-11-13 13:41:20 +09:00
Yukihiro "Matz" Matsumoto 280cb80a0d Merge pull request #5124 from shuujii/remove-unused-argument-of-mrb_obj_iv_tbl_memsize
Remove unused argument of `mrb_obj_iv_tbl_memsize`
2020-11-12 22:18:57 +09:00
KOBAYASHI Shuji ff2ef44c0e Remove unused argument of mrb_obj_iv_tbl_memsize 2020-11-12 20:19:41 +09:00
Yukihiro "Matz" Matsumoto 6a5e97b448 Merge pull request #5121 from shuujii/reduce-memory-usage-of-Hash-object
Reduce memory usage of Hash object
2020-11-10 21:56:42 +09:00
Yukihiro "Matz" Matsumoto cc20c5ca3a Merge pull request #5120 from kou/mrb-exe-new-str-lit-typo
Fix typo in backward compatible mrb_exc_new_str_lit() macro
2020-11-10 16:07:36 +09:00
Sutou Kouhei a00eabbf5d Fix typo in backward compatible mrb_exc_new_str_lit() macro 2020-11-10 16:03:05 +09:00
KOBAYASHI Shuji f2d8db39be Reduce memory usage of Hash object
## Implementation Summary

* Change entry list from segmented list to flat array.
* Change value of hash bucket from pointer to entry to index of entry list,
  and represent it by variable length bits according to capacity of hash
  buckets.
* Store management information about entry list and hash table to `struct
  RHash` as much as possible.

## Benchmark Summary

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

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

### Memory Usage

Lower value is better.

| Hash Size |   Baseline    |      New      |   Factor   |
|----------:|--------------:|--------------:|-----------:|
|        16 |          344B |          256B |   0.74419x |
|        40 |        1,464B |          840B |   0.57377x |
|       200 |        8,056B |        3,784B |   0.46971x |
|       500 |       17,169B |        9,944B |   0.57949x |

### Performance

Higher value is better.

#### `mrb_hash_set`

| Hash Size |   Baseline    |      New      |   Factor   |
|----------:|--------------:|--------------:|-----------:|
|        16 |  1.41847M i/s |  1.36004M i/s |   0.95881x |
|        40 |  0.39224M i/s |  0.31888M i/s |   0.81296x |
|       200 |  0.03780M i/s |  0.04290M i/s |   1.13494x |
|       500 |  0.01225M i/s |  0.01314M i/s |   1.07275x |

#### `mrb_hash_get`

| Hash Size |   Baseline    |      New      |   Factor   |
|----------:|--------------:|--------------:|-----------:|
|        16 | 26.05920M i/s | 30.19543M i/s |   1.15872x |
|        40 | 44.26420M i/s | 32.75781M i/s |   0.74005x |
|       200 | 44.55171M i/s | 31.56926M i/s |   0.70860x |
|       500 | 39.19250M i/s | 29.73806M i/s |   0.75877x |

#### `mrb_hash_each`

| Hash Size |   Baseline    |      New      |   Factor   |
|----------:|--------------:|--------------:|-----------:|
|        16 | 25.11964M i/s | 30.34167M i/s |   1.20789x |
|        40 | 11.74253M i/s | 13.25539M i/s |   1.12884x |
|       200 |  2.01133M i/s |  2.97214M i/s |   1.47770x |
|       500 |  0.87411M i/s |  1.21178M i/s |   1.38631x |

#### `Hash#[]=`

| Hash Size |   Baseline    |      New      |   Factor   |
|----------:|--------------:|--------------:|-----------:|
|        16 |  0.50095M i/s |  0.56490M i/s |   1.12764x |
|        40 |  0.19132M i/s |  0.18392M i/s |   0.96129x |
|       200 |  0.03624M i/s |  0.03256M i/s |   0.89860x |
|       500 |  0.01527M i/s |  0.01236M i/s |   0.80935x |
#### `Hash#[]`

| Hash Size |   Baseline    |      New      |   Factor   |
|----------:|--------------:|--------------:|-----------:|
|        16 | 11.53211M i/s | 12.78806M i/s |   1.10891x |
|        40 | 15.26920M i/s | 13.37529M i/s |   0.87596x |
|       200 | 15.28550M i/s | 13.36410M i/s |   0.87430x |
|       500 | 14.57695M i/s | 12.75388M i/s |   0.87494x |

#### `Hash#each`

| Hash Size |   Baseline    |      New      |   Factor   |
|----------:|--------------:|--------------:|-----------:|
|        16 |  0.30462M i/s |  0.27080M i/s |   0.88898x |
|        40 |  0.12912M i/s |  0.11704M i/s |   0.90642x |
|       200 |  0.02638M i/s |  0.02402M i/s |   0.91071x |
|       500 |  0.01066M i/s |  0.00959M i/s |   0.89953x |

#### `Hash#delete`

| Hash Size |   Baseline    |      New      |   Factor   |
|----------:|--------------:|--------------:|-----------:|
|        16 |  7.84167M i/s |  6.96419M i/s |   0.88810x |
|        40 |  6.91292M i/s |  7.41427M i/s |   1.07252x |
|       200 |  3.75952M i/s |  7.32080M i/s |   1.94727x |
|       500 |  2.10754M i/s |  7.05963M i/s |   3.34970x |

#### `Hash#shift`

| Hash Size |   Baseline    |      New      |   Factor   |
|----------:|--------------:|--------------:|-----------:|
|        16 | 14.66444M i/s | 13.18876M i/s |   0.89937x |
|        40 | 11.95124M i/s | 11.10420M i/s |   0.92913x |
|       200 |  5.53681M i/s |  7.88155M i/s |   1.42348x |
|       500 |  2.96728M i/s |  5.40405M i/s |   1.82121x |

#### `Hash#dup`

| Hash Size |   Baseline    |      New      |   Factor   |
|----------:|--------------:|--------------:|-----------:|
|        16 |  0.15063M i/s |  5.37889M i/s |  35.71024x |
|        40 |  0.06515M i/s |  3.38196M i/s |  51.91279x |
|       200 |  0.01359M i/s |  1.46538M i/s | 107.84056x |
|       500 |  0.00559M i/s |  0.75411M i/s | 134.88057x |

### Binary Size

Lower value is better.

|    File    |   Baseline    |      New      |  Factor   |
|:-----------|--------------:|--------------:|----------:|
| mruby      |      730,408B |      734,176B |  1.00519x |
| libmruby.a |    1,068,134B |    1,072,846B |  1.00441x |

## Other Fixes

The following issues have also been fixed in the parts where there was some
change this time.

* [Heap use-after-free in `Hash#value?`](https://gist.github.com/shuujii/30e4fcd5844a4112a0ecd4a5b3483101#file-heap-use-after-free-in-hash-value-md)
* [Heap use-after-free in `ht_hash_equal`](https://gist.github.com/shuujii/30e4fcd5844a4112a0ecd4a5b3483101#file-heap-use-after-free-in-ht_hash_equal-md)
* [Heap use-after-free in `ht_hash_func`](https://gist.github.com/shuujii/30e4fcd5844a4112a0ecd4a5b3483101#file-heap-use-after-free-in-ht_hash_func-md)
* [Heap use-after-free in `mrb_hash_merge`](https://gist.github.com/shuujii/30e4fcd5844a4112a0ecd4a5b3483101#file-heap-use-after-free-in-mrb_hash_merge-md)
* [Self-replacement does not work for `Hash#replace`](https://gist.github.com/shuujii/30e4fcd5844a4112a0ecd4a5b3483101#file-self-replacement-does-not-work-for-hash-replace-md)
* [Repeated deletes and inserts increase memory usage of `Hash`](https://gist.github.com/shuujii/30e4fcd5844a4112a0ecd4a5b3483101#file-repeated-deletes-and-inserts-increase-memory-usage-of-hash-md)
* [`Hash#rehash` does not reindex completely](https://gist.github.com/shuujii/30e4fcd5844a4112a0ecd4a5b3483101#file-hash-rehash-does-not-reindex-completely-md)
* `mrb_hash_delete_key` does not cause an error for frozen object
* `mrb_hash_new_capa` does not allocate required space first
* [`mrb_os_memsize_of_hash_table` result is incorrect](https://github.com/mruby/mruby/pull/5032#discussion_r457994075)
2020-11-10 15:21:49 +09:00
Yukihiro "Matz" Matsumoto 352c4755b2 Merge pull request #5118 from dearblue/mrb_value
Define `mrb_value` in struct for Word/NaN boxing
2020-11-10 11:50:59 +09:00
Yukihiro "Matz" Matsumoto 0df460892c Add range check before casting float to integer. 2020-11-09 11:35:54 +09:00
Yukihiro "Matz" Matsumoto 82249bb973 Merge pull request #5119 from kou/mruby-io-standard-io
Don't check FD for STDIN/STDOUT/STDERR; #5114
2020-11-09 11:19:21 +09:00
Sutou Kouhei 0cba422488 Don't check FD for STDIN/STDOUT/STDERR; #5114
We don't need to require valid STDIN/STDOUT/STDERR. If we require it,
we can't use mruby on an environment that doesn't have valid
STDIN/STDOUT/STDERR such as Windows service process. Windows service
process doesn't have valid STDIN.
2020-11-09 10:27:24 +09:00
Yukihiro "Matz" Matsumoto 9288805435 Merge pull request #5117 from dearblue/nan-32bit
Fixed build NaN boxing with 32-bit CPU mode
2020-11-08 14:38:18 +09:00
dearblue e993b83c50 Fixed build NaN boxing with 32-bit CPU mode
`SET_CPTR_VALUE()` requires the `p` field on 32-bit CPU mode.
2020-11-08 14:15:19 +09:00
dearblue 926ec1dc7e Define mrb_value in struct for Word/NaN boxing
This is to make it possible to distinguish between `mrb_value` and `mrb_sym` in C++ "Function overloading" and C11 "Generic selection".
2020-11-08 14:14:00 +09:00
Yukihiro "Matz" Matsumoto e2829bef0d Merge pull request #5115 from dearblue/nogems
Suppress `-Wunused-function`
2020-11-08 12:30:29 +09:00
dearblue 06d231d372 Suppress -Wunused-function
If no gem was specified, it was warning because `init_mrbgems()` was not used.

ref: #4250
2020-11-08 10:52:04 +09:00
Yukihiro "Matz" Matsumoto 8455344bf3 Skip too big left shift in flo_shift(). 2020-11-06 12:52:18 +09:00
Yukihiro "Matz" Matsumoto 2a52ebcc56 Avoid negating MRB_INT_MIN which is impossible. 2020-11-06 12:51:44 +09:00
Yukihiro "Matz" Matsumoto d93fc6593f Fix wrong integer casting. 2020-11-06 12:42:43 +09:00
Yukihiro "Matz" Matsumoto f77113e841 Fix a bug with printing (null) local variable name for a register. 2020-11-05 16:55:23 +09:00
Yukihiro "Matz" Matsumoto d9bd77b180 Fix A.new([[1,2],3]).flatten to return Array. 2020-11-05 14:29:26 +09:00
Yukihiro "Matz" Matsumoto 4e535080dc Use INT32_{MAX,MIN} to specify integer ranges. 2020-11-05 14:29:26 +09:00
Yukihiro "Matz" Matsumoto afba74ff50 Add Array.new([1,2,3]) initialization. 2020-11-05 14:29:25 +09:00
Yukihiro "Matz" Matsumoto aa4d8e9a2b Avoid integer overflow in comparison. 2020-11-04 14:27:34 +09:00
Yukihiro "Matz" Matsumoto 0113db6716 Add cast to silence int conversion warnings. 2020-11-04 14:18:47 +09:00
Yukihiro "Matz" Matsumoto b77a0f69a3 Fix a bug with big negative integers. 2020-11-04 14:15:51 +09:00
Yukihiro "Matz" Matsumoto 5d85045fcb Update mruby3.md about new instructions. 2020-11-04 14:01:56 +09:00
Yukihiro "Matz" Matsumoto d13df1536d Add a new instruction OP_LOADI32.
That loads 32 bit integer bypassing pool access.
2020-11-04 14:01:04 +09:00
Yukihiro "Matz" Matsumoto f8156ae175 Merge pull request #5113 from shuujii/reduce-recompilation-when-updating-presym-target-files
Reduce recompilation when updating presym target files
2020-11-03 18:13:56 +09:00
Yukihiro "Matz" Matsumoto b08da9c30b Merge pull request #5112 from shuujii/fix-dependencies-of-y.tab.o
Fix dependencies of `y.tab.o`
2020-11-03 18:12:50 +09:00
Yukihiro "Matz" Matsumoto 963b44286a Use C99 __func__ instead of __FUNCTION__; #5107 2020-11-03 18:03:23 +09:00
KOBAYASHI Shuji 82a2a5657c Reduce recompilation when updating presym target files
Fix that updating presym target files would recompile almost all files even
if symbols did not change.
2020-11-03 16:03:46 +09:00
KOBAYASHI Shuji ea5d0a593c Fix dependencies of y.tab.o
In the case of `y.tab.o`, `y.tab.d` was not read, so `y.tab.c` was not
recompiled by updating header files.

It seemed that the cause was overwriting the rake rule, so I deleted
unnecessary settings.
2020-11-03 15:56:08 +09:00
Yukihiro "Matz" Matsumoto b7e8406f6c Add new instructions to handle symbols/literals >255; fix #5109
New instructions:
  * OP_LOADL16
  * OP_LOADSYM16
  * OP_STRING16

Size of pools, symbols are `int16_t` but offset representation in the
bytecode was 8 bits. Size of child `irep` array is `int16_t`, too but
this change does not address it.
2020-11-03 14:58:44 +09:00
Yukihiro "Matz" Matsumoto 0be5b266b6 format '%p' expects argument of type 'void *'; #5107 2020-11-02 23:04:12 +09:00
Yukihiro "Matz" Matsumoto ac51a58683 ISO C does not allow extra ';' outside of a function; #5107 2020-11-02 23:04:12 +09:00
Yukihiro "Matz" Matsumoto 436765eb94 Revert "Remove long-time deprecated minirake."
`minirake` was still used in many occasions.
This reverts commit 3847c7eb64.
2020-11-02 15:14:36 +09:00
Yukihiro "Matz" Matsumoto ddfac9aba0 Search gem from MRUBY_ROOT if build config is in build_config. 2020-11-02 15:14:36 +09:00
Yukihiro "Matz" Matsumoto 9233d28ac7 Make Ranges frozen as Ruby3.0. 2020-11-02 15:14:36 +09:00
Yukihiro "Matz" Matsumoto dc886873bc Replace R-assignment by single-line pattern matching.
Since `R-assignment` in CRuby is abandoned.  Single-line pattern matching
in `mruby` only matches single local variable at the moment. Currently
it works as a right assignment to a local variable. It will be enhanced
in the future.
2020-11-02 15:14:36 +09:00
Yukihiro "Matz" Matsumoto 70ee936367 Update the build description in mruby3.md. 2020-11-02 15:14:35 +09:00
Yukihiro "Matz" Matsumoto c427776910 Merge pull request #5111 from shuujii/fix-parallel-build
Fix parallel build
2020-11-02 15:14:25 +09:00
KOBAYASHI Shuji 9a5c78dc26 Fix parallel build
When `rake -m` and so on are used to build in parallel, building may be
started before presym files are generated. Then, for example, the following
error occurs and this issue is fixed.

```console
In file included from /Users/shuujii/mruby/mruby/include/mruby.h:92:
/mruby/mruby/include/mruby/presym.h:16:10: fatal error: '../build/presym.inc' file not found
#include <../build/presym.inc>
         ^~~~~~~~~~~~~~~~~~~~~
```
2020-11-02 14:13:33 +09:00
Yukihiro "Matz" Matsumoto 331b119313 Merge pull request #5110 from bshastry/fix-mruby-ossfuzz-build
ossfuzz: Fix mruby include paths
2020-11-01 22:19:39 +09:00
Bhargava Shastry b5e4e283e8 ossfuzz: Fix mruby include paths 2020-11-01 13:24:03 +01:00
Yukihiro "Matz" Matsumoto f000856d68 Merge pull request #5108 from mimaki/display_preview_version
Add `preview` to version.
2020-11-01 17:19:01 +09:00
mimaki 943029954f Fix mruby -v option test. 2020-11-01 14:19:19 +09:00
mimaki bc9566eb64 Add preview to version. 2020-11-01 13:42:35 +09:00
Yukihiro "Matz" Matsumoto 6cc29ed377 Fix the condition to detect core mrbgems. 2020-10-30 07:15:11 +09:00
Yukihiro "Matz" Matsumoto e4d4192c3a Exclude symbols from mruby-test gem only used for tests. 2020-10-29 23:16:54 +09:00
Yukihiro "Matz" Matsumoto a5d05ea8b7 Use mrb dump format for non core mrbgems by default.
If you confirm the gem is cdump safe, add `spec.enable_cdump` in
`mrbgem.rake` file. Some external gems e.g. `mruby-mgem-template` do
not work with cdump.
2020-10-29 22:52:29 +09:00
Yukihiro "Matz" Matsumoto 86981dafb1 Use clear if instead of unless for condition. 2020-10-29 22:52:29 +09:00
Yukihiro "Matz" Matsumoto 5dff2194a2 Use instance variable @dir instead of access method dir. 2020-10-29 22:52:29 +09:00
Yukihiro "Matz" Matsumoto 78f7162508 Remove mrblib_dir and objs_dir configuration from gems.
Always use `mrblib` and 'src` for directory names.
2020-10-29 22:52:28 +09:00
Yukihiro "Matz" Matsumoto ccca5e521c Merge pull request #5105 from shuujii/fix-typo-in-Range-last
Fix typo in `Range#last`
2020-10-29 22:52:17 +09:00
Yukihiro "Matz" Matsumoto 212800a901 Merge pull request #5104 from shuujii/fix-typo-in-doc-guides-compile.md
Fix typo in `doc/guides/compile.md` [ci skip]
2020-10-29 22:51:43 +09:00
KOBAYASHI Shuji 353ecd7119 Fix typo in Range#last 2020-10-29 18:40:42 +09:00
KOBAYASHI Shuji 0736d7c99f Fix typo in doc/guides/compile.md [ci skip] 2020-10-29 18:27:11 +09:00
Yukihiro "Matz" Matsumoto 385cebe0b9 Use `default' gembox by default.
I changed to use `full-core` gembox for debugging. It should have been
reverted before `mruby3` branch was merged.
2020-10-29 11:53:10 +09:00
Yukihiro "Matz" Matsumoto 3847c7eb64 Remove long-time deprecated minirake. 2020-10-29 11:49:05 +09:00
Yukihiro "Matz" Matsumoto 24ffa4386a The path of the gem should be relative from MRUBY_ROOT.
It was relative from the directory of the build configuration file, but
the document says it's relative from `MRUBY_ROOT`. When the default
configuration file was `MRUBY_ROOT/build_config.rb`, it was OK for most
of the cases.
2020-10-29 11:49:05 +09:00
Yukihiro "Matz" Matsumoto 33742d941f Move build_config.rb -> build_config/default.rb; ref #5098
In addition, update the documents referring `build_config.rb` which is
no longer used. The new `build_config.rb` describes the new configuration
structure in the comment.
2020-10-29 11:49:05 +09:00
Yukihiro "Matz" Matsumoto c1ad4c4261 Restore original name for default build_config_name; ref #5098 2020-10-29 10:46:20 +09:00
Yukihiro "Matz" Matsumoto 41d5df03ed Use Dir.glob instead of map. 2020-10-29 10:43:09 +09:00
Yukihiro "Matz" Matsumoto 32ffd81011 Add beginless/endless ranges tests. 2020-10-29 10:43:09 +09:00
Yukihiro "Matz" Matsumoto cb636215bb Raise exception from Range#first with beginless ranges. 2020-10-29 10:43:08 +09:00
Yukihiro "Matz" Matsumoto d35677f213 Implement Range#last in mruby-range-ext in Ruby.
This reduce unnecessary calls of `mrb_funcall()`.
2020-10-29 10:43:08 +09:00
Yukihiro "Matz" Matsumoto 76eafa4608 Merge pull request #5098 from shuujii/revert-MRUBY_TARGET-mechanism
Revert `MRUBY_TARGET` mechanism; ref #5096
2020-10-29 10:42:56 +09:00
Yukihiro "Matz" Matsumoto 78d185efb9 Merge pull request #5102 from dearblue/c++-exc
Fixed build with `conf.enable_cxx_exception`
2020-10-29 10:41:56 +09:00
Yukihiro "Matz" Matsumoto f24658816c Merge pull request #5103 from shuujii/fix-mrb_obj_id-to-Float
Fix `mrb_obj_id` to `Float`
2020-10-29 07:01:09 +09:00
KOBAYASHI Shuji 43863d5f01 Fix mrb_obj_id to Float 2020-10-28 23:03:26 +09:00
dearblue 336f0de8bb Fixed build with conf.enable_cxx_exception
The problem was manifested by commit 5069fb15e4.
2020-10-28 21:10:33 +09:00
Yukihiro "Matz" Matsumoto 07224f8ed9 Merge pull request #5101 from dearblue/env-new
Reorganize `env_new()` as `mrb_env_new()`
2020-10-24 23:03:58 +09:00
dearblue 69a6bb1f12 Reorganize env_new() as mrb_env_new()
The `mrb_env_new()` function is a global function, but it is still treated as an internal function.
2020-10-24 22:29:31 +09:00
Yukihiro "Matz" Matsumoto 17247c51f2 Merge pull request #5099 from dearblue/getargs-array
Prohibit array changes by "a"/"*" specifier of `mrb_get_args()`
2020-10-23 15:43:18 +09:00
Yukihiro "Matz" Matsumoto fd38b9217d Merge pull request #5100 from dearblue/getargv-array
Prohibit array changes by `mrb_get_argv()`
2020-10-23 15:41:46 +09:00
dearblue edc49f9d26 Prohibit array changes by mrb_get_argv()
The `mrb_get_argv()` function will now return `const mrb_value *`.
This is because it is difficult for the caller to check if it is a splat argument (array object) and to write-barrier if necessary.
2020-10-22 23:22:29 +09:00
dearblue f0a64329b1 Prohibit array changes by "a"/"*" specifier of mrb_get_args()
The "a"/"*" specifier of the `mrb_get_args()` function will now return `const mrb_value *`.
This is because it is difficult for the caller to check if it is an array object and write-barrier if necessary.
And it requires calling `mrb_ary_modify()` on the unmodified array object, which is also difficult (this is similar to #5087).
2020-10-22 22:55:35 +09:00
KOBAYASHI Shuji 81c2108819 Revert MRUBY_TARGET mechanism; ref #5096
* In explanation of mruby, the expression `build_config.rb` is frequently
  used including official documents, so I think that it will not make sense
  if the file is no longer used.
* The `MRUBY_TARGET` mechanism seems to have little improvement, so I don't
  think it should be changed to avoid unnecessary confusion.
* `MRUBY_TARGET` and `MRuby.targets` represent somewhat different things,
  so using the same term "target" is a bit confusing.

The mechanism that can be written short when using a file under
`build_config` (renamed from `target`) directory remains
(`build_config/${MRUBY_CONFIG}.rb` is used if the path specified
in `MRUBY_CONFIG` doesn't exist).
2020-10-19 15:03:22 +09:00
Yukihiro "Matz" Matsumoto 27492e53a0 Add startless range (another part of #5085)
Ref #5093; close #5085
2020-10-16 17:29:23 +09:00
Yukihiro "Matz" Matsumoto 8d36393a5b Remove uninitialized local variable warning.
Fix for #5093
2020-10-16 16:47:04 +09:00
Yukihiro "Matz" Matsumoto 3c55cb0895 Turn of enable_debug by default; ref #5096
It was once turned off by #4045
2020-10-16 16:37:31 +09:00
Yukihiro "Matz" Matsumoto a373c48f3b Typo fixed; ref #5095
Thanks to @YunzheZJU
2020-10-16 13:34:32 +09:00
Yukihiro "Matz" Matsumoto c9db7d3531 Use conf.enable_debug; close #5095
According to `doc/guides/compile.md`; thanks to @YunzheZJU
2020-10-16 13:32:58 +09:00
Yukihiro "Matz" Matsumoto 045761390d Merge pull request #5094 from mruby-Forum/mruby3-preview
mruby 3.0.0-preview.
2020-10-16 10:56:54 +09:00
Hiroshi Mimaki 0589749952 mruby 3.0.0-preview. 2020-10-16 10:43:03 +09:00
Yukihiro "Matz" Matsumoto 4b5dd5683b Merge branch 'zubycz-work_for_merge' 2020-10-15 18:35:53 +09:00
Yukihiro "Matz" Matsumoto 6b457d2c00 Merge branch 'work_for_merge' of https://github.com/zubycz/mruby into zubycz-work_for_merge 2020-10-15 18:35:13 +09:00
Yukihiro "Matz" Matsumoto c779413df3 Fix out of bound access in parse.y. 2020-10-15 18:32:27 +09:00
Yukihiro "Matz" Matsumoto 9cebddf9fe Merge pull request #5084 from mruby/mruby3
Mruby3
2020-10-15 18:31:06 +09:00
Yukihiro "Matz" Matsumoto 21e07d6113 Add indent to lv in the C dump. 2020-10-14 20:26:06 +09:00
Yukihiro "Matz" Matsumoto 5b40bb8d15 Avoid using C struct dump for test Ruby code.
Files under `test/t` and `mrbgem/*/test` are for tests, not for actual
execution. So symbols in those files need not to be pre-allocated. This
change slightly reduce the memory consumption.
2020-10-14 15:52:14 +09:00
taiyoslime bec4d05340 Introduce endless range (a part of #5085)
Co-Authored-By: n4o847 <22975590+n4o847@users.noreply.github.com>
Co-Authored-By: smallkirby <ssmallkirby@gmail.com>
2020-10-13 14:09:36 +09:00
Yukihiro "Matz" Matsumoto 8c276f95be Merge pull request #5091 from zubycz/remove_unnecessary_assignment
Remove unnecessary assignment in String#upto
2020-10-12 18:23:22 +09:00
Yukihiro "Matz" Matsumoto 82046ff26e Revert "Add a new function mrb_exc_protect()."
This reverts commit 8746a6fe4e7bda8a0fbc0eaece9314ec51a0c255.

We already have `mrb_protect()`, `mrb_ensure()` and `mrb_rescue()`
functions. If you need to handle exceptions from C functions, use those
functions above.
2020-10-12 18:20:30 +09:00
Yukihiro "Matz" Matsumoto 3d6adccfbe Add a new function mrb_exc_protect().
`mrb_exc_protect()` takes two C functions, `body` to be executed first,
and `resc` to be executed when an error happens during `body` execution.
Since `mrb_exc_protect()` should be compiled with the proper compiler,
we will not see the problem like #5088 that was caused by `setjmp()` and
`throw` mixture.
2020-10-12 18:20:29 +09:00
Yukihiro "Matz" Matsumoto 5069fb15e4 Cause error explicitly from MRB_TRY() with cxx_exception; ref #5088
`MRB_TRY()` does not work when compiled by C compiler with `cxx_exception`
configuration. We should explicitly warn.
2020-10-12 18:20:29 +09:00
Yukihiro "Matz" Matsumoto 7ca59ecea2 Revert e2e6554b56 not to use MRB_TRY(); close #5088
`MRB_TRY()` does not work when compiled by C compiler with `cxx_exception`,
due to the mixture of `setjmp()` used by `mirb.c` and `throw` used by
the core.  The original intension of e2e6554b56 is to protect code from
signal interruption, but the signal interruption is not well-defined in
mruby anyway.
2020-10-12 18:20:29 +09:00
Yukihiro "Matz" Matsumoto 041351fb05 No need to get the irep record size twice. 2020-10-12 18:20:28 +09:00
Yukihiro "Matz" Matsumoto 34356974ee Update MRB_FLOAT_FMT to always use double precision. 2020-10-12 18:20:28 +09:00
Yukihiro "Matz" Matsumoto d2b548de60 Remove the length of `Float' pool from the binary dump.
Also fixed the size calculation of `irep` dump, that could cause memory
corruption.
2020-10-12 18:20:28 +09:00
Yukihiro "Matz" Matsumoto c80ece2149 Add bintest to host-m32 target. 2020-10-12 18:20:27 +09:00
Yukihiro "Matz" Matsumoto 356b719fef Remove DEBUG_ONLY_EXPR() from CHECKPOINT_* macros; ref #5060
To allow C++ compilation. Fix suggested by @dearblue.
2020-10-12 18:20:27 +09:00
Yukihiro "Matz" Matsumoto 896338e219 Unify mrb_str_to_str to mrb_obj_as_string.
Redirect `mrb_str_to_str` to `mrb_obj_as_string` via C macro.
Inspired by #5082
2020-10-12 18:20:26 +09:00
Yukihiro "Matz" Matsumoto bff79112a6 Dump/load 16 bits for ilen and slen in irep.
Those types are `uint16_t` in definition. Also we no longer need padding
for `iseq`.
2020-10-12 18:20:26 +09:00
Yukihiro "Matz" Matsumoto f1d02bfc15 Clarify the meaning of MRB_IREP_STATIC; ref #5084 2020-10-12 18:20:26 +09:00
Yukihiro "Matz" Matsumoto c1f5fdafb6 Remove duplicated constant IREP_TT_SFLAG; #5084 2020-10-12 18:20:25 +09:00
Yukihiro "Matz" Matsumoto 5d1d94d911 Use Markdown section marker #; ref #5084 [ci skip]
The fix was proposed by @dearblue
2020-10-12 18:20:25 +09:00
Yukihiro "Matz" Matsumoto 762556b6e8 Add const modifier to table in mrb_kwargs; #5084
The fix was proposed by @dearblue
2020-10-12 18:20:24 +09:00
Yukihiro "Matz" Matsumoto 618c589162 Should use PRId32 to dump .i32; ref #5084
The fix was proposed by @dearblue
2020-10-12 18:20:24 +09:00
Yukihiro "Matz" Matsumoto ab2b42d363 Update bintest of mruby-bin-debugger.
Need to support `int / int -> int` update.
2020-10-12 18:20:24 +09:00
Yukihiro "Matz" Matsumoto b9007244bd Add const before struct mrb_irep in mruby-bin-debugger gem. 2020-10-12 18:20:23 +09:00
Yukihiro "Matz" Matsumoto 7932523052 Remove host-debug internal target.
Target `host-debug` to use `host` internal target with debugging
configuration.
2020-10-12 18:20:23 +09:00
Yukihiro "Matz" Matsumoto 12881ccb05 Use NULL instead of 0; close #2467
The PR was from @cubicdaiya.
2020-10-12 18:20:23 +09:00
Yukihiro "Matz" Matsumoto 3ff2757bf7 Fix mrb_int_mul_overflow() to check either operand being zero. 2020-10-12 18:20:22 +09:00
Yukihiro "Matz" Matsumoto 4dcc1819c9 Embed debug information to resolve Windows VC's issue. 2020-10-12 18:20:22 +09:00
Yukihiro "Matz" Matsumoto 21ee56d82a Adjust backslash position in multi-line macros. 2020-10-12 18:20:21 +09:00
Yukihiro "Matz" Matsumoto 55a2ff5faf Use MRB_INT_MAX instead of INT_MAX according to variable type. 2020-10-12 18:20:21 +09:00
Kondo Uchio ed97c1779e Remove duplicated pattern 2020-10-12 18:20:21 +09:00
Uchio Kondo 0d8793047d Scan ruby files in directories 2020-10-12 18:20:20 +09:00
Kondo Uchio cbb46f6975 Exact match to allowed method/variable names 2020-10-12 18:20:20 +09:00
Uchio Kondo 0c242e278d Ensure exact match for symbols like foo!/foo?/foo=
e.g. symbols like "foo[]=" make invalid C codes
2020-10-12 18:20:20 +09:00
Yukihiro "Matz" Matsumoto 932b93fd12 Skip C comments from scan target; close #5072
The original PR was skipping Ruby comments as well, but caused some
issues in test suites.
2020-10-12 18:20:19 +09:00
Yukihiro "Matz" Matsumoto a4c5824e59 Restore old function names for compatibility; ref #5070
- `mrb_check_intern()` to return `mrb_value`
- `mrb_intern_check()` to return `mrb_sym` [NEW]

Other new functions:

- `mrb_intern_check_cstr()`
- `mrb_intern_check_str()`
2020-10-12 18:20:19 +09:00
Yukihiro "Matz" Matsumoto afcf19b727 Scan source code lines from downloaded mrbgems; fix #5071 2020-10-12 18:20:18 +09:00
Yukihiro "Matz" Matsumoto 30424dfa74 Restore old function names for compatibility; fix #5070
Rename new functions:

- `mrb_convert_type(mrb,val,type,tname,method)`
   => `mrb_type_convert(mrb,val,type,tname,method)`
- `mrb_check_convert_type(mrb,val,type,tname,method)`
   => `mrb_type_convert_check(mrb,val,type,tname,method)`

Old names are defined by macros (support `tname` drop and
`char*` => `mrb_sym` conversion).
2020-10-12 18:20:18 +09:00
Yukihiro "Matz" Matsumoto 9b8e5658ce Fix integer casting on 64 bit platforms.
On platforms where `sizeof(long)` is 4, casting `(long)` can lose data
or sign information.
2020-10-12 18:20:18 +09:00
Yukihiro "Matz" Matsumoto a127ded486 Fix warning from VC regarding implicit int conversion. 2020-10-12 18:20:17 +09:00
Yukihiro "Matz" Matsumoto fe3c3bb661 Made Rational overhaul.
- Implement `Rational()` in `C`.
- Use `float` to `rational` conversion function taken from:
  https://rosettacode.org/wiki/Convert_decimal_number_to_rational#C
2020-10-12 18:20:17 +09:00
Yukihiro "Matz" Matsumoto f9e781d83a Avoid unsigned int; Use mrb_int instead. 2020-10-12 18:20:16 +09:00
Yukihiro "Matz" Matsumoto fc8885f2f4 Use mrb_int extensively instead of int.
The mixture causes warnings on 64 bit Windows (VC).
2020-10-12 18:20:16 +09:00
Yukihiro "Matz" Matsumoto fe1ad37bfb Use goto to avoid problems with DIRECT_THREADED.
You can now use `NEXT` within `switch` statement like 7c087eb.
2020-10-12 18:20:16 +09:00
Yukihiro "Matz" Matsumoto 9e842b3a75 Extract div code in VM and make them shared by div methods. 2020-10-12 18:20:15 +09:00
Yukihiro "Matz" Matsumoto b81edb0035 Don't use NEXT within switch statement.
On non-`gcc` compatible environment, `NEXT` is translated to `break`.
2020-10-12 18:20:15 +09:00
Yukihiro "Matz" Matsumoto 86dee45f1d Remove meaningless IO.open(1<<32) test. 2020-10-12 18:20:15 +09:00
Yukihiro "Matz" Matsumoto 08f61db6ee Skip some Math.atan2() tests.
Linux `atan2(3)` man page says:

```
If  y is positive infinity (negative infinity) and x is positive infinity,
+pi/4 (-pi/4) is re‐ turned.
```

But on Microsoft VC/MinGW, `atan2()` returns `NaN` if either of
arguments is infinite. So we skip those tests on the platforms.
2020-10-12 18:20:14 +09:00
Yukihiro "Matz" Matsumoto 7f66e50ba2 Explain MRB_USE_MALLOC_TRIM; ref #5069 2020-10-12 18:20:14 +09:00
Rory OConnell 5592c7413a Remove compiler feature detection 2020-10-12 18:20:14 +09:00
Rory OConnell fff0f17b49 Better malloc_trim define name 2020-10-12 18:20:13 +09:00
Rory OConnell 2b05cf48d0 Work around removing tmp dir 2020-10-12 18:20:13 +09:00
Rory OConnell dae0de4461 Add call to malloc_trim on a full GC 2020-10-12 18:20:12 +09:00
Rory OConnell cfe8b0c81d Add methods for asking about compiler features 2020-10-12 18:20:12 +09:00
Yukihiro "Matz" Matsumoto 026726dd49 Remove obsolete MRB_WITHOUT_FLOAT macro from numeric.c. 2020-10-12 18:20:12 +09:00
Yukihiro "Matz" Matsumoto d7986b449d Change some int variables to mrb_int.
To silence some warnings. This change cancels part of 7ef3604134.
2020-10-12 18:20:11 +09:00
Yukihiro "Matz" Matsumoto 4970e24a1c Remove full-core from target/appveyor.rb. 2020-10-12 18:20:11 +09:00
Yukihiro "Matz" Matsumoto 950e60363a Update IO#popen to use keyword arguments instead of Hash args. 2020-10-12 18:20:11 +09:00
Yukihiro "Matz" Matsumoto 87c7064bad Update mrb_get_args() keyword argument support [incompatible]
* `mrb_kwargs` structure reordered (`values` and `rest` come last)
* take symbols instead of C `char*`
2020-10-12 18:20:10 +09:00
Yukihiro "Matz" Matsumoto 4cf1da9542 Separate jump destination check in OP_R_RETURN.
In the past code, the current `callinfo (ci)` was modified, thus it was
possible to pop `ci` beyond the `cibase`, that could cause out of memory
bound access for the code like the following:

```ruby
def m2
  lambda {
    Proc.new {
      return :return # return from the method
    }
  }.call.call
  :never_reached
end

p m2
```
2020-10-12 18:20:10 +09:00
Yukihiro "Matz" Matsumoto b01207ea94 Make the scope of const struct RProc *dst narrower. 2020-10-12 18:20:09 +09:00
Yukihiro "Matz" Matsumoto c2444b8424 Redefine CHECKPOINT_* macros.
By definition `mrb_assert()` called only when `MRB_DEBUG` is defined too.
But make I wanted to make clear that the local variable `current_checkpoint_tag`
is only accessed when `MRB_DEBUG` is set by wrapping with `DEBUG_ONLY_EXPR()`.
2020-10-12 18:20:09 +09:00
Yukihiro "Matz" Matsumoto 8461be11fc Include mruby/endian.h only when MRB_NO_FLOAT is undefined. 2020-10-12 18:20:09 +09:00
Yukihiro "Matz" Matsumoto 260db0f5fb Abandon packing all lower case symbols with 6 characters.
To make packed inline symbols within 31 bits, because the new method
hash tables allows only 31 bits of symbols. They use top 1 bit to maek
unused slots.
2020-10-12 18:20:08 +09:00
Yukihiro "Matz" Matsumoto 99ef00fe02 Add U prefix for mrb_sym dump.
Since `%u` of `mrb_sym` may be its MSB turned on.
2020-10-12 18:20:08 +09:00
Yukihiro "Matz" Matsumoto b9dfd0438f Don't compare int' with size_t (from sizeof()`). 2020-10-12 18:20:08 +09:00
Yukihiro "Matz" Matsumoto d0b5d720ac Use mrb_integer() instead of mrb_int().
`mrb_int()` includes implicit integer conversion, where `mrb_integer()`
does not. In this case, we know `obj` is an integer before hand.
2020-10-12 18:20:07 +09:00
Yukihiro "Matz" Matsumoto dd1ce5d53e Silence warnings from implicit integer conversions.
Caused from combination of `mrb_int`, `int` and `size_t`..
2020-10-12 18:20:07 +09:00
Yukihiro "Matz" Matsumoto 7eaaee5405 Add a new gem: mruby-catch.
Implements `catch`/`throw` non-local jump inherited from Lisp.

`catch([tag]) {|tag| block }  -> obj`

Example:
```
  catch(:foo) { 123 }               # => 123
  catch(:foo) { throw(:foo, 456) }  # => 456
  catch(:foo) { throw(:foo) }       # => nil
```
2020-10-12 18:20:07 +09:00
Yukihiro "Matz" Matsumoto 471479e723 Change float representation in mrb binary files.
From human readable (ASCII) string representation to binary dump of
IEEE754 in little endian.
2020-10-12 18:20:06 +09:00
Yukihiro "Matz" Matsumoto 397b005715 Replace the implementation of method tables in classes/modules.
They are basically the copy of instance variable tables. On my Linux
box, memory consumption of `mrbtest` measured by `valgrind` is:

- old: 17,683,830 bytes
- new: 14,283,749 bytes
2020-10-12 18:20:06 +09:00
Yukihiro "Matz" Matsumoto bf118b9006 Stop warning on 64 bit platforms. 2020-10-12 18:20:06 +09:00
Yukihiro "Matz" Matsumoto 7e3d22f095 Raname mrb_exc_new_str_lit() to mrb_exc_new_lit().
It uses `mrb_str_new_lit()` internally, but it doesn't need to express
it in the name of the function (macro).
2020-10-12 18:20:06 +09:00
Yukihiro "Matz" Matsumoto 01dbbcd553 Handle integer overflow in rational_s_new. 2020-10-12 18:20:05 +09:00
Yukihiro "Matz" Matsumoto e479a42757 Handle potential overflow in int_div and flo_idiv. 2020-10-12 18:20:05 +09:00
Yukihiro "Matz" Matsumoto 5134031e18 Use mrb_int_value() instead of mrb_fixnum_value().
Where fixnum overflow can happen.
2020-10-12 18:20:05 +09:00
Yukihiro "Matz" Matsumoto befcbd5607 Add MRB_NAN_BOXING for boxing target. 2020-10-12 18:20:04 +09:00
Yukihiro "Matz" Matsumoto 9d613159b5 Add mrb_integer() definition for MRB_NAN_BOXING. 2020-10-12 18:20:04 +09:00
Yukihiro "Matz" Matsumoto 3e71359d7a Update mruby-random gem to support 32 bit platforms.
`sizeof(rand_state)` had been bigger than `sizeof(void*)*3`. Changed
random number generator to `Xorshift96` on 32 bit platforms.
2020-10-12 18:20:04 +09:00
Yukihiro "Matz" Matsumoto 2b188ed8a1 Reorganize Integer system.
- Integrate `Fixnum` and `Integer`
- Remove `Integral`
- `int / int -> int`
- Replace `mrb_fixnum()` to `mrb_int()`
- Replace `mrb_fixnum_value()` to `mrb_int_value()`.
- Use `mrb_integer_p()` instead of `mrb_fixnum_p()`
2020-10-12 18:19:54 +09:00
n4o847 59af217779 Remove unnecessary assignment in String#upto
Co-authored-by: taiyoslime <t@iyosli.me>
Co-authored-by: smallkirby <ssmallkirby@gmail.com>
2020-10-12 16:50:22 +09:00
Yukihiro "Matz" Matsumoto 2bb84f1f1a Update build process for both host and cross compile. 2020-10-12 16:21:52 +09:00
Yukihiro "Matz" Matsumoto 850e200e84 Describe the need for -o option if multi files given. 2020-10-12 16:21:51 +09:00
Yukihiro "Matz" Matsumoto b978231bda Update usage description of mrbc. 2020-10-12 16:21:51 +09:00
Yukihiro "Matz" Matsumoto b7fe929232 Update Rakefile.
So that you can omit `host` target. Now `host-debug` works.
2020-10-12 16:21:51 +09:00
Yukihiro "Matz" Matsumoto 20ffc2206a "backport" CRuby r46756; ref #3500
Based on cremno/mruby@6bd0119
2020-10-12 16:21:50 +09:00
Yukihiro "Matz" Matsumoto caee1f68a2 Change the return type of mrb_check_intern() and friends.
They used to return `mrb_value` but now return `mrb_sym` for consistency
with other `intern` functions. If symbols are not defined, `check`
functions return `0`, instead of `nil` in the past.

It causes API incompatibility but I believe few people use those
functions out of the core, and those changes are very easy to handle,
hopefully.
2020-10-12 16:21:50 +09:00
Yukihiro "Matz" Matsumoto a4302524d0 Avoid using mrb_check_intern_str().
We call `mrb_intern_str()` later anyway, so there's no need to avoid
defining a new symbol here.
2020-10-12 16:21:49 +09:00
Yukihiro "Matz" Matsumoto 12d31c33af "backport" CRuby r46656; #2500
Based on cremno/mruby@d446192
2020-10-12 16:21:49 +09:00
Yukihiro "Matz" Matsumoto 5a7cbebc8a Remove MRB_NO_FLOAT_INLINE and MRB_WBOX_FLOAT_INLINE configuration.
They are not used from the beginning.
2020-10-12 16:21:49 +09:00
Yukihiro "Matz" Matsumoto 04fd7af23c Fixed ISO section numbers in test/t/superclass.rb. 2020-10-12 16:21:48 +09:00
Yukihiro "Matz" Matsumoto 2a92fb2516 Make division by zero cause ZeroDivisionError.
As described in ISO 15.2.30.
2020-10-12 16:21:48 +09:00
Yukihiro "Matz" Matsumoto 18e3d39ee2 Fixed wrong size calculation for memsize_of(). 2020-10-12 16:21:47 +09:00
Yukihiro "Matz" Matsumoto 55163a8a0a Rename MRB_TT_FIXNUM to MRB_TT_INTEGER.
We still have `#define MRB_TT_FIXNUM MRB_TT_INTEGER` for compatibility.
2020-10-12 16:21:47 +09:00
cremno 867268897a change linkage to internal 2020-10-12 16:21:47 +09:00
cremno 11317de468 define sprintf and format as global functions 2020-10-12 16:21:46 +09:00
cremno 857a1d9fc9 move mrbgem initialization into sprintf.c
Also remove some unnecessary code.
2020-10-12 16:21:46 +09:00
cremno b44326b561 Add tests for CRuby bug #9982
https://bugs.ruby-lang.org/issues/9982
2020-10-12 16:21:45 +09:00
KOBAYASHI Shuji 8bd1bc47b3 Always add trailing .0 in Float#inspect; ref #4225
Trailing `.0` is removed from `Float#to_s` and `Float#inspect` at
9d08025b. However, I think the more human-readable format is better
for `Float#inspect`.

For example, in the `Float#to_s` format, the failure message is not
well understood when testing values including types by `eql?` (e.g.
`Numeric#step` test).

  ```ruby
  assert "example" do
    exp = 1.0
    act = 1
    assert_operator(exp, :eql?, act)  #=> Expected 1 to be eql? 1.
  end
  ```
2020-10-12 16:21:45 +09:00
Yukihiro "Matz" Matsumoto c45674aff0 Rename mruby_version in the lockfile to mruby; close #4658 2020-10-12 16:21:44 +09:00
dearblue 80fe9838d2 Integrate Fixnum class into Integer class
* The `Fixnum` constant is now an alias for the `Integer` class.
* Remove `struct mrb_state::fixnum_class` member.
  If necessary, use `struct mrb_state::integer_class` instead.
2020-10-12 16:21:44 +09:00
KOBAYASHI Shuji 40d0d8fe0e Fix Fixnum and Float comparison in Hash lookup
```console
  $ bin/mruby -e 'p({1 => 2}.key?(1.0))'
  true
  ```

  ```console
  $ bin/mruby -e 'p({1 => 2}.key?(1.0))'
  false
  ```
2020-10-12 16:21:44 +09:00
Yukihiro "Matz" Matsumoto ee544dc881 Update the PR #4922 according to #3123.
close #3123
2020-10-12 16:21:43 +09:00
Yukihiro "Matz" Matsumoto ed32b6fcdc Update tests for integer division. 2020-10-12 16:21:43 +09:00
Yukihiro "Matz" Matsumoto c8cf9512cd Update the PR #4992 to enable integer division always. 2020-10-12 16:21:43 +09:00
Lanza 1835753f9f Update vm.c 2020-10-12 16:21:42 +09:00
Yukihiro "Matz" Matsumoto 424afa4446 Make Proc#parameters to support keyword arguments; fix #5066
TODO: Unlike CRuby, mruby's `Proc#parameters` does not distinguish
required keyword arguments and optional keyword arguments currently.
2020-10-12 16:21:42 +09:00
Yukihiro "Matz" Matsumoto 02e69d1c2c Update mruby3.md. 2020-10-12 16:21:41 +09:00
Yukihiro "Matz" Matsumoto 44a07393f4 Use xoshiro128++ instead of xorshift96/128. 2020-10-12 16:21:41 +09:00
Yukihiro "Matz" Matsumoto 0b22bf4a89 Fix rand_real to return random number [0,1) not [0,1]. 2020-10-12 16:21:41 +09:00
Yukihiro "Matz" Matsumoto 1520c97e17 Add default host target for cross compiling.
You don't have to define explicit `host` build target any more.
2020-10-12 16:21:40 +09:00
Yukihiro "Matz" Matsumoto 8a87549315 Rename float configuration option names.
- `MRB_WITHOUT_FLOAT` => `MRB_NO_FLOAT`
- `MRB_USE_FLOAT` => `MRB_USE_FLOAT32`

The former is to use `USE_XXX` naming convention. The latter is to make
sure `float` is 32bit float and not floating point number in general.
2020-10-12 16:21:40 +09:00
Yukihiro "Matz" Matsumoto ef9df5dc7d Allow MRUBY_CONFIG to specify target file out of source tree. 2020-10-12 16:21:39 +09:00
Yukihiro "Matz" Matsumoto 7dc595f98f Add a new document named mruby3.md.
That describes the changes in `mruby3`.
2020-10-12 16:21:39 +09:00
Yukihiro "Matz" Matsumoto d4b89ccc61 Add assertion we can pack function pointers in mrb_method_t.
If this assertion fails, you have to define `MRB_USE_METHOD_T_STRUCT`.
2020-10-12 16:21:39 +09:00
Yukihiro "Matz" Matsumoto 72d071540c Rename MRB_METHOD_T_STRUCT to MRB_USE_METHOD_T_STRUCT.
It's the first change of renaming configuration options to `MRB_XXX` to
`MRB_USE_XXX` or `MRB_NO_XXX`.
2020-10-12 16:21:38 +09:00
Yukihiro "Matz" Matsumoto dea185e687 Change out-of-range condition of time_t conversion. 2020-10-12 16:21:38 +09:00
Yukihiro "Matz" Matsumoto 968053a35b Avoid out-of-range error for negative time on MRB_TIME_T_UINT.
On platforms where `time_t` is unsigned, negative time can be a result
of integer casting. Out-of-range error is too strict for those cases.
This fix does not address wrong time value in `MRB_WORD_BOXING`. It will
be addressed later (by introducing "big" integers).
2020-10-12 16:21:37 +09:00
Yukihiro "Matz" Matsumoto 66114f8332 Change default mrb_value representation to MRB_WORD_BOXING. 2020-10-12 16:21:37 +09:00
Yukihiro "Matz" Matsumoto 8813ebec07 Skip array embedding if MRB_NO_BOXING and MRB_32BIT; fix #4382
On some platforms, `sizeof(mrb_value) > sizeof(void*)*3`, which makes
`MRB_ARY_EMBED_LEN_MAX` zero. And zero sized array cause compile errors.
2020-10-12 16:21:36 +09:00
Yukihiro "Matz" Matsumoto a93ef815be Add static check for MRB_USE_FLOAT and MRB_WITHOUT_FLOAT. 2020-10-12 16:21:36 +09:00
Yukihiro "Matz" Matsumoto 905d4010bf Fix wrong YAML in .github/workflows/build.yml. 2020-10-12 16:21:36 +09:00
Yukihiro "Matz" Matsumoto 763b39d00b Simplify NaN boxing definitions.
Remove `#ifdef` from `union mrb_value_`.
2020-10-12 16:21:35 +09:00
Yukihiro "Matz" Matsumoto 107c777341 Rename OP_JUW instruction to OP_JMPUW. 2020-10-12 16:21:35 +09:00
Yukihiro "Matz" Matsumoto 500f721f70 Fix typo _hander -> _handler. 2020-10-12 16:21:34 +09:00
Yukihiro "Matz" Matsumoto cb89e1f0d9 Adjust PR #5060 to the latest mruby3 branch. 2020-10-12 16:21:34 +09:00
dearblue 6bc5857125 Suppress warnings for C++
Variables in jump destination block separate declaration and assignment.
2020-10-12 16:21:34 +09:00
dearblue bfb7b491cc Restore the variable pc after longjmp()
Changes made after `setjmp()` are destroyed and need reassignment.
This problem is now caused by the addition of the `OP_JUW` instruction.

When actually building on FreeBSD 12.1 with `clang10 -fsanitize=address`, mrbtest "NameError#name [15.2.31.2.1]" is failed.

However, qualifying `pc` with `volatile` slows down significantly and increases the object code.
Suppress them by qualifying only the variables that restore `pc`.
2020-10-12 16:21:33 +09:00
dearblue c1f112c49a Replace global jump with catch handler implementation
When a global jump occurs, look at the catch handler table to determine where to jump.
In that case, `pc` already shows the following instruction, but since the table shows `begin_offset ... end_offset`, the comparison is done with `begin_offset < pc && pc <= end_offset`.
If there is a corresponding handler, move `pc` to `handler.target_offset` and continue running the VM.

When a global jump across `ensure` is made by `return`, `break`, `next`, `redo` and `retry`, the extended `RBreak` object saves and restores the C-level execution position.
This extended `RBreak` can have tag information, which makes it a pseudo coroutine (the "tag" mimics CRuby).

The implementation of pseudo coroutines by `RBreak` is summarized by `CHECKPOINT_RESTORE ... CHECKPOINT_MAIN ... CHECKPOINT_END` and `throw_tagged_break` / `unwind_ensure` macros.
The restart of processing is branched by `RBREAK_TAG_FOREACH(DISPATCH_CHECKPOINTS)`.

- Not only `rescue` blocks but also `ensure` blocks are now sandwiched between `OP_EXCEPT` and `OP_RAISEIF`.

- Remove the function `ecall()`.
  It is no longer necessary to re-enter the VM to perform an "ensure block".

  This will resolves #1888.

- Added instruction `OP_JUW` (Jump while UnWind).

  It jumps unconditionally like `OP_JMP`, but searches the catch handler table and executes the ensure block.
  Since it searches the catch handler table, it is much heavier than `OP_JMP`.
2020-10-12 16:21:33 +09:00
dearblue 0d7b4deccf Removed push/pop instructions for rescue/ensure
`OP_PUSHERR`, `OP_POPERR`, `OP_EPUSH` and `OP_EPOP` are removed.
2020-10-12 16:21:32 +09:00
dearblue f467b02d45 Extended OP_EXCEPT and OP_RAISE (OP_RAISEIF) instructions
- `OP_EXCEPT` checks if `mrb->exc` is `NULL`, `MRB_TT_EXCEPTION` or
  `MRB_TT_BREAK`.
  If `mrb->exc` is `NULL`, it will be replaced with `nil`.

- If `OP_RAISE` is `nil`, it does nothing and the immediately
  following instruction is executed (like `OP_NOP`).
  Also, in case of `RBreak` object, it moves to the processing for
  `break`.
  With this change, the instruction name is changed from
  `OP_RAISE` to `OP_RAISEIF`.
2020-10-12 16:21:32 +09:00
dearblue a54a3df32c Extended mruby binary format
The catch handler table is combined with iseq block.
This is to prevent the structure from growing by adding a field for the
catch handler table to the `mrb_irep` structure.

"iseq block" and "catch handler table":
  [number of catch handler table (2 bytes)]
  [number of byte code (4 bytes)]
  [iseq (any bytes)]
  [catch handlers (multiple of 7 bytes)]

catch handler:
  [catch type (1 byte)]
  [begin offset (2 bytes)]
  [end offset (2 bytes)]
  [target offset (2 bytes)]

catch type: enum mrb_catch_type (0 = rescue, 1 = ensure)
begin offset: Includes the specified instruction address
end offset: Does not include the specified instruction address
target offset: replaces pc with the specified instruction address

This table is not expanded by `read_irep_record_1()`.
The necessary elements are expanded one by one when used.
2020-10-12 16:21:32 +09:00
Yukihiro "Matz" Matsumoto 3ad6bbc40c Add target/host-cxx.rb to compile mruby with cxx_abi. 2020-10-12 16:21:31 +09:00
Yukihiro "Matz" Matsumoto 67d92c48b5 Avoid breaking the result array by side-effect in C++. 2020-10-12 16:21:31 +09:00
Yukihiro "Matz" Matsumoto 6fbc03b3a8 Revert 4c001673b
Probably I misunderstand strict aliasing rule of C++. The fix in
4c001673b was other way around.
2020-10-12 16:21:30 +09:00
Yukihiro "Matz" Matsumoto 690cafe274 Initialize kdict in OP_ENTER in vm.c. 2020-10-12 16:21:30 +09:00
Yukihiro "Matz" Matsumoto 4e56e0defc Rename union mrb_value to union mrb_value_.
Since some compiler complains when we `typedef` `mrb_value`.
2020-10-12 16:21:30 +09:00
Yukihiro "Matz" Matsumoto 53e46be7e2 Simplify mrb_value structure for MRB_WORD_BOXING. 2020-10-12 16:21:29 +09:00
Yukihiro "Matz" Matsumoto 73e289c54e Simplify mrb_value structure for MRB_NAN_BOXING. 2020-10-12 16:21:29 +09:00
Yukihiro "Matz" Matsumoto ce372122ed Remove mc_clear_by_id.
Clearing all method cache using `memset` is faster than conditional
clear by method id.
2020-10-12 16:21:28 +09:00
Yukihiro "Matz" Matsumoto a733c6e0ea Do not call mrb_mc_clear_by_class at mrb finalization. 2020-10-12 16:21:28 +09:00
Yukihiro "Matz" Matsumoto 425b142168 Refine MRB_NAN_BOXING on 32bit architecture.
You don't need pointer tweaking on 32bit architecture, where pointers
fit in 32bit (lower half of mrb_value).
2020-10-12 16:21:27 +09:00
Yukihiro "Matz" Matsumoto f751c28ca4 Add target/host-m32.rb to compile mruby in 32bit mode.
Tested only on Linux. You need to install 32bit relate libraries,
e.g. libc6-dev-i386.
2020-10-12 16:21:27 +09:00
Yukihiro "Matz" Matsumoto 4281429412 Use memset() to clear method cache. 2020-10-12 16:21:27 +09:00
Yukihiro "Matz" Matsumoto 0e50ea90f3 Add const specifier to cipush(); ref #5052 2020-10-12 16:21:26 +09:00
Yukihiro "Matz" Matsumoto 1eb71b008f Change default boxing scheme from MRB_NO_BOXING.
On 64bit platforms: `MRB_NAN_BOXING`
On 32bit platforms: `MRB_WORD_BOXING`
On debugging: `MRB_NO_BOXING`
2020-10-12 16:21:26 +09:00
Yukihiro "Matz" Matsumoto 84a68ca5ae Make sure bintest only works with host target. 2020-10-12 16:21:26 +09:00
Yukihiro "Matz" Matsumoto 5e9dc72bc5 Pack mrb_value into uint64_t when MRB_NAN_BOXING. 2020-10-12 16:21:25 +09:00
Yukihiro "Matz" Matsumoto 1eacdae319 Use hash table instead of segment list for instance variables. 2020-10-12 16:21:25 +09:00
Yukihiro "Matz" Matsumoto 59b35250cc Rename mrb_hash_modify to hash_modify.
Since it's an internal static function.
2020-10-12 16:21:24 +09:00
Yukihiro "Matz" Matsumoto 2b45d454bc Use mrb_field_write_barrier instead of mrb_write_barrier for push.
When the array is very big, the simpler `mrb_write_barrier` causes
calling `gc_mark_children` for big arrays repeatedly. That would hinder
performance very badly.
2020-10-12 16:21:24 +09:00
Yukihiro "Matz" Matsumoto ff0e3bcea6 Check lv before printing local variable names. 2020-10-12 16:21:24 +09:00
Yukihiro "Matz" Matsumoto 8b3f3c0bf3 Fix the bug by the combination with MRB_64BIT and MRB_INT32.
Which is caused by `MRB_NAN_BOXING`.
2020-10-12 16:21:23 +09:00
Yukihiro "Matz" Matsumoto cf2aabdad6 Run tests for target/boxing.rb. 2020-10-12 16:21:23 +09:00
Yukihiro "Matz" Matsumoto 3d8a38bea4 You don't need to keep index in local variables info in irep. 2020-10-12 16:21:22 +09:00
Yukihiro "Matz" Matsumoto 639946a006 Enable method cache by default.
Introduced `MRB_NO_METHOD_CACHE` which is inverse of `MRB_METHOD_CACHE`
that should be enabled intestinally. In addition, the default cache is
made bigger (128 -> 256).
2020-10-12 16:21:22 +09:00
Yukihiro "Matz" Matsumoto fb5e8ab6d5 Provide a new build target host-gprof that enables profiling. 2020-10-12 16:21:21 +09:00
Yukihiro "Matz" Matsumoto 11955ca1a1 Call #initialize_copy from init_copy only if it's redefined. 2020-10-12 16:21:21 +09:00
Yukihiro "Matz" Matsumoto 52dd0a8cd7 Skip mrb_get_args() in mrb_ary_push(). 2020-10-12 16:21:21 +09:00
Yukihiro "Matz" Matsumoto 6db0162ec7 Upgrade RITE_VM_VERSION to 0300 (means mruby 3.0). 2020-10-12 16:21:20 +09:00
Yukihiro "Matz" Matsumoto dec34d6c7b Split MRB_BINARY_FORMAT to major and minor.
The minor versions should be upper compatible. So mere opcode, section
addition can be done without breaking compiled binary.
2020-10-12 16:21:20 +09:00
Yukihiro "Matz" Matsumoto 8f0ac27196 Update opcode reference and comment.
- no OP_EXT_ anymore
- OP_LOADI16 in right position
2020-10-12 16:21:19 +09:00
Yukihiro "Matz" Matsumoto fd10c72319 Remove OP_EXT[123] from operands. 2020-10-12 16:21:19 +09:00
Yukihiro "Matz" Matsumoto ce7508e0d5 Allow rescue modifier in endless method definitions. 2020-10-12 16:21:19 +09:00
Yukihiro "Matz" Matsumoto c29212cf44 Implement endless-def as in CRuby [Feature#16746]. 2020-10-12 16:21:18 +09:00
Yukihiro "Matz" Matsumoto 6e86e290e4 Rightward-assign by ASSOC.
[ruby-bugs:15921]
2020-10-12 16:21:18 +09:00
Yukihiro "Matz" Matsumoto b2398879fa Avoid including limits.h and stdint.h before mruby.h.
They are included from `mruby.h` anyway, and including it ahead can
cause some errors regarding `INT32_MAX` etc. with C++ compiler.
2020-10-12 16:21:18 +09:00
Yukihiro "Matz" Matsumoto e01648b86b Stop CXX_ABI test with VisualC++.
This combination is too hard to support. Difference between C and C++ is
too big with VisualC++. GCC and clang are OK.
2020-10-12 16:21:17 +09:00
Yukihiro "Matz" Matsumoto e0c9b53217 Run rake gensym on AppVeyor. 2020-10-12 16:21:17 +09:00
Yukihiro "Matz" Matsumoto ce30a4e04b Add const to irep structure to place data on ROM. 2020-10-12 16:21:16 +09:00
Yukihiro "Matz" Matsumoto 31877043c4 Invoke rake gensym for GitHub action build. 2020-10-12 16:21:16 +09:00
Yukihiro "Matz" Matsumoto 167a747a41 Constify irep struct for Class#new. 2020-10-12 16:21:16 +09:00
Yukihiro "Matz" Matsumoto cfc958b01a Add const qualifier to generated Proc structures. 2020-10-12 16:21:15 +09:00
Yukihiro "Matz" Matsumoto 015f06ed8e Should not mark red (i.e. ROM allocated) objects. 2020-10-12 16:21:15 +09:00
Yukihiro "Matz" Matsumoto 95169097fc Add /std:c++latest option to VC CXX_ABI build. 2020-10-12 16:21:14 +09:00
Yukihiro "Matz" Matsumoto 474545bba2 Do not define mrb_lstat unless S_ISLNK is defined. 2020-10-12 16:21:14 +09:00
Yukihiro "Matz" Matsumoto 925cd2ab8f Use int instead of mrb_int for arena index. 2020-10-12 16:21:14 +09:00
Yukihiro "Matz" Matsumoto 9debf63340 Specify the size of struct RStringEmbed array part. 2020-10-12 16:21:13 +09:00
Yukihiro "Matz" Matsumoto 0f978932e2 Use %u instead of %d to dump symbol IDs. 2020-10-12 16:21:13 +09:00
Yukihiro "Matz" Matsumoto 6488ae855f Avoid use of designated initializer for the sake of cxx_abi. 2020-10-12 16:21:13 +09:00
Yukihiro "Matz" Matsumoto d2f267a13d Add casts to silence warnings. 2020-10-12 16:21:12 +09:00
Yukihiro "Matz" Matsumoto a4a1e01e81 Add explicit gensym to GitHub Actions. 2020-10-12 16:21:12 +09:00
Yukihiro "Matz" Matsumoto ee111dd175 Clarify the use of MRB_64BIT and MRB_INT64 in dump.c and load.c.
- `MRB_64BIT`: the size of a pointer is 64 bits
- `MRB_INT64`: the size of `mrb_int` is 64 bits
2020-10-12 16:21:11 +09:00
Yukihiro "Matz" Matsumoto f0c1126997 Fix dump.c for MRB_INT32 env. 2020-10-12 16:21:11 +09:00
Yukihiro "Matz" Matsumoto b7031e8bc8 Enable NUL (\0) again. 2020-10-12 16:21:10 +09:00
Yukihiro "Matz" Matsumoto 52507b1083 Generate C struct from irep instead of binary dump. 2020-10-12 16:21:10 +09:00
Yukihiro "Matz" Matsumoto 7deb41b0e8 Generate C source file to represent mrb_irep structures.
Type `mrbc -S -B<init> -o<outfile> <rbfiles...>` to generate the C
source code that holds compiled `mrb_irep`.

Appending the following code to the bottom of the generated code,
`mruby` executes the compiled code:

```C
int
main()
{
  mrb_state *mrb = mrb_open();
  struct RProc *p = mrb_proc_new(mrb, &init_irep);
  mrb_vm_run(mrb, p, mrb_top_self(mrb), 0);
  mrb_close(mrb);
  return 0;
}
```

Eventually static compile should use this representation, instead
of `uint8_t` array that holds `mrb` data, so that we can skip
interpreting `mrb` data.
2020-10-12 16:21:09 +09:00
Yukihiro "Matz" Matsumoto f1c06eef7c Scan more symbols from Ruby files by rake gensym. 2020-10-12 16:21:09 +09:00
Yukihiro "Matz" Matsumoto 449317a251 Removed alignment pragma from -B output from mrbc.
We no longer need 4 bytes alignment after we moved to the byte oriented
instructions.
2020-10-12 16:21:09 +09:00
Yukihiro "Matz" Matsumoto d428fa0c4a Replace entire irep->pool.
Changes:
- `pool format is completely replaced
  - supported types: `STR`, `INT32`, `INT64`, `FLOAT`
  - `FLOAT` may be replaced by binary representation in the future
- insert `NUL` after string literals in `mrb` files
- `irep->pool` no longer store values in `mrb_value`
- instead it stores in `mrb_pool_value`
- less allocation
- `mrb_irep` can be stored in ROM
2020-10-12 16:21:08 +09:00
Yukihiro "Matz" Matsumoto daa37be549 Rename struct mrb_locals to struct mrb_lvinfo.
That stands for "local variable information".
2020-10-12 16:21:08 +09:00
Yukihiro "Matz" Matsumoto ad15e59cd9 Add irep C struct dump from mrbc with -S option.
But we need more work:
- recursive `irep` dump (`irep->reps`)
- pool values dump (`irep->pool`)
2020-10-12 16:21:07 +09:00
Yukihiro "Matz" Matsumoto 71eb4b2b22 Avoid use of designated initializers to generate irep struct.
Since it's not supported on VC without `/std:c++latest`. That means it
doesn't work for `cxx_api` build on Windows VC.
2020-10-12 16:21:07 +09:00
Yukihiro "Matz" Matsumoto d93b1a48d2 Make call_irep static. 2020-10-12 16:21:07 +09:00
Yukihiro "Matz" Matsumoto 3a64cde61d Add /std:c++latest to VC option in build.yml. 2020-10-12 16:21:06 +09:00
Yukihiro "Matz" Matsumoto 4684864f04 Specify new MRUBY_TARGET instead of MRUBY_CONFIG. 2020-10-12 16:21:06 +09:00
Yukihiro "Matz" Matsumoto dd8c178a73 Use static const struct mrb_irep each_irep to ininitalize each. 2020-10-12 16:21:06 +09:00
Yukihiro "Matz" Matsumoto 029c7c1116 Add const modifier to mrb_irep for code_fetch_hook. 2020-10-12 16:21:05 +09:00
Yukihiro "Matz" Matsumoto a68f005fd7 Remove remaining chomp:true option from Rakefile. 2020-10-12 16:21:05 +09:00
Yukihiro "Matz" Matsumoto 1adf93aa54 Stop Rake multitasking on Windows-VC for the time being. 2020-10-12 16:21:04 +09:00
Yukihiro "Matz" Matsumoto 26da07db15 Avoid using chomp:true option to File.readlines.
The option is not available in the old version of Ruby.
2020-10-12 16:21:04 +09:00
Yukihiro "Matz" Matsumoto 7ab7cadbbb Stringify non C identifier symbols to stop macro errors by old gcc. 2020-10-12 16:21:04 +09:00
Yukihiro "Matz" Matsumoto 2c1d209fd5 Remove rake -v option from GitHub Actions. 2020-10-12 16:21:03 +09:00
Yukihiro "Matz" Matsumoto 5a3e014e49 Constify irep members.
- `pool`
- `syms`
- `reps`
2020-10-12 16:21:03 +09:00
Yukihiro "Matz" Matsumoto 744ba80919 Add explicit cast to DROP_PRECISION macro in rational.c. 2020-10-12 16:21:02 +09:00
Yukihiro "Matz" Matsumoto 0d755e583c Build process updated:
You have to specify `TARGET` to specify a configuration, e.g.

```
rake TARGET=host-debug all test
```

When you port `mruby` to a new configuration:
1. copy an existing configuration under `target` directory
2. modify the new configuration file
3. build using the new configuration
4. send PR if you please
2020-10-12 16:21:02 +09:00
KOBAYASHI Shuji 92d8012b4e Refine .travis.yml
* Disable automatic update and clean up on `brew install` (install time
  160 sec -> 5 sec).
* Avoid using deprecated keys.
2020-10-12 16:21:02 +09:00
KOBAYASHI Shuji cc587e6535 Removed Bison related settings from .travis.yml and appveyor.yml 2020-10-12 16:21:01 +09:00
KOBAYASHI Shuji 1122124f97 Revert part of "Start GitHub Actions" (4ce3997c)
Because some changes have been overridden.
2020-10-12 16:21:01 +09:00
KOBAYASHI Shuji 5405977a6e Add y.tab.c to remove Bison from build dependencies; ref 4ce3997c
I sometimes see Bison related problems in setting up build environments.
Therefore to remove Bison from build time dependencies, add `y.tab.c`
generated by Bison to the repository.

The reduction of dependency at build time also reduces the labor and time
for setup and installation in CI.

In addition, a path in `#line` directive is converted to a relative path so
that its path is constant regardless of development environments.
2020-10-12 16:21:00 +09:00
Yukihiro "Matz" Matsumoto f6dcc6dcfc Use the newer bison on GitHub actions macOS; ref #4903
`Windows-MinGW` and `Windows-VC` also requires updates.
2020-10-12 16:21:00 +09:00
Takeshi Watanabe 9712379e0f Start GitHub Actions; close #4903 2020-10-12 16:21:00 +09:00
Yukihiro "Matz" Matsumoto b67955b8ca Change the arguments of following implicit conversion functions:
- `mrb_convert_type`
- `mrb_check_convert_type`

Those function no longer take `tname` string representation of desired
type, and take method symbols instead of `const char*` names. This is
incompatible change. I hope no third-party gems use those functions.
2020-10-12 16:20:59 +09:00
Yukihiro "Matz" Matsumoto 2a366ffba8 Use functions that take symbols to reduce string litrals in C. 2020-10-12 16:20:59 +09:00
Yukihiro "Matz" Matsumoto 8864c30d16 Provide functions that take symbols instead of const char*.
- mrb_define_class_id
- mrb_define_module_id
- mrb_define_method_id
- mrb_define_singleton_method_id
- mrb_define_module_function_id
- mrb_define_const_id
- mrb_undef_method_id
- mrb_undef_class_method_id
- mrb_class_defined_id
- mrb_class_get_id
- mrb_class_defined_under_id
- mrb_class_get_under_id
- mrb_module_get_id
- mrb_module_get_under_id
- mrb_define_class_under_id
- mrb_define_module_under_id
- mrb_exc_get_id
2020-10-12 16:20:59 +09:00
Yukihiro "Matz" Matsumoto 3516a3c012 Use mrb->eStandardError instead of mrb_exc_get(). 2020-10-12 16:20:58 +09:00
Yukihiro "Matz" Matsumoto fa6a9f6f13 Add functions that take symbols as arguments.
- :
2020-10-12 16:20:58 +09:00
Yukihiro "Matz" Matsumoto 00f5ddc9ae Use mrb_funcall_id() extensively.
Except for support files e.g. `mruby-test/driver.c`, which are not
target of symbol collection via `rake gensym`.
2020-10-12 16:20:58 +09:00
Yukihiro "Matz" Matsumoto dcd3e5907c Define a new function mrb_funcall_id().
`mrb_funcall_id()` takes `mrb_sym` instead of `char*` for a method name.
You can use `MRB_SYM()`/`MRB_QSYM()` to specify the method to call.
2020-10-12 16:20:57 +09:00
Yukihiro "Matz" Matsumoto 80c15ddd15 Update the build instruction. 2020-10-12 16:20:57 +09:00
Yukihiro "Matz" Matsumoto 7fde48b838 Remove unnecessary comments from host-shared target. 2020-10-12 16:20:56 +09:00
Yukihiro "Matz" Matsumoto 509f2bfd93 Add a new target clang-asan to use LLVM's address sanitizer. 2020-10-12 16:20:56 +09:00
Yukihiro "Matz" Matsumoto b941e91866 Use more MRB_QSYM(). 2020-10-12 16:20:56 +09:00
Yukihiro "Matz" Matsumoto 312f54b580 Add Rakefile to build/presym dependency. 2020-10-12 16:20:55 +09:00
Yukihiro "Matz" Matsumoto 3a162cc33f Run rake gensym before the build. 2020-10-12 16:20:55 +09:00
Yukihiro "Matz" Matsumoto b60809f117 Remove explicit rake gensym. 2020-10-12 16:20:55 +09:00
Yukihiro "Matz" Matsumoto 0881e34496 Add dependency from all to gensym.
You don't need to invoke `rake gensym` explicitly any longer.
2020-10-12 16:20:54 +09:00
Yukihiro "Matz" Matsumoto 24ad5f35b1 Removed unnecessary dependency from all.
`libmruby.flags.mak` is only required from `mruby-config` gem.
2020-10-12 16:20:54 +09:00
Yukihiro "Matz" Matsumoto 3c222e4e71 Add mruby-bin-config to default.gembox. 2020-10-12 16:20:54 +09:00
Yukihiro "Matz" Matsumoto e2063fc267 Add operators to presym from Rakefile. 2020-10-12 16:20:53 +09:00
Yukihiro "Matz" Matsumoto 68f8d73308 Use MRB_QSYM() instead of MRB_OPSYM(). 2020-10-12 16:20:53 +09:00
Yukihiro "Matz" Matsumoto 246c76e261 Rename MRB_OPSYM() to MRB_QSYM().
Where `QSYM` means quoted symbols, which cannot be represented C
symbols, so specify aliases instead.

- operators: name of the operation, e.g. add for `+`
- predicates: add `_p` suffix instead of `?`
- bang methods: add `_b` suffix instead of `!`
- instance variables: add `a_` prefix instead of `@`
- global variables: add `d_` prefix instead of `@`
- class variables: unsupported; don't use them
2020-10-12 16:20:53 +09:00
Yukihiro "Matz" Matsumoto 6128ae61a8 Simplified Rakefile. 2020-10-12 16:20:52 +09:00
Yukihiro "Matz" Matsumoto e3e5596960 Use MRB_OPSYM() instead of mrb_intern_lit(). 2020-10-12 16:20:52 +09:00
Yukihiro "Matz" Matsumoto 1bcf6d9f3c Create MRB_OPSYM() macro to refer symbols corresponding operators.
For example, `MRB_OPSYM(add)` refers a symbol for `+`.
2020-10-12 16:20:51 +09:00
Yukihiro "Matz" Matsumoto 97e3c3a5a3 Undefine internal macros in presym.h.
- MRB_PRESYM_CSYM
- MRB_PRESYM_SYM
2020-10-12 16:20:51 +09:00
Yukihiro "Matz" Matsumoto acd5317fb1 Create build directory first before gensym. 2020-10-12 16:20:50 +09:00
Yukihiro "Matz" Matsumoto 8d90c7c0fa Remove unused variable from Rakefile. 2020-10-12 16:20:50 +09:00
Yukihiro "Matz" Matsumoto 5a88904fe8 Use File.open instead of File.write shortcut. 2020-10-12 16:20:49 +09:00
Yukihiro "Matz" Matsumoto b3db34c2a8 Remove presym files before writing just to make sure. 2020-10-12 16:20:49 +09:00
Yukihiro "Matz" Matsumoto 6b7c12f523 Specify MRUBY_TARGET in CI configuration YAML. 2020-10-12 16:20:49 +09:00
Yukihiro "Matz" Matsumoto fa18ffa90c Add rake gensym to appveyor.yml too. 2020-10-12 16:20:48 +09:00
Yukihiro "Matz" Matsumoto 3ec61c0929 Update host* targets to use default.gembox.
And now `default.gembox` includes `mruby-socket` gem.
2020-10-12 16:20:48 +09:00
Yukihiro "Matz" Matsumoto 10b1a52bb8 Small updates on documents:
- README.md
- CONTRIBUTING.md
- doc/limitations.md
2020-10-12 16:20:48 +09:00
Yukihiro "Matz" Matsumoto dcfc2dbf14 Add host-shared.rb to create shared mruby library. 2020-10-12 16:20:47 +09:00
Yukihiro "Matz" Matsumoto d70536e0e8 Update host.rb build script. 2020-10-12 16:20:47 +09:00
Yukihiro "Matz" Matsumoto fdbfeaf533 Build process updated:
You have to specify `TARGET` to specify a configuration, e.g.

```
rake TARGET=host-debug all test
```

When you port `mruby` to a new configuration:
1. copy an existing configuration under `target` directory
2. modify the new configuration file
3. build using the new configuration
4. send PR if you please
2020-10-12 16:20:47 +09:00
KOBAYASHI Shuji ea31878b1f Avoid changing directory in mruby-io test 2020-10-12 16:20:46 +09:00
KOBAYASHI Shuji d33b9dc81f Refine .travis.yml
* Disable automatic update and clean up on `brew install` (install time
  160 sec -> 5 sec).
* Avoid using deprecated keys.
2020-10-12 16:20:46 +09:00
Yukihiro "Matz" Matsumoto d612344e48 Should not use assert with expressions with side-effect; ref #4981
`assert()` can be completely removed when `NDEBUG` is set.
2020-10-12 16:20:45 +09:00
Yukihiro "Matz" Matsumoto d7e183bfdf Fixed wrong condition in #4981. 2020-10-12 16:20:45 +09:00
Yukihiro "Matz" Matsumoto d5c010422a Run rake gensym before the build. 2020-10-12 16:20:45 +09:00
Yukihiro "Matz" Matsumoto 5738ed0474 Keep build/presym through rake clean. 2020-10-12 16:20:44 +09:00
Yukihiro "Matz" Matsumoto 3174061593 Prepend gensym rule to depfiles. 2020-10-12 16:20:44 +09:00
Yukihiro "Matz" Matsumoto 76d752c03b Fix presym_find for strings without NUL terminators. 2020-10-12 16:20:44 +09:00
Yukihiro "Matz" Matsumoto 33647b904e Avoid snprintf in mruby-io test; ref #4981 2020-10-12 16:20:43 +09:00
Yukihiro "Matz" Matsumoto 47f65a93c5 Remove the temporary file from the AF_UNIX socket test; #4981 2020-10-12 16:20:43 +09:00
Yukihiro "Matz" Matsumoto a2fbb98fa6 Remove build/presym and build/presym.inc on rake clean. 2020-10-12 16:20:42 +09:00
Yukihiro "Matz" Matsumoto 721f934b9b Scan .rb files as well to generate presym table. 2020-10-12 16:20:42 +09:00
Yukihiro "Matz" Matsumoto d2cab16301 Update presym_find to use more efficient binary search. 2020-10-12 16:20:42 +09:00
Yukihiro "Matz" Matsumoto eddd324979 Add MRB_SYM() for inline symbols. 2020-10-12 16:20:41 +09:00
Yukihiro "Matz" Matsumoto f221f4e0fa Update Rakefile to generate presym. 2020-10-12 16:20:41 +09:00
Yukihiro "Matz" Matsumoto a476d71143 Support presym in symbol.c. 2020-10-12 16:20:41 +09:00
Yukihiro "Matz" Matsumoto 1e156974d5 Generate a table for preallocated symbols (presym).
`presym` are symbols used in the C source files. `gensym` rake rule
scans the entire C source files and collect symbols referenced from
them.
2020-10-12 16:20:40 +09:00
Yukihiro "Matz" Matsumoto 8853b03591 Merge pull request #5090 from zubycz/fix_error_when_build_without_float
Fix argument error when built with MRB_WITHOUT_FLOAT flag
2020-10-12 16:19:04 +09:00
Yukihiro "Matz" Matsumoto f53781bdeb Merge pull request #5089 from zubycz/fix_test_of_range_min
fix improper test of Range#min
2020-10-12 14:29:39 +09:00
ssmallkirby afc0d7a6c3 Fix argument error when built with MRB_WITHOUT_FLOAT flag
Fixed inproper argument of mrb_fixnum_value() called in integral_div(),
when built with MRB_WITHOUT_FLOAT flag.

Co-authored-by: taiyoslime <t@iyosli.me>
Co-authored-by: n4o847 <22975590+n4o847@users.noreply.github.com>
2020-10-12 14:16:18 +09:00
taiyoslime c4f75c7de0 fix improper test of Range#min 2020-10-12 13:42:27 +09:00
Yukihiro "Matz" Matsumoto 9ea7b71868 Merge pull request #5087 from dearblue/get-args-string
Prohibit string changes by "s"/"z" specifier of `mrb_get_args()`
2020-09-25 22:54:25 +09:00
dearblue 57611240a9 Prohibit string changes by "s"/"z" specifier of mrb_get_args()
- The `s` specifier is a string pointer obtained without performing `mrb_str_modify()`, so it cannot be changed.
- The `z` specifier cannot be changed because it is a string pointer obtained by `RSTRING_CSTR()` which returns `const char *`.
2020-09-25 21:02:58 +09:00
Yukihiro "Matz" Matsumoto a97f085c52 Merge pull request #5083 from wataash/example-clarify-caller
examples/mrbgems: clarify the caller
2020-09-18 14:16:23 +09:00
Wataru Ashihara 2bf9fd06d2 examples/mrbgems: clarify the caller
Before this commit:

  mruby -e 'CRubyExtension.ruby_method' # => A Ruby Extension
  mruby -e 'CRubyExtension.c_method'    # => A C Extension
  mruby -e 'CExtension.c_method'        # => A C Extension
  mruby -e 'RubyExtension.ruby_method'  # => A Ruby Extension

After this commit:

  mruby -e 'CRubyExtension.ruby_method' # => CRubyExtension: A Ruby Extension
  mruby -e 'CRubyExtension.c_method'    # => CRubyExtension: A C Extension
  mruby -e 'CExtension.c_method'        # => CExtension: A C Extension
  mruby -e 'RubyExtension.ruby_method'  # => RubyExtension: A Ruby Extension
2020-09-18 14:10:20 +09:00
Yukihiro "Matz" Matsumoto dffe4bc8ba Merge pull request #5082 from wataash/remove-type-check
Remove redundant type-check
2020-09-18 13:42:02 +09:00
Wataru Ashihara 4375bffee5 Remove redundant type-check
since mrb_str_to_str() also does it.
2020-09-18 13:35:03 +09:00
Yukihiro "Matz" Matsumoto e440681a06 Merge pull request #5081 from wataash/d-format-comment
*.d format is version-independent
2020-09-17 21:05:42 +09:00
Yukihiro "Matz" Matsumoto 758f8f4baf Merge pull request #5080 from wataash/fix-dep-read
Fix skipping reading file
2020-09-17 21:05:30 +09:00
Wataru Ashihara ea3b02e387 *.d format is version-independent
As pointed out by @shuujii on https://github.com/mruby/mruby/pull/5079 ,
multi-path in single-line could be appear even with older-gcc or clang.
2020-09-17 21:04:45 +09:00
Wataru Ashihara 069d9bb4d7 Fix skipping reading file 2020-09-17 20:30:17 +09:00
Yukihiro "Matz" Matsumoto 9757616c57 Merge pull request #5079 from wataash/fix-dep-parse
Fix *.d parsing with gcc 9.3.0
2020-09-17 20:20:03 +09:00
Wataru Ashihara e8723a4f3f Fix *.d parsing with gcc 9.3.0
Before this commit:

  $ rake
  ...
  $ rm build/host/src/gc.o
  $ rake
  rake aborted!
  Don't know how to build task '/home/foo/mruby/build/host/src/gc.o' (See the list of available tasks with `rake --tasks`)
  ...

After this commit:

  $ rake
  ...
  $ rm build/host/src/gc.o
  $ rake
  CC    src/gc.c -> build/host/src/gc.o
  ...

With gcc 9.3.0 on Ubuntu 20.04, build/host/src/array.d looks like:

  /build/host/src/array.o: /src/array.c \
   /include/mruby.h /include/mrbconf.h \
   /include/mruby/common.h \
   ...
   /include/mruby/range.h \
   /src/value_array.h

and it has been parsed to:

  [
                                           # /src/array.c missing
    "/include/mruby.h /include/mrbconf.h", # incorrectly parsed
    "/include/mruby/common.h",
    ...
    "/src/value_array.h",
  ]

After this change, *.d will be parsed correctly.

  [
    "/src/array.c",
    "/include/mruby.h",
    "/include/mrbconf.h",
    "/include/mruby/common.h",
    ...
    "/src/value_array.h",
  ]
2020-09-17 20:02:55 +09:00
Yukihiro "Matz" Matsumoto 5bfb70e9db Fix File.extname bug; fix #5077 2020-09-13 11:38:31 +09:00
Yukihiro "Matz" Matsumoto 8b65e4b73c Add test to ensure #5077 2020-09-13 11:38:06 +09:00
Yukihiro "Matz" Matsumoto 4e15832000 Update y.tab.c; ref #4933 2020-09-10 21:17:38 +09:00
Yukihiro "Matz" Matsumoto c27e451931 Merge pull request #4933 from dearblue/variables
Fix take over file scope variables with `mruby` and `mirb` command
2020-09-10 18:12:38 +09:00
Yukihiro "Matz" Matsumoto c345fe4321 Merge pull request #5076 from dearblue/call_type
Remove `enum call_type`
2020-09-07 23:22:13 +09:00
dearblue f99c315400 Remove enum call_type
It seems to be unnecessary from mruby-1.0.0 or earlier.
2020-09-03 23:18:16 +09:00
Yukihiro "Matz" Matsumoto e2c628583e Fix mrb_ary_splat() to copy the array always. 2020-08-30 19:14:34 +09:00
Yukihiro "Matz" Matsumoto 705f95c983 Merge pull request #5068 from sizious/mingw32-legacy-fixes
mruby-io: Fixing compilation issue under the legacy MinGW environment
2020-08-29 23:04:02 +09:00
Yukihiro "Matz" Matsumoto 6b8664b951 Fix the bug caused by to_a returning a frozen array.
Reported by @shuujii.
2020-08-29 23:00:36 +09:00
Yukihiro "Matz" Matsumoto f08f3c34be Fix a bug introduced by the last commit.
Should have handled the case `to_a` returns `nil`.
2020-08-29 22:58:07 +09:00
SiZiOUS 510b9e7abc mruby-io: Fixing compilation issue under the legacy MinGW environment
Adding MRB_MINGW32_LEGACY in common.h in order to identify the legacy MinGW environment (i.e. NOT to be confused with MinGW-w64).
For more info about MinGW defined macros, see: https://sourceforge.net/p/predef/wiki/Compilers/
2020-08-29 13:58:00 +02:00
Yukihiro "Matz" Matsumoto 564372d7b9 Fix mrb_obj_ceqq to avoid array copying. 2020-08-29 18:43:47 +09:00
Yukihiro "Matz" Matsumoto a66d86cfc1 Fix mrb_ary_splat to copy the array; fix #5067 2020-08-29 18:43:26 +09:00
Yukihiro "Matz" Matsumoto 96bae1d508 Merge pull request #5065 from shuujii/simplify-MSVC-detection-to-mrb_static_assert
Simplify MSVC detection to `mrb_static_assert`
2020-08-12 21:51:45 +09:00
KOBAYASHI Shuji 77c35e7097 Simplify MSVC detection to mrb_static_assert 2020-08-12 20:05:31 +09:00
Yukihiro "Matz" Matsumoto 2aa70e9690 Merge pull request #5062 from shuujii/use-normal-static_assert-in-mrb_static_assert-as-much-as-possible
Use normal `static_assert` in `mrb_static_assert` as much as possible
2020-08-11 22:33:44 +09:00
Yukihiro "Matz" Matsumoto ae09a219d5 Merge pull request #5063 from dearblue/stat32
Use `struct _stat32` instead of `struct __stat32`
2020-08-11 22:31:09 +09:00
dearblue c5dc184a6d Use struct _stat32 instead of struct __stat32
It is described as `struct __stat32` in the MSVC reference manual.
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/stat-functions?view=vs-2019
But it doesn't really exist, so it must use `struct _stat32`.

It also replaces `struct __stat64` with `struct _stat64` to make it look
nicer.
2020-08-11 22:09:28 +09:00
KOBAYASHI Shuji bab7e9f032 Use normal static_assert in mrb_static_assert as much as possible
* `_Static_assert` can also be used with `-std=gnu99` on GCC >= 4.6.
* `static_assert` can be used on MSVC.
* `static_assert` can be used even on old G++/Clang++ if
  `__GXX_EXPERIMENTAL_CXX0X__` is defined.
2020-08-11 20:47:20 +09:00
Yukihiro "Matz" Matsumoto 3b8df2c285 Fixed VC fstat issue. 2020-08-11 16:35:50 +09:00
Yukihiro "Matz" Matsumoto cfaaf7c6d4 Should use _fstat32() on 32bit Windows. 2020-08-11 16:02:05 +09:00
Yukihiro "Matz" Matsumoto 5210482c59 Add cast for mrb_fixnum_value() from time_t. 2020-08-11 16:01:23 +09:00
Yukihiro "Matz" Matsumoto 5e55b61c44 Fix mrb_int and size_t combination warnings. 2020-08-11 15:06:51 +09:00
Yukihiro "Matz" Matsumoto 4695dfdcb6 Avoid using mrb_funcall() from mruby-io gem. 2020-08-10 08:53:35 +09:00
Yukihiro "Matz" Matsumoto 55482063a7 Remove duplicated definition of E_EOF_ERROR. 2020-08-09 21:57:41 +09:00
Yukihiro "Matz" Matsumoto ab5726d4e4 Merge pull request #5061 from shuujii/allow-mrb_static_assert-to-be-used-outside-of-functions
Allow `mrb_static_assert()` to be used outside of functions
2020-08-09 21:57:30 +09:00
KOBAYASHI Shuji 0d54568b4d Allow mrb_static_assert() to be used outside of functions
The use of `struct` is an idea by @dearblue.
2020-08-09 20:39:36 +09:00
Yukihiro "Matz" Matsumoto df969b163a Return NaN for 0/0; d8e060d 2020-08-08 15:36:55 +09:00
Yukihiro "Matz" Matsumoto ad8b36daa1 Should not use mrb_float_value() with MRB_WITHOUT_FLOAT. 2020-08-08 14:14:17 +09:00
Yukihiro "Matz" Matsumoto c849b894ed Reintroduce mrb_static_assert; #5051
Note that the home brew version of `mrb_static_assert` only works within
the function body.  This reverts commit 8f99689.
2020-08-08 10:39:26 +09:00
Yukihiro "Matz" Matsumoto d8e060d2d3 Avoid division by zero undefined behavior. 2020-08-07 10:51:33 +09:00
Yukihiro "Matz" Matsumoto 9742bce198 Merge pull request #5059 from mruby/stable
Merge mruby 2.1.2
2020-08-06 17:47:36 +09:00
Hiroshi Mimaki 7f8d38bbbe Merge master. 2020-08-06 17:38:20 +09:00
Yukihiro "Matz" Matsumoto 0b95c8a1e8 Use memcpy to copy stack. 2020-08-06 17:02:15 +09:00
Yukihiro "Matz" Matsumoto 57a798e687 Use memset() to clear stack unless MRB_NAN_BOXING. 2020-08-06 17:01:59 +09:00
Yukihiro "Matz" Matsumoto 755233ef7d Remove block clear of callinfo. 2020-08-06 17:01:28 +09:00
Yukihiro "Matz" Matsumoto 8f99689ba3 Remove mrb_static_assert from the core; #5051 2020-08-06 16:01:45 +09:00
Hiroshi Mimaki 1a9bdfcde5 Update release date. 2020-08-06 12:45:59 +09:00
Yukihiro "Matz" Matsumoto 11cc7bed96 Merge pull request #5052 from dearblue/cistacks
Extend the `cipush()` and `cipop()` functions
2020-08-05 17:38:51 +09:00
Yukihiro "Matz" Matsumoto ef9c68795f Merge pull request #5058 from dearblue/benchmark
Improve `rake benchmark`
2020-08-05 06:51:54 +09:00
dearblue fde95a7db5 Improve rake benchmark
- Use POSIX format instead of GNU extension for `time` command.
  For example FreeBSD's `time(1)` does not have GNU extensions available.
- Sort `benchmark/bm_*.rb`.
  This is because the order of the bar graph cannot be uniquely
  determined depending on the result of `Dir.glob`.
2020-08-04 22:04:05 +09:00
Yukihiro "Matz" Matsumoto cfb799a18e Fix wrong condition for PACK_DIR_HEX; ref #5057 2020-08-04 17:50:09 +09:00
Yukihiro "Matz" Matsumoto 43443d9377 Should not decrement count when PACK_FLAG_COUNT2; fix #5057 2020-08-03 19:46:34 +09:00
Yukihiro "Matz" Matsumoto faed5054f8 Initialized local variables in mrb_hash_shift(). 2020-08-03 15:53:50 +09:00
Yukihiro "Matz" Matsumoto 0a505dcfd6 Simplify khash.h.
- Remove ` kh_put_prepare` function used only internally
- Remove `n_occupied` member from `kh_` struct
2020-07-31 18:14:02 +09:00
Yukihiro "Matz" Matsumoto 1517d77e93 Fix puts in mruby-print on no argument; 0e9bd24
`puts` should print newline when called without arguments.
2020-07-31 06:57:05 +09:00
Yukihiro "Matz" Matsumoto 9571a4c07e Merge pull request #5050 from dearblue/memsize_of2
Update document for `ObjectSpace.memsize_of` [ci skip]
2020-07-26 13:56:26 +09:00
dearblue d96be5c1b2 Extend the cipush() and cipop() functions
- Returns the updated call info.
- Unify the processing around `cipush()`.
- `cipop()` restores the stack.
2020-07-26 13:12:01 +09:00
dearblue 0983c723c5 Update document for ObjectSpace.memsize_of [ci skip]
The `recurse` keyword is removed by f00657ead7.
2020-07-26 13:12:01 +09:00
Yukihiro "Matz" Matsumoto 425b5f32d6 Merge pull request #5049 from shuujii/use-type-tag-for-hash-code-in-ht_hash_func
Use type tag for hash code in `ht_hash_func()`
2020-07-25 19:40:05 +09:00
KOBAYASHI Shuji 0c88c71786 Use type tag for hash code in ht_hash_func()
The function corresponding to `ht_hash_func()` was as follows in the days of
khash implementation (before d78acc7a).

  ```c
  mrb_hash_ht_hash_func(mrb_state *mrb, mrb_value key)
  {
    enum mrb_vtype t = mrb_type(key);
    ...
    switch (t) {
    ...
    default:
      hv = mrb_funcall(mrb, key, "hash", 0);
      h = (khint_t)t ^ (khint_t)mrb_fixnum(hv);
      break;
    }
    ...
  }
  ```

When switched to the segmented list implementation (d78acc7a), this function
was changed as follows.

  ```c
  sg_hash_func(mrb_state *mrb, seglist *t, mrb_value key)
  {
    enum mrb_vtype tt = mrb_type(key);
    ...
    switch (tt) {
    ...
    default:
      hv = mrb_funcall(mrb, key, "hash", 0);
      h = (size_t)t ^ (size_t)mrb_fixnum(hv);
      break;
    }
    ...
  }
  ```

Since the argument `t` was added, the variable for type tag was changed from
`t` to `tt`, but the variable used in the expression of `h` remained `t`.

Probably this is an omission of change, so fixed it.
2020-07-25 16:59:02 +09:00
Yukihiro "Matz" Matsumoto f868d7d357 Change the logic to calculate object (iv_tbl) size; #5045 2020-07-24 13:13:06 +09:00
Yukihiro "Matz" Matsumoto c69ca2c7f8 Merge pull request #5045 from dearblue/memsize_of
Improve `mruby-os-memsize`
2020-07-24 12:02:05 +09:00
dearblue ccd5f203bf Improve prototype for mrb_objspace_page_slot_size(); ref #5032
If it qualify a return type that is not a pointer with `const`, the
compiler ignores it.
2020-07-24 11:48:09 +09:00
dearblue 5c2b11d215 Avoid using FPU with mruby-os-memsize; ref #5032
And, in the calculation of the instance variable size, the fraction was
always rounded down because of division of integers, so fix it.

At the same time, test items that are no longer passed due to this
change are deleted.
2020-07-24 11:42:37 +09:00
dearblue c9ba761b9e Support without mruby-method for mruby-os-memsize; ref #5032 2020-07-24 11:42:26 +09:00
dearblue 2b588b8566 Add NUL terminator to string object size calculation; ref #5032 2020-07-24 11:42:16 +09:00
Yukihiro "Matz" Matsumoto b4f4f5968b ObjectSpace.count_objects to support MRB_TT_ISTRUCT; #5046 2020-07-23 07:10:35 +09:00
Yukihiro "Matz" Matsumoto e7599050dc Fix a bug with ht_index called with size==0; fix #5046
It happens when a hash made empty calls `rehash`.
2020-07-23 07:06:35 +09:00
Yukihiro "Matz" Matsumoto 0e9bd24827 Fix puts to print newline with empty strings; ref b184772 2020-07-22 17:50:01 +09:00
Yukihiro "Matz" Matsumoto b920270508 Use more mrb_field_write_barrier for instance variables. 2020-07-22 15:01:55 +09:00
Yukihiro "Matz" Matsumoto 491aa1bfe5 Use more local variables.
To make debugging easy, and to improve the performance little bit.
2020-07-22 15:01:54 +09:00
Yukihiro "Matz" Matsumoto c99bb756c4 Move gray_list update from gc_mark_children.
The responsibility moved to caller to avoid confusion. Currently the
function is called from only 2 places, so it is relatively easy to
ensure not to update `gray_list` in the caller.  But the assumption
may change in the future.
2020-07-22 15:01:54 +09:00
Yukihiro "Matz" Matsumoto 097f525817 Avoid using mrb_ary_modify from the internal function.
`mrb_ary_modify` calls `mrb_write_barrier`, so can cause the same
problem of the past `push`. It is provided for use-level API.
2020-07-22 15:01:54 +09:00
Yukihiro "Matz" Matsumoto 5533c29833 Use mrb_field_write_barrier instead of mrb_write_barrier for push.
When the array is very big, the simpler `mrb_write_barrier` causes
calling `gc_mark_children` for big arrays repeatedly. That would hinder
performance very badly.
2020-07-22 15:01:53 +09:00
Yukihiro "Matz" Matsumoto 0bb4d10ca7 Define Array#to_a to avoid unnecessary loops. 2020-07-22 14:56:56 +09:00
Yukihiro "Matz" Matsumoto 914da3d712 Small comment fix in mrblib/array.c. 2020-07-22 14:56:36 +09:00
Yukihiro "Matz" Matsumoto 670622f45d Skip unnecessary mark_context if mrb->c == mrb->root_c. 2020-07-22 14:56:03 +09:00
dearblue 97f71b5a67 Fixed garbled characters; ref #5041 2020-07-22 00:03:17 +09:00
dearblue 639703cf01 Remove unnecessory methods in mruby-objectspace; ref #5041
The `ObjectSpace#memsize_of` and `ObjectSpace#memsize_of_all` in `mruby-objectspace` ware
migrated to `mruby-os-memsize` mrbgem.
2020-07-21 23:32:30 +09:00
Yukihiro "Matz" Matsumoto 6334949ba6 Fix the VM stack handling bug in 'mrb_yield_with_class()`; fix #5042 2020-07-21 12:47:35 +09:00
Yukihiro "Matz" Matsumoto b1847721e8 Implement Kernel#print and Kernel#puts in C. 2020-07-20 23:35:17 +09:00
Yukihiro "Matz" Matsumoto f0afdf7496 Merge pull request #5041 from RoryO/extract-memsize-to-gem
Extract memsize to gem
2020-07-20 08:23:46 +09:00
Rory OConnell 0685784119 Adding to authors 2020-07-19 15:40:29 -07:00
Rory OConnell 5f4a27217e Separate memsize_of and memsize_of_all to a separate gem; #5040
Those methods are originally CRuby specific.

Co-authored-by: Yukihiro "Matz" Matsumoto <matz@ruby.or.jp>
2020-07-19 15:36:08 -07:00
Yukihiro "Matz" Matsumoto c9ea39843b Remove some tests from mruby-objectspace gem; #5040
Those tests succeeds only on some configuration.
2020-07-20 06:05:06 +09:00
Yukihiro "Matz" Matsumoto a6f31ad6ce Avoid accessing obj.tt of mrb_value; #5040
The old code compiles only on `MRB_NO_BOXING`.
2020-07-20 06:05:06 +09:00
Yukihiro "Matz" Matsumoto 07b75d927e Replace 0 by MRB_EACH_OBJ_OK; #5040 2020-07-20 06:04:54 +09:00
Yukihiro "Matz" Matsumoto 71254be076 Skip MRB_TT_FREE and MRB_TT_BREAK in each_object. 2020-07-19 13:11:53 +09:00
Yukihiro "Matz" Matsumoto 1d2c5c12d3 Reorder members of struct os_each_object_data to stop warnings.
`mrb_value` may or may not be struct according to configuration.
2020-07-19 13:10:08 +09:00
Yukihiro "Matz" Matsumoto 00337543a5 Should have updated the arg spec for memsize_of&memsize_of_all; #5040 2020-07-19 09:11:16 +09:00
Yukihiro "Matz" Matsumoto f76defd310 Use c specifier for mrb_get_args. 2020-07-19 07:47:07 +09:00
Yukihiro "Matz" Matsumoto d023adcb12 Add new specifier c to mrb_get_args.
`C` retrieves a `mrb_value` that refers a class/module.
`c` retrieves a `struct RClass*` pointer to a class/module.
2020-07-19 07:45:16 +09:00
Yukihiro "Matz" Matsumoto 5b2763821e Fix memsize_of_all to count all objects if no argument given; #5040 2020-07-19 07:42:35 +09:00
Yukihiro "Matz" Matsumoto 6d073f8d99 Fix memsize_of_all to count memory of subclass instances; #5040
`ObjectSpace.memsize_of_all` takes a class and count memory size of all
instances of the class and its subclasses (if any).
2020-07-19 06:57:34 +09:00
Yukihiro "Matz" Matsumoto 667ace2bfe Merge pull request #5040 from RoryO/add-memsize-of-all
Add ObjectSpace.memsize_of_all
2020-07-19 06:43:13 +09:00
Rory O'Connell ffe8bf6323 Avoid singleton classes with mrb_class_real 2020-07-18 13:55:45 -07:00
Rory OConnell a79d1ba9ff Adding memsize_of_all doc 2020-07-17 20:21:23 -07:00
Rory OConnell fe1ec9afdd Add ObjectSpace.memsize_of_all 2020-07-17 20:09:44 -07:00
Yukihiro "Matz" Matsumoto 1952004d5a Use proc->env to check block_given? if possible; fix #5039
This bug has been there since mruby 1.4.0 (2018-04).
2020-07-17 16:15:47 +09:00
Yukihiro "Matz" Matsumoto e41f1f5139 Fix indent of compiler conditions; #5032 2020-07-17 12:32:54 +09:00
Yukihiro "Matz" Matsumoto 495c1a377a Fix memsize_of to count method table size; #5032
Also avoid `mrb_funcall` to minimize VM recursion.
2020-07-17 12:31:00 +09:00
Yukihiro "Matz" Matsumoto 9f52bcfca9 Fix memsize_of Fibers; #5032
Memory size of a Fiber is calculated by stack size only in CRuby.
2020-07-17 11:50:12 +09:00
Yukihiro "Matz" Matsumoto a2b8c08a52 Add const to irep pointer in os_memsize_of_irep; #5032 2020-07-17 11:43:55 +09:00
Yukihiro "Matz" Matsumoto f00657ead7 Remove recursive memsize_of; #5032
This is enhancement from CRuby's `memsize_of`. We need to change the
CRuby first for the enhancement.
2020-07-17 11:15:07 +09:00
Yukihiro "Matz" Matsumoto 2e56da5a78 Remove MRB_TT_DATA calculation of memsize_of; #5032 2020-07-17 10:59:43 +09:00
Yukihiro "Matz" Matsumoto 60279b2a8e Use mrb_test instead of mrb_obj_eq; #5032 2020-07-17 10:53:24 +09:00
Yukihiro "Matz" Matsumoto c6b8b58e0e Fix memsize_of for fiber objects; #5032 2020-07-17 10:53:04 +09:00
Yukihiro "Matz" Matsumoto 7f66cf7d66 Fix memsize_of for string objects; #5032 2020-07-17 10:52:59 +09:00
Yukihiro "Matz" Matsumoto 9840d6a2e7 Merge pull request #5038 from dearblue/bidx
Fixed shift width for `MRB_ENV_SET_BIDX()`
2020-07-17 07:12:31 +09:00
Yukihiro "Matz" Matsumoto b5bf9510ee Merge pull request #5032 from RoryO/add-objspace-memsize-of
Add ObjectSpace.memsize_of
2020-07-17 07:10:58 +09:00
dearblue 5dc87f77d4 Fixed shift width for MRB_ENV_SET_BIDX()
ref c07f24cd1 and close #5035
2020-07-16 23:11:30 +09:00
Rory O'Connell f74d370c15 mrb_ prefix convention 2020-07-15 19:57:22 -07:00
Rory O'Connell 38b0759108 Clarify memsize_of documentation 2020-07-14 23:43:10 -07:00
Rory O'Connell 4d32c671a7 Finishing out memsize_of recursion 2020-07-14 23:30:35 -07:00
Yukihiro "Matz" Matsumoto bfd58a3fb3 Merge pull request #5036 from shuujii/fix-build_dir-mrbgems-gem_init.c-generation-condition
Fix `${build_dir}/mrbgems/gem_init.c` generation condition; ref #5010
2020-07-15 14:03:09 +09:00
Yukihiro "Matz" Matsumoto 1a4089803d Merge pull request #5037 from shuujii/set-STDOUT.sync=true-when-testing-on-AppVeyor
Set `STDOUT.sync=true` when testing on AppVeyor [skip travis]
2020-07-15 09:57:49 +09:00
KOBAYASHI Shuji 4bf050a192 Set STDOUT.sync=true when testing on AppVeyor [skip travis]
This issue is a correction error at 5a682bfc.
2020-07-14 21:30:36 +09:00
KOBAYASHI Shuji 49896a4d28 Fix ${build_dir}/mrbgems/gem_init.c generation condition; ref #5010
The `${build_dir}/mrbgems/gem_init.c` generation condition has been changed
at #5010, but it is somewhat insufficient, for example, there was a problem
with `rake && rake test`, which was also regenerated in `rake test`.
2020-07-14 19:55:23 +09:00
Rory OConnell 0e5394638b Validate ensure stack presense before calculating 2020-07-13 17:05:03 -07:00
Rory OConnell ad44021591 C89 compiler mode fixes 2020-07-13 16:43:59 -07:00
Rory OConnell 5759256ff8 Update tests for new calculations 2020-07-13 16:00:49 -07:00
Rory OConnell 5184263bdc Calculating sizes of VM components for a Fiber 2020-07-13 16:00:14 -07:00
Rory OConnell 6f945a09b4 Use object iv table size in calculation 2020-07-13 15:59:24 -07:00
Rory OConnell e7bd7d0eaf Use size of hash's table in calculation 2020-07-13 15:58:50 -07:00
Rory OConnell 41e3220539 All values use page slot size in calculation 2020-07-13 15:56:27 -07:00
Yukihiro "Matz" Matsumoto e3bb95bb6d Merge pull request #5034 from dearblue/ssize_t
Fix `ssize_t` for mingw; ref #5030
2020-07-13 08:47:02 +09:00
dearblue 5df95e8d7b Fix ssize_t for mingw; ref #5030
Legacy MinGW and MinGW-w64 had own `ssize_t`.
2020-07-12 17:10:57 +09:00
Yukihiro "Matz" Matsumoto 99bb2154ff Merge pull request #5033 from dearblue/mrb_free_backtrace
Remove the prototype declaration `mrb_free_backtrace()`
2020-07-11 16:43:34 +09:00
dearblue 28e39419a5 Remove the prototype declaration mrb_free_backtrace()
This function is removed by 9644ad5.
2020-07-11 16:15:17 +09:00
Yukihiro "Matz" Matsumoto 042f98912f Merge pull request #5030 from RoryO/fix-compile-msvc-io-utf8
Fix compiling mruby-io on msc with UTF8 enabled
2020-07-11 13:58:41 +09:00
Rory OConnell bb23faae65 downcase windows include file for mingw compatability 2020-07-10 21:18:31 -07:00
Rory OConnell 308c6c8311 Need typedef of ssize_t for msc compiler 2020-07-10 21:18:30 -07:00
Rory OConnell 37d6628688 fix case scopes and variable names 2020-07-10 00:57:45 -07:00
Rory OConnell 338c8538c9 Initial ObjectSpace.memsize_of implementation 2020-07-09 18:52:31 -07:00
Yukihiro "Matz" Matsumoto c5fd8cbbe1 Merge pull request #5031 from RoryO/update-ci
Update Windows CI settings
2020-07-08 10:09:44 +09:00
Rory OConnell 8a44903992 remove verbose test output 2020-07-07 17:34:26 -07:00
Rory OConnell 3a79d60515 fix rake -m for separating build and test steps 2020-07-07 11:18:44 -07:00
Yukihiro "Matz" Matsumoto 01a8d8498f Avoid infinite loop when converting objects to strings. 2020-07-06 23:11:51 +09:00
Rory OConnell b759746890 try not separating build and test steps 2020-07-05 21:37:20 -07:00
Rory OConnell b3dace6ae3 use verbose test output. use correct config file this time 2020-07-05 21:12:04 -07:00
Rory OConnell 4d393d5d09 use correct config file 2020-07-05 21:05:27 -07:00
Rory OConnell 5c7adf0534 separate build and test steps, remove MSC 2020-07-05 20:59:49 -07:00
Rory OConnell 4f189b2be9 remove vs2013, separate build and test commands 2020-07-05 20:55:56 -07:00
Yukihiro "Matz" Matsumoto 81fc5ff48a Merge pull request #5029 from RoryO/true-eq-false
object_id of true, false, and undef are all 0
2020-07-05 22:04:25 +09:00
Rory OConnell 5746958470 fix object_id of true, false, and undef all 0 2020-07-04 20:33:38 -07:00
Yukihiro "Matz" Matsumoto 97319697c8 Cancel 9cdf439
Should not free the pointer in `realloc` since it can cause
use-after-free problem.
2020-07-02 10:41:03 +09:00
Yukihiro "Matz" Matsumoto 612e5d6aad Merge pull request #5028 from RoryO/msvc-optimize-shuffle-bug
Work around MSC optimization generating non functional code with Array#shuffle
2020-06-30 10:41:26 +09:00
Rory OConnell ba9f81db8b VS2013 32-bit does not work 2020-06-29 16:16:55 -07:00
Rory OConnell 5b9f7c0b93 use 2015 image for 2013 builds, ruby 2 not on 2013 image 2020-06-29 15:59:13 -07:00
Rory OConnell ce167d70b7 fix quoting 2020-06-29 15:44:13 -07:00
Rory OConnell 0ed623c442 name appveyor jobs, fix <=2015 config 2020-06-29 15:38:11 -07:00
Rory OConnell 206f7ce272 simplify appveyor config 2020-06-29 15:21:15 -07:00
Rory OConnell b59283a03f per-machine appveyor os config 2020-06-29 15:05:02 -07:00
Rory OConnell 3cf48713a2 Work around more MSC optimzer bugs 2020-06-29 14:25:59 -07:00
Rory OConnell 6d5652114e update CI settings for Windows 2020-06-29 13:18:05 -07:00
Rory OConnell b1017b2651 Reduce scope of volatile keyword for MSC bug 2020-06-26 21:44:31 -07:00
Rory OConnell b8d896e56a Narrower scope working around MSC bug 2020-06-26 21:16:17 -07:00
Rory OConnell db296e9593 work around MSC optimization generating non functional code 2020-06-26 15:13:04 -07:00
dearblue 9840e5352b Isolate top-level local variables by file scope; fix #4931 2020-01-29 23:30:13 +09:00
dearblue 0aa5aa1de2 Add test for top level local variables are in file scope; ref #4931 2020-01-29 23:29:48 +09:00
dearblue 25d9370f97 Fix take over file scope variable names with mirb command
Ref #4931

With this change, the `_` variable is defined after the `-r` switch.
2020-01-19 21:59:47 +09:00
dearblue 2bab6e197d Fix take over file scope variables with mruby command
Resolve #4931
2020-01-19 21:52:37 +09:00
dearblue 893cc2780c Add mrbc_cleanup_local_variables() with mrbc_context; ref #4931
Clean up defined local variables.
2020-01-19 21:42:09 +09:00
Uchio KONDO 7c52734243 Add a testcase of #4137 fix 2018-10-15 14:46:24 +09:00
Tomoyuki Sahara 89dceefa12 s/__android__/__ANDROID__/. fixes #15.
mruby core uses __ANDROID__ to know whether the target system is
Android or not (in mrbgems/mruby-math).
2018-09-14 15:49:36 +09:00
ksss e8988197f2 Try Binding class 2017-02-24 11:06:47 +09:00
Tomoyuki Sahara 14bc5c3e51 Merge pull request #14 from masahino/add_pointer_casting
Add pointer casting
2016-12-16 23:02:28 +09:00
masahino b1ccf9764b Add pointer casting 2016-12-15 21:34:27 +09:00
Tomoyuki Sahara 0c3c538855 Merge pull request #13 from udzura/add-chroot
Implement Dir.chroot on mruby
2016-06-13 09:54:03 +09:00
Uchio KONDO 7318ae5977 Remove perror 2016-06-13 09:42:16 +09:00
Uchio KONDO e9c4b10446 Implement Dir.chroot on mruby 2016-06-10 15:59:20 +09:00
yui-knk 68334311ac Remove dependency to mruby-sprintf (Fix #3) 2016-02-11 21:47:13 +09:00
yui-knk fbf8c10a94 Merge pull request #5 from yui-knk/use_new_container_based_infrastructure
Use the new container-based test infrastructure on travis ci
2016-02-11 20:38:46 +09:00
yui-knk 4f0a509342 Use the new container-based test infrastructure on travis ci 2016-02-11 20:36:25 +09:00
yui-knk 96ea55d2f9 Add a test case for Set#inspect 2016-02-11 20:27:55 +09:00
yui-knk 24b09fca69 Remove src directory (Fix #2)
This gem does not have c implementation, so remove src directory.
2016-02-11 20:13:53 +09:00
yui-knk d39dcb4370 [ci skip] Fix indent 2016-02-11 20:13:26 +09:00
yui-knk ea9a99541a [ci skip] Update license year 2016-02-11 20:13:00 +09:00
yui-knk f48f6e01b5 Merge pull request #4 from yui-knk/fix_test_script
Reform build process on travis ci
2016-02-11 20:03:23 +09:00
yui-knk 604fd5c437 Reform build process on travis ci
* Change to create "mruby" directory in a repository
* Create Rakefile and use it in .travis.yml
  This enable us to write build script with Ruby syntax
2016-02-11 19:53:48 +09:00
yui-knk befc5a4d83 Merge pull request #1 from takahashim/add-dependency
add add_dependency
2016-02-05 01:38:39 +09:00
Tomoyuki Sahara b4415207ff Merge pull request #2 from kazuho/kazuho/mrbint64
cast `mrb_int` to `int` before applying sprintf "%d"
2016-01-07 13:24:03 +09:00
Kazuho Oku b14df08be6 cast mrb_int to int before applying sprintf "%d" 2016-01-06 12:10:21 +09:00
Tomoyuki Sahara b64c701c64 Merge pull request #11 from takahashim/fix-win-test
fix test for windows
2015-12-03 16:45:25 +09:00
takahashim 71f21845ca fix test for windows
* _mkdir() has only one argument
* use mktemp && mkdir instead of mkdtemp
* use _getcwd instead of P_tmpdir (sandbox is on current dir)
* test for Dir#tell and Dir#seek: skip when NotImplementedError
2015-12-03 15:48:37 +09:00
Tomoyuki Sahara 66c6f8b9d1 Merge pull request #10 from takahashim/notimplemented
use NotImplementedError instead of RuntimeError for Win
2015-12-03 15:32:13 +09:00
takahashim 6140cb158d use NotImplementedError instead of RuntimeError for Win 2015-12-03 15:25:12 +09:00
Tomoyuki Sahara d98ecabd90 Merge pull request #9 from takahashim/enable_test
add conf.enable_test into build_config.rb
2015-12-03 09:51:36 +09:00
takahashim 3501af9ba2 add conf.enable_test into build_config.rb 2015-12-03 00:10:19 +09:00
takahashim 7584d49aa3 add add_dependency 2015-09-13 15:16:28 +09:00
Tomoyuki Sahara 49f6fa51d9 Merge pull request #8 from joans321/master
disable dir_seek and dir_tell on android platform
2015-08-13 20:19:58 +09:00
xuejianqing 6e30353dfd disable dir_seek and dir_tell on android platform 2015-08-13 17:33:45 +08:00
Tomoyuki Sahara 444abbe5f9 Merge pull request #7 from furunkel/master
Use _WIN32 and _WIN64 to detect Windows instead of RUBY_PLATFORM
2015-06-02 09:27:33 +09:00
furunkel 9eec22cda1 Add missing declarations 2015-06-01 21:16:25 +02:00
furunkel 5542f7b0fc Use _WIN32 and _WIN64 to detect Windows instead of RUBY_PLATFORM 2015-06-01 21:06:59 +02:00
cremno f31733045f use mrb_debug_strdup() and mrb_debug_strndup()
As they are safer to use than mrb_malloc()+strlen()+strncpy() (see #2652).
2014-12-02 00:00:55 +01:00
cremno ce5a3dbcba add mrb_debug_strdup() and mrb_debug_strndup()
They behave similar to their POSIX equivalents, except
mrb_malloc_simple() is used for memory allocation and
errno might not be set since ISO C99 doesn't have ENOMEM.
2014-12-02 00:00:54 +01:00
Tomoyuki Sahara dfb471b40b type of 2nd argument was changed. 2014-09-19 13:49:39 +09:00
Tomoyuki Sahara f7a0946452 mrb_const_defined returns true if it is defined on a super class. 2014-09-19 13:22:56 +09:00
Tomoyuki Sahara 37105ef13b Merge pull request #1 from cremno/patch-1
use mrb_basic_ptr instead of obsolete mrb_basic
2014-09-01 09:29:31 +09:00
cremno baba54fb49 use mrb_basic_ptr instead of obsolete mrb_basic 2014-08-29 16:41:11 +02:00
yui-knk 93e1d2b992 implemente Set#divide (with 1 arity block) 2014-08-03 23:40:05 +09:00
yui-knk 93a8b08f59 implement #classify 2014-08-03 13:06:30 +09:00
yui-knk a442f232e9 Refactor #flatten_merge
Not to unnecessary recursive search.
2014-08-03 12:52:29 +09:00
yui-knk 0d89802877 fix typo 2014-08-03 12:50:51 +09:00
yui-knk 7861034bcf add test case to #flatten 2014-08-03 12:50:23 +09:00
yui-knk 2836acf045 implement flatten_merge, flatten, flatten! 2014-08-03 12:45:54 +09:00
take_cheeze f77fb11f4e Use RString in mesg instead. 2014-07-28 20:30:02 +09:00
take_cheeze e926b532ee Store exception message to mesg field of struct RException. 2014-07-28 16:34:01 +09:00
yui-knk dd10f722ad Delete unused code in .h .c 2014-07-24 08:39:47 +09:00
yui-knk 4f73ff51e2 Add not implemented methods to README.md 2014-07-24 08:35:42 +09:00
yui-knk b4e4d98125 Add some comment outed methods
+ classify
+ divide
2014-07-24 08:29:45 +09:00
yui-knk 5e10c11662 Comment out some method
+ freeze
+ taint
+ untaint
2014-07-24 08:27:48 +09:00
yui-knk fad2bd9617 Add example to README.md 2014-07-24 08:22:22 +09:00
yui-knk 500bd30d6c Initial commit 2014-07-24 08:15:57 +09:00
Tomoyuki Sahara 6cc24d0793 add tests for #tell and #seek. 2014-06-20 15:25:10 +09:00
Tomoyuki Sahara 193c82174f P_tmpdir does not have trailing / on Linux. 2014-06-17 11:47:16 +09:00
Tomoyuki Sahara 14e325348b copy-and-paste bug... 2014-06-17 11:37:57 +09:00
Tomoyuki Sahara 0d378be34e tests and documentation. 2014-06-17 11:33:10 +09:00
Tomoyuki Sahara 546d923e67 Merge pull request #5 from windwiny/patch-1
compatible 32 bit windows
2014-05-09 01:56:46 +09:00
windwiny 627282a5f6 compatible 32 bit windows 2014-05-07 20:43:12 +08:00
mirichi 670a457e06 add block argument test #2144 2014-04-28 13:49:50 +09:00
Akira Yumiyama 536e83614d Update .travis.yml 2014-04-04 11:31:28 +09:00
Akira Yumiyama 2a0423c11d Update .travis.yml 2014-04-04 11:30:38 +09:00
Akira Yumiyama 06b4dd56a4 Create .travis.yml 2014-04-04 11:24:52 +09:00
Akira Yumiyama a252681f39 Create .travis.yml 2014-04-04 11:24:07 +09:00
Tomoyuki Sahara 4800836dd4 On Windows platforms, users must agree on addional license. 2014-03-14 10:06:14 +09:00
Tomoyuki Sahara dc17037349 Merge pull request #3 from pbosetti/master
Can Build with VisualStudio
2014-03-14 09:45:44 +09:00
Tomoyuki Sahara c0abfaf69d catch up with mrb_class_get API change. 2014-02-13 16:32:52 +09:00
Paolo Bosetti 9768535582 Made compatible with VisualStudio 2013-12-10 14:33:36 +01:00
Tomoyuki Sahara 09d51f46a7 mrb_intern API change. 2013-12-03 10:06:32 +09:00
Paolo Bosetti d7e880d9b9 Fix for compilation under Win/MinGW 2013-12-02 12:15:21 +01:00
Akira Yumiyama a036be21bc fix chdir (pass the current directory) 2013-11-16 14:37:21 +09:00
Akira Yumiyama 12dce91db8 support Dir.chdir with block 2013-11-16 14:28:40 +09:00
Akira Yumiyama 797c1cc178 Merge pull request #2 from syuu1228/chdir
add Dir.chdir
2013-11-15 20:50:01 -08:00
Takuya ASADA 0380865a55 add chdir 2013-11-14 03:08:43 -08:00
Tomoyuki Sahara 487ab66ea0 ARGS_XXX macros was renamed to MRG_ARGS_XXX. 2013-08-21 09:23:56 +09:00
Tomoyuki Sahara 09ea0586ee catch up with DATA API changes. 2013-08-20 17:27:10 +09:00
Akira Yumiyama 838e4f975d add run_test.rb, .gitignore 2013-05-02 23:57:20 +09:00
Akira Yumiyama 5903e2f3bf rename mrb_class_obj_get -> mrb_class_get 2013-05-02 23:56:52 +09:00
Akira Yumiyama ee4fef5127 update run_test.rb 2013-05-02 23:38:50 +09:00
Akira Yumiyama 57296298e9 put MRB_ prefix before ARGS_XXX macros 2013-04-27 09:46:11 +09:00
Tomoyuki Sahara db5e3af473 mrb_str_new2 -> mrb_str_new_cstr 2013-04-09 15:47:12 +09:00
Akira Yumiyama 104b69d943 rename mrb_str_new2 -> mrb_str_new_cstr 2013-03-13 22:28:06 +09:00
Tomoyuki Sahara e56d53e354 Errno module for mruby. 2013-03-13 10:00:22 +09:00
Tomoyuki Sahara b6c71e4c68 Initial commit 2013-03-12 00:21:04 -07:00
Akira Yumiyama 5e296b24f3 remove Makefile 2013-03-06 12:59:19 +09:00
Akira Yumiyama 221296cb55 update README.md 2013-03-06 12:59:03 +09:00
Akira Yumiyama 1cde1f24ce fix with mruby/mruby support. 2013-03-06 12:51:04 +09:00
Akira Yumiyama f22a72e754 update README.md 2013-01-30 17:02:54 +09:00
Akira Yumiyama 04d51d9719 add mrbgem test runner 2013-01-30 15:11:53 +09:00
Akira Yumiyama ae5671369e update mrbgem.rake 2013-01-30 15:11:15 +09:00
Akira Yumiyama 6b7e81f75b update mrbgem.rake 2013-01-24 10:18:13 +09:00
Akira Yumiyama 2f486fbccb add mrb_mruby_dir_gem_final 2013-01-24 10:18:05 +09:00
Akira Yumiyama 2e2225e2d3 add mrbgem.rake 2013-01-04 00:19:04 +09:00
Tomoyuki Sahara 92ad6dc8c3 should not ignore Makefile... 2012-12-25 13:44:22 +09:00
Tomoyuki Sahara f210dd553e requires iij/mruby. 2012-12-25 13:34:52 +09:00
Tomoyuki Sahara 7a593bf2d4 Dir class for mruby (from iij/mruby) 2012-12-25 13:32:29 +09:00
Tomoyuki Sahara ca525d5482 Initial commit 2012-12-24 20:11:55 -08:00
615 changed files with 78149 additions and 33421 deletions
+3
View File
@@ -0,0 +1,3 @@
[codespell]
ignore-words = .github/linters/codespell.txt
skip = ./build,./doc/api,./doc/capi
+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
+30
View File
@@ -0,0 +1,30 @@
# About this file, see:
# Website: https://editorconfig.org/
# For Emacs users: https://github.com/editorconfig/editorconfig-emacs
# For Vim users: https://github.com/editorconfig/editorconfig-vim
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
tab_width = 8
trim_trailing_whitespace = true
[{Makefile,Makefile.*,makefile,*.mk}]
indent_style = tab
#max_line_length = 80
#[*.{c,cc,C,cxx,cpp,h,hh,H,hxx,hpp,inc,y}]
#max_line_length = 120
#[{*.rb,Rakefile,rakefile,*.rake,*.gemspec,*.gembox}]
#max_line_length = 120
# limitation to US-ASCII
[*.bat]
end_of_line = crlf
#max_line_length = 80
+8
View File
@@ -0,0 +1,8 @@
# Extend the tab with 8 whitespace
6fc5dc986a5ffc1a74c63ad0617ea1dcc10d3cdd
# reformatted doc/opcode.md
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
+1
View File
@@ -0,0 +1 @@
* @matz
+11
View File
@@ -0,0 +1,11 @@
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates
version: 2
updates:
- package-ecosystem: "bundler"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
+81
View File
@@ -0,0 +1,81 @@
# 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/**/*
- .codespellrc
- .dockerignore
- .pre-commit-config.yaml
- .prettierignore
- .prettierrc
- .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/**/*
+12
View File
@@ -0,0 +1,12 @@
{
"verbose": false,
"ignore_defaults": false,
"exclude": ["oss-fuzz/", "src/"],
"disable": {
"end_of_line": false,
"trim_trailing_whitespace": false,
"insert_final_newline": false,
"indent_size": true,
"indent_style": true
}
}
+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
+12
View File
@@ -0,0 +1,12 @@
ls:
.c: snake_case
.cpp: snake_case
.h: snake_case
.json: snake_case
.rb: snake_case
.yaml: regex:\.?[a-z]+(-[a-z]+)*
.yml: regex:\.?[a-z]+(-[a-z]+)*
ignore:
- build_config
- mrbgems/mruby-compiler/core/y.tab.c
+33
View File
@@ -0,0 +1,33 @@
# 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
MD001: false
# MD013 line-length - Line length
MD013: false
# MD014 commands-show-output - Dollar signs used before commands without showing output
MD014: false
# MD024 no-duplicate-heading/no-duplicate-header - Multiple headings with the same content
MD024: false
# MD025 single-title/single-h1 - Multiple top-level headings in the same document
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
+11
View File
@@ -0,0 +1,11 @@
---
# https://yamllint.readthedocs.io/en/stable/
# yamllint --strict -c .github/linters/.yaml-lint.yml .
extends: default
rules:
comments:
min-spaces-from-content: 1
document-start: disable
line-length: disable
truthy: false
+16
View File
@@ -0,0 +1,16 @@
ans
celler
clen
delet
disabl
filetest
fo
hel
ist
nd
quitt
remore
runn
sting
strin
wronly
+10
View File
@@ -0,0 +1,10 @@
{
"ignorePatterns": [
{
"pattern": "^https://github.com/mruby/mruby/commit/"
},
{
"pattern": "^mailto:"
}
]
}
+47 -97
View File
@@ -1,106 +1,56 @@
# https://github.com/actions/runner-images#available-images
name: Build & Test
on: [push, pull_request]
permissions:
contents: read
jobs:
Ubuntu-1604:
runs-on: ubuntu-16.04
GCC-CLANG:
name: "${{ matrix.os }}-${{ matrix.altname || matrix.cc }}"
runs-on: ${{ matrix.os }}
timeout-minutes: 10
strategy:
fail-fast: false
max-parallel: 8
matrix:
include:
- {os: ubuntu-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: macos-15, cc: clang, cxx: clang++}
- {os: macos-14, cc: clang, cxx: clang++}
- {os: windows-2025, cc: gcc, cxx: g++, altname: "mingw-gcc"}
- {os: windows-2022, cc: gcc, cxx: g++, altname: "mingw-gcc"}
env:
MRUBY_CONFIG: ci/gcc-clang
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
LD: ${{ matrix.cc }}
steps:
- uses: actions/checkout@v1
- name: apt
run: sudo apt install ruby gperf
- name: build and test
run: rake -m -j4 all test
env:
MRUBY_CONFIG: travis_config.rb
Ubuntu-1804-gcc:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v1
- name: apt
run: sudo apt install ruby gperf gcc g++
- name: build and test
run: rake -m -j4 all test
env:
MRUBY_CONFIG: travis_config.rb
CC: gcc
CXX: g++
Ubuntu-1804-clang:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v1
- name: apt
run: sudo apt install ruby gperf
- name: build and test
run: rake -m -j4 all test
env:
MRUBY_CONFIG: travis_config.rb
CC: clang
CXX: clang++
macOS:
runs-on: macos-latest
steps:
- uses: actions/checkout@v1
- name: brew
run: brew install ruby gperf
- name: build and test
run: rake -m -j4 all test
env:
MRUBY_CONFIG: travis_config.rb
Windows-MinGW:
runs-on: windows-latest
steps:
- uses: actions/checkout@v1
- name: chocolatey
run: choco install -y ruby gperf
- name: build and test
run: rake -E '$stdout.sync=true' -j4 test
env:
MRUBY_CONFIG: travis_config.rb
CFLAGS: -g -O1 -Wall -Wundef
Windows-Cygwin:
runs-on: windows-latest
steps:
- uses: actions/checkout@v1
- uses: actions/cache@v1
with:
path: C:\Users\runneradmin\AppData\Local\Temp\chocolatey
key: ${{ runner.os }}-cygwin-chocolatey-${{ matrix.os }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-cygwin-chocolatey-${{ matrix.os }}-
${{ runner.os }}-cygwin-chocolatey-
- name: chocolatey
run: choco install -y cygwin
- name: Install cygwin packages
shell: cmd
run: C:\tools\cygwin\cygwinsetup.exe -qgnNdO -R C:/tools/cygwin -l C:/tools/cygwin/package -s http://mirrors.kernel.org/sourceware/cygwin/ -P gcc-core,gcc-g++,make,gperf,ruby
- name: Set ENV
run: |
echo '::set-env name=PATH::C:\tools\cygwin\bin;C:\tools\cygwin\usr\bin'
- name: build and test
shell: cmd
run: C:\tools\cygwin\bin\ruby.exe /usr/bin/rake -m -j4 -E 'STDOUT.sync=true' test
env:
MRUBY_CONFIG: travis_config.rb
- 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:run:serial
Windows-VC:
runs-on: windows-latest
runs-on: windows-2022
timeout-minutes: 10
env:
MRUBY_CONFIG: ci/msvc
steps:
- uses: actions/checkout@v1
- name: chocolatey
run: choco install -y ruby gperf
- name: build and test
shell: cmd
run: |
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
rake -E "STDOUT.sync=true" -m -j4 test
env:
MRUBY_CONFIG: appveyor_config.rb
# TODO(take-cheeze): Re-enable /O2
CFLAGS: "/c /nologo /W3 /we4013 /Zi /MD /D_CRT_SECURE_NO_WARNINGS"
CXXFLAGS: "/c /nologo /W3 /Zi /MD /EHs /D_CRT_SECURE_NO_WARNINGS"
- 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:run:serial
-51
View File
@@ -1,51 +0,0 @@
name: "Code scanning - action"
on:
push:
pull_request:
schedule:
- cron: '0 19 * * 4'
jobs:
CodeQL-Build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
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
# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
# 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@v1
# ️ 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@v1
+41
View File
@@ -0,0 +1,41 @@
name: Coverage
on: [push]
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
+35
View File
@@ -0,0 +1,35 @@
# https://pre-commit.com/
name: Lint
on: [pull_request]
permissions:
contents: read
jobs:
pre-commit:
name: Run pre-commit
runs-on: ubuntu-latest
steps:
- 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@v4
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Run pre-commit
run: pre-commit run --all-files
ls-lint:
name: Run ls-lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ls-lint/action@v2.3.1
with:
config: .github/linters/.ls-lint.yml
-24
View File
@@ -1,24 +0,0 @@
name: CIFuzz
on: [pull_request]
jobs:
Fuzzing:
runs-on: ubuntu-latest
steps:
- name: Build Fuzzers
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
with:
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'
fuzz-seconds: 600
dry-run: false
- name: Upload Crash
uses: actions/upload-artifact@v1
if: failure()
with:
name: artifacts
path: ./out/artifacts
+27
View File
@@ -0,0 +1,27 @@
# https://github.com/google/oss-fuzz
name: CIFuzz
on: [pull_request]
permissions:
contents: read
jobs:
Fuzzing:
runs-on: ubuntu-latest
steps:
- name: Build Fuzzers
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
with:
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"
fuzz-seconds: 600
dry-run: false
- name: Upload Crash
uses: actions/upload-artifact@v4
if: failure()
with:
name: artifacts
path: ./out/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/*
+31
View File
@@ -0,0 +1,31 @@
# https://github.com/super-linter/super-linter
name: Super-Linter
on: [pull_request]
permissions:
contents: read
jobs:
build:
permissions:
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 ${{ 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: super-linter/super-linter/slim@v7.4.0
env:
# 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: true
+17 -15
View File
@@ -1,8 +1,8 @@
*.lock
*.bak
*.bc
*.d
*.i
*.lock
*.o
*.orig
*.pdb
@@ -13,25 +13,27 @@
*.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
-4414
View File
File diff suppressed because it is too large Load Diff
+132
View File
@@ -0,0 +1,132 @@
---
# https://pre-commit.com/
default_stages: [pre-commit, pre-push]
default_language_version:
# force all unspecified Python hooks to run python3
python: python3
# force all unspecified Node hooks to run Node.js v22.15.0 LTS
node: 22.15.0
minimum_pre_commit_version: "3.2.0"
exclude: "^tools/lrama/"
repos:
- repo: meta
hooks:
- id: identity
name: run identity
description: check your identity
- id: check-hooks-apply
name: run check-hooks-apply
description: 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.5.3"]
- repo: https://github.com/gitleaks/gitleaks
rev: v8.25.1
hooks:
- id: gitleaks
name: run gitleaks
description: detect hardcoded secrets with gitleaks
- repo: https://github.com/shssoichiro/oxipng
rev: v9.1.5
hooks:
- id: oxipng
name: run oxipng
description: use lossless compression to optimize PNG files
args: ["-o", "4", "--strip", "safe", "--alpha"]
- repo: https://github.com/pre-commit/pre-commit-hooks
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
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.5.5
hooks:
- id: forbid-tabs
name: run no-tabs checker
description: check the codebase for tabs
exclude: Makefile$
- id: remove-tabs
name: run tabs remover
description: find and convert tabs to spaces
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.4.1
hooks:
- id: codespell
name: run codespell
description: check spelling with codespell
- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 3.0.0
hooks:
- id: script-must-not-have-extension
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.44.0
hooks:
- id: markdownlint
name: run markdownlint
description: checks the style of Markdown files
args: [--config=.github/linters/.markdown-lint.yml]
types: [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
description: check shell scripts with a static analysis tool
- repo: https://github.com/adrienverge/yamllint
rev: v1.37.0
hooks:
- id: yamllint
name: run yamllint
description: check YAML files with yamllint
args: [--strict, -c=.github/linters/.yaml-lint.yml]
types: [yaml]
files: \.ya?ml$
+5
View File
@@ -0,0 +1,5 @@
# Ignore artifacts:
build
coverage
doc/internal/opcode.md
tools/lrama
+3
View File
@@ -0,0 +1,3 @@
{
"bracketSpacing": false
}
+2 -2
View File
@@ -5,7 +5,7 @@ jobs:
- os: osx
env:
- MRUBY_CONFIG=travis_config.rb
- MRUBY_CONFIG=ci/gcc-clang
script:
- rake -m && rake test
- rake -m test:run:serial
+8 -2
View File
@@ -11,7 +11,13 @@ mrbgems/*/src/**/*.c
mrbgems/*/mrblib/**/*.rb
mrbgems/*/include/**/*.h
-
AUTHORS
LICENSE
CONTRIBUTING.md
SECURITY.md
TODO.md
doc/*.md
doc/guides/*.md
doc/internal/*.md
AUTHORS
LEGAL
LICENSE
NEWS
+335 -38
View File
@@ -1,45 +1,342 @@
This is the (likely incomplete) list of "mruby developers".
If you submit a patch to mruby, please add your name to the end
of this list.
# Authors of mruby (mruby developers)
Yukihiro Matsumoto (Matz)
## The List of Contributors sorted by number of commits (as of 2025-06-03 a3e7280)
6258 Yukihiro "Matz" Matsumoto (@matz)*
681 dearblue (@dearblue)*
587 KOBAYASHI Shuji (@shuujii)
353 Daniel Bovensiepen (@bovi)*
345 Takeshi Watanabe (@take-cheeze)*
333 Masaki Muranaka (@monaka)
234 Jun Hiroe (@suzukaze)
233 John Bampton (@jbampton)
228 Tomoyuki Sahara (@tsahara)*
220 Cremno (@cremno)*
209 Yuki Kurihara (@ksss)+
144 Yasuhiro Matsumoto (@mattn)*
113 Carson McDonald (@carsonmcdonald)
104 Tomasz Pędraszewski (@dabroz)*
83 Akira Yumiyama (@akiray03)*
83 skandhas (@skandhas)
80 Masamitsu MURASE (@masamitsu-murase)
73 Hiroshi Mimaki (@mimaki)*
71 Tatsuhiko Kubo (@cubicdaiya)*
71 Yuichiro MASUI (@masuidrive)
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)*+
32 Masayoshi Takahashi (@takahashim)+
31 MATSUMOTO Ryosuke (@matsumotory)*
30 Nobuyoshi Nakada (@nobu)
26 Hoshiumi Arata (@hoshiumiarata)*
25 Julian Aron Prenner (@furunkel)*
22 Clayton Smith (@clayton-shopify)
22 Uchio Kondo (@udzura)*
22 Zachary Scott (@zzak)*
21 Ryan Lopopolo (@lopopolo)
20 Ryan Scott (@ryan-scott-dev)*
19 Bouke van der Bijl (@bouk)
19 Jared Breeden (@jbreeden)*
19 go kikuta (@gkta)*
18 Corey Powell (@IceDragon200)
18 Hidetaka Takano (@TJ-Hidetaka-Takano)
18 Jon Maken (@jonforums)+
18 leviongit (@leviongit)
18 mirichi (@mirichi)
17 Mitchell Blank Jr (@mitchblank)*
16 bggd (@bggd)
16 kano4 (@kano4)
15 Felix Jones (@felixjones)*
14 Blaž Hrastnik (@archseer)*
14 Kazuki Tsujimoto (@k-tsj)
14 Tadashi FUKUZAWA (@FUKUZAWA-Tadashi)+
14 fn ⌃ ⌥ (@FnControlOption)
13 Jose Narvaez (@goyox86)
13 Patrick Hogan (@pbhogan)
13 google-labs-jules[bot] (@google-jules)
12 Akira Kuroda (@akuroda)
12 Kouki Ooyatsu (kaishuu0123)*
12 NAKAMURA Usaku (@unak)*
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 takkaw (@takkaw)
10 Miura Hideki (@miura1729)
10 Narihiro Nakamura (@authorNari)
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 roco (@rystyle)*
7 vickash (@vickash)
6 Akito Mochizuki (@ak-mochi)
6 Beoran (@beoran)
6 David Siaw (@davidsiaw)*
6 Frederick John Milens III (@fjmilens3)
6 HASUMI Hitoshi (@hasumikin)
6 Hiro Asari (@BanzaiMan)
6 INOUE Yasuyuki (@yasuyuki)
6 Junji Sawada (@junjis0203)
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)
5 Hendrik (@Asmod4n)
5 Ichito Nagata (@i110)
5 Keita Obo (@ktaobo)*
5 Max Anselm (@silverhammermba)
5 Rodrigo Malizia (@rmalizia44)+
5 Syohei YOSHIDA (@syohex)
5 TOMITA Masahiro (@tmtm)
5 Yurie Yamane (@yurie)+
5 dreamedge (@dreamedge)
5 nkshigeru (@nkshigeru)
5 xuejianqing (@joans321)
4 Dante Catalfamo (@dantecatalfamo)
4 Goro Kikuchi (@gorogit)
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 Mark Delk (@jethrodaniel)
4 NARUSE, Yui (@nurse)
4 Ravil Bayramgalin (@brainopia)*+
4 Satoshi Odawara (@SatoshiOdawara)
4 Yuhei Okazaki (@Yuuhei-Okazaki)*
4 Yuji Yamano (@yyamano)
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 Hirohito Higashi (@HirohitoHigashi)
3 J. Mutua (@katmutua)+
3 Jan Berdajs (@mrbrdo)
3 Jonas Minnberg (@sasq64)
3 Joseph McCullough (@joequery)
3 Mark McCurry (@fundamental)
3 Nobuhiro Iwamatsu (@iwamatsu)
3 Per Lundberg (@perlun)*
3 Rob Fors (@robfors)*
3 Robert Rowe (@CaptainJet)
3 Sebastián Katzer (@katzer)*
3 Shuta Kimura (@kimushu)+
3 TERAJIMA, Motoyuki (@trmmy)
3 Taichi AOKI (@aoki1980taichi)
3 Takashi Kokubun (@k0kubun)
3 Tatsuhiro Tsujikawa (@tatsuhiro-t)
3 Thiago Scalone (@scalone)
3 Vladimir Dementyev (@palkan)*
3 William Light (@wrl)
3 bamchoh (@bamchoh)
3 sasaki takeru (@takeru)
3 windwiny (@windwiny)
2 Akira Moroo (@retrage)
2 Artur K (@nemerle)
2 Christian Mauceri (@mauceri)
2 Craig Lehmann (@craiglrock)*
2 Dominic Sisneros (@dsisnero)*
2 Dusan D. Majkic (@dmajkic)
2 Emiliano Lesende (@3miliano)
2 Francois Chagnon (@EiNSTeiN-)*
2 Gilad Zohari (@gzohari)
2 Go Saito (@govm)
2 Hiroyuki Iwatsuki (@iwadon)
2 Huei-Horng Yo (@hiroshiyui)
2 Jonas Kulla (@Ancurio)
2 Jun Takeda (@takjn)
2 Kazuaki Tanaka (@kaz0505)
2 Kazuhiko Yamashita (@pyama86)+
2 Kazuhiro Sera (@seratch)
2 Kuroda Daisuke (@dycoon)+
2 Lothar Scholz (@llothar)
2 Lukas Joeressen (@kext)
2 Masahiro Wakame (@vvkame)+
2 Minao Yamamoto (@tarosay)+
2 Nihad Abbasov (@NARKOZ)
2 Robert Mosolgo (@rmosolgo)
2 Russel Hunter Yukawa (@rhykw)+
2 Ryunosuke SATO (@tricknotes)
2 Santa Zhang (@santazhang)
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 Bradley Whited (@esotericpig)
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)
1 Francis Bogsanyi (@fbogsany)
1 Guo Xiao (@guoxiao)
1 Gwen Boatrite (@boatrit)
1 Gwendolyn Boatrite (@boatrite)
1 HARADA Makoto (@haramako)
1 HAYASHI Kentaro (@kenhys)
1 Hiroki Mori (@yamori813)+
1 Hiromasa Ishii (@Hir0)+
1 Hiroyuki Matsuzaki (@Hiroyuki-Matsuzaki)
1 Hugo Logmans (@hlogmans)
1 Jack Danger Canty (@JackDanger)
1 Jeff Federman (@jefffederman)
1 Jeffrey Crowell (@crowell)
1 Jeremy Ong (@jeremyong)
1 Jiro Nishiguchi (@spiritloose)
1 Joachim Baran (@indiedotkim)
1 Joe Kutner (@jkutner)
1 Jun Aruga (@junaruga)
1 Junichi Kajiwara (@kjunichi)
1 Jurriaan Pruis (@jurriaan)
1 Katsuhiko Kageyama (@kishima)+
1 Katsuyoshi Ito (@katsuyoshi)
1 Kazuhiro NISHIYAMA (@znz)
1 Kei Sawada (@remore)
1 Kim H Madsen (@kimhmadsen)
1 Koichi ITO (@koic)
1 Konstantin Haase (@rkh)
1 Leo Neat (@Leo-Neat)
1 Lian Cheng (@liancheng)
1 Luis Lavena (@luislavena)
1 Lukas Elmer (@lukaselmer)
1 Lukas Stabe (@Ahti)
1 M.Naruoka (@fenrir-naru)
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)
1 Mitsutaka Mimura (@takkanm)
1 Nathan Ladd (@ntl)
1 Nicholas (@knf)
1 Nozomi SATO (@nozomiS)
1 Okumura Takahiro (@hfm)
1 Patrick Ellis (@pje)
1 Patrick Pokatilo (@SHyx0rmZ)
1 Pavel Evstigneev (@Paxa)+
1 Paweł Świątkowski (@katafrakt)
1 Pete Kinnecom (@petekinnecom)
1 Prayag Verma (@pra85)
1 Ranmocy (@ranmocy)
1 Robert McNally (@wolfmcnally)
1 Ryan Davis (@zenspider)
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)
1 Takuma Kume (@takumakume)+
1 Takuya ASADA (@syuu1228)
1 Thomas Schmidt (@digitaltom)
1 Timo Schilling (@timoschilling)
1 Tom Black (@blacktm)
1 Utkarsh Kukreti (@utkarshkukreti)
1 W (@graywolf)
1 Wuffers Lightwolf (@w-x-l)
1 YAMAMOTO Yuji (@igrep)
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)
1 hasse (@hasse09052)
1 hhc0null (@hhc0null)
1 iTitou (@titouanc)
1 javier ramírez (@javier)
1 liyuray (@liyuray)
1 lucas dicioccio (@lucasdicioccio)
1 n4o847 (@n4o847)
1 niyarin (@niyarin)
1 robert (@R-obert)
1 sbsoftware (@sbsoftware)
1 ssmallkirby (@smallkirby)
1 taku toyama (@tsuichu)
`*` - Entries unified according to names and addresses
`+` - Entries with names different from commits
## Contributors without named commits
Yuichi Osawa (Mitsubishi Electric Micro-Computer Application Software)
Shota Nakano (Manycolors)
Bjorn De Meyer
## Corporate contributors
Ministry of Economy, Trade and Industry, Japan
Kyushu Bureau of Economy, Trade and Industry
SCSK KYUSHU CORPORATION
Kyushu Institute of Technology
Network Applied Communication Laboratory, Inc.
Daniel Bovensiepen
Jon Maken
Bjorn De Meyer
Yuichiro MASUI
Masamitsu MURASE
Masaki Muranaka
Internet Initiative Japan Inc.
Tadashi FUKUZAWA
MATSUMOTO Ryosuke
Yasuhiro Matsumoto
Koji Yoshioka
Jun Hiroe
Narihiro Nakamura
Yuichi Nishiwaki
Tatsuhiko Kubo
Takeshi Watanabe
Yuki Kurihara
specified non-profit corporation mruby Forum
Kazuaki Tanaka
Hiromasa Ishii
Hiroshi Mimaki
Satoshi Odawara
Specified non-profit organization mruby Forum
Mitsubishi Electric Micro-Computer Application Software Co.,Ltd.
Ralph Desir(Mav7)
Hiroyuki Matsuzaki
Yuhei Okazaki
Manycolors, Inc.
Shota Nakano
Yuichi Osawa
Terence Lee
Zachary Scott
Tomasz Dąbrowski
Christopher Aue
Masahiro Wakame
YAMAMOTO Masaya
KOBAYASHI Shuji
RIZAL Reckordp
+137 -27
View File
@@ -1,22 +1,127 @@
# How to contribute
mruby is an open-source project which is looking forward to each contribution.
Contributors agree to license their contribution(s) under MIT license.
## Your Pull Request
To make it easy to review and understand your change please keep the following
things in mind before submitting your pull request:
* Work on the latest possible state of **mruby/master**
* Create a branch which is dedicated to your change
* Test your changes before creating a pull request (```rake test```)
* If possible write a test case which confirms your change
* Don't mix several features or bug-fixes in one pull request
* Create a meaningful commit message
* Explain your change (i.e. with a link to the issue you are fixing)
* Use mrbgem to provide non ISO features (classes, modules and methods) unless
- Work on the latest possible state of **mruby/master**
- Create a branch which is dedicated to your change
- Test your changes before creating a pull request (`rake test`)
- If possible write a test case which confirms your change
- Don't mix several features or bugfixes in one pull request
- Create a meaningful commit message
- Explain your change (i.e. with a link to the issue you are fixing)
- Use mrbgem to provide non ISO features (classes, modules and methods) unless
you have a special reason to implement them in the core
## pre-commit
A framework for managing and maintaining multi-language `pre-commit` hooks.
`pre-commit` can be [installed](https://pre-commit.com/#installation) with `pip`, `curl`, `brew` or `conda`.
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.
To run a single hook use `pre-commit run --all-files <hook_id>`
To update use `pre-commit autoupdate`
Sometimes you might need to skip one or more hooks which can be done with the `SKIP` environment variable.
`$ SKIP=yamllint git commit -m "foo"`
For convenience, we have added `pre-commit run --all-files`, `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)
- [Usage](https://pre-commit.com/#usage)
- [pre-commit autoupdate](https://pre-commit.com/#pre-commit-autoupdate)
- [Temporarily disabling hooks](https://pre-commit.com/#temporarily-disabling-hooks)
## Docker
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/).
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
```
You can also run any custom `docker-compose` command which will override
the default. For example to run `pre-commit run --all-files` type:
`$ 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
How to style your C and Ruby code which you want to submit.
@@ -31,12 +136,7 @@ C code:
mruby should be highly portable to other systems and compilers. For this it is
recommended to keep your code as close as possible to the C99 standard
(http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf).
Although we target C99, we've heard some compilers in the embedded environment
still requires declarations of local variables to be at the beginning of a
scope. Until we confirm the situation has changed, we use the old-style
variable declaration.
(<http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf>).
Visual C++ is also an important target for mruby (supported version is 2013 or
later). For this reason features that are not supported by Visual C++ may not
@@ -50,19 +150,15 @@ The dependencies to libraries should be kept to an absolute minimum. This
increases the portability but makes it also easier to cut away parts of mruby
on-demand.
#### Don't use C++ style comments
#### Insert a break after the function return value:
/* This is the preferred comment style */
Use C++ style comments only for temporary comment e.g. commenting out some code lines.
#### Insert a break after the method return value:
int
main(void)
{
...
}
```c
int
main(void)
{
...
}
```
### Ruby code
@@ -72,4 +168,18 @@ language itself. Please note the following hints for your Ruby code:
#### Comply with the Ruby standard (ISO/IEC 30170:2012)
mruby is currently targeting to execute Ruby code which complies to ISO/IEC
30170:2012 (http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=59579).
30170:2012 (<https://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=59579>),
unless there's a clear reason, e.g. the latest Ruby has changed behavior from ISO.
## Building documentation
### mruby API
- [YARD](https://yardoc.org/) - YARD is a documentation generation tool for the Ruby programming language
- [yard-mruby](https://rubygems.org/gems/yard-mruby) - Document mruby sources with YARD
- [yard-coderay](https://rubygems.org/gems/yard-coderay) - Adds coderay syntax highlighting to YARD docs
### C API
- [Doxygen](https://www.doxygen.nl/) - Generate documentation from source code
- [Graphviz](https://graphviz.org/) - Graphviz is open source graph visualization software
+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 . .
+654 -314
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.3.0)
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
+56
View File
@@ -4,3 +4,59 @@ 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/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/string.c]
The implementation of mrb_memsearch_ss() is taken from
https://github.com/WojciechMula/sse4-strstr.git
Copyright (c) 2008-2016, Wojciech Muła
All rights reserved.
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]
The code in this function was inspired from Fred Bayer's pdouble.c.
Since pdouble.c was released as Public Domain, I'm releasing this
code as public domain as well.
Dave Hylands
The original code can be found in https://github.com/dhylands/format-float
[mrbgems/mruby-dir/src/Win/dirent.c] used only for Windows platform
Copyright Kevlin Henney, 1997, 2003, 2012. All rights reserved.
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose is hereby granted without fee, provided
that this copyright and permissions notice appear in all copies and
derivatives.
This software is supplied "as is" without express or implied warranty.
But that said, if there are any problems please get in touch.
+1 -2
View File
@@ -1,4 +1,4 @@
Copyright (c) 2020 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"),
@@ -17,4 +17,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
+45 -4
View File
@@ -1,15 +1,56 @@
# mruby is using Rake (http://rake.rubyforge.org) as a build tool.
# 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 : check_pre_commit
$(PRE_COMMIT) run --all-files
.PHONY : check
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
+248 -7
View File
@@ -1,13 +1,254 @@
* NEWS
NEWS
----
This document is a list of user visible feature changes made between
releases except for bug fixes.
# User visible changes in `mruby3.4` from `mruby3.3`
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
- mruby now supports `private` and `protected` visibility ([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 spelling in `src/vm.c`
- [#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
+78 -44
View File
@@ -1,78 +1,117 @@
[![Build Status][build-status-img]][travis-ci]
<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
mruby is the lightweight implementation of the Ruby language complying to (part
of) the [ISO standard][ISO-standard]. Its syntax is Ruby 2.x compatible.
of) the [ISO standard][ISO-standard] with more recent features provided by Ruby 3.x.
Also, its syntax is Ruby 3.x compatible except for pattern matching.
mruby can be linked and embedded within your application. We provide the
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 stable version 2.1.2 of mruby can be downloaded via the following URL: [https://github.com/mruby/mruby/archive/2.1.2.zip](https://github.com/mruby/mruby/archive/2.1.2.zip)
To get mruby, you can download the stable version 3.4.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 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:
$ git clone https://github.com/mruby/mruby.git
```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
We don't have a mailing list, but you can use [GitHub issues](https://github.com/mruby/mruby/issues).
## How to compile and install (mruby and gems)
## How to compile, test, and install (mruby and gems)
See the [compile.md](https://github.com/mruby/mruby/blob/master/doc/guides/compile.md) file.
For the simplest case, type
## Running Tests
```console
rake all test
```
To run the tests, execute the following from the project's root directory.
$ rake test
Note: `bison` bundled with MacOS is too old to compile `mruby`.
Try `brew install bison` and follow the instuction shown to update
the `$PATH` to compile `mruby`.
See the [compile.md](doc/guides/compile.md) file for the detail.
## Building documentation
There are two sets of documentation in mruby: the mruby API (generated by yard) and C API (Doxygen)
There are two sets of documentation in mruby: the mruby API (generated by YARD) and C API (Doxygen and Graphviz)
To build both of them, simply go
rake doc
```console
rake doc
```
You can also view them in your browser
rake view_api
rake view_capi
```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](https://github.com/mruby/mruby/blob/master/doc/guides/mrbgems.md).
For example code of how to use mrbgems look into the folder *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
mruby is released under the [MIT License](https://github.com/mruby/mruby/blob/master/LICENSE).
mruby is released under the [MIT License](LICENSE).
## Note for License
@@ -80,26 +119,21 @@ mruby has chosen a MIT License due to its permissive license allowing
developers to target various environments such as embedded systems.
However, the license requires the display of the copyright notice and license
information in manuals for instance. Doing so for big projects can be
complicated or troublesome. This is why mruby has decided to display "mruby
complicated or troublesome. This is why mruby has decided to display "mruby
developers" as the copyright name to make it simple conventionally.
In the future, mruby might ask you to distribute your new code
(that you will commit,) under the MIT License as a member of
"mruby developers" but contributors will keep their copyright.
(We did not intend for contributors to transfer or waive their copyrights,
Actual copyright holder name (contributors) will be listed in the AUTHORS
actual copyright holder name (contributors) will be listed in the [AUTHORS](AUTHORS)
file.)
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 <http://github.com/mruby/mruby>. We consider you have granted
non-exclusive right to your contributed code under MIT license. If you want to
be named as one of mruby developers, please include an update to the AUTHORS
file in your pull request.
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]: http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=59579
[build-status-img]: https://travis-ci.org/mruby/mruby.svg?branch=master
[contribution-guidelines]: https://github.com/mruby/mruby/blob/master/CONTRIBUTING.md
[travis-ci]: https://travis-ci.org/mruby/mruby
[ISO-standard]: https://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=59579
[contribution-guidelines]: CONTRIBUTING.md
+48 -112
View File
@@ -1,4 +1,3 @@
# encoding: utf-8
# Build description.
# basic build file for mruby
MRUBY_ROOT = File.dirname(File.expand_path(__FILE__))
@@ -10,11 +9,11 @@ Rake.verbose(false) if Rake.verbose == Rake::DSL::DEFAULT
$LOAD_PATH << File.join(MRUBY_ROOT, "lib")
# load build systems
require "mruby-core-ext"
require "mruby/core_ext"
require "mruby/build"
# load configuration file
MRUBY_CONFIG = (ENV['MRUBY_CONFIG'] && ENV['MRUBY_CONFIG'] != '') ? ENV['MRUBY_CONFIG'] : "#{MRUBY_ROOT}/build_config.rb"
MRUBY_CONFIG = MRuby::Build.mruby_config_path
load MRUBY_CONFIG
# load basic rules
@@ -23,138 +22,75 @@ MRuby.each_target do |build|
end
# load custom rules
load "#{MRUBY_ROOT}/src/mruby_core.rake"
load "#{MRUBY_ROOT}/mrblib/mrblib.rake"
load "#{MRUBY_ROOT}/tasks/core.rake"
load "#{MRUBY_ROOT}/tasks/mrblib.rake"
load "#{MRUBY_ROOT}/tasks/mrbgems.rake"
load "#{MRUBY_ROOT}/tasks/libmruby.rake"
load "#{MRUBY_ROOT}/tasks/bin.rake"
load "#{MRUBY_ROOT}/tasks/presym.rake"
load "#{MRUBY_ROOT}/tasks/test.rake"
load "#{MRUBY_ROOT}/tasks/benchmark.rake"
load "#{MRUBY_ROOT}/tasks/gitlab.rake"
load "#{MRUBY_ROOT}/tasks/doc.rake"
def install_D(src, dst)
rm_f dst
mkdir_p File.dirname(dst)
cp src, dst
end
load "#{MRUBY_ROOT}/tasks/install.rake"
##############################
# generic build targets, rules
task :default => :all
bin_path = ENV['INSTALL_DIR'] || "#{MRUBY_ROOT}/bin"
depfiles = MRuby.targets['host'].bins.map do |bin|
install_path = MRuby.targets['host'].exefile("#{bin_path}/#{bin}")
source_path = MRuby.targets['host'].exefile("#{MRuby.targets['host'].build_dir}/bin/#{bin}")
file install_path => source_path do |t|
install_D t.prerequisites.first, t.name
end
install_path
end
MRuby.each_target do |target|
gems.map do |gem|
current_dir = gem.dir.relative_path_from(Dir.pwd)
relative_from_root = gem.dir.relative_path_from(MRUBY_ROOT)
current_build_dir = File.expand_path "#{build_dir}/#{relative_from_root}"
if current_build_dir !~ /^#{Regexp.escape(build_dir)}/
current_build_dir = "#{build_dir}/mrbgems/#{gem.name}"
end
gem.bins.each do |bin|
exec = exefile("#{build_dir}/bin/#{bin}")
objs = Dir.glob("#{current_dir}/tools/#{bin}/*.{c,cpp,cxx,cc}").map { |f| objfile(f.pathmap("#{current_build_dir}/tools/#{bin}/%n")) }
file exec => objs + target.libraries do |t|
gem_flags = gems.map { |g| g.linker.flags }
gem_flags_before_libraries = gems.map { |g| g.linker.flags_before_libraries }
gem_flags_after_libraries = gems.map { |g| g.linker.flags_after_libraries }
gem_libraries = gems.map { |g| g.linker.libraries }
gem_library_paths = gems.map { |g| g.linker.library_paths }
linker.run t.name, t.prerequisites, gem_libraries, gem_library_paths, gem_flags, gem_flags_before_libraries, gem_flags_after_libraries
end
if target == MRuby.targets['host']
install_path = MRuby.targets['host'].exefile("#{bin_path}/#{bin}")
file install_path => exec do |t|
install_D t.prerequisites.first, t.name
end
depfiles += [ install_path ]
elsif target == MRuby.targets['host-debug']
unless MRuby.targets['host'].gems.map {|g| g.bins}.include?([bin])
install_path = MRuby.targets['host-debug'].exefile("#{bin_path}/#{bin}")
file install_path => exec do |t|
install_D t.prerequisites.first, t.name
end
depfiles += [ install_path ]
end
else
depfiles += [ exec ]
end
end
end
end
depfiles += MRuby.targets.map { |n, t|
t.libraries
}.flatten
depfiles += MRuby.targets.reject { |n, t| n == 'host' }.map { |n, t|
t.bins.map { |bin| t.exefile("#{t.build_dir}/bin/#{bin}") }
}.flatten
desc "build all targets, install (locally) in-repo"
task :all => depfiles do
task :all => :gensym do
Rake::Task[:build].invoke
puts
puts "Build summary:"
puts
MRuby.each_target do
print_build_summary
MRuby.each_target do |build|
build.print_build_summary
end
MRuby::Lockfile.write
end
desc "run all mruby tests"
task :test
MRuby.each_target do
if test_enabled?
t = :"test_#{self.name}"
task t => ["all"] do
run_test
end
task :test => t
end
if bintest_enabled?
t = :"bintest_#{self.name}"
task t => ["all"] do
run_bintest
end
task :test => t
end
end
task :build => MRuby.targets.flat_map{|_, build| build.products}
desc "clean all built and in-repo installed artifacts"
task :clean do
MRuby.each_target do |t|
rm_rf t.build_dir
MRuby.each_target do |build|
rm_rf build.build_dir
rm_f build.products
end
rm_f depfiles
puts "Cleaned up target build folder"
puts "Cleaned up target build directory"
end
desc "clean everything!"
task :deep_clean => ["clean", "clean_doc"] do
MRuby.each_target do |t|
rm_rf t.gem_clone_dir
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"
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"
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
+20
View File
@@ -0,0 +1,20 @@
# Security Policy
## Reporting a Vulnerability
If you have any security concern, contact <matz@ruby.or.jp>.
## Scope
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:
- Runtime C undefined behavior (including integer overflow)
- Crash caused by misused API
- Crash caused by modified compiled binary
- ASAN/Valgrind warning for too big memory allocation
mruby assumes `malloc(3)` returns `NULL` for too big allocations
-8
View File
@@ -1,8 +0,0 @@
Things to do (Things that are not done yet)
* special variables ($1,$2..)
* super in aliased methods
Things to improve (Done but things to fix)
* Make additions as they are noticed.
+13
View File
@@ -0,0 +1,13 @@
# Things to Do in the future
# After mruby 3.1
- parser and code generator independent from `mrb_state` (picoruby?)
- variable sized AST node
- iv/hash entry cache
- more peephole optimization (if possible)
# Things to do (Things we need to consider)
- `begin ... end while cond` to behave as CRuby
- special variables ($1,$2..)
+33 -25
View File
@@ -1,39 +1,47 @@
version: "{build}"
os: Visual Studio 2017
shallow_clone: true
environment:
matrix:
# Visual Studio 2017 64bit
- visualcpp: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat
- 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
# Visual Studio 2017 32bit
- visualcpp: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat
- 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 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 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 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 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 32-bit
visualcpp: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat
appveyor_build_worker_image: Visual Studio 2015
machine: x86
# Visual Studio 2015 64bit
- visualcpp: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat
machine: amd64
# Visual Studio 2015 32bit
- visualcpp: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat
machine: x86
# Visual Studio 2013 64bit
- visualcpp: C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat
machine: amd64
init:
- call "%visualcpp%" %machine%
# For using Rubyinstaller's Ruby 2.4 64bit
- set PATH=C:\Ruby24-x64\bin;%PATH%
# 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=appveyor_config.rb
- rake -m
- rake -E $stdout.sync=true test
- set MRUBY_CONFIG=ci/msvc
- rake -m test:run:serial
-46
View File
@@ -1,46 +0,0 @@
def setup_option(conf)
conf.cc.flags[0].delete("/Zi") unless ENV['CFLAGS']
conf.cxx.flags[0].delete("/Zi") unless ENV['CFLAGS'] || ENV['CXXFLAGS']
conf.linker.flags << "/DEBUG:NONE" unless ENV['LDFLAGS']
end
MRuby::Build.new('full-debug') do |conf|
toolchain :visualcpp
enable_debug
# include all core GEMs
conf.gembox 'full-core'
conf.cc.defines += %w(MRB_GC_STRESS MRB_METHOD_CACHE MRB_ENABLE_DEBUG_HOOK)
setup_option(conf)
conf.enable_test
end
MRuby::Build.new do |conf|
toolchain :visualcpp
# include all core GEMs
conf.gembox 'full-core'
conf.compilers.each do |c|
c.defines += %w(MRB_GC_FIXED_ARENA)
end
setup_option(conf)
conf.enable_bintest
conf.enable_test
end
MRuby::Build.new('cxx_abi') do |conf|
toolchain :visualcpp
conf.gembox 'full-core'
conf.compilers.each do |c|
c.defines += %w(MRB_GC_FIXED_ARENA)
end
setup_option(conf)
conf.enable_bintest
conf.enable_test
enable_cxx_abi
build_mrbc_exec
end
+18 -23
View File
@@ -1,29 +1,29 @@
# AO render benchmark
# Original program (C) Syoyo Fujita in Javascript (and other languages)
# Original program (C) Syoyo Fujita in JavaScript (and other languages)
# https://code.google.com/p/aobench/
# Ruby(yarv2llvm) version by Hideki Miura
# mruby version by Hideki Miura
#
IMAGE_WIDTH = 64
IMAGE_HEIGHT = 64
IMAGE_WIDTH = Integer(ARGV[0] || 64)
IMAGE_HEIGHT = IMAGE_WIDTH
NSUBSAMPLES = 2
NAO_SAMPLES = 8
module Rand
# Use xorshift
@@x = 123456789
@@y = 362436069
@@z = 521288629
@@w = 88675123
@x = 123456789
@y = 362436069
@z = 521288629
@w = 88675123
BNUM = 1 << 29
BNUMF = BNUM.to_f
def self.rand
x = @@x
x = @x
t = x ^ ((x & 0xfffff) << 11)
w = @@w
@@x, @@y, @@z = @@y, @@z, w
w = @@w = (w ^ (w >> 19) ^ (t ^ (t >> 8)))
w = @w
@x, @y, @z = @y, @z, w
w = @w = (w ^ (w >> 19) ^ (t ^ (t >> 8)))
(w % BNUM) / BNUMF
end
end
@@ -179,7 +179,7 @@ def clamp(f)
i.to_i
end
def otherBasis(basis, n)
def orthoBasis(basis, n)
basis[2] = Vec.new(n.x, n.y, n.z)
basis[1] = Vec.new(0.0, 0.0, 0.0)
@@ -211,7 +211,7 @@ class Scene
def ambient_occlusion(isect)
basis = Array.new(3)
otherBasis(basis, isect.n)
orthoBasis(basis, isect.n)
ntheta = NAO_SAMPLES
nphi = NAO_SAMPLES
@@ -243,8 +243,6 @@ class Scene
@plane.intersect(ray, occisect)
if occisect.hit
occlusion = occlusion + 1.0
else
0.0
end
end
end
@@ -254,16 +252,15 @@ class Scene
end
def render(w, h, nsubsamples)
cnt = 0
nsf = nsubsamples.to_f
nsfs = nsf * nsf
h.times do |y|
w.times do |x|
rad = Vec.new(0.0, 0.0, 0.0)
# Subsmpling
# Subsampling
nsubsamples.times do |v|
nsubsamples.times do |u|
cnt = cnt + 1
wf = w.to_f
hf = h.to_f
xf = x.to_f
@@ -288,15 +285,13 @@ class Scene
rad.x = rad.x + col.x
rad.y = rad.y + col.y
rad.z = rad.z + col.z
else
0.0
end
end
end
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))
-1
View File
@@ -1,4 +1,3 @@
def fib n
return n if n < 2
fib(n-2) + fib(n-1)
+4 -2
View File
@@ -1,9 +1,11 @@
#from http://www.bagley.org/~doug/shootout/bench/lists/lists.ruby
# from http://www.bagley.org/~doug/shootout/bench/lists/lists.ruby
# which is lost long time ago. The past content can be retrieved from
# https://web.archive.org/web/20040805115204/http://www.bagley.org/~doug/shootout/bench/lists/lists.ruby
NUM = 300
SIZE = 10000
def test_lists()
def test_lists
# create a list of integers (Li1) from 1 to SIZE
li1 = (1..SIZE).to_a
# copy the list to li2 (not by individual items)
+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
-28
View File
@@ -1,28 +0,0 @@
MRuby::Build.new do |conf|
toolchain :gcc
end
MRuby::Build.new('no_boxing') do |conf|
toolchain :gcc
conf.gembox 'default'
end
MRuby::Build.new('word_boxing') do |conf|
toolchain :gcc
conf.gembox 'default'
conf.compilers.each do |c|
c.defines += %w(MRB_WORD_BOXING)
end
end
MRuby::Build.new('nan_boxing') do |conf|
toolchain :gcc
conf.gembox 'default'
conf.compilers.each do |c|
c.defines += %w(MRB_NAN_BOXING)
end
end
-13
View File
@@ -1,13 +0,0 @@
MRuby::Build.new do |conf|
toolchain :gcc
end
MRuby::Build.new('gcc') do |conf|
toolchain :gcc
conf.gembox 'default'
end
MRuby::Build.new('clang') do |conf|
toolchain :clang
conf.gembox 'default'
end
+8 -151
View File
@@ -1,152 +1,9 @@
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
# Turn on `enable_debug` for better debugging
# enable_debug
# Use mrbgems
# conf.gem 'examples/mrbgems/ruby_extension_example'
# conf.gem 'examples/mrbgems/c_extension_example' do |g|
# g.cc.flags << '-g' # append cflags in this gem
# end
# conf.gem 'examples/mrbgems/c_and_ruby_extension_example'
# conf.gem :core => 'mruby-eval'
# conf.gem :mgem => 'mruby-onig-regexp'
# conf.gem :github => 'mattn/mruby-onig-regexp'
# conf.gem :git => 'git@github.com:mattn/mruby-onig-regexp.git', :branch => 'master', :options => '-v'
# include the default GEMs
conf.gembox 'default'
# C compiler settings
# conf.cc do |cc|
# cc.command = ENV['CC'] || 'gcc'
# cc.flags = [ENV['CFLAGS'] || %w()]
# cc.include_paths = ["#{root}/include"]
# cc.defines = %w()
# cc.option_include_path = %q[-I"%s"]
# cc.option_define = '-D%s'
# cc.compile_options = %Q[%{flags} -MMD -o "%{outfile}" -c "%{infile}"]
# end
# mrbc settings
# conf.mrbc do |mrbc|
# mrbc.compile_options = "-g -B%{funcname} -o-" # The -g option is required for line numbers
# end
# Linker settings
# conf.linker do |linker|
# linker.command = ENV['LD'] || 'gcc'
# linker.flags = [ENV['LDFLAGS'] || []]
# linker.flags_before_libraries = []
# linker.libraries = %w()
# linker.flags_after_libraries = []
# linker.library_paths = []
# linker.option_library = '-l%s'
# linker.option_library_path = '-L%s'
# linker.link_options = "%{flags} -o "%{outfile}" %{objs} %{libs}"
# end
# Archiver settings
# conf.archiver do |archiver|
# archiver.command = ENV['AR'] || 'ar'
# archiver.archive_options = 'rs "%{outfile}" %{objs}'
# end
# Parser generator settings
# conf.yacc do |yacc|
# yacc.command = ENV['YACC'] || 'bison'
# yacc.compile_options = %q[-o "%{outfile}" "%{infile}"]
# end
# gperf settings
# conf.gperf do |gperf|
# gperf.command = 'gperf'
# gperf.compile_options = %q[-L ANSI-C -C -p -j1 -i 1 -g -o -t -N mrb_reserved_word -k"1,3,$" "%{infile}" > "%{outfile}"]
# end
# file extensions
# conf.exts do |exts|
# exts.object = '.o'
# exts.executable = '' # '.exe' if Windows
# exts.library = '.a'
# end
# file separetor
# conf.file_separator = '/'
# bintest
# conf.enable_bintest
end
MRuby::Build.new('host-debug') do |conf|
# load specific toolchain settings
# Gets set by the VS command prompts.
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
toolchain :visualcpp
else
toolchain :gcc
end
enable_debug
# include the default GEMs
conf.gembox 'default'
# C compiler settings
conf.cc.defines = %w(MRB_ENABLE_DEBUG_HOOK)
# Generate mruby debugger command (require mruby-eval)
conf.gem :core => "mruby-bin-debugger"
# bintest
# conf.enable_bintest
end
MRuby::Build.new('test') do |conf|
# Gets set by the VS command prompts.
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
toolchain :visualcpp
else
toolchain :gcc
end
enable_debug
conf.enable_bintest
conf.enable_test
conf.gembox 'default'
end
#MRuby::Build.new('bench') do |conf|
# # Gets set by the VS command prompts.
# if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
# toolchain :visualcpp
# else
# toolchain :gcc
# conf.cc.flags << '-O3'
# end
# The default build configuration file was moved to `build_config/default.rb`.
#
# conf.gembox 'default'
#end
# Define cross build settings
# MRuby::CrossBuild.new('32bit') do |conf|
# toolchain :gcc
#
# conf.cc.flags << "-m32"
# conf.linker.flags << "-m32"
#
# conf.build_mrbtest_lib_only
#
# conf.gem 'examples/mrbgems/c_and_ruby_extension_example'
#
# conf.test_runner.command = 'env'
# end
# Recommended way to customize the build configuration is:
# * copy `default.rb` (or any config file) to a new file (e.g. `myconfig.rb`)
# * edit `myconfig.rb`.
# * `rake MRUBY_CONFIG=/path/to/myconfig.rb` to compile and test.
# * or `rake MRUBY_CONFIG=myconfig` if your configuration file is in the `build_config` directory.
# * (optional) submit your configuration as a pull-request if it's useful for others
raise "The default configuration was moved to `build_config/default.rb`"
@@ -1,21 +1,5 @@
MRuby::Build.new do |conf|
# Gets set by the VS command prompts.
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
toolchain :visualcpp
else
toolchain :gcc
end
enable_debug
# include the default GEMs
conf.gembox 'default'
end
# Cross Compiling configuration for Arduino Due
# http://arduino.cc/en/Main/ArduinoBoardDue
# https://arduino.cc/en/Main/ArduinoBoardDue
#
# Requires Arduino IDE >= 1.5
MRuby::CrossBuild.new("ArduinoDue") do |conf|
@@ -27,7 +11,7 @@ MRuby::CrossBuild.new("ArduinoDue") do |conf|
# ARDUINO_PATH = '/Applications/Arduino.app/Contents/Java'
# GNU Linux
ARDUINO_PATH = '/opt/arduino'
# Arduino IDE <= 1.5.6
# Arduino IDE <= 1.5.6
BIN_PATH = "#{ARDUINO_PATH}/hardware/tools/g++_arm_none_eabi/bin"
# Arduino IDE >= 1.5.7
# BIN_PATH = "#{ARDUINO_PATH}/hardware/tools/gcc-arm-none-eabi-4.8.3-2014q1/bin"
@@ -47,9 +31,8 @@ MRuby::CrossBuild.new("ArduinoDue") do |conf|
#configuration for low memory environment
cc.defines << %w(MRB_HEAP_PAGE_SIZE=64)
cc.defines << %w(KHASH_DEFAULT_SIZE=8)
cc.defines << %w(MRB_STR_BUF_MIN_SIZE=20)
cc.defines << %w(MRB_GC_STRESS)
#cc.defines << %w(MRB_DISABLE_STDIO) #if you dont need stdio.
#cc.defines << %w(MRB_NO_STDIO) #if you don't need stdio.
#cc.defines << %w(POOL_PAGE_SIZE=1000) #effective only for use with mruby-eval
end
@@ -77,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"
@@ -5,7 +5,7 @@
MRuby::Build.new do |conf|
toolchain :gcc
conf.gembox 'default'
conf.cc.defines = %w(ENABLE_READLINE)
conf.cc.defines = %w(MRB_USE_READLINE)
conf.gembox 'default'
#lightweight regular expression
@@ -21,7 +21,7 @@ MRuby::CrossBuild.new('core2-32-poky-linux') do |conf|
#
POKY_EDISON_PATH = '/opt/poky-edison/1.7.2'
POKY_EDISON_SYSROOT = "#{POKY_EDISON_PATH}/sysroots/core2-32-poky-linux"
POKY_EDISON_SYSROOT = "#{POKY_EDISON_PATH}/sysroots/core2-32-poky-linux"
POKY_EDISON_X86_PATH = "#{POKY_EDISON_PATH}/sysroots/i386-pokysdk-darwin"
POKY_EDISON_BIN_PATH = "#{POKY_EDISON_X86_PATH}/usr/bin/i586-poky-linux"
@@ -33,7 +33,7 @@ MRuby::CrossBuild.new('core2-32-poky-linux') do |conf|
cc.flags << %w(-O2 -pipe -g -feliminate-unused-debug-types)
cc.flags << "--sysroot=#{POKY_EDISON_SYSROOT}"
cc.compile_options = %Q[%{flags} -o "%{outfile}" -c "%{infile}"]
cc.defines = %w(ENABLE_READLINE)
cc.defines = %w(MRB_USE_READLINE)
end
conf.cxx do |cxx|
@@ -1,22 +1,5 @@
MRuby::Build.new do |conf|
# Gets set by the VS command prompts.
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
toolchain :visualcpp
else
toolchain :gcc
end
enable_debug
# include the default GEMs
conf.gembox 'default'
end
# Cross Compiling configuration for Intel Galileo on Arduino environment
# http://arduino.cc/en/ArduinoCertified/IntelGalileo
# https://arduino.cc/en/ArduinoCertified/IntelGalileo
#
# Requires Arduino IDE for Intel Galileo
MRuby::CrossBuild.new("Galileo") do |conf|
@@ -29,7 +12,7 @@ MRuby::CrossBuild.new("Galileo") do |conf|
#ARDUINO_GALILEO_PATH = '/opt/arduino'
GALILEO_BIN_PATH = "#{GALILEO_ARDUINO_PATH}/hardware/tools/x86/i386-pokysdk-darwin/usr/bin/i586-poky-linux-uclibc"
GALILEO_SYSROOT = "#{GALILEO_ARDUINO_PATH}/hardware/tools/x86/i586-poky-linux-uclibc"
GALILEO_SYSROOT = "#{GALILEO_ARDUINO_PATH}/hardware/tools/x86/i586-poky-linux-uclibc"
GALILEO_X86_PATH = "#{GALILEO_ARDUINO_PATH}/hardware/arduino/x86"
@@ -73,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"
@@ -91,7 +73,7 @@ MRuby::CrossBuild.new("Galileo") do |conf|
conf.gem :core => "mruby-fiber"
conf.gem :core => "mruby-toplevel-ext"
#lightweigh regular expression
#lightweight regular expression
conf.gem :github => "masamitsu-murase/mruby-hs-regexp", :branch => "master"
#Arduino API
@@ -1,19 +1,3 @@
MRuby::Build.new do |conf|
# Gets set by the VS command prompts.
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
toolchain :visualcpp
else
toolchain :gcc
end
enable_debug
# include the default GEMs
conf.gembox 'default'
end
# Cross Compiling configuration for RX630
# http://gadget.renesas.com/
#
@@ -30,12 +14,11 @@ MRuby::CrossBuild.new("RX630") do |conf|
cc.compile_options = %Q[%{flags} -o "%{outfile}" -c "%{infile}"]
#configuration for low memory environment
cc.defines << %w(MRB_USE_FLOAT)
cc.defines << %w(MRB_USE_FLOAT32)
cc.defines << %w(MRB_HEAP_PAGE_SIZE=64)
cc.defines << %w(KHASH_DEFAULT_SIZE=8)
cc.defines << %w(MRB_STR_BUF_MIN_SIZE=20)
cc.defines << %w(MRB_GC_STRESS)
cc.defines << %w(MRB_DISABLE_STDIO) #if you dont need stdio.
cc.defines << %w(MRB_NO_STDIO) #if you don't need stdio.
#cc.defines << %w(POOL_PAGE_SIZE=1000) #effective only for use with mruby-eval
end
@@ -67,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"
+11
View File
@@ -0,0 +1,11 @@
# Requires Android NDK r13 or later.
MRuby::CrossBuild.new('android-arm64-v8a') do |conf|
params = {
:arch => 'arm64-v8a',
:sdk_version => 33,
:toolchain => :clang
}
toolchain :android, params
conf.gembox 'default'
end
@@ -0,0 +1,13 @@
# Requires Android NDK r13 or later.
MRuby::CrossBuild.new('android-armeabi-v7a-neon-hard') do |conf|
params = {
:arch => 'armeabi-v7a',
:mfpu => 'neon',
:mfloat_abi => 'hard',
:sdk_version => 33,
:toolchain => :clang
}
toolchain :android, params
conf.gembox 'default'
end
+11
View File
@@ -0,0 +1,11 @@
MRuby::Build.new('bench') do |conf|
# Gets set by the VS command prompts.
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
toolchain :visualcpp
else
toolchain :gcc
conf.cc.flags << '-O3'
end
conf.gembox 'default'
end
+19
View File
@@ -0,0 +1,19 @@
boxings = %w[no word nan]
bits = [64, 32]
ints = [64, 32]
boxings.product(bits, ints) do |boxing, bit, int|
MRuby::Build.new("boxing-#{boxing}-m#{bit}-i#{int}") do |conf|
conf.toolchain :gcc
conf.gembox 'full-core'
conf.compilers.each do |c|
c.defines << "MRB_#{boxing.upcase}_BOXING"
c.defines << "MRB_INT#{int}"
c.flags << "-m#{bit}"
end
conf.linker.flags << "-m#{bit}"
conf.enable_debug
conf.enable_test
conf.enable_bintest
end
end
@@ -1,21 +1,5 @@
MRuby::Build.new do |conf|
# Gets set by the VS command prompts.
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
toolchain :visualcpp
else
toolchain :gcc
end
enable_debug
# include the default GEMs
conf.gembox 'default'
end
# Cross Compiling configuration for Digilent chipKIT Max32
# http://www.digilentinc.com/Products/Detail.cfm?Prod=CHIPKIT-MAX32
# https://www.digilentinc.com/Products/Detail.cfm?Prod=CHIPKIT-MAX32
#
# Requires MPIDE (https://github.com/chipKIT32/chipKIT32-MAX)
#
@@ -44,9 +28,8 @@ MRuby::CrossBuild.new("chipKITMax32") do |conf|
#configuration for low memory environment
cc.defines << %w(MRB_HEAP_PAGE_SIZE=64)
cc.defines << %w(KHASH_DEFAULT_SIZE=8)
cc.defines << %w(MRB_STR_BUF_MIN_SIZE=20)
cc.defines << %w(MRB_GC_STRESS)
#cc.defines << %w(MRB_DISABLE_STDIO) #if you dont need stdio.
#cc.defines << %w(MRB_NO_STDIO) #if you don't need stdio.
#cc.defines << %w(POOL_PAGE_SIZE=1000) #effective only for use with mruby-eval
end
@@ -73,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"
@@ -1,21 +1,22 @@
STDOUT.sync = STDERR.sync = true unless Rake.application.options.always_multitask
MRuby::Build.new('full-debug') do |conf|
toolchain :gcc
enable_debug
conf.toolchain
conf.enable_debug
# include all core GEMs
conf.gembox 'full-core'
conf.cc.flags += %w(-Werror=declaration-after-statement)
conf.cc.defines += %w(MRB_GC_STRESS MRB_METHOD_CACHE MRB_ENABLE_DEBUG_HOOK)
conf.cc.defines += %w(MRB_GC_STRESS MRB_USE_DEBUG_HOOK)
conf.enable_test
end
MRuby::Build.new do |conf|
toolchain :gcc
conf.toolchain
# include all core GEMs
conf.gembox 'full-core'
conf.cc.flags += %w(-Werror=declaration-after-statement)
conf.gem :core => 'mruby-bin-debugger'
conf.compilers.each do |c|
c.defines += %w(MRB_GC_FIXED_ARENA)
end
@@ -24,17 +25,16 @@ MRuby::Build.new do |conf|
end
MRuby::Build.new('cxx_abi') do |conf|
toolchain :gcc
conf.toolchain
conf.gembox 'full-core'
conf.cc.flags += %w(-fpermissive)
conf.cc.flags += %w(-fpermissive -std=gnu++03)
conf.compilers.each do |c|
c.defines += %w(MRB_GC_FIXED_ARENA)
end
conf.enable_bintest
conf.enable_test
enable_cxx_abi
conf.enable_cxx_abi
build_mrbc_exec
conf.build_mrbc_exec
end
+20
View File
@@ -0,0 +1,20 @@
STDOUT.sync = STDERR.sync = true unless Rake.application.options.always_multitask
def setup_option(conf)
conf.cc.compile_options.sub!(%r{/Zi }, "") unless ENV['CFLAGS']
conf.cxx.compile_options.sub!(%r{/Zi }, "") unless ENV['CFLAGS'] || ENV['CXXFLAGS']
conf.linker.flags << "/DEBUG:NONE" unless ENV['LDFLAGS']
end
MRuby::Build.new do |conf|
conf.toolchain :visualcpp
# include all core GEMs
conf.gembox 'full-core'
conf.compilers.each do |c|
c.defines += %w(MRB_GC_FIXED_ARENA)
end
setup_option(conf)
conf.enable_bintest
conf.enable_test
end
+11
View File
@@ -0,0 +1,11 @@
MRuby::Build.new do |conf|
conf.toolchain :clang
# include the GEM box
conf.gembox 'full-core'
# Turn on `enable_debug` for better debugging
conf.enable_sanitizer "address,undefined"
conf.enable_debug
conf.enable_bintest
conf.enable_test
end
+14
View File
@@ -0,0 +1,14 @@
# Define cross build settings
MRuby::CrossBuild.new('cross-32bit') do |conf|
conf.toolchain :gcc
conf.cc.flags << "-m32"
conf.linker.flags << "-m32"
# conf.build_mrbtest_lib_only
conf.gem :core => "mruby-bin-mruby"
conf.gem "#{MRUBY_ROOT}/examples/mrbgems/c_and_ruby_extension_example"
conf.test_runner.command = 'env'
end
+90
View File
@@ -0,0 +1,90 @@
# Cross-compile using MinGW and test using Wine.
#
# Steps:
#
# 1. Install MinGW; 64-bit target seems to work best.
#
# 2. Install Wine.
#
# 3. Run command:
#
# wine cmd /c echo "Hello world"'
#
# This will confirm that Wine works and will trigger standard
# Wine setup, which is slow.
#
# 4. Confirm that drive 'z:' is mapped to your root filesystem.
# (This is supposed to be a default but it helps to
# double-check.) To confirm, run:
#
# wine cmd /c dir 'z:\\'
#
# This should give you a DOS-style equivalent of 'ls /'. If not,
# you'll need to fix that with winecfg or by adding a symlink to
# '~/.wine/dosdevices'.
#
# 5. You will likely need to tweak the settings below to work with
# your configuration unless it is exactly like one of the platforms
# I've tested on (Ubuntu 20.04 or macOS using brew.)
#
# 6. Run the build command:
#
# MRUBY_CONFIG=build_config/cross-mingw-winetest.rb rake test
#
# If all goes well, you should now have Windows executables and a
# set of passing tests.
#
#
# Caveats:
#
# 1. This works by using a helper script that rewrites test output
# to make it look *nix-like and then handing it back to the test
# cases. Some of the existing tests were (slightly) modified to
# make this easier but only for the 'full-core' gembox. Other
# gems' bintests may or may not work with the helper script and
# may or may not be fixable by extending the script.
#
# 2. MinGW and Wine are both complex and not very consistent so you
# will likely need to do some fiddling to get things to work.
#
# 3. This script assumes you are running it on a *nix-style OS.
#
# 4. I recommend building 64-bit targets only. Building a 32-bit
# Windows binary with i686-w64-mingw32 seems to work (at least,
# it did for me) but the resulting executable failed a number of
# unit tests due to small errors in some floating-point
# operations. It's unclear if this indicates more serious problems.
#
MRuby::CrossBuild.new("cross-mingw-winetest") do |conf|
conf.toolchain :gcc
conf.host_target = "x86_64-w64-mingw32"
# Ubuntu 20
conf.cc.command = "#{conf.host_target}-gcc-posix"
# macOS+Wine from brew
#conf.cc.command = "#{conf.host_target}-gcc"
conf.linker.command = conf.cc.command
conf.archiver.command = "#{conf.host_target}-gcc-ar"
conf.exts.executable = ".exe"
# By default, we compile as static as possible to remove runtime
# MinGW dependencies; they are probably fixable but it gets
# complicated.
conf.cc.flags = ['-static']
conf.linker.flags += ['-static']
conf.test_runner do |t|
thisdir = File.absolute_path( File.dirname(__FILE__) )
t.command = File.join(thisdir, * %w{ helpers wine_runner.rb})
end
conf.gembox "full-core"
conf.enable_bintest
conf.enable_test
end
+14
View File
@@ -0,0 +1,14 @@
#
# Ubuntu 20.04 requires at least `gcc-mingw-w64-x86-64` package as a
# cross compiler.
#
MRuby::CrossBuild.new("cross-mingw") do |conf|
conf.toolchain :gcc
conf.host_target = "x86_64-w64-mingw32" # required for `for_windows?` used by `mruby-socket` gem
conf.cc.command = "#{conf.host_target}-gcc-posix"
conf.linker.command = conf.cc.command
conf.archiver.command = "#{conf.host_target}-gcc-ar"
conf.exts.executable = ".exe"
conf.gembox "default"
end
+83
View File
@@ -0,0 +1,83 @@
MRuby::Build.new do |conf|
# load specific toolchain settings
conf.toolchain
# Use mrbgems
# conf.gem 'examples/mrbgems/ruby_extension_example'
# conf.gem 'examples/mrbgems/c_extension_example' do |g|
# g.cc.flags << '-g' # append cflags in this gem
# end
# conf.gem 'examples/mrbgems/c_and_ruby_extension_example'
# conf.gem :core => 'mruby-eval'
# conf.gem :mgem => 'mruby-onig-regexp'
# conf.gem :github => 'mattn/mruby-onig-regexp'
# conf.gem :git => 'git@github.com:mattn/mruby-onig-regexp.git', :branch => 'master', :options => '-v'
# include the GEM box
conf.gembox 'default'
# C compiler settings
# conf.cc do |cc|
# cc.command = ENV['CC'] || 'gcc'
# cc.flags = [ENV['CFLAGS'] || %w()]
# cc.include_paths = ["#{root}/include"]
# cc.defines = %w()
# cc.option_include_path = %q[-I"%s"]
# cc.option_define = '-D%s'
# cc.compile_options = %Q[%{flags} -MMD -o "%{outfile}" -c "%{infile}"]
# end
# mrbc settings
# conf.mrbc do |mrbc|
# mrbc.compile_options = "-g -B%{funcname} -o-" # The -g option is required for line numbers
# end
# Linker settings
# conf.linker do |linker|
# linker.command = ENV['LD'] || 'gcc'
# linker.flags = [ENV['LDFLAGS'] || []]
# linker.flags_before_libraries = []
# linker.libraries = %w()
# linker.flags_after_libraries = []
# linker.library_paths = []
# linker.option_library = '-l%s'
# linker.option_library_path = '-L%s'
# linker.link_options = %Q[%{flags} -o "%{outfile}" %{objs} %{libs}]
# end
# Archiver settings
# conf.archiver do |archiver|
# archiver.command = ENV['AR'] || 'ar'
# archiver.archive_options = 'rs "%{outfile}" %{objs}'
# end
# Parser generator settings
# conf.yacc do |yacc|
# yacc.command = ENV['YACC'] || 'bison'
# yacc.compile_options = %q[-o "%{outfile}" "%{infile}"]
# end
# gperf settings
# conf.gperf do |gperf|
# gperf.command = 'gperf'
# gperf.compile_options = %q[-L ANSI-C -C -j1 -i 1 -o -t -N mrb_reserved_word -k"1,3,$" "%{infile}" > "%{outfile}"]
# end
# file extensions
# conf.exts do |exts|
# exts.object = '.o'
# exts.executable = '' # '.exe' if Windows
# exts.library = '.a'
# end
# 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
conf.enable_test
end
+82
View File
@@ -0,0 +1,82 @@
# Cross Compiling configuration for the Sega Dreamcast
# https://dreamcast.wiki/Using_Ruby_for_Sega_Dreamcast_development
#
# Requires KallistiOS (KOS)
# http://gamedev.allusion.net/softprj/kos/
#
# 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/
#
# Install mruby for Sega Dreamcast using the "mruby" kos-port.
#
MRuby::CrossBuild.new("dreamcast") do |conf|
toolchain :gcc
# Getting critical environment variables
KOS_BASE = ENV["KOS_BASE"]
KOS_CC_BASE = ENV["KOS_CC_BASE"]
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
# All flags and settings below were extracted from KallistiOS environment files
conf.cc do |cc|
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)
end
# C++ compiler
conf.cxx do |cxx|
cxx.command = conf.cc.command.dup
cxx.include_paths = conf.cc.include_paths.dup
cxx.flags = conf.cc.flags.dup
cxx.flags << %w(-fno-operator-names)
cxx.defines = conf.cc.defines.dup
cxx.compile_options = conf.cc.compile_options.dup
end
# Linker
conf.linker do |linker|
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 = "#{KOS_CC_BASE}/bin/sh-elf-ar"
archiver.archive_options = 'rcs "%{outfile}" %{objs}'
end
# No executables needed for KallistiOS
conf.bins = []
# Do not build test binaries
conf.build_mrbtest_lib_only
# Gemboxes
conf.gembox "default-no-stdio"
conf.gembox "stdlib-ext"
conf.gembox "metaprog"
# 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-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"
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
+72
View File
@@ -0,0 +1,72 @@
# Cross Compiling configuration for the Nintendo GameBoyAdvance.
# This configuration requires devkitARM
# https://devkitpro.org/wiki/Getting_Started/devkitARM
#
# Tested only on GNU/Linux
#
MRuby::CrossBuild.new("gameboyadvance") do |conf|
toolchain :gcc
DEVKITPRO_PATH = "/opt/devkitpro"
BIN_PATH = "#{DEVKITPRO_PATH}/devkitARM/bin"
# C compiler
conf.cc do |cc|
cc.command = "#{BIN_PATH}/arm-none-eabi-gcc"
cc.flags << ["-mthumb-interwork", "-mthumb", "-O2"]
cc.compile_options = %(%{flags} -o "%{outfile}" -c "%{infile}")
end
# C++ compiler
conf.cxx do |cxx|
cxx.command = "#{BIN_PATH}/arm-none-eabi-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}/arm-none-eabi-gcc"
linker.flags << ["-mthumb-interwork", "-mthumb", "-specs=gba.specs"]
end
# No executables
conf.bins = []
# Do not build executable test
conf.build_mrbtest_lib_only
# Disable C++ exception
conf.disable_cxx_exception
# Gems from core
# removing mruby-io
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"
end
+71
View File
@@ -0,0 +1,71 @@
#!/usr/bin/env ruby
# Wrapper for running tests for cross-compiled Windows builds in Wine.
require 'open3'
DOSROOT = 'z:'
# Rewrite test output to replace DOS-isms with Unix-isms.
def clean(output, stderr = false)
ends_with_newline = !!(output =~ /\n$/)
executable = ARGV[0].gsub(/\.exe\z/i, '')
# Fix line-ends
output = output.gsub(/\r\n/, "\n")
# Strip out Wine messages
results = output.split(/\n/).map do |line|
# Fix file paths
if line =~ /#{DOSROOT}\\/i
line.gsub!(/#{DOSROOT}([^:]*)/i) { |path|
path.gsub!(/^#{DOSROOT}/i, '')
path.gsub!(%r{\\}, '/')
path
}
end
# strip '.exe' off the end of the executable's name if needed
line.gsub!(/(#{Regexp.escape executable})\.exe/i, '\1')
line
end
result_text = results.join("\n")
result_text += "\n" if ends_with_newline
result_text
end
def main
if ARGV.empty? || ARGV[0] =~ /^- (-?) (\?|help|h) $/x
puts "#{$0} <command-line>"
exit 0
end
# For simplicity, just read all of stdin into memory and pass that
# as an argument when invoking wine. (Skipped if STDIN was not
# redirected.)
if !STDIN.tty?
input = STDIN.read
else
input = ""
end
# Disable all Wine messages so they don't interfere with the output
ENV['WINEDEBUG'] = 'err-all,warn-all,fixme-all,trace-all'
# Run the program in wine and capture the output
output, errormsg, status = Open3.capture3('wine', *ARGV, :stdin_data => input)
# Clean and print the results.
STDOUT.write clean(output)
STDERR.write clean(errormsg)
exit(status.exitstatus)
end
main()
+12
View File
@@ -0,0 +1,12 @@
MRuby::Build.new do |conf|
conf.toolchain
# include the default GEMs
conf.gembox 'default'
# C compiler settings
conf.cc.defines = %w(MRB_USE_DEBUG_HOOK)
conf.enable_debug
conf.enable_cxx_abi
conf.enable_test
end
+20
View File
@@ -0,0 +1,20 @@
MRuby::Build.new('host') do |conf|
# load specific toolchain settings
conf.toolchain
conf.enable_debug
# include the default GEMs
conf.gembox 'full-core'
# C compiler settings
conf.cc.defines = %w(MRB_USE_DEBUG_HOOK MRB_NO_BOXING)
# Generate mruby debugger command (require mruby-eval)
conf.gem :core => "mruby-bin-debugger"
# test
conf.enable_test
# bintest
conf.enable_bintest
end
+14
View File
@@ -0,0 +1,14 @@
MRuby::Build.new do |conf|
# load specific toolchain settings
toolchain :gcc
# include the GEM box
conf.gembox 'full-core'
conf.cc.defines << 'MRB_USE_FLOAT32'
# Turn on `enable_debug` for better debugging
conf.enable_debug
conf.enable_test
conf.enable_bintest
end
+14
View File
@@ -0,0 +1,14 @@
MRuby::Build.new do |conf|
# load specific toolchain settings
toolchain :gcc
# include the GEM box
conf.gembox 'full-core'
conf.cc.flags << '-pg'
conf.linker.flags << '-pg'
# Turn on `enable_debug` for better debugging
conf.enable_debug
conf.enable_test
end
+15
View File
@@ -0,0 +1,15 @@
MRuby::Build.new do |conf|
# load specific toolchain settings
toolchain :gcc
# include the GEM box
conf.gembox 'full-core'
conf.cc.flags << '-m32'
conf.linker.flags << '-m32'
# Turn on `enable_debug` for better debugging
conf.enable_debug
conf.enable_test
conf.enable_bintest
end
+22
View File
@@ -0,0 +1,22 @@
MRuby::Build.new do |conf|
# load specific toolchain settings
toolchain :gcc
# include the GEM box
conf.gembox "stdlib"
conf.gembox "stdlib-ext"
conf.gembox "stdlib-io"
conf.gembox "metaprog"
conf.gem :core => 'mruby-bin-mruby'
conf.gem :core => 'mruby-bin-mirb'
# Add configuration
conf.compilers.each do |c|
c.defines << "MRB_NO_FLOAT"
end
conf.enable_debug
conf.enable_test
conf.enable_bintest
end
+36
View File
@@ -0,0 +1,36 @@
# NOTE: Currently, this configuration file does not support VisualC++!
# Your help is needed!
MRuby::Build.new do |conf|
# load specific toolchain settings
conf.toolchain
# include the GEM box
conf.gembox 'default'
# C compiler settings
conf.compilers.each do |cc|
cc.flags << '-fPIC'
end
conf.archiver do |archiver|
archiver.command = cc.command
archiver.archive_options = '-shared -o %{outfile} %{objs}'
end
# file extensions
conf.exts do |exts|
exts.library = '.so'
end
# 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
conf.enable_test
end
+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 Luckfox Pico embedded SBC.
#
# To build on Ubuntu x86_64: rake MRUBY_CONFIG=build_config/luckfox_pico.rb
# Uses Buildroot SDK for this board. Binaries run on the corresponding Linux image.
# Requires: https://github.com/LuckfoxTECH/luckfox-pico
#
# NOTE: default config includes all standard mrbgems, EXCEPT: mruby-cmath
#
MRuby::CrossBuild.new("luckfox_pico") do |conf|
# Clone the luckfox-pico repo above next to (same directory level) as mruby.
SDK_BASE = File.realpath(File.expand_path("../../../", File.expand_path(__FILE__)) + "/luckfox-pico")
TOOLCHAIN_BASE = "#{SDK_BASE}/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf"
SYSROOT = "#{TOOLCHAIN_BASE}/arm-rockchip830-linux-uclibcgnueabihf/sysroot"
toolchain :gcc
# C compiler settings
conf.cc do |cc|
cc.command = "#{TOOLCHAIN_BASE}/bin/arm-rockchip830-linux-uclibcgnueabihf-gcc"
cc.include_paths << "#{TOOLCHAIN_BASE}/lib/gcc/arm-rockchip830-linux-uclibcgnueabihf/8.3.0/include"
cc.include_paths << "#{TOOLCHAIN_BASE}/lib/gcc/arm-rockchip830-linux-uclibcgnueabihf/8.3.0/include-fixed"
cc.include_paths << "#{TOOLCHAIN_BASE}/arm-rockchip830-linux-uclibcgnueabihf/include/c++/8.3.0/arm-rockchip830-linux-uclibcgnueabihf"
cc.include_paths << "#{SYSROOT}/usr/include"
# Flags taken from the SDK's Makefile
cc.flags << ["-march=armv7-a", "-mfpu=neon", "-mfloat-abi=hard"]
cc.flags << ["-D_LARGEFILE_SOURCE", "-D_LARGEFILE64_SOURCE", "-D_FILE_OFFSET_BITS=64", "-ffunction-sections", "-fdata-sections"]
cc.flags << ["-O2", "-fPIC"]
cc.flags << ["-Wl,--copy-dt-needed-entries", "-Wl,-lc,-lgcc_s"]
end
# Linker settings
conf.linker do |linker|
linker.command = cc.command
linker.library_paths << "#{TOOLCHAIN_BASE}/arm-rockchip830-linux-uclibcgnueabihf/lib"
linker.flags = cc.flags
end
# Archiver settings
conf.archiver do |archiver|
archiver.command = "#{TOOLCHAIN_BASE}/bin/arm-rockchip830-linux-uclibcgnueabihf-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/'
# SDK doesn't include complex math for uClibc
# 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
+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
+4
View File
@@ -0,0 +1,4 @@
MRuby::CrossBuild.new('minimal') do |conf|
conf.toolchain :gcc
conf.cc.defines << 'MRB_NO_STDIO'
end
+11
View File
@@ -0,0 +1,11 @@
MRuby::Build.new do |conf|
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
conf.toolchain :visualcpp
else
conf.toolchain :gcc
end
conf.build_mrbc_exec
conf.disable_libmruby
conf.disable_presym
end
+73
View File
@@ -0,0 +1,73 @@
# Cross Compiling configuration for the Nintendo Switch, it requires Nintendo SDK
# Tested on windows
MRuby::CrossBuild.new('nintendo_switch_32bit') do |conf|
conf.toolchain :clang
NINTENDO_SDK_PATH = ENV['NINTENDO_SDK_ROOT']
include_paths = [
"#{NINTENDO_SDK_PATH}/Include",
"#{NINTENDO_SDK_PATH}/Common/Configs/Targets/NX-NXFP2-a32/Include"
]
conf.cc do |cc|
cc.command = "#{NINTENDO_SDK_PATH}/Compilers/NX/bin/nx-clang++"
cc.include_paths += include_paths
cc.flags += ['-fpic -fno-short-enums -ffunction-sections -fdata-sections -fno-common -fno-strict-aliasing -fomit-frame-pointer -fno-vectorize -funsigned-char -O2 -g -mno-implicit-float']
cc.defines += 'NN_SDK_BUILD_RELEASE'
end
conf.cxx do |cxx|
cxx.command = "#{NINTENDO_SDK_PATH}/Compilers/NX/bin/nx-clang++"
cxx.include_paths += include_paths
cxx.flags += ['-fpic -fno-short-enums -ffunction-sections -fdata-sections -fno-common -fno-strict-aliasing -fomit-frame-pointer -fno-vectorize -funsigned-char -O2 -g -mno-implicit-float']
cxx.defines += 'NN_SDK_BUILD_RELEASE'
end
conf.archiver do |archiver|
archiver.command = "#{NINTENDO_SDK_PATH}/Compilers/NX/nx/armv7l/bin/llvm-ar"
end
conf.linker do |linker|
linker.command = "#{NINTENDO_SDK_PATH}/Compilers/NX/nx/armv7l/bin/clang++"
linker.libraries = []
end
# Add your mrbgems
end
MRuby::CrossBuild.new('nintendo_switch_64bit') do |conf|
conf.toolchain :clang
NINTENDO_SDK_PATH = ENV['NINTENDO_SDK_ROOT']
include_paths = [
"#{NINTENDO_SDK_PATH}/Include",
"#{NINTENDO_SDK_PATH}/Common/Configs/Targets/NX-NXFP2-a64/Include"
]
conf.cc do |cc|
cc.command = "#{NINTENDO_SDK_PATH}/Compilers/NX/bin/nx-clang++"
cc.include_paths += include_paths
cc.flags += ['-fpic -fno-short-enums -ffunction-sections -fdata-sections -fno-common -fno-strict-aliasing -fomit-frame-pointer -fno-vectorize -funsigned-char -O2 -g -mno-implicit-float']
cc.flags << '--target=aarch64-nintendo-nx-elf'
cc.defines += 'NN_SDK_BUILD_RELEASE'
end
conf.cxx do |cxx|
cxx.command = "#{NINTENDO_SDK_PATH}/Compilers/NX/bin/nx-clang++"
cxx.include_paths += include_paths
cxx.flags += ['-fpic -fno-short-enums -ffunction-sections -fdata-sections -fno-common -fno-strict-aliasing -fomit-frame-pointer -fno-vectorize -funsigned-char -O2 -g -mno-implicit-float']
cxx.flags << '--target=aarch64-nintendo-nx-elf'
cxx.defines += 'NN_SDK_BUILD_RELEASE'
end
conf.archiver do |archiver|
archiver.command = "#{NINTENDO_SDK_PATH}/Compilers/NX/nx/aarch64/bin/llvm-ar"
end
conf.linker do |linker|
linker.command = "#{NINTENDO_SDK_PATH}/Compilers/NX/nx/aarch64/bin/clang++"
linker.libraries = []
end
# Add your mrbgems
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
+26
View File
@@ -0,0 +1,26 @@
# Cross compiling configuration for SerenityOS
# Graphical Unix-like operating system for x86 computers.
# https://github.com/SerenityOS/serenity
#
# Should be built using the SerenityOS Ports system
# https://github.com/SerenityOS/serenity/tree/master/Ports
#
# As of 2021/08/20, SERENITY_ARCH is defined in the SerenityOS Ports
# build script to always be either "i686" or "x86_64"
MRuby::CrossBuild.new('serenity') do |conf|
conf.toolchain :gcc
conf.archiver.command = "#{ENV['SERENITY_ARCH']}-pc-serenity-ar"
conf.linker.command = "#{ENV['SERENITY_ARCH']}-pc-serenity-g++"
conf.cxx.command = "#{ENV['SERENITY_ARCH']}-pc-serenity-g++"
conf.cxx.defines << (ENV['SERENITY_ARCH'].include?('64') ? 'MRB_64BIT' : 'MRB_32BIT')
conf.cc.command = "#{ENV['SERENITY_ARCH']}-pc-serenity-gcc"
conf.cc.defines << (ENV['SERENITY_ARCH'].include?('64') ? 'MRB_64BIT' : 'MRB_32BIT')
conf.gembox 'full-core'
conf.test_runner.command = 'env'
end
+359 -180
View File
@@ -1,3 +1,5 @@
<!-- summary: About the Compile -->
# Compile
mruby uses Rake to compile and cross-compile all libraries and
@@ -6,45 +8,54 @@ binaries.
## Prerequisites
To compile mruby out of the source code you need the following tools:
* C Compiler (e.g. `gcc` or `clang`)
* Linker (e.g. `gcc` or `clang`)
* Archive utility (e.g. `ar`)
* Parser generator (e.g. `bison`)
* Ruby 2.0 or later (e.g. `ruby` or `jruby`)
Note that `bison` bundled with MacOS is too old to compile `mruby`.
Try `brew install bison` and follow the instuction shown to update
the `$PATH` to compile `mruby`.
- C Compiler (e.g. `gcc` or `clang`)
- Linker (e.g. `gcc` or `clang`)
- Archive utility (e.g. `ar`)
- Ruby 2.5 or later (e.g. `ruby` or `jruby`)
Optional:
* GIT (to update mruby source and integrate mrbgems easier)
* C++ compiler (to use GEMs which include \*.cpp, \*.cxx, \*.cc)
* Assembler (to use GEMs which include \*.asm)
## Usage
- Git (to update mruby source and integrate mrbgems easier)
- C++ compiler (to use mrbgems which include `*.cpp`, `*.cxx`, `*.cc`)
- Bison (to compile `mrbgems/mruby-compiler/core/parse.y`)
- gperf (to compile `mrbgems/mruby-compiler/core/keywords`)
Note that `bison` bundled with macOS is too old to compile `mruby`.
Try `brew install bison` and follow the instruction shown to update
the `$PATH` to compile `mruby`. We also encourage you to upgrade `ruby`
on macOS in similar manner.
## Build
To compile `mruby` with the default build configuration, just invoke `rake`
inside of the mruby source root. To generate and execute the test tools call
`rake test`. To clean all build files call `rake clean`. To see full command
line on build, call `rake -v`.
You can specify your own configuration file by the `MRUBY_CONFIG` environment
variable (you can use `CONFIG` for shorthand for `MRUBY_CONFIG`). If the path
doesn't exist, `build_config/${MRUBY_CONFIG}.rb` is used. The default
configuration is defined in the `build_config/default.rb` file.
Those build configuration files contain the build configuration of mruby, for
example:
Inside of the root directory of the mruby source a file exists
called *build_config.rb*. This file contains the build configuration
of mruby and looks like this for example:
```ruby
MRuby::Build.new do |conf|
toolchain :gcc
conf.toolchain :gcc
end
```
All tools necessary to compile mruby can be set or modified here. In case
you want to maintain an additional *build_config.rb* you can define a
customized path using the *$MRUBY_CONFIG* environment variable.
To compile just call `rake` inside of the mruby source root. To
generate and execute the test tools call `rake test`. To clean
all build files call `rake clean`. To see full command line on
build, call `rake -v`.
All tools necessary to compile mruby can be set or modified here.
## Build Configuration
Inside of the *build_config.rb* the following options can be configured
based on your environment.
We wish you submit a pull-request to `build_config/PLATFORM.rb`, once you
created a new configuration for a new platform.
Inside the configuration file, the following options can be
configured based on your environment.
### Toolchains
@@ -54,32 +65,36 @@ configure the build environment for specific compiler infrastructures.
#### GCC
Toolchain configuration for the GNU C Compiler.
```ruby
toolchain :gcc
conf.toolchain :gcc
```
#### clang
Toolchain configuration for the LLVM C Compiler clang. Mainly equal to the
GCC toolchain.
```ruby
toolchain :clang
conf.toolchain :clang
```
#### Visual Studio 2010, 2012 and 2013
Toolchain configuration for Visual Studio on Windows. If you use the
[Visual Studio Command Prompt](http://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
toolchain :visualcpp
conf.toolchain :visualcpp
```
#### Android
Toolchain configuration for Android.
```ruby
toolchain :android
conf.toolchain :android
```
Requires the custom standalone Android NDK and the toolchain path
@@ -88,27 +103,56 @@ in `ANDROID_STANDALONE_TOOLCHAIN`.
### Binaries
It is possible to select which tools should be compiled during the compilation
process. The following tools can be selected:
* mruby (mruby interpreter)
* mirb (mruby interactive shell)
process. For example,
To select them declare conf.gem as follows:
```ruby
conf.gem "#{root}/mrbgems/mruby-bin-mruby"
conf.gem "#{root}/mrbgems/mruby-bin-mirb"
```
- `mruby`
- `mirb`
The configuration are done via `mrbgems`. See `Mrbgems` section.
### File Separator
Some environments require a different file separator character. It is possible to
set the character via `conf.file_separator`.
```ruby
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.
```ruby
conf.cc do |cc|
cc.command = ...
@@ -123,19 +167,21 @@ end
C Compiler has header searcher to detect installed library.
If you need a include path of header file use `search_header_path`:
If you need an include path of header file use `search_header_path`:
```ruby
# Searches ```iconv.h```.
# Searches `iconv.h`.
# If found it will return include path of the header file.
# Otherwise it will return nil .
# Otherwise it will return nil.
fail 'iconv.h not found' unless conf.cc.search_header_path 'iconv.h'
```
If you need a full file name of header file use `search_header`:
If you need a full filename of header file use `search_header`:
```ruby
# Searches ```iconv.h```.
# Searches `iconv.h`.
# If found it will return full path of the header file.
# Otherwise it will return nil .
# Otherwise it will return nil.
iconv_h = conf.cc.search_header 'iconv.h'
print "iconv.h found: #{iconv_h}\n"
```
@@ -145,6 +191,7 @@ When you are using GCC toolchain (including clang toolchain since its base is gc
it will use compiler specific include paths too. (For example `/usr/local/include`, `/usr/include`)
If you need a special header search paths define a singleton method `header_search_paths` to C compiler:
```ruby
def conf.cc.header_search_paths
['/opt/local/include'] + include_paths
@@ -154,6 +201,7 @@ end
### Linker
Configuration of the Linker binary, flags and library paths.
```ruby
conf.linker do |linker|
linker.command = ...
@@ -161,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 = ...
@@ -171,6 +219,7 @@ end
### Archiver
Configuration of the Archiver binary and flags.
```ruby
conf.archiver do |archiver|
archiver.command = ...
@@ -181,6 +230,7 @@ end
### Parser Generator
Configuration of the Parser Generator binary and flags.
```ruby
conf.yacc do |yacc|
yacc.command = ...
@@ -191,6 +241,7 @@ end
### GPerf
Configuration of the GPerf binary and flags.
```ruby
conf.gperf do |gperf|
gperf.command = ...
@@ -199,6 +250,7 @@ end
```
### File Extensions
```ruby
conf.exts do |exts|
exts.object = ...
@@ -207,26 +259,52 @@ conf.exts do |exts|
end
```
### Preallocated Symbols
By far, preallocated symbols are highly compatible with the previous versions, so
we expect you won't see any problem with them. But just in case you face any
issue, you can disable preallocated symbols by specifying `conf.disable_presym`.
In the build process, `mrbc` under cross compiling environment will be compiled
with this configuration.
### Mrbgems
Integrate GEMs in the build process.
```ruby
# Integrate GEM with additional configuration
conf.gem 'path/to/gem' do |g|
g.cc.flags << ...
end
`mruby` comes with the (sort of) packaging system named `mrbgems`. To
specify `gem`, you can use `conf.gem` in the configuration file.
# Integrate GEM without additional configuration
conf.gem 'path/to/another/gem'
```ruby
# Integrate a bundled Gem you see in `mrbgems` directory
conf.gem :core => 'mruby-something'
# Integrate a Gem from GitHub
conf.gem :github => 'someone/mruby-another'
# Integrate a mruby binary Gem
conf.gem :core => 'mruby-bin-mruby'
# Integrate a interactive mruby binary Gem
conf.gem :core => 'mruby-bin-mirb'
# Integrate GemBox (set of Gems)
conf.gembox "default"
```
See doc/mrbgems/README.md for more option about mrbgems.
A GemBox is a set of Gems defined in `mrbgems/default.gembox` for example.
It's just a set of `mrbgem` configurations.
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/guides/mrbgems.md](mrbgems.md) for more option about mrbgems.
### Mrbtest
Configuration Mrbtest build process.
If you want mrbtest.a only, You should set `conf.build_mrbtest_lib_only`
If you want `mrbtest.a` only, You should set `conf.build_mrbtest_lib_only`
```ruby
conf.build_mrbtest_lib_only
```
@@ -234,11 +312,12 @@ conf.build_mrbtest_lib_only
### Bintest
Tests for mrbgem tools using CRuby.
To have bintests place \*.rb scripts to `bintest/` directory of mrbgems.
To have bintests place `*.rb` scripts to `bintest/` directory of mrbgems.
See `mruby-bin-*/bintest/*.rb` if you need examples.
If you want a temporary files use `tempfile` module of CRuby instead of `/tmp/`.
You can enable it with following:
```ruby
conf.enable_bintest
```
@@ -257,58 +336,65 @@ files are compiled by C++ compiler.
When you mix C++ code, C++ exception would be enabled automatically.
If you need to enable C++ exception explicitly add the following:
```ruby
conf.enable_cxx_exception
```
#### C++ exception disabling.
#### C++ exception disabling
If your compiler does not support C++ and you want to ensure
If your compiler does not support C++, and you want to ensure
you don't use mrbgem written in C++, you can explicitly disable
C++ exception, add following:
```ruby
conf.disable_cxx_exception
```
and you will get an error when you try to use C++ gem.
Note that it must be called before `enable_cxx_exception` or `gem` method.
### Debugging mode
To enable debugging mode add the following:
```ruby
conf.enable_debug
```
When debugging mode is enabled
* Macro `MRB_DEBUG` would be defined.
* Which means `mrb_assert()` macro is enabled.
* Debug information of irep would be generated by `mrbc`.
* Because `-g` flag would be added to `mrbc` runner.
* You can have better backtrace of mruby scripts with this.
- Macro `MRB_DEBUG` would be defined.
- Which means `mrb_assert()` macro is enabled.
- Debug information of irep would be generated by `mrbc`.
- Because `-g` flag would be added to `mrbc` runner.
- You can have better backtrace of mruby scripts with this.
## Cross-Compilation
mruby can also be cross-compiled from one platform to another. To
achieve this the *build_config.rb* needs to contain an instance of
`MRuby::CrossBuild`. This instance defines the compilation
tools and flags for the target platform. An example could look
like this:
mruby can also be cross-compiled from one platform to another. To achieve
cross-compilation, the build configuration needs to contain an instance of
`MRuby::CrossBuild`. This instance defines the compilation tools and flags
for the target platform. An example could look like this:
```ruby
MRuby::CrossBuild.new('32bit') do |conf|
toolchain :gcc
conf.toolchain :gcc
conf.cc.flags << "-m32"
conf.linker.flags << "-m32"
end
```
All configuration options of `MRuby::Build` can also be used
in `MRuby::CrossBuild`.
All configuration options of `MRuby::Build` can also be used in
`MRuby::CrossBuild`. You can find examples under the `build_config`
directory.
### Mrbtest in Cross-Compilation
In cross compilation, you can run `mrbtest` on emulator if
In cross compilation, you can run `mrbtest` on an emulator if
you have it by changing configuration of test runner.
```ruby
conf.test_runner do |t|
t.command = ... # set emulator. this value must be non nil or false
@@ -322,48 +408,44 @@ 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:
+- build
|
+- host
|
+- bin <- Binaries (mirb, mrbc and mruby)
|
+- lib <- Libraries (libmruby.a and libmruby_core.a)
|
+- mrblib
|
+- src
|
+- test <- mrbtest tool
|
+- tools
|
+- mirb
|
+- mrbc
|
+- mruby
```
+- build
|
+- host
|
+- LEGAL <- License description
|
+- bin <- Binaries (mirb, mrbc and mruby)
|
+- lib <- Libraries (libmruby.a and libmruby_core.a)
|
+- mrbc <- Minimal mrbc place
|
+- mrbgems <- Compilation result from mrbgems
|
+- mrblib <- Compilation result from mrblib
|
+- src <- Compilation result from C sources
```
The compilation workflow will look like this:
* compile all files under *src* (object files will be stored
in *build/host/src*)
* generate parser grammar out of *src/parse.y* (generated
result will be stored in *build/host/src/y.tab.c*)
* compile *build/host/src/y.tab.c* to *build/host/src/y.tab.o*
* create *build/host/lib/libmruby_core.a* out of all object files (C only)
* create `build/host/bin/mrbc` by compiling *tools/mrbc/mrbc.c* and
linking with *build/host/lib/libmruby_core.a*
* create *build/host/mrblib/mrblib.c* by compiling all \*.rb files
under *mrblib* with `build/host/bin/mrbc`
* compile *build/host/mrblib/mrblib.c* to *build/host/mrblib/mrblib.o*
* create *build/host/lib/libmruby.a* out of all object files (C and Ruby)
* create `build/host/bin/mruby` by compiling *mrbgems/mruby-bin-mruby/tools/mruby/mruby.c* and
linking with *build/host/lib/libmruby.a*
* create `build/host/bin/mirb` by compiling *mrbgems/mruby-bin-mirb/tools/mirb/mirb.c* and
linking with *build/host/lib/libmruby.a*
- compile minimal `mrbc` from `src` and `mrblib` sources
- compile all files under `src` (object files will be stored in `build/host/mrbc/src`)
- compile `mruby-compiler` gem
- create `build/host/mrbc/lib/libmruby_core.a` out of all object files (C only)
- create `build/host/mrbc/bin/mrbc` via `mruby-bin-mrbc` gem
- compile all files under `src` and store result in `build/host/src`
- create `build/host/mrblib/mrblib.c` by compiling all `*.rb` files under `mrblib` with `build/host/mrbc/bin/mrbc`
- compile `build/host/mrblib/mrblib.c` to `build/host/mrblib/mrblib.o`
- create `build/host/lib/libmruby.a` out of all object files (C and Ruby)
- compile (normal) mrbgems specified in the configuration file
- create `build/host/lib/libmruby.a` from object files from gems and `libmruby_core.a`
- create binary commands according to binary gems (e.g. `mirb` and `mruby`)
- copy binaries under `build/host/bin` to `bin` directory
```
_____ _____ ______ ____ ____ _____ _____ ____
@@ -374,73 +456,54 @@ linking with *build/host/lib/libmruby.a*
### Cross-Compilation
In case of a cross-compilation to *i386* the *build* directory structure looks
In case of a cross-compilation to `i386` the `build` directory structure looks
like this:
+- build
|
+- host
| |
| +- bin <- Native Binaries
| |
| +- lib <- Native Libraries
| |
| +- mrblib
| |
| +- src
| |
| +- test <- Native mrbtest tool
| |
| +- tools
| |
| +- mirb
| |
| +- mrbc
| |
| +- mruby
+- i386
|
+- bin <- Cross-compiled Binaries
|
+- lib <- Cross-compiled Libraries
|
+- mrblib
|
+- src
|
+- test <- Cross-compiled mrbtest tool
|
+- tools
|
+- mirb
|
+- mrbc
|
+- mruby
```
+- build
|
+- host
| |
| +- bin <- Native Binaries
| |
| +- lib <- Native Libraries
| |
| +- mrbgems
| |
| +- src
|
+- i386
|
+- bin <- Cross-compiled Binaries
|
+- include <- Header Directory
|
+- lib <- Cross-compiled Libraries
|
+- mrbgems
|
+- mrblib
|
+- src
```
An extra directory is created for the target platform. In case you
compile for *i386* a directory called *i386* is created under the
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.
Afterwards the cross compilation process proceeds like this:
* cross-compile all files under *src* (object files will be stored
in *build/i386/src*)
* generate parser grammar out of *src/parse.y* (generated
result will be stored in *build/i386/src/y.tab.c*)
* cross-compile *build/i386/src/y.tab.c* to *build/i386/src/y.tab.o*
* create *build/i386/mrblib/mrblib.c* by compiling all \*.rb files
under *mrblib* with the native `build/host/bin/mrbc`
* cross-compile *build/host/mrblib/mrblib.c* to *build/host/mrblib/mrblib.o*
* create *build/i386/lib/libmruby.a* out of all object files (C and Ruby)
* create `build/i386/bin/mruby` by cross-compiling *mrbgems/mruby-bin-mruby/tools/mruby/mruby.c* and
linking with *build/i386/lib/libmruby.a*
* create `build/i386/bin/mirb` by cross-compiling *mrbgems/mruby-bin-mirb/tools/mirb/mirb.c* and
linking with *build/i386/lib/libmruby.a*
* create *build/i386/lib/libmruby_core.a* out of all object files (C only)
* create `build/i386/bin/mrbc` by cross-compiling *tools/mrbc/mrbc.c* and
linking with *build/i386/lib/libmruby_core.a*
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:
- cross-compile all files under `src` and store result in `build/i386/src`
- create `build/i386/lib/libmruby_core.a` out of C object files
- create `build/i386/mrblib/mrblib.c` by compiling all `*.rb` files under `mrblib` with native `build/host/bin/mrbc`
- cross-compile `build/i386/mrblib/mrblib.c` to `build/i386/mrblib/mrblib.o`
- create `build/i386/lib/libmruby.a` from object files from gems and `libmruby_core.a`
- create binary commands according to binary gems (e.g. `mirb` and `mruby`)
- copy binaries under `build/host/bin` to `bin` directory
```
_______________________________________________________________
@@ -471,22 +534,138 @@ feature due to the reason that there are functions (e.g. stdio) which
can't be disabled for the main build.
```ruby
MRuby::CrossBuild.new('Minimal') do |conf|
toolchain :gcc
conf.cc.defines = %w(MRB_DISABLE_STDIO)
conf.bins = []
MRuby::CrossBuild.new('minimal') do |conf|
conf.toolchain :gcc
conf.cc.defines << 'MRB_NO_STDIO'
end
```
This configuration defines a cross compile build called 'Minimal' which
This configuration defines a cross compile build called 'minimal' which
is using the GCC and compiles for the host machine. It also disables
all usages of stdio and doesn't compile any binaries (e.g. mrbc).
all usages of stdio and doesn't compile any binaries (e.g. `mrbc`).
## Test Environment
mruby's build process includes a test environment. In case you start the testing
of mruby, a native binary called `mrbtest` will be generated and executed.
This binary contains all test cases which are defined under *test/t*. In case
of a cross-compilation an additional cross-compiled *mrbtest* binary is
This binary contains all test cases which are defined under `test/t`. In case
of a cross-compilation an additional cross-compiled `mrbtest` binary is
generated. You can copy this binary and run on your target system.
## Embedding `mruby` in Your Application
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:
--cc print compiler name
--cflags print flags passed to compiler
--ld print linker name
--ldflags print flags passed to linker
--ldflags-before-libs print flags passed to linker before linked libraries
--libs print linked libraries
--libmruby-path print libmruby path
--help print this help
```
For example, when you have a C source file (`c.c`) and try to
compile and link it with `libmruby.a`, you can run the following command,
```
`mruby-config --cc --cflags` c.c `mruby-config --ldflags --libs`
```
When you use `make`, add following lines in `Makefile`
```
MRB_CONFIG = <path-to-mruby-config>
CFLAGS = `$(MRB_CONFIG) --cflags`
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.
+34 -31
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 2.1.2 (2020-07-10)
mruby 3.4.0 (2025-04-20)
```
## 2.2 Basic Operation
@@ -50,7 +52,7 @@ To invoke the mruby debugger, just type `mrdb`.
To specify the script file:
```bash
$ mrdb [option] file name
$ mrdb [option] filename
```
For example: Debugging sample.rb
@@ -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
@@ -82,8 +84,8 @@ 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`.
- notice
To debug mruby binary files, you need to compile mruby files with option `-g`.
```bash
$ mrbc -g sample.rb
@@ -114,12 +116,12 @@ b [class:]method
The breakpoint will be ordered in serial from 1.
The number, which was given to the deleted breakpoint, will never be given to another breakpoint again.
You can give multiple breakpoints to specified the line number and method.
Be ware that breakpoint command will not check the validity of the class name and method name.
You can give multiple breakpoints to the specified the line number and method.
Be aware that the breakpoint command will not check the validity of the class name and method name.
You can get the current breakpoint information by the following options.
breakpoint breakpoint number : file name. line number
breakpoint breakpoint number : filename. line number
breakpoint breakpoint number : [class name,] method name
@@ -165,7 +167,7 @@ Example:
(foo.rb:1) delete
```
This will delete all of the breakpoints.
This will delete all the breakpoints.
```
(foo.rb:1) delete 1 3
@@ -192,7 +194,7 @@ Example:
(foo.rb:1) disable
```
Use `disable` if you would like to disable all of the breakpoints.
Use `disable` if you would like to disable all the breakpoints.
```
(foo.rb:1) disable 1 3
@@ -220,6 +222,7 @@ Example:
```
Enabling all breakpoints
```
(foo.rb:1) enable 1 3
```
@@ -263,8 +266,8 @@ Example:
```
(sample.rb:1) info breakpoints
Num Type Enb What
1 breakpoint y at sample.rb:3 -> file name,line number
Num Type Enb What
1 breakpoint y at sample.rb:3 -> filename,line number
2 breakpoint n in Sample_class:sample_class_method -> [class:]method name
3 breakpoint y in sample_global_method
```
@@ -273,8 +276,8 @@ Displaying the specified breakpoint number:
```
(foo.rb:1) info breakpoints 1 3
Num Type Enb What
1 breakpoint y at sample.rb:3
Num Type Enb What
1 breakpoint y at sample.rb:3
3 breakpoint y in sample_global_method
```
@@ -298,11 +301,11 @@ When you do not specify both the `first` and `last` options, you will receive th
Example:
```
Specifying file name and first row number
Specifying filename and first row number
sample.rb:1) list sample2.rb:5
```
Specifying the file name and the first and last row number:
Specifying the filename and the first and last row number:
```
(sample.rb:1) list sample2.rb:6,7
@@ -323,7 +326,7 @@ expr: expression
The expression is mandatory.
The displayed expressions will be serially ordered from 1.
If an exception occurs, the exception information will be displayed and the debugging will be continued.
If an exception occurs, the exception information will be displayed, and the debugging will be continued.
Example:
@@ -366,5 +369,5 @@ r
#### Step Command
This will run the program step by step.
When the method and the block are invoked, the program will be stop at the first row.
When the method and the block are invoked, the program will stop at the first row.
The program, which is developed in C, will be ignored.
+32 -29
View File
@@ -1,25 +1,28 @@
<!-- 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]: http://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
execution speed. This is an error indicating overflow of "GC arena"
execution speed. This is an error indicating overflow of "GC arena"
implementing "conservative GC".
GC (garbage collector) must ensure that object is "alive", in other
words, that it is referenced by somewhere from program. This can be
words, that it is referenced by somewhere from the program. This can be
determined by checking if the object can be directly or indirectly
referenced by root. The local variables, global variables and
constants etc are root.
referenced by root. The local variables, global variables and
constants etc. are root.
If program execution is performed inside mruby VM, there is nothing to
worry about because GC can access all roots owned by VM.
worry about because GC can access all roots owned by the VM.
The problem arises when executing C functions. The object referenced
The problem arises when executing C functions. The object referenced
by C variable is also "alive", but mruby GC cannot aware of this, so
it might mistakenly recognize the objects referenced by only C
variables as dead.
@@ -27,18 +30,18 @@ variables as dead.
This can be a fatal bug if the GC tries to collect a live object.
In CRuby, we scan C stack area, and use C variable as root to check
whether object is alive or not. Of course, because we are accessing C
whether object is alive or not. Of course, because we are accessing C
stack just as memory region, we never know it is an integer or a
pointer. We workaround this by assuming that if it looks like a
pointer, then assume it as a pointer. We call it "conservative".
pointer. We work around this by assuming that if it looks like a
pointer, then assume it as a pointer. We call it "conservative".
By the way, CRuby's "conservative GC" has some problems.
The biggest problem is we have no way to access to the stack area in
portable way. Therefore, we cannot use this method if we'd like to
portable way. Therefore, we cannot use this method if we'd like to
implement highly portable runtime, like mruby.
So we came up with an another plan to implement "conservative GC" in mruby.
So we came up with another plan to implement "conservative GC" in mruby.
Again, the problem is when an object which was created in C function, becomes
no longer referenced in the Ruby world, and cannot be treated as garbage.
@@ -46,7 +49,7 @@ no longer referenced in the Ruby world, and cannot be treated as garbage.
In mruby, we recognize all objects created in C function are alive.
Then we have no problem such as confusing a live object as dead.
This means that because we cannot collect truly dead object, we may
This means that because we cannot collect a truly dead object, we may
lose efficiency, but as a trade-off the GC itself is highly portable.
We can say goodbye to the problem that GC deletes live objects due to
optimization which sometimes occurs in CRuby.
@@ -62,17 +65,17 @@ 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 kick in. This memory usage may look like memory leak, but will also
GC never kicks in. This memory usage may look like memory leaks, but will also
make execution slower as more memory will need to be allocated.
With the build time configuration, you can limit the maximum size of
arena (e.g., 100). Then if you create many objects, arena overflows,
arena (e.g., 100). Then if you create many objects, arena overflows,
thus you will get an "arena overflow error".
To workaround these problems, we have `mrb_gc_arena_save()` and
To work around these problems, we have `mrb_gc_arena_save()` and
`mrb_gc_arena_restore()` functions.
`int mrb_gc_arena_save(mrb)` returns the current position of the stack
@@ -93,7 +96,7 @@ In mruby, C function calls are surrounded by this save/restore, but we
can further optimize memory usage by surrounding save/restore, and can
avoid creating arena overflow bugs.
Let's take a real example. Here is the source code of `Array#inspect`:
Let's take a real example. Here is the source code of `Array#inspect`:
```c
static mrb_value
@@ -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) {
@@ -140,29 +143,29 @@ inspect_ary(mrb_state *mrb, mrb_value ary, mrb_value list)
}
```
This is a real example, so a little bit complicated, but bear with me.
This is a real example, so slightly complicated, but bear with me.
The essence of `Array#inspect` is that after stringifying each element
of array using `inspect` method, we join them together so that we can
get `inspect` representation of the entire array.
After the `inspect` representation is created, we no longer require the
individual string representation. This means that we don't have to register
individual string representation. This means that we don't have to register
these temporal objects into GC arena.
Therefore, in order to keep the arena size small; the `ary_inspect()` function
will do the following:
* save the position of the stack top using `mrb_gc_arena_save()`.
* get `inspect` representation of each element.
* append it to the constructing entire `inspect` representation of array.
* restore stack top position using `mrb_gc_arena_restore()`.
- save the position of the stack top using `mrb_gc_arena_save()`.
- get `inspect` representation of each element.
- append it to the constructing entire `inspect` representation of array.
- restore stack top position using `mrb_gc_arena_restore()`.
Please note that the final `inspect` representation of entire array
was created before the call of `mrb_gc_arena_restore()`. Otherwise,
was created before the call of `mrb_gc_arena_restore()`. Otherwise,
required temporal object may be deleted by GC.
We may have a usecase where after creating many temporal objects, we'd
like to keep some of them. In this case, we cannot use the same idea
We may have an usecase where after creating many temporal objects, we'd
like to keep some of them. In this case, we cannot use the same idea
in `ary_inspect()` like appending objects to existing one.
Instead, after `mrb_gc_arena_restore()`, we must re-register the objects we
want to keep in the arena using `mrb_gc_protect(mrb, obj)`.
+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
```
+85
View File
@@ -0,0 +1,85 @@
<!-- summary: About Linking with `libmruby` -->
# Linking `libmruby` to your application
You have two ways to link `libmruby` to your application.
- using executable gem.
- using normal compilation process
## Executable Gems
If your application is relatively small, `mrbgem` is an easier way to
create the executable. By tradition, the gem name start with
`mruby-bin-`, e.g. `mruby-bin-debugger`.
### `mrbgem.rake` file
The executable name is specified in `mrbgem.rake` file at the top of
your `mrbgem` directory.
```ruby
MRuby::Gem::Specification.new('mruby-bin-example') do |spec|
spec.license = 'MIT'
spec.author = 'mruby developers'
spec.summary = 'Example for executable command gem'
spec.bins = %w(mruby-example) # <- this is binary name
end
```
### Source tree structure
The source file for the gem executable should be in
`<gem-name>/tools/<bin-name>`. Currently, we support C or C++ source code
(`.c`, `.cpp`, `.cxx`, `.cc`) for the executable. Ruby source files are not
supported. Put the functionality in the different gem and specify dependency to
it in `mrbgem.rake`.
## Normal compilation process
The `libmruby` is a normal library so that you can just link it to your
application. Specify proper compiler options (`-I` etc.) and linker options
(`-lmruby` etc.) to compile and link your application. Specify those options in
your build script (e.g. `Makefile`).
### Compiler options
You need to specify compiler options that are compatible to mruby configuration,
for example:
- `-I` to specify the place for mruby header files
- `-D` to specify mruby configuration macros
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
```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
```
### Linker options
Just like compiler options, you need to specify linker options that are
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
```console
$ mruby-config --ldflags
-L/home/matz/work/mruby/build/host/lib
$ mruby-config --ldflags-before-libs
# <nothing in this case>
$ mruby-config --libs
-lmruby -lm
```
+120
View File
@@ -0,0 +1,120 @@
<!-- summary: About Memory Allocator Customization -->
# Memory Allocation
In mruby, you can customize how memory is allocated in two ways:
1. **Provide your own `malloc()`/`realloc()`/`free()`**
2. **Override `mrb_basic_alloc_func()`**
---
## 1. Provide your own `malloc()`/`realloc()`/`free()`
On platforms without a full C standard library —such as many microcontrollers— you may need to supply your own implementations of `malloc()`, `realloc()`, and `free()`. mrubys allocator calls directly into these functions, so replacing them lets you control **every** allocation and deallocation performed by your entire program, including any thirdparty libraries you link against.
Keep in mind:
- Calling `realloc(NULL, size)` must behave like `malloc(size)`.
- Calling `free(NULL)` must be a noop.
Simply define these three functions in your code (or link against a library that provides them), and mruby — along with all other code in your process — will use your versions automatically.
## 2. Override `mrb_basic_alloc_func()`
Inside mruby, all of its own memory allocations go through a single function called mrb_basic_alloc_func() (formerly mrb_default_allocf()). By defining this function in your application before linking, you can intercept and handle **only** the memory operations initiated by mruby itself without affecting other libraries or parts of your program.
```c
// Example signature:
// void* mrb_basic_alloc_func(void* ptr, size_t size);
```
Implement mrb_basic_alloc_func() in your code, and mruby will invoke it for every internal allocation, reallocation, and free request.
### Expected behavior
- `mrb_basic_alloc_func(NULL, size)` should allocate `size` bytes, just like `malloc(size)`.
- `mrb_basic_alloc_func(ptr, size)` should resize the existing block at `ptr` to `size` bytes, just like `realloc(ptr, size)`.
- `mrb_basic_alloc_func(ptr, 0)` should free the block at `ptr`, just like `free(ptr)`.
---
## Summary of effects:
- **Custom `malloc`/`realloc`/`free`**: replaces allocation behavior globally (mruby + all other code and thirdparty libraries).
- **Custom `mrb_basic_alloc_func()`**: replaces allocation behavior only for mrubys internal use, leaving other libraries allocations untouched.
## Migration note
If you are moving from the old API:
1. **Removal of `mrb_open_allocf()`**
- \_Old:
```c
mrb_state *mrb = mrb_open_allocf(my_allocf, ud);
```
- \_New:
```c
// No allocf parameter; set up your hook via mrb_basic_alloc_func definition.
mrb_state *mrb = mrb_open_core();
```
2. **`mrb_open_core()` takes no arguments**
- Simply drop any allocf or user-data arguments, and redefine `mrb_basic_alloc_func` as you need.
3. **No more `mrb_allocf` type**
- Definitions using the `mrb_allocf` typedef can be removed; implement `mrb_basic_alloc_func()` with the signature below:
```c
void* mrb_basic_alloc_func(void *ptr, size_t size);
```
4. **`mrb_basic_alloc_func` signature change**
- _Old:_
```c
void* mrb_default_allocf(mrb_state *mrb, void *ptr, size_t size, void *ud);
```
- _New:_
```c
void* mrb_basic_alloc_func(void *ptr, size_t size);
```
---
### Code examples
- **Old style**:
```c
static void*
my_allocf(mrb_state *mrb, void *ud, void *ptr, size_t size)
{
// ...custom logic...
}
mrb_state *mrb = mrb_open_allocf(my_allocf, some_ud);
```
- **New style**:
```c
// Define your hook before creating the state:
void*
mrb_basic_alloc_func(void *ptr, size_t size)
{
// ...custom logic...
}
mrb_state *mrb = mrb_open_core();
```
+183 -116
View File
@@ -1,181 +1,248 @@
# mruby configuration macros.
<!-- summary: About Build-time Configurations -->
## How to use these macros.
You can use mrbconfs with following ways:
* Write them in `mrbconf.h`.
* Using compiler flags is preferred when building a cross binaries or multiple mruby binaries
since it's easier to use different mrbconf per each `MRuby::Build`.
* Most flags can be enabled by just commenting in.
* Pass them as compiler flags.
* Make sure you pass the same flags to all compilers since some mrbconf(e.g., `MRB_GC_FIXED_ARENA`)
changes `struct` layout and cause memory access error when C and other language(e.g., C++) is mixed.
# mruby configuration macros
## stdio setting.
`MRB_DISABLE_STDIO`
* When defined `<stdio.h>` functions won't be used.
* Some features will be disabled when this is enabled:
* `mrb_irep` load/dump from/to file.
* Compiling mruby script from file.
* Printing features in **src/print.c**.
## The configuration file
## Debug macros.
`MRB_ENABLE_DEBUG_HOOK`
* When defined code fetch hook and debug OP hook will be enabled.
* When using any of the hook set function pointer `code_fetch_hook` and/or `debug_op_hook` of `mrb_state`.
* Fetch hook will be called before any OP.
* Debug OP hook will be called when dispatching `OP_DEBUG`.
You can do the build configuration in the build configuration file. The default
configuration file is `build_config/default.rb`.
You can specify your own configuration file by the `MRUBY_CONFIG` environment
variable (you can use `CONFIG` for shorthand for `MRUBY_CONFIG`). If the path
doesn't exist, `build_config/${MRUBY_CONFIG}.rb` is used.
## How to use these macros
Just add the configuration value to the `MRuby::Build#defines` attribute.
This is the same for `MRuby::CrossBuild`.
```ruby
# build_config.rb
MRuby::Build.new do |conf|
...
conf.defines << 'MRB_GC_FIXED_ARENA'
conf.defines << 'MRB_NO_METHOD_CACHE'
...
end
```
**_NOTE_**
- Use common definitions (`conf.defines`) instead of per-compiler definitions (e.g., `conf.cc.defines`) unless there is a special reason not to.
- It is now deprecated to edit the `include/mruby/mrbconf.h` file or give it directly as a compiler flag, as was the case before.
## stdio setting
`MRB_NO_STDIO`
- When defined `<stdio.h>` functions won't be used.
- Some features will be disabled when this is enabled:
- `mrb_irep` load/dump from/to file.
- Compiling mruby script from a file.
- Printing features in **src/print.c**.
## Debug macros
`MRB_USE_DEBUG_HOOK`
- When defined code fetch hook and debug OP hook will be enabled.
- When using any of the hook set function pointer `code_fetch_hook` and/or `debug_op_hook` of `mrb_state`.
- Fetch hook will be called before any OP.
- Debug OP hook will be called when dispatching `OP_DEBUG`.
`MRB_DEBUG`
* When defined `mrb_assert*` macro will be defined with macros from `<assert.h>`.
* Could be enabled via `enable_debug` method of `MRuby::Build`.
- When defined `mrb_assert*` macro will be defined with macros from `<assert.h>`.
- Could be enabled via `enable_debug` method of `MRuby::Build`.
## Stack configuration
`MRB_STACK_EXTEND_DOUBLING`
* If defined doubles the stack size when extending it.
* Else extends stack with `MRB_STACK_GROWTH`.
- If defined doubles the stack size when extending it.
- Otherwise extends stack with `MRB_STACK_GROWTH`.
`MRB_STACK_GROWTH`
* Default value is `128`.
* Used in stack extending.
* Ignored when `MRB_STACK_EXTEND_DOUBLING` is defined.
- Default value is `128`.
- Used in stack extending.
- Ignored when `MRB_STACK_EXTEND_DOUBLING` is defined.
`MRB_STACK_MAX`
* Default value is `0x40000 - MRB_STACK_GROWTH`.
* Raises `RuntimeError` when stack size exceeds this value.
## Primitive type configuration.
- Default value is `0x40000 - MRB_STACK_GROWTH`.
- Raises `RuntimeError` when stack size exceeds this value.
`MRB_USE_FLOAT`
* When defined single precision floating point type(C type `float`) is used as `mrb_float`.
* Else double precision floating point type(C type `double`) is used as `mrb_float`.
## Primitive type configuration
`MRB_WITHOUT_FLOAT`
* When defined removes floating point numbers from mruby.
* It makes mruby easier to handle in "Microcontroller without FPU" and "Kernel Space".
`MRB_USE_FLOAT32`
- When defined single-precision floating-point type(C type `float`) is used as `mrb_float`.
- Otherwise, double-precision floating-point type(C type `double`) is used as `mrb_float`.
`MRB_NO_FLOAT`
- When defined removes floating-point numbers from mruby.
- It makes mruby easier to handle in "Micro-controller without FPU" and "Kernel Space".
`MRB_INT32`
* When defined, or `MRB_INT64` are not defined on 32-bit CPU mode, `mrb_int` will be defined as `int32_t`.
* Conflicts with `MRB_INT64`.
- When defined, or `MRB_INT64` are not defined on 32-bit CPU mode, `mrb_int` will be defined as `int32_t`.
- Conflicts with `MRB_INT64`.
`MRB_INT64`
* When defined, or `MRB_INT32` are not defined on 64-bit CPU mode, `mrb_int` will be defined as `int64_t`.
* Conflicts with `MRB_INT32`.
## Garbage collector configuration.
- When defined, or `MRB_INT32` are not defined on 64-bit CPU mode, `mrb_int` will be defined as `int64_t`.
- Conflicts with `MRB_INT32`.
## Garbage collector configuration
`MRB_GC_STRESS`
* When defined full GC is emitted per each `RBasic` allocation.
* Mainly used in memory manager debugging.
- When defined full GC is emitted per each `RBasic` allocation.
- Mainly used in memory manager debugging.
- If defined at the same time as `MRB_DEBUG`, full GC is emitted also per each heap allocation (`mrb_malloc()` or etc.).
This configuration slows down mruby execution by a factor of 2 to 3 or even more.
`MRB_GC_TURN_OFF_GENERATIONAL`
* When defined turns generational GC by default.
- When defined turns generational GC off by default.
`MRB_GC_FIXED_ARENA`
* When defined used fixed size GC arena.
* Raises `RuntimeError` when this is defined and GC arena size exceeds `MRB_GC_ARENA_SIZE`.
* Useful tracking unnecessary mruby object allocation.
- When defined used fixed size GC arena.
- Raises `RuntimeError` when this is defined and GC arena size exceeds `MRB_GC_ARENA_SIZE`.
- Useful tracking unnecessary mruby object allocation.
`MRB_GC_ARENA_SIZE`
* Default value is `100`.
* Ignored when `MRB_GC_FIXED_ARENA` isn't defined.
* Defines fixed GC arena size.
- Default value is `100`.
- Ignored when `MRB_GC_FIXED_ARENA` isn't defined.
- Defines fixed GC arena size.
`MRB_HEAP_PAGE_SIZE`
* Defines value is `1024`.
* Specifies number of `RBasic` per each heap page.
## Memory pool configuration.
- 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`".
In mruby 3.1.0, the "size of management data per heap page" is 6 words, also "size per object" is 6 words.
For a 32-bit CPU, `(6 * 4) + (6 * 4) * MRB_HEAP_PAGE_SIZE` gives the bytes of size per heap page.
Conversely, for example, to keep the size per heap page to 4 Ki bytes,
calculate `(4096 - (6 * 4)) / (6 * 4)` to specify `MRB_HEAP_PAGE_SIZE=169`.
## Memory pool configuration
`POOL_ALIGNMENT`
* Default value is `4`.
* If you're allocating data types that requires alignment more than default value define the
largest value of required alignment.
- Default value is `4`.
- If you're allocating data types that requires alignment more than default value define the
largest value of required alignment.
`POOL_PAGE_SIZE`
* Default value is `16000`.
* Specifies page size of pool page.
* Smaller the value is increases memory overhead.
## State atexit configuration.
- Default value is `16000`.
- Specifies page size of pool page.
- Smaller the value is increases memory overhead.
## State atexit configuration
`MRB_FIXED_STATE_ATEXIT_STACK`
* If defined enables fixed size `mrb_state` atexit stack.
* Raises `RuntimeError` when `mrb_state_atexit` call count to same `mrb_state` exceeds
`MRB_FIXED_STATE_ATEXIT_STACK_SIZE`'s value.
- If defined enables fixed size `mrb_state` atexit stack.
- Raises `RuntimeError` when `mrb_state_atexit` call count to same `mrb_state` exceeds
`MRB_FIXED_STATE_ATEXIT_STACK_SIZE`'s value.
`MRB_FIXED_STATE_ATEXIT_STACK_SIZE`
* Default value is `5`.
* If `MRB_FIXED_STATE_ATEXIT_STACK` isn't defined this macro is ignored.
## `mrb_value` configuration.
- Default value is `5`.
- If `MRB_FIXED_STATE_ATEXIT_STACK` isn't defined this macro is ignored.
## `mrb_value` configuration
`MRB_ENDIAN_BIG`
* If defined compiles mruby for big endian machines.
* Used in `MRB_NAN_BOXING`.
* Some mrbgem use this mrbconf.
- If defined compiles mruby for big endian machines.
- Used in `MRB_NAN_BOXING`.
- Some mrbgem use this mrbconf.
`MRB_NAN_BOXING`
* If defined represent `mrb_value` in boxed `double`.
* Conflicts with `MRB_USE_FLOAT` and `MRB_WITHOUT_FLOAT`.
- If defined represent `mrb_value` in boxed `double`.
- Conflicts with `MRB_USE_FLOAT32` and `MRB_NO_FLOAT`.
`MRB_WORD_BOXING`
* If defined represent `mrb_value` as a word.
* If defined `Float` will be a mruby object with `RBasic`.
## Instance variable configuration.
`MRB_IV_SEGMENT_SIZE`
* Default value is `4`.
* Specifies size of each segment in segment list.
- If defined represent `mrb_value` as a word.
- If defined `Float` will be a mruby object with `RBasic`.
## Reduce heap memory configuration.
## Reduce heap memory configuration
`MRB_USE_LINK_TIME_RO_DATA_P`
* Only available on ELF platforms.
* If you specify the address of a read-only section when creating a symbol or string, that string will be used as it is.
* Heap memory can be saved.
* Uses `__ehdr_start` and `__init_array_start`.
* It must be `__ehdr_start < data_addr < __init_array_start`.
`MRB_USE_ETEXT_RO_DATA_P`
- Use `etext` and `edata` section addresses defined by the linker to detect read-only data.
- Those addresses are widely available, but not portable, nor standardized.
- This macro is defined by default on User-mode Linux.
`MRB_NO_DEFAULT_RO_DATA_P`
- Define this macro when the default `mrb_ro_data_p()` does not work for any reason.
`MRB_USE_CUSTOM_RO_DATA_P`
* Takes precedence over `MRB_USE_LINK_TIME_RO_DATA_P`.
* Please try if `MRB_USE_LINK_TIME_RO_DATA_P` is not available.
* The `mrb_ro_data_p()` function is implemented by the user in an arbitrary file.
* The prototype declaration is `mrb_bool mrb_ro_data_p(const char *ptr)`.
* Return `TRUE` if `ptr` is in read-only section, otherwise return `FALSE`.
## Other configuration.
- Please try if `MRB_USE_LINK_TIME_RO_DATA_P` is not available.
- The `mrb_ro_data_p()` function is implemented by the user in an arbitrary file.
- The prototype declaration is `mrb_bool mrb_ro_data_p(const char *ptr)`.
- Return `TRUE` if `ptr` is in the read-only section, otherwise return `FALSE`.
## Other configuration
`MRB_MALLOC_TRIM`
- call `malloc_trim(0)` for each `mrb_full_gc()` call
`MRB_UTF8_STRING`
* Adds UTF-8 encoding support to character-oriented String instance methods.
* If it isn't defined, they only support the US-ASCII encoding.
- Adds UTF-8 encoding support to character-oriented String instance methods.
- If it isn't defined, they only support the US-ASCII encoding.
`MRB_STR_LENGTH_MAX`
- The maximum length of strings (default 1MB)
- set this value to zero to skip the check
`MRB_ARY_LENGTH_MAX`
- The maximum length of arrays (default 1MB)
- set this value to zero to skip the check
`MRB_FUNCALL_ARGC_MAX`
* Default value is `16`.
* Specifies 4th argument(`argc`) max value of `mrb_funcall`.
* Raises `ArgumentError` when the `argc` argument is bigger then this value `mrb_funcall`.
- Default value is `16`.
- Specifies 4th argument(`argc`) max value of `mrb_funcall`.
- Raises `ArgumentError` when the `argc` argument is bigger then this value `mrb_funcall`.
`KHASH_DEFAULT_SIZE`
* Default value is `32`.
* Specifies default size of khash table bucket.
* Used in `kh_init_ ## name` function.
`MRB_STR_BUF_MIN_SIZE`
* Default value is `128`.
* Specifies initial capacity of `RString` created by `mrb_str_buf_new` function..
- Default value is `32`.
- Specifies default size of khash table bucket.
- Used in `kh_init_ ## name` function.
`MRB_METHOD_CACHE`
* Improve performance for method dispatch.
`MRB_NO_METHOD_CACHE`
- Disable method cache to save memory.
`MRB_METHOD_CACHE_SIZE`
* Default value is `128`.
* Ignored if `MRB_METHOD_CACHE` is not defined.
* Need to be the power of 2.
`MRB_METHOD_T_STRUCT`
* Use C struct to represent `mrb_method_t`
* No `MRB_METHOD_T_STRUCT` requires highest 2 bits of function pointers to be zero
* Define this macro on machines that use higher bits of pointers
- Default value is `256`.
- Ignored if `MRB_NO_METHOD_CACHE` is defined.
- Need to be the power of 2.
`MRB_ENABLE_ALL_SYMBOLS`
* Make it available `Symbols.all_symbols` in `mrbgems/mruby-symbol-ext`
* Increase heap memory usage.
`MRB_USE_ALL_SYMBOLS`
- Make it available `Symbol.all_symbols` in `mrbgems/mruby-symbol-ext`
- Increase heap memory usage.
`MRB_USE_VM_SWITCH_DISPATCH`
- Turn on switch dispatch in VM loop

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