本文整理汇总了C++中Dsymbol::getModule方法的典型用法代码示例。如果您正苦于以下问题:C++ Dsymbol::getModule方法的具体用法?C++ Dsymbol::getModule怎么用?C++ Dsymbol::getModule使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dsymbol
的用法示例。
在下文中一共展示了Dsymbol::getModule方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: obj_write_deferred
void obj_write_deferred(Library *library)
{
for (int i = 0; i < obj_symbols_towrite.dim; i++)
{ Dsymbol *s = (Dsymbol *)obj_symbols_towrite.data[i];
Module *m = s->getModule();
char *mname;
if (m)
{ mname = m->srcfile->toChars();
lastmname = mname;
}
else
{
//mname = s->ident->toChars();
mname = lastmname;
assert(mname);
}
obj_start(mname);
static int count;
count++; // sequence for generating names
/* Create a module that's a doppelganger of m, with just
* enough to be able to create the moduleinfo.
*/
OutBuffer idbuf;
idbuf.printf("%s.%d", m ? m->ident->toChars() : mname, count);
char *idstr = idbuf.toChars();
idbuf.data = NULL;
Identifier *id = new Identifier(idstr, TOKidentifier);
Module *md = new Module(mname, id, 0, 0);
md->members = new Array();
md->members->push(s); // its only 'member' is s
if (m)
{
md->doppelganger = 1; // identify this module as doppelganger
md->md = m->md;
md->aimports.push(m); // it only 'imports' m
md->massert = m->massert;
md->marray = m->marray;
}
md->genobjfile(0);
/* Set object file name to be source name with sequence number,
* as mangled symbol names get way too long.
*/
char *fname = FileName::removeExt(mname);
OutBuffer namebuf;
unsigned hash = 0;
for (char *p = s->toChars(); *p; p++)
hash += *p;
namebuf.printf("%s_%x_%x.%s", fname, count, hash, global.obj_ext);
namebuf.writeByte(0);
mem.free(fname);
fname = (char *)namebuf.extractData();
//printf("writing '%s'\n", fname);
File *objfile = new File(fname);
obj_end(library, objfile);
}
obj_symbols_towrite.dim = 0;
}
示例2: obj_write_deferred
void obj_write_deferred(Library *library)
{
for (size_t i = 0; i < obj_symbols_towrite.dim; i++)
{
Dsymbol *s = obj_symbols_towrite[i];
Module *m = s->getModule();
char *mname;
if (m)
{
mname = m->srcfile->toChars();
lastmname = mname;
}
else
{
//mname = s->ident->toChars();
mname = lastmname;
assert(mname);
}
obj_start(mname);
static int count;
count++; // sequence for generating names
/* Create a module that's a doppelganger of m, with just
* enough to be able to create the moduleinfo.
*/
OutBuffer idbuf;
idbuf.printf("%s.%d", m ? m->ident->toChars() : mname, count);
char *idstr = idbuf.peekString();
if (!m)
{
// it doesn't make sense to make up a module if we don't know where to put the symbol
// so output it into it's own object file without ModuleInfo
objmod->initfile(idstr, NULL, mname);
toObjFile(s, false);
objmod->termfile();
}
else
{
idbuf.data = NULL;
Identifier *id = Identifier::create(idstr, TOKidentifier);
Module *md = Module::create(mname, id, 0, 0);
md->members = Dsymbols_create();
md->members->push(s); // its only 'member' is s
md->doppelganger = 1; // identify this module as doppelganger
md->md = m->md;
md->aimports.push(m); // it only 'imports' m
md->massert = m->massert;
md->munittest = m->munittest;
md->marray = m->marray;
genObjFile(md, false);
}
/* Set object file name to be source name with sequence number,
* as mangled symbol names get way too long.
*/
const char *fname = FileName::removeExt(mname);
OutBuffer namebuf;
unsigned hash = 0;
for (char *p = s->toChars(); *p; p++)
hash += *p;
namebuf.printf("%s_%x_%x.%s", fname, count, hash, global.obj_ext);
FileName::free((char *)fname);
fname = namebuf.extractString();
//printf("writing '%s'\n", fname);
File *objfile = File::create(fname);
obj_end(library, objfile);
}
obj_symbols_towrite.dim = 0;
}