Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | Static Public Member Functions | List of all members
dart::kernel::InferredTypeMetadataHelper Class Reference

#include <kernel_translation_helper.h>

Inheritance diagram for dart::kernel::InferredTypeMetadataHelper:
dart::kernel::MetadataHelper

Public Types

enum class  Kind { Type , ArgType }
 

Public Member Functions

 InferredTypeMetadataHelper (KernelReaderHelper *helper, ConstantReader *constant_reader, Kind kind=Kind::Type)
 
InferredTypeMetadata GetInferredType (intptr_t node_offset, bool read_constant=true)
 
- Public Member Functions inherited from dart::kernel::MetadataHelper
 MetadataHelper (KernelReaderHelper *helper, const char *tag, bool precompiler_only)
 

Static Public Member Functions

static const char * tag (Kind kind)
 

Additional Inherited Members

- Protected Member Functions inherited from dart::kernel::MetadataHelper
intptr_t FindMetadataMapping (intptr_t node_offset)
 
intptr_t GetNextMetadataPayloadOffset (intptr_t node_offset)
 
intptr_t GetComponentMetadataPayloadOffset ()
 
- Protected Attributes inherited from dart::kernel::MetadataHelper
KernelReaderHelperhelper_
 
TranslationHelpertranslation_helper_
 

Detailed Description

Definition at line 1061 of file kernel_translation_helper.h.

Member Enumeration Documentation

◆ Kind

Enumerator
Type 
ArgType 

Definition at line 1063 of file kernel_translation_helper.h.

1063 {
1064 Type, // Inferred type of a call, field or variable.
1065 ArgType, // Inferred incoming argument type.
1066 };

Constructor & Destructor Documentation

◆ InferredTypeMetadataHelper()

dart::kernel::InferredTypeMetadataHelper::InferredTypeMetadataHelper ( KernelReaderHelper helper,
ConstantReader constant_reader,
InferredTypeMetadataHelper::Kind  kind = Kind::Type 
)
explicit

Definition at line 1868 of file kernel_translation_helper.cc.

1872 : MetadataHelper(helper, tag(kind), /* precompiler_only = */ true),
1873 constant_reader_(constant_reader) {}
MetadataHelper(KernelReaderHelper *helper, const char *tag, bool precompiler_only)

Member Function Documentation

◆ GetInferredType()

InferredTypeMetadata dart::kernel::InferredTypeMetadataHelper::GetInferredType ( intptr_t  node_offset,
bool  read_constant = true 
)

Definition at line 1875 of file kernel_translation_helper.cc.

1877 {
1878 const intptr_t md_offset = GetNextMetadataPayloadOffset(node_offset);
1879 if (md_offset < 0) {
1880 return InferredTypeMetadata(kDynamicCid,
1882 }
1883
1884 AlternativeReadingScopeWithNewData alt(&helper_->reader_,
1885 &H.metadata_payloads(), md_offset);
1886
1887 const NameIndex kernel_name = helper_->ReadCanonicalNameReference();
1888 const uint8_t flags = helper_->ReadByte();
1889
1890 const Object* constant_value = &Object::null_object();
1892 const intptr_t constant_index = helper_->ReadUInt();
1893 if (read_constant) {
1894 constant_value = &Object::ZoneHandle(
1895 H.zone(), constant_reader_->ReadConstant(constant_index));
1896 }
1897 }
1898
1899 if (H.IsRoot(kernel_name)) {
1901 return InferredTypeMetadata(kDynamicCid, flags);
1902 }
1903
1904 const Class& klass =
1905 Class::Handle(helper_->zone_, H.LookupClassByKernelClass(kernel_name));
1906 ASSERT(!klass.IsNull());
1907
1908 intptr_t cid = klass.id();
1909 if (cid == kClosureCid) {
1910 // VM uses more specific function types and doesn't expect instances of
1911 // _Closure class, so inferred _Closure class doesn't make sense for the VM.
1912 cid = kDynamicCid;
1913 }
1914
1915 return InferredTypeMetadata(cid, flags, *constant_value);
1916}
static Object & Handle()
Definition: object.h:407
static Object & ZoneHandle()
Definition: object.h:419
InstancePtr ReadConstant(intptr_t constant_index)
intptr_t GetNextMetadataPayloadOffset(intptr_t node_offset)
#define ASSERT(E)
FlutterSemanticsFlag flags
@ kDynamicCid
Definition: class_id.h:253
const intptr_t cid
Definition: SkMD5.cpp:130

◆ tag()

static const char * dart::kernel::InferredTypeMetadataHelper::tag ( Kind  kind)
inlinestatic

Definition at line 1068 of file kernel_translation_helper.h.

1068 {
1069 switch (kind) {
1070 case Kind::Type:
1071 return "vm.inferred-type.metadata";
1072 case Kind::ArgType:
1073 return "vm.inferred-arg-type.metadata";
1074 }
1075 UNREACHABLE();
1076 return nullptr;
1077 }
#define UNREACHABLE()
Definition: assert.h:248

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