module RubyVM::RJIT::Type
This returns an appropriate Type
based on a known value
Constants
- BlockParamProxy
- CString
- False
- Fixnum
- Flonum
- Hash
- HeapSymbol
- ImmSymbol
- Nil
- TArray
- TString
- True
- Unknown
List of types
- UnknownHeap
- UnknownImm
Public Class Methods
from(val)
click to toggle source
# File ruby_vm/rjit/type.rb, line 145 def from(val) if C::SPECIAL_CONST_P(val) if fixnum?(val) Type::Fixnum elsif val.nil? Type::Nil elsif val == true Type::True elsif val == false Type::False elsif static_symbol?(val) Type::ImmSymbol elsif flonum?(val) Type::Flonum else raise "Illegal value: #{val.inspect}" end else val_class = C.to_value(C.rb_class_of(val)) if val_class == C.rb_cString && C.rb_obj_frozen_p(val) return Type::CString end if C.to_value(val) == C.rb_block_param_proxy return Type::BlockParamProxy end case C::BUILTIN_TYPE(val) in C::RUBY_T_ARRAY Type::TArray in C::RUBY_T_HASH Type::Hash in C::RUBY_T_STRING Type::TString else Type::UnknownHeap end end end
Private Class Methods
fixnum?(obj)
click to toggle source
# File ruby_vm/rjit/type.rb, line 185 def fixnum?(obj) (C.to_value(obj) & C::RUBY_FIXNUM_FLAG) == C::RUBY_FIXNUM_FLAG end
flonum?(obj)
click to toggle source
# File ruby_vm/rjit/type.rb, line 189 def flonum?(obj) (C.to_value(obj) & C::RUBY_FLONUM_MASK) == C::RUBY_FLONUM_FLAG end
static_symbol?(obj)
click to toggle source
# File ruby_vm/rjit/type.rb, line 193 def static_symbol?(obj) (C.to_value(obj) & 0xff) == C::RUBY_SYMBOL_FLAG end