Ian Lance Taylor wrote:
Since you are generating C code, you control the horizontal and the
vertical. Count the number of virtual calls you have, and emit
struct object_header *__my_private_temp_1;
struct object_header *__my_private_temp_2;
...
at the start of the C function. Then for each virtual call do
(__my_private_temp_N = objectexpression,
((int(*)(struct object_header *, int))
(temp->vmt[VMTINDEX_MyObject_square))(__my_private_temp_N, 5)))
replacing N with the index of the call.
Ah, of course! That will make the code a lot nicer than what I was thinking.
Thanks!
Nicholas Sherlock