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

Unified Diff: courgette/image_utils.h

Issue 1491703003: [Courgette] Initial Implementation of LabelManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
Index: courgette/image_utils.h
diff --git a/courgette/image_utils.h b/courgette/image_utils.h
index c016357732d05745c3487a317b1eab98d91fa840..9c5d00537f8dd866d2b84ebe29f911bec5586746 100644
--- a/courgette/image_utils.h
+++ b/courgette/image_utils.h
@@ -15,6 +15,28 @@ namespace courgette {
typedef uint32 RVA;
+// A Label is a symbolic reference to an address. Unlike a conventional
+// assembly language, we always know the address. The address will later be
+// stored in a table and the Label will be replaced with the index into the
+// table.
+//
+// TODO(sra): Make fields private and add setters and getters.
+class Label {
+ public:
+ static const int kNoIndex = -1;
grt (UTC plus 2) 2015/12/02 19:03:40 nit: enum : int { kNoIndex = -1 }; as per https:
huangs 2015/12/02 20:51:02 Done.
+ Label() : rva_(0), index_(kNoIndex), count_(0) {}
+ explicit Label(RVA rva) : rva_(rva), index_(kNoIndex), count_(0) {}
+
+ bool operator==(const Label& other) const {
+ return rva_ == other.rva_ && index_ == other.index_ &&
+ count_ == other.count_;
+ }
+
+ RVA rva_; // Address referred to by the label.
grt (UTC plus 2) 2015/12/02 19:03:40 use non-static member initializers here; e.g.: R
huangs 2015/12/02 20:51:02 Done.
+ int index_; // Index of address in address table, kNoIndex until assigned.
+ int count_;
+};
+
// These helper functions avoid the need for casts in the main code.
inline uint16 ReadU16(const uint8* address, size_t offset) {
return *reinterpret_cast<const uint16*>(address + offset);

Powered by Google App Engine
This is Rietveld 408576698