MCPcopy Create free account
hub / github.com/WebAssembly/wabt / GenTypeDecl

Method GenTypeDecl

include/wabt/decompiler-ls.h:212–237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

210 }
211
212 std::string GenTypeDecl(const std::string& name) const {
213 auto it = vars.find(name);
214 if (it == vars.end()) {
215 return "";
216 }
217 if (it->second.struct_layout) {
218 std::string s = "{ ";
219 for (auto& access : it->second.accesses) {
220 if (access.second.idx) {
221 s += ", ";
222 }
223 s += IdxToName(access.second.idx);
224 s += ':';
225 s += GetDecompTypeName(access.second.type);
226 }
227 s += " }";
228 return s;
229 }
230 // We don't have a struct layout, or the struct has just one field,
231 // so maybe we can just declare it as a pointer to one type?
232 if (it->second.same_type != Type::Void) {
233 return cat(GetDecompTypeName(it->second.same_type), "_ptr",
234 GenAlign(it->second.same_align, it->second.last_opc));
235 }
236 return "";
237 }
238
239 std::string GenAccess(uint64_t offset, const Node& addr_exp) const {
240 auto name = AddrExpName(addr_exp);

Callers 1

LocalDeclMethod · 0.80

Calls 4

GetDecompTypeNameFunction · 0.85
catFunction · 0.85
findMethod · 0.80
endMethod · 0.45

Tested by

no test coverage detected