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
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
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
f1568af0d2
gc.c: fix GC regressions
...
The past fix was wrong.
2023-03-29 08:46:10 +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
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
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
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
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
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
b1d0a3d3aa
etc.c (mrb_float_id): define the function only when necessary
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
dearblue
ddaf3bdc0f
Added note to CINFO_* constants
2023-03-09 22:13:52 +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
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
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
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
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
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
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