Sha256: 15c5fcc4317cfc5b49837335b870ff37158387603a0a8733f9a73330e5e9621c

Contents?: true

Size: 690 Bytes

Versions: 1

Compression:

Stored size: 690 Bytes

Contents

#include "cruby.h"

static inline void
vm_check_if_namespace(VALUE klass)
{
  if (!RB_TYPE_P(klass, T_CLASS) && !RB_TYPE_P(klass, T_MODULE)) {
    rb_raise(rb_eTypeError, "%+"PRIsVALUE" is not a class/module", klass);
  }
}
static inline void
vm_ensure_not_refinement_module(VALUE self)
{
  if (RB_TYPE_P(self, T_MODULE) && FL_TEST(self, RMODULE_IS_REFINEMENT)) {
    rb_warn("not defined at the refinement, but at the outer class/module");
  }
}
// https://github.com/ruby/ruby/blob/v2_4_1/insns.def#L201-L223
void
llrb_insn_setconstant(VALUE self, VALUE cbase, ID id, VALUE val) {
  vm_check_if_namespace(cbase);
  vm_ensure_not_refinement_module(self);
  rb_const_set(cbase, id, val);
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
llrb-0.0.1 ext/llrb_insn_setconstant.c