pirvtable.c - implementation of a vtable, that is used by the parser for its semantic actions.


Using a vtable makes changing the behaviour of the parser easy. The parser calls vtable methods at certain points, for instance at the start of a subroutine and at the end. Depending on the type of output that is expected, the appropiate function is invoked. Any output type should implement all vtable methods for correct behaviour.


static void not_implemented(struct emit_data *data, ...)

Default entry that is set to all vtable entries. If a particular vtable entry is invoked, but was never implemented, this method is called. This is usefulS, because not all output type need all vtable methods. The variable arguments are necessary, you never know how many args a method has.


pirvtable *new_pirvtable(void)

Constructor for a pir vtable. All entries are set to "not_implemented" function.

void destroy_pirvtable(pirvtable *vtable)

Destructor for the pirvtable. It first calls the custome destructor of the emit_data structure, which is private to each of the back-ends (so we don't know what memory is allocated for that, only the back-ends know).