jserv / amacc

Small C Compiler generating ELF executable Arm architecture, supporting JIT execution
Other
1.01k stars 160 forks source link

Add support for struct assignement. #92

Open HPCguy opened 2 years ago

HPCguy commented 2 years ago

Struct/union assignments are not currently allowed, since they require moving mem blocks:

struct foo s1, s2;
s1 = s2;  // not allowed

That said, the AST tracks all the type information needed to support this. Assignment/copy just needs to be converted to a SYSC to memcpy(). Also, for function return values and parameters, the C-standard ABI conventions need to be followed. I looked at the C89 standard and didn't see it spelled out. Some compilers used to convert struct parameters to pointers automatically if the struct size exceeded a certain limit, and I am not sure what the rules are now.