Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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 IsLegacy () const
 
bool IsStrictlyNonNullable () const
 
virtual AbstractTypePtr SetInstantiatedNullability (const TypeParameter &type_param, Heap::Space space) const
 
virtual AbstractTypePtr NormalizeFutureOrType (Heap::Space space) const
 
virtual ClassPtr type_class () const
 
virtual TypeArgumentsPtr arguments () const
 
virtual bool CanonicalizeEquals (const Instance &other) const
 
virtual uint32_t CanonicalizeHash () const
 
virtual bool Equals (const Instance &other) const
 
virtual InstancePtr CanonicalizeLocked (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
 
uword Hash () 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
 
intptr_t SizeFromClass () const
 
InstancePtr Canonicalize (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 9786 of file object.h.

Member Function Documentation

◆ base()

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

Definition at line 9798 of file object.h.

9798{ 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)

◆ bound()

AbstractTypePtr dart::TypeParameter::bound ( ) const

Definition at line 22810 of file object.cc.

22810 {
22813 const auto& type_parameters =
22814 TypeParameters::Handle(owner.type_parameters());
22815 return type_parameters.BoundAt(index() - base());
22816 } else {
22817 const auto& owner = Class::Handle(parameterized_class());
22818 if (owner.IsNull()) {
22819 return IsolateGroup::Current()->object_store()->nullable_object_type();
22820 }
22821 const auto& type_parameters =
22822 TypeParameters::Handle(owner.type_parameters());
22823 return type_parameters.BoundAt(index() - base());
22824 }
22825}
ObjectStore * object_store() const
Definition isolate.h:505
static IsolateGroup * Current()
Definition isolate.h:534
static Object & Handle()
Definition object.h:407
intptr_t index() const
Definition object.h:9800
ClassPtr parameterized_class() const
Definition object.cc:22783
intptr_t base() const
Definition object.h:9798
bool IsFunctionTypeParameter() const
Definition object.h:9792
FunctionTypePtr parameterized_function_type() const
Definition object.cc:22793

◆ Canonicalize()

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

Reimplemented from dart::AbstractType.

Definition at line 22932 of file object.cc.

22932 {
22934 Zone* zone = thread->zone();
22935 if (IsCanonical()) {
22936#ifdef DEBUG
22939 }
22940#endif
22941 return this->ptr();
22942 }
22943 auto isolate_group = thread->isolate_group();
22944 ObjectStore* object_store = isolate_group->object_store();
22945 TypeParameter& type_parameter = TypeParameter::Handle(zone);
22946 {
22947 SafepointMutexLocker ml(isolate_group->type_canonicalization_mutex());
22949 object_store->canonical_type_parameters());
22950 type_parameter ^= table.GetOrNull(CanonicalTypeParameterKey(*this));
22951 if (type_parameter.IsNull()) {
22952 // Add this type parameter into the canonical table of type parameters.
22953 if (this->IsNew()) {
22954 type_parameter ^= Object::Clone(*this, Heap::kOld);
22955 } else {
22956 type_parameter = this->ptr();
22957 }
22958 ASSERT(type_parameter.IsOld());
22959 type_parameter.SetCanonical(); // Mark object as being canonical.
22960 bool present = table.Insert(type_parameter);
22961 ASSERT(!present);
22962 }
22963 object_store->set_canonical_type_parameters(table.Release());
22964 }
22965 return type_parameter.ptr();
22966}
SI F table(const skcms_Curve *curve, F v)
bool IsFinalized() const
Definition object.h:9030
@ kOld
Definition heap.h:39
static ObjectPtr Clone(const Object &orig, Heap::Space space, bool load_with_relaxed_atomics=false)
Definition object.cc:2960
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 9848 of file object.h.

9848 {
9850 }
bool IsClassTypeParameter() const
Definition object.h:9796
const char * CanonicalNameCString() const
Definition object.h:9848

◆ CanonicalNameCString() [2/2]

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

Definition at line 23025 of file object.cc.

23027 {
23028 Thread* thread = Thread::Current();
23029 ZoneTextBuffer printer(thread->zone());
23030 const char* base_fmt = is_class_type_parameter ? "C%" Pd : "F%" Pd;
23031 const char* index_fmt = is_class_type_parameter ? "X%" Pd : "Y%" Pd;
23032 if (base != 0) {
23033 printer.Printf(base_fmt, base);
23034 }
23035 printer.Printf(index_fmt, index - base);
23036 return printer.buffer();
23037}
static Thread * Current()
Definition thread.h:361
#define Pd
Definition globals.h:408

◆ ComputeHash()

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

Reimplemented from dart::AbstractType.

Definition at line 22976 of file object.cc.

22976 {
22978 uint32_t result = parameterized_class_id();
22981 // A legacy type should have the same hash as its non-nullable version to be
22982 // consistent with the definition of type equality in Dart code.
22983 Nullability type_param_nullability = nullability();
22984 if (type_param_nullability == Nullability::kLegacy) {
22985 type_param_nullability = Nullability::kNonNullable;
22986 }
22987 result = CombineHashes(result, static_cast<uint32_t>(type_param_nullability));
22989 SetHash(result);
22990 return result;
22991}
void SetHash(intptr_t value) const
Definition object.h:13360
Nullability nullability() const
Definition object.h:9037
static constexpr intptr_t kHashBits
Definition object.h:323
classid_t parameterized_class_id() const
Definition object.cc:22771
GAsyncResult * result
Nullability
Definition object.h:1112
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 9835 of file object.h.

9835{ return; }

◆ GetFromTypeArguments()

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

Definition at line 22827 of file object.cc.

22829 {
22831 const TypeArguments& type_args = IsFunctionTypeParameter()
22832 ? function_type_arguments
22833 : instantiator_type_arguments;
22834 return type_args.TypeAtNullSafe(index());
22835}
friend class TypeArguments
Definition object.h:9343

◆ HasTypeClass()

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

Reimplemented from dart::AbstractType.

Definition at line 9789 of file object.h.

9789{ return false; }

◆ index()

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

Definition at line 9800 of file object.h.

9800{ return untag()->index_; }

◆ index_offset()

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

Definition at line 9802 of file object.h.

9802 {
9803 return OFFSET_OF(UntaggedTypeParameter, index_);
9804 }
#define OFFSET_OF(type, field)
Definition globals.h:138

◆ InstanceSize()

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

Definition at line 9856 of file object.h.

9856 {
9857 return RoundedAllocationSize(sizeof(UntaggedTypeParameter));
9858 }
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 22837 of file object.cc.

22843 {
22844 Zone* zone = Thread::Current()->zone();
22845 AbstractType& result = AbstractType::Handle(zone);
22846 bool substituted = false;
22849 if (index() >= num_free_fun_type_params) {
22850 // Do not instantiate the function type parameter.
22851 // Get a replacement from the updated function type.
22852 ASSERT(function_type_mapping != nullptr);
22853 result = function_type_mapping->MapTypeParameter(*this);
22854 ASSERT(TypeParameter::Cast(result).index() ==
22855 index() - num_free_fun_type_params);
22856 ASSERT(TypeParameter::Cast(result).base() ==
22857 base() - num_free_fun_type_params);
22858 ASSERT(TypeParameter::Cast(result).nullability() == nullability());
22859 AbstractType& upper_bound = AbstractType::Handle(zone, bound());
22860 if (!upper_bound.IsInstantiated()) {
22861 upper_bound = upper_bound.InstantiateFrom(
22862 instantiator_type_arguments, function_type_arguments,
22863 num_free_fun_type_params, space, function_type_mapping,
22864 num_parent_type_args_adjustment);
22865 }
22866 if (upper_bound.ptr() == Type::NeverType()) {
22867 // Normalize 'X extends Never' to 'Never'.
22869 }
22870 } else if (function_type_arguments.IsNull()) {
22871 return Type::DynamicType();
22872 } else {
22873 result = function_type_arguments.TypeAt(index());
22874 substituted = true;
22875 }
22876 } else {
22879 if (instantiator_type_arguments.IsNull()) {
22880 return Type::DynamicType();
22881 }
22882 if (instantiator_type_arguments.Length() <= index()) {
22883 // InstantiateFrom can be invoked from a compilation pipeline with
22884 // mismatching type arguments vector. This can only happen for
22885 // a dynamically unreachable code - which compiler can't remove
22886 // statically for some reason.
22887 // To prevent crashes we return AbstractType::null(), understood by caller
22888 // (see AssertAssignableInstr::Canonicalize).
22889 return AbstractType::null();
22890 }
22891 result = instantiator_type_arguments.TypeAt(index());
22892 substituted = true;
22893 // Instantiating a class type parameter cannot result in a
22894 // function type parameter.
22895 // Bounds of class type parameters are ignored in the VM.
22896 }
22897 result = result.SetInstantiatedNullability(*this, space);
22898 if (substituted && (num_parent_type_args_adjustment != 0)) {
22899 // This type parameter is used inside a generic function type.
22900 // A type being substituted can have nested function types,
22901 // whose number of parent function type arguments should be adjusted
22902 // after the substitution.
22903 result = result.UpdateFunctionTypes(num_parent_type_args_adjustment,
22904 kAllFree, space, function_type_mapping);
22905 }
22906 // Canonicalization is not part of instantiation.
22907 return result.NormalizeFutureOrType(space);
22908}
static ObjectPtr null()
Definition object.h:433
Zone * zone() const
AbstractTypePtr bound() const
Definition object.cc:22810
static TypePtr NeverType()
Definition object.cc:21874
static TypePtr DynamicType()
Definition object.cc:21866
@ kAllFree
Definition object.h:2920

◆ IsClassTypeParameter()

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

Definition at line 9796 of file object.h.

9796{ 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 22706 of file object.cc.

22709 {
22710 TRACE_TYPE_CHECKS_VERBOSE(" TypeParameter::IsEquivalent(%s, %s, kind %d)\n",
22711 ToCString(), other.ToCString(),
22712 static_cast<int>(kind));
22713 if (ptr() == other.ptr()) {
22714 TRACE_TYPE_CHECKS_VERBOSE(" - result: true (same types)\n");
22715 return true;
22716 }
22717 if (!other.IsTypeParameter()) {
22719 " - result: false (other is not a type parameter)\n");
22720 return false;
22721 }
22722 const TypeParameter& other_type_param = TypeParameter::Cast(other);
22723 ASSERT(IsFinalized() && other_type_param.IsFinalized());
22724 // Compare index, base and owner.
22726 if (!other_type_param.IsFunctionTypeParameter()) {
22728 " - result: false (other is not a function type parameter)\n");
22729 return false;
22730 }
22732 other_type_param.parameterized_function_type()) &&
22733 ((function_type_equivalence == nullptr) ||
22734 !function_type_equivalence->ContainsOwnersOfTypeParameters(
22735 *this, other_type_param))) {
22737 " - result: false (owners are not equivalent)\n");
22738 return false;
22739 }
22740 } else {
22741 if (!other_type_param.IsClassTypeParameter()) {
22743 " - result: false (other is not a class type parameter)\n");
22744 return false;
22745 }
22746 if (parameterized_class_id() != other_type_param.parameterized_class_id()) {
22748 " - result: false (parameterized class id)\n");
22749 return false;
22750 }
22751 }
22752 if (base() != other_type_param.base() ||
22753 index() != other_type_param.index()) {
22754 TRACE_TYPE_CHECKS_VERBOSE(" - result: false (mismatch base/index)\n");
22755 return false;
22756 }
22757 if (!IsNullabilityEquivalent(Thread::Current(), other_type_param, kind)) {
22758 TRACE_TYPE_CHECKS_VERBOSE(" - result: false (mismatch nullability)\n");
22759 return false;
22760 }
22761 TRACE_TYPE_CHECKS_VERBOSE(" - result: true\n");
22762 return true;
22763}
bool IsNullabilityEquivalent(Thread *thread, const AbstractType &other_type, TypeEquality kind) const
Definition object.cc:21245
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 9792 of file object.h.

9792 {
9794 untag()->flags());
9795 }
static constexpr T decode(S value)
Definition bitfield.h:173
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 22696 of file object.cc.

22697 {
22698 // Bounds of class type parameters are ignored in the VM.
22699 if (IsClassTypeParameter()) {
22700 return genericity == kFunctions;
22701 }
22703 return (genericity == kCurrentClass) || (index() >= num_free_fun_type_params);
22704}
@ kFunctions
Definition object.h:2231
@ kCurrentClass
Definition object.h:2230

◆ New()

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

Definition at line 22997 of file object.cc.

23000 {
23001 ASSERT(owner.IsNull() || owner.IsClass() || owner.IsFunctionType());
23002 const bool is_function_type_parameter = owner.IsFunctionType();
23004 is_function_type_parameter);
23005 Zone* Z = Thread::Current()->zone();
23006 const TypeParameter& result = TypeParameter::Handle(Z, TypeParameter::New());
23007 result.set_flags(flags);
23008 if (is_function_type_parameter) {
23009 result.set_owner(owner);
23010 } else {
23011 result.set_parameterized_class_id(owner.IsNull() ? kIllegalCid
23012 : Class::Cast(owner).id());
23013 }
23014 result.set_base(base);
23015 result.set_index(index);
23016 result.SetHash(0);
23017 result.set_nullability(nullability);
23019
23020 result.InitializeTypeTestingStubNonAtomic(
23022 return result.ptr();
23023}
#define Z
static constexpr S encode(T value)
Definition bitfield.h:167
friend class Class
Definition object.h:9874
static CodePtr DefaultCodeForType(const AbstractType &type, bool lazy_specialize=true)
@ kIllegalCid
Definition class_id.h:214
const uintptr_t id

◆ parameterized_class()

ClassPtr dart::TypeParameter::parameterized_class ( ) const

Definition at line 22783 of file object.cc.

22783 {
22784 if (IsClassTypeParameter()) {
22786 if (cid != kIllegalCid) {
22788 }
22789 }
22790 return Class::null();
22791}
ClassPtr At(intptr_t cid) const
ClassTable * class_table() const
Definition isolate.h:491
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 22771 of file object.cc.

22771 {
22772 if (IsClassTypeParameter()) {
22773 return Smi::Value(Smi::RawCast(untag()->owner()));
22774 } else {
22775 return kFunctionCid;
22776 }
22777}
static ObjectPtr RawCast(ObjectPtr obj)
Definition object.h:325
intptr_t Value() const
Definition object.h:9969

◆ parameterized_function_type()

FunctionTypePtr dart::TypeParameter::parameterized_function_type ( ) const

Definition at line 22793 of file object.cc.

22793 {
22795 return FunctionType::RawCast(untag()->owner());
22796}

◆ PrintName()

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

Reimplemented from dart::AbstractType.

Definition at line 22968 of file object.cc.

22969 {
22970 const TypeParameter& type_param = TypeParameter::Cast(*this);
22971 // Type parameter names are meaningless after canonicalization.
22972 printer->AddString(type_param.CanonicalNameCString());
22973 printer->AddString(NullabilitySuffix(name_visibility));
22974}
virtual const char * NullabilitySuffix(NameVisibility name_visibility) const
Definition object.cc:21360

◆ set_base()

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

Definition at line 22798 of file object.cc.

22798 {
22799 ASSERT(value >= 0);
22800 ASSERT(Utils::IsUint(16, value));
22801 StoreNonPointer(&untag()->base_, value);
22802}
void StoreNonPointer(const FieldType *addr, ValueType value) const
Definition object.h:819
static bool IsUint(intptr_t N, T value)
Definition utils.h:313

◆ set_index()

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

Definition at line 22804 of file object.cc.

22804 {
22805 ASSERT(value >= 0);
22806 ASSERT(Utils::IsUint(16, value));
22807 StoreNonPointer(&untag()->index_, value);
22808}

◆ set_parameterized_class_id()

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

Definition at line 22778 of file object.cc.

22778 {
22780 untag()->set_owner(Smi::New(value));
22781}
static SmiPtr New(intptr_t value)
Definition object.h:9985

◆ ToNullability()

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

Definition at line 22674 of file object.cc.

22675 {
22676 if (nullability() == value) {
22677 return ptr();
22678 }
22679 // Clone type parameter and set new nullability.
22680 TypeParameter& type_parameter = TypeParameter::Handle();
22681 type_parameter ^= Object::Clone(*this, space);
22682 type_parameter.set_nullability(value);
22683 type_parameter.SetHash(0);
22684 type_parameter.InitializeTypeTestingStubNonAtomic(Code::Handle(
22686 if (IsCanonical()) {
22687 // Object::Clone does not clone canonical bit.
22688 ASSERT(!type_parameter.IsCanonical());
22690 ASSERT(type_parameter.IsFinalized());
22691 type_parameter ^= type_parameter.Canonicalize(Thread::Current());
22692 }
22693 return type_parameter.ptr();
22694}

◆ type_class_id()

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

Reimplemented from dart::AbstractType.

Definition at line 9790 of file object.h.

9790{ 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 22910 of file object.cc.

22914 {
22916 ASSERT(num_parent_type_args_adjustment >= 0);
22917 if (IsFunctionTypeParameter() && (index() >= num_free_fun_type_params)) {
22918 Zone* zone = Thread::Current()->zone();
22919 ASSERT(function_type_mapping != nullptr);
22920 const auto& new_tp = TypeParameter::Handle(
22921 zone, function_type_mapping->MapTypeParameter(*this));
22922 ASSERT(new_tp.base() == base() + num_parent_type_args_adjustment);
22923 ASSERT(new_tp.index() == index() + num_parent_type_args_adjustment);
22924 ASSERT(new_tp.nullability() == nullability());
22925 ASSERT(new_tp.IsFinalized());
22926 return new_tp.ptr();
22927 } else {
22928 return ptr();
22929 }
22930}

Friends And Related Symbol Documentation

◆ Class

friend class Class
friend

Definition at line 9874 of file object.h.


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