Index: runtime/vm/precompiler.h |
diff --git a/runtime/vm/precompiler.h b/runtime/vm/precompiler.h |
index c32a955269d43287faa9958dac99e0cd8b9e3404..3dc25e0ce4a5d46a02db21b4972f2a92a2a54bee 100644 |
--- a/runtime/vm/precompiler.h |
+++ b/runtime/vm/precompiler.h |
@@ -7,6 +7,7 @@ |
#include "vm/allocation.h" |
#include "vm/hash_map.h" |
+#include "vm/hash_table.h" |
#include "vm/object.h" |
namespace dart { |
@@ -256,6 +257,34 @@ class Precompiler : public ValueObject { |
Error& error_; |
}; |
+ |
+class FunctionsTraits { |
+ public: |
+ static bool IsMatch(const Object& a, const Object& b) { |
+ Zone* zone = Thread::Current()->zone(); |
+ String& a_s = String::Handle(zone); |
+ String& b_s = String::Handle(zone); |
+ a_s = a.IsFunction() ? Function::Cast(a).name() : String::Cast(a).raw(); |
+ b_s = b.IsFunction() ? Function::Cast(b).name() : String::Cast(b).raw(); |
+ ASSERT(a_s.IsSymbol() && b_s.IsSymbol()); |
+ return a_s.raw() == b_s.raw(); |
+ } |
+ static uword Hash(const Object& obj) { |
+ if (obj.IsFunction()) { |
+ return String::Handle(Function::Cast(obj).name()).Hash(); |
+ } else { |
+ ASSERT(String::Cast(obj).IsSymbol()); |
+ return String::Cast(obj).Hash(); |
+ } |
+ } |
+ static RawObject* NewKey(const Function& function) { |
+ return function.raw(); |
+ } |
+}; |
+ |
+typedef UnorderedHashSet<FunctionsTraits> UniqueFunctionsSet; |
+ |
+ |
} // namespace dart |
#endif // VM_PRECOMPILER_H_ |