cgbackut.h

来自「开放源码的编译器open watcom 1.6.0版的源代码」· C头文件 代码 · 共 1,466 行 · 第 1/4 页

H
1,466
字号
/****************************************************************************
*
*                            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 __CGBACKUT_H__
#define __CGBACKUT_H__

// CGBACKUT.H -- internal (to C++ back-end) definitions
//
// 93/09/09 -- J.W.Welch    -- defined

#include "typesig.h"
#include "codegen.h"
#include "cgaux.h"
#include "cginfo.h"
#include "conpool.h"
#include "cgio.h"
#include "vstk.h"
#include "stringl.h"

typedef union  se     SE;
typedef struct se_def SE_DEF;
typedef struct se_ref SE_REF;
typedef struct cond_label COND_LABEL;

enum {
    DSC_CONST           = 0x01,
    DSC_CODE_OK         = 0x02,
    DSC_NULL            = 0x00
};

typedef enum                    // flags controlling grouped destruction
{   DGRP_DIRECT     = 0x0001    // - TRUE ==> direct destruction
,   DGRP_TEMPS      = 0x0002    // - TRUE ==> generate DTOR of temps
,   DGRP_COMPS      = 0x0004    // - TRUE ==> generate DTOR of components
,   DGRP_CTOR       = 0x0008    // - TRUE ==> dtor of ctor
,   DGRP_COUNT      = 0x2000    // - TRUE ==> count the destructions
                                // flags used internally
,   DGRP_VTEST      = 0x0010    // - TRUE ==> virtual test done
,   DGRP_LIVE       = 0x0020    // - TRUE ==> live code
,   DGRP_DONE       = 0x0040    // - TRUE ==> CGDone for expression
,   DGRP_TRASH      = 0x0080    // - TRUE ==> CGTrash for expression
,   DGRP_CTOR_BEG   = 0x0100    // - TRUE ==> (-xst) ctor-bit enabled
,   DGRP_CTOR_END   = 0x0200    // - TRUE ==> (-xst) ctor-bit disabled
,   DGRP_XST        = 0x0400    // - TRUE ==> -xst in effect
,   DGRP_TAB_CALL   = 0x0800    // - TRUE ==> table call req'd to be genned
,   DGRP_TRY_EMIT   = 0x1000    // - TRUE ==> emit try adjustment
,   DGRP_NONE       = 0         // - place holder
} DGRP_FLAGS;

#define UNDEFINED_LABEL 0       // indicates no label definition
#define UNDEFINED_TEMP  0       // indicates no temporary defined
#define UNDEFINED_TYPE  (-1)    // indicates no type defined

typedef struct cond_info COND_INFO;
struct cond_info                // COND_INFO -- info. for conditional DTOR
{   SYMBOL sym;                 // - base symbol for test
    target_offset_t offset;     // - offset of byte to be tested/set/reset
    uint_8 mask;                // - mask for byte
    PAD_UNSIGNED
};

typedef struct                  // CGBK_INFO -- useful info for CGBK...
{   target_size_t size_code_ptr;// - size of code pointer
    target_size_t size_data_ptr;// - size of data pointer
    target_size_t size_offset;  // - size of offset
    target_size_t size_rw_base; // - base of RW_DTREG_..
    target_size_t size_fs_hand; // - size of fs handle
    PAD_UNSIGNED
} CGBK_INFO;

extern CGBK_INFO CgbkInfo;      // found in CGBKMAIN


typedef struct throw_ro THROW_RO;
struct throw_ro                 // THROW_RO -- R/O blocks for thrown types
{   THROW_RO *next;             // - next in ring( hdr. in ring_throw_ro )
    SYMBOL sym;                 // - symbol for the block
    TYPE_SIG *sig;              // - type signature for the type
    unsigned emitted : 1;       // - TRUE ==> has been emitted to codegen
    PAD_UNSIGNED
};

typedef target_offset_t STATE_VAR;

typedef struct                  // RT_DEF -- definitions for a R/T call
{   call_handle handle;         // - call handle
    cg_type type;               // - type for R/T call
} RT_DEF;

typedef struct try_impl TRY_IMPL;
struct try_impl                 // TRY_IMPL -- try's implemented in a function
{   TRY_IMPL* next;             // - next in ring
    SYMBOL try_sym;             // - try symbol
    SYMBOL jmp_sym;             // - jmpbuf variable
    target_offset_t offset_var;  // - offset of try variable from fun R/W
    target_offset_t offset_jmpbuf;//- offset of jmpbuf from fun R/W
    PAD_UNSIGNED
};

typedef struct dtreg_obj        DTREG_OBJ; // - registration variables
struct dtreg_obj
{   DTREG_OBJ* next;            // - next in ring
    SYMBOL sym;                 // - symbol for object (in use)
    SYMBOL cg_sym;              // - symbol for object (defined)
    target_offset_t offset;     // - offset of symbol
    unsigned in_use :1;         // - TRUE ==> in use
    PAD_UNSIGNED
};

typedef struct type_sig_ent     TYPE_SIG_ENT;
struct type_sig_ent             // TYPE_SIG_ENT -- entry in ring of type sig.s
{   TYPE_SIG_ENT *next;         // - next entry
    TYPE_SIG* sig;              // - type signature
};

typedef struct                  // SE_BASE -- base for state entries
{   SE* next;                   // - next in ring
    SE* prev;                   // - previous in ring
    STATE_VAR state_var;        // - state variable for entry
    uint_8 se_type;             // - type of entry
    uint_8 gen              :1; // - TRUE ==> entry is to be generated
    PAD_UNSIGNED
} SE_BASE;

typedef struct                  // SE_SYM_AUTO -- auto symbol to be DTORed
{   SE_BASE base;               // - base
    SYMBOL sym;                 // - auto symbol
    SYMBOL dtor;                // - DTOR for symbol
    target_offset_t offset;     // - offset of symbol from R/W block
    PAD_UNSIGNED
} SE_SYM_AUTO;

typedef struct                  // SE_SYM_STATIC -- static symbol to be DTORed
{   SE_BASE base;               // - base
    SYMBOL sym;                 // - static symbol
    SYMBOL dtor;                // - DTOR for symbol
} SE_SYM_STATIC;

typedef struct                  // SE_SUBOBJ -- sub-object
{   SE_BASE base;               // - base
    TYPE type;                  // - object type
    SYMBOL dtor;                // - DTOR for symbol
    target_offset_t offset;     // - offset within object (DTOR object)
    target_offset_t original;   // - offset within object (original object)
    uint_8 kind;                // - kind of object (DTC_...)
    PAD_UNSIGNED
} SE_SUBOBJ;

typedef struct                  // SE_ARRAY -- array in object table
{   SE_BASE base;               // - base
    TYPE_SIG* sig;              // - type signature for element
    target_offset_t offset;     // - offset of array
    target_size_t count;        // - number of elements
    PAD_UNSIGNED
} SE_ARRAY;

typedef struct                  // SE_CTOR_TEST -- command: test if ctor'ed
{   SE_BASE base;               // - base
    unsigned flag_no;           // - flag number
} SE_CTOR_TEST;

typedef struct                  // SE_SET_SV -- command: set_sv
{   SE_BASE base;               // - base
    SE* se;                     // - entry to be set
} SE_SET_SV;

typedef struct                  // SE_TEST_FLAG -- command: test_flag
{   SE_BASE base;               // - base
    SE* se_true;                // - entry, when TRUE
    SE* se_false;               // - entry, when FALSE
    target_offset_t index;      // - index
    PAD_UNSIGNED
} SE_TEST_FLAG;

typedef struct                  // SE_TRY -- try block start
{   SE_BASE base;               // - base
    TRY_IMPL* try_impl;         // - try implementation to be used
    TYPE_SIG_ENT* sigs;         // - type signatures for catches
    SYMBOL sym;                 // - symbol for try, catches
} SE_TRY;

typedef struct                  // SE_CATCH -- catch block start
{   SE_BASE base;               // - base
    SE* try_blk;                // - try for catch
    TYPE_SIG_ENT* sig;          // - type signature for caught variable
} SE_CATCH;

typedef struct                  // SE_FN_EXC -- function except. specification
{   SE_BASE base;               // - base
    TYPE_SIG_ENT* sigs;         // - type signatures in specification
} SE_FN_EXC;

typedef struct                  // SE_COMPONENT -- SUB-OBJECT COMPONENT
{   SE_BASE base;               // - base
    DTREG_OBJ* obj;             // - RW_DTREG_OBJECT symbol
    SYMBOL dtor;                // - DTOR for component
    target_offset_t offset;     // - offset of component
    PAD_UNSIGNED
} SE_COMPONENT;

typedef struct                  // SE_OBJECT_INIT -- static/auto object init
{   SE_BASE base;               // - base
    DTREG_OBJ* reg;             // - registration element
} SE_ARRAY_INIT;

typedef struct                  // SE_DLT_1 -- new-delete, 1 parm
{   SE_BASE base;               // - base
    SYMBOL op_del;              // - operator delete( void* )
    target_offset_t offset;     // - offset of ptr to object
    PAD_UNSIGNED
} SE_DLT_1;

typedef struct                  // SE_DLT_2 -- new-delete, 2 parms
{   SE_BASE base;               // - base
    SYMBOL op_del;              // - operator delete( void*, size_t )
    target_offset_t offset;     // - offset of ptr to object
    target_size_t size;         // - object size
    PAD_UNSIGNED
} SE_DLT_2;

typedef SE_DLT_1 SE_DLT_1_ARRAY;    // SE_DLT_1_ARRAY
typedef SE_DLT_2 SE_DLT_2_ARRAY;    // SE_DLT_2_ARRAY


union se                        // SE -- state entry: one of
{   SE_BASE base;               // - base
    SE_SYM_AUTO sym_auto;       // - auto symbol
    SE_SYM_STATIC sym_static;   // - static symbol
    SE_ARRAY array;             // - array in object table
    SE_SUBOBJ subobj;           // - sub-object
    SE_SET_SV set_sv;           // - cmd: set_sv
    SE_TEST_FLAG test_flag;     // - cmd: test_flag
    SE_TRY try_blk;             // - cmd: try
    SE_CATCH catch_blk;         // - cmd: catch
    SE_FN_EXC fn_exc;           // - cmd: fn_exc
    SE_COMPONENT component;     // - cmd: component
    SE_ARRAY_INIT array_init;   // - cmd: data array initialization
    SE_DLT_1 del_1;             // - cmd: new-delete (1 parm)
    SE_DLT_2 del_2;             // - cmd: new-delete (2 parms)
    SE_DLT_1 del_1_array;       // - cmd: new-delete-array (1 parm)
    SE_DLT_2 del_2_array;       // - cmd: new-delete-array (2 parms)
    SE_CTOR_TEST ctor_test;     // - cmd: ctor-test
};

typedef struct blk_posn BLK_POSN;

typedef struct cmd_base         CMD_BASE;
struct cmd_base
{   CMD_BASE* next;             // - next in ring
    SYMBOL sym;                 // - symbol for generated command
    unsigned emitted : 1;       // - TRUE ==> has been emitted to codegen
};

typedef struct                  // CMD_SET_SV
{   CMD_BASE base;              // - base
    STATE_VAR state_var;        // - state variable
    PAD_UNSIGNED
} CMD_SET_SV;

typedef struct                  // CMD_TEST_FLAG
{   CMD_BASE base;              // - base
    target_size_t index;        // - index
    STATE_VAR state_var_true;   // - true value
    STATE_VAR state_var_false;  // - false value
    PAD_UNSIGNED
} CMD_TEST_FLAG;

typedef struct                  // CMD_TRY
{   CMD_BASE base;              // - base
    TYPE_SIG_ENT* sigs;         // - type signatures
    target_offset_t offset_var; // - offset of try variable from fun R/W
    target_offset_t offset_jmpbuf; // - offset of jmpbuf from fun R/W
    STATE_VAR state;            // - state preceding try
    PAD_UNSIGNED
} CMD_TRY;

typedef struct                  // CMD_FN_EXC
{   CMD_BASE base;              // - base
    TYPE_SIG_ENT* sigs;         // - type signatures
} CMD_FN_EXC;

typedef struct                  // CMD_COMPONENT
{   CMD_BASE base;              // - base
    DTREG_OBJ* obj;             // - object
    SYMBOL dtor;                // - DTOR for component
    unsigned cmd_type;          // - command type
    target_offset_t offset;     // - offset of component
    PAD_UNSIGNED
} CMD_COMPONENT;

typedef struct                  // CMD_ARRAY_INIT
{   CMD_BASE base;              // - base
    DTREG_OBJ* reg;             // - registration to be used
} CMD_ARRAY_INIT;

typedef struct                  // CMD_CTOR_TEST
{   CMD_BASE base;              // - base
    unsigned flag_no;           // - flag number
} CMD_CTOR_TEST;

typedef struct                  // CMD_DEL_1
{   CMD_BASE base;              // - base
    SYMBOL op_del;              // - operator delete( void* )
    target_offset_t offset;     // - offset to ptr to object
    PAD_UNSIGNED
} CMD_DEL_1;

typedef struct                  // CMD_DEL_2
{   CMD_BASE base;              // - base
    SYMBOL op_del;              // - operator delete( void*, size_t )
    target_offset_t offset;     // - offset to ptr to object
    target_offset_t size;       // - object size
    PAD_UNSIGNED
} CMD_DEL_2;

typedef CMD_DEL_1 CMD_DEL_1_ARRAY;  // CMD_DEL_1_ARRAY
typedef CMD_DEL_2 CMD_DEL_2_ARRAY;  // CMD_DEL_2_ARRAY


typedef struct stab_defn        STAB_DEFN; // -- state table definition
struct stab_defn
{   SE* state_table;            // - state table entries
    SYMBOL ro;                  // - R/O symbol
    unsigned kind;              // - kind of state table
};


typedef struct stab_obj         STAB_OBJ; // -- state table for object
struct stab_obj
{   STAB_OBJ* next;             // - next in ring
    TYPE obj;                   // - StructType of object
    STAB_DEFN* defn;            // - definition
    STATE_VAR state_virtual;    // - object: state for last virtual base
    STATE_VAR state_direct;     // - object: state for last direct base
    PAD_UNSIGNED
};


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?