Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
dart::FunctionType Class Reference

#include <object.h>

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

Public Types

using PackedNumParentTypeArguments = UntaggedFunctionType::PackedNumParentTypeArguments
 
using PackedNumTypeParameters = UntaggedFunctionType::PackedNumTypeParameters
 
using PackedHasNamedOptionalParameters = UntaggedFunctionType::PackedHasNamedOptionalParameters
 
using PackedNumImplicitParameters = UntaggedFunctionType::PackedNumImplicitParameters
 
using PackedNumFixedParameters = UntaggedFunctionType::PackedNumFixedParameters
 
using PackedNumOptionalParameters = UntaggedFunctionType::PackedNumOptionalParameters
 
- Public Types inherited from dart::Object
enum  NameVisibility { kInternalName = 0 , kScrubbedName , kUserVisibleName }
 
enum class  NameDisambiguation { kYes , kNo }
 
using UntaggedObjectType = UntaggedObject
 
using ObjectPtrType = ObjectPtr
 

Public Member Functions

virtual bool HasTypeClass () const
 
FunctionTypePtr ToNullability (Nullability value, Heap::Space space) const
 
virtual classid_t type_class_id () 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
 
virtual uword ComputeHash () const
 
bool IsSubtypeOf (const FunctionType &other, Heap::Space space, FunctionTypeMapping *function_type_equivalence=nullptr) const
 
intptr_t NumParentTypeArguments () const
 
void SetNumParentTypeArguments (intptr_t value) const
 
intptr_t NumTypeParameters () const
 
intptr_t NumTypeArguments () const
 
intptr_t num_implicit_parameters () const
 
void set_num_implicit_parameters (intptr_t value) const
 
intptr_t num_fixed_parameters () const
 
void set_num_fixed_parameters (intptr_t value) const
 
bool HasOptionalParameters () const
 
bool HasOptionalNamedParameters () const
 
bool HasRequiredNamedParameters () const
 
bool HasOptionalPositionalParameters () const
 
intptr_t NumOptionalParameters () const
 
void SetNumOptionalParameters (intptr_t num_optional_parameters, bool are_optional_positional) const
 
intptr_t NumOptionalPositionalParameters () const
 
intptr_t NumOptionalNamedParameters () const
 
intptr_t NumParameters () const
 
uint32_t packed_parameter_counts () const
 
void set_packed_parameter_counts (uint32_t packed_parameter_counts) const
 
uint16_t packed_type_parameter_counts () const
 
void set_packed_type_parameter_counts (uint16_t packed_parameter_counts) const
 
TypeParameterPtr TypeParameterAt (intptr_t index, Nullability nullability=Nullability::kNonNullable) const
 
AbstractTypePtr result_type () const
 
void set_result_type (const AbstractType &value) const
 
AbstractTypePtr ParameterTypeAt (intptr_t index) const
 
void SetParameterTypeAt (intptr_t index, const AbstractType &value) const
 
ArrayPtr parameter_types () const
 
void set_parameter_types (const Array &value) const
 
ArrayPtr named_parameter_names () const
 
void set_named_parameter_names (const Array &value) const
 
StringPtr ParameterNameAt (intptr_t index) const
 
void SetParameterNameAt (intptr_t index, const String &value) const
 
bool IsRequiredAt (intptr_t index) const
 
void SetIsRequiredAt (intptr_t index) const
 
void CreateNameArrayIncludingFlags (Heap::Space space=Heap::kOld) const
 
void FinalizeNameArray () const
 
TypeParametersPtr type_parameters () const
 
void SetTypeParameters (const TypeParameters &value) const
 
bool HasSameTypeParametersAndBounds (const FunctionType &other, TypeEquality kind, FunctionTypeMapping *function_type_equivalence=nullptr) const
 
bool IsGeneric () const
 
bool HasGenericParent () const
 
bool IsContravariantParameter (intptr_t parameter_position, const FunctionType &other, intptr_t other_parameter_position, Heap::Space space, FunctionTypeMapping *function_type_equivalence) const
 
intptr_t GetRequiredFlagIndex (intptr_t index, intptr_t *flag_mask) const
 
void Print (NameVisibility name_visibility, BaseTextBuffer *printer) const
 
void PrintParameters (Thread *thread, Zone *zone, NameVisibility name_visibility, BaseTextBuffer *printer) const
 
StringPtr ToUserVisibleString () const
 
const char * ToUserVisibleCString () const
 
bool ContainsHandles () 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 NumParentTypeArgumentsOf (FunctionTypePtr ptr)
 
static intptr_t NumTypeParametersOf (FunctionTypePtr ptr)
 
static intptr_t NumTypeArgumentsOf (FunctionTypePtr ptr)
 
static intptr_t NumFixedParametersOf (FunctionTypePtr ptr)
 
static bool HasOptionalParameters (FunctionTypePtr ptr)
 
static bool HasOptionalNamedParameters (FunctionTypePtr ptr)
 
static bool HasOptionalPositionalParameters (FunctionTypePtr ptr)
 
static intptr_t NumOptionalParametersOf (FunctionTypePtr ptr)
 
static intptr_t NumOptionalPositionalParametersOf (FunctionTypePtr ptr)
 
static intptr_t NumOptionalNamedParametersOf (FunctionTypePtr ptr)
 
static intptr_t NumParametersOf (FunctionTypePtr ptr)
 
static intptr_t packed_parameter_counts_offset ()
 
static intptr_t packed_type_parameter_counts_offset ()
 
static intptr_t parameter_types_offset ()
 
static intptr_t named_parameter_names_offset ()
 
static intptr_t NameArrayLengthIncludingFlags (intptr_t num_parameters)
 
static intptr_t type_parameters_offset ()
 
static bool IsGeneric (FunctionTypePtr ptr)
 
static intptr_t InstanceSize ()
 
static FunctionTypePtr New (intptr_t num_parent_type_arguments=0, Nullability nullability=Nullability::kLegacy, Heap::Space space=Heap::kOld)
 
static FunctionTypePtr Clone (const FunctionType &orig, Heap::Space space)
 
- 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)
 

Friends

class Class
 
class Function
 

Additional Inherited Members

- 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 9493 of file object.h.

Member Typedef Documentation

◆ PackedHasNamedOptionalParameters

Definition at line 9499 of file object.h.

◆ PackedNumFixedParameters

Definition at line 9503 of file object.h.

◆ PackedNumImplicitParameters

Definition at line 9501 of file object.h.

◆ PackedNumOptionalParameters

Definition at line 9505 of file object.h.

◆ PackedNumParentTypeArguments

Definition at line 9496 of file object.h.

◆ PackedNumTypeParameters

Definition at line 9498 of file object.h.

Member Function Documentation

◆ Canonicalize()

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

Reimplemented from dart::AbstractType.

Definition at line 22539 of file object.cc.

22539 {
22541 Zone* zone = thread->zone();
22542 if (IsCanonical()) {
22543#ifdef DEBUG
22544 // Verify that all fields are allocated in old space and are canonical.
22545 if (IsGeneric()) {
22546 const TypeParameters& type_params =
22548 ASSERT(type_params.IsOld());
22549 TypeArguments& type_args = TypeArguments::Handle(zone);
22550 type_args = type_params.bounds();
22551 ASSERT(type_args.IsOld());
22552 ASSERT(type_args.IsCanonical());
22553 type_args = type_params.defaults();
22554 ASSERT(type_args.IsOld());
22555 ASSERT(type_args.IsCanonical());
22556 }
22557 AbstractType& type = AbstractType::Handle(zone);
22558 type = result_type();
22559 ASSERT(type.IsOld());
22560 ASSERT(type.IsCanonical());
22563 const intptr_t num_params = NumParameters();
22564 for (intptr_t i = 0; i < num_params; i++) {
22565 type = ParameterTypeAt(i);
22566 ASSERT(type.IsOld());
22567 ASSERT(type.IsCanonical());
22568 }
22569#endif
22570 return ptr();
22571 }
22572 auto isolate_group = thread->isolate_group();
22573 ObjectStore* object_store = isolate_group->object_store();
22574 FunctionType& sig = FunctionType::Handle(zone);
22575 {
22576 SafepointMutexLocker ml(isolate_group->type_canonicalization_mutex());
22578 object_store->canonical_function_types());
22579 sig ^= table.GetOrNull(CanonicalFunctionTypeKey(*this));
22580 ASSERT(object_store->canonical_function_types() == table.Release().ptr());
22581 }
22582 if (sig.IsNull()) {
22583 // The function type was not found in the table. It is not canonical yet.
22584 // Canonicalize its type parameters and types.
22585
22586 // Clone this function type to the old heap and update
22587 // owners of type parameters.
22588 FunctionType& new_sig = FunctionType::Handle(zone);
22589 if (this->IsNew()) {
22590 new_sig ^= FunctionType::Clone(*this, Heap::kOld);
22591 } else {
22592 new_sig ^= this->ptr();
22593 }
22594 ASSERT(new_sig.IsOld());
22595
22596 if (new_sig.IsGeneric()) {
22597 const TypeParameters& type_params =
22598 TypeParameters::Handle(zone, new_sig.type_parameters());
22599 ASSERT(type_params.IsOld());
22600 TypeArguments& type_args = TypeArguments::Handle(zone);
22601 type_args = type_params.bounds();
22602 if (!type_args.IsCanonical()) {
22603 type_args = type_args.Canonicalize(thread);
22604 type_params.set_bounds(type_args);
22605 }
22606 type_args = type_params.defaults();
22607 if (!type_args.IsCanonical()) {
22608 type_args = type_args.Canonicalize(thread);
22609 type_params.set_defaults(type_args);
22610 }
22611 }
22612 AbstractType& type = AbstractType::Handle(zone);
22613 type = new_sig.result_type();
22614 if (!type.IsCanonical()) {
22615 type = type.Canonicalize(thread);
22616 new_sig.set_result_type(type);
22617 }
22618 ASSERT(Array::Handle(zone, new_sig.parameter_types()).IsOld());
22619 ASSERT(Array::Handle(zone, new_sig.named_parameter_names()).IsOld());
22620 const intptr_t num_params = new_sig.NumParameters();
22621 for (intptr_t i = 0; i < num_params; i++) {
22622 type = new_sig.ParameterTypeAt(i);
22623 if (!type.IsCanonical()) {
22624 type = type.Canonicalize(thread);
22625 new_sig.SetParameterTypeAt(i, type);
22626 }
22627 }
22628 // Check to see if the function type got added to canonical table
22629 // during canonicalization of its signature types.
22630 SafepointMutexLocker ml(isolate_group->type_canonicalization_mutex());
22632 object_store->canonical_function_types());
22633 sig ^= table.GetOrNull(CanonicalFunctionTypeKey(new_sig));
22634 if (sig.IsNull()) {
22635 // Add this function type into the canonical table of function types.
22636 sig = new_sig.ptr();
22637 ASSERT(sig.IsOld());
22638 sig.SetCanonical(); // Mark object as being canonical.
22639 bool present = table.Insert(sig);
22640 ASSERT(!present);
22641 }
22642 object_store->set_canonical_function_types(table.Release());
22643 }
22644 return sig.ptr();
22645}
SI F table(const skcms_Curve *curve, F v)
bool IsFinalized() const
Definition object.h:9030
friend class TypeArguments
Definition object.h:9343
TypeParametersPtr type_parameters() const
Definition object.h:9707
AbstractTypePtr ParameterTypeAt(intptr_t index) const
Definition object.cc:8643
AbstractTypePtr result_type() const
Definition object.h:9650
ArrayPtr named_parameter_names() const
Definition object.h:9669
static FunctionTypePtr Clone(const FunctionType &orig, Heap::Space space)
Definition object.cc:11701
intptr_t NumParameters() const
Definition object.h:9628
bool IsGeneric() const
Definition object.h:9727
ArrayPtr parameter_types() const
Definition object.h:9658
@ kOld
Definition heap.h:39
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
static Object & Handle()
Definition object.h:407
#define ASSERT(E)
UnorderedHashSet< CanonicalFunctionTypeTraits > CanonicalFunctionTypeSet

◆ Clone()

FunctionTypePtr dart::FunctionType::Clone ( const FunctionType orig,
Heap::Space  space 
)
static

Definition at line 11701 of file object.cc.

11702 {
11703 if (orig.IsGeneric()) {
11704 // Need a deep clone in order to update owners of type parameters.
11705 return FunctionType::RawCast(
11706 orig.UpdateFunctionTypes(0, kAllFree, space, nullptr));
11707 } else {
11708 return FunctionType::RawCast(Object::Clone(orig, space));
11709 }
11710}
static ObjectPtr Clone(const Object &orig, Heap::Space space, bool load_with_relaxed_atomics=false)
Definition object.cc:2960
static ObjectPtr RawCast(ObjectPtr obj)
Definition object.h:325
@ kAllFree
Definition object.h:2920

◆ ComputeHash()

uword dart::FunctionType::ComputeHash ( ) const
virtual

Reimplemented from dart::AbstractType.

Definition at line 22421 of file object.cc.

22421 {
22423 uint32_t result =
22425 // A legacy type should have the same hash as its non-nullable version to be
22426 // consistent with the definition of type equality in Dart code.
22427 Nullability type_nullability = nullability();
22428 if (type_nullability == Nullability::kLegacy) {
22429 type_nullability = Nullability::kNonNullable;
22430 }
22431 result = CombineHashes(result, static_cast<uint32_t>(type_nullability));
22432 AbstractType& type = AbstractType::Handle();
22433 const intptr_t num_type_params = NumTypeParameters();
22434 if (num_type_params > 0) {
22435 const TypeParameters& type_params =
22437 const TypeArguments& bounds = TypeArguments::Handle(type_params.bounds());
22438 result = CombineHashes(result, bounds.Hash());
22439 // Since the default arguments are ignored when comparing two generic
22440 // function types for type equality, the hash does not depend on them.
22441 }
22442 type = result_type();
22443 result = CombineHashes(result, type.Hash());
22444 const intptr_t num_params = NumParameters();
22445 for (intptr_t i = 0; i < num_params; i++) {
22446 type = ParameterTypeAt(i);
22447 result = CombineHashes(result, type.Hash());
22448 }
22450 String& param_name = String::Handle();
22451 for (intptr_t i = num_fixed_parameters(); i < num_params; i++) {
22452 param_name = ParameterNameAt(i);
22453 result = CombineHashes(result, param_name.Hash());
22454 }
22455 // Required flag is not hashed, see comment above about legacy type.
22456 }
22458 SetHash(result);
22459 return result;
22460}
void SetHash(intptr_t value) const
Definition object.h:13360
Nullability nullability() const
Definition object.h:9037
StringPtr ParameterNameAt(intptr_t index) const
Definition object.cc:8703
bool HasOptionalNamedParameters() const
Definition object.h:9589
intptr_t num_fixed_parameters() const
Definition object.h:9575
intptr_t NumTypeParameters() const
Definition object.h:9558
uint16_t packed_type_parameter_counts() const
Definition object.h:9637
uint32_t packed_parameter_counts() const
Definition object.h:9630
static constexpr intptr_t kHashBits
Definition object.h:323
GAsyncResult * result
Optional< SkRect > bounds
Definition SkRecords.h:189
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

◆ ContainsHandles()

bool dart::FunctionType::ContainsHandles ( ) const

Definition at line 8350 of file object.cc.

8350 {
8351 const intptr_t num_params = num_fixed_parameters();
8352 for (intptr_t i = 0; i < num_params; i++) {
8353 const bool is_handle =
8354 AbstractType::Handle(ParameterTypeAt(i)).type_class_id() ==
8355 kFfiHandleCid;
8356 if (is_handle) {
8357 return true;
8358 }
8359 }
8360 return AbstractType::Handle(result_type()).type_class_id() == kFfiHandleCid;
8361}

◆ CreateNameArrayIncludingFlags()

void dart::FunctionType::CreateNameArrayIncludingFlags ( Heap::Space  space = Heap::kOld) const

Definition at line 8750 of file object.cc.

8750 {
8751#if defined(DART_PRECOMPILED_RUNTIME)
8752 UNREACHABLE();
8753#else
8754 const intptr_t num_named_parameters = NumOptionalNamedParameters();
8755 if (num_named_parameters == 0) {
8756 return set_named_parameter_names(Object::empty_array());
8757 }
8758 // Currently, we only store flags for named parameters.
8759 const intptr_t last_index = (num_named_parameters - 1) /
8760 compiler::target::kNumParameterFlagsPerElement;
8761 const intptr_t num_flag_slots = last_index + 1;
8762 intptr_t num_total_slots = num_named_parameters + num_flag_slots;
8763 auto& array = Array::Handle(Array::New(num_total_slots, space));
8764 // Set flag slots to Smi 0 before handing off.
8765 auto& empty_flags_smi = Smi::Handle(Smi::New(0));
8766 for (intptr_t i = num_named_parameters; i < num_total_slots; i++) {
8767 array.SetAt(i, empty_flags_smi);
8768 }
8770#endif
8771}
#define UNREACHABLE()
Definition assert.h:248
static ArrayPtr New(intptr_t len, Heap::Space space=Heap::kNew)
Definition object.h:10933
intptr_t NumOptionalNamedParameters() const
Definition object.h:9621
void set_named_parameter_names(const Array &value) const
Definition object.cc:8730
static SmiPtr New(intptr_t value)
Definition object.h:9985

◆ EnumerateURIs()

void dart::FunctionType::EnumerateURIs ( URIs uris) const
virtual

Reimplemented from dart::AbstractType.

Definition at line 22647 of file object.cc.

22647 {
22648 Thread* thread = Thread::Current();
22649 Zone* zone = thread->zone();
22650 AbstractType& type = AbstractType::Handle(zone);
22651 const intptr_t num_params = NumParameters();
22652 for (intptr_t i = 0; i < num_params; i++) {
22653 type = ParameterTypeAt(i);
22654 type.EnumerateURIs(uris);
22655 }
22656 // Handle result type last, since it appears last in the user visible name.
22657 type = result_type();
22658 type.EnumerateURIs(uris);
22659}
static Thread * Current()
Definition thread.h:361

◆ FinalizeNameArray()

void dart::FunctionType::FinalizeNameArray ( ) const

Definition at line 8844 of file object.cc.

8844 {
8845#if defined(DART_PRECOMPILER_RUNTIME)
8846 UNREACHABLE();
8847#else
8848 const intptr_t num_named_parameters = NumOptionalNamedParameters();
8849 if (num_named_parameters == 0) {
8850 ASSERT(untag()->named_parameter_names() == Object::empty_array().ptr());
8851 return;
8852 }
8853 const Array& parameter_names =
8855 // Truncate the parameter names array to remove unused flags from the end.
8856 intptr_t last_used = parameter_names.Length() - 1;
8857 for (; last_used >= num_named_parameters; --last_used) {
8858 if (Smi::Value(Smi::RawCast(parameter_names.At(last_used))) != 0) {
8859 break;
8860 }
8861 }
8862 parameter_names.Truncate(last_used + 1);
8863#endif
8864}
intptr_t Value() const
Definition object.h:9969
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)

◆ GetRequiredFlagIndex()

intptr_t dart::FunctionType::GetRequiredFlagIndex ( intptr_t  index,
intptr_t *  flag_mask 
) const

Definition at line 8773 of file object.cc.

8774 {
8775 // If these calculations change, also change
8776 // FlowGraphBuilder::BuildClosureCallHasRequiredNamedArgumentsCheck.
8778 ASSERT(flag_mask != nullptr);
8779 ASSERT(index >= num_fixed_parameters());
8780 index -= num_fixed_parameters();
8781 *flag_mask = (1 << compiler::target::kRequiredNamedParameterFlag)
8782 << ((static_cast<uintptr_t>(index) %
8783 compiler::target::kNumParameterFlagsPerElement) *
8784 compiler::target::kNumParameterFlags);
8786 index / compiler::target::kNumParameterFlagsPerElement;
8787}

◆ HasGenericParent()

bool dart::FunctionType::HasGenericParent ( ) const
inline

Definition at line 9730 of file object.h.

9730{ return NumParentTypeArguments() > 0; }
intptr_t NumParentTypeArguments() const
Definition object.h:9550

◆ HasOptionalNamedParameters() [1/2]

bool dart::FunctionType::HasOptionalNamedParameters ( ) const
inline

Definition at line 9589 of file object.h.

9589 {
9591 }

◆ HasOptionalNamedParameters() [2/2]

static bool dart::FunctionType::HasOptionalNamedParameters ( FunctionTypePtr  ptr)
inlinestatic

Definition at line 9585 of file object.h.

9585 {
9586 return ptr->untag()
9587 ->packed_parameter_counts_.Read<PackedHasNamedOptionalParameters>();
9588 }
UntaggedFunctionType::PackedHasNamedOptionalParameters PackedHasNamedOptionalParameters
Definition object.h:9500
UntaggedObject * untag() const

◆ HasOptionalParameters() [1/2]

bool dart::FunctionType::HasOptionalParameters ( ) const
inline

Definition at line 9583 of file object.h.

9583{ return HasOptionalParameters(ptr()); }
bool HasOptionalParameters() const
Definition object.h:9583

◆ HasOptionalParameters() [2/2]

static bool dart::FunctionType::HasOptionalParameters ( FunctionTypePtr  ptr)
inlinestatic

Definition at line 9578 of file object.h.

9578 {
9579 return ptr->untag()
9580 ->packed_parameter_counts_.Read<PackedNumOptionalParameters>() >
9581 0;
9582 }
UntaggedFunctionType::PackedNumOptionalParameters PackedNumOptionalParameters
Definition object.h:9506

◆ HasOptionalPositionalParameters() [1/2]

bool dart::FunctionType::HasOptionalPositionalParameters ( ) const
inline

Definition at line 9597 of file object.h.

9597 {
9599 }
bool HasOptionalPositionalParameters() const
Definition object.h:9597

◆ HasOptionalPositionalParameters() [2/2]

static bool dart::FunctionType::HasOptionalPositionalParameters ( FunctionTypePtr  ptr)
inlinestatic

Definition at line 9594 of file object.h.

9594 {
9596 }

◆ HasRequiredNamedParameters()

bool dart::FunctionType::HasRequiredNamedParameters ( ) const

Definition at line 8866 of file object.cc.

8866 {
8867 const intptr_t num_named_params = NumOptionalNamedParameters();
8868 if (num_named_params == 0) return false;
8869 // Check for flag slots in the named parameter names array.
8870 const auto& parameter_names = Array::Handle(named_parameter_names());
8871 ASSERT(!parameter_names.IsNull());
8872 return parameter_names.Length() > num_named_params;
8873}

◆ HasSameTypeParametersAndBounds()

bool dart::FunctionType::HasSameTypeParametersAndBounds ( const FunctionType other,
TypeEquality  kind,
FunctionTypeMapping function_type_equivalence = nullptr 
) const

Definition at line 10059 of file object.cc.

10062 {
10063 Zone* const zone = Thread::Current()->zone();
10065 " FunctionType::HasSameTypeParametersAndBounds(%s, %s)\n", ToCString(),
10066 other.ToCString());
10067
10068 const intptr_t num_type_params = NumTypeParameters();
10069 if (num_type_params != other.NumTypeParameters()) {
10071 " - result: false (number of type parameters)\n");
10072 return false;
10073 }
10074 if (num_type_params > 0) {
10075 const TypeParameters& type_params =
10077 ASSERT(!type_params.IsNull());
10078 const TypeParameters& other_type_params =
10079 TypeParameters::Handle(zone, other.type_parameters());
10080 ASSERT(!other_type_params.IsNull());
10081 if (kind == TypeEquality::kInSubtypeTest) {
10082 if (!type_params.AllDynamicBounds() ||
10083 !other_type_params.AllDynamicBounds()) {
10084 AbstractType& bound = AbstractType::Handle(zone);
10085 AbstractType& other_bound = AbstractType::Handle(zone);
10086 for (intptr_t i = 0; i < num_type_params; i++) {
10087 bound = type_params.BoundAt(i);
10088 other_bound = other_type_params.BoundAt(i);
10089 // Bounds that are mutual subtypes are considered equal.
10090 if (!bound.IsSubtypeOf(other_bound, Heap::kOld,
10091 function_type_equivalence) ||
10092 !other_bound.IsSubtypeOf(bound, Heap::kOld,
10093 function_type_equivalence)) {
10095 " - result: false (bounds are not mutual subtypes)\n");
10096 return false;
10097 }
10098 }
10099 }
10100 } else {
10101 if (NumParentTypeArguments() != other.NumParentTypeArguments()) {
10103 " - result: false (mismatch in number of type arguments)\n");
10104 return false;
10105 }
10106 const TypeArguments& bounds =
10107 TypeArguments::Handle(zone, type_params.bounds());
10108 const TypeArguments& other_bounds =
10109 TypeArguments::Handle(zone, other_type_params.bounds());
10110 if (!bounds.IsEquivalent(other_bounds, kind, function_type_equivalence)) {
10112 " - result: false (bounds are not equivalent)\n");
10113 return false;
10114 }
10115 if (kind == TypeEquality::kCanonical) {
10116 // Compare default arguments.
10117 const TypeArguments& defaults =
10118 TypeArguments::Handle(zone, type_params.defaults());
10119 const TypeArguments& other_defaults =
10120 TypeArguments::Handle(zone, other_type_params.defaults());
10121 if (defaults.IsNull()) {
10122 if (!other_defaults.IsNull()) {
10124 " - result: false (mismatch in defaults)\n");
10125 return false;
10126 }
10127 } else if (!defaults.IsEquivalent(other_defaults, kind,
10128 function_type_equivalence)) {
10130 " - result: false (default types are not equivalent)\n");
10131 return false;
10132 }
10133 }
10134 }
10135 if (kind != TypeEquality::kInSubtypeTest) {
10136 // Compare flags (IsGenericCovariantImpl).
10137 if (!Array::Equals(type_params.flags(), other_type_params.flags())) {
10138 TRACE_TYPE_CHECKS_VERBOSE(" - result: false (flags are not equal)\n");
10139 return false;
10140 }
10141 }
10142 }
10143 TRACE_TYPE_CHECKS_VERBOSE(" - result: true\n");
10144 return true;
10145}
static bool Equals(ArrayPtr a, ArrayPtr b)
Definition object.h:10833
virtual const char * ToCString() const
Definition object.h:366
Zone * zone() const
#define TRACE_TYPE_CHECKS_VERBOSE(format,...)
Definition object.cc:226

◆ HasTypeClass()

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

Reimplemented from dart::AbstractType.

Definition at line 9508 of file object.h.

9508{ return false; }

◆ InstanceSize()

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

Definition at line 9756 of file object.h.

9756 {
9757 return RoundedAllocationSize(sizeof(UntaggedFunctionType));
9758 }
static constexpr intptr_t RoundedAllocationSize(intptr_t size)
Definition object.h:758

◆ InstantiateFrom()

AbstractTypePtr dart::FunctionType::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 9841 of file object.cc.

9847 {
9849 Zone* zone = Thread::Current()->zone();
9850 const intptr_t num_parent_type_args = NumParentTypeArguments();
9851 bool delete_type_parameters = false;
9852 if (num_free_fun_type_params == kCurrentAndEnclosingFree) {
9853 // See the comment on kCurrentAndEnclosingFree to understand why we don't
9854 // adjust 'num_free_fun_type_params' downward in this case.
9855 num_free_fun_type_params = kAllFree;
9856 delete_type_parameters = true;
9857 } else {
9858 ASSERT(!IsInstantiated(kAny, num_free_fun_type_params));
9859 // We only consider the function type parameters declared by the parents
9860 // of this signature function as free.
9861 if (num_parent_type_args < num_free_fun_type_params) {
9862 num_free_fun_type_params = num_parent_type_args;
9863 }
9864 }
9865
9866 // The number of parent type parameters that remain uninstantiated.
9867 const intptr_t remaining_parent_type_params =
9868 num_free_fun_type_params < num_parent_type_args
9869 ? num_parent_type_args - num_free_fun_type_params
9870 : 0;
9871
9872 // Adjust number of parent type arguments for all nested substituted types.
9873 num_parent_type_args_adjustment =
9874 remaining_parent_type_params +
9875 (delete_type_parameters ? 0 : NumTypeParameters());
9876
9877 FunctionType& sig = FunctionType::Handle(
9878 FunctionType::New(remaining_parent_type_params, nullability(), space));
9879 AbstractType& type = AbstractType::Handle(zone);
9880
9881 FunctionTypeMapping scope(zone, &function_type_mapping, *this, sig);
9882
9883 // Copy the type parameters and instantiate their bounds and defaults.
9884 if (!delete_type_parameters) {
9885 const TypeParameters& type_params =
9887 if (!type_params.IsNull()) {
9888 const TypeParameters& sig_type_params =
9890 // No need to set names that are ignored in a signature, however, the
9891 // length of the names array defines the number of type parameters.
9892 sig_type_params.set_names(Array::Handle(zone, type_params.names()));
9893 sig_type_params.set_flags(Array::Handle(zone, type_params.flags()));
9894 sig.SetTypeParameters(sig_type_params);
9895 TypeArguments& type_args = TypeArguments::Handle(zone);
9896 type_args = type_params.bounds();
9897 if (!type_args.IsNull() && !type_args.IsInstantiated()) {
9898 type_args = type_args.InstantiateFrom(
9899 instantiator_type_arguments, function_type_arguments,
9900 num_free_fun_type_params, space, function_type_mapping,
9901 num_parent_type_args_adjustment);
9902 }
9903 sig_type_params.set_bounds(type_args);
9904 type_args = type_params.defaults();
9905 if (!type_args.IsNull() && !type_args.IsInstantiated()) {
9906 type_args = type_args.InstantiateFrom(
9907 instantiator_type_arguments, function_type_arguments,
9908 num_free_fun_type_params, space, function_type_mapping,
9909 num_parent_type_args_adjustment);
9910 }
9911 sig_type_params.set_defaults(type_args);
9912 }
9913 }
9914
9915 type = result_type();
9916 if (!type.IsInstantiated()) {
9917 type = type.InstantiateFrom(
9918 instantiator_type_arguments, function_type_arguments,
9919 num_free_fun_type_params, space, function_type_mapping,
9920 num_parent_type_args_adjustment);
9921 // A returned null type indicates a failed instantiation in dead code that
9922 // must be propagated up to the caller, the optimizing compiler.
9923 if (type.IsNull()) {
9924 return FunctionType::null();
9925 }
9926 }
9927 sig.set_result_type(type);
9928 const intptr_t num_params = NumParameters();
9929 sig.set_num_implicit_parameters(num_implicit_parameters());
9930 sig.set_num_fixed_parameters(num_fixed_parameters());
9931 sig.SetNumOptionalParameters(NumOptionalParameters(),
9933 sig.set_parameter_types(Array::Handle(Array::New(num_params, space)));
9934 for (intptr_t i = 0; i < num_params; i++) {
9935 type = ParameterTypeAt(i);
9936 if (!type.IsInstantiated()) {
9937 type = type.InstantiateFrom(
9938 instantiator_type_arguments, function_type_arguments,
9939 num_free_fun_type_params, space, function_type_mapping,
9940 num_parent_type_args_adjustment);
9941 // A returned null type indicates a failed instantiation in dead code that
9942 // must be propagated up to the caller, the optimizing compiler.
9943 if (type.IsNull()) {
9944 return FunctionType::null();
9945 }
9946 }
9947 sig.SetParameterTypeAt(i, type);
9948 }
9949 sig.set_named_parameter_names(Array::Handle(zone, named_parameter_names()));
9950
9951 if (delete_type_parameters) {
9952 ASSERT(sig.IsInstantiated(kFunctions));
9953 }
9954
9955 sig.SetIsFinalized();
9956
9957 // Canonicalization is not part of instantiation.
9958 return sig.ptr();
9959}
intptr_t num_implicit_parameters() const
Definition object.h:9565
virtual bool IsInstantiated(Genericity genericity=kAny, intptr_t num_free_fun_type_params=kAllFree) const
Definition object.cc:10850
intptr_t NumOptionalParameters() const
Definition object.h:9605
static FunctionTypePtr New(intptr_t num_parent_type_arguments=0, Nullability nullability=Nullability::kLegacy, Heap::Space space=Heap::kOld)
Definition object.cc:11682
static ObjectPtr null()
Definition object.h:433
static TypeParametersPtr New(Heap::Space space=Heap::kOld)
Definition object.cc:6778
@ kCurrentAndEnclosingFree
Definition object.h:2917
@ kFunctions
Definition object.h:2231
@ kAny
Definition object.h:2229

◆ IsContravariantParameter()

bool dart::FunctionType::IsContravariantParameter ( intptr_t  parameter_position,
const FunctionType other,
intptr_t  other_parameter_position,
Heap::Space  space,
FunctionTypeMapping function_type_equivalence 
) const

Definition at line 10042 of file object.cc.

10047 {
10048 const AbstractType& param_type =
10049 AbstractType::Handle(ParameterTypeAt(parameter_position));
10050 if (param_type.IsTopTypeForSubtyping()) {
10051 return true;
10052 }
10053 const AbstractType& other_param_type =
10054 AbstractType::Handle(other.ParameterTypeAt(other_parameter_position));
10055 return other_param_type.IsSubtypeOf(param_type, space,
10056 function_type_equivalence);
10057}

◆ IsEquivalent()

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

Reimplemented from dart::AbstractType.

Definition at line 22170 of file object.cc.

22173 {
22174 ASSERT(!IsNull());
22175 if (ptr() == other.ptr()) {
22176 return true;
22177 }
22178 if (!other.IsFunctionType()) {
22179 return false;
22180 }
22181 const FunctionType& other_type = FunctionType::Cast(other);
22182 if ((packed_parameter_counts() != other_type.packed_parameter_counts()) ||
22184 other_type.packed_type_parameter_counts())) {
22185 // Different number of type parameters or parameters.
22186 return false;
22187 }
22188 Thread* thread = Thread::Current();
22189 Zone* zone = thread->zone();
22190 if (!IsNullabilityEquivalent(thread, other_type, kind)) {
22191 return false;
22192 }
22193 if (!IsFinalized() || !other_type.IsFinalized()) {
22195 return false; // Too early to decide if equal.
22196 }
22197 FunctionTypeMapping scope(zone, &function_type_equivalence, *this,
22198 other_type);
22199
22200 // Equal function types must have equal signature types and equal optional
22201 // named arguments.
22202 // Compare function type parameters and their bounds.
22203 // Check the type parameters and bounds of generic functions.
22204 if (!HasSameTypeParametersAndBounds(other_type, kind,
22205 function_type_equivalence)) {
22206 return false;
22207 }
22208 AbstractType& param_type = Type::Handle(zone);
22209 AbstractType& other_param_type = Type::Handle(zone);
22210 // Check the result type.
22211 param_type = result_type();
22212 other_param_type = other_type.result_type();
22213 if (!param_type.IsEquivalent(other_param_type, kind,
22214 function_type_equivalence)) {
22215 return false;
22216 }
22217 // Check the types of all parameters.
22218 const intptr_t num_params = NumParameters();
22219 ASSERT(other_type.NumParameters() == num_params);
22220 for (intptr_t i = 0; i < num_params; i++) {
22221 param_type = ParameterTypeAt(i);
22222 other_param_type = other_type.ParameterTypeAt(i);
22223 // Use contravariant order in case we test for subtyping.
22224 if (!other_param_type.IsEquivalent(param_type, kind,
22225 function_type_equivalence)) {
22226 return false;
22227 }
22228 }
22230 ASSERT(other_type.HasOptionalNamedParameters()); // Same packed counts.
22231 for (intptr_t i = num_fixed_parameters(); i < num_params; i++) {
22232 if (ParameterNameAt(i) != other_type.ParameterNameAt(i)) {
22233 return false;
22234 }
22235 if (IsRequiredAt(i) != other_type.IsRequiredAt(i)) {
22236 return false;
22237 }
22238 }
22239 }
22240 return true;
22241}
bool IsNullabilityEquivalent(Thread *thread, const AbstractType &other_type, TypeEquality kind) const
Definition object.cc:21245
bool IsRequiredAt(intptr_t index) const
Definition object.cc:8813
bool HasSameTypeParametersAndBounds(const FunctionType &other, TypeEquality kind, FunctionTypeMapping *function_type_equivalence=nullptr) const
Definition object.cc:10059
bool IsNull() const
Definition object.h:363

◆ IsGeneric() [1/2]

bool dart::FunctionType::IsGeneric ( ) const
inline

Definition at line 9727 of file object.h.

9727{ return IsGeneric(ptr()); }

◆ IsGeneric() [2/2]

static bool dart::FunctionType::IsGeneric ( FunctionTypePtr  ptr)
inlinestatic

Definition at line 9724 of file object.h.

9724 {
9725 return ptr->untag()->type_parameters() != TypeParameters::null();
9726 }

◆ IsInstantiated()

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

Reimplemented from dart::AbstractType.

Definition at line 10850 of file object.cc.

10851 {
10852 if (num_free_fun_type_params == kCurrentAndEnclosingFree) {
10853 num_free_fun_type_params = kAllFree;
10854 } else if (genericity != kCurrentClass) {
10855 const intptr_t num_parent_type_args = NumParentTypeArguments();
10856 if (num_parent_type_args > 0 && num_free_fun_type_params > 0) {
10857 // The number of parent type arguments is cached in the FunctionType, so
10858 // we can't consider any FunctionType with free parent type arguments as
10859 // fully instantiated. Instead, the FunctionType must be instantiated to
10860 // reduce the number of parent type arguments, even if they're unused in
10861 // its component types.
10862 return false;
10863 }
10864 // Don't consider local function type parameters as free.
10865 if (num_free_fun_type_params > num_parent_type_args) {
10866 num_free_fun_type_params = num_parent_type_args;
10867 }
10868 }
10869 AbstractType& type = AbstractType::Handle(result_type());
10870 if (!type.IsInstantiated(genericity, num_free_fun_type_params)) {
10871 return false;
10872 }
10873 const intptr_t num_parameters = NumParameters();
10874 for (intptr_t i = 0; i < num_parameters; i++) {
10875 type = ParameterTypeAt(i);
10876 if (!type.IsInstantiated(genericity, num_free_fun_type_params)) {
10877 return false;
10878 }
10879 }
10880 const intptr_t num_type_params = NumTypeParameters();
10881 if (num_type_params > 0) {
10882 TypeParameters& type_params = TypeParameters::Handle(type_parameters());
10883 if (!type_params.AllDynamicBounds()) {
10884 for (intptr_t i = 0; i < type_params.Length(); ++i) {
10885 type = type_params.BoundAt(i);
10886 if (!type.IsInstantiated(genericity, num_free_fun_type_params)) {
10887 return false;
10888 }
10889 }
10890 }
10891 }
10892 return true;
10893}
@ kCurrentClass
Definition object.h:2230

◆ IsRequiredAt()

bool dart::FunctionType::IsRequiredAt ( intptr_t  index) const

Definition at line 8813 of file object.cc.

8813 {
8815 return false;
8816 }
8817 intptr_t flag_mask;
8818 const intptr_t flag_index = GetRequiredFlagIndex(index, &flag_mask);
8819 const Array& parameter_names =
8821 if (flag_index >= parameter_names.Length()) {
8822 return false;
8823 }
8824 const intptr_t flags =
8825 Smi::Value(Smi::RawCast(parameter_names.At(flag_index)));
8826 return (flags & flag_mask) != 0;
8827}
intptr_t GetRequiredFlagIndex(intptr_t index, intptr_t *flag_mask) const
Definition object.cc:8773
FlutterSemanticsFlag flags

◆ IsSubtypeOf()

bool dart::FunctionType::IsSubtypeOf ( const FunctionType other,
Heap::Space  space,
FunctionTypeMapping function_type_equivalence = nullptr 
) const

Definition at line 10147 of file object.cc.

10150 {
10151 TRACE_TYPE_CHECKS_VERBOSE(" FunctionType::IsSubtypeOf(%s, %s)\n",
10152 ToCString(), other.ToCString());
10153 const intptr_t num_fixed_params = num_fixed_parameters();
10154 const intptr_t num_opt_pos_params = NumOptionalPositionalParameters();
10155 const intptr_t num_opt_named_params = NumOptionalNamedParameters();
10156 const intptr_t other_num_fixed_params = other.num_fixed_parameters();
10157 const intptr_t other_num_opt_pos_params =
10158 other.NumOptionalPositionalParameters();
10159 const intptr_t other_num_opt_named_params =
10160 other.NumOptionalNamedParameters();
10161 // This signature requires the same arguments or less and accepts the same
10162 // arguments or more. We can ignore implicit parameters.
10163 const intptr_t num_ignored_params = num_implicit_parameters();
10164 const intptr_t other_num_ignored_params = other.num_implicit_parameters();
10165 if (((num_fixed_params - num_ignored_params) >
10166 (other_num_fixed_params - other_num_ignored_params)) ||
10167 ((num_fixed_params - num_ignored_params + num_opt_pos_params) <
10168 (other_num_fixed_params - other_num_ignored_params +
10169 other_num_opt_pos_params)) ||
10170 (num_opt_named_params < other_num_opt_named_params)) {
10172 " - result: false (mismatch in number of parameters)\n");
10173 return false;
10174 }
10175 Thread* thread = Thread::Current();
10176 Zone* zone = thread->zone();
10177 FunctionTypeMapping scope(zone, &function_type_equivalence, *this, other);
10178
10179 // Check the type parameters and bounds of generic functions.
10181 function_type_equivalence)) {
10183 " - result: false (mismatch in type parameters)\n");
10184 return false;
10185 }
10186 // Check the result type.
10187 const AbstractType& other_res_type =
10188 AbstractType::Handle(zone, other.result_type());
10189 // 'void Function()' is a subtype of 'Object Function()'.
10190 if (!other_res_type.IsTopTypeForSubtyping()) {
10191 const AbstractType& res_type = AbstractType::Handle(zone, result_type());
10192 if (!res_type.IsSubtypeOf(other_res_type, space,
10193 function_type_equivalence)) {
10194 TRACE_TYPE_CHECKS_VERBOSE(" - result: false (result type)\n");
10195 return false;
10196 }
10197 }
10198 // Check the types of fixed and optional positional parameters.
10199 for (intptr_t i = 0; i < (other_num_fixed_params - other_num_ignored_params +
10200 other_num_opt_pos_params);
10201 i++) {
10202 if (!IsContravariantParameter(i + num_ignored_params, other,
10203 i + other_num_ignored_params, space,
10204 function_type_equivalence)) {
10205 TRACE_TYPE_CHECKS_VERBOSE(" - result: false (parameter type)\n");
10206 return false;
10207 }
10208 }
10209 // Check that for each optional named parameter of type T of the other
10210 // function type, there exists an optional named parameter of this function
10211 // type with an identical name and with a type S that is a supertype of T.
10212 // Note that SetParameterNameAt() guarantees that names are symbols, so we
10213 // can compare their raw pointers.
10214 const int num_params = num_fixed_params + num_opt_named_params;
10215 const int other_num_params =
10216 other_num_fixed_params + other_num_opt_named_params;
10217 bool found_param_name;
10218 String& other_param_name = String::Handle(zone);
10219 for (intptr_t i = other_num_fixed_params; i < other_num_params; i++) {
10220 other_param_name = other.ParameterNameAt(i);
10221 ASSERT(other_param_name.IsSymbol());
10222 found_param_name = false;
10223 for (intptr_t j = num_fixed_params; j < num_params; j++) {
10224 ASSERT(String::Handle(zone, ParameterNameAt(j)).IsSymbol());
10225 if (ParameterNameAt(j) == other_param_name.ptr()) {
10226 found_param_name = true;
10227 if (!IsContravariantParameter(j, other, i, space,
10228 function_type_equivalence)) {
10230 " - result: false (optional parameter type)\n");
10231 return false;
10232 }
10233 break;
10234 }
10235 }
10236 if (!found_param_name) {
10238 " - result: false (named parameter not found)\n");
10239 return false;
10240 }
10241 }
10242 // Check that for each required named parameter in this function, there's a
10243 // corresponding required named parameter in the other function.
10244 String& param_name = other_param_name;
10245 for (intptr_t j = num_params - num_opt_named_params; j < num_params; j++) {
10246 if (IsRequiredAt(j)) {
10247 param_name = ParameterNameAt(j);
10248 ASSERT(param_name.IsSymbol());
10249 bool found = false;
10250 for (intptr_t i = other_num_fixed_params; i < other_num_params; i++) {
10251 ASSERT(String::Handle(zone, other.ParameterNameAt(i)).IsSymbol());
10252 if (other.ParameterNameAt(i) == param_name.ptr()) {
10253 found = true;
10254 if (!other.IsRequiredAt(i)) {
10256 " - result: false (mismatch in required named "
10257 "parameters)\n");
10258 return false;
10259 }
10260 }
10261 }
10262 if (!found) {
10264 " - result: false (required named parameter not found)\n");
10265 return false;
10266 }
10267 }
10268 }
10269 TRACE_TYPE_CHECKS_VERBOSE(" - result: true\n");
10270 return true;
10271}
intptr_t NumOptionalPositionalParameters() const
Definition object.h:9614
bool IsContravariantParameter(intptr_t parameter_position, const FunctionType &other, intptr_t other_parameter_position, Heap::Space space, FunctionTypeMapping *function_type_equivalence) const
Definition object.cc:10042

◆ NameArrayLengthIncludingFlags()

static intptr_t dart::FunctionType::NameArrayLengthIncludingFlags ( intptr_t  num_parameters)
static

◆ named_parameter_names()

ArrayPtr dart::FunctionType::named_parameter_names ( ) const
inline

Definition at line 9669 of file object.h.

9669 {
9670 return untag()->named_parameter_names();
9671 }

◆ named_parameter_names_offset()

static intptr_t dart::FunctionType::named_parameter_names_offset ( )
inlinestatic

Definition at line 9673 of file object.h.

9673 {
9674 return OFFSET_OF(UntaggedFunctionType, named_parameter_names_);
9675 }
#define OFFSET_OF(type, field)
Definition globals.h:138

◆ New()

FunctionTypePtr dart::FunctionType::New ( intptr_t  num_parent_type_arguments = 0,
Nullability  nullability = Nullability::kLegacy,
Heap::Space  space = Heap::kOld 
)
static

Definition at line 11682 of file object.cc.

11684 {
11685 Zone* Z = Thread::Current()->zone();
11686 const FunctionType& result =
11688 result.set_packed_parameter_counts(0);
11689 result.set_packed_type_parameter_counts(0);
11690 result.set_named_parameter_names(Object::empty_array());
11691 result.SetNumParentTypeArguments(num_parent_type_arguments);
11692 result.SetHash(0);
11693 result.set_flags(0);
11694 result.set_nullability(nullability);
11696 result.InitializeTypeTestingStubNonAtomic(
11698 return result.ptr();
11699}
#define Z
static CodePtr DefaultCodeForType(const AbstractType &type, bool lazy_specialize=true)

◆ num_fixed_parameters()

intptr_t dart::FunctionType::num_fixed_parameters ( ) const
inline

Definition at line 9575 of file object.h.

9575{ return NumFixedParametersOf(ptr()); }
static intptr_t NumFixedParametersOf(FunctionTypePtr ptr)
Definition object.h:9571

◆ num_implicit_parameters()

intptr_t dart::FunctionType::num_implicit_parameters ( ) const
inline

Definition at line 9565 of file object.h.

9565 {
9566 return untag()
9567 ->packed_parameter_counts_.Read<PackedNumImplicitParameters>();
9568 }
UntaggedFunctionType::PackedNumImplicitParameters PackedNumImplicitParameters
Definition object.h:9502

◆ NumFixedParametersOf()

static intptr_t dart::FunctionType::NumFixedParametersOf ( FunctionTypePtr  ptr)
inlinestatic

Definition at line 9571 of file object.h.

9571 {
9572 return ptr->untag()
9573 ->packed_parameter_counts_.Read<PackedNumFixedParameters>();
9574 }
UntaggedFunctionType::PackedNumFixedParameters PackedNumFixedParameters
Definition object.h:9504

◆ NumOptionalNamedParameters()

intptr_t dart::FunctionType::NumOptionalNamedParameters ( ) const
inline

Definition at line 9621 of file object.h.

9621 {
9623 }
static intptr_t NumOptionalNamedParametersOf(FunctionTypePtr ptr)
Definition object.h:9618

◆ NumOptionalNamedParametersOf()

static intptr_t dart::FunctionType::NumOptionalNamedParametersOf ( FunctionTypePtr  ptr)
inlinestatic

Definition at line 9618 of file object.h.

9618 {
9620 }
static intptr_t NumOptionalParametersOf(FunctionTypePtr ptr)
Definition object.h:9601

◆ NumOptionalParameters()

intptr_t dart::FunctionType::NumOptionalParameters ( ) const
inline

Definition at line 9605 of file object.h.

9605 {
9606 return NumOptionalParametersOf(ptr());
9607 }

◆ NumOptionalParametersOf()

static intptr_t dart::FunctionType::NumOptionalParametersOf ( FunctionTypePtr  ptr)
inlinestatic

Definition at line 9601 of file object.h.

9601 {
9602 return ptr->untag()
9603 ->packed_parameter_counts_.Read<PackedNumOptionalParameters>();
9604 }

◆ NumOptionalPositionalParameters()

intptr_t dart::FunctionType::NumOptionalPositionalParameters ( ) const
inline

Definition at line 9614 of file object.h.

9614 {
9616 }
static intptr_t NumOptionalPositionalParametersOf(FunctionTypePtr ptr)
Definition object.h:9611

◆ NumOptionalPositionalParametersOf()

static intptr_t dart::FunctionType::NumOptionalPositionalParametersOf ( FunctionTypePtr  ptr)
inlinestatic

Definition at line 9611 of file object.h.

9611 {
9613 }

◆ NumParameters()

intptr_t dart::FunctionType::NumParameters ( ) const
inline

Definition at line 9628 of file object.h.

9628{ return NumParametersOf(ptr()); }
static intptr_t NumParametersOf(FunctionTypePtr ptr)
Definition object.h:9625

◆ NumParametersOf()

static intptr_t dart::FunctionType::NumParametersOf ( FunctionTypePtr  ptr)
inlinestatic

Definition at line 9625 of file object.h.

9625 {
9627 }

◆ NumParentTypeArguments()

intptr_t dart::FunctionType::NumParentTypeArguments ( ) const
inline

Definition at line 9550 of file object.h.

9550 {
9551 return NumParentTypeArgumentsOf(ptr());
9552 }
static intptr_t NumParentTypeArgumentsOf(FunctionTypePtr ptr)
Definition object.h:9545

◆ NumParentTypeArgumentsOf()

static intptr_t dart::FunctionType::NumParentTypeArgumentsOf ( FunctionTypePtr  ptr)
inlinestatic

Definition at line 9545 of file object.h.

9545 {
9546 return ptr->untag()
9547 ->packed_type_parameter_counts_.Read<PackedNumParentTypeArguments>();
9548 }
UntaggedFunctionType::PackedNumParentTypeArguments PackedNumParentTypeArguments
Definition object.h:9497

◆ NumTypeArguments()

intptr_t dart::FunctionType::NumTypeArguments ( ) const
inline

Definition at line 9563 of file object.h.

9563{ return NumTypeArgumentsOf(ptr()); }
static intptr_t NumTypeArgumentsOf(FunctionTypePtr ptr)
Definition object.h:9560

◆ NumTypeArgumentsOf()

static intptr_t dart::FunctionType::NumTypeArgumentsOf ( FunctionTypePtr  ptr)
inlinestatic

Definition at line 9560 of file object.h.

9560 {
9562 }
static intptr_t NumTypeParametersOf(FunctionTypePtr ptr)
Definition object.h:9554

◆ NumTypeParameters()

intptr_t dart::FunctionType::NumTypeParameters ( ) const
inline

Definition at line 9558 of file object.h.

9558{ return NumTypeParametersOf(ptr()); }

◆ NumTypeParametersOf()

static intptr_t dart::FunctionType::NumTypeParametersOf ( FunctionTypePtr  ptr)
inlinestatic

Definition at line 9554 of file object.h.

9554 {
9555 return ptr->untag()
9556 ->packed_type_parameter_counts_.Read<PackedNumTypeParameters>();
9557 }
UntaggedFunctionType::PackedNumTypeParameters PackedNumTypeParameters
Definition object.h:9498

◆ packed_parameter_counts()

uint32_t dart::FunctionType::packed_parameter_counts ( ) const
inline

Definition at line 9630 of file object.h.

9630 {
9631 return untag()->packed_parameter_counts_;
9632 }

◆ packed_parameter_counts_offset()

static intptr_t dart::FunctionType::packed_parameter_counts_offset ( )
inlinestatic

Definition at line 9634 of file object.h.

9634 {
9635 return OFFSET_OF(UntaggedFunctionType, packed_parameter_counts_);
9636 }

◆ packed_type_parameter_counts()

uint16_t dart::FunctionType::packed_type_parameter_counts ( ) const
inline

Definition at line 9637 of file object.h.

9637 {
9638 return untag()->packed_type_parameter_counts_;
9639 }

◆ packed_type_parameter_counts_offset()

static intptr_t dart::FunctionType::packed_type_parameter_counts_offset ( )
inlinestatic

Definition at line 9641 of file object.h.

9641 {
9642 return OFFSET_OF(UntaggedFunctionType, packed_type_parameter_counts_);
9643 }

◆ parameter_types()

ArrayPtr dart::FunctionType::parameter_types ( ) const
inline

Definition at line 9658 of file object.h.

9658{ return untag()->parameter_types(); }

◆ parameter_types_offset()

static intptr_t dart::FunctionType::parameter_types_offset ( )
inlinestatic

Definition at line 9660 of file object.h.

9660 {
9661 return OFFSET_OF(UntaggedFunctionType, parameter_types_);
9662 }

◆ ParameterNameAt()

StringPtr dart::FunctionType::ParameterNameAt ( intptr_t  index) const

Definition at line 8703 of file object.cc.

8703 {
8704 const intptr_t num_fixed = num_fixed_parameters();
8705 if (!HasOptionalNamedParameters() || index < num_fixed) {
8706 // The positional parameter names are stored on the function, not here.
8707 UNREACHABLE();
8708 }
8709 const Array& parameter_names =
8711 return String::RawCast(parameter_names.At(index - num_fixed));
8712}

◆ ParameterTypeAt()

AbstractTypePtr dart::FunctionType::ParameterTypeAt ( intptr_t  index) const

Definition at line 8643 of file object.cc.

8643 {
8645 return AbstractType::RawCast(parameter_types.At(index));
8646}

◆ Print()

void dart::FunctionType::Print ( NameVisibility  name_visibility,
BaseTextBuffer printer 
) const

Definition at line 10813 of file object.cc.

10814 {
10815 if (IsNull()) {
10816 printer->AddString("null"); // Signature optimized out in precompiler.
10817 return;
10818 }
10819 Thread* thread = Thread::Current();
10820 Zone* zone = thread->zone();
10821 const TypeParameters& type_params =
10823 if (!type_params.IsNull()) {
10824 printer->AddString("<");
10825 const intptr_t base = NumParentTypeArguments();
10826 const bool kIsClassTypeParameter = false;
10827 // Type parameter names are meaningless after canonicalization.
10828 type_params.Print(thread, zone, kIsClassTypeParameter, base,
10829 name_visibility, printer);
10830 printer->AddString(">");
10831 }
10832 printer->AddString("(");
10833 PrintParameters(thread, zone, name_visibility, printer);
10834 printer->AddString(") => ");
10835 const AbstractType& res_type = AbstractType::Handle(zone, result_type());
10836 if (!res_type.IsNull()) {
10837 res_type.PrintName(name_visibility, printer);
10838 } else {
10839 printer->AddString("null");
10840 }
10841}
void PrintParameters(Thread *thread, Zone *zone, NameVisibility name_visibility, BaseTextBuffer *printer) const
Definition object.cc:10700

◆ PrintName()

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

Reimplemented from dart::AbstractType.

Definition at line 22661 of file object.cc.

22662 {
22663 const char* suffix = NullabilitySuffix(name_visibility);
22664 if (suffix[0] != '\0') {
22665 printer->AddString("(");
22666 }
22667 FunctionType::Cast(*this).Print(name_visibility, printer);
22668 if (suffix[0] != '\0') {
22669 printer->AddString(")");
22670 printer->AddString(suffix);
22671 }
22672}
virtual const char * NullabilitySuffix(NameVisibility name_visibility) const
Definition object.cc:21360

◆ PrintParameters()

void dart::FunctionType::PrintParameters ( Thread thread,
Zone zone,
NameVisibility  name_visibility,
BaseTextBuffer printer 
) const

Definition at line 10700 of file object.cc.

10703 {
10704 AbstractType& param_type = AbstractType::Handle(zone);
10705 const intptr_t num_params = NumParameters();
10706 const intptr_t num_fixed_params = num_fixed_parameters();
10707 const intptr_t num_opt_pos_params = NumOptionalPositionalParameters();
10708 const intptr_t num_opt_named_params = NumOptionalNamedParameters();
10709 const intptr_t num_opt_params = num_opt_pos_params + num_opt_named_params;
10710 ASSERT((num_fixed_params + num_opt_params) == num_params);
10711 intptr_t i = 0;
10712 if (name_visibility == kUserVisibleName) {
10713 // Hide implicit parameters.
10715 }
10716 String& name = String::Handle(zone);
10717 while (i < num_fixed_params) {
10718 param_type = ParameterTypeAt(i);
10719 ASSERT(!param_type.IsNull());
10720 param_type.PrintName(name_visibility, printer);
10721 if (i != (num_params - 1)) {
10722 printer->AddString(", ");
10723 }
10724 i++;
10725 }
10726 if (num_opt_params > 0) {
10727 if (num_opt_pos_params > 0) {
10728 printer->AddString("[");
10729 } else {
10730 printer->AddString("{");
10731 }
10732 for (intptr_t i = num_fixed_params; i < num_params; i++) {
10733 if (num_opt_named_params > 0 && IsRequiredAt(i)) {
10734 printer->AddString("required ");
10735 }
10736 param_type = ParameterTypeAt(i);
10737 ASSERT(!param_type.IsNull());
10738 param_type.PrintName(name_visibility, printer);
10739 // The parameter name of an optional positional parameter does not need
10740 // to be part of the signature, since it is not used.
10741 if (num_opt_named_params > 0) {
10742 name = ParameterNameAt(i);
10743 printer->AddString(" ");
10744 printer->AddString(name.ToCString());
10745 }
10746 if (i != (num_params - 1)) {
10747 printer->AddString(", ");
10748 }
10749 }
10750 if (num_opt_pos_params > 0) {
10751 printer->AddString("]");
10752 } else {
10753 printer->AddString("}");
10754 }
10755 }
10756}
@ kUserVisibleName
Definition object.h:645
const char *const name

◆ result_type()

AbstractTypePtr dart::FunctionType::result_type ( ) const
inline

Definition at line 9650 of file object.h.

9650{ return untag()->result_type(); }

◆ set_named_parameter_names()

void dart::FunctionType::set_named_parameter_names ( const Array value) const

Definition at line 8730 of file object.cc.

8730 {
8731 ASSERT(value.ptr() == Object::empty_array().ptr() || value.Length() > 0);
8732 untag()->set_named_parameter_names(value.ptr());
8733}
uint8_t value

◆ set_num_fixed_parameters()

void dart::FunctionType::set_num_fixed_parameters ( intptr_t  value) const

Definition at line 11659 of file object.cc.

11659 {
11660 ASSERT(value >= 0);
11661 untag()->packed_parameter_counts_.Update<PackedNumFixedParameters>(value);
11662}

◆ set_num_implicit_parameters()

void dart::FunctionType::set_num_implicit_parameters ( intptr_t  value) const

Definition at line 11608 of file object.cc.

11608 {
11609 ASSERT(value >= 0);
11610 untag()->packed_parameter_counts_.Update<PackedNumImplicitParameters>(value);
11611}

◆ set_packed_parameter_counts()

void dart::FunctionType::set_packed_parameter_counts ( uint32_t  packed_parameter_counts) const

Definition at line 11598 of file object.cc.

11599 {
11600 untag()->packed_parameter_counts_ = packed_parameter_counts;
11601}

◆ set_packed_type_parameter_counts()

void dart::FunctionType::set_packed_type_parameter_counts ( uint16_t  packed_parameter_counts) const

Definition at line 11603 of file object.cc.

11604 {
11605 untag()->packed_type_parameter_counts_ = packed_type_parameter_counts;
11606}

◆ set_parameter_types()

void dart::FunctionType::set_parameter_types ( const Array value) const

Definition at line 8655 of file object.cc.

8655 {
8656 ASSERT(value.IsNull() || value.Length() > 0);
8657 untag()->set_parameter_types(value.ptr());
8658}

◆ set_result_type()

void dart::FunctionType::set_result_type ( const AbstractType value) const

Definition at line 8633 of file object.cc.

8633 {
8634 ASSERT(!value.IsNull());
8635 untag()->set_result_type(value.ptr());
8636}

◆ SetIsRequiredAt()

void dart::FunctionType::SetIsRequiredAt ( intptr_t  index) const

Definition at line 8829 of file object.cc.

8829 {
8830#if defined(DART_PRECOMPILER_RUNTIME)
8831 UNREACHABLE();
8832#else
8833 intptr_t flag_mask;
8834 const intptr_t flag_index = GetRequiredFlagIndex(index, &flag_mask);
8835 const Array& parameter_names =
8837 ASSERT(flag_index < parameter_names.Length());
8838 const intptr_t flags =
8839 Smi::Value(Smi::RawCast(parameter_names.At(flag_index)));
8840 parameter_names.SetAt(flag_index, Smi::Handle(Smi::New(flags | flag_mask)));
8841#endif
8842}

◆ SetNumOptionalParameters()

void dart::FunctionType::SetNumOptionalParameters ( intptr_t  num_optional_parameters,
bool  are_optional_positional 
) const

Definition at line 11668 of file object.cc.

11670 {
11671 // HasOptionalNamedParameters only checks this bit, so only set it if there
11672 // are actual named parameters.
11673 untag()->packed_parameter_counts_.Update<PackedHasNamedOptionalParameters>(
11674 (value > 0) && !are_optional_positional);
11675 untag()->packed_parameter_counts_.Update<PackedNumOptionalParameters>(value);
11676}

◆ SetNumParentTypeArguments()

void dart::FunctionType::SetNumParentTypeArguments ( intptr_t  value) const

Definition at line 8893 of file object.cc.

8893 {
8894 ASSERT(value >= 0);
8897 }
8898 untag()->packed_type_parameter_counts_.Update<PackedNumParentTypeArguments>(
8899 value);
8900}
static constexpr bool is_valid(T value)
Definition bitfield.h:148
static void ReportTooManyTypeParameters(const FunctionType &sig)
Definition object.cc:8875

◆ SetParameterNameAt()

void dart::FunctionType::SetParameterNameAt ( intptr_t  index,
const String value 
) const

Definition at line 8714 of file object.cc.

8715 {
8716#if defined(DART_PRECOMPILED_RUNTIME)
8717 UNREACHABLE();
8718#else
8719 ASSERT(!value.IsNull() && value.IsSymbol());
8720 const intptr_t num_fixed = num_fixed_parameters();
8721 if (!HasOptionalNamedParameters() || index < num_fixed) {
8722 UNREACHABLE();
8723 }
8724 const Array& parameter_names =
8726 parameter_names.SetAt(index - num_fixed, value);
8727#endif
8728}

◆ SetParameterTypeAt()

void dart::FunctionType::SetParameterTypeAt ( intptr_t  index,
const AbstractType value 
) const

Definition at line 8648 of file object.cc.

8649 {
8650 ASSERT(!value.IsNull());
8652 parameter_types.SetAt(index, value);
8653}

◆ SetTypeParameters()

void dart::FunctionType::SetTypeParameters ( const TypeParameters value) const

Definition at line 8884 of file object.cc.

8884 {
8885 untag()->set_type_parameters(value.ptr());
8886 const intptr_t count = value.Length();
8889 }
8890 untag()->packed_type_parameter_counts_.Update<PackedNumTypeParameters>(count);
8891}
int count

◆ ToNullability()

FunctionTypePtr dart::FunctionType::ToNullability ( Nullability  value,
Heap::Space  space 
) const

Definition at line 22005 of file object.cc.

22006 {
22007 if (nullability() == value) {
22008 return ptr();
22009 }
22010 // Clone function type and set new nullability.
22011 FunctionType& type = FunctionType::Handle(FunctionType::Clone(*this, space));
22012 type.set_nullability(value);
22013 type.SetHash(0);
22014 type.InitializeTypeTestingStubNonAtomic(
22016 if (IsCanonical()) {
22017 // Object::Clone does not clone canonical bit.
22018 ASSERT(!type.IsCanonical());
22019 type ^= type.Canonicalize(Thread::Current());
22020 }
22021 return type.ptr();
22022}

◆ ToUserVisibleCString()

const char * dart::FunctionType::ToUserVisibleCString ( ) const

Definition at line 11712 of file object.cc.

11712 {
11713 Zone* zone = Thread::Current()->zone();
11714 ZoneTextBuffer printer(zone);
11715 Print(kUserVisibleName, &printer);
11716 return printer.buffer();
11717}
void Print() const
Definition object.cc:2681

◆ ToUserVisibleString()

StringPtr dart::FunctionType::ToUserVisibleString ( ) const

Definition at line 11719 of file object.cc.

11719 {
11720 Thread* thread = Thread::Current();
11721 ZoneTextBuffer printer(thread->zone());
11722 Print(kUserVisibleName, &printer);
11723 return Symbols::New(thread, printer.buffer());
11724}
static StringPtr New(Thread *thread, const char *cstr)
Definition symbols.h:722

◆ type_class_id()

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

Reimplemented from dart::AbstractType.

Definition at line 9510 of file object.h.

9510{ return kIllegalCid; }
@ kIllegalCid
Definition class_id.h:214

◆ type_parameters()

TypeParametersPtr dart::FunctionType::type_parameters ( ) const
inline

Definition at line 9707 of file object.h.

9707 {
9708 return untag()->type_parameters();
9709 }

◆ type_parameters_offset()

static intptr_t dart::FunctionType::type_parameters_offset ( )
inlinestatic

Definition at line 9711 of file object.h.

9711 {
9712 return OFFSET_OF(UntaggedFunctionType, type_parameters_);
9713 }

◆ TypeParameterAt()

TypeParameterPtr dart::FunctionType::TypeParameterAt ( intptr_t  index,
Nullability  nullability = Nullability::kNonNullable 
) const

Definition at line 8618 of file object.cc.

8619 {
8620 ASSERT(index >= 0 && index < NumTypeParameters());
8621 Thread* thread = Thread::Current();
8622 Zone* zone = thread->zone();
8623 TypeParameter& type_param = TypeParameter::Handle(
8624 zone, TypeParameter::New(*this, NumParentTypeArguments(),
8626 type_param.SetIsFinalized();
8627 if (IsFinalized()) {
8628 type_param ^= type_param.Canonicalize(thread);
8629 }
8630 return type_param.ptr();
8631}

◆ UpdateFunctionTypes()

AbstractTypePtr dart::FunctionType::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 9961 of file object.cc.

9965 {
9966 ASSERT(num_parent_type_args_adjustment >= 0);
9968 Zone* zone = Thread::Current()->zone();
9969
9970 const intptr_t old_num_parent_type_args = NumParentTypeArguments();
9971 // From now on, adjust all type parameter types
9972 // which belong to this or nested function types.
9973 if (num_free_fun_type_params > old_num_parent_type_args) {
9974 num_free_fun_type_params = old_num_parent_type_args;
9975 }
9976
9977 FunctionType& new_type = FunctionType::Handle(
9978 zone, FunctionType::New(
9979 NumParentTypeArguments() + num_parent_type_args_adjustment,
9980 nullability(), space));
9981 AbstractType& type = AbstractType::Handle(zone);
9982
9983 FunctionTypeMapping scope(zone, &function_type_mapping, *this, new_type);
9984
9985 const TypeParameters& type_params =
9987 if (!type_params.IsNull()) {
9988 const TypeParameters& new_type_params =
9990 // No need to set names that are ignored in a signature, however, the
9991 // length of the names array defines the number of type parameters.
9992 new_type_params.set_names(Array::Handle(zone, type_params.names()));
9993 new_type_params.set_flags(Array::Handle(zone, type_params.flags()));
9994 TypeArguments& type_args = TypeArguments::Handle(zone);
9995 type_args = type_params.bounds();
9996 if (!type_args.IsNull()) {
9997 type_args = type_args.UpdateFunctionTypes(num_parent_type_args_adjustment,
9998 num_free_fun_type_params, space,
9999 function_type_mapping);
10000 }
10001 new_type_params.set_bounds(type_args);
10002 type_args = type_params.defaults();
10003 if (!type_args.IsNull()) {
10004 type_args = type_args.UpdateFunctionTypes(num_parent_type_args_adjustment,
10005 num_free_fun_type_params, space,
10006 function_type_mapping);
10007 }
10008 new_type_params.set_defaults(type_args);
10009 new_type.SetTypeParameters(new_type_params);
10010 }
10011
10012 type = result_type();
10013 type = type.UpdateFunctionTypes(num_parent_type_args_adjustment,
10014 num_free_fun_type_params, space,
10015 function_type_mapping);
10016 new_type.set_result_type(type);
10017
10018 const intptr_t num_params = NumParameters();
10019 new_type.set_num_implicit_parameters(num_implicit_parameters());
10020 new_type.set_num_fixed_parameters(num_fixed_parameters());
10021 new_type.SetNumOptionalParameters(NumOptionalParameters(),
10023 new_type.set_parameter_types(Array::Handle(Array::New(num_params, space)));
10024 for (intptr_t i = 0; i < num_params; i++) {
10025 type = ParameterTypeAt(i);
10026 type = type.UpdateFunctionTypes(num_parent_type_args_adjustment,
10027 num_free_fun_type_params, space,
10028 function_type_mapping);
10029 new_type.SetParameterTypeAt(i, type);
10030 }
10031 new_type.set_named_parameter_names(
10033 new_type.SetIsFinalized();
10034
10035 return new_type.ptr();
10036}

Friends And Related Symbol Documentation

◆ Class

friend class Class
friend

Definition at line 9772 of file object.h.

◆ Function

friend class Function
friend

Definition at line 9773 of file object.h.


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