本文整理汇总了C++中OutBuffer::writenl方法的典型用法代码示例。如果您正苦于以下问题:C++ OutBuffer::writenl方法的具体用法?C++ OutBuffer::writenl怎么用?C++ OutBuffer::writenl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OutBuffer
的用法示例。
在下文中一共展示了OutBuffer::writenl方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: genhdrfile
void Module::genhdrfile()
{
OutBuffer hdrbufr;
hdrbufr.doindent = 1;
hdrbufr.printf("// D import file generated from '%s'", srcfile->toChars());
hdrbufr.writenl();
HdrGenState hgs;
memset(&hgs, 0, sizeof(hgs));
hgs.hdrgen = 1;
toCBuffer(&hdrbufr, &hgs);
// Transfer image to file
hdrfile->setbuffer(hdrbufr.data, hdrbufr.offset);
hdrbufr.data = NULL;
ensurePathToNameExists(Loc(), hdrfile->toChars());
writeFile(loc, hdrfile);
}
示例2: gensymfile
void Module::gensymfile()
{
OutBuffer buf;
HdrGenState hgs;
//printf("Module::gensymfile()\n");
buf.printf("// Sym file generated from '%s'", srcfile->toChars());
buf.writenl();
for (size_t i = 0; i < members->dim; i++)
{
Dsymbol *s = (*members)[i];
s->toCBuffer(&buf, &hgs);
}
// Transfer image to file
symfile->setbuffer(buf.data, buf.offset);
buf.data = NULL;
writeFile(loc, symfile);
}
示例3: genhdrfile
void Module::genhdrfile()
{
OutBuffer hdrbufr;
hdrbufr.printf("// D import file generated from '%s'", srcfile->toChars());
hdrbufr.writenl();
HdrGenState hgs;
memset(&hgs, 0, sizeof(hgs));
hgs.hdrgen = 1;
toCBuffer(&hdrbufr, &hgs);
// Transfer image to file
hdrfile->setbuffer(hdrbufr.data, hdrbufr.offset);
hdrbufr.data = NULL;
char *pt = FileName::path(hdrfile->toChars());
if (*pt)
FileName::ensurePathExists(pt);
mem.free(pt);
hdrfile->writev();
}
示例4: semantic
//.........这里部分代码省略.........
* that Dsymbol::search errors before overload resolution.
*/
#if 0
sc->protection = protection;
#else
sc->protection = PROTpublic;
#endif
for (size_t i = 0; i < aliasdecls.dim; i++)
{ Dsymbol *s = aliasdecls[i];
//printf("\tImport alias semantic('%s')\n", s->toChars());
if (mod->search(loc, names[i], 0))
s->semantic(sc);
else
{
s = mod->search_correct(names[i]);
if (s)
mod->error(loc, "import '%s' not found, did you mean '%s %s'?", names[i]->toChars(), s->kind(), s->toChars());
else
mod->error(loc, "import '%s' not found", names[i]->toChars());
}
}
sc = sc->pop();
}
if (global.params.moduleDeps != NULL &&
// object self-imports itself, so skip that (Bugzilla 7547)
!(id == Id::object && sc->module->ident == Id::object))
{
/* The grammar of the file is:
* ImportDeclaration
* ::= BasicImportDeclaration [ " : " ImportBindList ] [ " -> "
* ModuleAliasIdentifier ] "\n"
*
* BasicImportDeclaration
* ::= ModuleFullyQualifiedName " (" FilePath ") : " Protection
* " [ " static" ] : " ModuleFullyQualifiedName " (" FilePath ")"
*
* FilePath
* - any string with '(', ')' and '\' escaped with the '\' character
*/
OutBuffer *ob = global.params.moduleDeps;
ob->writestring(sc->module->toPrettyChars());
ob->writestring(" (");
escapePath(ob, sc->module->srcfile->toChars());
ob->writestring(") : ");
// use protection instead of sc->protection because it couldn't be
// resolved yet, see the comment above
ProtDeclaration::protectionToCBuffer(ob, protection);
if (isstatic)
StorageClassDeclaration::stcToCBuffer(ob, STCstatic);
ob->writestring(": ");
if (packages)
{
for (size_t i = 0; i < packages->dim; i++)
{
Identifier *pid = (*packages)[i];
ob->printf("%s.", pid->toChars());
}
}
ob->writestring(id->toChars());
ob->writestring(" (");
if (mod)
escapePath(ob, mod->srcfile->toChars());
else
ob->writestring("???");
ob->writebyte(')');
for (size_t i = 0; i < names.dim; i++)
{
if (i == 0)
ob->writebyte(':');
else
ob->writebyte(',');
Identifier *name = names[i];
Identifier *alias = aliases[i];
if (!alias)
{
ob->printf("%s", name->toChars());
alias = name;
}
else
ob->printf("%s=%s", alias->toChars(), name->toChars());
}
if (aliasId)
ob->printf(" -> %s", aliasId->toChars());
ob->writenl();
}
//printf("-Import::semantic('%s'), pkg = %p\n", toChars(), pkg);
}
示例5: semantic
void PragmaDeclaration::semantic(Scope *sc)
{ // Should be merged with PragmaStatement
#if IN_LLVM
Pragma llvm_internal = LLVMnone;
std::string arg1str;
#endif
//printf("\tPragmaDeclaration::semantic '%s'\n",toChars());
if (ident == Id::msg)
{
if (args)
{
for (size_t i = 0; i < args->dim; i++)
{
Expression *e = (*args)[i];
sc = sc->startCTFE();
e = e->semantic(sc);
e = resolveProperties(sc, e);
sc = sc->endCTFE();
// pragma(msg) is allowed to contain types as well as expressions
e = ctfeInterpretForPragmaMsg(e);
if (e->op == TOKerror)
{ errorSupplemental(loc, "while evaluating pragma(msg, %s)", (*args)[i]->toChars());
return;
}
StringExp *se = e->toString();
if (se)
{
se = se->toUTF8(sc);
fprintf(stderr, "%.*s", (int)se->len, (char *)se->string);
}
else
fprintf(stderr, "%s", e->toChars());
}
fprintf(stderr, "\n");
}
goto Lnodecl;
}
else if (ident == Id::lib)
{
if (!args || args->dim != 1)
error("string expected for library name");
else
{
Expression *e = (*args)[0];
sc = sc->startCTFE();
e = e->semantic(sc);
e = resolveProperties(sc, e);
sc = sc->endCTFE();
e = e->ctfeInterpret();
(*args)[0] = e;
if (e->op == TOKerror)
goto Lnodecl;
StringExp *se = e->toString();
if (!se)
error("string expected for library name, not '%s'", e->toChars());
else
{
char *name = (char *)mem.malloc(se->len + 1);
memcpy(name, se->string, se->len);
name[se->len] = 0;
if (global.params.verbose)
fprintf(global.stdmsg, "library %s\n", name);
if (global.params.moduleDeps && !global.params.moduleDepsFile)
{
OutBuffer *ob = global.params.moduleDeps;
Module *imod = sc->instantiatingModule();
ob->writestring("depsLib ");
ob->writestring(imod->toPrettyChars());
ob->writestring(" (");
escapePath(ob, imod->srcfile->toChars());
ob->writestring(") : ");
ob->writestring((char *) name);
ob->writenl();
}
mem.free(name);
}
}
goto Lnodecl;
}
else if (ident == Id::startaddress)
{
if (!args || args->dim != 1)
error("function name expected for start address");
else
{
/* Bugzilla 11980:
* resolveProperties and ctfeInterpret call are not necessary.
*/
Expression *e = (*args)[0];
sc = sc->startCTFE();
e = e->semantic(sc);
sc = sc->endCTFE();
//.........这里部分代码省略.........
示例6: semantic
//.........这里部分代码省略.........
if (!isstatic && !aliasId && !names.dim)
{
/* Default to private importing
*/
enum PROT prot = sc->protection;
if (!sc->explicitProtection)
prot = PROTprivate;
sc->scopesym->importScope(mod, prot);
}
mod->semantic();
if (mod->needmoduleinfo)
sc->module->needmoduleinfo = 1;
sc = sc->push(mod);
for (size_t i = 0; i < aliasdecls.dim; i++)
{ Dsymbol *s = (Dsymbol *)aliasdecls.data[i];
//printf("\tImport alias semantic('%s')\n", s->toChars());
if (!mod->search(loc, (Identifier *)names.data[i], 0))
error("%s not found", ((Identifier *)names.data[i])->toChars());
s->semantic(sc);
}
sc = sc->pop();
}
if (global.params.moduleDeps != NULL)
{
/* The grammar of the file is:
* ImportDeclaration
* ::= BasicImportDeclaration [ " : " ImportBindList ] [ " -> "
* ModuleAliasIdentifier ] "\n"
*
* BasicImportDeclaration
* ::= ModuleFullyQualifiedName " (" FilePath ") : " Protection
* " [ " static" ] : " ModuleFullyQualifiedName " (" FilePath ")"
*
* FilePath
* - any string with '(', ')' and '\' escaped with the '\' character
*/
OutBuffer *ob = global.params.moduleDeps;
ob->writestring(sc->module->toPrettyChars());
ob->writestring(" (");
escapePath(ob, sc->module->srcfile->toChars());
ob->writestring(") : ");
ProtDeclaration::protectionToCBuffer(ob, sc->protection);
if (isstatic)
StorageClassDeclaration::stcToCBuffer(ob, STCstatic);
ob->writestring(": ");
if (packages)
{
for (size_t i = 0; i < packages->dim; i++)
{
Identifier *pid = (Identifier *)packages->data[i];
ob->printf("%s.", pid->toChars());
}
}
ob->writestring(id->toChars());
ob->writestring(" (");
if (mod)
escapePath(ob, mod->srcfile->toChars());
else
ob->writestring("???");
ob->writebyte(')');
for (size_t i = 0; i < names.dim; i++)
{
if (i == 0)
ob->writebyte(':');
else
ob->writebyte(',');
Identifier *name = (Identifier *)names.data[i];
Identifier *alias = (Identifier *)aliases.data[i];
if (!alias)
{
ob->printf("%s", name->toChars());
alias = name;
}
else
ob->printf("%s=%s", alias->toChars(), name->toChars());
}
if (aliasId)
ob->printf(" -> %s", aliasId->toChars());
ob->writenl();
}
//printf("-Import::semantic('%s'), pkg = %p\n", toChars(), pkg);
}
示例7: semantic
//.........这里部分代码省略.........
AliasDeclaration *ad = aliasdecls[i];
//printf("\tImport alias semantic('%s')\n", ad->toChars());
if (mod->search(loc, names[i]))
{
ad->semantic(sc);
}
else
{
Dsymbol *s = mod->search_correct(names[i]);
if (s)
mod->error(loc, "import '%s' not found, did you mean '%s %s'?", names[i]->toChars(), s->kind(), s->toChars());
else
mod->error(loc, "import '%s' not found", names[i]->toChars());
ad->type = Type::terror;
}
}
sc = sc->pop();
}
// object self-imports itself, so skip that (Bugzilla 7547)
// don't list pseudo modules __entrypoint.d, __main.d (Bugzilla 11117, 11164)
if (global.params.moduleDeps != NULL &&
!(id == Id::object && sc->module->ident == Id::object) &&
sc->module->ident != Id::entrypoint &&
strcmp(sc->module->ident->string, "__main") != 0)
{
/* The grammar of the file is:
* ImportDeclaration
* ::= BasicImportDeclaration [ " : " ImportBindList ] [ " -> "
* ModuleAliasIdentifier ] "\n"
*
* BasicImportDeclaration
* ::= ModuleFullyQualifiedName " (" FilePath ") : " Protection|"string"
* " [ " static" ] : " ModuleFullyQualifiedName " (" FilePath ")"
*
* FilePath
* - any string with '(', ')' and '\' escaped with the '\' character
*/
OutBuffer *ob = global.params.moduleDeps;
Module* imod = sc->instantiatingModule();
if (!global.params.moduleDepsFile)
ob->writestring("depsImport ");
ob->writestring(imod->toPrettyChars());
ob->writestring(" (");
escapePath(ob, imod->srcfile->toChars());
ob->writestring(") : ");
// use protection instead of sc->protection because it couldn't be
// resolved yet, see the comment above
protectionToBuffer(ob, protection);
ob->writeByte(' ');
if (isstatic)
StorageClassDeclaration::stcToCBuffer(ob, STCstatic);
ob->writestring(": ");
if (packages)
{
for (size_t i = 0; i < packages->dim; i++)
{
Identifier *pid = (*packages)[i];
ob->printf("%s.", pid->toChars());
}
}
ob->writestring(id->toChars());
ob->writestring(" (");
if (mod)
escapePath(ob, mod->srcfile->toChars());
else
ob->writestring("???");
ob->writeByte(')');
for (size_t i = 0; i < names.dim; i++)
{
if (i == 0)
ob->writeByte(':');
else
ob->writeByte(',');
Identifier *name = names[i];
Identifier *alias = aliases[i];
if (!alias)
{
ob->printf("%s", name->toChars());
alias = name;
}
else
ob->printf("%s=%s", alias->toChars(), name->toChars());
}
if (aliasId)
ob->printf(" -> %s", aliasId->toChars());
ob->writenl();
}
//printf("-Import::semantic('%s'), pkg = %p\n", toChars(), pkg);
}
示例8: semantic
//.........这里部分代码省略.........
if (!sc->explicitProtection)
prot = PROTprivate;
for (Scope *scd = sc; scd; scd = scd->enclosing)
{
if (scd->scopesym)
{
scd->scopesym->importScope(this, prot);
break;
}
}
mod->semantic();
if (mod->needmoduleinfo)
{ //printf("module4 %s because of %s\n", sc->module->toChars(), mod->toChars());
sc->module->needmoduleinfo = 1;
}
if (aliasId)
{
AliasDeclaration *ad = new AliasDeclaration(loc, aliasId, mod);
sc->insert(ad);
ad->semantic(sc);
}
}
//printf("-Import::semantic('%s'), pkg = %p\n", toChars(), pkg);
if (global.params.moduleDeps != NULL &&
// object self-imports itself, so skip that (Bugzilla 7547)
!(id == Id::object && sc->module->ident == Id::object))
{
/* The grammar of the file is:
* ImportDeclaration
* ::= BasicImportDeclaration [ " : " ImportBindList ] [ " -> "
* ModuleAliasIdentifier ] "\n"
*
* BasicImportDeclaration
* ::= ModuleFullyQualifiedName " (" FilePath ") : " Protection
* " [ " static" ] : " ModuleFullyQualifiedName " (" FilePath ")"
*
* FilePath
* - any string with '(', ')' and '\' escaped with the '\' character
*/
OutBuffer *ob = global.params.moduleDeps;
ob->writestring(sc->module->toPrettyChars());
ob->writestring(" (");
escapePath(ob, sc->module->srcfile->toChars());
ob->writestring(") : ");
ProtDeclaration::protectionToCBuffer(ob, sc->protection);
if (isstatic)
StorageClassDeclaration::stcToCBuffer(ob, STCstatic);
ob->writestring(": ");
if (packages)
{
for (size_t i = 0; i < packages->dim; i++)
{
Identifier *pid = (*packages)[i];
ob->printf("%s.", pid->toChars());
}
}
ob->writestring(id->toChars());
ob->writestring(" (");
if (mod)
escapePath(ob, mod->srcfile->toChars());
else
ob->writestring("???");
ob->writebyte(')');
for (size_t i = 0; i < names.dim; i++)
{
if (i == 0)
ob->writebyte(':');
else
ob->writebyte(',');
Identifier *name = names[i];
Identifier *alias = aliases[i];
if (!alias)
{
ob->printf("%s", name->toChars());
alias = name;
}
else
ob->printf("%s=%s", alias->toChars(), name->toChars());
}
if (aliasId)
ob->printf(" -> %s", aliasId->toChars());
ob->writenl();
}
//printf("-Import::semantic('%s'), pkg = %p\n", toChars(), pkg);
}