mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-04-09 05:19:03 +02:00
First import of dmd-2.065-b1 (7088593).
The CPP mangling is not integrated yet.
This commit is contained in:
@@ -44,7 +44,7 @@ void Module::init()
|
||||
modules = new DsymbolTable();
|
||||
}
|
||||
|
||||
Module::Module(char *filename, Identifier *ident, int doDocComment, int doHdrGen)
|
||||
Module::Module(const char *filename, Identifier *ident, int doDocComment, int doHdrGen)
|
||||
: Package(ident)
|
||||
{
|
||||
const char *srcfilename;
|
||||
@@ -90,7 +90,7 @@ Module::Module(char *filename, Identifier *ident, int doDocComment, int doHdrGen
|
||||
|
||||
macrotable = NULL;
|
||||
escapetable = NULL;
|
||||
safe = FALSE;
|
||||
safe = false;
|
||||
#if IN_DMD
|
||||
doppelganger = 0;
|
||||
cov = NULL;
|
||||
@@ -101,7 +101,30 @@ Module::Module(char *filename, Identifier *ident, int doDocComment, int doHdrGen
|
||||
namelen = 0;
|
||||
|
||||
srcfilename = FileName::defaultExt(filename, global.mars_ext);
|
||||
if (!FileName::equalsExt(srcfilename, global.mars_ext) &&
|
||||
|
||||
#if IN_LLVM
|
||||
bool allow_no_extension = global.params.isLinux || global.params.isOSX ||
|
||||
global.params.isFreeBSD || global.params.isOpenBSD ||
|
||||
global.params.isSolaris;
|
||||
#else
|
||||
#if linux || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun
|
||||
/* Allow 'script' D source files to have no extension.
|
||||
*/
|
||||
bool allow_no_extension = true;
|
||||
#else
|
||||
bool allow_no_extension = false;
|
||||
#endif
|
||||
#endif
|
||||
if (allow_no_extension &&
|
||||
global.params.run &&
|
||||
!FileName::ext(filename) &&
|
||||
FileName::exists(srcfilename) == 0 &&
|
||||
FileName::exists(filename) == 1)
|
||||
{
|
||||
FileName::free(srcfilename);
|
||||
srcfilename = FileName::removeExt(filename); // just does a mem.strdup(filename)
|
||||
}
|
||||
else if (!FileName::equalsExt(srcfilename, global.mars_ext) &&
|
||||
!FileName::equalsExt(srcfilename, global.hdr_ext) &&
|
||||
!FileName::equalsExt(srcfilename, "dd"))
|
||||
{
|
||||
@@ -303,7 +326,7 @@ bool Module::read(Loc loc)
|
||||
{
|
||||
for (size_t i = 0; i < global.path->dim; i++)
|
||||
{
|
||||
char *p = (*global.path)[i];
|
||||
const char *p = (*global.path)[i];
|
||||
fprintf(stderr, "import path[%llu] = %s\n", (ulonglong)i, p);
|
||||
}
|
||||
}
|
||||
@@ -399,7 +422,7 @@ void Module::parse()
|
||||
char *srcname = srcfile->name->toChars();
|
||||
//printf("Module::parse(srcname = '%s')\n", srcname);
|
||||
|
||||
utf8_t *buf = srcfile->buffer;
|
||||
utf8_t *buf = (utf8_t *)srcfile->buffer;
|
||||
size_t buflen = srcfile->len;
|
||||
|
||||
if (buflen >= 2)
|
||||
@@ -578,28 +601,30 @@ void Module::parse()
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
{
|
||||
#if IN_LLVM
|
||||
Parser p(this, buf, buflen, gen_docs);
|
||||
Parser p(this, buf, buflen, gen_docs);
|
||||
#else
|
||||
Parser p(this, buf, buflen, docfile != NULL);
|
||||
Parser p(this, buf, buflen, docfile != NULL);
|
||||
#endif
|
||||
p.nextToken();
|
||||
members = p.parseModule();
|
||||
p.nextToken();
|
||||
members = p.parseModule();
|
||||
md = p.md;
|
||||
numlines = p.scanloc.linnum;
|
||||
}
|
||||
|
||||
if (srcfile->ref == 0)
|
||||
::free(srcfile->buffer);
|
||||
srcfile->buffer = NULL;
|
||||
srcfile->len = 0;
|
||||
|
||||
md = p.md;
|
||||
numlines = p.scanloc.linnum;
|
||||
|
||||
/* The symbol table into which the module is to be inserted.
|
||||
*/
|
||||
DsymbolTable *dst;
|
||||
|
||||
if (md)
|
||||
{ /* A ModuleDeclaration, md, was provided.
|
||||
{
|
||||
/* A ModuleDeclaration, md, was provided.
|
||||
* The ModuleDeclaration sets the packages this module appears in, and
|
||||
* the name of this module.
|
||||
*/
|
||||
@@ -608,17 +633,17 @@ void Module::parse()
|
||||
Package *ppack = NULL;
|
||||
dst = Package::resolve(md->packages, &this->parent, &ppack);
|
||||
assert(dst);
|
||||
#if 0
|
||||
if (ppack && ppack->isModule())
|
||||
|
||||
Module *m = ppack ? ppack->isModule() : NULL;
|
||||
if (m && strcmp(m->srcfile->name->name(), "package.d") != 0)
|
||||
{
|
||||
error(loc, "package name '%s' in file %s conflicts with usage as a module name in file %s",
|
||||
ppack->toChars(), srcname, ppack->isModule()->srcfile->toChars());
|
||||
dst = modules;
|
||||
::error(md->loc, "package name '%s' conflicts with usage as a module name in file %s",
|
||||
ppack->toPrettyChars(), m->srcfile->toChars());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{ /* The name of the module is set to the source file name.
|
||||
{
|
||||
/* The name of the module is set to the source file name.
|
||||
* There are no packages.
|
||||
*/
|
||||
dst = modules; // and so this module goes into global module symbol table
|
||||
@@ -665,8 +690,7 @@ void Module::parse()
|
||||
*/
|
||||
Dsymbol *prev = dst->lookup(ident);
|
||||
assert(prev);
|
||||
Module *mprev = prev->isModule();
|
||||
if (mprev)
|
||||
if (Module *mprev = prev->isModule())
|
||||
{
|
||||
if (strcmp(srcname, mprev->srcfile->toChars()) == 0)
|
||||
error(loc, "from file %s must be imported as module '%s'",
|
||||
@@ -675,10 +699,8 @@ void Module::parse()
|
||||
error(loc, "from file %s conflicts with another module %s from file %s",
|
||||
srcname, mprev->toChars(), mprev->srcfile->toChars());
|
||||
}
|
||||
else
|
||||
else if (Package *pkg = prev->isPackage())
|
||||
{
|
||||
Package *pkg = prev->isPackage();
|
||||
assert(pkg);
|
||||
if (pkg->isPkgMod == PKGunknown && isPackageMod)
|
||||
{
|
||||
/* If the previous inserted Package is not yet determined as package.d,
|
||||
@@ -691,6 +713,8 @@ void Module::parse()
|
||||
error(pkg->loc, "from file %s conflicts with package name %s",
|
||||
srcname, pkg->toChars());
|
||||
}
|
||||
else
|
||||
assert(global.errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1071,7 +1095,7 @@ void Module::runDeferredSemantic3()
|
||||
|
||||
/************************************
|
||||
* Recursively look at every module this module imports,
|
||||
* return TRUE if it imports m.
|
||||
* return true if it imports m.
|
||||
* Can be used to detect circular imports.
|
||||
*/
|
||||
|
||||
@@ -1087,7 +1111,7 @@ int Module::imports(Module *m)
|
||||
for (size_t i = 0; i < aimports.dim; i++)
|
||||
{ Module *mi = aimports[i];
|
||||
if (mi == m)
|
||||
return TRUE;
|
||||
return true;
|
||||
if (!mi->insearch)
|
||||
{
|
||||
mi->insearch = 1;
|
||||
@@ -1096,7 +1120,7 @@ int Module::imports(Module *m)
|
||||
return r;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*************************************
|
||||
@@ -1191,8 +1215,8 @@ DsymbolTable *Package::resolve(Identifiers *packages, Dsymbol **pparent, Package
|
||||
if (packages)
|
||||
{
|
||||
for (size_t i = 0; i < packages->dim; i++)
|
||||
{ Identifier *pid = (*packages)[i];
|
||||
|
||||
{
|
||||
Identifier *pid = (*packages)[i];
|
||||
Package *pkg;
|
||||
Dsymbol *p = dst->lookup(pid);
|
||||
if (!p)
|
||||
@@ -1219,14 +1243,13 @@ DsymbolTable *Package::resolve(Identifiers *packages, Dsymbol **pparent, Package
|
||||
dst = pkg->symtab;
|
||||
if (ppkg && !*ppkg)
|
||||
*ppkg = pkg;
|
||||
#if 0
|
||||
if (pkg->isModule())
|
||||
{ // Return the module so that a nice error message can be generated
|
||||
{
|
||||
// Return the module so that a nice error message can be generated
|
||||
if (ppkg)
|
||||
*ppkg = (Package *)p;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (pparent)
|
||||
|
||||
Reference in New Issue
Block a user