-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closer to what I want, but definitely not there yet.
- Loading branch information
Showing
70 changed files
with
1,917 additions
and
1,614 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package(default_visibility = ["//visibility:public"]) | ||
|
||
cc_library( | ||
name = "category", | ||
hdrs = ["category.h"], | ||
deps = [ | ||
"//common/language:type_kind", | ||
], | ||
) | ||
|
||
cc_library( | ||
name = "component", | ||
hdrs = ["component.h"], | ||
deps = [ | ||
":category", | ||
"//common:result", | ||
"@nth_cc//nth/debug", | ||
"@nth_cc//nth/io/deserialize", | ||
"@nth_cc//nth/io/serialize", | ||
"@nth_cc//nth/utility:bytes", | ||
], | ||
) | ||
|
||
cc_library( | ||
name = "entry", | ||
hdrs = ["entry.h"], | ||
deps = [], | ||
) | ||
|
||
cc_library( | ||
name = "manifest", | ||
hdrs = ["manifest.h"], | ||
srcs = ["manifest.cc"], | ||
deps = [ | ||
":category", | ||
":component", | ||
"//common:result", | ||
"//common/internal:functions", | ||
"//common/internal:identifiers", | ||
"//common/internal:integers", | ||
"//common/internal:parameters", | ||
"//common/internal:strings", | ||
"@com_google_absl//absl/container:flat_hash_map", | ||
"@nth_cc//nth/debug", | ||
"@nth_cc//nth/io/deserialize", | ||
"@nth_cc//nth/io/serialize", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#ifndef ICARUS_COMMON_CONSTANT_CATEGORY_H | ||
#define ICARUS_COMMON_CONSTANT_CATEGORY_H | ||
|
||
#include <cstdint> | ||
|
||
namespace ic { | ||
|
||
enum class ConstantCategory : uint8_t { | ||
#define IC_XMACRO_TYPE_KIND(kind) kind##Type, | ||
#include "common/language/type_kind.xmacro.h" | ||
Followup, | ||
Integer, | ||
String, | ||
}; | ||
|
||
} // namespace ic | ||
|
||
#endif // ICARUS_COMMON_CONSTANT_CATEGORY_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#ifndef ICARUS_COMMON_CONSTANT_COMPONENT_H | ||
#define ICARUS_COMMON_CONSTANT_COMPONENT_H | ||
|
||
#include <cstdint> | ||
|
||
#include "common/constant/category.h" | ||
#include "common/result.h" | ||
#include "nth/io/deserialize/deserialize.h" | ||
#include "nth/io/serialize/serialize.h" | ||
#include "nth/utility/bytes.h" | ||
|
||
namespace ic { | ||
|
||
struct ConstantComponent { | ||
ConstantComponent() = default; | ||
explicit constexpr ConstantComponent(ConstantCategory category, uint32_t value) | ||
: value_(value), category_(static_cast<uint8_t>(category)) {} | ||
|
||
friend Result NthSerialize(auto& s, ConstantComponent const& c) { | ||
return s.write(nth::bytes(c)); | ||
} | ||
friend Result NthDeserialize(auto& d, ConstantComponent& c) { | ||
return d.read(nth::bytes(c)); | ||
} | ||
|
||
[[nodiscard]] constexpr ConstantCategory category() const { | ||
return static_cast<ConstantCategory>(category_); | ||
} | ||
[[nodiscard]] constexpr uint32_t value() const { return value_; } | ||
|
||
private: | ||
// `value_` stores the width for categories that have variable-length widths | ||
// and an actual value for categories with a fixed-length width. | ||
uint32_t value_ : 24; | ||
uint32_t category_ : 8; | ||
}; | ||
|
||
} // namespace ic | ||
|
||
#endif // ICARUS_COMMON_CONSTANT_COMPONENT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#ifndef ICARUS_COMMON_CONSTANT_ENTRY_H | ||
#define ICARUS_COMMON_CONSTANT_ENTRY_H | ||
|
||
#include <cstdint> | ||
|
||
namespace ic { | ||
|
||
struct Constant { | ||
constexpr uint32_t value() const { return value_; } | ||
|
||
private: | ||
friend struct ConstantManifest; | ||
constexpr Constant(uint32_t index) : value_(index) {} | ||
|
||
uint32_t value_; | ||
}; | ||
|
||
} // namespace ic | ||
|
||
#endif // ICARUS_COMMON_CONSTANT_ENTRY_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include "common/constant/manifest.h" | ||
|
||
#include "common/internal/functions.h" | ||
#include "common/internal/parameters.h" | ||
#include "nth/debug/debug.h" | ||
#include "nth/utility/no_destructor.h" | ||
|
||
namespace ic { | ||
namespace { | ||
|
||
nth::NoDestructor<ConstantManifest> global_manifest_; | ||
|
||
} // namespace | ||
|
||
ConstantManifest const& ConstantManifest::Global() { | ||
[[maybe_unused]] static const bool init = [&] { | ||
internal_common::InitializeParameters(global_manifest_->table()); | ||
internal_common::InitializeFunctions(global_manifest_->table()); | ||
return false; | ||
}(); | ||
return *global_manifest_; | ||
} | ||
|
||
ConstantManifest& ConstantManifest::MutableGlobal() { | ||
return *global_manifest_; | ||
} | ||
|
||
Constant ConstantManifest::NextSlot() const { | ||
return Constant(components_.size()); | ||
} | ||
|
||
ConstantComponent const& ConstantManifest::operator[](size_t n) const { | ||
NTH_REQUIRE((v.harden), n < components_.size()); | ||
return components_[n]; | ||
} | ||
|
||
void InsertIntoGlobalConstantManifest(ConstantCategory category, uint32_t n) { | ||
global_manifest_->components_.emplace_back(category, n); | ||
NTH_LOG("{} INserting. size is now {}")<<={category, global_manifest_->components_.size()}; | ||
} | ||
|
||
} // namespace ic |
Oops, something went wrong.