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

#include <canonical_tables.h>

Static Public Member Functions

static const char * Name ()
 
static bool ReportStats ()
 
static bool IsMatch (const Object &a, const Object &b)
 
static uword Hash (const Object &key)
 

Detailed Description

Definition at line 337 of file canonical_tables.h.

Member Function Documentation

◆ Hash()

uword dart::MetadataMapTraits::Hash ( const Object key)
static

Definition at line 61 of file canonical_tables.cc.

61 {
62 if (key.IsLibrary()) {
63 return String::Hash(Library::Cast(key).url());
64 } else if (key.IsClass()) {
65 return String::Hash(Class::Cast(key).Name());
66 } else if (key.IsFunction()) {
67 return CombineHashes(String::Hash(Function::Cast(key).name()),
68 Hash(Object::Handle(Function::Cast(key).Owner())));
69 } else if (key.IsField()) {
70 return CombineHashes(String::Hash(Field::Cast(key).name()),
71 Hash(Object::Handle(Field::Cast(key).Owner())));
72 } else if (key.IsTypeParameter()) {
73 return TypeParameter::Cast(key).Hash();
74 } else if (key.IsNamespace()) {
75 return Hash(Library::Handle(Namespace::Cast(key).target()));
76 }
78}
#define UNREACHABLE()
Definition: assert.h:248
static uword Hash(const Object &key)
static const char * Name()
static Object & Handle()
Definition: object.h:407
uword Hash() const
Definition: object.h:10216
uint32_t * target
const char *const name
uint32_t CombineHashes(uint32_t hash, uint32_t other_hash)
Definition: hash.h:12

◆ IsMatch()

bool dart::MetadataMapTraits::IsMatch ( const Object a,
const Object b 
)
static

Definition at line 11 of file canonical_tables.cc.

11 {
12 // In the absence of hot reload, this can just be an identity check. With
13 // reload, some old program elements may be retained by the stack, closures
14 // or mirrors, which are absent from the new version of the library's
15 // metadata table. This name-based matching fuzzy maps the old program
16 // elements to corresponding new elements, preserving the behavior of the old
17 // metaname+fields scheme.
18 if (a.IsLibrary() && b.IsLibrary()) {
19 const String& url_a = String::Handle(Library::Cast(a).url());
20 const String& url_b = String::Handle(Library::Cast(b).url());
21 return url_a.Equals(url_b);
22 } else if (a.IsClass() && b.IsClass()) {
23 const String& name_a = String::Handle(Class::Cast(a).Name());
24 const String& name_b = String::Handle(Class::Cast(b).Name());
25 return name_a.Equals(name_b);
26 } else if (a.IsFunction() && b.IsFunction()) {
27 const auto& func_a = Function::Cast(a);
28 const auto& func_b = Function::Cast(b);
29 if (func_a.IsNonImplicitClosureFunction() ||
30 func_b.IsNonImplicitClosureFunction()) {
31 return a.ptr() == b.ptr();
32 }
33 const String& name_a = String::Handle(func_a.name());
34 const String& name_b = String::Handle(func_b.name());
35 if (!name_a.Equals(name_b)) {
36 return false;
37 }
38 const Object& owner_a = Object::Handle(Function::Cast(a).Owner());
39 const Object& owner_b = Object::Handle(Function::Cast(b).Owner());
40 return IsMatch(owner_a, owner_b);
41 } else if (a.IsField() && b.IsField()) {
42 const String& name_a = String::Handle(Field::Cast(a).name());
43 const String& name_b = String::Handle(Field::Cast(b).name());
44 if (!name_a.Equals(name_b)) {
45 return false;
46 }
47 const Object& owner_a = Object::Handle(Field::Cast(a).Owner());
48 const Object& owner_b = Object::Handle(Field::Cast(b).Owner());
49 return IsMatch(owner_a, owner_b);
50 } else if (a.IsTypeParameter() && b.IsTypeParameter()) {
51 if (TypeParameter::Cast(a).index() != TypeParameter::Cast(b).index() ||
52 TypeParameter::Cast(a).base() != TypeParameter::Cast(b).base()) {
53 return false;
54 }
55 return TypeParameter::Cast(a).parameterized_class_id() ==
56 TypeParameter::Cast(b).parameterized_class_id();
57 }
58 return a.ptr() == b.ptr();
59}
static bool IsMatch(const Object &a, const Object &b)
static bool b
struct MyStruct a[10]

◆ Name()

static const char * dart::MetadataMapTraits::Name ( )
inlinestatic

Definition at line 339 of file canonical_tables.h.

339{ return "MetadataMapTraits"; }

◆ ReportStats()

static bool dart::MetadataMapTraits::ReportStats ( )
inlinestatic

Definition at line 340 of file canonical_tables.h.

340{ return false; }

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