📄 ctypes.h
字号:
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Internal CFE types.
*
****************************************************************************/
#define ENUM_HANDLE ENUMPTR
#if defined(__386__)
typedef char * SYM_NAMEPTR;
#else
typedef char __FAR * SYM_NAMEPTR;
#endif
#include "cg.h"
#include "cgaux.h"
/* only for long_double */
#include "xfloat.h"
typedef back_handle BACK_HANDLE;
typedef label_handle LABEL_HANDLE;
typedef char *NAME_HANDLE;
typedef cg_sym_handle CGSYM_HANDLE;
typedef dbg_type dbug_type;
typedef signed_64 int64;
typedef unsigned_64 uint64;
#define L I64LO32
#define H I64HI32
/* CONST, VOLATILE can appear in typ->decl_flags and leaf->leaf_flags.
* NEAR, FAR, HUGE can appear in typ->decl_flags, leaf->leaf_flags,
* and sym->attrib.
* CDECL,PASCAL,FORTRAN,SYSCALL can appear in typ->decl_flags and sym->attrib.
* LVALUE, CONSTANT, VOID will only appear in leaf->leaf_flags.
*
* freed by CFOLD
*/
typedef enum type_modifiers { /* type leaf sym */
FLAG_NONE = 0x0000,
FLAG_CONST = 0x0001, /* Y0001 Y0001 */
FLAG_VOLATILE = 0x0002, /* Y0002 Y0002 */
FLAG_RESTRICT = 0x10000, /* see how this flies */
FLAG_NEAR = 0x0004, /* Y0004 Y0004 Y0004 */
FLAG_FAR = 0x0008, /* Y0008 Y0008 Y0008 */
FLAG_HUGE = 0x0010, /* Y0010 Y0010 Y0010 */
FLAG_MEM_MODEL = FLAG_NEAR | FLAG_FAR| FLAG_HUGE,
LANG_CDECL = 0x0020, /* Y0020 Y0020 */
LANG_PASCAL = 0x0040, /* Y0040 Y0040 */
LANG_FORTRAN = 0x0060, /* Y0060 Y0060 */
LANG_SYSCALL = 0x0080, /* Y0080 Y0080 */ /* 04-jul-91 */
LANG_STDCALL = 0x00A0, /* Y00A0 Y00A0 */ /* 08-jan-92 */
LANG_OPTLINK = 0x00C0, /* Y00C0 Y00C0 */
LANG_FASTCALL = 0x00E0,
FLAG_LANGUAGES = (LANG_CDECL |
LANG_PASCAL |
LANG_FORTRAN|
LANG_SYSCALL|
LANG_STDCALL|
LANG_OPTLINK|
LANG_FASTCALL),
FLAG_INTERRUPT = (FLAG_NEAR+FLAG_FAR), /* interrupt function */
/* FLAG_NEAR + FLAG_FAR both on ==> interrupt far */
FLAG_SAVEREGS = 0x0100, /* Y0100 Y0100 */
FLAG_LOADDS = 0x0200, /* Y0200 Y0200 */
FLAG_EXPORT = 0x0400, /* Y0400 Y0400 */
FLAG_BASED = 0x0800, /* Y0800 Y0800 _based ptr or var */
FLAG_SEGMENT = 0x1000, /* Y1000 Y1000 __segment type */
FLAG_FAR16 = 0x2000, /* Y2000 Y2000 __far16 modifier */
FLAG_UNALIGNED = 0x4000, /* _Packed structures */
FLAG_INLINE = 0x8000, /* Y8000 _inline keyword */
FLAG_WAS_ARRAY = 0x8000, /* Y8000 for "char *argv[]" */
} type_modifiers;
typedef enum sym_flags {
SYM_FUNCTION = 0x01, /* ON => function, OFF => variable */
SYM_REFERENCED = 0x02, /* symbol was referenced in program */
SYM_TYPE_GIVEN = 0x04, /* a ret type was specified for this func */
SYM_EMITTED = 0x04, /* symbol has been emitted to cgen */
SYM_DEFINED = 0x08, /* symbol has been defined */
SYM_INITIALIZED = 0x10, /* variable has been initialized */
SYM_OLD_STYLE_FUNC = 0x10, /* function defined with old-style defn */
SYM_TEMP = 0x20, /* this is a temp created by MakeNewSym */
SYM_CHECK_STACK = 0x40, /* function requires stack checking code */
SYM_ASSIGNED = 0x40, /* variable has been assigned to */
SYM_ADDR_TAKEN = 0x80, /* variable/func has had its address taken */
SYM_IGNORE_UNREFERENCE = 0x0100, /* don't print msg if unreferenced */
SYM_OK_TO_RECURSE = 0x0200, /* OK to do tail recursion */
SYM_FUNC_RETURN_VAR = 0x0400, /* this is function return variable */
SYM_FUNC_NEEDS_THUNK = 0x0800, /* need a thunk prolog? */
SYM_BASED_STACK_VARS = 0x1000, /* _based(_segname("_STACK")) vars */
SYM_USED_IN_PRAGMA = 0x2000, /* symbol referenced in a pragma */
SYM_INTRINSIC = 0x4000, /* #pragma intrinsic(name) */
SYM_TRY_VOLATILE = 0x8000, /* volatile because try is used */
} sym_flags;
typedef enum stg_classes { // used in sym.stg_class
SC_NULL = 0, // storage class not specified
SC_FORWARD, // forward declaration
SC_EXTERN, // extern
SC_STATIC, // static
SC_TYPEDEF, // typedef
SC_AUTO, // auto
SC_REGISTER // register
} stg_classes;
typedef enum declspec_class { //note declspec field 2-bits in SYM_ENTRY
DECLSPEC_NONE = 0,
DECLSPEC_DLLIMPORT,
DECLSPEC_DLLEXPORT,
DECLSPEC_THREAD,
} declspec_class;
typedef enum string_flags { // string literal flags
STRLIT_WIDE = 0x80, // must not conflict with FLAG_MEM_MODEL
} string_flags;
typedef unsigned short SYM_HANDLE;
typedef struct string_literal *STR_HANDLE;
struct parm_list {
struct parm_list *next_parm;
struct type_definition *parm_type;
};
struct array_info {
unsigned long dimension;
int refno;
};
typedef enum BASED_KIND{
BASED_NONE,
BASED_VOID, //__based( void ) segment:>offset base op
BASED_SELFSEG, //__based( (__segment) __self ) use seg of self
BASED_VAR, //__based( <var> ) add to var pointer
BASED_SEGVAR, //__based( <var> ) add to var seg
BASED_VARSEG, //__based( (__segment) <var> ) ) use seg of var
BASED_SEGNAME, //__based( __segname( "name" ) use seg of segname
} BASED_KIND;
/* matches CTypeSizes[] table in ctype.c */
/* matches CGDataType[] table in cgen2.c */
/* matches CTypenames[] table in cgdump.c */
/* matches AsmDataType[] table in cprag86.c */
typedef enum DATA_TYPE {
TYPE_CHAR = 0, /* signed char */
TYPE_UCHAR,
TYPE_SHORT,
TYPE_USHORT,
TYPE_INT,
TYPE_UINT,
TYPE_LONG,
TYPE_ULONG,
TYPE_LONG64,
TYPE_ULONG64,
TYPE_FLOAT,
TYPE_DOUBLE,
TYPE_POINTER,
TYPE_ARRAY,
TYPE_STRUCT,
TYPE_UNION,
TYPE_FUNCTION,
TYPE_FIELD, /* signed bit field */
TYPE_VOID,
TYPE_ENUM,
TYPE_TYPEDEF,
TYPE_UFIELD, /* unsigned bit field */
TYPE_DOT_DOT_DOT, /* for the ... in prototypes */
TYPE_PLAIN_CHAR, /* char */
TYPE_WCHAR, /* L'c' - a wide character constant */
TYPE_LONG_DOUBLE,
TYPE_FCOMPLEX,
TYPE_DCOMPLEX,
TYPE_LDCOMPLEX,
TYPE_FIMAGINARY,
TYPE_DIMAGINARY,
TYPE_LDIMAGINARY,
TYPE_BOOL,
TYPE_UNUSED, /* an unused type (a unref'd function) */
TYPE_LAST_ENTRY /* make sure this is always last */
} DATA_TYPE;
// values for type->type_flags
enum type_state {
TF2_DWARF_DEF = 0x01, // dwarf type has been defined
TF2_DWARF_FWD = 0x02, // dwarf forward reference
TF2_DWARF = (TF2_DWARF_DEF|TF2_DWARF_FWD), // dwarf is active
// If the following flag is on, then it indicates a dummy typedef
// It is used to record modifiers such as const, volatile
// e.g.
// struct foo { int a,b };
// const struct foo *p;
// type of p will be:
// TYPE_POINTER -> dummy TYPE_TYPEDEF const -> TYPE_STRUCT
//
TF2_DUMMY_TYPEDEF = 0x04, // gone now dummy typedef to record modifiers
TF2_TYPE_PLAIN_CHAR = 0x10, // indicates plain char
};
typedef struct type_definition {
DATA_TYPE decl_type;
enum type_state type_flags;
union {
struct type_definition * object;
int object_index; /* for pre-compiled headers */
};
struct type_definition *next_type;
union {
dw_handle dwarf_type; /* used for browsing info */
dbug_type debug_type; /* pass 2: debug type */
int type_index; /* for pre-compiled hdrs */
};
union {
struct {
short int segment; /* TYPE_POINTER */
SYM_HANDLE based_sym; /* var with seg of based ptr*/
BASED_KIND based_kind; /* kind of base variable */
type_modifiers decl_flags; /* only symbols and ptr have attributes */
} p;
union {
struct tag_entry *tag; /* STRUCT, UNION, ENUM */
int tag_index; /* for pre-compiled header */
};
SYM_HANDLE typedefn; /* TYPE_TYPEDEF */
union {
struct type_definition **parms;/* TYPE_FUNCTION */
int parm_index; /* for pre-compiled header */
};
struct { /* TYPE_FIELD or TYPE_UFIELD */
unsigned char field_width; /* # of bits */
unsigned char field_start; /* # of bits to << by */
unsigned char field_type; /* TYPE_xxxx of field */
} f;
union {
struct array_info *array; /* TYPE_ARRAY */
unsigned long array_dimension; /* for pre-compiled header */
};
} u;
} TYPEDEFN, *TYPEPTR;
extern void WalkTypeList( void (*func)(TYPEPTR) );
extern void WalkFuncTypeList( void (*func)(TYPEPTR,int) );
struct textsegment { /* used for #pragma alloc_text(seg,func1,func2,...) */
union {
struct textsegment *next;
int textsegment_len; /* for pre-compiled header */
};
int segment_number;
int index;
char segname[1];
};
typedef struct fname_list {
union {
struct fname_list *next;
int fname_len; /* for pre-compiled header */
};
time_t mtime; /* from stat.st_mtime */
unsigned index;
bool rwflag;
bool once;
char *fullpath;
char name[1];
} *FNAMEPTR;
typedef struct rdir_list {
union {
struct rdir_list *next;
int name_len; /* for pre-compiled header */
};
char name[1];
} *RDIRPTR;
typedef struct incfile {
struct incfile *nextfile;
int len;
char filename[1];
} INCFILE;
typedef struct xref_entry {
struct xref_entry *next_xref;
unsigned linenum;
unsigned filenum;
} XREF_ENTRY, *XREFPTR;
extern XREFPTR NewXref( XREFPTR );
struct sym_hash_entry { /* SYMBOL TABLE structure */
union {
struct sym_hash_entry __FAR *next_sym;
int hash_index; /* for pre-compiled header */
};
union {
TYPEPTR sym_type;
int sym_type_index; /* for pre-compiled header */
};
#if _HOST == 386
SYM_HANDLE handle;
char level;
#else
unsigned handle;
unsigned level;
#endif
char name[1];
};
typedef struct sym_hash_entry __FAR *SYM_HASHPTR;
typedef struct expr_node *TREEPTR;
typedef struct symtab_entry { /* SYMBOL TABLE structure */
char *name;
union {
TYPEPTR sym_type;
int sym_type_index; /* for pre-compiled header */
};
SYM_HANDLE handle;
unsigned short defn_file_index; /* file this symbol is defined in */
union {
int defn_line; /* line number sym is defined on */
int index; /* symbol index in object file */
} d;
union {
BACK_HANDLE backinfo;
int hash_value;
temp_handle return_var; /* for the .R symbol */
} info;
union {
struct {
int offset;
int segment; /* segment identifier */
} var;
struct {
SYM_HANDLE parms;
SYM_HANDLE locals;
TREEPTR start_of_func; /* starting tree node */
} func;
} u;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -