Skip to content

Commit

Permalink
remove errors.d from mars.d (#16565)
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright authored Jun 6, 2024
1 parent 2060b8e commit 2df43f9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
6 changes: 4 additions & 2 deletions compiler/src/dmd/main.d
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@ private int tryMain(size_t argc, const(char)** argv, ref Param params)
if (params.jsonFieldFlags)
{
Modules modules; // empty
generateJson(modules);
if (generateJson(modules, global.errorSink))
fatal();
return EXIT_SUCCESS;
}
usage();
Expand Down Expand Up @@ -625,7 +626,8 @@ private int tryMain(size_t argc, const(char)** argv, ref Param params)
// Generate output files
if (params.json.doOutput)
{
generateJson(modules);
if (generateJson(modules, global.errorSink))
fatal();
}
if (!global.errors && params.ddoc.doOutput)
{
Expand Down
19 changes: 14 additions & 5 deletions compiler/src/dmd/mars.d
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,15 @@ Where:
%.*s", cast(int)inifileCanon.length, inifileCanon.ptr, cast(int)help.length, &help[0]);
}

extern (C++) void generateJson(ref Modules modules)
/*******************************************
* Generate JSON file.
* Params:
* modules = Modules
* eSink = error message sink
* Returns:
* true on error
*/
extern (C++) bool generateJson(ref Modules modules, ErrorSink eSink)
{
OutBuffer buf;
json_generate(modules, buf);
Expand All @@ -144,8 +152,8 @@ extern (C++) void generateJson(ref Modules modules)
{
if (global.params.objfiles.length == 0)
{
error(Loc.initial, "cannot determine JSON filename, use `-Xf=<file>` or provide a source file");
fatal();
eSink.error(Loc.initial, "cannot determine JSON filename, use `-Xf=<file>` or provide a source file");
return true;
}
// Generate json file name from first obj name
const(char)[] n = global.params.objfiles[0].toDString;
Expand All @@ -155,8 +163,9 @@ extern (C++) void generateJson(ref Modules modules)
jsonfilename = FileName.forceExt(n, json_ext);
}
if (!writeFile(Loc.initial, jsonfilename, buf[]))
fatal();
return true;
}
return false;
}

version (DigitalMars)
Expand Down Expand Up @@ -1579,7 +1588,7 @@ bool parseCommandLine(const ref Strings arguments, const size_t argc, ref Param

// @@@DEPRECATED_2.111@@@
// Deprecated in 2.101, remove in 2.111
deprecation(Loc.initial, "`-version=number` is deprecated, use version identifiers instead");
eSink.deprecation(Loc.initial, "`-version=number` is deprecated, use version identifiers instead");
}
else if (Identifier.isValidIdentifier(p + 9))
{
Expand Down

0 comments on commit 2df43f9

Please sign in to comment.