d: Merge upstream dmd, druntime 4c18eed967, phobos d945686a4.
[official-gcc.git] / gcc / d / dmd / json.d
blobf1999fd458d3b800e1940e57319a1d2ad14f2efb
1 /**
2 * Code for generating .json descriptions of the module when passing the `-X` flag to dmd.
4 * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
5 * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright)
6 * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
7 * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/json.d, _json.d)
8 * Documentation: https://dlang.org/phobos/dmd_json.html
9 * Coverage: https://codecov.io/gh/dlang/dmd/src/master/src/dmd/json.d
12 module dmd.json;
14 import core.stdc.stdio;
15 import core.stdc.string;
16 import dmd.aggregate;
17 import dmd.arraytypes;
18 import dmd.astenums;
19 import dmd.attrib;
20 import dmd.cond;
21 import dmd.dclass;
22 import dmd.declaration;
23 import dmd.denum;
24 import dmd.dimport;
25 import dmd.dmodule;
26 import dmd.dsymbol;
27 import dmd.dtemplate;
28 import dmd.errors;
29 import dmd.expression;
30 import dmd.func;
31 import dmd.globals;
32 import dmd.hdrgen;
33 import dmd.id;
34 import dmd.identifier;
35 import dmd.location;
36 import dmd.mtype;
37 import dmd.common.outbuffer;
38 import dmd.root.rootobject;
39 import dmd.root.string;
40 import dmd.target;
41 import dmd.visitor;
43 version(Windows) {
44 extern (C) char* getcwd(char* buffer, size_t maxlen);
45 } else {
46 import core.sys.posix.unistd : getcwd;
49 private extern (C++) final class ToJsonVisitor : Visitor
51 alias visit = Visitor.visit;
52 public:
53 OutBuffer* buf;
54 int indentLevel;
55 const(char)[] filename;
57 extern (D) this(OutBuffer* buf) scope @safe
59 this.buf = buf;
63 void indent()
65 if (buf.length >= 1 && (*buf)[buf.length - 1] == '\n')
66 for (int i = 0; i < indentLevel; i++)
67 buf.writeByte(' ');
70 void removeComma()
72 if (buf.length >= 2 && (*buf)[buf.length - 2] == ',' && ((*buf)[buf.length - 1] == '\n' || (*buf)[buf.length - 1] == ' '))
73 buf.setsize(buf.length - 2);
76 void comma()
78 if (indentLevel > 0)
79 buf.writestring(",\n");
82 void stringStart()
84 buf.writeByte('\"');
87 void stringEnd()
89 buf.writeByte('\"');
92 extern(D) void stringPart(const char[] s)
94 foreach (char c; s)
96 switch (c)
98 case '\n':
99 buf.writestring("\\n");
100 break;
101 case '\r':
102 buf.writestring("\\r");
103 break;
104 case '\t':
105 buf.writestring("\\t");
106 break;
107 case '\"':
108 buf.writestring("\\\"");
109 break;
110 case '\\':
111 buf.writestring("\\\\");
112 break;
113 case '\b':
114 buf.writestring("\\b");
115 break;
116 case '\f':
117 buf.writestring("\\f");
118 break;
119 default:
120 if (c < 0x20)
121 buf.printf("\\u%04x", c);
122 else
124 // Note that UTF-8 chars pass through here just fine
125 buf.writeByte(c);
127 break;
132 // Json value functions
133 /*********************************
134 * Encode string into buf, and wrap it in double quotes.
136 extern(D) void value(const char[] s)
138 stringStart();
139 stringPart(s);
140 stringEnd();
143 void value(int value)
145 if (value < 0)
147 buf.writeByte('-');
148 value = -value;
150 buf.print(value);
153 void valueBool(bool value)
155 buf.writestring(value ? "true" : "false");
158 /*********************************
159 * Item is an intented value and a comma, for use in arrays
161 extern(D) void item(const char[] s)
163 indent();
164 value(s);
165 comma();
168 void item(int i)
170 indent();
171 value(i);
172 comma();
175 void itemBool(const bool b)
177 indent();
178 valueBool(b);
179 comma();
182 // Json array functions
183 void arrayStart()
185 indent();
186 buf.writestring("[\n");
187 indentLevel++;
190 void arrayEnd()
192 indentLevel--;
193 removeComma();
194 if (buf.length >= 2 && (*buf)[buf.length - 2] == '[' && (*buf)[buf.length - 1] == '\n')
195 buf.setsize(buf.length - 1);
196 else if (!(buf.length >= 1 && (*buf)[buf.length - 1] == '['))
198 buf.writestring("\n");
199 indent();
201 buf.writestring("]");
202 comma();
205 // Json object functions
206 void objectStart()
208 indent();
209 buf.writestring("{\n");
210 indentLevel++;
213 void objectEnd()
215 indentLevel--;
216 removeComma();
217 if (buf.length >= 2 && (*buf)[buf.length - 2] == '{' && (*buf)[buf.length - 1] == '\n')
218 buf.setsize(buf.length - 1);
219 else
221 buf.writestring("\n");
222 indent();
224 buf.writestring("}");
225 comma();
228 // Json object property functions
229 extern(D) void propertyStart(const char[] name)
231 indent();
232 value(name);
233 buf.writestring(" : ");
237 Write the given string object property only if `s` is not null.
239 Params:
240 name = the name of the object property
241 s = the string value of the object property
243 extern(D) void property(const char[] name, const char[] s)
245 if (s is null)
246 return;
247 propertyStart(name);
248 value(s);
249 comma();
253 Write the given string object property.
255 Params:
256 name = the name of the object property
257 s = the string value of the object property
259 extern(D) void requiredProperty(const char[] name, const char[] s)
261 propertyStart(name);
262 if (s is null)
263 buf.writestring("null");
264 else
265 value(s);
266 comma();
269 extern(D) void property(const char[] name, int i)
271 propertyStart(name);
272 value(i);
273 comma();
276 extern(D) void propertyBool(const char[] name, const bool b)
278 propertyStart(name);
279 valueBool(b);
280 comma();
283 extern(D) void property(const char[] name, TRUST trust)
285 final switch (trust)
287 case TRUST.default_:
288 // Should not be printed
289 //property(name, "default");
290 break;
291 case TRUST.system: return property(name, "system");
292 case TRUST.trusted: return property(name, "trusted");
293 case TRUST.safe: return property(name, "safe");
297 extern(D) void property(const char[] name, PURE purity)
299 final switch (purity)
301 case PURE.impure:
302 // Should not be printed
303 //property(name, "impure");
304 break;
305 case PURE.weak: return property(name, "weak");
306 case PURE.const_: return property(name, "strong");
307 case PURE.fwdref: return property(name, "fwdref");
311 extern(D) void property(const char[] name, const LINK linkage)
313 final switch (linkage)
315 case LINK.default_:
316 // Should not be printed
317 //property(name, "default");
318 break;
319 case LINK.d:
320 // Should not be printed
321 //property(name, "d");
322 break;
323 case LINK.system: return property(name, "system");
324 case LINK.c: return property(name, "c");
325 case LINK.cpp: return property(name, "cpp");
326 case LINK.windows: return property(name, "windows");
327 case LINK.objc: return property(name, "objc");
331 extern(D) void propertyStorageClass(const char[] name, StorageClass stc)
333 stc &= STC.visibleStorageClasses;
334 if (stc)
336 propertyStart(name);
337 arrayStart();
338 while (stc)
340 auto p = stcToString(stc);
341 assert(p.length);
342 item(p);
344 arrayEnd();
348 extern(D) void property(const char[] linename, const char[] charname, const ref Loc loc)
350 if (loc.isValid())
352 if (auto filename = loc.filename.toDString)
354 if (filename != this.filename)
356 this.filename = filename;
357 property("file", filename);
360 if (loc.linnum)
362 property(linename, loc.linnum);
363 if (loc.charnum)
364 property(charname, loc.charnum);
369 extern(D) void property(const char[] name, Type type)
371 if (type)
373 property(name, type.toString());
377 extern(D) void property(const char[] name, const char[] deconame, Type type)
379 if (type)
381 if (type.deco)
382 property(deconame, type.deco.toDString);
383 else
384 property(name, type.toString());
388 extern(D) void property(const char[] name, Parameters* parameters)
390 if (parameters is null || parameters.length == 0)
391 return;
392 propertyStart(name);
393 arrayStart();
394 if (parameters)
396 for (size_t i = 0; i < parameters.length; i++)
398 Parameter p = (*parameters)[i];
399 objectStart();
400 if (p.ident)
401 property("name", p.ident.toString());
402 property("type", "deco", p.type);
403 propertyStorageClass("storageClass", p.storageClass);
404 if (p.defaultArg)
405 property("default", p.defaultArg.toString());
406 objectEnd();
409 arrayEnd();
412 /* ========================================================================== */
413 void jsonProperties(Dsymbol s)
415 if (s.isModule())
416 return;
417 if (!s.isTemplateDeclaration()) // TemplateDeclaration::kind() acts weird sometimes
419 property("name", s.toString());
420 if (s.isStaticCtorDeclaration())
422 property("kind", s.isSharedStaticCtorDeclaration()
423 ? "shared static constructor" : "static constructor");
425 else if (s.isStaticDtorDeclaration())
427 property("kind", s.isSharedStaticDtorDeclaration()
428 ? "shared static destructor" : "static destructor");
430 else
431 property("kind", s.kind.toDString);
433 // TODO: How about package(names)?
434 property("protection", visibilityToString(s.visible().kind));
435 if (EnumMember em = s.isEnumMember())
437 if (em.origValue)
438 property("value", em.origValue.toString());
440 property("comment", s.comment.toDString);
441 property("line", "char", s.loc);
444 void jsonProperties(Declaration d)
446 if (d.storage_class & STC.local)
447 return;
448 jsonProperties(cast(Dsymbol)d);
449 propertyStorageClass("storageClass", d.storage_class);
450 property("linkage", d._linkage);
451 property("type", "deco", d.type);
452 // Emit originalType if it differs from type
453 if (d.type != d.originalType && d.originalType)
455 auto ostr = d.originalType.toString();
456 if (d.type)
458 auto tstr = d.type.toString();
459 if (ostr != tstr)
461 //printf("tstr = %s, ostr = %s\n", tstr, ostr);
462 property("originalType", ostr);
465 else
466 property("originalType", ostr);
470 void jsonProperties(TemplateDeclaration td)
472 jsonProperties(cast(Dsymbol)td);
473 if (td.onemember && td.onemember.isCtorDeclaration())
474 property("name", "this"); // __ctor -> this
475 else
476 property("name", td.ident.toString()); // Foo(T) -> Foo
479 /* ========================================================================== */
480 override void visit(Dsymbol s)
484 override void visit(Module s)
486 objectStart();
487 if (s.md)
488 property("name", s.md.toString());
489 property("kind", s.kind.toDString);
490 filename = s.srcfile.toString();
491 property("file", filename);
492 property("comment", s.comment.toDString);
493 propertyStart("members");
494 arrayStart();
495 for (size_t i = 0; i < s.members.length; i++)
497 (*s.members)[i].accept(this);
499 arrayEnd();
500 objectEnd();
503 override void visit(Import s)
505 if (s.id == Id.object)
506 return;
507 objectStart();
508 propertyStart("name");
509 stringStart();
510 foreach (const pid; s.packages){
511 stringPart(pid.toString());
512 buf.writeByte('.');
514 stringPart(s.id.toString());
515 stringEnd();
516 comma();
517 property("kind", s.kind.toDString);
518 property("comment", s.comment.toDString);
519 property("line", "char", s.loc);
520 if (s.visible().kind != Visibility.Kind.public_)
521 property("protection", visibilityToString(s.visible().kind));
522 if (s.aliasId)
523 property("alias", s.aliasId.toString());
524 bool hasRenamed = false;
525 bool hasSelective = false;
526 for (size_t i = 0; i < s.aliases.length; i++)
528 // avoid empty "renamed" and "selective" sections
529 if (hasRenamed && hasSelective)
530 break;
531 else if (s.aliases[i])
532 hasRenamed = true;
533 else
534 hasSelective = true;
536 if (hasRenamed)
538 // import foo : alias1 = target1;
539 propertyStart("renamed");
540 objectStart();
541 for (size_t i = 0; i < s.aliases.length; i++)
543 const name = s.names[i];
544 const _alias = s.aliases[i];
545 if (_alias)
546 property(_alias.toString(), name.toString());
548 objectEnd();
550 if (hasSelective)
552 // import foo : target1;
553 propertyStart("selective");
554 arrayStart();
555 foreach (i, name; s.names)
557 if (!s.aliases[i])
558 item(name.toString());
560 arrayEnd();
562 objectEnd();
565 override void visit(AttribDeclaration d)
567 Dsymbols* ds = d.include(null);
568 if (ds)
570 for (size_t i = 0; i < ds.length; i++)
572 Dsymbol s = (*ds)[i];
573 s.accept(this);
578 override void visit(ConditionalDeclaration d)
580 if (d.condition.inc != Include.notComputed)
582 visit(cast(AttribDeclaration)d);
583 return; // Don't visit the if/else bodies again below
585 Dsymbols* ds = d.decl ? d.decl : d.elsedecl;
586 for (size_t i = 0; i < ds.length; i++)
588 Dsymbol s = (*ds)[i];
589 s.accept(this);
593 override void visit(TypeInfoDeclaration d)
597 override void visit(PostBlitDeclaration d)
601 override void visit(Declaration d)
603 objectStart();
604 //property("unknown", "declaration");
605 jsonProperties(d);
606 objectEnd();
609 override void visit(AggregateDeclaration d)
611 objectStart();
612 jsonProperties(d);
613 ClassDeclaration cd = d.isClassDeclaration();
614 if (cd)
616 if (cd.baseClass && cd.baseClass.ident != Id.Object)
618 property("base", cd.baseClass.toPrettyChars(true).toDString);
620 if (cd.interfaces.length)
622 propertyStart("interfaces");
623 arrayStart();
624 foreach (b; cd.interfaces)
626 item(b.sym.toPrettyChars(true).toDString);
628 arrayEnd();
631 if (d.members)
633 propertyStart("members");
634 arrayStart();
635 for (size_t i = 0; i < d.members.length; i++)
637 Dsymbol s = (*d.members)[i];
638 s.accept(this);
640 arrayEnd();
642 objectEnd();
645 override void visit(FuncDeclaration d)
647 objectStart();
648 jsonProperties(d);
649 TypeFunction tf = cast(TypeFunction)d.type;
650 if (tf && tf.ty == Tfunction)
651 property("parameters", tf.parameterList.parameters);
652 property("endline", "endchar", d.endloc);
653 if (d.foverrides.length)
655 propertyStart("overrides");
656 arrayStart();
657 for (size_t i = 0; i < d.foverrides.length; i++)
659 FuncDeclaration fd = d.foverrides[i];
660 item(fd.toPrettyChars().toDString);
662 arrayEnd();
664 if (d.fdrequire)
666 propertyStart("in");
667 d.fdrequire.accept(this);
669 if (d.fdensure)
671 propertyStart("out");
672 d.fdensure.accept(this);
674 objectEnd();
677 override void visit(TemplateDeclaration d)
679 objectStart();
680 // TemplateDeclaration::kind returns the kind of its Aggregate onemember, if it is one
681 property("kind", "template");
682 jsonProperties(d);
683 propertyStart("parameters");
684 arrayStart();
685 for (size_t i = 0; i < d.parameters.length; i++)
687 TemplateParameter s = (*d.parameters)[i];
688 objectStart();
689 property("name", s.ident.toString());
691 if (auto type = s.isTemplateTypeParameter())
693 if (s.isTemplateThisParameter())
694 property("kind", "this");
695 else
696 property("kind", "type");
697 property("type", "deco", type.specType);
698 property("default", "defaultDeco", type.defaultType);
701 if (auto value = s.isTemplateValueParameter())
703 property("kind", "value");
704 property("type", "deco", value.valType);
705 if (value.specValue)
706 property("specValue", value.specValue.toString());
707 if (value.defaultValue)
708 property("defaultValue", value.defaultValue.toString());
711 if (auto _alias = s.isTemplateAliasParameter())
713 property("kind", "alias");
714 property("type", "deco", _alias.specType);
715 if (_alias.specAlias)
716 property("specAlias", _alias.specAlias.toString());
717 if (_alias.defaultAlias)
718 property("defaultAlias", _alias.defaultAlias.toString());
721 if (auto tuple = s.isTemplateTupleParameter())
723 property("kind", "tuple");
726 objectEnd();
728 arrayEnd();
729 Expression expression = d.constraint;
730 if (expression)
732 property("constraint", expression.toString());
734 propertyStart("members");
735 arrayStart();
736 for (size_t i = 0; i < d.members.length; i++)
738 Dsymbol s = (*d.members)[i];
739 s.accept(this);
741 arrayEnd();
742 objectEnd();
745 override void visit(EnumDeclaration d)
747 if (d.isAnonymous())
749 if (d.members)
751 for (size_t i = 0; i < d.members.length; i++)
753 Dsymbol s = (*d.members)[i];
754 s.accept(this);
757 return;
759 objectStart();
760 jsonProperties(d);
761 property("base", "baseDeco", d.memtype);
762 if (d.members)
764 propertyStart("members");
765 arrayStart();
766 for (size_t i = 0; i < d.members.length; i++)
768 Dsymbol s = (*d.members)[i];
769 s.accept(this);
771 arrayEnd();
773 objectEnd();
776 override void visit(EnumMember s)
778 objectStart();
779 jsonProperties(cast(Dsymbol)s);
780 property("type", "deco", s.origType);
781 objectEnd();
784 override void visit(VarDeclaration d)
786 if (d.storage_class & STC.local)
787 return;
788 objectStart();
789 jsonProperties(d);
790 if (d._init)
791 property("init", toString(d._init));
792 if (d.isField())
793 property("offset", d.offset);
794 if (!d.alignment.isUnknown() && !d.alignment.isDefault())
795 property("align", d.alignment.get());
796 objectEnd();
799 override void visit(TemplateMixin d)
801 objectStart();
802 jsonProperties(d);
803 objectEnd();
807 Generate an array of module objects that represent the syntax of each
808 "root module".
810 Params:
811 modules = array of the "root modules"
813 private void generateModules(ref Modules modules)
815 arrayStart();
816 foreach (m; modules)
818 if (global.params.v.verbose)
819 message("json gen %s", m.toChars());
820 m.accept(this);
822 arrayEnd();
826 Generate the "compilerInfo" object which contains information about the compiler
827 such as the filename, version, supported features, etc.
829 private void generateCompilerInfo()
831 import dmd.target : target;
832 objectStart();
833 requiredProperty("vendor", global.compileEnv.vendor);
834 requiredProperty("version", global.versionString());
835 property("__VERSION__", global.versionNumber());
836 requiredProperty("interface", determineCompilerInterface());
837 property("size_t", size_t.sizeof);
838 propertyStart("platforms");
839 arrayStart();
840 if (target.os == Target.OS.Windows)
842 item("windows");
844 else
846 item("posix");
847 if (target.os == Target.OS.linux)
848 item("linux");
849 else if (target.os == Target.OS.OSX)
850 item("osx");
851 else if (target.os == Target.OS.FreeBSD)
853 item("freebsd");
854 item("bsd");
856 else if (target.os == Target.OS.OpenBSD)
858 item("openbsd");
859 item("bsd");
861 else if (target.os == Target.OS.Solaris)
863 item("solaris");
864 item("bsd");
867 arrayEnd();
869 propertyStart("architectures");
870 arrayStart();
871 item(target.architectureName);
872 arrayEnd();
874 propertyStart("predefinedVersions");
875 arrayStart();
876 if (global.versionids)
878 foreach (const versionid; *global.versionids)
880 item(versionid.toString());
883 arrayEnd();
885 propertyStart("supportedFeatures");
887 objectStart();
888 scope(exit) objectEnd();
889 propertyBool("includeImports", true);
891 objectEnd();
895 Generate the "buildInfo" object which contains information specific to the
896 current build such as CWD, importPaths, configFile, etc.
898 private void generateBuildInfo()
900 objectStart();
901 requiredProperty("cwd", getcwd(null, 0).toDString);
902 requiredProperty("argv0", global.params.argv0);
903 requiredProperty("config", global.inifilename);
904 requiredProperty("libName", global.params.libname);
906 propertyStart("importPaths");
907 arrayStart();
908 if (global.params.imppath)
910 foreach (importPath; *global.params.imppath)
912 item(importPath.toDString);
915 arrayEnd();
917 propertyStart("objectFiles");
918 arrayStart();
919 foreach (objfile; global.params.objfiles)
921 item(objfile.toDString);
923 arrayEnd();
925 propertyStart("libraryFiles");
926 arrayStart();
927 foreach (lib; global.params.libfiles)
929 item(lib.toDString);
931 arrayEnd();
933 propertyStart("ddocFiles");
934 arrayStart();
935 foreach (ddocFile; global.params.ddoc.files)
937 item(ddocFile.toDString);
939 arrayEnd();
941 requiredProperty("mapFile", global.params.mapfile);
942 requiredProperty("resourceFile", global.params.resfile);
943 requiredProperty("defFile", global.params.deffile);
945 objectEnd();
949 Generate the "semantics" object which contains a 'modules' field representing
950 semantic information about all the modules used in the compilation such as
951 module name, isRoot, contentImportedFiles, etc.
953 private void generateSemantics()
955 objectStart();
956 propertyStart("modules");
957 arrayStart();
958 foreach (m; Module.amodules)
960 objectStart();
961 requiredProperty("name", m.md ? m.md.toString() : null);
962 requiredProperty("file", m.srcfile.toString());
963 propertyBool("isRoot", m.isRoot());
964 if(m.contentImportedFiles.length > 0)
966 propertyStart("contentImports");
967 arrayStart();
968 foreach (file; m.contentImportedFiles)
970 item(file.toDString);
972 arrayEnd();
974 objectEnd();
976 arrayEnd();
977 objectEnd();
981 /***********************************
982 * Generate json for the modules.
983 * Params:
984 * modules = array of Modules
985 * buf = write json output to buf
987 extern (C++) void json_generate(ref Modules modules, ref OutBuffer buf)
989 scope ToJsonVisitor json = new ToJsonVisitor(&buf);
990 // write trailing newline
991 scope(exit) buf.writeByte('\n');
993 if (global.params.jsonFieldFlags == 0)
995 // Generate the original format, which is just an array
996 // of modules representing their syntax.
997 json.generateModules(modules);
998 json.removeComma();
1000 else
1002 // Generate the new format which is an object where each
1003 // output option is its own field.
1005 json.objectStart();
1006 if (global.params.jsonFieldFlags & JsonFieldFlags.compilerInfo)
1008 json.propertyStart("compilerInfo");
1009 json.generateCompilerInfo();
1011 if (global.params.jsonFieldFlags & JsonFieldFlags.buildInfo)
1013 json.propertyStart("buildInfo");
1014 json.generateBuildInfo();
1016 if (global.params.jsonFieldFlags & JsonFieldFlags.modules)
1018 json.propertyStart("modules");
1019 json.generateModules(modules);
1021 if (global.params.jsonFieldFlags & JsonFieldFlags.semantics)
1023 json.propertyStart("semantics");
1024 json.generateSemantics();
1026 json.objectEnd();
1031 A string listing the name of each JSON field. Useful for errors messages.
1033 enum jsonFieldNames = () {
1034 string s;
1035 string prefix = "";
1036 foreach (idx, enumName; __traits(allMembers, JsonFieldFlags))
1038 static if (idx > 0)
1040 s ~= prefix ~ "`" ~ enumName ~ "`";
1041 prefix = ", ";
1044 return s;
1045 }();
1048 Parse the given `fieldName` and return its corresponding JsonFieldFlags value.
1050 Params:
1051 fieldName = the field name to parse
1053 Returns: JsonFieldFlags.none on error, otherwise the JsonFieldFlags value
1054 corresponding to the given fieldName.
1056 extern (C++) JsonFieldFlags tryParseJsonField(const(char)* fieldName)
1058 auto fieldNameString = fieldName.toDString();
1059 foreach (idx, enumName; __traits(allMembers, JsonFieldFlags))
1061 static if (idx > 0)
1063 if (fieldNameString == enumName)
1064 return __traits(getMember, JsonFieldFlags, enumName);
1067 return JsonFieldFlags.none;
1071 Determines and returns the compiler interface which is one of `dmd`, `ldc`,
1072 `gdc` or `sdc`. Returns `null` if no interface can be determined.
1074 private extern(D) string determineCompilerInterface()
1076 if (global.compileEnv.vendor == "Digital Mars D")
1077 return "dmd";
1078 if (global.compileEnv.vendor == "LDC")
1079 return "ldc";
1080 if (global.compileEnv.vendor == "GNU D")
1081 return "gdc";
1082 if (global.compileEnv.vendor == "SDC")
1083 return "sdc";
1084 return null;