Previous: , Up: Instruction Meta-class Definition   [Contents][Index]


4.3.6 Function Layout

Below is a template for the event handler function of an instruction meta-class.

QSMM_INSTR_META_CLASS(instr_meta_class_name) {
    struct param_s param;
        // structure "param_s" is for holding instruction parameters in
        // binary form
    // TODO: declare (and possibly initialize) other automatic variables.
    if (QSMM_HAS_INSTR_CLASS(qsmm_evt))
        qsmm_get_eh_instr_param(qsmm,sizeof(param),&param);
    switch (qsmm_evt) {
        case QSMM_EVT_ENT_INIT:
            // TODO: handle the instruction meta-class initialization
            //       event.
            break;
        case QSMM_EVT_ENT_DONE:
            // TODO: handle the instruction meta-class uninitialization
            //       event.
            break;
        case QSMM_EVT_INSTR_CLASS_INIT:
            qsmm_set_eh_instr_param_str_f(qsmm, fmt,
                                          param.field, ...);
                // set a text representation of binary parameters of the
                // instruction class
            qsmm_set_eh_noutcome(qsmm,noutcome);
                // set the number of outcomes of the instruction class if
                // it is not equal to 1
            // TODO: perform other initialization procedures for the
            //       instruction class.
            break;
        case QSMM_EVT_INSTR_CLASS_DONE:
            // TODO: handle the instruction class uninitialization event.
            break;
        case QSMM_EVT_ENGINE_INIT:
            // TODO: handle the model instance initialization event.
            break;
        case QSMM_EVT_ENGINE_DONE:
            // TODO: handle the model instance uninitialization event.
            break;
        case QSMM_EVT_ACTIVATE:
            // TODO: handle instruction invocation.
            qsmm_set_instr_outcome(qsmm,outcome);
                // set an instruction outcome if the instruction class has
                // multiple outcomes
            break;
    }
    return 0;
}