Browse Source

Add parsehdr to the build

As requested in #22

(cherry picked from commit d5985b4b97cb06a89050c34674878c6430432fe1)
nemerle 8 years ago
parent
commit
cd6797499f
5 changed files with 490 additions and 626 deletions
  1. 1 0
      tools/CMakeLists.txt
  2. 4 0
      tools/parsehdr/CMakeLists.txt
  3. 66 65
      tools/parsehdr/locident.h
  4. 413 551
      tools/parsehdr/parsehdr.cpp
  5. 6 10
      tools/parsehdr/parsehdr.h

+ 1 - 0
tools/CMakeLists.txt

@@ -1 +1,2 @@
 add_subdirectory(makedsig)
+add_subdirectory(parsehdr)

+ 4 - 0
tools/parsehdr/CMakeLists.txt

@@ -0,0 +1,4 @@
+add_executable(parselib parsehdr.cpp)
+
+target_link_libraries(parselib dcc_hash)
+qt5_use_modules(parselib Core)

+ 66 - 65
tools/parsehdr/locident.h

@@ -1,23 +1,24 @@
+#pragma once
 /*$Log:	locident.h,v $
  * Revision 1.6  94/02/22  15:20:23  cifuente
  * Code generation is done.
- * 
+ *
  * Revision 1.5  93/12/10  09:38:20  cifuente
  * New high-level types
- * 
+ *
  * Revision 1.4  93/11/10  17:30:51  cifuente
  * Procedure header, locals
- * 
+ *
  * Revision 1.3  93/11/08  12:06:35  cifuente
  * du1 analysis finished.  Instantiates procedure arguments for user
  * declared procedures.
- * 
+ *
  * Revision 1.2  93/10/25  11:01:00  cifuente
  * New SYNTHETIC instructions for d/u analysis
- * 
+ *
  * Revision 1.1  93/10/11  11:47:39  cifuente
  * Initial revision
- * 
+ *
  * File: locIdent.h
  * Purpose: High-level local identifier definitions
  * Date: October 1993
@@ -26,92 +27,92 @@
 
 /* Type definition */
 typedef struct {
-	Int		csym;		/* # symbols used 			*/
-	Int		alloc;		/* # symbols allocated 		*/
-	Int		*idx;		/* Array of integer indexes */
+    Int		csym;		/* # symbols used 			*/
+    Int		alloc;		/* # symbols allocated 		*/
+    Int		*idx;		/* Array of integer indexes */
 } IDX_ARRAY;
 
 /* Type definitions used in the decompiled program  */
 typedef enum {
     TYPE_UNKNOWN = 0,   /* unknown so far      		*/
     TYPE_BYTE_SIGN,		/* signed byte (8 bits) 	*/
-	TYPE_BYTE_UNSIGN,	/* unsigned byte 			*/
+    TYPE_BYTE_UNSIGN,	/* unsigned byte 			*/
     TYPE_WORD_SIGN,     /* signed word (16 bits) 	*/
-	TYPE_WORD_UNSIGN,	/* unsigned word (16 bits)	*/
-	TYPE_LONG_SIGN,		/* signed long (32 bits)	*/
-	TYPE_LONG_UNSIGN,	/* unsigned long (32 bits)	*/
-	TYPE_RECORD,		/* record structure			*/
+    TYPE_WORD_UNSIGN,	/* unsigned word (16 bits)	*/
+    TYPE_LONG_SIGN,		/* signed long (32 bits)	*/
+    TYPE_LONG_UNSIGN,	/* unsigned long (32 bits)	*/
+    TYPE_RECORD,		/* record structure			*/
     TYPE_PTR,        	/* pointer (32 bit ptr) 	*/
     TYPE_STR,        	/* string               	*/
- 	TYPE_CONST,			/* constant (any type)		*/
-	TYPE_FLOAT,			/* floating point			*/
-	TYPE_DOUBLE,		/* double precision float	*/
+    TYPE_CONST,			/* constant (any type)		*/
+    TYPE_FLOAT,			/* floating point			*/
+    TYPE_DOUBLE,		/* double precision float	*/
 } hlType;
 
-static char *hlTypes[13] = {"", "char", "unsigned char", "int", "unsigned int", 
-			 		 "long", "unsigned long", "record", "int *", "char *",
-			 		 "", "float", "double"};
+static char *hlTypes[13] = {"", "char", "unsigned char", "int", "unsigned int",
+                     "long", "unsigned long", "record", "int *", "char *",
+                     "", "float", "double"};
 
 typedef enum {
-	STK_FRAME,			/* For stack vars			*/
-	REG_FRAME,			/* For register variables 	*/
-	GLB_FRAME,			/* For globals				*/
+    STK_FRAME,			/* For stack vars			*/
+    REG_FRAME,			/* For register variables 	*/
+    GLB_FRAME,			/* For globals				*/
 } frameType;
 
 
 /* Enumeration to determine whether pIcode points to the high or low part
  * of a long number */
 typedef enum {
-	HIGH_FIRST,			/* High value is first		*/
-	LOW_FIRST,			/* Low value is first		*/
+    HIGH_FIRST,			/* High value is first		*/
+    LOW_FIRST,			/* Low value is first		*/
 } hlFirst;
 
 
 /* LOCAL_ID */
 typedef struct {
-	hlType			type;	/* Probable type							 */
-	boolT			illegal;/* Boolean: not a valid field any more		 */
-	IDX_ARRAY		idx;	/* Index into icode array (REG_FRAME only)	 */
-	frameType		loc;	/* Frame location							 */
-	boolT			hasMacro;/* Identifier requires a macro				 */
-	char			macro[10];/* Macro for this identifier				 */
-	char			name[20];/* Identifier's name						 */
-	union {					/* Different types of identifiers 			 */
-		byte		regi;	/* For TYPE_BYTE(WORD)_(UN)SIGN registers    */ 
-		struct {			/* For TYPE_BYTE(WORD)_(UN)SIGN on the stack */
-			byte	regOff; /*    register offset (if any)				 */
-			Int		off;	/*    offset from BP						 */
-		}			bwId;
-		struct _bwGlb {		/* For TYPE_BYTE(WORD)_(UN)SIGN globals		 */
-			int16	seg;	/*   segment value							 */
-			int16	off;	/*   offset									 */
-			byte 	regi;	/*   optional indexed register				 */
-		}			bwGlb;
-		struct _longId{		/* For TYPE_LONG_(UN)SIGN registers			 */
-			byte	h;		/*   high register							 */
-			byte	l;		/*   low register							 */
-		}			longId;
-		struct _longStkId { /* For TYPE_LONG_(UN)SIGN on the stack	     */
-			Int		offH;	/*   high offset from BP					 */
-			Int		offL;	/*   low offset from BP						 */
-		}			longStkId;
-		struct {			/* For TYPE_LONG_(UN)SIGN globals			 */
-			int16	seg;	/*   segment value							 */
-			int16	offH;	/*   offset high							 */
-			int16	offL;	/*   offset low								 */
-			byte	regi;	/*   optional indexed register				 */
-		}			longGlb;
-		struct {			/* For TYPE_LONG_(UN)SIGN constants			 */
-			dword	h;		/*	 high word								 */
-			dword 	l;		/*	 low word								 */
-		}			longKte;
-	}				id;
+    hlType			type;	/* Probable type							 */
+    boolT			illegal;/* Boolean: not a valid field any more		 */
+    IDX_ARRAY		idx;	/* Index into icode array (REG_FRAME only)	 */
+    frameType		loc;	/* Frame location							 */
+    boolT			hasMacro;/* Identifier requires a macro				 */
+    char			macro[10];/* Macro for this identifier				 */
+    char			name[20];/* Identifier's name						 */
+    union {					/* Different types of identifiers 			 */
+        byte		regi;	/* For TYPE_BYTE(WORD)_(UN)SIGN registers    */
+        struct {			/* For TYPE_BYTE(WORD)_(UN)SIGN on the stack */
+            byte	regOff; /*    register offset (if any)				 */
+            Int		off;	/*    offset from BP						 */
+        }			bwId;
+        struct _bwGlb {		/* For TYPE_BYTE(WORD)_(UN)SIGN globals		 */
+            int16	seg;	/*   segment value							 */
+            int16	off;	/*   offset									 */
+            byte 	regi;	/*   optional indexed register				 */
+        }			bwGlb;
+        struct _longId{		/* For TYPE_LONG_(UN)SIGN registers			 */
+            byte	h;		/*   high register							 */
+            byte	l;		/*   low register							 */
+        }			longId;
+        struct _longStkId { /* For TYPE_LONG_(UN)SIGN on the stack	     */
+            Int		offH;	/*   high offset from BP					 */
+            Int		offL;	/*   low offset from BP						 */
+        }			longStkId;
+        struct {			/* For TYPE_LONG_(UN)SIGN globals			 */
+            int16	seg;	/*   segment value							 */
+            int16	offH;	/*   offset high							 */
+            int16	offL;	/*   offset low								 */
+            byte	regi;	/*   optional indexed register				 */
+        }			longGlb;
+        struct {			/* For TYPE_LONG_(UN)SIGN constants			 */
+            dword	h;		/*	 high word								 */
+            dword 	l;		/*	 low word								 */
+        }			longKte;
+    }				id;
 } ID;
 
 typedef struct {
-	Int			csym;		/* No. of symbols in the table	*/
-	Int			alloc;		/* No. of symbols allocated		*/
-	ID			*id;		/* Identifier					*/
+    Int			csym;		/* No. of symbols in the table	*/
+    Int			alloc;		/* No. of symbols allocated		*/
+    ID			*id;		/* Identifier					*/
 } LOCAL_ID;
 
 

File diff suppressed because it is too large
+ 413 - 551
tools/parsehdr/parsehdr.cpp


+ 6 - 10
tools/parsehdr/parsehdr.h

@@ -1,18 +1,17 @@
+#pragma once
+#include "Enums.h"
 /*
  *$Log:	parsehdr.h,v $
  */
 /* Header file for parsehdr.c */
 
 typedef unsigned long dword;    /* 32 bits	*/
-typedef unsigned char byte;	    /* 8 bits 	*/ 
+typedef unsigned char byte;	    /* 8 bits 	*/
 typedef unsigned short word;    /* 16 bits	*/
 typedef unsigned char boolT;    /* 8 bits 	*/
 
-#define TRUE  1
-#define FALSE 0
-
 #define BUFF_SIZE 8192          /* Holds a declaration */
-#define FBUF_SIZE 32700         /* Holds part of a header file */
+#define FBUF_SIZE 32700        /* Holds part of a header file */
 
 #define	NARGS		15
 #define	NAMES_L		160
@@ -38,11 +37,8 @@ void	phWarning(char *errmsg);
 
 #define  SYMLEN     16                  /* Including the null */
 #define  Int        long                /* For locident.h */
-#define  int16 short int                /* For locident.h */
-#include "locident.h"                   /* For the hlType enum */
-#define  bool       unsigned char       /* For internal use */
-#define  TRUE       1
-#define  FALSE      0
+//#include "locident.h"                   /* For the hlType enum */
+//#define  bool       unsigned char       /* For internal use */
 
 typedef
 struct ph_func_tag

Some files were not shown because too many files changed in this diff