home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / dosdisas.zip / dccsrcoo.zip / error.cpp < prev    next >
C/C++ Source or Header  |  1997-10-14  |  4KB  |  104 lines

  1. /****************************************************************************
  2.  *$Log:    error.c,v $
  3.  * Revision 2.6  94/02/22  15:15:49  cifuente
  4.  * New errors for the code generator and data flow analysis.
  5.  * 
  6.  * Revision 2.5  93/10/11  11:36:06  cifuente
  7.  * Error message for condition flag use/def not found.
  8.  * 
  9.  * Revision 2.4  93/09/20  11:49:55  cifuente
  10.  * Changed tabs to spaces
  11.  * 
  12.  * Revision 2.3  93/08/23  12:15:03  cifuente
  13.  * Interactive mode with curses
  14.  * 
  15.  * Revision 2.1  93/03/30  14:50:53  cifuente
  16.  * Compiled with gcc.
  17.  * 
  18.  *          REVCOMP project error messages
  19.  ***************************************************************************/
  20.  
  21. // Mike: if you make dcc a custom control, then errors can be handled by
  22. // implementing a method in VB
  23. #include "dcc.h"
  24.  
  25. #include <stdio.h> 
  26. #include <stdlib.h>
  27. //#ifndef __UNIX__
  28. #if 1
  29. #include <stdarg.h>
  30. #else
  31. #include <varargs.h>
  32. #endif
  33.  
  34. static char *errorMessage[] = {
  35.   "Invalid option -%c\n",                                   /* INVALID_ARG    */
  36.   "Invalid instruction %02X at location %06lX\n",           /* INVALID_OPCODE */
  37.   "Don't understand 80386 instruction %02X at location %06lX\n",
  38.                                                             /* INVALID_386OP  */
  39.   "Segment override with no memory operand at location %06lX\n",
  40.                                                             /* FUNNY_SEGOVR   */
  41.   "REP prefix without a string instruction at location %06lX\n",/* FUNNY_REP */
  42.   "Cannot open %s\n",                                       /* CANNOT_OPEN    */
  43.   "Error while reading %s\n",                               /* CANNOT_READ    */
  44.   "malloc of %ld bytes failed\n",                           /* MALLOC_FAILED  */
  45.   "Don't understand new EXE format\n",                      /* NEWEXE_FORMAT  */
  46.   "Failed to find a BB for jump to %ld in proc %s\n",        /* NO_BB          */
  47.   "Basic Block is a synthetic jump\n",                /* INVALID_SYNTHETIC_BB */
  48.   "Failed to find a BB for interval\n",                     /* INVALID_INT_BB */
  49.   "Instruction at location %06lX goes beyond loaded image\n",   
  50.                                                             /* IP_OUT_OF_RANGE*/
  51.   "Definition not found for condition code usage at opcode %d\n",
  52.                                                             /* DEF_NOT_FOUND */
  53.   "JX use, definition not supported at opcode #%d\n",        /* JX_NOT_DEF */
  54.   "Def - use not supported.  Def op = %d, use op = %d.\n",  /* NOT_DEF_USE */
  55.   "Failed to construct repeat..until() condition.\n",        /* REPEAT_FAIL */
  56.   "Failed to construct while() condition.\n",                /* WHILE_FAIL */
  57. };
  58.  
  59.  
  60. /****************************************************************************
  61.  fatalError: displays error message and exits the program.
  62.  ****************************************************************************/
  63. void fatalError(Int errId, ...)
  64. {  va_list args;
  65. //#ifdef __UNIX__   /* ultrix */
  66. #if 0
  67.    Int errId;
  68.  
  69.     va_start(args);
  70.     errId = va_arg(args, Int);
  71. #else
  72.     va_start(args, errId);
  73. #endif
  74.  
  75.     if (errId == USAGE)
  76.        fprintf(stderr,"Usage: dcc [-a1a2cmpsvVi][-o asmfile] DOS_executable\n");
  77.     else {
  78.         fprintf(stderr, "dcc: ");
  79.         vfprintf(stderr, errorMessage[errId - 1], args);
  80.     }
  81.     va_end(args);
  82.     exit((int)errId);
  83. }
  84.  
  85.  
  86. /****************************************************************************
  87.  reportError: reports the warning/error and continues with the program.
  88.  ****************************************************************************/
  89. void reportError(Int errId, ...)
  90. {  va_list args;
  91. //#ifdef __UNIX__   /* ultrix */
  92. #if 0
  93.    Int errId;
  94.  
  95.     va_start(args);
  96.     errId = va_arg(args, Int);
  97. #else           /* msdos or windows*/
  98.     va_start(args, errId);
  99. #endif
  100.     fprintf(stderr, "dcc: ");
  101.     vfprintf(stderr, errorMessage[errId - 1], args);
  102.     va_end(args);
  103. }
  104.