symtype.h
来自「开放源码的编译器open watcom 1.6.0版的源代码」· C头文件 代码 · 共 1,407 行 · 第 1/5 页
H
1,407 行
/****************************************************************************
*
* 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: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
#ifndef _SYMTYPE_H
typedef struct cdopt_cache CDOPT_CACHE;
typedef struct friend_list FRIEND;
typedef struct name_space NAME_SPACE;
typedef struct using_ns USING_NS;
typedef struct sym_region SYM_REGION;
typedef struct scope *SCOPE;
typedef struct symbol_name *SYMBOL_NAME;
typedef struct decl_spec DECL_SPEC;
typedef struct base_class BASE_CLASS;
typedef struct search_result SEARCH_RESULT;
typedef struct class_table CLASS_TABLE;
typedef struct class_vbtable CLASS_VBTABLE;
typedef struct class_vftable CLASS_VFTABLE;
typedef struct thunk_cast THUNK_CAST;
typedef struct thunk_action THUNK_ACTION;
typedef struct member_ptr_cast MEMBER_PTR_CAST;
typedef struct gen_leap GEN_LEAP;
typedef struct reloc_list RELOC_LIST;
typedef struct parse_tree_node *PTREE; // defined in PTREE.H
typedef struct rewrite_package REWRITE; // defined in REWRITE.H
typedef struct template_info TEMPLATE_INFO; // defined in TEMPLATE.H
typedef struct template_specialization TEMPLATE_SPECIALIZATION; // defined in TEMPLATE.H
typedef struct fn_template_defn FN_TEMPLATE_DEFN;//defined in TEMPLATE.H
typedef struct func_list FNOV_LIST; // defined in FNOVLOAD.H
typedef struct pool_con POOL_CON; // defined in CONPOOL.H
#include "linkage.h"
#include "toknlocn.h"
#include "hashtab.h"
#include "pragdefn.h"
/* types used for collecting decl-specifiers */
/* only one of these may be specified except typedef+mutable is allowed */
typedef enum {
STG_TYPEDEF = 0x01,
STG_REGISTER = 0x02,
STG_AUTO = 0x04,
STG_EXTERN = 0x08,
STG_STATIC = 0x10,
STG_MUTABLE = 0x20,
STG_NULL = 0x00
} stg_class_t;
/* any one of these may be specified */
typedef enum {
STY_CONST = 0x01,
STY_VOLATILE = 0x02,
STY_FRIEND = 0x04,
STY_INLINE = 0x08,
STY_VIRTUAL = 0x10,
STY_EXPLICIT = 0x20,
STY_UNALIGNED = 0x40,
STY_DSPEC_MOD = ( STY_CONST
| STY_VOLATILE
| STY_UNALIGNED
),
STY_FN_MODIFIER = ( STY_FRIEND
| STY_INLINE
| STY_VIRTUAL
| STY_EXPLICIT
),
STY_NULL = 0x00
} specifier_t;
/* only certain combinations may be specified */
typedef enum {
STM_CHAR = 0x0001,
STM_INT = 0x0002,
STM_LONG = 0x0004,
STM_FLOAT = 0x0008,
STM_DOUBLE = 0x0010,
STM_SIGNED = 0x0020,
STM_UNSIGNED = 0x0040,
STM_SHORT = 0x0080,
STM_VOID = 0x0100,
STM_SEGMENT = 0x0200,
STM_BOOL = 0x0400,
STM_INT64 = 0x0800,
STM_NULL = 0x0000
} scalar_t;
typedef enum {
STS_DLLIMPORT = 0x0001,
STS_DLLEXPORT = 0x0002,
STS_NAKED = 0x0004,
STS_THREAD = 0x0008,
STS_MODIFIER = 0x0010,
STS_NULL = 0x0000
} ms_declspec_t;
// check PTypeCombine if any new fields are added
struct decl_spec {
DECL_SPEC *prev;
SYMBOL typedef_defined; // typedef needs to be def'd
SYMBOL prev_sym; // 'p' in char *p, q;
SCOPE scope; // 'S::' part of the type
TYPE partial; // typedef part of decl-spec
TYPE ms_declspec_fnmod; // __declspec( <fn-modifier> )
LINKAGE linkage; // non-NULL if extern "?"
PTREE id; // id from typedef references
char *name; // name of typedef ('C' in class C)
stg_class_t stg_class; // storage class part of decl-spec
scalar_t scalar; // scalar tokens part of decl-spec
specifier_t specifier; // type qualifiers part of decl-spec
ms_declspec_t ms_declspec; // __declspec( <id> ) modifiers
int : 0;
unsigned type_defined : 1; // a type was defined
unsigned type_declared : 1; // a type was declared
unsigned ctor_name : 1; // decl-spec can be a ctor-name
unsigned is_default : 1; // no decl-spec has been specified
unsigned diagnosed : 1; // use of decl-spec diagnosed
unsigned decl_checked : 1; // type checked (& built) already
unsigned type_elaborated : 1;// "class C" or "enum E"
unsigned nameless_allowed :1;// nameless declaration is allowed
unsigned generic : 1; // <class T, ... templare type arg
unsigned class_instantiation:1;// C<X,x> instantiation
unsigned no_more_linkage : 1;// no more extern "?" allowed
unsigned arg_declspec : 1; // decl-specs for an argument
unsigned class_idiom : 1; // "class C;" idiom used
int : 0;
};
typedef struct decl_info DECL_INFO;
struct decl_info {
DECL_INFO *next;
DECL_INFO *parms; // function parms (NULLable)
PTREE id; // declarator id (NULLable)
SCOPE scope; // 'C' part of 'C::id' (NULLable)
SCOPE friend_scope; // SCOPE friend should be in
SYMBOL sym; // declared symbol (NULLable)
SYMBOL generic_sym; // symbol for template <class T>
SYMBOL proto_sym; // SC_DEFAULT sym for this parm
TYPE list; // list of declarator types
TYPE type; // final declared type
PTREE defarg_expr; // initial/default value (NULLable)
REWRITE *body; // storage for function body
REWRITE *mem_init; // storage for mem-initializer
REWRITE *defarg_rewrite;// storage for default argument
char *name; // name of symbol (NULLable)
TOKEN_LOCN init_locn; // location of '(' for inits
unsigned sym_used : 1; // don't free 'sym'
unsigned friend_fn : 1; // symbol is a friend function
unsigned fn_defn : 1; // function is being defined
unsigned template_member:1;// declaring a template member
unsigned has_dspec : 1; // has decl-specifiers (set by DeclFunction)
unsigned has_defarg : 1; // has default argument
unsigned explicit_parms : 1;// explicit parms in declarator
};
// types dealing with representing types
typedef enum {
TYP_MIN = 0x00,
TYP_ERROR = 0x00,
TYP_BOOL = 0x01,
TYP_CHAR = 0x02,
TYP_SCHAR = 0x03,
TYP_UCHAR = 0x04,
TYP_WCHAR = 0x05,
TYP_SSHORT = 0x06,
TYP_USHORT = 0x07,
TYP_SINT = 0x08,
TYP_UINT = 0x09,
TYP_SLONG = 0x0a,
TYP_ULONG = 0x0b,
TYP_SLONG64 = 0x0c,
TYP_ULONG64 = 0x0d,
TYP_FLOAT = 0x0e,
TYP_DOUBLE = 0x0f,
TYP_LONG_DOUBLE = 0x10,
TYP_ENUM = 0x11,
TYP_POINTER = 0x12,
TYP_TYPEDEF = 0x13,
TYP_CLASS = 0x14,
TYP_BITFIELD = 0x15,
TYP_FUNCTION = 0x16,
TYP_ARRAY = 0x17,
TYP_DOT_DOT_DOT = 0x18,
TYP_VOID = 0x19,
TYP_MODIFIER = 0x1a,
TYP_MEMBER_POINTER = 0x1b,
TYP_GENERIC = 0x1c,
TYP_FREE = 0x1d,
TYP_MAX,
TYP_FIRST_VALID = TYP_BOOL,
} type_id;
typedef enum {
TF1_FIRST = 0x00000001, // TYP_ERROR
TF1_SPECIAL_FMT = 0x00000002,
TF1_DEFAULT = 0x00000001, // TYP_SINT
TF1_CLEAN = 0x00000002,
TF1_SEGMENT = 0x00000001, // TYP_USHORT
TF1_ZERO_SIZE = 0x00000001, // TYP_ARRAY
TF1_LOADDS = 0x00000001, // TYP_FUNCTION
TF1_SAVEREGS = 0x00000002, // *************************
TF1_PLUSPLUS = 0x00000004, // * Remember to add any *
TF1_INLINE = 0x00000008, // * new flags that should *
TF1_VIRTUAL = 0x00000010, // * be ignored during a *
TF1_INTERRUPT = 0x00000020, // * fn type comparision *
TF1_PURE = 0x00000040, // * to TF1_FN_IGNORE *
TF1_STACK_CHECK = 0x00000080, // *************************
TF1_INTRINSIC = 0x00000100,
TF1_EXPLICIT = 0x00000200,
TF1_NAKED = 0x00000400,
TF1_PLUSPLUS_SET = 0x80000000, /* note 1 */// don't change TF1_PLUSPLUS
TF1_CONST = 0x00000001, // TYP_MODIFIER
TF1_VOLATILE = 0x00000002,
TF1_MUTABLE = 0x00000004,
TF1_NEAR = 0x00000010,
TF1_FAR = 0x00000020,
TF1_FAR16 = 0x00000040,
TF1_HUGE = 0x00000080,
TF1_BASED = 0x00000700, // mask to extract type of base
TF1_BASED_STRING = 0x00000100, // _based( "string" )
TF1_BASED_SELF = 0x00000200, // _based((_segment)_self)
TF1_BASED_VOID = 0x00000300, // _based(void)
TF1_BASED_FETCH = 0x00000400, // _based(s) (_segment s;)
TF1_BASED_ADD = 0x00000500, // _based(p) (char *p;)
TF1_DLLEXPORT = 0x00000800,
TF1_DLLIMPORT = 0x00001000,
TF1_UNALIGNED = 0x00002000,
TF1_THREAD = 0x00004000,
TF1_COMMON = 0x80000000, /* note 2 */// same addr in all modules
TF1_IN_MEM = 0x40000000, /* note 2 */// sym was used in inline asm
TF1_TYP_FUNCTION = 0x80000000, /* note 1 */// modifier is a fn modifier
TF1_OUTERMOST = 0x40000000, /* note 1 */// modifier percolates out
TF1_HUG_FUNCTION = 0x20000000, /* note 1 */// modifier hugs functions
/* notes:
(1) flag is only used in pre-FinishDeclarator types (thrown away)
(2) flag is only used to adjust post-FinishDeclarator types (can
occupy note 1 bit positions)
*/
TF1_REFERENCE = 0x00000001, // TYP_POINTER
TF1_FAR_BUT_NEAR = 0x00000002, // object is near but typed as far
TF1_UNNAMED = 0x00000001, // TYP_ENUM, TYP_TYPEDEF
TF1_UNION = 0x00000001, // TYP_CLASS
TF1_STRUCT = 0x00000002,
TF1_UNBOUND = 0x00000004, // unbound class template
TF1_INSTANTIATION = 0x00000008, // class is an instance of a class template
TF1_SPECIFIC = 0x00000010, // class is a specific instantiation
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?