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