1 /** 2 * Compiler implementation of the 3 * $(LINK2 http://www.dlang.org, D programming language). 4 * 5 * Copyright: Copyright (C) 1985-1998 by Symantec 6 * Copyright (C) 2000-2021 by The D Language Foundation, All Rights Reserved 7 * Authors: $(LINK2 http://www.digitalmars.com, Walter Bright) 8 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 9 * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/backend/cgcv.c, backend/cgcv.c) 10 */ 11 12 /* Header for cgcv.c */ 13 14 module dmd.backend.cgcv; 15 16 // Online documentation: https://dlang.org/phobos/dmd_backend_cgcv.html 17 18 import dmd.backend.cc : Classsym, Symbol; 19 import dmd.backend.dlist; 20 import dmd.backend.type; 21 22 extern (C++): 23 @nogc: 24 nothrow: 25 26 alias symlist_t = LIST*; 27 28 extern __gshared char* ftdbname; 29 30 void cv_init(); 31 uint cv_typidx(type* t); 32 void cv_outsym(Symbol* s); 33 void cv_func(Symbol* s); 34 void cv_term(); 35 36 void dwarf_outsym(Symbol* s); 37 38 uint cv4_struct(Classsym*, int); 39 40 41 /* =================== Added for MARS compiler ========================= */ 42 43 alias idx_t = uint; // type of type index 44 45 /* Data structure for a type record */ 46 47 struct debtyp_t 48 { 49 align(1): 50 uint prev; // previous debtyp_t with same hash 51 ushort length; // length of following array 52 ubyte[2] data; // variable size array 53 } 54 55 struct Cgcv 56 { 57 uint signature; 58 symlist_t list; // deferred list of symbols to output 59 idx_t deb_offset; // offset added to type index 60 uint sz_idx; // size of stored type index 61 int LCFDoffset; 62 int LCFDpointer; 63 int FD_code; // frame for references to code 64 } 65 66 __gshared Cgcv cgcv; 67 68 debtyp_t* debtyp_alloc(uint length); 69 int cv_stringbytes(const(char)* name); 70 uint cv4_numericbytes(uint value); 71 void cv4_storenumeric(ubyte* p, uint value); 72 uint cv4_signednumericbytes(int value); 73 void cv4_storesignednumeric(ubyte* p, int value); 74 idx_t cv_debtyp(debtyp_t* d); 75 int cv_namestring(ubyte* p, const(char)* name, int length = -1); 76 uint cv4_typidx(type* t); 77 idx_t cv4_arglist(type* t, uint* pnparam); 78 ubyte cv4_callconv(type* t); 79 idx_t cv_numdebtypes(); 80 81 void TOWORD(ubyte* a, uint b) 82 { 83 *cast(ushort*)a = cast(ushort)b; 84 } 85 86 void TOLONG(ubyte* a, uint b) 87 { 88 *cast(uint*)a = b; 89 } 90 91 void TOIDX(ubyte* a, uint b) 92 { 93 if (cgcv.sz_idx == 4) 94 TOLONG(a,b); 95 else 96 TOWORD(a,b); 97 } 98 99 enum DEBSYM = 5; // segment of symbol info 100 enum DEBTYP = 6; // segment of type info 101 102 /* ======================== Added for Codeview 8 =========================== */ 103 104 void cv8_initfile(const(char)* filename); 105 void cv8_termfile(const(char)* objfilename); 106 void cv8_initmodule(const(char)* filename, const(char)* modulename); 107 void cv8_termmodule(); 108 void cv8_func_start(Symbol* sfunc); 109 void cv8_func_term(Symbol* sfunc); 110 //void cv8_linnum(Srcpos srcpos, uint offset); // Srcpos isn't available yet 111 void cv8_outsym(Symbol* s); 112 void cv8_udt(const(char)* id, idx_t typidx); 113 int cv8_regnum(Symbol* s); 114 idx_t cv8_fwdref(Symbol* s); 115 idx_t cv8_darray(type* tnext, idx_t etypidx); 116 idx_t cv8_ddelegate(type* t, idx_t functypidx); 117 idx_t cv8_daarray(type* t, idx_t keyidx, idx_t validx); 118 119