Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)
|
#include "debug_counter.h"
#include "id.h"
#include "internal.h"
#include "internal/array.h"
#include "internal/compar.h"
#include "internal/enum.h"
#include "internal/gc.h"
#include "internal/hash.h"
#include "internal/numeric.h"
#include "internal/object.h"
#include "internal/proc.h"
#include "internal/rational.h"
#include "internal/vm.h"
#include "probes.h"
#include "ruby/encoding.h"
#include "ruby/st.h"
#include "ruby/util.h"
#include "transient_heap.h"
#include "builtin.h"
#include "ruby_assert.h"
#include "array.rbinc"
Go to the source code of this file.
Data Structures | |
struct | ary_sort_data |
struct | select_bang_arg |
Enumerations | |
enum | ary_take_pos_flags { ARY_TAKE_FIRST = 0 , ARY_TAKE_LAST = 1 } |
Variables | |
VALUE | rb_cArray |
VALUE | rb_output_fs |
#define ARY_CAPA | ( | ary | ) |
#define ARY_EMBED_LEN | ( | a | ) |
#define ARY_EMBED_P | ( | ary | ) |
#define ARY_EMBED_PTR | ( | a | ) | (assert(ARY_EMBED_P(a)), RARRAY(a)->as.ary) |
#define ARY_HEAP_CAPA | ( | a | ) |
#define ARY_HEAP_LEN | ( | a | ) | (assert(!ARY_EMBED_P(a)), RARRAY(a)->as.heap.len) |
#define ARY_HEAP_PTR | ( | a | ) | (assert(!ARY_EMBED_P(a)), RARRAY(a)->as.heap.ptr) |
#define ARY_HEAP_SIZE | ( | a | ) | (assert(!ARY_EMBED_P(a)), assert(ARY_OWNS_HEAP_P(a)), ARY_CAPA(a) * sizeof(VALUE)) |
#define ARY_INCREASE_LEN | ( | ary, | |
n | |||
) |
#define ARY_INCREASE_PTR | ( | ary, | |
n | |||
) |
#define ARY_OWNS_HEAP_P | ( | a | ) |
#define ARY_SET_CAPA | ( | ary, | |
n | |||
) |
#define ARY_SET_EMBED_LEN | ( | ary, | |
n | |||
) |
#define ARY_SET_HEAP_LEN | ( | ary, | |
n | |||
) |
#define ARY_SET_LEN | ( | ary, | |
n | |||
) |
#define ARY_SET_PTR | ( | ary, | |
p | |||
) |
#define ARY_SET_SHARED | ( | ary, | |
value | |||
) |
#define ARY_SET_SHARED_ROOT_REFCNT | ( | ary, | |
value | |||
) |
#define ARY_SHARED_P | ( | ary | ) |
#define ARY_SHARED_ROOT | ( | ary | ) | (assert(ARY_SHARED_P(ary)), RARRAY(ary)->as.heap.aux.shared_root) |
#define ARY_SHARED_ROOT_OCCUPIED | ( | ary | ) | (ARY_SHARED_ROOT_REFCNT(ary) == 1) |
#define ARY_SHARED_ROOT_P | ( | ary | ) |
#define ARY_SHARED_ROOT_REFCNT | ( | ary | ) | (assert(ARY_SHARED_ROOT_P(ary)), RARRAY(ary)->as.heap.aux.capa) |
#define FL_SET_EMBED | ( | a | ) |
#define FL_SET_SHARED | ( | ary | ) |
#define FL_SET_SHARED_ROOT | ( | ary | ) |
#define FL_UNSET_EMBED | ( | ary | ) | FL_UNSET((ary), RARRAY_EMBED_FLAG|RARRAY_EMBED_LEN_MASK) |
#define FL_UNSET_SHARED | ( | ary | ) | FL_UNSET((ary), ELTS_SHARED) |
#define RAND_UPTO | ( | max | ) | (long)rb_random_ulong_limited((randgen), (max)-1) |
#define RUBY_UNTYPED_DATA_WARNING 0 |
#define tmpary | ( | n | ) | rb_ary_tmp_new(n) |
#define tmpary_discard | ( | a | ) | (ary_discard(a), RBASIC_SET_CLASS_RAW(a, rb_cArray)) |
#define to_ary rb_to_array_type |
enum ary_take_pos_flags |
void Init_Array | ( | void | ) |
Definition at line 8082 of file array.c.
References rb_ary_aref(), rb_ary_assoc(), rb_ary_at(), rb_ary_clear(), rb_ary_cmp(), rb_ary_delete(), rb_ary_each(), rb_ary_includes(), rb_ary_last(), rb_ary_plus(), rb_ary_push(), rb_ary_rassoc(), rb_ary_replace(), rb_ary_sort(), rb_ary_sort_bang(), rb_cArray, rb_cObject, rb_define_alias(), rb_define_alloc_func(), rb_define_class(), rb_define_method, rb_define_singleton_method, rb_include_module(), and rb_mEnumerable.
Definition at line 1802 of file array.c.
References argc, argv, rb_ary_aref1(), and rb_check_arity.
Referenced by Init_Array().
Definition at line 1823 of file array.c.
References FIX2LONG, FIXNUM_P, len, NUM2LONG, Qfalse, Qnil, RARRAY_LEN, rb_arithmetic_sequence_beg_len_step(), rb_ary_entry(), and rb_ary_subseq_step().
Referenced by rb_ary_aref().
Definition at line 4938 of file array.c.
References select_bang_arg::ary, key, NIL_P, Qnil, RARRAY_AREF, RARRAY_LEN, rb_check_array_type(), and rb_equal().
Referenced by Init_Array().
Definition at line 1855 of file array.c.
References NUM2LONG, and rb_ary_entry().
Referenced by Init_Array(), and rb_obj_dig().
Definition at line 1521 of file array.c.
References ARY_DEFAULT_SIZE, ARY_SHARED_P, and RARRAY_LEN.
void rb_ary_cancel_sharing | ( | VALUE | ary | ) |
Definition at line 565 of file array.c.
References ARY_EMBED_PTR, ARY_HEAP_PTR, ARY_SET_CAPA, ARY_SET_EMBED_LEN, ARY_SET_PTR, ARY_SHARED_P, ARY_SHARED_ROOT, ARY_SHARED_ROOT_OCCUPIED, ary_verify, FL_SET_EMBED, FL_UNSET_SHARED, len, MEMCPY, MEMMOVE, ptr, RARRAY_CONST_PTR_TRANSIENT, RARRAY_EMBED_LEN_MAX, RARRAY_LEN, RARRAY_PTR_USE_TRANSIENT, and rb_gc_writebarrier_remember().
Referenced by rb_ary_modify().
Definition at line 1314 of file array.c.
References argv, ARY_SET_LEN, len, and RARRAY_LEN.
Referenced by rb_mod_init_copy().
Definition at line 4534 of file array.c.
References select_bang_arg::ary, ARY_CAPA, ARY_DEFAULT_SIZE, ARY_EMBED_P, ARY_SET_EMBED_LEN, ARY_SET_LEN, ARY_SHARED_P, ary_verify, and FL_SET_EMBED.
Referenced by Init_Array(), rb_threadptr_pending_interrupt_clear(), and ruby_set_argv().
Definition at line 5198 of file array.c.
References INT2FIX, len, NIL_P, Qnil, Qundef, RARRAY_LEN, rb_check_array_type(), and rb_exec_recursive_paired().
Referenced by Init_Array().
Definition at line 3956 of file array.c.
References select_bang_arg::ary, ary_verify, Qnil, RARRAY_AREF, RARRAY_LEN, rb_ary_store(), rb_block_given_p(), rb_equal(), and rb_yield().
Referenced by Init_Array().
Definition at line 4010 of file array.c.
References select_bang_arg::ary, ARY_INCREASE_LEN, ary_verify, len, MEMMOVE, ptr, Qnil, RARRAY_AREF, RARRAY_LEN, RARRAY_PTR_USE_TRANSIENT, and rb_ary_modify().
Definition at line 3987 of file array.c.
References select_bang_arg::ary, RARRAY_AREF, RARRAY_LEN, and rb_ary_store().
Definition at line 2666 of file array.c.
References ARY_SET_LEN, ary_verify, len, RARRAY_CONST_PTR_TRANSIENT, RARRAY_LEN, and rb_ary_new2.
Referenced by rb_ary_sort().
Definition at line 2517 of file array.c.
References ary_verify, RARRAY_AREF, RARRAY_LEN, rb_yield(), and RETURN_SIZED_ENUMERATOR.
Referenced by Init_Array().
Definition at line 1672 of file array.c.
Referenced by EVENTSINK_Invoke(), rb_ary_aref1(), rb_ary_at(), rb_debug_inspector_frame_binding_get(), rb_debug_inspector_frame_class_get(), rb_debug_inspector_frame_iseq_get(), rb_debug_inspector_frame_self_get(), rb_error_frozen_object(), and rb_resolve_me_location().
void rb_ary_free | ( | VALUE | ary | ) |
Definition at line 864 of file array.c.
References ARY_HEAP_CAPA, ARY_OWNS_HEAP_P, ARY_SHARED_P, ARY_SHARED_ROOT_OCCUPIED, ARY_SHARED_ROOT_P, RARRAY_LEN, RB_DEBUG_COUNTER_INC, and USE_DEBUG_COUNTER.
Definition at line 674 of file array.c.
References rb_obj_freeze().
Referenced by rb_method_definition_set().
Definition at line 5126 of file array.c.
References select_bang_arg::ary, Qfalse, Qtrue, RARRAY_AREF, RARRAY_LEN, and rb_equal().
Referenced by Init_Array().
Definition at line 2780 of file array.c.
References len, NIL_P, RARRAY_AREF, RARRAY_LEN, rb_check_string_type(), rb_enc_associate(), rb_str_buf_new(), rb_str_new, rb_str_set_len(), rb_usascii_encoding(), rb_usascii_str_new, RSTRING_LEN, and StringValue.
Referenced by rb_insn_operand_intern(), rb_proc_isolate_bang(), and rb_proc_ractor_make_shareable().
Definition at line 1932 of file array.c.
References argc, argv, ARY_TAKE_LAST, len, Qnil, RARRAY_AREF, and RARRAY_LEN.
Referenced by Init_Array(), and rb_gc_register_mark_object().
size_t rb_ary_memsize | ( | VALUE | ary | ) |
Definition at line 894 of file array.c.
References ARY_CAPA, and ARY_OWNS_HEAP_P.
void rb_ary_modify | ( | VALUE | ary | ) |
Definition at line 606 of file array.c.
References rb_ary_cancel_sharing().
Referenced by rb_ary_delete_at(), rb_ary_resize(), rb_ary_reverse(), rb_ary_rotate(), rb_ary_sort_bang(), and rb_ary_store().
VALUE rb_ary_new | ( | void | ) |
Definition at line 749 of file array.c.
References RARRAY_EMBED_LEN_MAX, and rb_ary_new2.
Referenced by EVENTSINK_Invoke(), Init_Encoding(), Init_GC(), Init_load(), Init_ossl_asn1(), Init_VM(), Init_win32ole(), Init_win32ole_event(), ole_methods_from_typeinfo(), ole_variant2val(), ossl_get_errors(), rb_call_end_proc(), rb_f_global_variables(), rb_f_untrace_var(), rb_insn_operand_intern(), rb_memory_view_extract_item_members(), rb_mod_ancestors(), rb_mod_included_modules(), rb_obj_instance_variables(), and rb_ractor_thread_list().
Definition at line 743 of file array.c.
References rb_cArray.
Referenced by rb_hash_keys(), rb_hash_values(), and rb_insns_name_array().
Definition at line 754 of file array.c.
References ARY_SET_LEN, and rb_ary_new2.
Definition at line 788 of file array.c.
References rb_ary_tmp_new_from_values(), and rb_cArray.
Referenced by rb_insn_operand_intern().
Definition at line 4800 of file array.c.
References ARY_SET_LEN, len, RARRAY_CONST_PTR_TRANSIENT, RARRAY_LEN, rb_ary_new2, and to_ary.
Referenced by Init_Array().
Definition at line 1350 of file array.c.
References ARY_CAPA, ARY_DEFAULT_SIZE, ARY_OWNS_HEAP_P, ARY_SET_LEN, ary_verify, Qnil, RARRAY_AREF, and RARRAY_LEN.
void rb_ary_ptr_use_end | ( | VALUE | ary | ) |
Definition at line 252 of file array.c.
References FL_UNSET_RAW, and RARRAY_PTR_IN_USE_FLAG.
Definition at line 243 of file array.c.
References FL_SET_RAW, RARRAY_CONST_PTR_TRANSIENT, and RARRAY_PTR_IN_USE_FLAG.
Definition at line 1301 of file array.c.
References ARY_SET_LEN, ary_verify, ptr, RARRAY_LEN, RARRAY_PTR_USE_TRANSIENT, and RB_OBJ_WRITE.
Referenced by EVENTSINK_Invoke(), Init_Array(), Init_Encoding(), Init_VM(), ole_typedesc2val(), ossl_get_errors(), rb_f_global_variables(), rb_f_untrace_var(), rb_gc_register_mark_object(), rb_get_kwargs(), rb_get_values_at(), rb_hash_values_at(), rb_insn_operand_intern(), rb_insns_name_array(), rb_iseq_parameters(), rb_memory_view_extract_item_members(), rb_mod_ancestors(), rb_mod_included_modules(), rb_ractor_thread_list(), rb_threadptr_pending_interrupt_enque(), rb_uninterruptible(), rb_unnamed_parameters(), ruby_init_loadpath(), ruby_set_argv(), and yyparse().
Definition at line 4967 of file array.c.
References select_bang_arg::ary, Qnil, RARRAY_AREF, RARRAY_LEN, rb_equal(), and T_ARRAY.
Referenced by Init_Array().
Definition at line 4484 of file array.c.
References ARY_HEAP_LEN, ARY_HEAP_PTR, ARY_OWNS_HEAP_P, ARY_SET_LEN, ARY_SET_PTR, ARY_SHARED_P, ARY_SHARED_ROOT, ary_verify, FL_SET_EMBED, FL_UNSET_EMBED, FL_UNSET_SHARED, RARRAY_CONST_PTR_TRANSIENT, RARRAY_EMBED_LEN_MAX, RARRAY_LEN, and to_ary.
Referenced by Init_Array().
expands or shrinks ary to len elements.
expanded region will be filled with Qnil.
ary | an array |
len | new size |
Definition at line 2235 of file array.c.
References ARY_CAPA, ARY_DEFAULT_SIZE, ARY_EMBED_P, ARY_EMBED_PTR, ARY_HEAP_PTR, ARY_MAX_SIZE, ARY_SET_CAPA, ARY_SET_EMBED_LEN, ARY_SET_HEAP_LEN, ARY_SET_LEN, ary_verify, len, MEMCPY, RARRAY_EMBED_LEN_MAX, RARRAY_LEN, rb_ary_modify(), rb_eIndexError, and rb_raise().
Referenced by rb_get_values_at(), rb_mod_init_copy(), and rb_nmin_run().
Definition at line 2679 of file array.c.
References RARRAY_LEN, and rb_cArray.
Definition at line 2998 of file array.c.
References len, RARRAY_LEN, RARRAY_PTR_USE_TRANSIENT, and rb_ary_modify().
Referenced by rb_nmin_run().
Definition at line 3079 of file array.c.
References cnt, len, ptr, Qnil, RARRAY_LEN, RARRAY_PTR_USE_TRANSIENT, and rb_ary_modify().
Definition at line 2212 of file array.c.
References ARY_CAPA, ARY_SET_LEN, ARY_SHARED_P, len, rb_bug(), rb_eRuntimeError, and rb_raise().
Referenced by rb_hash_keys(), and rb_hash_values().
Definition at line 687 of file array.c.
References ARY_EMBED_P, ARY_SHARED_P, Qfalse, Qtrue, and RARRAY.
Referenced by rb_get_expanded_load_path().
Definition at line 1413 of file array.c.
References ARY_DEFAULT_SIZE, ARY_EMBED_P, ARY_INCREASE_LEN, ARY_INCREASE_PTR, ARY_SHARED_P, ARY_SHARED_ROOT, ARY_SHARED_ROOT_OCCUPIED, ary_verify, assert, len, MEMMOVE, ptr, Qnil, RARRAY_AREF, RARRAY_LEN, RARRAY_PTR_USE_TRANSIENT, and top.
Definition at line 3396 of file array.c.
References ary_sort_data::ary, rb_ary_dup(), and rb_ary_sort_bang().
Referenced by Init_Array().
Definition at line 3298 of file array.c.
References ary_sort_data::ary, ARY_EMBED_LEN, ARY_EMBED_P, ARY_EMBED_PTR, ARY_HEAP_LEN, ARY_HEAP_PTR, ARY_SET_CAPA, ARY_SET_EMBED_LEN, ARY_SET_HEAP_LEN, ARY_SET_LEN, ARY_SET_PTR, ARY_SHARED_P, ary_verify, assert, ary_sort_data::cmp_opt, FL_FREEZE, FL_SET, FL_SET_EMBED, FL_UNSET, FL_UNSET_EMBED, FL_UNSET_SHARED, len, cmp_opt_data::opt_inited, cmp_opt_data::opt_methods, ptr, RARRAY_LEN, RARRAY_PTR_USE, rb_ary_modify(), rb_block_given_p(), rb_cArray, and ruby_qsort().
Referenced by Init_Array(), and rb_ary_sort().
Definition at line 1141 of file array.c.
References ARY_CAPA, ARY_MAX_SIZE, ARY_SET_LEN, len, RARRAY_LEN, rb_ary_modify(), rb_eIndexError, and rb_raise().
Referenced by Init_ossl_asn1(), ossl_generate_cb_2(), rb_ary_delete(), rb_ary_delete_same(), rb_sym_to_proc(), and rb_unnamed_parameters().
Definition at line 1700 of file array.c.
References len, and rb_ary_subseq_step().
Definition at line 1678 of file array.c.
References len, Qnil, RARRAY_LEN, rb_cArray, rb_eArgError, and rb_raise().
Referenced by rb_ary_aref1(), and rb_ary_subseq().
Definition at line 846 of file array.c.
References rb_ary_transient_heap_evacuate, and TRUE.
Referenced by Init_load(), Init_sym(), Init_Thread(), Init_vm_objects(), rb_default_coverage(), rb_gc_register_mark_object(), rb_get_kwargs(), rb_mod_init_copy(), rb_nmin_run(), rb_struct_new(), and rb_sym_to_proc().
Definition at line 854 of file array.c.
References ARY_SET_LEN, Qnil, rb_ary_transient_heap_evacuate, and TRUE.
Referenced by rb_default_coverage().
Definition at line 774 of file array.c.
References ARY_SET_LEN.
Referenced by rb_ary_new_from_values().
Definition at line 2133 of file array.c.
References NIL_P, rb_ary_new3, and rb_check_array_type().
Definition at line 975 of file array.c.
References rb_ary_new3.
Referenced by rb_big_divmod(), rb_big_divrem_normal(), rb_gcdlcm(), rb_hash_assoc(), rsock_s_recvfrom(), rsock_s_recvfrom_nonblock(), and yyparse().
Definition at line 988 of file array.c.
References rb_check_convert_type_with_id(), and T_ARRAY.
Referenced by rb_Array(), rb_ary_assoc(), rb_ary_cmp(), rb_ary_to_ary(), rb_hash_set_pair(), rb_io_popen(), rb_yield_splat(), and rb_yield_splat_kw().
Definition at line 994 of file array.c.
References rb_check_convert_type_with_id(), and T_ARRAY.
Referenced by rb_Array().
VALUE rb_ec_ary_new_from_values | ( | rb_execution_context_t * | ec, |
long | n, | ||
const VALUE * | elts | ||
) |
Definition at line 832 of file array.c.
References ARY_SET_LEN, and rb_cArray.
VALUE rb_get_values_at | ( | VALUE | obj, |
long | olen, | ||
int | argc, | ||
const VALUE * | argv, | ||
VALUE(*)(VALUE, long) | func | ||
) |
Definition at line 3673 of file array.c.
References argc, argv, FIX2LONG, FIXNUM_P, len, NUM2LONG, RARRAY_LEN, rb_ary_new2, rb_ary_push(), rb_ary_resize(), and rb_range_beg_len().
Definition at line 981 of file array.c.
References rb_convert_type_with_id(), and T_ARRAY.
VALUE rb_cArray |
Definition at line 40 of file array.c.
Referenced by Init_Array(), Init_vm_backtrace(), rb_ary_new_capa(), rb_ary_new_from_values(), rb_ary_resurrect(), rb_ary_sort_bang(), rb_ary_subseq_step(), rb_ec_ary_new_from_values(), and rb_nmin_run().