コード例 #1
0
static VALUE
lfp_svar_get(rb_thread_t *th, VALUE *lfp, VALUE key)
{
    NODE *svar = lfp_svar_place(th, lfp);

    switch (key) {
      case 0:
	return svar->u1.value;
      case 1:
	return svar->u2.value;
      default: {
	const VALUE hash = svar->u3.value;

	if (hash == Qnil) {
	    return Qnil;
	}
	else {
	    return rb_hash_lookup(hash, key);
	}
      }
    }
}
コード例 #2
0
static VALUE
lfp_svar_get(rb_thread_t *th, VALUE *lfp, rb_num_t key)
{
    NODE *svar = lfp_svar_place(th, lfp);

    switch (key) {
      case 0:
	return svar->u1.value;
      case 1:
	return svar->u2.value;
      default: {
	const VALUE ary = svar->u3.value;

	if (NIL_P(ary)) {
	    return Qnil;
	}
	else {
	    return rb_ary_entry(ary, key - DEFAULT_SPECIAL_VAR_COUNT);
	}
      }
    }
}
コード例 #3
0
static void
lfp_svar_set(rb_thread_t *th, VALUE *lfp, VALUE key, VALUE val)
{
    NODE *svar = lfp_svar_place(th, lfp);

    switch (key) {
      case 0:
	svar->u1.value = val;
	return;
      case 1:
	svar->u2.value = val;
	return;
      default: {
	VALUE hash = svar->u3.value;

	if (hash == Qnil) {
	    svar->u3.value = hash = rb_hash_new();
	}
	rb_hash_aset(hash, key, val);
      }
    }
}
コード例 #4
0
static void
lfp_svar_set(rb_thread_t *th, VALUE *lfp, rb_num_t key, VALUE val)
{
    NODE *svar = lfp_svar_place(th, lfp);

    switch (key) {
      case 0:
	svar->u1.value = val;
	return;
      case 1:
	svar->u2.value = val;
	return;
      default: {
	VALUE ary = svar->u3.value;

	if (NIL_P(ary)) {
	    svar->u3.value = ary = rb_ary_new();
	}
	rb_ary_store(ary, key - DEFAULT_SPECIAL_VAR_COUNT, val);
      }
    }
}