Skip to content

Commit 2cbbdac

Browse files
committed
Store type string alongside LLVM types in spec
1 parent 55d47e9 commit 2cbbdac

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

include/anvill/Declarations.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ struct ValueDecl {
6666

6767
// Type of this value.
6868
llvm::Type *type{nullptr};
69+
70+
// Untranslated type string of this value.
71+
std::string type_string;
6972
};
7073

7174
// A value declaration corresponding with a named parameter.
@@ -105,6 +108,9 @@ struct VariableDecl {
105108
// `0x14` there is also an `int`.
106109
llvm::Type *type{nullptr};
107110

111+
// Untranslated type string of this variable.
112+
std::string type_string;
113+
108114
// Address of this global variable.
109115
std::uint64_t address{0};
110116

lib/JSON.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ JSONTranslator::DecodeValue(const llvm::json::Object *obj, const char *desc,
361361

362362
if (auto maybe_type_str = obj->getString("type")) {
363363
std::string spec = maybe_type_str->str();
364+
decl.type_string = spec;
364365
auto type_spec_res = type_translator.DecodeFromString(spec);
365366
if (!type_spec_res.Succeeded()) {
366367
std::stringstream ss;
@@ -754,6 +755,7 @@ JSONTranslator::DecodeGlobalVar(const llvm::json::Object *obj) const {
754755

755756
anvill::VariableDecl decl;
756757
decl.type = type;
758+
decl.type_string = spec;
757759
decl.address = address;
758760
return decl;
759761
}

0 commit comments

Comments
 (0)