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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
|
/**
* Contains C++ interfaces for interacting with DMD as a library.
*
* Copyright: Copyright (C) 1999-2024 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/cxxfrontend.d, _cxxfrontend.d)
* Documentation: https://dlang.org/phobos/dmd_cxxfrontend.html
* Coverage: https://codecov.io/gh/dlang/dmd/src/master/src/dmd/cxxfrontend.d
*/
module dmd.cxxfrontend;
import dmd.aggregate : AggregateDeclaration;
import dmd.arraytypes;
import dmd.astenums;
import dmd.common.outbuffer : OutBuffer;
import dmd.denum : EnumDeclaration;
import dmd.dmodule /*: Module*/;
import dmd.dscope : Scope;
import dmd.dstruct /*: StructDeclaration*/;
import dmd.dsymbol : Dsymbol, ScopeDsymbol, CAsmDeclaration, SearchOpt, SearchOptFlags;
import dmd.dtemplate /*: TemplateInstance, TemplateParameter, Tuple*/;
import dmd.errorsink : ErrorSink;
import dmd.expression /*: Expression*/;
import dmd.func : FuncDeclaration;
import dmd.globals;
import dmd.identifier : Identifier;
import dmd.init : Initializer, NeedInterpret;
import dmd.location : Loc;
import dmd.mtype /*: Covariant, Type, Parameter, ParameterList*/;
import dmd.rootobject : RootObject;
import dmd.statement : Statement, AsmStatement, GccAsmStatement;
// NB: At some point in the future, we can switch to shortened function syntax.
extern (C++, "dmd"):
/***********************************************************
* cppmangle.d
*/
const(char)* toCppMangleItanium(Dsymbol s)
{
import dmd.cppmangle;
return dmd.cppmangle.toCppMangleItanium(s);
}
const(char)* cppTypeInfoMangleItanium(Dsymbol s)
{
import dmd.cppmangle;
return dmd.cppmangle.cppTypeInfoMangleItanium(s);
}
const(char)* cppThunkMangleItanium(FuncDeclaration fd, int offset)
{
import dmd.cppmangle;
return dmd.cppmangle.cppThunkMangleItanium(fd, offset);
}
/***********************************************************
* dinterpret.d
*/
Expression ctfeInterpret(Expression e)
{
import dmd.dinterpret;
return dmd.dinterpret.ctfeInterpret(e);
}
/***********************************************************
* dmangle.d
*/
const(char)* mangleExact(FuncDeclaration fd)
{
import dmd.dmangle;
return dmd.dmangle.mangleExact(fd);
}
void mangleToBuffer(Type t, ref OutBuffer buf)
{
import dmd.dmangle;
return dmd.dmangle.mangleToBuffer(t, buf);
}
void mangleToBuffer(Expression e, ref OutBuffer buf)
{
import dmd.dmangle;
return dmd.dmangle.mangleToBuffer(e, buf);
}
void mangleToBuffer(Dsymbol s, ref OutBuffer buf)
{
import dmd.dmangle;
return dmd.dmangle.mangleToBuffer(s, buf);
}
void mangleToBuffer(TemplateInstance ti, ref OutBuffer buf)
{
import dmd.dmangle;
return dmd.dmangle.mangleToBuffer(ti, buf);
}
/***********************************************************
* dmodule.d
*/
void getLocalClasses(Module mod, ref ClassDeclarations aclasses)
{
return dmd.dmodule.getLocalClasses(mod, aclasses);
}
FuncDeclaration findGetMembers(ScopeDsymbol dsym)
{
return dmd.dmodule.findGetMembers(dsym);
}
/***********************************************************
* doc.d
*/
void gendocfile(Module m, const char* ddoctext_ptr, size_t ddoctext_length,
const char* datetime, ErrorSink eSink, ref OutBuffer outbuf)
{
import dmd.doc;
return dmd.doc.gendocfile(m, ddoctext_ptr, ddoctext_length, datetime, eSink, outbuf);
}
/***********************************************************
* dstruct.d
*/
FuncDeclaration search_toString(StructDeclaration sd)
{
return dmd.dstruct.search_toString(sd);
}
/***********************************************************
* dsymbolsem.d
*/
void dsymbolSemantic(Dsymbol dsym, Scope* sc)
{
import dmd.dsymbolsem;
return dmd.dsymbolsem.dsymbolSemantic(dsym, sc);
}
void addMember(Dsymbol dsym, Scope* sc, ScopeDsymbol sds)
{
import dmd.dsymbolsem;
return dmd.dsymbolsem.addMember(dsym, sc, sds);
}
Dsymbol search(Dsymbol d, const ref Loc loc, Identifier ident, SearchOptFlags
flags = SearchOpt.all)
{
import dmd.dsymbolsem;
return dmd.dsymbolsem.search(d, loc, ident, flags);
}
void setScope(Dsymbol d, Scope* sc)
{
import dmd.dsymbolsem;
return dmd.dsymbolsem.setScope(d, sc);
}
void importAll(Dsymbol d, Scope* sc)
{
import dmd.dsymbolsem;
return dmd.dsymbolsem.importAll(d, sc);
}
/***********************************************************
* dtemplate.d
*/
inout(Expression) isExpression(inout RootObject o)
{
return dmd.dtemplate.isExpression(o);
}
inout(Dsymbol) isDsymbol(inout RootObject o)
{
return dmd.dtemplate.isDsymbol(o);
}
inout(Type) isType(inout RootObject o)
{
return dmd.dtemplate.isType(o);
}
inout(Tuple) isTuple(inout RootObject o)
{
return dmd.dtemplate.isTuple(o);
}
inout(Parameter) isParameter(inout RootObject o)
{
return dmd.dtemplate.isParameter(o);
}
inout(TemplateParameter) isTemplateParameter(inout RootObject o)
{
return dmd.dtemplate.isTemplateParameter(o);
}
bool isError(const RootObject o)
{
return dmd.dtemplate.isError(o);
}
void printTemplateStats(bool listInstances, ErrorSink eSink)
{
return dmd.dtemplate.printTemplateStats(listInstances, eSink);
}
/***********************************************************
* dtoh.d
*/
void genCppHdrFiles(ref Modules ms)
{
import dmd.dtoh;
return dmd.dtoh.genCppHdrFiles(ms);
}
/***********************************************************
* enumsem.d
*/
Expression getDefaultValue(EnumDeclaration ed, const ref Loc loc)
{
import dmd.enumsem;
return dmd.enumsem.getDefaultValue(ed, loc);
}
/***********************************************************
* expression.d
*/
void expandTuples(Expressions* exps, Identifiers* names = null)
{
return dmd.expression.expandTuples(exps, names);
}
/***********************************************************
* expressionsem.d
*/
Expression expressionSemantic(Expression e, Scope* sc)
{
import dmd.expressionsem;
return dmd.expressionsem.expressionSemantic(e, sc);
}
/***********************************************************
* funcsem.d
*/
bool functionSemantic(FuncDeclaration fd)
{
import dmd.funcsem;
return dmd.funcsem.functionSemantic(fd);
}
bool functionSemantic3(FuncDeclaration fd)
{
import dmd.funcsem;
return dmd.funcsem.functionSemantic3(fd);
}
/***********************************************************
* hdrgen.d
*/
void genhdrfile(Module m, bool doFuncBodies, ref OutBuffer buf)
{
import dmd.hdrgen;
return dmd.hdrgen.genhdrfile(m, doFuncBodies, buf);
}
const(char)* toChars(const Statement s)
{
import dmd.hdrgen;
return dmd.hdrgen.toChars(s);
}
const(char)* toChars(const Expression e)
{
import dmd.hdrgen;
return dmd.hdrgen.toChars(e);
}
const(char)* toChars(const Initializer i)
{
import dmd.hdrgen;
return dmd.hdrgen.toChars(i);
}
const(char)* toChars(const Type t)
{
import dmd.hdrgen;
return dmd.hdrgen.toChars(t);
}
void moduleToBuffer(ref OutBuffer buf, bool vcg_ast, Module m)
{
import dmd.hdrgen;
return dmd.hdrgen.moduleToBuffer(buf, vcg_ast, m);
}
const(char)* parametersTypeToChars(ParameterList pl)
{
import dmd.hdrgen;
return dmd.hdrgen.parametersTypeToChars(pl);
}
/***********************************************************
* iasm.d
*/
Statement asmSemantic(AsmStatement s, Scope *sc)
{
import dmd.iasm;
return dmd.iasm.asmSemantic(s, sc);
}
void asmSemantic(CAsmDeclaration d, Scope *sc)
{
import dmd.iasm;
return dmd.iasm.asmSemantic(d, sc);
}
/***********************************************************
* iasmgcc.d
*/
Statement gccAsmSemantic(GccAsmStatement s, Scope *sc)
{
import dmd.iasmgcc;
return dmd.iasmgcc.gccAsmSemantic(s, sc);
}
void gccAsmSemantic(CAsmDeclaration d, Scope *sc)
{
import dmd.iasmgcc;
return dmd.iasmgcc.gccAsmSemantic(d, sc);
}
/***********************************************************
* initsem.d
*/
Initializer initializerSemantic(Initializer init, Scope* sc, ref Type tx,
NeedInterpret needInterpret)
{
import dmd.initsem;
return dmd.initsem.initializerSemantic(init, sc, tx, needInterpret);
}
Expression initializerToExpression(Initializer init, Type itype = null, const
bool isCfile = false)
{
import dmd.initsem;
return dmd.initsem.initializerToExpression(init, itype, isCfile);
}
/***********************************************************
* json.d
*/
void json_generate(ref Modules modules, ref OutBuffer buf)
{
import dmd.json;
return dmd.json.json_generate(modules, buf);
}
JsonFieldFlags tryParseJsonField(const(char)* fieldName)
{
import dmd.json;
return dmd.json.tryParseJsonField(fieldName);
}
/***********************************************************
* mtype.d
*/
AggregateDeclaration isAggregate(Type t)
{
return dmd.mtype.isAggregate(t);
}
/***********************************************************
* optimize.d
*/
Expression optimize(Expression e, int result, bool keepLvalue = false)
{
import dmd.optimize;
return dmd.optimize.optimize(e, result, keepLvalue);
}
/***********************************************************
* semantic2.d
*/
void semantic2(Dsymbol dsym, Scope* sc)
{
import dmd.semantic2;
return dmd.semantic2.semantic2(dsym, sc);
}
/***********************************************************
* semantic3.d
*/
void semantic3(Dsymbol dsym, Scope* sc)
{
import dmd.semantic3;
return dmd.semantic3.semantic3(dsym, sc);
}
void semanticTypeInfoMembers(StructDeclaration sd)
{
import dmd.semantic3;
return dmd.semantic3.semanticTypeInfoMembers(sd);
}
/***********************************************************
* statementsem.d
*/
Statement statementSemantic(Statement s, Scope* sc)
{
import dmd.statementsem;
return dmd.statementsem.statementSemantic(s, sc);
}
/***********************************************************
* templateparamsem.d
*/
bool tpsemantic(TemplateParameter tp, Scope* sc, TemplateParameters* parameters)
{
import dmd.templateparamsem;
return dmd.templateparamsem.tpsemantic(tp, sc, parameters);
}
/***********************************************************
* typesem.d
*/
bool hasPointers(Type t)
{
import dmd.typesem;
return dmd.typesem.hasPointers(t);
}
Type typeSemantic(Type type, const ref Loc loc, Scope* sc)
{
import dmd.typesem;
return dmd.typesem.typeSemantic(type, loc, sc);
}
Type trySemantic(Type type, const ref Loc loc, Scope* sc)
{
import dmd.typesem;
return dmd.typesem.trySemantic(type, loc, sc);
}
Type merge(Type type)
{
import dmd.typesem;
return dmd.typesem.merge(type);
}
Type merge2(Type type)
{
import dmd.typesem;
return dmd.typesem.merge2(type);
}
Expression defaultInit(Type mt, const ref Loc loc, const bool isCfile = false)
{
import dmd.typesem;
return dmd.typesem.defaultInit(mt, loc, isCfile);
}
Dsymbol toDsymbol(Type type, Scope* sc)
{
import dmd.typesem;
return dmd.typesem.toDsymbol(type, sc);
}
Covariant covariant(Type src, Type t, StorageClass* pstc = null, bool
cppCovariant = false)
{
import dmd.typesem;
return dmd.typesem.covariant(src, t, pstc, cppCovariant);
}
bool isBaseOf(Type tthis, Type t, int* poffset)
{
import dmd.typesem;
return dmd.typesem.isBaseOf(tthis, t, poffset);
}
bool equivalent(Type src, Type t)
{
import dmd.typesem;
return dmd.typesem.equivalent(src, t);
}
Type sarrayOf(Type type, dinteger_t dim)
{
import dmd.typesem;
return dmd.typesem.sarrayOf(type, dim);
}
Type arrayOf(Type type)
{
import dmd.typesem;
return dmd.typesem.arrayOf(type);
}
Type constOf(Type type)
{
import dmd.typesem;
return dmd.typesem.constOf(type);
}
Type immutableOf(Type type)
{
import dmd.typesem;
return dmd.typesem.immutableOf(type);
}
Type mutableOf(Type type)
{
import dmd.typesem;
return dmd.typesem.mutableOf(type);
}
Type sharedOf(Type type)
{
import dmd.typesem;
return dmd.typesem.sharedOf(type);
}
Type sharedConstOf(Type type)
{
import dmd.typesem;
return dmd.typesem.sharedConstOf(type);
}
Type unSharedOf(Type type)
{
import dmd.typesem;
return dmd.typesem.unSharedOf(type);
}
Type wildOf(Type type)
{
import dmd.typesem;
return dmd.typesem.wildOf(type);
}
Type wildConstOf(Type type)
{
import dmd.typesem;
return dmd.typesem.wildConstOf(type);
}
Type sharedWildOf(Type type)
{
import dmd.typesem;
return dmd.typesem.sharedWildOf(type);
}
Type sharedWildConstOf(Type type)
{
import dmd.typesem;
return dmd.typesem.sharedWildConstOf(type);
}
Type substWildTo(Type type, uint mod)
{
import dmd.typesem;
return dmd.typesem.substWildTo(type, mod);
}
Type unqualify(Type type, uint m)
{
import dmd.typesem;
return dmd.typesem.unqualify(type, m);
}
Type toHeadMutable(const(Type) type)
{
import dmd.typesem;
return dmd.typesem.toHeadMutable(type);
}
Type aliasthisOf(Type type)
{
import dmd.typesem;
return dmd.typesem.aliasthisOf(type);
}
Type castMod(Type type, MOD mod)
{
import dmd.typesem;
return dmd.typesem.castMod(type, mod);
}
Type addMod(Type type, MOD mod)
{
import dmd.typesem;
return dmd.typesem.addMod(type, mod);
}
Type addStorageClass(Type type, StorageClass stc)
{
import dmd.typesem;
return dmd.typesem.addStorageClass(type, stc);
}
Type pointerTo(Type type)
{
import dmd.typesem;
return dmd.typesem.pointerTo(type);
}
Type referenceTo(Type type)
{
import dmd.typesem;
return dmd.typesem.referenceTo(type);
}
/***********************************************************
* typinf.d
*/
bool genTypeInfo(Expression e, const ref Loc loc, Type torig, Scope* sc)
{
import dmd.typinf;
return dmd.typinf.genTypeInfo(e, loc, torig, sc);
}
bool isSpeculativeType(Type t)
{
import dmd.typinf;
return dmd.typinf.isSpeculativeType(t);
}
bool builtinTypeInfo(Type t)
{
import dmd.typinf;
return dmd.typinf.builtinTypeInfo(t);
}
version (IN_LLVM)
{
/***********************************************************
* argtypes_aarch64.d
*/
TypeTuple toArgTypes_aarch64(Type t)
{
import dmd.argtypes_aarch64;
return dmd.argtypes_aarch64.toArgTypes_aarch64(t);
}
bool isHFVA(Type t, int maxNumElements = 4, Type* rewriteType = null)
{
import dmd.argtypes_aarch64;
return dmd.argtypes_aarch64.isHFVA(t, maxNumElements, rewriteType);
}
/***********************************************************
* argtypes_sysv_x64.d
*/
TypeTuple toArgTypes_sysv_x64(Type t)
{
import dmd.argtypes_sysv_x64;
return dmd.argtypes_sysv_x64.toArgTypes_sysv_x64(t);
}
/***********************************************************
* argtypes_x86.d
*/
TypeTuple toArgTypes_x86(Type t)
{
import dmd.argtypes_x86;
return dmd.argtypes_x86.toArgTypes_x86(t);
}
}
|