Forums » Programming with the ECS » Intermediate Code »
How to represent a union type?
Added by Rochus Keller over 1 year ago
I undestand how a record (struct) type has to be represented, but I didn't find out yet how to represent a union type.
The C++ compiler so far seems neither to render unions nor structs. If I enter something like
union X {
int a;
char b;
};
void test(X x) {
}
in the sandbox, I get
.code "test(X)"
loc "input", 6, 6
void
push fun $lnk
enter 0
sym +2, "x", ptr [$fp + 32]
loc "input", 6, 13
type "X"
pop ptr $fp
ret
Replies (2)
RE: How to represent a union type? - Added by Florian Negele over 1 year ago
A union type can be represented using a record type with all fields located at offset zero.
RE: How to represent a union type? - Added by Rochus Keller over 1 year ago
That was obvious, sorry for the stupid question.