<div dir="ltr"><div><div><div><div>Hi all,<br><br></div>I'm working on a run time that allows you to run code on the fly. My language allows users to define custom structs.<br><br></div>Once
 I have generated a func that returns a struct, I would like to map the 
function result back to a std::vector<GenericValue> to be used in 
the c++ part. For normal return types (char, ints, double) its easy to 
cast to their function pointer and execute and wrap the results.<br><br></div><div>// for double f();<br>auto func = (double (*f)()) engine->getFunctionAddress("f");<br></div><div>double result = func(); <br><br></div><div>// how to do this for exampleStruct {double, double}, where example struct is defined by the user<br></div><div>// exampleStruct f();<br></div><div>// we can't do auto func = (exampleStruct (*f)()) engine->getFunctionAddress("f");<br></div><div>// since example struct is defined by the user inside the runtime/interpreter<br></div><div>??<br><br></div><div>How
 can I cast a function that returns a user defined struct ? I know the 
layout of the struct, but the struct layout might be different in the IR
 vs C++? I know I could alloc memory in the func and return a ptr to a 
struct (returned as void* ), and use that as an offset to read the 
struct values, but I would like to avoid using a ptr in this case. What 
would be the right approach in ths case?<br></div><div><br></div>I tried to look into t he executionengine::runFunction but, they are incomplete.<br></div>I'm using llvm 3.7 btw.</div>