symtype.h
来自「开放源码的编译器open watcom 1.6.0版的源代码」· C头文件 代码 · 共 1,407 行 · 第 1/5 页
H
1,407 行
unsigned zero_array : 1; // contains a zero sized array as last member
unsigned free : 1; // used for precompiled headers
unsigned lattice : 1; // more than one direct ref to a vbase
unsigned passed_ref : 1; // class value is passed as a reference
unsigned has_def_ctor :1;// has an explicit default constructor
unsigned vftable_done :1;// vftable has been collected already
unsigned vbtable_done :1;// vftable has been collected already
unsigned has_udc : 1; // has a user-defined conversion declared
unsigned common : 1; // used when searching for common bases
unsigned has_comp_info:1;// has compiler generated info inside
unsigned has_mutable : 1;// has a mutable data member
unsigned empty : 1; // class has zero size
unsigned has_fn : 1; // has any member function
int : 0;
} CLASSINFO;
// kludge alert:
// ScopeRttiLeaps uses 'of' in a TYP_CLASS as a cache temporarily
PCH_struct type {
TYPE next; // used for keeping track of dup. types
TYPE of;
union {
struct { // TYP_ERROR
unsigned fmt;
} e;
struct { // TYP_NULL
void *init1;
void *init2;
} i;
struct { // TYP_TYPEDEF, TYP_ENUM
SYMBOL sym;
SCOPE scope;
} t;
struct { // TYP_CLASS
SCOPE scope;
CLASSINFO *info;
} c;
struct { // TYP_BITFIELD
unsigned field_start;
unsigned field_width;
} b;
struct { // TYP_ARRAY
CGREFNO refno;
target_size_t array_size;
} a;
struct { // TYP_MODIFIER
void *base;
union {
AUX_INFO *pragma;
unsigned pragma_idx;
};
} m;
struct { // TYP_FUNCTION
arg_list *args;
union {
AUX_INFO *pragma;
unsigned pragma_idx;
};
} f;
struct { // TYP_MEMBER_POINTER
TYPE host; // may not be TYP_CLASS! (can be NULL)
} mp;
struct { // TYP_GENERIC
unsigned index; // keeps template args distinct
} g;
} u;
dbg_info dbg; // FOR D2 AND DWARF
type_flag flag;
type_id id;
type_dbgflag dbgflag;
};
#define SCOPE_DEFS \
SCOPE_DEF(SCOPE_FILE, MIN_HASHTAB_SIZE+2 ) /* file scope */\
,SCOPE_DEF(SCOPE_CLASS, MIN_HASHTAB_SIZE+2 ) /* class scope */\
,SCOPE_DEF(SCOPE_FUNCTION, MIN_HASHTAB_SIZE ) /* function arguments */\
,SCOPE_DEF(SCOPE_BLOCK, MIN_HASHTAB_SIZE ) /* {} block scopes */\
,SCOPE_DEF(SCOPE_TEMPLATE_DECL, MIN_HASHTAB_SIZE ) /* template declaration scope */\
,SCOPE_DEF(SCOPE_TEMPLATE_INST, MIN_HASHTAB_SIZE ) /* template instantiation scope*/\
,SCOPE_DEF(SCOPE_TEMPLATE_PARM, MIN_HASHTAB_SIZE ) /* template parameters scope */\
,SCOPE_DEF(SCOPE_TEMPLATE_SPEC_PARM, MIN_HASHTAB_SIZE ) /* template parameters (for template specializations) scope */\
,SCOPE_DEF(SCOPE_FREE, MIN_HASHTAB_SIZE ) /* unused scope (pcheader) */
typedef enum {
#define SCOPE_DEF(a,b) a
SCOPE_DEFS
#undef SCOPE_DEF
, SCOPE_MAX
} scope_type_t;
#define SC_DEFS \
SC_DEF(SC_NULL )/* not defined */\
,SC_DEF(SC_EXTERN )/* external reference */\
,SC_DEF(SC_STATIC )/* static definition */\
,SC_DEF(SC_AUTO )/* automatic storage */\
,SC_DEF(SC_REGISTER )/* register storage */\
,SC_DEF(SC_TYPEDEF )/* typedef symbol */\
,SC_DEF(SC_ACCESS )/* member access symbol (11.3) */\
,SC_DEF(SC_DEFAULT )/* represents a default argument value */\
,SC_DEF(SC_ENUM )/* enumerated constant */\
,SC_DEF(SC_MEMBER )/* class member */\
,SC_DEF(SC_PUBLIC )/* defined and symbol exported */\
,SC_DEF(SC_NAMESPACE )/* symbol is a namespace id */\
,SC_DEF(SC_CLASS_TEMPLATE )/* symbol is a class template */\
,SC_DEF(SC_FUNCTION_TEMPLATE )/* symbol is a function template */\
,SC_DEF(SC_STATIC_FUNCTION_TEMPLATE)/* symbol is a function template */\
/* **** used only in Code Generation: */\
,SC_DEF(SC_VIRTUAL_FUNCTION )/* indirect symbol for a virt. fn call */\
/* **** only in template instantiation */\
,SC_DEF(SC_ADDRESS_ALIAS )/* symbol use in template instantiations*/\
/* **** used only when writing pchdrs */\
,SC_DEF(SC_FREE )/* used for precompiled headers */\
,SC_DEF(SC_MAX )
typedef enum {
#define SC_DEF(a) a
SC_DEFS
#undef SC_DEF
} symbol_class;
typedef enum // flags for symbol.flag
// general flags
{ SF_REFERENCED = 0x00000001 // - symbol has been referenced
, SF_INITIALIZED = 0x00000002 // - storage for symbol is initialized
, SF_CONSTANT_INT = 0x00000004 // - constant value in symbol
, SF_ADDR_TAKEN = 0x00000008 // - address of symbol has been taken
, SF_NO_REF_WARN = 0x00000010 // - don't warn if unreferenced
, SF_FAR16_CALLER = 0x00000020 // - function called a far16 function
, SF_ADDR_THUNK = 0x00000040 // - addressability thunk (u.thunk_calls is set)
, SF_DBG_ADDR_TAKEN = 0x00000080 // - addr of sym taken in debug info
// if neither set, it is undecided
// what function does
, SF_LONGJUMP = 0x00000100 // - function: has longjump, throw
, SF_NO_LONGJUMP = 0x00000200 // - function: no longjump, throw
, SF_ERROR = 0x00000400 // - symbol is erroneous
, SF_CONST_NO_CODE = 0x00000800 // - symbol is const & doesn't need code
// to initialize it (const double d=1;)
, SF_TEMPLATE_FN = 0x00001000 // - generated from a fn template
// - u.alias is fn template symbol
// (if it is known)
, SF_CONSTANT_INT64 = 0x00002000 // - constant int-64 value in symbol
, SF_ALIAS = 0x00004000 // - sym is a true alias of another sym
, SF_CG_ADDR_TAKEN = 0x00008000 // - address is known outside generated code
, SF_ENUM_UINT = 0x00010000 // - constant unsigned value in symbol
// specific flags:
// SCOPE_CLASS
, SF_PROTECTED = 0x80000000 // - symbol is protected
, SF_PRIVATE = 0x40000000 // - symbol is private
, SF_IN_VFT = 0x20000000 // - function in gen'ed VFT
// SCOPE_FILE
, SF_PLUSPLUS = 0x80000000 // - symbol is extern "C++"
, SF_IS_THROW = 0x40000000 // - R/T call is a C++ throw
// - variable
, SF_ANONYMOUS = 0x08000000 // - - member of an anonymous union
, SF_RETN_OPT = 0x04000000 // - - optimized away by return opt.
, SF_CATCH_ALIAS = 0x02000000 // - - catch variable alias
, SF_IN_CLASS_INIT = 0x01000000 // - - in-class initialization
// of const static integral
// member
// - function
, SF_DONT_INLINE = 0x08000000 // - - don't inline this function!
, SF_MUST_GEN = 0x04000000 // - - function must be generated
// - function, during back-end
, SF_CG_INLINEABLE = 0x02000000 // - - function could be inlined
/* multi-bit constants */
, SF_ACCESS = ( SF_PRIVATE // - - access for member
| SF_PROTECTED )
, SF_FN_LONGJUMP = ( SF_LONGJUMP // - - decidable if function can
| SF_NO_LONGJUMP ) //throw, longjump, etc
, SF_NULL = 0x00000000
} symbol_flag;
typedef enum // flags for symbol.flags2
// hdl control flags
{ SF2_TOKEN_LOCN = 0x01 // - has token location
, SF2_CG_HANDLE = 0x02 // - has code-gen handle
, SF2_DW_HANDLE_FWD = 0x04 // - has forward dwarf handle
, SF2_DW_HANDLE_DEF = 0x08 // - has defined dwarf handle
, SF2_SYMDBG = 0x10 // - has defined symdbg handle
/* multi-bit constants */
, SF2_DW_HANDLE = ( SF2_DW_HANDLE_FWD
| SF2_DW_HANDLE_DEF )
, SF2_HDL_MASK = ( SF2_DW_HANDLE // - - 'handles' union value
| SF2_CG_HANDLE )
, SF2_NULL = 0x00
} symbol_flag2;
PCH_struct symbol { // SYMBOL in symbol table
SYMBOL next; // - next in ring
SYMBOL thread; // - SCOPE ordering OR defarg base chain
TYPE sym_type; // - TYPE for symbol
SYMBOL_NAME name; // - SYMBOL_NAME for symbol
// union {
// DW_TOKEN_LOCN *location; // - location during parsing
// void *cg_handle; // - handle during code-generation
// } hdl;
SYM_TOKEN_LOCN *locn; // - location, (dwarf or cg) handle
union {
target_ulong uval; // - SC_ENUM -- unsigned value
target_long sval; // - SC_ENUM -- signed value
POOL_CON* pval; // - SC_ENUM, const int: - pool value
target_offset_t offset; // - SC_MEMBER -- data offset
TEMPLATE_INFO *tinfo; // - SC_CLASS_TEMPLATE -- info for it
FN_TEMPLATE_DEFN *defn; // - SC_FUNCTION_TEMPLATE -- defn for it
PTREE defarg_info; // - SC_DEFAULT -- defarg info
// use op=PT_TYPE,
// next is defarg expr
// scope for temporaries (or NULL)
TYPE udc_type; // - SC_ACCESS -- extra info for UDCs
SYMBOL alias; // - SF_ALIAS -- aliased symbol
SYMBOL virt_fun; // - SC_VIRTUAL_FUNCTION -- virt. func.
unsigned scalar_order; // - SC_FUNCTION -- used in dummy scalars
SYMBOL thunk_calls; // - SC_FUNCTION -- when thunk, orig. function
NAME_SPACE *ns; // - SC_NAMESPACE -- info for it
SYMBOL sym;
TYPE type;
int sym_offset; // - SC_AUTO,SC_REGISTER -- fast cgen
} u;
symbol_flag flag; // - flags
uint_8 flag2; // - flags2
symbol_class id; // - storage class
fe_seg_id segid; // - segment id
};
// adding a symbol to the SYMBOL_NAME has to be consistently
// a push or append for namespace multi-sym returns
#define _AddSymToRing( h, r ) RingAppend( (h), (r) );
PCH_struct symbol_name {
SYMBOL_NAME next;
SYMBOL name_type;
SYMBOL name_syms;
char *name;
SCOPE containing;
};
// region includes 'first' up to and including 'last' (both fields are non-NULL)
PCH_struct sym_region { // list of symbols from same SYMBOL_NAME
SYM_REGION *next;
SYMBOL from; // - first symbol
SYMBOL to; // - last symbol
};
PCH_struct name_space {
SYMBOL sym; // - sym of namespace
SCOPE scope; // - scope of namespace
SYMBOL last_sym; // - scope's last sym (see TEMPLATE.C)
NAME_SPACE *all; // - link together all namespaces
union {
unsigned flags;
struct {
unsigned global_fs : 1; // - global filescope
unsigned free : 1; // - used for PCH
unsigned unnamed : 1; // - unnamed namespace
};
};
};
PCH_struct using_ns {
USING_NS *next;
SCOPE trigger; // - if we find nothing in this scope,
// search in the alternate scope
SCOPE using_scope; // - alternate namespace scope to search
};
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?