dbtypes.c
来自「开放源码的编译器open watcom 1.6.0版的源代码」· C语言 代码 · 共 1,151 行 · 第 1/3 页
C
1,151 行
/****************************************************************************
*
* 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!
*
****************************************************************************/
#include <string.h>
#include "standard.h"
#include "coderep.h"
#include "cgdefs.h"
#include "sysmacro.h"
#include "symdbg.h"
#include "model.h"
#include "typedef.h"
#include "ocentry.h"
#include "objrep.h"
#include "zoiks.h"
#include "dbgstrct.h"
#ifndef NDEBUG
#include "echoapi.h"
#endif
#include "i64.h"
extern uint Length(char*);
extern dbg_loc LocDupl( dbg_loc );
extern offset LocSimpField( dbg_loc );
extern type_def *TypeAddress(cg_type);
/* WV interface */
#if _TARGET &( _TARG_IAPX86 | _TARG_80386 )
extern dbg_type WVFtnType( char *name, dbg_ftn_type tipe );
extern dbg_type WVScalar( char *name, cg_type tipe );
extern dbg_type WVScope( char *name );
extern void WVDumpName( name_entry *name, dbg_type tipe );
extern void WVBackRefType( name_entry *name, dbg_type tipe );
extern dbg_type WVCharBlock( unsigned_32 len );
extern dbg_type WVIndCharBlock( back_handle len, cg_type len_type,
int off );
extern dbg_type WVLocCharBlock( dbg_loc loc, cg_type len_type );
extern dbg_type WVFtnArray( back_handle dims, cg_type lo_bound_tipe,
cg_type num_elts_tipe, int off,
dbg_type base );
extern dbg_type WVArray( dbg_type idx, dbg_type base );
extern dbg_type WVIntArray( unsigned_32 hi, dbg_type base );
extern dbg_type WVEndArray( array_list *ar );
extern dbg_type WVSubRange( signed_32 lo, signed_32 hi,
dbg_type base );
extern dbg_type WVDereference( cg_type ptr_type, dbg_type base );
extern dbg_type WVPtr( cg_type ptr_type, dbg_type base );
extern dbg_type WVBasedPtr( cg_type ptr_type, dbg_type base,
dbg_loc loc_segment );
extern dbg_type WVEndStruct( struct_list *st );
extern dbg_type WVEndEnum( enum_list *en );
extern dbg_type WVEndProc( proc_list *pr );
#endif
/* DF interface */
extern dbg_type DFFtnType( char *name, dbg_ftn_type tipe );
extern dbg_type DFScalar( char *name, cg_type tipe );
extern dbg_type DFScope( char *name );
extern void DFDumpName( name_entry *name, dbg_type tipe );
extern void DFBackRefType( name_entry *name, dbg_type tipe );
extern dbg_type DFCharBlock( unsigned_32 len );
extern dbg_type DFIndCharBlock( back_handle len, cg_type len_type,
int off );
extern dbg_type DFLocCharBlock( dbg_loc loc, cg_type len_type );
extern dbg_type DFFtnArray( back_handle dims, cg_type lo_bound_tipe,
cg_type num_elts_tipe, int off,
dbg_type base );
extern dbg_type DFArray( dbg_type idx, dbg_type base );
extern dbg_type DFIntArray( unsigned_32 hi, dbg_type base );
extern dbg_type DFEndArray( array_list *ar );
extern dbg_type DFSubRange( signed_32 lo, signed_32 hi,
dbg_type base );
extern dbg_type DFDereference( cg_type ptr_type, dbg_type base );
extern dbg_type DFPtr( cg_type ptr_type, dbg_type base );
extern dbg_type DFBasedPtr( cg_type ptr_type, dbg_type base,
dbg_loc loc_segment );
extern void DFBegStruct( struct_list *st );
extern dbg_type DFEndStruct( struct_list *st );
extern dbg_type DFEndEnum( enum_list *en );
extern dbg_type DFEndProc( proc_list *pr );
/* DF interface */
extern dbg_type CVFtnType( char *name, dbg_ftn_type tipe );
extern dbg_type CVScalar( char *name, cg_type tipe );
extern dbg_type CVScope( char *name );
extern void CVDumpName( name_entry *name, dbg_type tipe );
extern void CVBackRefType( name_entry *name, dbg_type tipe );
extern dbg_type CVCharBlock( unsigned_32 len );
extern dbg_type CVIndCharBlock( back_handle len, cg_type len_type,
int off );
extern dbg_type CVLocCharBlock( dbg_loc loc, cg_type len_type );
extern dbg_type CVFtnArray( back_handle dims, cg_type lo_bound_tipe,
cg_type num_elts_tipe, int off,
dbg_type base );
extern dbg_type CVArray( dbg_type idx, dbg_type base );
extern dbg_type CVIntArray( unsigned_32 hi, dbg_type base );
extern dbg_type CVEndArray( array_list *ar );
extern dbg_type CVArraySize( offset size, unsigned_32 hi, dbg_type base );
extern dbg_type CVSubRange( signed_32 lo, signed_32 hi,
dbg_type base );
extern dbg_type CVDereference( cg_type ptr_type, dbg_type base );
extern dbg_type CVPtr( cg_type ptr_type, dbg_type base );
extern dbg_type CVBasedPtr( cg_type ptr_type, dbg_type base,
dbg_loc loc_segment );
//extern void CVBegStruct( struct_list *st );
extern dbg_type CVEndStruct( struct_list *st );
extern dbg_type CVEndEnum( enum_list *en );
extern dbg_type CVEndProc( proc_list *pr );
#define MAX_TYPE_SIZE (1024 * 16)
static char Nested; /* set when types are nested by others */
/*
need to fix dbg_type so it's a handle that can be used
by any format WV, DW and CV.
figure how fundamental types are done
*/
extern dbg_type _CGAPI DBFtnType( char *name, dbg_ftn_type tipe ) {
/******************************************************************/
dbg_type ret;
#ifndef NDEBUG
EchoAPI( "DBFtnType( %c, %i )", name, tipe );
#endif
if( _IsModel( DBG_DF ) ) {
ret = DFFtnType( name, tipe );
}else if( _IsModel( DBG_CV ) ) {
ret = CVFtnType( name, tipe );
}else{
#if _TARGET &( _TARG_IAPX86 | _TARG_80386 )
ret = WVFtnType( name, tipe );
#endif
}
#ifndef NDEBUG
EchoAPI( " -> %i\n", ret );
#endif
return( ret );
}
extern dbg_type _CGAPI DBScalar( char *name, cg_type tipe ) {
/************************************************************/
dbg_type ret;
#ifndef NDEBUG
EchoAPI( "DBScalar( %c,%t )", name, tipe );
#endif
if( _IsModel( DBG_DF ) ) {
ret = DFScalar( name, tipe );
}else if( _IsModel( DBG_CV ) ) {
ret = CVScalar( name, tipe );
}else{
#if _TARGET &( _TARG_IAPX86 | _TARG_80386 )
ret = WVScalar( name, tipe );
#endif
}
#ifndef NDEBUG
EchoAPI( " -> %i\n", ret );
#endif
return( ret );
}
extern dbg_type _CGAPI DBScope( char *name ) {
/*********************************************/
dbg_type ret;
#ifndef NDEBUG
EchoAPI( "DBScope( %c )", name );
#endif
if( _IsModel( DBG_DF ) ) {
ret = DFScope( name );
}else if( _IsModel( DBG_CV ) ) {
ret = CVScope( name );
}else{
#if _TARGET &( _TARG_IAPX86 | _TARG_80386 )
ret = WVScope( name );
#endif
}
#ifndef NDEBUG
EchoAPI( " -> %i\n", ret );
#endif
return( ret );
}
extern name_entry * _CGAPI DBBegName( char *nm, dbg_type scope ) {
/*****************************************************************/
name_entry *name;
uint len;
#ifndef NDEBUG
EchoAPI( "DBBegName( %c, %i )", nm, scope );
#endif
len = strlen( nm );
_Alloc( name, sizeof( name_entry ) + len );
strcpy( name->name, nm );
name->len = len;
name->scope = scope;
name->refno = DBG_NIL_TYPE;
#ifndef NDEBUG
EchoAPI( " -> %i\n", name );
#endif
return( name );
}
extern dbg_type _CGAPI DBForward( name_entry *name ) {
/*****************************************************/
#ifndef NDEBUG
EchoAPI( "DBForward( %i )", name );
#endif
if( name->refno == DBG_NIL_TYPE ) {
if( _IsModel( DBG_DF ) ) {
/* do nothing */
}else if( _IsModel( DBG_CV ) ) {
CVDumpName( name, DBG_FWD_TYPE );
}else{
#if _TARGET &( _TARG_IAPX86 | _TARG_80386 )
WVDumpName( name, DBG_FWD_TYPE );
#endif
}
}
#ifndef NDEBUG
EchoAPI( " -> %i\n", name->refno );
#endif
return( name->refno );
}
extern dbg_type _CGAPI DBEndName( name_entry *name, dbg_type tipe ) {
/********************************************************************/
dbg_type retv;
#ifndef NDEBUG
EchoAPI( "DBEndName( %i, %i )", name, tipe );
#endif
if( name->refno == DBG_NIL_TYPE ) {
if( _IsModel( DBG_DF ) ) {
DFDumpName( name, tipe );
}else if( _IsModel( DBG_CV ) ) {
CVDumpName( name, tipe );
}else{
#if _TARGET &( _TARG_IAPX86 | _TARG_80386 )
WVDumpName( name, tipe );
#endif
}
} else if( _IsModel( DBG_TYPES ) ) {
if( _IsModel( DBG_DF ) ) {
DFBackRefType( name, tipe );
}else if( _IsModel( DBG_CV ) ) {
CVBackRefType( name, tipe );
}else{
#if _TARGET &( _TARG_IAPX86 | _TARG_80386 )
WVBackRefType( name, tipe );
#endif
}
}
retv = name->refno;
_Free( name, sizeof( name_entry ) + name->len );
#ifndef NDEBUG
EchoAPI( " -> %i\n", retv );
#endif
return( retv );
}
extern dbg_type _CGAPI DBCharBlock( unsigned_32 len ) {
/******************************************************/
dbg_type ret;
#ifndef NDEBUG
EchoAPI( "DBCharBlock( %i )", len );
#endif
if( _IsModel( DBG_DF ) ) {
ret = DFCharBlock( len );
}else if( _IsModel( DBG_CV ) ) {
ret = CVCharBlock( len );
}else{
#if _TARGET &( _TARG_IAPX86 | _TARG_80386 )
ret = WVCharBlock( len );
#else
ret = 0;
#endif
}
return( ret );
}
extern dbg_type _CGAPI DBIndCharBlock( back_handle len, cg_type len_type,
int off ) {
/************************************************************************/
dbg_type ret;
#ifndef NDEBUG
EchoAPI( "DBIndCharBlock( %i, %t, %i )", len,len_type, off );
#endif
if( _IsModel( DBG_DF ) ) {
ret = DFIndCharBlock( len, len_type, off );
}else if( _IsModel( DBG_CV ) ) {
ret = CVIndCharBlock( len, len_type, off );
}else{
#if _TARGET &( _TARG_IAPX86 | _TARG_80386 )
ret = WVIndCharBlock( len, len_type, off );
#else
ret = 0;
#endif
}
#ifndef NDEBUG
EchoAPI( " -> %i\n", ret );
#endif
return( ret );
}
extern dbg_type _CGAPI DBLocCharBlock( dbg_loc loc, cg_type len_type ) {
/***********************************************************************/
dbg_type ret;
#ifndef NDEBUG
EchoAPI( "DBLocCharBlock( %i, %t )", loc, len_type );
#endif
if( _IsModel( DBG_DF ) ) {
ret = DFLocCharBlock( loc, len_type );
}else if( _IsModel( DBG_CV ) ) {
ret = CVLocCharBlock( loc, len_type );
}else{
#if _TARGET &( _TARG_IAPX86 | _TARG_80386 )
ret = WVLocCharBlock( loc, len_type );
#else
ret = 0;
#endif
}
#ifndef NDEBUG
EchoAPI( " -> %i\n", ret );
#endif
return( ret );
}
extern dbg_type _CGAPI DBFtnArray( back_handle dims, cg_type lo_bound_tipe,
cg_type num_elts_tipe, int off,
dbg_type base ) {
/***************************************************************************/
dbg_type ret;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?