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; }
Type::Type(const RuntimeType& rtt) : m_bits(bitsFromDataType(rtt.outerType(), rtt.innerType())) , m_class(nullptr) { if (rtt.outerType() == KindOfObject && rtt.hasKnownClass()) { m_class = rtt.knownClass(); } else if (rtt.outerType() == KindOfArray && rtt.hasArrayKind()) { m_arrayKindValid = true; m_arrayKind = rtt.arrayKind(); } }
Type::Type(const RuntimeType& rtt) : m_bits(bitsFromDataType(rtt.outerType(), rtt.innerType())) , m_hasConstVal(false) , m_class(nullptr) { if (rtt.outerType() == KindOfObject && rtt.hasKnownClass()) { m_class = rtt.knownClass(); } else if (rtt.outerType() == KindOfArray && rtt.hasArrayKind()) { m_arrayInfo = makeArrayInfo(rtt.arrayKind(), nullptr); } }
Type Type::fromRuntimeType(const RuntimeType& rtt) { return fromDataType(rtt.outerType(), rtt.innerType(), rtt.knownClass()); }