Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store type string alongside LLVM types in spec #327

Open
wants to merge 2 commits into
base: ian/set_context_at_entry_to_function
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions include/anvill/Declarations.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ struct ValueDecl {

// Type of this value.
llvm::Type *type{nullptr};

// Untranslated type string of this value.
std::string type_string;
};

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

// Untranslated type string of this variable.
std::string type_string;

// Address of this global variable.
std::uint64_t address{0};

Expand Down
2 changes: 2 additions & 0 deletions lib/JSON.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ JSONTranslator::DecodeValue(const llvm::json::Object *obj, const char *desc,

if (auto maybe_type_str = obj->getString("type")) {
std::string spec = maybe_type_str->str();
decl.type_string = spec;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you missed doing this assignment in ParseJsonIntoCallableDecl

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't it use DecodeValue as well?

auto type_spec_res = type_translator.DecodeFromString(spec);
if (!type_spec_res.Succeeded()) {
std::stringstream ss;
Expand Down Expand Up @@ -754,6 +755,7 @@ JSONTranslator::DecodeGlobalVar(const llvm::json::Object *obj) const {

anvill::VariableDecl decl;
decl.type = type;
decl.type_string = spec;
decl.address = address;
return decl;
}
Expand Down
1 change: 1 addition & 0 deletions libraries/doctest/src
Submodule src added at f0ab4e