Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(668)

Unified Diff: src/module-resolve-set-inl.h

Issue 2367623004: [modules] Detect and throw exceptions for cyclic dependencies (Closed)
Patch Set: Update golden files Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/messages.h ('k') | src/objects.h » ('j') | src/objects.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/module-resolve-set-inl.h
diff --git a/src/module-resolve-set-inl.h b/src/module-resolve-set-inl.h
new file mode 100644
index 0000000000000000000000000000000000000000..55cbff70a364287e3bd8195647b5f930ef51851e
--- /dev/null
+++ b/src/module-resolve-set-inl.h
@@ -0,0 +1,68 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef V8_MODULE_RESOLVE_SET_INL_H_
+#define V8_MODULE_RESOLVE_SET_INL_H_
+
+#include <unordered_map>
+#include <unordered_set>
+#include <utility>
+
+#include "src/objects-inl.h" // inl version required for hashing
+#include "src/zone/zone-allocator.h"
+#include "src/zone/zone.h"
+
+namespace v8 {
+namespace internal {
+
+template <typename T>
+struct Module::HandleValueHash {
+ V8_INLINE size_t operator()(Handle<T> handle) const { return handle->Hash(); }
+};
+
+struct Module::ModuleHandleEqual {
+ V8_INLINE bool operator()(Handle<Module> lhs, Handle<Module> rhs) const {
+ return *lhs == *rhs;
+ }
+};
+
+struct Module::StringHandleEqual {
+ V8_INLINE bool operator()(Handle<String> lhs, Handle<String> rhs) const {
+ return lhs->Equals(*rhs);
+ }
+};
+
+class Module::UnorderedStringSet
+ : public std::unordered_set<Handle<String>, HandleValueHash<String>,
+ StringHandleEqual,
+ zone_allocator<Handle<String>>> {
+ public:
+ explicit UnorderedStringSet(Zone* zone)
+ : std::unordered_set<Handle<String>, HandleValueHash<String>,
+ StringHandleEqual, zone_allocator<Handle<String>>>(
+ 2, HandleValueHash<String>(), StringHandleEqual(),
+ zone_allocator<Handle<String>>(zone)) {}
+};
+
+class Module::ResolveSet
+ : public std::unordered_map<
+ Handle<Module>, UnorderedStringSet*, HandleValueHash<Module>,
+ ModuleHandleEqual, zone_allocator<std::pair<const Handle<Module>,
+ UnorderedStringSet*>>> {
+ public:
+ explicit ResolveSet(Zone* zone)
+ : std::unordered_map<Handle<Module>, UnorderedStringSet*,
+ HandleValueHash<Module>, ModuleHandleEqual,
+ zone_allocator<std::pair<const Handle<Module>,
+ UnorderedStringSet*>>>(
+ 2 /* bucket count */, HandleValueHash<Module>(),
+ ModuleHandleEqual(),
+ zone_allocator<
+ std::pair<const Handle<Module>, UnorderedStringSet*>>(zone)) {}
+};
+
+} // namespace internal
+} // namespace v8
+
+#endif // V8_MODULE_RESOLVE_SET_INL_H_
« no previous file with comments | « src/messages.h ('k') | src/objects.h » ('j') | src/objects.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698