initial commit
This commit is contained in:
commit
549fbc6b74
31 changed files with 3377 additions and 0 deletions
65
devoir/include/mne.h
Normal file
65
devoir/include/mne.h
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
/**
|
||||
* @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 */
|
||||
Loading…
Add table
Add a link
Reference in a new issue