CSC448: Code Generation: Run-Time Storage for Objects II [76/133] |
Corin did not show
For field access, find the type of the object whose field we
are accessing (use tc.getType
), then look up
the field offset (use the lookupFieldOffset
method).
For constructor calls, allocate room for the object on the heap by calling malloc (passing (the size of the object + 1) * slotSize). A pointer to the allocated memory is returned. It will eventually be a pointer to the object. Move the address of the vtable into the zero offset, then move all of the new field values into the memory allocated on the heap.
Hunt for examples in: