18 #ifdef MRB_USE_IV_SEGLIST
20 #ifndef MRB_SEGMENT_SIZE
21 #define MRB_SEGMENT_SIZE 4
24 typedef struct segment {
71 segment *seg = t->rootseg;
73 segment *matched_seg = NULL;
74 size_t matched_idx = 0;
78 for (i=0; i<MRB_SEGMENT_SIZE; i++) {
81 if (!seg->next && i >= t->last_len) {
88 if (!matched_seg && key == 0) {
92 else if (key == sym) {
104 matched_seg->key[matched_idx] =
sym;
105 matched_seg->val[matched_idx] = val;
143 for (i=0; i<MRB_SEGMENT_SIZE; i++) {
146 if (!seg->next && i >= t->last_len) {
150 if (vp) *vp = seg->val[
i];
178 for (i=0; i<MRB_SEGMENT_SIZE; i++) {
181 if (!seg->next && i >= t->last_len) {
187 if (vp) *vp = seg->val[
i];
205 for (i=0; i<MRB_SEGMENT_SIZE; i++) {
209 if (!seg->next && i >= t->last_len) {
213 n =(*func)(mrb, key, seg->val[
i], p);
214 if (n > 0)
return FALSE;
233 if (t->size > 0)
return t->size;
236 if (seg->next == NULL) {
241 size += MRB_SEGMENT_SIZE;
258 while (seg != NULL) {
259 for (i=0; i<MRB_SEGMENT_SIZE; i++) {
263 if ((seg->next == NULL) && (i >= t->last_len)) {
266 iv_put(mrb, t2, key, val);
291 #ifndef MRB_IVHASH_INIT_SIZE
292 #define MRB_IVHASH_INIT_SIZE 8
361 if (n > 0)
return FALSE;
405 iv_foreach(mrb, t, iv_mark_i, 0);
425 mark_tbl(mrb, obj->
iv);
431 return iv_size(mrb, obj->
iv);
438 iv_free(mrb, obj->
iv);
445 return mrb_fixnum_value(0);
474 if (obj->
iv && iv_get(mrb, obj->
iv, sym, &v))
476 return mrb_nil_value();
485 return mrb_nil_value();
494 t = obj->
iv = iv_new(mrb);
497 iv_put(mrb, t, sym, v);
506 t = obj->
iv = iv_new(mrb);
508 else if (iv_get(mrb, t, sym, &v)) {
512 iv_put(mrb, t, sym, v);
533 return iv_get(mrb, t, sym, NULL);
541 if (!obj_iv_p(obj))
return FALSE;
556 d->
iv = iv_copy(mrb, s->
iv);
586 size_t len = iv_size(mrb, t);
593 mrb_str_cat2(mrb, str, cn);
597 iv_foreach(mrb, t, inspect_i, &str);
611 if (t && iv_del(mrb, t, sym, &val)) {
615 return mrb_undef_value();
641 if (len > 1 && s[0] ==
'@' && s[1] !=
'@') {
685 if (len > 2 && s[0] ==
'@' && s[1] ==
'@') {
717 iv_foreach(mrb, c->
iv, cv_i, &ary);
734 if (iv_get(mrb, t, sym, &v))
742 return mrb_nil_value();
760 if (iv_get(mrb, t, sym, NULL)) {
762 iv_put(mrb, t, sym, v);
770 cls->
iv = iv_new(mrb);
774 iv_put(mrb, cls->
iv, sym, v);
789 if (iv_get(mrb, t, sym, NULL))
return TRUE;
823 if (iv_get(mrb, t, sym, NULL)) {
825 iv_put(mrb, t, sym, v);
836 iv_put(mrb, c->
iv, sym, v);
845 if (!t)
return FALSE;
846 return iv_get(mrb, t, sym, NULL);
876 if (iv_get(mrb, t, sym, &v))
898 return mrb_nil_value();
904 mod_const_check(mrb, mod);
918 if (c->
iv && iv_get(mrb, c->
iv, sym, &v)) {
925 if (c2->
iv && iv_get(mrb, c2->
iv, sym, &v)) {
930 return const_get(mrb, c, sym);
936 mod_const_check(mrb, mod);
952 mod_const_check(mrb, mod);
977 if (len > 1 &&
ISUPPER(s[0])) {
999 iv_foreach(mrb, c->
iv, const_i, &ary);
1013 return mrb_nil_value();
1015 if (iv_get(mrb, mrb->
globals, sym, &v))
1017 return mrb_nil_value();
1026 t = mrb->
globals = iv_new(mrb);
1031 iv_put(mrb, t, sym, v);
1063 iv_foreach(mrb, t, gv_i, &ary);
1067 for (i = 1; i <= 9; ++
i) {
1068 buf[1] = (char)(i +
'0');
1083 if (tmp->
iv && iv_get(mrb, tmp->
iv,
id, NULL)) {
1089 if (!exclude && !mod_retry && (klass->tt ==
MRB_TT_MODULE)) {
1100 return mrb_const_defined_0(mrb, klass,
id,
TRUE,
FALSE);
1135 if (!outer)
return 0;
1141 iv_foreach(mrb, outer->
iv, csym_i, &arg);