模块 RubyVM::RJIT::CPointer

此命名空间下的每个类都是一个指针。即使类型是即时类型,在调用“*”之前也不应取消引用。

公共类方法

with_class_name(prefix, name, cache: false, &block) 单击以切换源

给一个动态的 CPointer 类命名,以便在检查时看到它

# File ruby_vm/rjit/c_pointer.rb, line 374
def self.with_class_name(prefix, name, cache: false, &block)
  return block.call if !name.nil? && name.empty?

  # Use a cached result only if cache: true
  class_name = "#{prefix}_#{name}"
  klass =
    if cache && self.const_defined?(class_name)
      self.const_get(class_name)
    else
      block.call
    end

  # Give it a name unless it's already defined
  unless self.const_defined?(class_name)
    self.const_set(class_name, klass)
  end

  klass
end