Previous: , Up: Instruction Class Set Definition   [Contents][Index]


4.4.6 Function Layout

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

static QSMM_INSTR_CLASS_SET(instr_class_set_name) {
    struct stack_frame_s *stack_frame_p=0;
        // structure "stack_frame_s" represents a user stack frame
    // TODO: declare (and possibly initialize) other automatic variables.
    switch (qsmm_evt) {
        case QSMM_EVT_ENT_INIT:
            // Register instruction classes.
            QSMM_REG_INSTR_CLASS(meta_class_1);
            QSMM_REG_INSTR_CLASS(meta_class_2);
            // ...
            QSMM_REG_INSTR_CLASS_PARAM(meta_class_a,var_a);
            QSMM_REG_INSTR_CLASS_PARAM(meta_class_b,var_b);
            // ...
            qsmm_set_nstate_max(qsmm,__FUNCTION__,nstate);
                // set the maximum allowed and the default number of
                // states for nodes that belong to this node class
            // Create the nodes.
            QSMM_NODE_CREATE(node1);
            QSMM_NODE_CREATE(node2);
            // ...
            // TODO: perform other initialization procedures.
            break;
        case QSMM_EVT_ENT_DONE:
            // TODO: handle the instruction class set 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_NODE_ENTER:
            qsmm_get_stack_frame(qsmm,0,(void **) &stack_frame_p);
            // TODO: initialize *stack_frame_p, possibly according to the
            //       content of a structure addressed by qsmm_param_p.
            break;
        case QSMM_EVT_NODE_LEAVE:
            qsmm_get_stack_frame(qsmm,0,(void **) &stack_frame_p);
            // TODO: set the content of a structure addressed by
            //       qsmm_param_p according to *stack_frame_p and
            //       uninitialize *stack_frame_p.
            break;
    }
    return 0;
}