Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | Private Member Functions | Friends | List of all members
dart::TypeParameter Class Reference

#include <object.h>

Inheritance diagram for dart::TypeParameter:
dart::AbstractType dart::Instance dart::Object

Public Member Functions

TypeParameterPtr ToNullability (Nullability value, Heap::Space space) const
 
virtual bool HasTypeClass () const
 
virtual classid_t type_class_id () const
 
bool IsFunctionTypeParameter () const
 
bool IsClassTypeParameter () const
 
intptr_t base () const
 
void set_base (intptr_t value) const
 
intptr_t index () const
 
void set_index (intptr_t value) const
 
classid_t parameterized_class_id () const
 
void set_parameterized_class_id (classid_t value) const
 
ClassPtr parameterized_class () const
 
FunctionTypePtr parameterized_function_type () const
 
AbstractTypePtr bound () const
 
virtual bool IsInstantiated (Genericity genericity=kAny, intptr_t num_free_fun_type_params=kAllFree) const
 
virtual bool IsEquivalent (const Instance &other, TypeEquality kind, FunctionTypeMapping *function_type_equivalence=nullptr) const
 
virtual AbstractTypePtr InstantiateFrom (const TypeArguments &instantiator_type_arguments, const TypeArguments &function_type_arguments, intptr_t num_free_fun_type_params, Heap::Space space, FunctionTypeMapping *function_type_mapping=nullptr, intptr_t num_parent_type_args_adjustment=0) const
 
virtual AbstractTypePtr UpdateFunctionTypes (intptr_t num_parent_type_args_adjustment, intptr_t num_free_fun_type_params, Heap::Space space, FunctionTypeMapping *function_type_mapping) const
 
virtual AbstractTypePtr Canonicalize (Thread *thread) const
 
virtual void EnumerateURIs (URIs *uris) const
 
virtual void PrintName (NameVisibility visibility, BaseTextBuffer *printer) const
 
AbstractTypePtr GetFromTypeArguments (const TypeArguments &instantiator_type_arguments, const TypeArguments &function_type_arguments) const
 
const char * CanonicalNameCString () const
 
- Public Member Functions inherited from dart::AbstractType
bool IsFinalized () const
 
void SetIsFinalized () const
 
Nullability nullability () const
 
bool IsNullable () const
 
bool IsNonNullable () const
 
bool IsStrictlyNonNullable () const
 
virtual AbstractTypePtr SetInstantiatedNullability (const TypeParameter &type_param, Heap::Space space) const
 
virtual AbstractTypePtr NormalizeFutureOrType (Heap::Space space) const
 
virtual bool HasTypeClass () const
 
virtual classid_t type_class_id () const
 
virtual ClassPtr type_class () const
 
virtual TypeArgumentsPtr arguments () const
 
virtual bool IsInstantiated (Genericity genericity=kAny, intptr_t num_free_fun_type_params=kAllFree) const
 
virtual bool CanonicalizeEquals (const Instance &other) const
 
virtual uint32_t CanonicalizeHash () const
 
virtual bool Equals (const Instance &other) const
 
virtual bool IsEquivalent (const Instance &other, TypeEquality kind, FunctionTypeMapping *function_type_equivalence=nullptr) const
 
virtual AbstractTypePtr InstantiateFrom (const TypeArguments &instantiator_type_arguments, const TypeArguments &function_type_arguments, intptr_t num_free_fun_type_params, Heap::Space space, FunctionTypeMapping *function_type_mapping=nullptr, intptr_t num_parent_type_args_adjustment=0) const
 
virtual AbstractTypePtr UpdateFunctionTypes (intptr_t num_parent_type_args_adjustment, intptr_t num_free_fun_type_params, Heap::Space space, FunctionTypeMapping *function_type_mapping) const
 
virtual InstancePtr CanonicalizeLocked (Thread *thread) const
 
virtual AbstractTypePtr Canonicalize (Thread *thread) const
 
virtual const char * NullabilitySuffix (NameVisibility name_visibility) const
 
StringPtr Name () const
 
const char * NameCString () const
 
StringPtr UserVisibleName () const
 
const char * UserVisibleNameCString () const
 
StringPtr ScrubbedName () const
 
const char * ScrubbedNameCString () const
 
virtual void PrintName (NameVisibility visibility, BaseTextBuffer *printer) const
 
virtual void EnumerateURIs (URIs *uris) const
 
uword Hash () const
 
virtual uword ComputeHash () const
 
StringPtr ClassName () const
 
bool IsDynamicType () const
 
bool IsVoidType () const
 
bool IsNullType () const
 
bool IsNeverType () const
 
bool IsSentinelType () const
 
bool IsObjectType () const
 
bool IsNullableObjectType () const
 
bool IsTopTypeForSubtyping () const
 
bool IsTopTypeForInstanceOf () const
 
bool IsBoolType () const
 
bool IsIntType () const
 
bool IsIntegerImplementationType () const
 
bool IsDoubleType () const
 
bool IsFloat32x4Type () const
 
bool IsFloat64x2Type () const
 
bool IsInt32x4Type () const
 
bool IsNumberType () const
 
bool IsSmiType () const
 
bool IsMintType () const
 
bool IsStringType () const
 
bool IsDartFunctionType () const
 
bool IsDartClosureType () const
 
bool IsDartRecordType () const
 
bool IsFfiPointerType () const
 
bool IsFutureOrType () const
 
AbstractTypePtr UnwrapFutureOr () const
 
bool IsCatchAllType () const
 
bool IsTypeClassAllowedBySpawnUri () const
 
bool IsSubtypeOf (const AbstractType &other, Heap::Space space, FunctionTypeMapping *function_type_equivalence=nullptr) const
 
uword type_test_stub_entry_point () const
 
CodePtr type_test_stub () const
 
void SetTypeTestingStub (const Code &stub) const
 
void InitializeTypeTestingStubNonAtomic (const Code &stub) const
 
void UpdateTypeTestingStubEntryPoint () const
 
- Public Member Functions inherited from dart::Instance
virtual bool OperatorEquals (const Instance &other) const
 
bool IsIdenticalTo (const Instance &other) const
 
virtual bool CanonicalizeEquals (const Instance &other) const
 
virtual uint32_t CanonicalizeHash () const
 
intptr_t SizeFromClass () const
 
InstancePtr Canonicalize (Thread *thread) const
 
virtual InstancePtr CanonicalizeLocked (Thread *thread) const
 
virtual void CanonicalizeFieldsLocked (Thread *thread) const
 
InstancePtr CopyShallowToOldSpace (Thread *thread) const
 
ObjectPtr GetField (const Field &field) const
 
void SetField (const Field &field, const Object &value) const
 
AbstractTypePtr GetType (Heap::Space space) const
 
virtual TypeArgumentsPtr GetTypeArguments () const
 
virtual void SetTypeArguments (const TypeArguments &value) const
 
bool IsInstanceOf (const AbstractType &other, const TypeArguments &other_instantiator_type_arguments, const TypeArguments &other_function_type_arguments) const
 
bool IsAssignableTo (const AbstractType &other, const TypeArguments &other_instantiator_type_arguments, const TypeArguments &other_function_type_arguments) const
 
bool IsValidNativeIndex (int index) const
 
intptr_t * NativeFieldsDataAddr () const
 
intptr_t GetNativeField (int index) const
 
void GetNativeFields (uint16_t num_fields, intptr_t *field_values) const
 
void SetNativeFields (uint16_t num_fields, const intptr_t *field_values) const
 
uint16_t NumNativeFields () const
 
void SetNativeField (int index, intptr_t value) const
 
bool IsCallable (Function *function) const
 
ObjectPtr Invoke (const String &selector, const Array &arguments, const Array &argument_names, bool respect_reflectable=true, bool check_is_entrypoint=false) const
 
ObjectPtr InvokeGetter (const String &selector, bool respect_reflectable=true, bool check_is_entrypoint=false) const
 
ObjectPtr InvokeSetter (const String &selector, const Instance &argument, bool respect_reflectable=true, bool check_is_entrypoint=false) const
 
ObjectPtr EvaluateCompiledExpression (const Class &klass, const ExternalTypedData &kernel_buffer, const Array &type_definitions, const Array &arguments, const TypeArguments &type_arguments) const
 
virtual ObjectPtr HashCode () const
 
IntegerPtr IdentityHashCode (Thread *thread) const
 
virtual bool IsPointer () const
 
- Public Member Functions inherited from dart::Object
virtual ~Object ()
 
ObjectPtr ptr () const
 
void operator= (ObjectPtr value)
 
bool IsCanonical () const
 
void SetCanonical () const
 
void ClearCanonical () const
 
bool IsImmutable () const
 
void SetImmutable () const
 
void ClearImmutable () const
 
intptr_t GetClassId () const
 
ClassPtr clazz () const
 
 CLASS_LIST_FOR_HANDLES (DEFINE_CLASS_TESTER)
 
bool IsNull () const
 
virtual const char * ToCString () const
 
void PrintJSON (JSONStream *stream, bool ref=true) const
 
virtual void PrintJSONImpl (JSONStream *stream, bool ref) const
 
void PrintImplementationFields (JSONStream *stream) const
 
virtual void PrintImplementationFieldsImpl (const JSONArray &jsarr_fields) const
 
virtual const char * JSONType () const
 
virtual StringPtr DictionaryName () const
 
bool IsNew () const
 
bool IsOld () const
 
bool InVMIsolateHeap () const
 
void Print () const
 

Static Public Member Functions

static intptr_t index_offset ()
 
static const char * CanonicalNameCString (bool is_class_type_parameter, intptr_t base, intptr_t index)
 
static intptr_t InstanceSize ()
 
static TypeParameterPtr New (const Object &owner, intptr_t base, intptr_t index, Nullability nullability)
 
- Static Public Member Functions inherited from dart::AbstractType
static intptr_t flags_offset ()
 
static intptr_t hash_offset ()
 
static void AddURI (URIs *uris, const String &name, const String &uri)
 
static StringPtr PrintURIs (URIs *uris)
 
static bool InstantiateAndTestSubtype (AbstractType *subtype, AbstractType *supertype, const TypeArguments &instantiator_type_args, const TypeArguments &function_type_args)
 
static intptr_t type_test_stub_entry_point_offset ()
 
static intptr_t InstanceSize ()
 
static intptr_t NextFieldOffset ()
 
- Static Public Member Functions inherited from dart::Instance
static bool NullIsAssignableTo (const AbstractType &other)
 
static bool NullIsAssignableTo (const AbstractType &other, const TypeArguments &other_instantiator_type_arguments, const TypeArguments &other_function_type_arguments)
 
static ObjectPtr EvaluateCompiledExpression (Thread *thread, const Object &receiver, const Library &library, const Class &klass, const ExternalTypedData &kernel_buffer, const Array &type_definitions, const Array &param_values, const TypeArguments &type_param_values)
 
static intptr_t UnroundedSize ()
 
static intptr_t InstanceSize ()
 
static InstancePtr New (const Class &cls, Heap::Space space=Heap::kNew)
 
static InstancePtr NewAlreadyFinalized (const Class &cls, Heap::Space space=Heap::kNew)
 
static intptr_t DataOffsetFor (intptr_t cid)
 
static intptr_t ElementSizeFor (intptr_t cid)
 
static intptr_t NextFieldOffset ()
 
static intptr_t NativeFieldsOffset ()
 
- Static Public Member Functions inherited from dart::Object
static ObjectPtr RawCast (ObjectPtr obj)
 
static constexpr bool ContainsCompressedPointers ()
 
static intptr_t tags_offset ()
 
static ObjectHandle ()
 
static ObjectHandle (Zone *zone)
 
static ObjectHandle (ObjectPtr ptr)
 
static ObjectHandle (Zone *zone, ObjectPtr ptr)
 
static ObjectZoneHandle ()
 
static ObjectZoneHandle (Zone *zone)
 
static ObjectZoneHandle (ObjectPtr ptr)
 
static ObjectZoneHandle (Zone *zone, ObjectPtr ptr)
 
static ObjectReadOnlyHandle ()
 
static ObjectPtr null ()
 
static void set_vm_isolate_snapshot_object_table (const Array &table)
 
static ClassPtr class_class ()
 
static ClassPtr dynamic_class ()
 
static ClassPtr void_class ()
 
static ClassPtr type_parameters_class ()
 
static ClassPtr type_arguments_class ()
 
static ClassPtr patch_class_class ()
 
static ClassPtr function_class ()
 
static ClassPtr closure_data_class ()
 
static ClassPtr ffi_trampoline_data_class ()
 
static ClassPtr field_class ()
 
static ClassPtr script_class ()
 
static ClassPtr library_class ()
 
static ClassPtr namespace_class ()
 
static ClassPtr kernel_program_info_class ()
 
static ClassPtr code_class ()
 
static ClassPtr instructions_class ()
 
static ClassPtr instructions_section_class ()
 
static ClassPtr instructions_table_class ()
 
static ClassPtr object_pool_class ()
 
static ClassPtr pc_descriptors_class ()
 
static ClassPtr code_source_map_class ()
 
static ClassPtr compressed_stackmaps_class ()
 
static ClassPtr var_descriptors_class ()
 
static ClassPtr exception_handlers_class ()
 
static ClassPtr context_class ()
 
static ClassPtr context_scope_class ()
 
static ClassPtr sentinel_class ()
 
static ClassPtr api_error_class ()
 
static ClassPtr language_error_class ()
 
static ClassPtr unhandled_exception_class ()
 
static ClassPtr unwind_error_class ()
 
static ClassPtr singletargetcache_class ()
 
static ClassPtr unlinkedcall_class ()
 
static ClassPtr monomorphicsmiablecall_class ()
 
static ClassPtr icdata_class ()
 
static ClassPtr megamorphic_cache_class ()
 
static ClassPtr subtypetestcache_class ()
 
static ClassPtr loadingunit_class ()
 
static ClassPtr weak_serialization_reference_class ()
 
static ClassPtr weak_array_class ()
 
static void InitNullAndBool (IsolateGroup *isolate_group)
 
static void Init (IsolateGroup *isolate_group)
 
static void InitVtables ()
 
static void FinishInit (IsolateGroup *isolate_group)
 
static void FinalizeVMIsolate (IsolateGroup *isolate_group)
 
static void FinalizeReadOnlyObject (ObjectPtr object)
 
static void Cleanup ()
 
static ErrorPtr Init (IsolateGroup *isolate_group, const uint8_t *kernel_buffer, intptr_t kernel_buffer_size)
 
static void MakeUnusedSpaceTraversable (const Object &obj, intptr_t original_size, intptr_t used_size)
 
static intptr_t InstanceSize ()
 
template<class FakeObject >
static void VerifyBuiltinVtable (intptr_t cid)
 
static void VerifyBuiltinVtables ()
 
static bool ShouldHaveImmutabilityBitSet (classid_t class_id)
 

Private Member Functions

virtual uword ComputeHash () const
 

Friends

class Class
 

Additional Inherited Members

- Public Types inherited from dart::Object
enum  NameVisibility { kInternalName = 0 , kScrubbedName , kUserVisibleName }
 
enum class  NameDisambiguation { kYes , kNo }
 
using UntaggedObjectType = UntaggedObject
 
using ObjectPtrType = ObjectPtr
 
- Static Public Attributes inherited from dart::Object
static constexpr intptr_t kHashBits = 30
 
static const ClassId kClassId = kObjectCid
 
- Protected Member Functions inherited from dart::AbstractType
bool IsNullabilityEquivalent (Thread *thread, const AbstractType &other_type, TypeEquality kind) const
 
void SetHash (intptr_t value) const
 
UntaggedAbstractType::TypeState type_state () const
 
void set_flags (uint32_t value) const
 
void set_type_state (UntaggedAbstractType::TypeState value) const
 
void set_nullability (Nullability value) const
 
 HEAP_OBJECT_IMPLEMENTATION (AbstractType, Instance)
 
- Protected Member Functions inherited from dart::Instance
virtual void PrintSharedInstanceJSON (JSONObject *jsobj, bool ref, bool include_id=true) const
 
- Protected Member Functions inherited from dart::Object
 Object ()
 
uword raw_value () const
 
void setPtr (ObjectPtr value, intptr_t default_cid)
 
void CheckHandle () const
 
cpp_vtable vtable () const
 
void set_vtable (cpp_vtable value)
 
bool Contains (uword addr) const
 
template<typename type , std::memory_order order = std::memory_order_relaxed>
type LoadPointer (type const *addr) const
 
template<typename type , std::memory_order order = std::memory_order_relaxed>
void StorePointer (type const *addr, type value) const
 
template<typename type , typename compressed_type , std::memory_order order = std::memory_order_relaxed>
void StoreCompressedPointer (compressed_type const *addr, type value) const
 
template<typename type >
void StorePointerUnaligned (type const *addr, type value, Thread *thread) const
 
void StoreSmi (SmiPtr const *addr, SmiPtr value) const
 
template<typename FieldType >
void StoreSimd128 (const FieldType *addr, simd128_value_t value) const
 
template<typename FieldType >
FieldType LoadNonPointer (const FieldType *addr) const
 
template<typename FieldType , std::memory_order order>
FieldType LoadNonPointer (const FieldType *addr) const
 
template<typename FieldType , typename ValueType >
void StoreNonPointer (const FieldType *addr, ValueType value) const
 
template<typename FieldType , typename ValueType , std::memory_order order>
void StoreNonPointer (const FieldType *addr, ValueType value) const
 
template<typename FieldType >
FieldType * UnsafeMutableNonPointer (const FieldType *addr) const
 
 CLASS_LIST (STORE_NON_POINTER_ILLEGAL_TYPE)
 
void UnimplementedMethod () const
 
void AddCommonObjectProperties (JSONObject *jsobj, const char *protocol_type, bool ref) const
 
- Static Protected Member Functions inherited from dart::Object
static DART_NOINLINE ObjectHandleImpl (Zone *zone, ObjectPtr ptr, intptr_t default_cid)
 
static DART_NOINLINE ObjectZoneHandleImpl (Zone *zone, ObjectPtr ptr, intptr_t default_cid)
 
static DART_NOINLINE ObjectReadOnlyHandleImpl (intptr_t cid)
 
static ObjectPtr Allocate (intptr_t cls_id, intptr_t size, Heap::Space space, bool compressed, uword ptr_field_start_offset, uword ptr_field_end_offset)
 
template<typename T >
static DART_FORCE_INLINE T::ObjectPtrType Allocate (Heap::Space space)
 
template<typename T >
static DART_FORCE_INLINE T::ObjectPtrType Allocate (Heap::Space space, intptr_t elements)
 
template<typename T >
static DART_FORCE_INLINE T::ObjectPtrType AllocateVariant (intptr_t class_id, Heap::Space space)
 
template<typename T >
static DART_FORCE_INLINE T::ObjectPtrType AllocateVariant (intptr_t class_id, Heap::Space space, intptr_t elements)
 
static constexpr intptr_t RoundedAllocationSize (intptr_t size)
 
static ObjectPtr Clone (const Object &orig, Heap::Space space, bool load_with_relaxed_atomics=false)
 
template<typename T >
static DART_FORCE_INLINE uword from_offset ()
 
template<typename T >
static DART_FORCE_INLINE uword to_offset (intptr_t length=0)
 
- Protected Attributes inherited from dart::Object
ObjectPtr ptr_
 

Detailed Description

Definition at line 9807 of file object.h.

Member Function Documentation

◆ base()

intptr_t dart::TypeParameter::base ( ) const
inline

Definition at line 9819 of file object.h.

9819{ return untag()->base_; }
raw_obj untag() -> num_entries()) VARIABLE_COMPRESSED_VISITOR(Array, Smi::Value(raw_obj->untag() ->length())) VARIABLE_COMPRESSED_VISITOR(TypedData, TypedData::ElementSizeInBytes(raw_obj->GetClassId()) *Smi::Value(raw_obj->untag() ->length())) VARIABLE_COMPRESSED_VISITOR(Record, RecordShape(raw_obj->untag() ->shape()).num_fields()) VARIABLE_NULL_VISITOR(CompressedStackMaps, CompressedStackMaps::PayloadSizeOf(raw_obj)) VARIABLE_NULL_VISITOR(OneByteString, Smi::Value(raw_obj->untag() ->length())) VARIABLE_NULL_VISITOR(TwoByteString, Smi::Value(raw_obj->untag() ->length())) intptr_t UntaggedField::VisitFieldPointers(FieldPtr raw_obj, ObjectPointerVisitor *visitor)
Definition: raw_object.cc:558

◆ bound()

AbstractTypePtr dart::TypeParameter::bound ( ) const

Definition at line 22737 of file object.cc.

22737 {
22740 const auto& type_parameters =
22741 TypeParameters::Handle(owner.type_parameters());
22742 return type_parameters.BoundAt(index() - base());
22743 } else {
22744 const auto& owner = Class::Handle(parameterized_class());
22745 if (owner.IsNull()) {
22746 return IsolateGroup::Current()->object_store()->nullable_object_type();
22747 }
22748 const auto& type_parameters =
22749 TypeParameters::Handle(owner.type_parameters());
22750 return type_parameters.BoundAt(index() - base());
22751 }
22752}
ObjectStore * object_store() const
Definition: isolate.h:510
static IsolateGroup * Current()
Definition: isolate.h:539
static Object & Handle()
Definition: object.h:407
intptr_t index() const
Definition: object.h:9821
ClassPtr parameterized_class() const
Definition: object.cc:22710
intptr_t base() const
Definition: object.h:9819
bool IsFunctionTypeParameter() const
Definition: object.h:9813
FunctionTypePtr parameterized_function_type() const
Definition: object.cc:22720

◆ Canonicalize()

AbstractTypePtr dart::TypeParameter::Canonicalize ( Thread thread) const
virtual

Reimplemented from dart::AbstractType.

Definition at line 22859 of file object.cc.

22859 {
22861 Zone* zone = thread->zone();
22862 if (IsCanonical()) {
22863#ifdef DEBUG
22866 }
22867#endif
22868 return this->ptr();
22869 }
22870 auto isolate_group = thread->isolate_group();
22871 ObjectStore* object_store = isolate_group->object_store();
22872 TypeParameter& type_parameter = TypeParameter::Handle(zone);
22873 {
22874 SafepointMutexLocker ml(isolate_group->type_canonicalization_mutex());
22876 object_store->canonical_type_parameters());
22877 type_parameter ^= table.GetOrNull(CanonicalTypeParameterKey(*this));
22878 if (type_parameter.IsNull()) {
22879 // Add this type parameter into the canonical table of type parameters.
22880 if (this->IsNew()) {
22881 type_parameter ^= Object::Clone(*this, Heap::kOld);
22882 } else {
22883 type_parameter = this->ptr();
22884 }
22885 ASSERT(type_parameter.IsOld());
22886 type_parameter.SetCanonical(); // Mark object as being canonical.
22887 bool present = table.Insert(type_parameter);
22888 ASSERT(!present);
22889 }
22890 object_store->set_canonical_type_parameters(table.Release());
22891 }
22892 return type_parameter.ptr();
22893}
SI F table(const skcms_Curve *curve, F v)
bool IsFinalized() const
Definition: object.h:9053
@ kOld
Definition: heap.h:39
static ObjectPtr Clone(const Object &orig, Heap::Space space, bool load_with_relaxed_atomics=false)
Definition: object.cc:2899
ObjectPtr ptr() const
Definition: object.h:332
bool IsCanonical() const
Definition: object.h:335
bool IsNew() const
Definition: object.h:390
bool IsOld() const
Definition: object.h:391
#define ASSERT(E)
UnorderedHashSet< CanonicalTypeParameterTraits > CanonicalTypeParameterSet

◆ CanonicalNameCString() [1/2]

const char * dart::TypeParameter::CanonicalNameCString ( ) const
inline

Definition at line 9869 of file object.h.

9869 {
9871 }
bool IsClassTypeParameter() const
Definition: object.h:9817
const char * CanonicalNameCString() const
Definition: object.h:9869

◆ CanonicalNameCString() [2/2]

const char * dart::TypeParameter::CanonicalNameCString ( bool  is_class_type_parameter,
intptr_t  base,
intptr_t  index 
)
static

Definition at line 22946 of file object.cc.

22948 {
22949 Thread* thread = Thread::Current();
22950 ZoneTextBuffer printer(thread->zone());
22951 const char* base_fmt = is_class_type_parameter ? "C%" Pd : "F%" Pd;
22952 const char* index_fmt = is_class_type_parameter ? "X%" Pd : "Y%" Pd;
22953 if (base != 0) {
22954 printer.Printf(base_fmt, base);
22955 }
22956 printer.Printf(index_fmt, index - base);
22957 return printer.buffer();
22958}
friend class Thread
Definition: object.h:1025
static Thread * Current()
Definition: thread.h:362
#define Pd
Definition: globals.h:408

◆ ComputeHash()

uword dart::TypeParameter::ComputeHash ( ) const
privatevirtual

Reimplemented from dart::AbstractType.

Definition at line 22903 of file object.cc.

22903 {
22905 uint32_t result = parameterized_class_id();
22908 result = CombineHashes(result, static_cast<uint32_t>(nullability()));
22910 SetHash(result);
22911 return result;
22912}
void SetHash(intptr_t value) const
Definition: object.h:13386
Nullability nullability() const
Definition: object.h:9060
static constexpr intptr_t kHashBits
Definition: object.h:323
classid_t parameterized_class_id() const
Definition: object.cc:22698
GAsyncResult * result
uint32_t CombineHashes(uint32_t hash, uint32_t other_hash)
Definition: hash.h:12
uint32_t FinalizeHash(uint32_t hash, intptr_t hashbits=kBitsPerInt32)
Definition: hash.h:20

◆ EnumerateURIs()

virtual void dart::TypeParameter::EnumerateURIs ( URIs uris) const
inlinevirtual

Reimplemented from dart::AbstractType.

Definition at line 9856 of file object.h.

9856{ return; }

◆ GetFromTypeArguments()

AbstractTypePtr dart::TypeParameter::GetFromTypeArguments ( const TypeArguments instantiator_type_arguments,
const TypeArguments function_type_arguments 
) const

Definition at line 22754 of file object.cc.

22756 {
22758 const TypeArguments& type_args = IsFunctionTypeParameter()
22759 ? function_type_arguments
22760 : instantiator_type_arguments;
22761 return type_args.TypeAtNullSafe(index());
22762}
friend class TypeArguments
Definition: object.h:9363

◆ HasTypeClass()

virtual bool dart::TypeParameter::HasTypeClass ( ) const
inlinevirtual

Reimplemented from dart::AbstractType.

Definition at line 9810 of file object.h.

9810{ return false; }

◆ index()

intptr_t dart::TypeParameter::index ( ) const
inline

Definition at line 9821 of file object.h.

9821{ return untag()->index_; }

◆ index_offset()

static intptr_t dart::TypeParameter::index_offset ( )
inlinestatic

Definition at line 9823 of file object.h.

9823 {
9824 return OFFSET_OF(UntaggedTypeParameter, index_);
9825 }
#define OFFSET_OF(type, field)
Definition: globals.h:138

◆ InstanceSize()

static intptr_t dart::TypeParameter::InstanceSize ( )
inlinestatic

Definition at line 9877 of file object.h.

9877 {
9878 return RoundedAllocationSize(sizeof(UntaggedTypeParameter));
9879 }
static constexpr intptr_t RoundedAllocationSize(intptr_t size)
Definition: object.h:758

◆ InstantiateFrom()

AbstractTypePtr dart::TypeParameter::InstantiateFrom ( const TypeArguments instantiator_type_arguments,
const TypeArguments function_type_arguments,
intptr_t  num_free_fun_type_params,
Heap::Space  space,
FunctionTypeMapping function_type_mapping = nullptr,
intptr_t  num_parent_type_args_adjustment = 0 
) const
virtual

Reimplemented from dart::AbstractType.

Definition at line 22764 of file object.cc.

22770 {
22771 Zone* zone = Thread::Current()->zone();
22772 AbstractType& result = AbstractType::Handle(zone);
22773 bool substituted = false;
22776 if (index() >= num_free_fun_type_params) {
22777 // Do not instantiate the function type parameter.
22778 // Get a replacement from the updated function type.
22779 ASSERT(function_type_mapping != nullptr);
22780 result = function_type_mapping->MapTypeParameter(*this);
22781 ASSERT(TypeParameter::Cast(result).index() ==
22782 index() - num_free_fun_type_params);
22783 ASSERT(TypeParameter::Cast(result).base() ==
22784 base() - num_free_fun_type_params);
22785 ASSERT(TypeParameter::Cast(result).nullability() == nullability());
22786 AbstractType& upper_bound = AbstractType::Handle(zone, bound());
22787 if (!upper_bound.IsInstantiated()) {
22788 upper_bound = upper_bound.InstantiateFrom(
22789 instantiator_type_arguments, function_type_arguments,
22790 num_free_fun_type_params, space, function_type_mapping,
22791 num_parent_type_args_adjustment);
22792 }
22793 if (upper_bound.ptr() == Type::NeverType()) {
22794 // Normalize 'X extends Never' to 'Never'.
22796 }
22797 } else if (function_type_arguments.IsNull()) {
22798 return Type::DynamicType();
22799 } else {
22800 result = function_type_arguments.TypeAt(index());
22801 substituted = true;
22802 }
22803 } else {
22806 if (instantiator_type_arguments.IsNull()) {
22807 return Type::DynamicType();
22808 }
22809 if (instantiator_type_arguments.Length() <= index()) {
22810 // InstantiateFrom can be invoked from a compilation pipeline with
22811 // mismatching type arguments vector. This can only happen for
22812 // a dynamically unreachable code - which compiler can't remove
22813 // statically for some reason.
22814 // To prevent crashes we return AbstractType::null(), understood by caller
22815 // (see AssertAssignableInstr::Canonicalize).
22816 return AbstractType::null();
22817 }
22818 result = instantiator_type_arguments.TypeAt(index());
22819 substituted = true;
22820 // Instantiating a class type parameter cannot result in a
22821 // function type parameter.
22822 // Bounds of class type parameters are ignored in the VM.
22823 }
22824 result = result.SetInstantiatedNullability(*this, space);
22825 if (substituted && (num_parent_type_args_adjustment != 0)) {
22826 // This type parameter is used inside a generic function type.
22827 // A type being substituted can have nested function types,
22828 // whose number of parent function type arguments should be adjusted
22829 // after the substitution.
22830 result = result.UpdateFunctionTypes(num_parent_type_args_adjustment,
22831 kAllFree, space, function_type_mapping);
22832 }
22833 // Canonicalization is not part of instantiation.
22834 return result.NormalizeFutureOrType(space);
22835}
static ObjectPtr null()
Definition: object.h:433
Zone * zone() const
Definition: thread_state.h:37
AbstractTypePtr bound() const
Definition: object.cc:22737
static TypePtr NeverType()
static TypePtr DynamicType()
@ kAllFree
Definition: object.h:2940

◆ IsClassTypeParameter()

bool dart::TypeParameter::IsClassTypeParameter ( ) const
inline

Definition at line 9817 of file object.h.

9817{ return !IsFunctionTypeParameter(); }

◆ IsEquivalent()

bool dart::TypeParameter::IsEquivalent ( const Instance other,
TypeEquality  kind,
FunctionTypeMapping function_type_equivalence = nullptr 
) const
virtual

Reimplemented from dart::AbstractType.

Definition at line 22633 of file object.cc.

22636 {
22637 TRACE_TYPE_CHECKS_VERBOSE(" TypeParameter::IsEquivalent(%s, %s, kind %d)\n",
22638 ToCString(), other.ToCString(),
22639 static_cast<int>(kind));
22640 if (ptr() == other.ptr()) {
22641 TRACE_TYPE_CHECKS_VERBOSE(" - result: true (same types)\n");
22642 return true;
22643 }
22644 if (!other.IsTypeParameter()) {
22646 " - result: false (other is not a type parameter)\n");
22647 return false;
22648 }
22649 const TypeParameter& other_type_param = TypeParameter::Cast(other);
22650 ASSERT(IsFinalized() && other_type_param.IsFinalized());
22651 // Compare index, base and owner.
22653 if (!other_type_param.IsFunctionTypeParameter()) {
22655 " - result: false (other is not a function type parameter)\n");
22656 return false;
22657 }
22659 other_type_param.parameterized_function_type()) &&
22660 ((function_type_equivalence == nullptr) ||
22661 !function_type_equivalence->ContainsOwnersOfTypeParameters(
22662 *this, other_type_param))) {
22664 " - result: false (owners are not equivalent)\n");
22665 return false;
22666 }
22667 } else {
22668 if (!other_type_param.IsClassTypeParameter()) {
22670 " - result: false (other is not a class type parameter)\n");
22671 return false;
22672 }
22673 if (parameterized_class_id() != other_type_param.parameterized_class_id()) {
22675 " - result: false (parameterized class id)\n");
22676 return false;
22677 }
22678 }
22679 if (base() != other_type_param.base() ||
22680 index() != other_type_param.index()) {
22681 TRACE_TYPE_CHECKS_VERBOSE(" - result: false (mismatch base/index)\n");
22682 return false;
22683 }
22684 if (!IsNullabilityEquivalent(Thread::Current(), other_type_param, kind)) {
22685 TRACE_TYPE_CHECKS_VERBOSE(" - result: false (mismatch nullability)\n");
22686 return false;
22687 }
22688 TRACE_TYPE_CHECKS_VERBOSE(" - result: true\n");
22689 return true;
22690}
bool IsNullabilityEquivalent(Thread *thread, const AbstractType &other_type, TypeEquality kind) const
Definition: object.cc:21196
virtual const char * ToCString() const
Definition: object.h:366
#define TRACE_TYPE_CHECKS_VERBOSE(format,...)
Definition: object.cc:226

◆ IsFunctionTypeParameter()

bool dart::TypeParameter::IsFunctionTypeParameter ( ) const
inline

Definition at line 9813 of file object.h.

9813 {
9815 untag()->flags());
9816 }
static constexpr T decode(S value)
Definition: bitfield.h:171
FlutterSemanticsFlag flags

◆ IsInstantiated()

bool dart::TypeParameter::IsInstantiated ( Genericity  genericity = kAny,
intptr_t  num_free_fun_type_params = kAllFree 
) const
virtual

Reimplemented from dart::AbstractType.

Definition at line 22623 of file object.cc.

22624 {
22625 // Bounds of class type parameters are ignored in the VM.
22626 if (IsClassTypeParameter()) {
22627 return genericity == kFunctions;
22628 }
22630 return (genericity == kCurrentClass) || (index() >= num_free_fun_type_params);
22631}
@ kFunctions
Definition: object.h:2251
@ kCurrentClass
Definition: object.h:2250

◆ New()

TypeParameterPtr dart::TypeParameter::New ( const Object owner,
intptr_t  base,
intptr_t  index,
Nullability  nullability 
)
static

Definition at line 22918 of file object.cc.

22921 {
22922 ASSERT(owner.IsNull() || owner.IsClass() || owner.IsFunctionType());
22923 const bool is_function_type_parameter = owner.IsFunctionType();
22925 is_function_type_parameter);
22926 Zone* Z = Thread::Current()->zone();
22927 const TypeParameter& result = TypeParameter::Handle(Z, TypeParameter::New());
22928 result.set_flags(flags);
22929 if (is_function_type_parameter) {
22930 result.set_owner(owner);
22931 } else {
22932 result.set_parameterized_class_id(owner.IsNull() ? kIllegalCid
22933 : Class::Cast(owner).id());
22934 }
22935 result.set_base(base);
22936 result.set_index(index);
22937 result.SetHash(0);
22938 result.set_nullability(nullability);
22940
22941 result.InitializeTypeTestingStubNonAtomic(
22943 return result.ptr();
22944}
#define Z
static constexpr S encode(T value)
Definition: bitfield.h:165
static CodePtr DefaultCodeForType(const AbstractType &type, bool lazy_specialize=true)
@ kIllegalCid
Definition: class_id.h:214

◆ parameterized_class()

ClassPtr dart::TypeParameter::parameterized_class ( ) const

Definition at line 22710 of file object.cc.

22710 {
22711 if (IsClassTypeParameter()) {
22713 if (cid != kIllegalCid) {
22715 }
22716 }
22717 return Class::null();
22718}
ClassPtr At(intptr_t cid) const
Definition: class_table.h:362
ClassTable * class_table() const
Definition: isolate.h:496
int32_t classid_t
Definition: globals.h:524
const intptr_t cid

◆ parameterized_class_id()

classid_t dart::TypeParameter::parameterized_class_id ( ) const

Definition at line 22698 of file object.cc.

22698 {
22699 if (IsClassTypeParameter()) {
22700 return Smi::Value(Smi::RawCast(untag()->owner()));
22701 } else {
22702 return kFunctionCid;
22703 }
22704}
static ObjectPtr RawCast(ObjectPtr obj)
Definition: object.h:325
intptr_t Value() const
Definition: object.h:9990

◆ parameterized_function_type()

FunctionTypePtr dart::TypeParameter::parameterized_function_type ( ) const

Definition at line 22720 of file object.cc.

22720 {
22722 return FunctionType::RawCast(untag()->owner());
22723}

◆ PrintName()

void dart::TypeParameter::PrintName ( NameVisibility  visibility,
BaseTextBuffer printer 
) const
virtual

Reimplemented from dart::AbstractType.

Definition at line 22895 of file object.cc.

22896 {
22897 const TypeParameter& type_param = TypeParameter::Cast(*this);
22898 // Type parameter names are meaningless after canonicalization.
22899 printer->AddString(type_param.CanonicalNameCString());
22900 printer->AddString(NullabilitySuffix(name_visibility));
22901}
virtual const char * NullabilitySuffix(NameVisibility name_visibility) const
Definition: object.cc:21303

◆ set_base()

void dart::TypeParameter::set_base ( intptr_t  value) const

Definition at line 22725 of file object.cc.

22725 {
22726 ASSERT(value >= 0);
22728 StoreNonPointer(&untag()->base_, value);
22729}
void StoreNonPointer(const FieldType *addr, ValueType value) const
Definition: object.h:819
static bool IsUint(intptr_t N, T value)
Definition: utils.h:328
uint8_t value

◆ set_index()

void dart::TypeParameter::set_index ( intptr_t  value) const

Definition at line 22731 of file object.cc.

22731 {
22732 ASSERT(value >= 0);
22734 StoreNonPointer(&untag()->index_, value);
22735}

◆ set_parameterized_class_id()

void dart::TypeParameter::set_parameterized_class_id ( classid_t  value) const

Definition at line 22705 of file object.cc.

22705 {
22707 untag()->set_owner(Smi::New(value));
22708}
static SmiPtr New(intptr_t value)
Definition: object.h:10006

◆ ToNullability()

TypeParameterPtr dart::TypeParameter::ToNullability ( Nullability  value,
Heap::Space  space 
) const

Definition at line 22601 of file object.cc.

22602 {
22603 if (nullability() == value) {
22604 return ptr();
22605 }
22606 // Clone type parameter and set new nullability.
22607 TypeParameter& type_parameter = TypeParameter::Handle();
22608 type_parameter ^= Object::Clone(*this, space);
22609 type_parameter.set_nullability(value);
22610 type_parameter.SetHash(0);
22611 type_parameter.InitializeTypeTestingStubNonAtomic(Code::Handle(
22613 if (IsCanonical()) {
22614 // Object::Clone does not clone canonical bit.
22615 ASSERT(!type_parameter.IsCanonical());
22617 ASSERT(type_parameter.IsFinalized());
22618 type_parameter ^= type_parameter.Canonicalize(Thread::Current());
22619 }
22620 return type_parameter.ptr();
22621}

◆ type_class_id()

virtual classid_t dart::TypeParameter::type_class_id ( ) const
inlinevirtual

Reimplemented from dart::AbstractType.

Definition at line 9811 of file object.h.

9811{ return kIllegalCid; }

◆ UpdateFunctionTypes()

AbstractTypePtr dart::TypeParameter::UpdateFunctionTypes ( intptr_t  num_parent_type_args_adjustment,
intptr_t  num_free_fun_type_params,
Heap::Space  space,
FunctionTypeMapping function_type_mapping 
) const
virtual

Reimplemented from dart::AbstractType.

Definition at line 22837 of file object.cc.

22841 {
22843 ASSERT(num_parent_type_args_adjustment >= 0);
22844 if (IsFunctionTypeParameter() && (index() >= num_free_fun_type_params)) {
22845 Zone* zone = Thread::Current()->zone();
22846 ASSERT(function_type_mapping != nullptr);
22847 const auto& new_tp = TypeParameter::Handle(
22848 zone, function_type_mapping->MapTypeParameter(*this));
22849 ASSERT(new_tp.base() == base() + num_parent_type_args_adjustment);
22850 ASSERT(new_tp.index() == index() + num_parent_type_args_adjustment);
22851 ASSERT(new_tp.nullability() == nullability());
22852 ASSERT(new_tp.IsFinalized());
22853 return new_tp.ptr();
22854 } else {
22855 return ptr();
22856 }
22857}

Friends And Related Function Documentation

◆ Class

friend class Class
friend

Definition at line 9895 of file object.h.


The documentation for this class was generated from the following files: