int ac_lvc(int lc,int lv1,int lv2) { /* Assertion Check : Loop Variant check. */ if (lc == 0) { if (lv2 < 0) { #ifdef SE_EXCEPTIONS internal_exception_handler(Loop_variant); #else { char msg [64]; sprintf(msg,"Bad First Variant Value = %d\n",lv2); error0(msg,NULL); } #endif } else { return lv2; } } else if ((lv2 < 0) || (lv2 >= lv1)) { #ifdef SE_EXCEPTIONS internal_exception_handler(Loop_variant); #else { char msg [512]; sprintf(msg, "Bad loop variant.\nLoop body counter = %d (done)\n" "Previous Variant = %d\nNew Variant = %d\n", lc,lv1,lv2); error0(msg,NULL); } #endif } return lv2; }
T0* ci(int id, T0* o, se_position position) { /* Check Id for reference target. */ if ( vc(o,position) != NULL) { if ( id == (o->id) ) { return o; } else { #ifdef SE_EXCEPTIONS internal_exception_handler(System_level_type_error); #else int l = se_position2line(position); int c = se_position2column(position); int f = se_position2path_id(position); se_print_bad_target(SE_ERR,id,o,l,c,f); se_print_run_time_stack(); se_print_bad_target(SE_ERR,id,o,l,c,f); #ifdef SE_SEDB sedb_break(se_dst,0); #else exit(EXIT_FAILURE); #endif #endif } } return o; }
void ac_civ(int v,char*vv) { if (!v) { #ifdef SE_EXCEPTIONS internal_exception_handler(Check_instruction); #else error0("Check Assertion Violated.",vv); #endif } }
void ac_inv(int v,char*vv) { if (!v) { #ifdef SE_EXCEPTIONS internal_exception_handler(Class_invariant); #else error0("Class Invariant Violation.",vv); #endif } }
void ac_ens(int v,char*vv) { if (!v) { #ifdef SE_EXCEPTIONS internal_exception_handler(Postcondition); #else error0("Ensure Assertion Violated.",vv); #endif } }
void ac_req(int v,char*vv) { if (!v) { #ifdef SE_EXCEPTIONS internal_exception_handler(Precondition); #else error0("Require Assertion Violated.",vv); #endif } }
void ac_liv(int v,char*vv) { /* Assertion Check : Loop Invariant check. */ if (!v) { #ifdef SE_EXCEPTIONS internal_exception_handler(Loop_invariant); #else error0("Loop Invariant Violation.",vv); #endif } }
T0* se_evobt(T0* o, se_position position) { /* Error Void Or Bad Type. */ if (!o) { #ifdef SE_EXCEPTIONS internal_exception_handler(Void_call_target); #else error1("Target is Void.",position); #endif } else { #ifdef SE_EXCEPTIONS internal_exception_handler(System_level_type_error); #else error2(o,position); #endif } return o; /* Dummy return to avoid C warnings. */ }
static void check_write(int expected, int actual) { if (actual != expected) { handle(SE_HANDLE_RUNTIME_ERROR, NULL); #ifdef SE_EXCEPTIONS internal_exception_handler(Routine_failure); #elif !defined(SE_BOOST) error0("Routine failure: could not write.", NULL); #else fprintf(SE_ERR,"Routine failure (write returned %d but expected %d).\n", actual, expected); exit(EXIT_FAILURE); #endif } }
void se_gc_check_id(void*o,int id) { if (id != (((T0*)o)->id)) { #ifdef SE_EXCEPTIONS internal_exception_handler(Routine_failure); #else fprintf(SE_ERR,"System-validity error detected during GC cycle.\n"); se_print_bad_target(SE_ERR,id,(T0*)o,0,0,0); se_print_run_time_stack(); fprintf(SE_ERR,"System-validity error detected during GC cycle.\n"); se_print_bad_target(SE_ERR,id,(T0*)o,0,0,0); exit(EXIT_FAILURE); #endif } }
T0* se_string_inspect_check(T0* o, se_position position) { /* Void check for expression of type STRING in inspect. */ if (o != NULL) { return o; } else { #ifdef SE_EXCEPTIONS internal_exception_handler(Incorrect_inspect_value); #else error1("Expression just after \"inspect\" is Void.",position); #endif return NULL; } }
T0* vc(T0* o, se_position position) { /* Void check for reference target. */ if (o != NULL) { return o; } else { #ifdef SE_EXCEPTIONS internal_exception_handler(Void_call_target); #else error1("Call with a Void target.",position); #endif return NULL; } }