Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 0 additions & 43 deletions compiler/src/dmd/dsymbolsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -7632,49 +7632,6 @@ bool determineFields(AggregateDeclaration ad)
return true;
}

/****************************
* A Singleton that loads core.stdc.config
* Returns:
* Module of core.stdc.config, null if couldn't find it
*/
Module loadCoreStdcConfig()
{
__gshared Module core_stdc_config;
auto pkgids = new Identifier[2];
pkgids[0] = Id.core;
pkgids[1] = Id.stdc;
return loadModuleFromLibrary(core_stdc_config, pkgids, Id.config);
}

/**********************************
* Load a Module from the library.
* Params:
* mod = cached return value of this call
* pkgids = package identifiers
* modid = module id
* Returns:
* Module loaded, null if cannot load it
*/
extern (D) private static Module loadModuleFromLibrary(ref Module mod, Identifier[] pkgids, Identifier modid)
{
if (mod)
return mod;

auto imp = new Import(Loc.initial, pkgids[], modid, null, true);
// Module.load will call fatal() if there's no module available.
// Gag the error here, pushing the error handling to the caller.
const errors = global.startGagging();
imp.load(null);
if (imp.mod)
{
imp.mod.importAll(null);
imp.mod.dsymbolSemantic(null);
}
global.endGagging(errors);
mod = imp.mod;
return mod;
}

/// Do an atomic operation (currently tailored to [shared] static ctors|dtors) needs
private CallExp doAtomicOp(string op, Identifier var, Expression arg, Scope* sc)
{
Expand Down
4 changes: 0 additions & 4 deletions compiler/src/dmd/id.d
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,6 @@ immutable Msgtable[] msgtable =
{ "std" },
{ "core" },
{ "internal" },
{ "config" },
{ "c_complex_float" },
{ "c_complex_double" },
{ "c_complex_real" },
{ "etc" },
{ "attribute" },
{ "atomic" },
Expand Down
69 changes: 0 additions & 69 deletions compiler/src/dmd/typesem.d
Original file line number Diff line number Diff line change
Expand Up @@ -7983,75 +7983,6 @@ Type addStorageClass(Type type, STC stc)
}
}

/**********************************************
* Extract complex type from core.stdc.config
* Params:
* loc = for error messages
* sc = context
* ty = a complex or imaginary type
* Returns:
* Complex!float, Complex!double, Complex!real or null for error
*/

Type getComplexLibraryType(Loc loc, Scope* sc, TY ty)
{
// singleton
__gshared Type complex_float;
__gshared Type complex_double;
__gshared Type complex_real;

Type* pt;
Identifier id;
switch (ty)
{
case Timaginary32:
case Tcomplex32: id = Id.c_complex_float; pt = &complex_float; break;
case Timaginary64:
case Tcomplex64: id = Id.c_complex_double; pt = &complex_double; break;
case Timaginary80:
case Tcomplex80: id = Id.c_complex_real; pt = &complex_real; break;
default:
return Type.terror;
}

if (*pt)
return *pt;
*pt = Type.terror;

auto eSink = global.errorSink;

Module mConfig = loadCoreStdcConfig();
if (!mConfig)
{
eSink.error(loc, "`core.stdc.config` is required for complex numbers");
return *pt;
}

Dsymbol s = mConfig.searchX(Loc.initial, sc, id, SearchOpt.ignorePrivateImports);
if (!s)
{
eSink.error(loc, "`%s` not found in core.stdc.config", id.toErrMsg());
return *pt;
}
s = s.toAlias();
if (auto t = dmd.dsymbolsem.getType(s))
{
if (auto ts = t.toBasetype().isTypeStruct())
{
*pt = ts;
return ts;
}
}
if (auto sd = s.isStructDeclaration())
{
*pt = sd.type;
return sd.type;
}

eSink.error(loc, "`%s` must be an alias for a complex struct", s.toErrMsg());
return *pt;
}

/*******************************
* Covariant means that 'src' can substitute for 't',
* i.e. a pure function is a match for an impure type.
Expand Down
Loading