static void TestString( void ) { dw_loc_handle string_length; dw_handle string_hdl; dw_loc_handle a_loc; dw_loc_id id; /* type InputBuffer = String( 512 ); -- I forget exact Ada syntax */ DWDeclPos( Client, 50, 1 ); DWString( Client, NULL, 512, "InputBuffer", 0, 0 ); /* CHARACTER*(*) A */ /* we'll pretend the length of the string is at -4[ebp] */ DWDeclPos( Client, 50, 8 ); id = DWLocInit( Client ); DWLocOp( Client, id, DW_LOC_fbreg, -4 ); string_length = DWLocFini( Client, id ); string_hdl = DWString( Client, string_length, sizeof( uint_32 ), NULL, 0, 0 ); DWLocTrash( Client, string_length ); id = DWLocInit( Client ); DWLocOp( Client, id, DW_LOC_fbreg, -8 ); a_loc = DWLocFini( Client, id ); DWDeclPos( Client, 50, 16 ); DWVariable( Client, string_hdl, a_loc, 0, NULL, "A", 0, 0 ); DWLocTrash( Client, a_loc ); }
static void TestPointer( void ) { /* const char * far *p */ DWDeclPos( Client, 36, 12 ); DWPointer( Client, ConstCharStar, DW_PTR_TYPE_FAR16 ); /* same thing but a reference */ DWDeclPos( Client, 36, 29 ); DWPointer( Client, ConstCharStar, DW_FLAG_REFERENCE | DW_PTR_TYPE_FAR32 ); }
static dw_handle BIGetBaseType( TYPE typ ) { //========================================= // Get initialized base type DWDeclPos( cBIId, CurrFile->rec, 0 ); return( baseTypes[ typ ] ); }
void BIOutSrcLine( void ) { //=================== // Set Current Source Line if( _GenerateBrInfo() ) { DWLineNum( cBIId, DW_LN_DEFAULT, SrcRecNum, 0, 0 ); DWDeclPos( cBIId, CurrFile->rec, 0 ); } }
void BIStartBlockData( sym_id ste_ptr ) { //========================================== char name[MAX_SYMLEN+1]; if( _GenerateBrInfo() ) { memset( name, 0, MAX_SYMLEN+1 ); DWDeclPos( cBIId, CurrFile->rec, 0 ); DWBeginLexicalBlock( cBIId, 0, strncpy( name, ste_ptr->u.ns.name, ste_ptr->u.ns.u2.name_len ) ); } }
static void TestArray( void ) { #if 0 dw_dim_info dim_info; dw_vardim_info vdim_info; dw_handle array_hdl; dw_loc_handle buf_loc; dw_loc_handle buf2_loc; dw_loc_id id; /* char buf[80]; */ DWDeclPos( Client, 55, 79 ); array_hdl = DWBeginArray( Client, 1 ); dim_info.index_type = FundamentalTypes[DW_FT_UNSIGNED]; dim_info.lo_data = 0; dim_info.hi_data = 79; DWArrayDimension( Client, &dim_info ); DWEndArray( Client ); SymHandles[3] = 0x1234bUL; id = DWLocInit( Client ); DWLocStatic( Client, id, (dw_sym_handle)3 ); buf_loc = DWLocFini( Client, id ); DWDeclPos( Client, 55, 80 ); DWVariable( Client, array_hdl, buf_loc, 0, NULL, "buf", 0, DW_FLAG_GLOBAL ); DWLocTrash( Client, buf_loc ); /* INTEGER*4 A(1:N) */ DWDeclPos( Client, 55, 81 ); array_hdl = DWBeginArray( Client, 1 ); dim_info.index_type = FundamentalTypes[DW_FT_SIGNED]; dim_info.lo_data = 1; id = DWLocInit( Client ); /* assume N is at -4[ebp] */ DWLocOp( Client, id, DW_LOC_fbreg, -4 ); buf2_loc = DWLocFini( Client, id ); vdim_info.count_data = (dw_handle)buf2_loc; DWArrayDimension( Client, &dim_info ); DWLocTrash( Client, buf2_loc ); DWEndArray( Client ); #endif }
static void TestTypedef( void ) { dw_handle name_ptr; dw_handle volatile_name; /* typedef signed char uint_8; */ DWDeclPos( Client, 10, 1 ); DWTypedef( Client, FundamentalTypes[DW_FT_SIGNED_CHAR], "uint_8", 0, 0 ); /* typedef const char *name_ptr; */ DWDeclPos( Client, 11, 1 ); name_ptr = DWTypedef( Client, ConstCharStar, "name_ptr", 0, 0 ); /* typedef name_ptr other_ptr */ DWDeclPos( Client, 12, 1 ); DWTypedef( Client, name_ptr, "other_ptr", 0, 0 ); /* typedef volatile name_ptr icky_ptr */ DWDeclPos( Client, 15, 1 ); volatile_name = DWModifier( Client, name_ptr, DW_MOD_VOLATILE ); DWTypedef( Client, volatile_name, "icky_ptr", 0, 0 ); }
void BIStartComBlock( sym_id ste_ptr ) { //========================================= char name[MAX_SYMLEN+1]; if( _GenerateBrInfo() ) { memset( name, 0, MAX_SYMLEN+1 ); DWDeclPos( cBIId, CurrFile->rec, 0 ); currState |= BI_STATE_IN_COMMON_BLOCK; DWIncludeCommonBlock( cBIId, DWBeginCommonBlock( cBIId, justJunk, 0, strncpy( name, ste_ptr->u.ns.name, ste_ptr->u.ns.u2.name_len ), 0 ) ); } }
void BISetSrcFile( void ) { //=================== // Set Current Source Line char *name; if( _GenerateBrInfo() ) { if ( !( ProgSw & PS_FATAL_ERROR ) && CurrFile ) { name = BIMKFullPath( CurrFile->name ); DWSetFile( cBIId, name ); DWDeclFile( cBIId, name ); DWLineNum( cBIId, DW_LN_DEFAULT, CurrFile->rec, 0, 0 ); DWDeclPos( cBIId, CurrFile->rec, 0 ); } } }
static dw_handle BIGetUnionType( sym_id ste_ptr ) { //================================================= // get a union type of a non named symbol struct fstruct *fs; dw_handle ret; symbol data; long max = 0; long map = 0; char buff[12]; ret = DWStruct( cBIId, DW_ST_UNION ); fs = ste_ptr->u.ns.xt.record; // find the largest size of map while( fs ) { if ( fs->size > max ) { max = fs->size; } fs = &fs->link->u.sd; } // Start the union declaration DWDeclPos( cBIId, CurrFile->rec, 0 ); DWBeginStruct( cBIId, ret, max, ste_ptr->u.ns.name, 0, 0 ); fs = ste_ptr->u.ns.xt.record; data.u.ns.xt.record = FMemAlloc( sizeof( fstruct) ); while( fs ) { memset( data.u.ns.xt.record, 0, sizeof( fstruct ) ); memcpy( data.u.ns.xt.record, fs, sizeof( fmap ) ); data.u.ns.si.va.u.dim_ext = NULL; data.u.ns.u1.s.typ = FT_STRUCTURE; strcpy( data.u.ns.name, "MAP" ); strcat( data.u.ns.name, itoa( map, buff, 10 ) ); data.u.ns.u2.name_len = strlen( data.u.ns.name ); strcpy( data.u.ns.xt.record->name, data.u.ns.name ); data.u.ns.xt.record->name_len = data.u.ns.u2.name_len; map++; DWAddField( cBIId, BIGetType( &data ), justJunk, data.u.ns.name, 0 ); fs = &fs->link->u.sd; } FMemFree( data.u.ns.xt.record ); DWEndStruct( cBIId ); return( ret ); }
static void TestEnum( void ) { dw_uconst value; /* enum colours { RED, GREEN, BLUE }; */ DWDeclFile( Client, "A_New_File" ); DWDeclPos( Client, 1, 5 ); EnumColours = DWBeginEnumeration( Client, 1, "colours", 0, 0 ); value = 2; DWAddConstant( Client, value, "BLUE" ); value = 1; DWAddConstant( Client, value, "GREEN" ); value = 0; DWAddConstant( Client, value, "RED" ); DWEndEnumeration( Client ); }
static void BIOutSP( sym_id ste_ptr ) { //===================================== // Dump the subprogram. char name[MAX_SYMLEN+1]; uint flags = 0; dw_handle fret; DWDeclPos( cBIId, CurrFile->rec, 0 ); if ( ( ste_ptr->u.ns.flags & SY_SUBPROG_TYPE ) == SY_FUNCTION ) { if( ste_ptr->u.ns.flags & SY_SENTRY ) { fret = subProgTyHandle; } else { if ( ste_ptr->u.ns.u1.s.typ == FT_STRUCTURE ) { fret = BIStartStructType( ste_ptr, FALSE ); } else { fret = DWHandle( cBIId, DW_ST_NONE ); } subProgTyHandle = fret; } } else { fret = BIGetSPType( ste_ptr ); } memset( name, 0, MAX_SYMLEN+1 ); strncpy( name, ste_ptr->u.ns.name, ste_ptr->u.ns.u2.name_len ); if ( ste_ptr->u.ns.flags & SY_SENTRY ) { fret = DWBeginEntryPoint( cBIId, fret, justJunk, 0, name, 0, flags ); }else{ if ( ( ste_ptr->u.ns.flags & SY_SUBPROG_TYPE ) == SY_PROGRAM ) { flags |= DW_FLAG_MAIN; } fret = DWBeginSubroutine( cBIId, 0, fret, justJunk, 0, 0, 0, 0, name, 0, flags ); } BISetHandle( ste_ptr, fret ); }
static dw_handle BIGetArrayType( sym_id ste_ptr ) { //================================================= // Get An array type of a named symbol int dim = _DimCount( ste_ptr->u.ns.si.va.u.dim_ext->dim_flags ); int x = 0; dw_dim_info data; intstar4 *sub; dw_handle ret; data.index_type = BIGetBaseType( FT_INTEGER ); sub = &( ste_ptr->u.ns.si.va.u.dim_ext->subs_1_lo ); ret = DWBeginArray( cBIId, BIGetType( ste_ptr ), 0, NULL, 0, 0 ); for( x = 0; x < dim; x++ ) { data.lo_data = *sub++; data.hi_data = *sub++; DWArrayDimension( cBIId, &data ); } DWDeclPos( cBIId, CurrFile->rec, 0 ); DWEndArray( cBIId ); return( ret ); }
static dw_handle BIGetType( sym_id ste_ptr ) { //============================================ // Get the Symbol's NON COMPOUND DWARF TYPE, TYPE typ = ste_ptr->u.ns.u1.s.typ; dw_handle ret = 0; switch( typ ) { case( FT_LOGICAL_1 ): case( FT_LOGICAL ): case( FT_INTEGER_1 ): case( FT_INTEGER_2 ): case( FT_INTEGER ): case( FT_HEX ): case( FT_REAL ): case( FT_DOUBLE ): case( FT_TRUE_EXTENDED ): case( FT_COMPLEX ): case( FT_DCOMPLEX ): case( FT_TRUE_XCOMPLEX ): ret = baseTypes[ typ ]; break; case( FT_CHAR ): ret = DWString(cBIId, 0, ste_ptr->u.ns.xt.size, "", 0, 0); break; case( FT_UNION ): ret = BIGetUnionType( ste_ptr ); break; case( FT_STRUCTURE ): ret = BIGetStructType( ste_ptr, 0 ); break; } DWDeclPos( cBIId, CurrFile->rec, 0 ); return( ret ); }
static dw_handle BIGetStructType( sym_id ste_ptr, dw_handle handle ) { //==================================================================== // get a struct type of a non named symbol struct field *fields; dw_handle ret; sym_id data = alloca( sizeof(symbol) + AllocName(MAX_SYMLEN) ); char *name; char buffer[MAX_SYMLEN+1]; long un = 0; if ( handle ) { ret = handle; } else if ( ste_ptr->u.ns.xt.record->dbh ) { return( ste_ptr->u.ns.xt.record->dbh ); } else { // consider: record /bar/ function x() // .... // we want to use the handle we used when the function // was defined if ( ste_ptr->u.ns.xt.record == SubProgId->u.ns.xt.record ) { ret = subProgTyHandle; } else { ret = DWStruct( cBIId, DW_ST_STRUCT ); } } ste_ptr->u.ns.xt.record->dbh = ret; DWDeclPos( cBIId, CurrFile->rec, 0 ); memset( buffer, 0, MAX_SYMLEN+1 ); DWBeginStruct( cBIId, ret, ste_ptr->u.ns.xt.record->size, strncpy( buffer, ste_ptr->u.ns.xt.record->name, ste_ptr->u.ns.xt.record->name_len ), 0, 0 ); fields = ste_ptr->u.ns.xt.record->fl.fields; while( fields ) { data->u.ns.u1.s.typ = fields->typ; data->u.ns.xt.record = fields->xt.record; name = NULL; if ( fields->typ == FT_UNION ) { data->u.ns.si.va.u.dim_ext = NULL; data->u.ns.u2.name_len = 0; data->u.ns.name[0] = 0; un++; name = data->u.ns.name; } else { data->u.ns.si.va.u.dim_ext = fields->dim_ext; data->u.ns.u2.name_len = fields->name_len; strncpy( data->u.ns.name, fields->name, fields->name_len ); data->u.ns.name[ fields->name_len ] = 0; if ( *(data->u.ns.name) ) { name = data->u.ns.name; } } if ( data->u.ns.si.va.u.dim_ext ) { DWAddField(cBIId, BIGetArrayType(data), justJunk, name, 0); } else { DWAddField( cBIId, BIGetType( data ), justJunk, name, 0 ); } fields = &fields->link->u.fd; } DWEndStruct( cBIId ); return( ret ); }