RuntimeType RuntimeType::setKnownClass(const Class* klass) const { assert(isObject()); RuntimeType rtt; rtt.m_kind = VALUE; rtt.m_value.outerType = outerType(); rtt.m_value.klass = m_value.klass; rtt.m_value.knownClass = klass; rtt.consistencyCheck(); return rtt; }
RuntimeType RuntimeType::setArrayKind(ArrayData::ArrayKind arrayKind) const { assert(isArray() || (isRef() && innerType() == KindOfArray)); RuntimeType rtt; rtt.m_kind = this->m_kind; rtt.m_value.outerType = outerType(); rtt.m_value.innerType = innerType(); rtt.m_value.arrayKindValid = true; rtt.m_value.arrayKind = arrayKind; rtt.consistencyCheck(); return rtt; }
RuntimeType RuntimeType::unbox() const { assert(m_kind == VALUE); if (m_value.outerType != KindOfRef) { consistencyCheck(); return *this; } RuntimeType rtt; rtt.m_value.outerType = m_value.innerType; rtt.m_value.innerType = KindOfInvalid; rtt.consistencyCheck(); return rtt; }
RuntimeType RuntimeType::box() const { ASSERT(m_kind == VALUE); if (m_value.outerType == KindOfRef) { consistencyCheck(); return *this; } RuntimeType rtt; rtt.m_value.outerType = KindOfRef; rtt.m_value.innerType = m_value.outerType; rtt.consistencyCheck(); return rtt; }
RuntimeType RuntimeType::setKnownClass(const Class* klass) const { assert(isObject() || (isRef() && innerType() == KindOfObject)); RuntimeType rtt; rtt.m_kind = this->m_kind; rtt.m_value.outerType = outerType(); rtt.m_value.innerType = innerType(); rtt.m_value.klass = m_value.klass; rtt.m_value.knownClass = klass; rtt.consistencyCheck(); return rtt; }
RuntimeType RuntimeType::setValueType(DataType newInner) const { assert(m_kind == VALUE); RuntimeType rtt; rtt.m_kind = VALUE; rtt.m_value.outerType = outerType(); if (outerType() == KindOfRef) { rtt.m_value.innerType = newInner; } else { rtt.m_value.outerType = newInner; } assert(rtt.valueType() == newInner); rtt.m_value.klass = nullptr; rtt.consistencyCheck(); return rtt; }