summaryrefslogtreecommitdiffhomepage
path: root/src/array.c
AgeCommit message (Collapse)Author
2021-12-29array.c: fix `mrb_ary_shift_m` initialization bug.Yukihiro "Matz" Matsumoto
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
2021-09-10array.c: forgot to adjust tail position in `mrb_ary_splice`.Yukihiro "Matz" Matsumoto
2021-09-08array.c: refactor `mrb_ary_splice`.Yukihiro "Matz" Matsumoto
2021-09-05array.c: check integer overflow before addition.Yukihiro "Matz" Matsumoto
2021-08-03Replace `mrb_fixnum_value()` with `mrb_int_value()`.Yukihiro "Matz" Matsumoto
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-07-10Update internal methods not to be listed in backtraces.Yukihiro "Matz" Matsumoto
- String#__lines - Array#__ary_eq - Array#__ary_cmp - Hash#__delete - Kernel#__case_eqq - Integer#__coerce_step_counter
2021-06-20Added `MRB_OBJ_ALLOC()` macro that does not require a castdearblue
The `MRB_OBJ_ALLOC()` macro function returns a pointer of the type corresponding to the constant literal defined in `enum mrb_vtype`.
2021-05-27array.c: unify `mrb_ary_ref` and `mrb_ary_entry`Yukihiro "Matz" Matsumoto
Use only `mrb_ary_entry` hereafter.
2021-05-27array.c: check for negative shift size.Yukihiro "Matz" Matsumoto
2021-05-02array.c: `mrb_ary_shift_m` should be `static`.Yukihiro "Matz" Matsumoto
2021-04-27array.c: update `Array#shift` to take optional argument; close #5428Yukihiro "Matz" Matsumoto
2021-02-16Update URL explaining alignment issue; close #5344Yukihiro "Matz" Matsumoto
2021-02-13chore: fix missing HTTPS on linksJohn Bampton
2021-01-11Avoid including `presym.inc` in existing header filesKOBAYASHI Shuji
Addressed an issue where existing programs linking `libmruby.a` could only be built by adding `<build-dir>/include` to compiler's include path.
2020-11-25Move inline `iseq` in `array.c` to `array.rb`.Yukihiro "Matz" Matsumoto
There's no efficiency difference since `cdump` is implemented.
2020-11-13Change name and usage of presym macrosKOBAYASHI Shuji
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-10-23Merge pull request #5099 from dearblue/getargs-arrayYukihiro "Matz" Matsumoto
Prohibit array changes by "a"/"*" specifier of `mrb_get_args()`
2020-10-22Prohibit array changes by `mrb_get_argv()`dearblue
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-22Prohibit array changes by "a"/"*" specifier of `mrb_get_args()`dearblue
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-12Reorganize `Integer` system.Yukihiro "Matz" Matsumoto
- 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-12Rename `MRB_TT_FIXNUM` to `MRB_TT_INTEGER`.Yukihiro "Matz" Matsumoto
We still have `#define MRB_TT_FIXNUM MRB_TT_INTEGER` for compatibility.
2020-10-12Rename float configuration option names.Yukihiro "Matz" Matsumoto
- `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-12Skip array embedding if `MRB_NO_BOXING` and `MRB_32BIT`; fix #4382Yukihiro "Matz" Matsumoto
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-12Adjust PR #5060 to the latest `mruby3` branch.Yukihiro "Matz" Matsumoto
2020-10-12Use `mrb_field_write_barrier` instead of `mrb_write_barrier` for `push`.Yukihiro "Matz" Matsumoto
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-12Skip `mrb_get_args()` in `mrb_ary_push()`.Yukihiro "Matz" Matsumoto
2020-10-12Avoid use of designated initializers to generate `irep` struct.Yukihiro "Matz" Matsumoto
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-12Use `static const struct mrb_irep each_irep` to ininitalize `each`.Yukihiro "Matz" Matsumoto
2020-10-12Constify `irep` members.Yukihiro "Matz" Matsumoto
- `pool` - `syms` - `reps`
2020-10-12Use `mrb_funcall_id()` extensively.Yukihiro "Matz" Matsumoto
Except for support files e.g. `mruby-test/driver.c`, which are not target of symbol collection via `rake gensym`.
2020-10-12Use `MRB_QSYM()` instead of `MRB_OPSYM()`.Yukihiro "Matz" Matsumoto
2020-10-12Use `MRB_OPSYM()` instead of `mrb_intern_lit()`.Yukihiro "Matz" Matsumoto
2020-10-12Add `MRB_SYM()` for inline symbols.Yukihiro "Matz" Matsumoto
2020-08-30Fix `mrb_ary_splat()` to copy the array always.Yukihiro "Matz" Matsumoto
2020-08-29Fix the bug caused by `to_a` returning a frozen array.Yukihiro "Matz" Matsumoto
Reported by @shuujii.
2020-08-29Fix `mrb_ary_splat` to copy the array; fix #5067Yukihiro "Matz" Matsumoto
2020-07-22Avoid using `mrb_ary_modify` from the internal function.Yukihiro "Matz" Matsumoto
`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-22Use `mrb_field_write_barrier` instead of `mrb_write_barrier` for `push`.Yukihiro "Matz" Matsumoto
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-06-22Skip `mrb_get_args()` in `mrb_ary_{aget,aset}` unless necessary.Yukihiro "Matz" Matsumoto
Use simpler `mrb_get_argc()` and `mrb_get_arg1()` instead.
2020-06-20Add `mrb_get_arg1()` that retrieves single (and only) argument.Yukihiro "Matz" Matsumoto
`mrb_get_arg1()` raises `ArgumentError` if the method does not receive one argument. And replaces all `mrb_get_args(mrb, "o", &arg)` by the new function.
2020-05-24Do not destruct rest arguments for __send__Yusuke Endoh
Formerly, `__send__(*args)` modified `args` with `Array#shift`. This bug affects optcarrot. This changeset avoids the array destruction by using `args = args[1, len-1]`.
2020-04-24Support `undef` for `mrb_ary_splice()` instead of `[]`dearblue
When removing elements from an array, it is possible to avoid creating an empty array. Before this patch: ```c mrb_ary_splice(mrb, ary, head, len, mrb_ary_new(mrb)); ``` After this patch: ```c mrb_ary_splice(mrb, ary, head, len, mrb_undef_value()); ```
2019-12-13Fix arguments check to `Array#each`KOBAYASHI Shuji
#### Before this patch: ``` $ mruby -e '[].each(1){}' #=> no error ``` #### After this patch: ``` $ mruby -e '[].each(1){}' #=> ArgumentError: wrong number of arguments ```
2019-11-08Avoid crashing of `Array#unshift`; fix #4808Yukihiro "Matz" Matsumoto
On cases like `a.unshift(*a)`.
2019-09-18Remove `mrb_get_args(mrb, "")`; ref 30f37872KOBAYASHI Shuji
2019-09-14Add a macro `mrb_frozen_p` that points to `MRB_FROZEN_P`.Yukihiro "Matz" Matsumoto
2019-08-18Prohibit changes to iseq in principledearblue
2019-08-17Implement `Array#each` using inline mruby bytecode.Yukihiro "Matz" Matsumoto
2019-08-05Use new specifiers/modifiers of `mrb_vfromat()`KOBAYASHI Shuji
The binary sizes (gems are only `mruby-bin-mruby`) are reduced slightly in my environment than before the introduction of new specifiers/modifiers (5116789a) with this change. ------------+-------------------+-------------------+-------- BINARY | BEFORE (5116789a) | AFTER (This PR) | RATIO ------------+-------------------+-------------------+-------- mruby | 593416 bytes | 593208 bytes | -0.04% libmruby.a | 769048 bytes | 767264 bytes | -0.23% ------------+-------------------+-------------------+-------- BTW, I accidentally changed `tasks/toolchains/visualcpp.rake` at #4613, so I put it back.
2019-06-23Fix argument specs to `Array`KOBAYASHI Shuji