/** * @file mne.h * @brief Abstract interface for mnemonics (bytecode instructions). */ #ifndef MNE_H #define MNE_H /* Forward declarations to break circular dependencies. */ typedef struct _stack_t stack_t; typedef struct _visitor_t visitor_t; /** * @brief Forward declaration of abstract class Mne. * */ typedef struct _mne_t mne_t; /** * @brief Virtual method table for Mne interface. * */ typedef struct { /** * @brief Destroy method (polymorphic destructor). */ void (*destroy_fn)(mne_t *); /** * @brief Interpret method: execute this mnemonic on the given stack. */ void (*interpret_fn)(const mne_t *const, stack_t *const); /** * @brief Accept method: allow a visitor to visit this mnemonic. */ void (*accept_fn)(const mne_t *const, visitor_t *const); } mne_vtable_t; /** * @brief Polymorphic destructor: calls the destroy method via vtable. * * @param self The mnemonic (can be NULL). */ void mne_destroy(mne_t *self); /** * @brief Interpreter method: execute this mnemonic on the given stack. * * @param self The mnemonic. * @param stack The stack to interpret on. * @pre self != NULL && stack != NULL. */ void mne_interpret(const mne_t *const self, stack_t *const stack); /** * @brief Visitor acceptance method: allow a visitor to visit this mnemonic. * * @param self The mnemonic. * @param visitor The visitor. * @pre self != NULL && visitor != NULL. */ void mne_accept(const mne_t *const self, visitor_t *const visitor); #endif /* MNE_H */