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

Static Public Member Functions

static intptr_t 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::kNonNullable, 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 9513 of file object.h.

Member Typedef Documentation

◆ PackedHasNamedOptionalParameters

Definition at line 9519 of file object.h.

◆ PackedNumFixedParameters

Definition at line 9523 of file object.h.

◆ PackedNumImplicitParameters

Definition at line 9521 of file object.h.

◆ PackedNumOptionalParameters

Definition at line 9525 of file object.h.

◆ PackedNumParentTypeArguments

Definition at line 9516 of file object.h.

◆ PackedNumTypeParameters

Definition at line 9518 of file object.h.

Member Function Documentation

◆ Canonicalize()

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

Reimplemented from dart::AbstractType.

Definition at line 22466 of file object.cc.

22466 {
22468 Zone* zone = thread->zone();
22469 if (IsCanonical()) {
22470#ifdef DEBUG
22471 // Verify that all fields are allocated in old space and are canonical.
22472 if (IsGeneric()) {
22473 const TypeParameters& type_params =
22475 ASSERT(type_params.IsOld());
22476 TypeArguments& type_args = TypeArguments::Handle(zone);
22477 type_args = type_params.bounds();
22478 ASSERT(type_args.IsOld());
22479 ASSERT(type_args.IsCanonical());
22480 type_args = type_params.defaults();
22481 ASSERT(type_args.IsOld());
22482 ASSERT(type_args.IsCanonical());
22483 }
22484 AbstractType& type = AbstractType::Handle(zone);
22485 type = result_type();
22486 ASSERT(type.IsOld());
22487 ASSERT(type.IsCanonical());
22490 const intptr_t num_params = NumParameters();
22491 for (intptr_t i = 0; i < num_params; i++) {
22493 ASSERT(type.IsOld());
22494 ASSERT(type.IsCanonical());
22495 }
22496#endif
22497 return ptr();
22498 }
22499 auto isolate_group = thread->isolate_group();
22500 ObjectStore* object_store = isolate_group->object_store();
22501 FunctionType& sig = FunctionType::Handle(zone);
22502 {
22503 SafepointMutexLocker ml(isolate_group->type_canonicalization_mutex());
22505 object_store->canonical_function_types());
22506 sig ^= table.GetOrNull(CanonicalFunctionTypeKey(*this));
22507 ASSERT(object_store->canonical_function_types() == table.Release().ptr());
22508 }
22509 if (sig.IsNull()) {
22510 // The function type was not found in the table. It is not canonical yet.
22511 // Canonicalize its type parameters and types.
22512
22513 // Clone this function type to the old heap and update
22514 // owners of type parameters.
22515 FunctionType& new_sig = FunctionType::Handle(zone);
22516 if (this->IsNew()) {
22517 new_sig ^= FunctionType::Clone(*this, Heap::kOld);
22518 } else {
22519 new_sig ^= this->ptr();
22520 }
22521 ASSERT(new_sig.IsOld());
22522
22523 if (new_sig.IsGeneric()) {
22524 const TypeParameters& type_params =
22525 TypeParameters::Handle(zone, new_sig.type_parameters());
22526 ASSERT(type_params.IsOld());
22527 TypeArguments& type_args = TypeArguments::Handle(zone);
22528 type_args = type_params.bounds();
22529 if (!type_args.IsCanonical()) {
22530 type_args = type_args.Canonicalize(thread);
22531 type_params.set_bounds(type_args);
22532 }
22533 type_args = type_params.defaults();
22534 if (!type_args.IsCanonical()) {
22535 type_args = type_args.Canonicalize(thread);
22536 type_params.set_defaults(type_args);
22537 }
22538 }
22539 AbstractType& type = AbstractType::Handle(zone);
22540 type = new_sig.result_type();
22541 if (!type.IsCanonical()) {
22542 type = type.Canonicalize(thread);
22543 new_sig.set_result_type(type);
22544 }
22545 ASSERT(Array::Handle(zone, new_sig.parameter_types()).IsOld());
22546 ASSERT(Array::Handle(zone, new_sig.named_parameter_names()).IsOld());
22547 const intptr_t num_params = new_sig.NumParameters();
22548 for (intptr_t i = 0; i < num_params; i++) {
22549 type = new_sig.ParameterTypeAt(i);
22550 if (!type.IsCanonical()) {
22551 type = type.Canonicalize(thread);
22552 new_sig.SetParameterTypeAt(i, type);
22553 }
22554 }
22555 // Check to see if the function type got added to canonical table
22556 // during canonicalization of its signature types.
22557 SafepointMutexLocker ml(isolate_group->type_canonicalization_mutex());
22559 object_store->canonical_function_types());
22560 sig ^= table.GetOrNull(CanonicalFunctionTypeKey(new_sig));
22561 if (sig.IsNull()) {
22562 // Add this function type into the canonical table of function types.
22563 sig = new_sig.ptr();
22564 ASSERT(sig.IsOld());
22565 sig.SetCanonical(); // Mark object as being canonical.
22566 bool present = table.Insert(sig);
22567 ASSERT(!present);
22568 }
22569 object_store->set_canonical_function_types(table.Release());
22570 }
22571 return sig.ptr();
22572}
SI F table(const skcms_Curve *curve, F v)
GLenum type
bool IsFinalized() const
Definition: object.h:9053
friend class TypeArguments
Definition: object.h:9363
TypeParametersPtr type_parameters() const
Definition: object.h:9727
AbstractTypePtr ParameterTypeAt(intptr_t index) const
Definition: object.cc:8585
AbstractTypePtr result_type() const
Definition: object.h:9670
ArrayPtr named_parameter_names() const
Definition: object.h:9689
static FunctionTypePtr Clone(const FunctionType &orig, Heap::Space space)
Definition: object.cc:11650
intptr_t NumParameters() const
Definition: object.h:9648
bool IsGeneric() const
Definition: object.h:9747
ArrayPtr parameter_types() const
Definition: object.h:9678
@ 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 11650 of file object.cc.

11651 {
11652 if (orig.IsGeneric()) {
11653 // Need a deep clone in order to update owners of type parameters.
11654 return FunctionType::RawCast(
11655 orig.UpdateFunctionTypes(0, kAllFree, space, nullptr));
11656 } else {
11657 return FunctionType::RawCast(Object::Clone(orig, space));
11658 }
11659}
static ObjectPtr Clone(const Object &orig, Heap::Space space, bool load_with_relaxed_atomics=false)
Definition: object.cc:2899
static ObjectPtr RawCast(ObjectPtr obj)
Definition: object.h:325
@ kAllFree
Definition: object.h:2940

◆ ComputeHash()

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

Reimplemented from dart::AbstractType.

Definition at line 22354 of file object.cc.

22354 {
22356 uint32_t result =
22358 result = CombineHashes(result, static_cast<uint32_t>(nullability()));
22359 AbstractType& type = AbstractType::Handle();
22360 const intptr_t num_type_params = NumTypeParameters();
22361 if (num_type_params > 0) {
22362 const TypeParameters& type_params =
22364 const TypeArguments& bounds = TypeArguments::Handle(type_params.bounds());
22365 result = CombineHashes(result, bounds.Hash());
22366 // Since the default arguments are ignored when comparing two generic
22367 // function types for type equality, the hash does not depend on them.
22368 }
22369 type = result_type();
22370 result = CombineHashes(result, type.Hash());
22371 const intptr_t num_params = NumParameters();
22372 for (intptr_t i = 0; i < num_params; i++) {
22374 result = CombineHashes(result, type.Hash());
22375 }
22377 String& param_name = String::Handle();
22378 for (intptr_t i = num_fixed_parameters(); i < num_params; i++) {
22379 param_name = ParameterNameAt(i);
22380 result = CombineHashes(result, param_name.Hash());
22381 }
22382 // Required flag is not hashed, see comment above about legacy type.
22383 }
22385 SetHash(result);
22386 return result;
22387}
void SetHash(intptr_t value) const
Definition: object.h:13386
Nullability nullability() const
Definition: object.h:9060
StringPtr ParameterNameAt(intptr_t index) const
Definition: object.cc:8645
bool HasOptionalNamedParameters() const
Definition: object.h:9609
intptr_t num_fixed_parameters() const
Definition: object.h:9595
intptr_t NumTypeParameters() const
Definition: object.h:9578
uint16_t packed_type_parameter_counts() const
Definition: object.h:9657
uint32_t packed_parameter_counts() const
Definition: object.h:9650
static constexpr intptr_t kHashBits
Definition: object.h:323
GAsyncResult * result
Optional< SkRect > bounds
Definition: SkRecords.h:189
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 8292 of file object.cc.

8292 {
8293 const intptr_t num_params = num_fixed_parameters();
8294 for (intptr_t i = 0; i < num_params; i++) {
8295 const bool is_handle =
8296 AbstractType::Handle(ParameterTypeAt(i)).type_class_id() ==
8297 kFfiHandleCid;
8298 if (is_handle) {
8299 return true;
8300 }
8301 }
8302 return AbstractType::Handle(result_type()).type_class_id() == kFfiHandleCid;
8303}

◆ CreateNameArrayIncludingFlags()

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

Definition at line 8692 of file object.cc.

8692 {
8693#if defined(DART_PRECOMPILED_RUNTIME)
8694 UNREACHABLE();
8695#else
8696 const intptr_t num_named_parameters = NumOptionalNamedParameters();
8697 if (num_named_parameters == 0) {
8698 return set_named_parameter_names(Object::empty_array());
8699 }
8700 // Currently, we only store flags for named parameters.
8701 const intptr_t last_index = (num_named_parameters - 1) /
8703 const intptr_t num_flag_slots = last_index + 1;
8704 intptr_t num_total_slots = num_named_parameters + num_flag_slots;
8705 auto& array = Array::Handle(Array::New(num_total_slots, space));
8706 // Set flag slots to Smi 0 before handing off.
8707 auto& empty_flags_smi = Smi::Handle(Smi::New(0));
8708 for (intptr_t i = num_named_parameters; i < num_total_slots; i++) {
8709 array.SetAt(i, empty_flags_smi);
8710 }
8712#endif
8713}
#define UNREACHABLE()
Definition: assert.h:248
static ArrayPtr New(intptr_t len, Heap::Space space=Heap::kNew)
Definition: object.h:10959
intptr_t NumOptionalNamedParameters() const
Definition: object.h:9641
void set_named_parameter_names(const Array &value) const
Definition: object.cc:8672
static SmiPtr New(intptr_t value)
Definition: object.h:10006
static constexpr intptr_t kNumParameterFlagsPerElement
Definition: runtime_api.h:328

◆ EnumerateURIs()

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

Reimplemented from dart::AbstractType.

Definition at line 22574 of file object.cc.

22574 {
22575 Thread* thread = Thread::Current();
22576 Zone* zone = thread->zone();
22577 AbstractType& type = AbstractType::Handle(zone);
22578 const intptr_t num_params = NumParameters();
22579 for (intptr_t i = 0; i < num_params; i++) {
22581 type.EnumerateURIs(uris);
22582 }
22583 // Handle result type last, since it appears last in the user visible name.
22584 type = result_type();
22585 type.EnumerateURIs(uris);
22586}
friend class Thread
Definition: object.h:1025
static Thread * Current()
Definition: thread.h:362

◆ FinalizeNameArray()

void dart::FunctionType::FinalizeNameArray ( ) const

Definition at line 8786 of file object.cc.

8786 {
8787#if defined(DART_PRECOMPILER_RUNTIME)
8788 UNREACHABLE();
8789#else
8790 const intptr_t num_named_parameters = NumOptionalNamedParameters();
8791 if (num_named_parameters == 0) {
8792 ASSERT(untag()->named_parameter_names() == Object::empty_array().ptr());
8793 return;
8794 }
8795 const Array& parameter_names =
8797 // Truncate the parameter names array to remove unused flags from the end.
8798 intptr_t last_used = parameter_names.Length() - 1;
8799 for (; last_used >= num_named_parameters; --last_used) {
8800 if (Smi::Value(Smi::RawCast(parameter_names.At(last_used))) != 0) {
8801 break;
8802 }
8803 }
8804 parameter_names.Truncate(last_used + 1);
8805#endif
8806}
intptr_t Value() const
Definition: object.h:9990
raw_obj untag() -> num_entries()) VARIABLE_COMPRESSED_VISITOR(Array, Smi::Value(raw_obj->untag() ->length())) VARIABLE_COMPRESSED_VISITOR(TypedData, TypedData::ElementSizeInBytes(raw_obj->GetClassId()) *Smi::Value(raw_obj->untag() ->length())) VARIABLE_COMPRESSED_VISITOR(Record, RecordShape(raw_obj->untag() ->shape()).num_fields()) VARIABLE_NULL_VISITOR(CompressedStackMaps, CompressedStackMaps::PayloadSizeOf(raw_obj)) VARIABLE_NULL_VISITOR(OneByteString, Smi::Value(raw_obj->untag() ->length())) VARIABLE_NULL_VISITOR(TwoByteString, Smi::Value(raw_obj->untag() ->length())) intptr_t UntaggedField::VisitFieldPointers(FieldPtr raw_obj, ObjectPointerVisitor *visitor)
Definition: raw_object.cc:558

◆ GetRequiredFlagIndex()

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

Definition at line 8715 of file object.cc.

8716 {
8717 // If these calculations change, also change
8718 // FlowGraphBuilder::BuildClosureCallHasRequiredNamedArgumentsCheck.
8720 ASSERT(flag_mask != nullptr);
8721 ASSERT(index >= num_fixed_parameters());
8722 index -= num_fixed_parameters();
8724 << ((static_cast<uintptr_t>(index) %
8729}

◆ HasGenericParent()

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

Definition at line 9750 of file object.h.

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

◆ HasOptionalNamedParameters() [1/2]

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

Definition at line 9609 of file object.h.

9609 {
9611 }

◆ HasOptionalNamedParameters() [2/2]

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

Definition at line 9605 of file object.h.

9605 {
9606 return ptr->untag()
9607 ->packed_parameter_counts_.Read<PackedHasNamedOptionalParameters>();
9608 }
UntaggedFunctionType::PackedHasNamedOptionalParameters PackedHasNamedOptionalParameters
Definition: object.h:9520
UntaggedObject * untag() const

◆ HasOptionalParameters() [1/2]

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

Definition at line 9603 of file object.h.

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

◆ HasOptionalParameters() [2/2]

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

Definition at line 9598 of file object.h.

9598 {
9599 return ptr->untag()
9600 ->packed_parameter_counts_.Read<PackedNumOptionalParameters>() >
9601 0;
9602 }
UntaggedFunctionType::PackedNumOptionalParameters PackedNumOptionalParameters
Definition: object.h:9526

◆ HasOptionalPositionalParameters() [1/2]

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

Definition at line 9617 of file object.h.

9617 {
9619 }
bool HasOptionalPositionalParameters() const
Definition: object.h:9617

◆ HasOptionalPositionalParameters() [2/2]

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

Definition at line 9614 of file object.h.

9614 {
9616 }

◆ HasRequiredNamedParameters()

bool dart::FunctionType::HasRequiredNamedParameters ( ) const

Definition at line 8808 of file object.cc.

8808 {
8809 const intptr_t num_named_params = NumOptionalNamedParameters();
8810 if (num_named_params == 0) return false;
8811 // Check for flag slots in the named parameter names array.
8812 const auto& parameter_names = Array::Handle(named_parameter_names());
8813 ASSERT(!parameter_names.IsNull());
8814 return parameter_names.Length() > num_named_params;
8815}

◆ HasSameTypeParametersAndBounds()

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

Definition at line 10001 of file object.cc.

10004 {
10005 Zone* const zone = Thread::Current()->zone();
10007 " FunctionType::HasSameTypeParametersAndBounds(%s, %s)\n", ToCString(),
10008 other.ToCString());
10009
10010 const intptr_t num_type_params = NumTypeParameters();
10011 if (num_type_params != other.NumTypeParameters()) {
10013 " - result: false (number of type parameters)\n");
10014 return false;
10015 }
10016 if (num_type_params > 0) {
10017 const TypeParameters& type_params =
10019 ASSERT(!type_params.IsNull());
10020 const TypeParameters& other_type_params =
10021 TypeParameters::Handle(zone, other.type_parameters());
10022 ASSERT(!other_type_params.IsNull());
10023 if (kind == TypeEquality::kInSubtypeTest) {
10024 if (!type_params.AllDynamicBounds() ||
10025 !other_type_params.AllDynamicBounds()) {
10026 AbstractType& bound = AbstractType::Handle(zone);
10027 AbstractType& other_bound = AbstractType::Handle(zone);
10028 for (intptr_t i = 0; i < num_type_params; i++) {
10029 bound = type_params.BoundAt(i);
10030 other_bound = other_type_params.BoundAt(i);
10031 // Bounds that are mutual subtypes are considered equal.
10032 if (!bound.IsSubtypeOf(other_bound, Heap::kOld,
10033 function_type_equivalence) ||
10034 !other_bound.IsSubtypeOf(bound, Heap::kOld,
10035 function_type_equivalence)) {
10037 " - result: false (bounds are not mutual subtypes)\n");
10038 return false;
10039 }
10040 }
10041 }
10042 } else {
10043 if (NumParentTypeArguments() != other.NumParentTypeArguments()) {
10045 " - result: false (mismatch in number of type arguments)\n");
10046 return false;
10047 }
10048 const TypeArguments& bounds =
10049 TypeArguments::Handle(zone, type_params.bounds());
10050 const TypeArguments& other_bounds =
10051 TypeArguments::Handle(zone, other_type_params.bounds());
10052 if (!bounds.IsEquivalent(other_bounds, kind, function_type_equivalence)) {
10054 " - result: false (bounds are not equivalent)\n");
10055 return false;
10056 }
10057 if (kind == TypeEquality::kCanonical) {
10058 // Compare default arguments.
10059 const TypeArguments& defaults =
10060 TypeArguments::Handle(zone, type_params.defaults());
10061 const TypeArguments& other_defaults =
10062 TypeArguments::Handle(zone, other_type_params.defaults());
10063 if (defaults.IsNull()) {
10064 if (!other_defaults.IsNull()) {
10066 " - result: false (mismatch in defaults)\n");
10067 return false;
10068 }
10069 } else if (!defaults.IsEquivalent(other_defaults, kind,
10070 function_type_equivalence)) {
10072 " - result: false (default types are not equivalent)\n");
10073 return false;
10074 }
10075 }
10076 }
10077 if (kind != TypeEquality::kInSubtypeTest) {
10078 // Compare flags (IsGenericCovariantImpl).
10079 if (!Array::Equals(type_params.flags(), other_type_params.flags())) {
10080 TRACE_TYPE_CHECKS_VERBOSE(" - result: false (flags are not equal)\n");
10081 return false;
10082 }
10083 }
10084 }
10085 TRACE_TYPE_CHECKS_VERBOSE(" - result: true\n");
10086 return true;
10087}
static bool Equals(ArrayPtr a, ArrayPtr b)
Definition: object.h:10854
virtual const char * ToCString() const
Definition: object.h:366
Zone * zone() const
Definition: thread_state.h:37
#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 9528 of file object.h.

9528{ return false; }

◆ InstanceSize()

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

Definition at line 9776 of file object.h.

9776 {
9777 return RoundedAllocationSize(sizeof(UntaggedFunctionType));
9778 }
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 9783 of file object.cc.

9789 {
9791 Zone* zone = Thread::Current()->zone();
9792 const intptr_t num_parent_type_args = NumParentTypeArguments();
9793 bool delete_type_parameters = false;
9794 if (num_free_fun_type_params == kCurrentAndEnclosingFree) {
9795 // See the comment on kCurrentAndEnclosingFree to understand why we don't
9796 // adjust 'num_free_fun_type_params' downward in this case.
9797 num_free_fun_type_params = kAllFree;
9798 delete_type_parameters = true;
9799 } else {
9800 ASSERT(!IsInstantiated(kAny, num_free_fun_type_params));
9801 // We only consider the function type parameters declared by the parents
9802 // of this signature function as free.
9803 if (num_parent_type_args < num_free_fun_type_params) {
9804 num_free_fun_type_params = num_parent_type_args;
9805 }
9806 }
9807
9808 // The number of parent type parameters that remain uninstantiated.
9809 const intptr_t remaining_parent_type_params =
9810 num_free_fun_type_params < num_parent_type_args
9811 ? num_parent_type_args - num_free_fun_type_params
9812 : 0;
9813
9814 // Adjust number of parent type arguments for all nested substituted types.
9815 num_parent_type_args_adjustment =
9816 remaining_parent_type_params +
9817 (delete_type_parameters ? 0 : NumTypeParameters());
9818
9819 FunctionType& sig = FunctionType::Handle(
9820 FunctionType::New(remaining_parent_type_params, nullability(), space));
9821 AbstractType& type = AbstractType::Handle(zone);
9822
9823 FunctionTypeMapping scope(zone, &function_type_mapping, *this, sig);
9824
9825 // Copy the type parameters and instantiate their bounds and defaults.
9826 if (!delete_type_parameters) {
9827 const TypeParameters& type_params =
9829 if (!type_params.IsNull()) {
9830 const TypeParameters& sig_type_params =
9832 // No need to set names that are ignored in a signature, however, the
9833 // length of the names array defines the number of type parameters.
9834 sig_type_params.set_names(Array::Handle(zone, type_params.names()));
9835 sig_type_params.set_flags(Array::Handle(zone, type_params.flags()));
9836 sig.SetTypeParameters(sig_type_params);
9837 TypeArguments& type_args = TypeArguments::Handle(zone);
9838 type_args = type_params.bounds();
9839 if (!type_args.IsNull() && !type_args.IsInstantiated()) {
9840 type_args = type_args.InstantiateFrom(
9841 instantiator_type_arguments, function_type_arguments,
9842 num_free_fun_type_params, space, function_type_mapping,
9843 num_parent_type_args_adjustment);
9844 }
9845 sig_type_params.set_bounds(type_args);
9846 type_args = type_params.defaults();
9847 if (!type_args.IsNull() && !type_args.IsInstantiated()) {
9848 type_args = type_args.InstantiateFrom(
9849 instantiator_type_arguments, function_type_arguments,
9850 num_free_fun_type_params, space, function_type_mapping,
9851 num_parent_type_args_adjustment);
9852 }
9853 sig_type_params.set_defaults(type_args);
9854 }
9855 }
9856
9857 type = result_type();
9858 if (!type.IsInstantiated()) {
9859 type = type.InstantiateFrom(
9860 instantiator_type_arguments, function_type_arguments,
9861 num_free_fun_type_params, space, function_type_mapping,
9862 num_parent_type_args_adjustment);
9863 // A returned null type indicates a failed instantiation in dead code that
9864 // must be propagated up to the caller, the optimizing compiler.
9865 if (type.IsNull()) {
9866 return FunctionType::null();
9867 }
9868 }
9869 sig.set_result_type(type);
9870 const intptr_t num_params = NumParameters();
9871 sig.set_num_implicit_parameters(num_implicit_parameters());
9872 sig.set_num_fixed_parameters(num_fixed_parameters());
9873 sig.SetNumOptionalParameters(NumOptionalParameters(),
9875 sig.set_parameter_types(Array::Handle(Array::New(num_params, space)));
9876 for (intptr_t i = 0; i < num_params; i++) {
9878 if (!type.IsInstantiated()) {
9879 type = type.InstantiateFrom(
9880 instantiator_type_arguments, function_type_arguments,
9881 num_free_fun_type_params, space, function_type_mapping,
9882 num_parent_type_args_adjustment);
9883 // A returned null type indicates a failed instantiation in dead code that
9884 // must be propagated up to the caller, the optimizing compiler.
9885 if (type.IsNull()) {
9886 return FunctionType::null();
9887 }
9888 }
9889 sig.SetParameterTypeAt(i, type);
9890 }
9891 sig.set_named_parameter_names(Array::Handle(zone, named_parameter_names()));
9892
9893 if (delete_type_parameters) {
9894 ASSERT(sig.IsInstantiated(kFunctions));
9895 }
9896
9897 sig.SetIsFinalized();
9898
9899 // Canonicalization is not part of instantiation.
9900 return sig.ptr();
9901}
intptr_t num_implicit_parameters() const
Definition: object.h:9585
static FunctionTypePtr New(intptr_t num_parent_type_arguments=0, Nullability nullability=Nullability::kNonNullable, Heap::Space space=Heap::kOld)
Definition: object.cc:11631
virtual bool IsInstantiated(Genericity genericity=kAny, intptr_t num_free_fun_type_params=kAllFree) const
Definition: object.cc:10792
intptr_t NumOptionalParameters() const
Definition: object.h:9625
static ObjectPtr null()
Definition: object.h:433
static TypeParametersPtr New(Heap::Space space=Heap::kOld)
Definition: object.cc:6723
@ kFunctions
Definition: object.h:2251
@ kAny
Definition: object.h:2249
@ kCurrentAndEnclosingFree
Definition: object.h:2937

◆ 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 9984 of file object.cc.

9989 {
9990 const AbstractType& param_type =
9991 AbstractType::Handle(ParameterTypeAt(parameter_position));
9992 if (param_type.IsTopTypeForSubtyping()) {
9993 return true;
9994 }
9995 const AbstractType& other_param_type =
9996 AbstractType::Handle(other.ParameterTypeAt(other_parameter_position));
9997 return other_param_type.IsSubtypeOf(param_type, space,
9998 function_type_equivalence);
9999}

◆ IsEquivalent()

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

Reimplemented from dart::AbstractType.

Definition at line 22109 of file object.cc.

22112 {
22113 ASSERT(!IsNull());
22114 if (ptr() == other.ptr()) {
22115 return true;
22116 }
22117 if (!other.IsFunctionType()) {
22118 return false;
22119 }
22120 const FunctionType& other_type = FunctionType::Cast(other);
22121 if ((packed_parameter_counts() != other_type.packed_parameter_counts()) ||
22123 other_type.packed_type_parameter_counts())) {
22124 // Different number of type parameters or parameters.
22125 return false;
22126 }
22127 Thread* thread = Thread::Current();
22128 Zone* zone = thread->zone();
22129 if (!IsNullabilityEquivalent(thread, other_type, kind)) {
22130 return false;
22131 }
22132 if (!IsFinalized() || !other_type.IsFinalized()) {
22134 return false; // Too early to decide if equal.
22135 }
22136 FunctionTypeMapping scope(zone, &function_type_equivalence, *this,
22137 other_type);
22138
22139 // Equal function types must have equal signature types and equal optional
22140 // named arguments.
22141 // Compare function type parameters and their bounds.
22142 // Check the type parameters and bounds of generic functions.
22143 if (!HasSameTypeParametersAndBounds(other_type, kind,
22144 function_type_equivalence)) {
22145 return false;
22146 }
22147 AbstractType& param_type = Type::Handle(zone);
22148 AbstractType& other_param_type = Type::Handle(zone);
22149 // Check the result type.
22150 param_type = result_type();
22151 other_param_type = other_type.result_type();
22152 if (!param_type.IsEquivalent(other_param_type, kind,
22153 function_type_equivalence)) {
22154 return false;
22155 }
22156 // Check the types of all parameters.
22157 const intptr_t num_params = NumParameters();
22158 ASSERT(other_type.NumParameters() == num_params);
22159 for (intptr_t i = 0; i < num_params; i++) {
22160 param_type = ParameterTypeAt(i);
22161 other_param_type = other_type.ParameterTypeAt(i);
22162 // Use contravariant order in case we test for subtyping.
22163 if (!other_param_type.IsEquivalent(param_type, kind,
22164 function_type_equivalence)) {
22165 return false;
22166 }
22167 }
22169 ASSERT(other_type.HasOptionalNamedParameters()); // Same packed counts.
22170 for (intptr_t i = num_fixed_parameters(); i < num_params; i++) {
22171 if (ParameterNameAt(i) != other_type.ParameterNameAt(i)) {
22172 return false;
22173 }
22174 if (IsRequiredAt(i) != other_type.IsRequiredAt(i)) {
22175 return false;
22176 }
22177 }
22178 }
22179 return true;
22180}
bool IsNullabilityEquivalent(Thread *thread, const AbstractType &other_type, TypeEquality kind) const
Definition: object.cc:21196
bool IsRequiredAt(intptr_t index) const
Definition: object.cc:8755
bool HasSameTypeParametersAndBounds(const FunctionType &other, TypeEquality kind, FunctionTypeMapping *function_type_equivalence=nullptr) const
Definition: object.cc:10001
bool IsNull() const
Definition: object.h:363

◆ IsGeneric() [1/2]

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

Definition at line 9747 of file object.h.

9747{ return IsGeneric(ptr()); }

◆ IsGeneric() [2/2]

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

Definition at line 9744 of file object.h.

9744 {
9745 return ptr->untag()->type_parameters() != TypeParameters::null();
9746 }

◆ 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 10792 of file object.cc.

10793 {
10794 if (num_free_fun_type_params == kCurrentAndEnclosingFree) {
10795 num_free_fun_type_params = kAllFree;
10796 } else if (genericity != kCurrentClass) {
10797 const intptr_t num_parent_type_args = NumParentTypeArguments();
10798 if (num_parent_type_args > 0 && num_free_fun_type_params > 0) {
10799 // The number of parent type arguments is cached in the FunctionType, so
10800 // we can't consider any FunctionType with free parent type arguments as
10801 // fully instantiated. Instead, the FunctionType must be instantiated to
10802 // reduce the number of parent type arguments, even if they're unused in
10803 // its component types.
10804 return false;
10805 }
10806 // Don't consider local function type parameters as free.
10807 if (num_free_fun_type_params > num_parent_type_args) {
10808 num_free_fun_type_params = num_parent_type_args;
10809 }
10810 }
10811 AbstractType& type = AbstractType::Handle(result_type());
10812 if (!type.IsInstantiated(genericity, num_free_fun_type_params)) {
10813 return false;
10814 }
10815 const intptr_t num_parameters = NumParameters();
10816 for (intptr_t i = 0; i < num_parameters; i++) {
10818 if (!type.IsInstantiated(genericity, num_free_fun_type_params)) {
10819 return false;
10820 }
10821 }
10822 const intptr_t num_type_params = NumTypeParameters();
10823 if (num_type_params > 0) {
10824 TypeParameters& type_params = TypeParameters::Handle(type_parameters());
10825 if (!type_params.AllDynamicBounds()) {
10826 for (intptr_t i = 0; i < type_params.Length(); ++i) {
10827 type = type_params.BoundAt(i);
10828 if (!type.IsInstantiated(genericity, num_free_fun_type_params)) {
10829 return false;
10830 }
10831 }
10832 }
10833 }
10834 return true;
10835}
@ kCurrentClass
Definition: object.h:2250

◆ IsRequiredAt()

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

Definition at line 8755 of file object.cc.

8755 {
8757 return false;
8758 }
8759 intptr_t flag_mask;
8760 const intptr_t flag_index = GetRequiredFlagIndex(index, &flag_mask);
8761 const Array& parameter_names =
8763 if (flag_index >= parameter_names.Length()) {
8764 return false;
8765 }
8766 const intptr_t flags =
8767 Smi::Value(Smi::RawCast(parameter_names.At(flag_index)));
8768 return (flags & flag_mask) != 0;
8769}
intptr_t GetRequiredFlagIndex(intptr_t index, intptr_t *flag_mask) const
Definition: object.cc:8715
FlutterSemanticsFlag flags

◆ IsSubtypeOf()

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

Definition at line 10089 of file object.cc.

10092 {
10093 TRACE_TYPE_CHECKS_VERBOSE(" FunctionType::IsSubtypeOf(%s, %s)\n",
10094 ToCString(), other.ToCString());
10095 const intptr_t num_fixed_params = num_fixed_parameters();
10096 const intptr_t num_opt_pos_params = NumOptionalPositionalParameters();
10097 const intptr_t num_opt_named_params = NumOptionalNamedParameters();
10098 const intptr_t other_num_fixed_params = other.num_fixed_parameters();
10099 const intptr_t other_num_opt_pos_params =
10100 other.NumOptionalPositionalParameters();
10101 const intptr_t other_num_opt_named_params =
10102 other.NumOptionalNamedParameters();
10103 // This signature requires the same arguments or less and accepts the same
10104 // arguments or more. We can ignore implicit parameters.
10105 const intptr_t num_ignored_params = num_implicit_parameters();
10106 const intptr_t other_num_ignored_params = other.num_implicit_parameters();
10107 if (((num_fixed_params - num_ignored_params) >
10108 (other_num_fixed_params - other_num_ignored_params)) ||
10109 ((num_fixed_params - num_ignored_params + num_opt_pos_params) <
10110 (other_num_fixed_params - other_num_ignored_params +
10111 other_num_opt_pos_params)) ||
10112 (num_opt_named_params < other_num_opt_named_params)) {
10114 " - result: false (mismatch in number of parameters)\n");
10115 return false;
10116 }
10117 Thread* thread = Thread::Current();
10118 Zone* zone = thread->zone();
10119 FunctionTypeMapping scope(zone, &function_type_equivalence, *this, other);
10120
10121 // Check the type parameters and bounds of generic functions.
10123 function_type_equivalence)) {
10125 " - result: false (mismatch in type parameters)\n");
10126 return false;
10127 }
10128 // Check the result type.
10129 const AbstractType& other_res_type =
10130 AbstractType::Handle(zone, other.result_type());
10131 // 'void Function()' is a subtype of 'Object Function()'.
10132 if (!other_res_type.IsTopTypeForSubtyping()) {
10133 const AbstractType& res_type = AbstractType::Handle(zone, result_type());
10134 if (!res_type.IsSubtypeOf(other_res_type, space,
10135 function_type_equivalence)) {
10136 TRACE_TYPE_CHECKS_VERBOSE(" - result: false (result type)\n");
10137 return false;
10138 }
10139 }
10140 // Check the types of fixed and optional positional parameters.
10141 for (intptr_t i = 0; i < (other_num_fixed_params - other_num_ignored_params +
10142 other_num_opt_pos_params);
10143 i++) {
10144 if (!IsContravariantParameter(i + num_ignored_params, other,
10145 i + other_num_ignored_params, space,
10146 function_type_equivalence)) {
10147 TRACE_TYPE_CHECKS_VERBOSE(" - result: false (parameter type)\n");
10148 return false;
10149 }
10150 }
10151 // Check that for each optional named parameter of type T of the other
10152 // function type, there exists an optional named parameter of this function
10153 // type with an identical name and with a type S that is a supertype of T.
10154 // Note that SetParameterNameAt() guarantees that names are symbols, so we
10155 // can compare their raw pointers.
10156 const int num_params = num_fixed_params + num_opt_named_params;
10157 const int other_num_params =
10158 other_num_fixed_params + other_num_opt_named_params;
10159 bool found_param_name;
10160 String& other_param_name = String::Handle(zone);
10161 for (intptr_t i = other_num_fixed_params; i < other_num_params; i++) {
10162 other_param_name = other.ParameterNameAt(i);
10163 ASSERT(other_param_name.IsSymbol());
10164 found_param_name = false;
10165 for (intptr_t j = num_fixed_params; j < num_params; j++) {
10166 ASSERT(String::Handle(zone, ParameterNameAt(j)).IsSymbol());
10167 if (ParameterNameAt(j) == other_param_name.ptr()) {
10168 found_param_name = true;
10169 if (!IsContravariantParameter(j, other, i, space,
10170 function_type_equivalence)) {
10172 " - result: false (optional parameter type)\n");
10173 return false;
10174 }
10175 break;
10176 }
10177 }
10178 if (!found_param_name) {
10180 " - result: false (named parameter not found)\n");
10181 return false;
10182 }
10183 }
10184 // Check that for each required named parameter in this function, there's a
10185 // corresponding required named parameter in the other function.
10186 String& param_name = other_param_name;
10187 for (intptr_t j = num_params - num_opt_named_params; j < num_params; j++) {
10188 if (IsRequiredAt(j)) {
10189 param_name = ParameterNameAt(j);
10190 ASSERT(param_name.IsSymbol());
10191 bool found = false;
10192 for (intptr_t i = other_num_fixed_params; i < other_num_params; i++) {
10193 ASSERT(String::Handle(zone, other.ParameterNameAt(i)).IsSymbol());
10194 if (other.ParameterNameAt(i) == param_name.ptr()) {
10195 found = true;
10196 if (!other.IsRequiredAt(i)) {
10198 " - result: false (mismatch in required named "
10199 "parameters)\n");
10200 return false;
10201 }
10202 }
10203 }
10204 if (!found) {
10206 " - result: false (required named parameter not found)\n");
10207 return false;
10208 }
10209 }
10210 }
10211 TRACE_TYPE_CHECKS_VERBOSE(" - result: true\n");
10212 return true;
10213}
intptr_t NumOptionalPositionalParameters() const
Definition: object.h:9634
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:9984

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

9689 {
9690 return untag()->named_parameter_names();
9691 }

◆ named_parameter_names_offset()

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

Definition at line 9693 of file object.h.

9693 {
9694 return OFFSET_OF(UntaggedFunctionType, named_parameter_names_);
9695 }
#define OFFSET_OF(type, field)
Definition: globals.h:138

◆ New()

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

Definition at line 11631 of file object.cc.

11633 {
11634 Zone* Z = Thread::Current()->zone();
11635 const FunctionType& result =
11637 result.set_packed_parameter_counts(0);
11638 result.set_packed_type_parameter_counts(0);
11639 result.set_named_parameter_names(Object::empty_array());
11640 result.SetNumParentTypeArguments(num_parent_type_arguments);
11641 result.SetHash(0);
11642 result.set_flags(0);
11643 result.set_nullability(nullability);
11645 result.InitializeTypeTestingStubNonAtomic(
11647 return result.ptr();
11648}
#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 9595 of file object.h.

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

◆ num_implicit_parameters()

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

Definition at line 9585 of file object.h.

9585 {
9586 return untag()
9587 ->packed_parameter_counts_.Read<PackedNumImplicitParameters>();
9588 }
UntaggedFunctionType::PackedNumImplicitParameters PackedNumImplicitParameters
Definition: object.h:9522

◆ NumFixedParametersOf()

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

Definition at line 9591 of file object.h.

9591 {
9592 return ptr->untag()
9593 ->packed_parameter_counts_.Read<PackedNumFixedParameters>();
9594 }
UntaggedFunctionType::PackedNumFixedParameters PackedNumFixedParameters
Definition: object.h:9524

◆ NumOptionalNamedParameters()

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

Definition at line 9641 of file object.h.

9641 {
9643 }
static intptr_t NumOptionalNamedParametersOf(FunctionTypePtr ptr)
Definition: object.h:9638

◆ NumOptionalNamedParametersOf()

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

Definition at line 9638 of file object.h.

9638 {
9640 }
static intptr_t NumOptionalParametersOf(FunctionTypePtr ptr)
Definition: object.h:9621

◆ NumOptionalParameters()

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

Definition at line 9625 of file object.h.

9625 {
9626 return NumOptionalParametersOf(ptr());
9627 }

◆ NumOptionalParametersOf()

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

Definition at line 9621 of file object.h.

9621 {
9622 return ptr->untag()
9623 ->packed_parameter_counts_.Read<PackedNumOptionalParameters>();
9624 }

◆ NumOptionalPositionalParameters()

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

Definition at line 9634 of file object.h.

9634 {
9636 }
static intptr_t NumOptionalPositionalParametersOf(FunctionTypePtr ptr)
Definition: object.h:9631

◆ NumOptionalPositionalParametersOf()

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

Definition at line 9631 of file object.h.

9631 {
9633 }

◆ NumParameters()

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

Definition at line 9648 of file object.h.

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

◆ NumParametersOf()

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

Definition at line 9645 of file object.h.

9645 {
9647 }

◆ NumParentTypeArguments()

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

Definition at line 9570 of file object.h.

9570 {
9571 return NumParentTypeArgumentsOf(ptr());
9572 }
static intptr_t NumParentTypeArgumentsOf(FunctionTypePtr ptr)
Definition: object.h:9565

◆ NumParentTypeArgumentsOf()

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

Definition at line 9565 of file object.h.

9565 {
9566 return ptr->untag()
9567 ->packed_type_parameter_counts_.Read<PackedNumParentTypeArguments>();
9568 }
UntaggedFunctionType::PackedNumParentTypeArguments PackedNumParentTypeArguments
Definition: object.h:9517

◆ NumTypeArguments()

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

Definition at line 9583 of file object.h.

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

◆ NumTypeArgumentsOf()

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

Definition at line 9580 of file object.h.

9580 {
9582 }
static intptr_t NumTypeParametersOf(FunctionTypePtr ptr)
Definition: object.h:9574

◆ NumTypeParameters()

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

Definition at line 9578 of file object.h.

9578{ return NumTypeParametersOf(ptr()); }

◆ NumTypeParametersOf()

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

Definition at line 9574 of file object.h.

9574 {
9575 return ptr->untag()
9576 ->packed_type_parameter_counts_.Read<PackedNumTypeParameters>();
9577 }
UntaggedFunctionType::PackedNumTypeParameters PackedNumTypeParameters
Definition: object.h:9518

◆ packed_parameter_counts()

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

Definition at line 9650 of file object.h.

9650 {
9651 return untag()->packed_parameter_counts_;
9652 }

◆ packed_parameter_counts_offset()

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

Definition at line 9654 of file object.h.

9654 {
9655 return OFFSET_OF(UntaggedFunctionType, packed_parameter_counts_);
9656 }

◆ packed_type_parameter_counts()

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

Definition at line 9657 of file object.h.

9657 {
9658 return untag()->packed_type_parameter_counts_;
9659 }

◆ packed_type_parameter_counts_offset()

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

Definition at line 9661 of file object.h.

9661 {
9662 return OFFSET_OF(UntaggedFunctionType, packed_type_parameter_counts_);
9663 }

◆ parameter_types()

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

Definition at line 9678 of file object.h.

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

◆ parameter_types_offset()

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

Definition at line 9680 of file object.h.

9680 {
9681 return OFFSET_OF(UntaggedFunctionType, parameter_types_);
9682 }

◆ ParameterNameAt()

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

Definition at line 8645 of file object.cc.

8645 {
8646 const intptr_t num_fixed = num_fixed_parameters();
8647 if (!HasOptionalNamedParameters() || index < num_fixed) {
8648 // The positional parameter names are stored on the function, not here.
8649 UNREACHABLE();
8650 }
8651 const Array& parameter_names =
8653 return String::RawCast(parameter_names.At(index - num_fixed));
8654}

◆ ParameterTypeAt()

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

Definition at line 8585 of file object.cc.

8585 {
8587 return AbstractType::RawCast(parameter_types.At(index));
8588}

◆ Print()

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

Definition at line 10755 of file object.cc.

10756 {
10757 if (IsNull()) {
10758 printer->AddString("null"); // Signature optimized out in precompiler.
10759 return;
10760 }
10761 Thread* thread = Thread::Current();
10762 Zone* zone = thread->zone();
10763 const TypeParameters& type_params =
10765 if (!type_params.IsNull()) {
10766 printer->AddString("<");
10767 const intptr_t base = NumParentTypeArguments();
10768 const bool kIsClassTypeParameter = false;
10769 // Type parameter names are meaningless after canonicalization.
10770 type_params.Print(thread, zone, kIsClassTypeParameter, base,
10771 name_visibility, printer);
10772 printer->AddString(">");
10773 }
10774 printer->AddString("(");
10775 PrintParameters(thread, zone, name_visibility, printer);
10776 printer->AddString(") => ");
10777 const AbstractType& res_type = AbstractType::Handle(zone, result_type());
10778 if (!res_type.IsNull()) {
10779 res_type.PrintName(name_visibility, printer);
10780 } else {
10781 printer->AddString("null");
10782 }
10783}
void PrintParameters(Thread *thread, Zone *zone, NameVisibility name_visibility, BaseTextBuffer *printer) const
Definition: object.cc:10642

◆ PrintName()

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

Reimplemented from dart::AbstractType.

Definition at line 22588 of file object.cc.

22589 {
22590 const char* suffix = NullabilitySuffix(name_visibility);
22591 if (suffix[0] != '\0') {
22592 printer->AddString("(");
22593 }
22594 FunctionType::Cast(*this).Print(name_visibility, printer);
22595 if (suffix[0] != '\0') {
22596 printer->AddString(")");
22597 printer->AddString(suffix);
22598 }
22599}
virtual const char * NullabilitySuffix(NameVisibility name_visibility) const
Definition: object.cc:21303

◆ PrintParameters()

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

Definition at line 10642 of file object.cc.

10645 {
10646 AbstractType& param_type = AbstractType::Handle(zone);
10647 const intptr_t num_params = NumParameters();
10648 const intptr_t num_fixed_params = num_fixed_parameters();
10649 const intptr_t num_opt_pos_params = NumOptionalPositionalParameters();
10650 const intptr_t num_opt_named_params = NumOptionalNamedParameters();
10651 const intptr_t num_opt_params = num_opt_pos_params + num_opt_named_params;
10652 ASSERT((num_fixed_params + num_opt_params) == num_params);
10653 intptr_t i = 0;
10654 if (name_visibility == kUserVisibleName) {
10655 // Hide implicit parameters.
10657 }
10658 String& name = String::Handle(zone);
10659 while (i < num_fixed_params) {
10660 param_type = ParameterTypeAt(i);
10661 ASSERT(!param_type.IsNull());
10662 param_type.PrintName(name_visibility, printer);
10663 if (i != (num_params - 1)) {
10664 printer->AddString(", ");
10665 }
10666 i++;
10667 }
10668 if (num_opt_params > 0) {
10669 if (num_opt_pos_params > 0) {
10670 printer->AddString("[");
10671 } else {
10672 printer->AddString("{");
10673 }
10674 for (intptr_t i = num_fixed_params; i < num_params; i++) {
10675 if (num_opt_named_params > 0 && IsRequiredAt(i)) {
10676 printer->AddString("required ");
10677 }
10678 param_type = ParameterTypeAt(i);
10679 ASSERT(!param_type.IsNull());
10680 param_type.PrintName(name_visibility, printer);
10681 // The parameter name of an optional positional parameter does not need
10682 // to be part of the signature, since it is not used.
10683 if (num_opt_named_params > 0) {
10685 printer->AddString(" ");
10686 printer->AddString(name.ToCString());
10687 }
10688 if (i != (num_params - 1)) {
10689 printer->AddString(", ");
10690 }
10691 }
10692 if (num_opt_pos_params > 0) {
10693 printer->AddString("]");
10694 } else {
10695 printer->AddString("}");
10696 }
10697 }
10698}
@ kUserVisibleName
Definition: object.h:645
const char *const name

◆ result_type()

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

Definition at line 9670 of file object.h.

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

◆ set_named_parameter_names()

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

Definition at line 8672 of file object.cc.

8672 {
8673 ASSERT(value.ptr() == Object::empty_array().ptr() || value.Length() > 0);
8674 untag()->set_named_parameter_names(value.ptr());
8675}
uint8_t value

◆ set_num_fixed_parameters()

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

Definition at line 11608 of file object.cc.

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

◆ set_num_implicit_parameters()

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

Definition at line 11557 of file object.cc.

11557 {
11558 ASSERT(value >= 0);
11559 untag()->packed_parameter_counts_.Update<PackedNumImplicitParameters>(value);
11560}

◆ set_packed_parameter_counts()

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

Definition at line 11547 of file object.cc.

11548 {
11549 untag()->packed_parameter_counts_ = packed_parameter_counts;
11550}

◆ set_packed_type_parameter_counts()

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

Definition at line 11552 of file object.cc.

11553 {
11554 untag()->packed_type_parameter_counts_ = packed_type_parameter_counts;
11555}

◆ set_parameter_types()

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

Definition at line 8597 of file object.cc.

8597 {
8598 ASSERT(value.IsNull() || value.Length() > 0);
8599 untag()->set_parameter_types(value.ptr());
8600}

◆ set_result_type()

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

Definition at line 8575 of file object.cc.

8575 {
8576 ASSERT(!value.IsNull());
8577 untag()->set_result_type(value.ptr());
8578}

◆ SetIsRequiredAt()

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

Definition at line 8771 of file object.cc.

8771 {
8772#if defined(DART_PRECOMPILER_RUNTIME)
8773 UNREACHABLE();
8774#else
8775 intptr_t flag_mask;
8776 const intptr_t flag_index = GetRequiredFlagIndex(index, &flag_mask);
8777 const Array& parameter_names =
8779 ASSERT(flag_index < parameter_names.Length());
8780 const intptr_t flags =
8781 Smi::Value(Smi::RawCast(parameter_names.At(flag_index)));
8782 parameter_names.SetAt(flag_index, Smi::Handle(Smi::New(flags | flag_mask)));
8783#endif
8784}

◆ SetNumOptionalParameters()

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

Definition at line 11617 of file object.cc.

11619 {
11620 // HasOptionalNamedParameters only checks this bit, so only set it if there
11621 // are actual named parameters.
11622 untag()->packed_parameter_counts_.Update<PackedHasNamedOptionalParameters>(
11623 (value > 0) && !are_optional_positional);
11624 untag()->packed_parameter_counts_.Update<PackedNumOptionalParameters>(value);
11625}

◆ SetNumParentTypeArguments()

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

Definition at line 8835 of file object.cc.

8835 {
8836 ASSERT(value >= 0);
8839 }
8840 untag()->packed_type_parameter_counts_.Update<PackedNumParentTypeArguments>(
8841 value);
8842}
static constexpr bool is_valid(T value)
Definition: bitfield.h:146
static void ReportTooManyTypeParameters(const FunctionType &sig)
Definition: object.cc:8817

◆ SetParameterNameAt()

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

Definition at line 8656 of file object.cc.

8657 {
8658#if defined(DART_PRECOMPILED_RUNTIME)
8659 UNREACHABLE();
8660#else
8661 ASSERT(!value.IsNull() && value.IsSymbol());
8662 const intptr_t num_fixed = num_fixed_parameters();
8663 if (!HasOptionalNamedParameters() || index < num_fixed) {
8664 UNREACHABLE();
8665 }
8666 const Array& parameter_names =
8668 parameter_names.SetAt(index - num_fixed, value);
8669#endif
8670}

◆ SetParameterTypeAt()

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

Definition at line 8590 of file object.cc.

8591 {
8592 ASSERT(!value.IsNull());
8594 parameter_types.SetAt(index, value);
8595}

◆ SetTypeParameters()

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

Definition at line 8826 of file object.cc.

8826 {
8827 untag()->set_type_parameters(value.ptr());
8828 const intptr_t count = value.Length();
8831 }
8832 untag()->packed_type_parameter_counts_.Update<PackedNumTypeParameters>(count);
8833}
int count
Definition: FontMgrTest.cpp:50

◆ ToNullability()

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

Definition at line 21944 of file object.cc.

21945 {
21946 if (nullability() == value) {
21947 return ptr();
21948 }
21949 // Clone function type and set new nullability.
21950 FunctionType& type = FunctionType::Handle(FunctionType::Clone(*this, space));
21951 type.set_nullability(value);
21952 type.SetHash(0);
21953 type.InitializeTypeTestingStubNonAtomic(
21955 if (IsCanonical()) {
21956 // Object::Clone does not clone canonical bit.
21957 ASSERT(!type.IsCanonical());
21958 type ^= type.Canonicalize(Thread::Current());
21959 }
21960 return type.ptr();
21961}

◆ ToUserVisibleCString()

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

Definition at line 11661 of file object.cc.

11661 {
11662 Zone* zone = Thread::Current()->zone();
11663 ZoneTextBuffer printer(zone);
11664 Print(kUserVisibleName, &printer);
11665 return printer.buffer();
11666}
void Print() const
Definition: object.cc:2620

◆ ToUserVisibleString()

StringPtr dart::FunctionType::ToUserVisibleString ( ) const

Definition at line 11668 of file object.cc.

11668 {
11669 Thread* thread = Thread::Current();
11670 ZoneTextBuffer printer(thread->zone());
11671 Print(kUserVisibleName, &printer);
11672 return Symbols::New(thread, printer.buffer());
11673}
static StringPtr New(Thread *thread, const char *cstr)
Definition: symbols.h:723

◆ type_class_id()

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

Reimplemented from dart::AbstractType.

Definition at line 9530 of file object.h.

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

◆ type_parameters()

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

Definition at line 9727 of file object.h.

9727 {
9728 return untag()->type_parameters();
9729 }

◆ type_parameters_offset()

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

Definition at line 9731 of file object.h.

9731 {
9732 return OFFSET_OF(UntaggedFunctionType, type_parameters_);
9733 }

◆ TypeParameterAt()

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

Definition at line 8560 of file object.cc.

8561 {
8562 ASSERT(index >= 0 && index < NumTypeParameters());
8563 Thread* thread = Thread::Current();
8564 Zone* zone = thread->zone();
8565 TypeParameter& type_param = TypeParameter::Handle(
8566 zone, TypeParameter::New(*this, NumParentTypeArguments(),
8568 type_param.SetIsFinalized();
8569 if (IsFinalized()) {
8570 type_param ^= type_param.Canonicalize(thread);
8571 }
8572 return type_param.ptr();
8573}

◆ 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 9903 of file object.cc.

9907 {
9908 ASSERT(num_parent_type_args_adjustment >= 0);
9910 Zone* zone = Thread::Current()->zone();
9911
9912 const intptr_t old_num_parent_type_args = NumParentTypeArguments();
9913 // From now on, adjust all type parameter types
9914 // which belong to this or nested function types.
9915 if (num_free_fun_type_params > old_num_parent_type_args) {
9916 num_free_fun_type_params = old_num_parent_type_args;
9917 }
9918
9919 FunctionType& new_type = FunctionType::Handle(
9920 zone, FunctionType::New(
9921 NumParentTypeArguments() + num_parent_type_args_adjustment,
9922 nullability(), space));
9923 AbstractType& type = AbstractType::Handle(zone);
9924
9925 FunctionTypeMapping scope(zone, &function_type_mapping, *this, new_type);
9926
9927 const TypeParameters& type_params =
9929 if (!type_params.IsNull()) {
9930 const TypeParameters& new_type_params =
9932 // No need to set names that are ignored in a signature, however, the
9933 // length of the names array defines the number of type parameters.
9934 new_type_params.set_names(Array::Handle(zone, type_params.names()));
9935 new_type_params.set_flags(Array::Handle(zone, type_params.flags()));
9936 TypeArguments& type_args = TypeArguments::Handle(zone);
9937 type_args = type_params.bounds();
9938 if (!type_args.IsNull()) {
9939 type_args = type_args.UpdateFunctionTypes(num_parent_type_args_adjustment,
9940 num_free_fun_type_params, space,
9941 function_type_mapping);
9942 }
9943 new_type_params.set_bounds(type_args);
9944 type_args = type_params.defaults();
9945 if (!type_args.IsNull()) {
9946 type_args = type_args.UpdateFunctionTypes(num_parent_type_args_adjustment,
9947 num_free_fun_type_params, space,
9948 function_type_mapping);
9949 }
9950 new_type_params.set_defaults(type_args);
9951 new_type.SetTypeParameters(new_type_params);
9952 }
9953
9954 type = result_type();
9955 type = type.UpdateFunctionTypes(num_parent_type_args_adjustment,
9956 num_free_fun_type_params, space,
9957 function_type_mapping);
9958 new_type.set_result_type(type);
9959
9960 const intptr_t num_params = NumParameters();
9961 new_type.set_num_implicit_parameters(num_implicit_parameters());
9962 new_type.set_num_fixed_parameters(num_fixed_parameters());
9963 new_type.SetNumOptionalParameters(NumOptionalParameters(),
9965 new_type.set_parameter_types(Array::Handle(Array::New(num_params, space)));
9966 for (intptr_t i = 0; i < num_params; i++) {
9968 type = type.UpdateFunctionTypes(num_parent_type_args_adjustment,
9969 num_free_fun_type_params, space,
9970 function_type_mapping);
9971 new_type.SetParameterTypeAt(i, type);
9972 }
9973 new_type.set_named_parameter_names(
9975 new_type.SetIsFinalized();
9976
9977 return new_type.ptr();
9978}

Friends And Related Function Documentation

◆ Class

friend class Class
friend

Definition at line 9793 of file object.h.

◆ Function

friend class Function
friend

Definition at line 9794 of file object.h.


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