本文整理汇总了C++中OutBuffer::writestring方法的典型用法代码示例。如果您正苦于以下问题:C++ OutBuffer::writestring方法的具体用法?C++ OutBuffer::writestring怎么用?C++ OutBuffer::writestring使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OutBuffer
的用法示例。
在下文中一共展示了OutBuffer::writestring方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: objectEnd
void JsonOut::objectEnd()
{
indentLevel--;
removeComma();
if (buf->offset >= 2 &&
buf->data[buf->offset - 2] == '{' &&
buf->data[buf->offset - 1] == '\n')
buf->offset -= 1;
else
{
buf->writestring("\n");
indent();
}
buf->writestring("}");
comma();
}
示例2: visit
void visit(AssignExp *e)
{
/* Evaluate assign expressions right to left
*/
e->e2->accept(this);
e->e1->accept(this);
buf->writestring("Assign");
}
示例3: arrayEnd
void JsonOut::arrayEnd()
{
indentLevel--;
removeComma();
if (buf->offset >= 2 &&
buf->data[buf->offset - 2] == '[' &&
buf->data[buf->offset - 1] == '\n')
buf->offset -= 1;
else if (!(buf->offset >= 1 &&
buf->data[buf->offset - 1] == '['))
{
buf->writestring("\n");
indent();
}
buf->writestring("]");
comma();
}
示例4: visit
void visit(TypeVector *t)
{
if (substitute(t))
return;
buf.writestring("U8__vector");
t->basetype->accept(this);
store(t);
}
示例5: mangle
char *mangle(Declaration *sthis)
{
OutBuffer buf;
char *id;
Dsymbol *s;
//printf("::mangle(%s)\n", sthis->toChars());
s = sthis;
do
{
//printf("mangle: s = %p, '%s', parent = %p\n", s, s->toChars(), s->parent);
if (s->ident)
{
FuncDeclaration *fd = s->isFuncDeclaration();
if (s != sthis && fd)
{
id = mangle(fd);
buf.prependstring(id);
goto L1;
}
else
{
id = s->ident->toChars();
int len = strlen(id);
char tmp[sizeof(len) * 3 + 1];
buf.prependstring(id);
sprintf(tmp, "%d", len);
buf.prependstring(tmp);
}
}
else
buf.prependstring("0");
s = s->parent;
} while (s);
// buf.prependstring("_D");
L1:
//printf("deco = '%s'\n", sthis->type->deco ? sthis->type->deco : "null");
//printf("sthis->type = %s\n", sthis->type->toChars());
FuncDeclaration *fd = sthis->isFuncDeclaration();
if (fd && (fd->needThis() || fd->isNested()))
buf.writeByte(Type::needThisPrefix());
if (sthis->type->deco)
buf.writestring(sthis->type->deco);
else
{
#ifdef DEBUG
if (!fd->inferRetType)
printf("%s\n", fd->toChars());
#endif
assert(fd && fd->inferRetType);
}
id = buf.toChars();
buf.data = NULL;
return id;
}
示例6: printDepsConditional
// Helper for printing dependency information
void printDepsConditional(Scope *sc, DVCondition* condition, const char* depType)
{
if (!global.params.moduleDeps || global.params.moduleDepsFile)
return;
OutBuffer *ob = global.params.moduleDeps;
Module* imod = sc ? (sc->instantiatingModule ? sc->instantiatingModule : sc->module) : condition->mod;
if (!imod)
return;
ob->writestring(depType);
ob->writestring(imod->toPrettyChars());
ob->writestring(" (");
escapePath(ob, imod->srcfile->toChars());
ob->writestring(") : ");
if (condition->ident)
ob->printf("%s\n", condition->ident->toChars());
else
ob->printf("%d\n", condition->level);
}
示例7: idPool
Identifier *Identifier::generateId(const char *prefix, size_t i)
{ OutBuffer buf;
buf.writestring(prefix);
buf.printf("%llu", (ulonglong)i);
char *id = buf.peekString();
return idPool(id);
}
示例8: json_generate
void json_generate(Array *modules)
{ OutBuffer buf;
buf.writestring("[\n");
for (int i = 0; i < modules->dim; i++)
{ Module *m = (Module *)modules->data[i];
if (global.params.verbose)
printf("json gen %s\n", m->toChars());
m->toJsonBuffer(&buf);
buf.writestring(",\n");
}
JsonRemoveComma(&buf);
buf.writestring("]\n");
// Write buf to file
char *arg = global.params.xfilename;
if (!arg || !*arg)
{ // Generate lib file name from first obj name
char *n = (char *)global.params.objfiles->data[0];
n = FileName::name(n);
FileName *fn = FileName::forceExt(n, global.json_ext);
arg = fn->toChars();
}
else if (arg[0] == '-' && arg[1] == 0)
{ // Write to stdout; assume it succeeds
int n = fwrite(buf.data, 1, buf.offset, stdout);
assert(n == buf.offset); // keep gcc happy about return values
return;
}
// if (!FileName::absolute(arg))
// arg = FileName::combine(dir, arg);
FileName *jsonfilename = FileName::defaultExt(arg, global.json_ext);
File *jsonfile = new File(jsonfilename);
assert(jsonfile);
jsonfile->setbuffer(buf.data, buf.offset);
jsonfile->ref = 1;
char *pt = FileName::path(jsonfile->toChars());
if (*pt)
FileName::ensurePathExists(pt);
mem.free(pt);
jsonfile->writev();
}
示例9: argsCppMangle
void argsCppMangle(Parameters *arguments, int varargs)
{
if (arguments)
Parameter::foreach(arguments, &argsCppMangleDg, (void*)this);
if (varargs)
buf.writestring("z");
else if (!arguments || !arguments->dim)
buf.writeByte('v'); // encode ( ) arguments
}
示例10: idPool
Identifier *Identifier::generateId(const char *prefix, size_t i)
{ OutBuffer buf;
buf.writestring(prefix);
buf.printf("%llu", (ulonglong)i);
char *id = buf.toChars();
buf.data = NULL;
return Lexer::idPool(id);
}
示例11: visit
void visit(Declaration *d)
{
//printf("Declaration::mangle(this = %p, '%s', parent = '%s', linkage = %d)\n",
// d, d->toChars(), d->parent ? d->parent->toChars() : "null", d->linkage);
if (!d->parent || d->parent->isModule() || d->linkage == LINKcpp) // if at global scope
{
switch (d->linkage)
{
case LINKd:
break;
case LINKc:
case LINKwindows:
case LINKpascal:
result = d->ident->toChars();
break;
case LINKcpp:
result = toCppMangle(d);
break;
case LINKdefault:
d->error("forward declaration");
result = d->ident->toChars();
break;
default:
fprintf(stderr, "'%s', linkage = %d\n", d->toChars(), d->linkage);
assert(0);
}
}
if (!result)
{
OutBuffer buf;
buf.writestring("_D");
mangleDecl(&buf, d);
result = buf.extractString();
}
#ifdef DEBUG
assert(result);
size_t len = strlen(result);
assert(len > 0);
for (size_t i = 0; i < len; i++)
{
assert(result[i] == '_' ||
result[i] == '@' ||
result[i] == '?' ||
result[i] == '$' ||
isalnum(result[i]) || result[i] & 0x80);
}
#endif
}
示例12: mangle_function
void mangle_function(FuncDeclaration *d)
{
/*
* <mangled-name> ::= _Z <encoding>
* <encoding> ::= <function name> <bare-function-type>
* ::= <data name>
* ::= <special-name>
*/
TypeFunction *tf = (TypeFunction *)d->type;
buf.writestring(global.params.isOSX ? "__Z" : "_Z"); // "__Z" for OSX, "_Z" for other
Dsymbol *p = d->toParent();
if (p && !p->isModule() && tf->linkage == LINKcpp)
{
buf.writeByte('N');
if (d->type->isConst())
buf.writeByte('K');
prefix_name(p);
if (d->isDtorDeclaration())
{
buf.writestring("D1");
}
else
{
source_name(d);
}
buf.writeByte('E');
}
else
{
source_name(d);
}
if (tf->linkage == LINKcpp) //Template args accept extern "C" symbols with special mangling
{
assert(tf->ty == Tfunction);
argsCppMangle(tf->parameters, tf->varargs);
}
}
示例13: argsCppMangle
void argsCppMangle(Parameters *arguments, int varargs)
{
size_t n = 0;
if (arguments)
{
ArgsCppMangleCtx ctx = { this, 0 };
Parameter::foreach(arguments, &argsCppMangleDg, &ctx);
n = ctx.cnt;
}
if (varargs)
buf.writestring("z");
else if (!n)
buf.writeByte('v'); // encode ( ) arguments
}
示例14: visit
void visit(TypeVector *t)
{
if (substitute(t)) return;
store(t);
if (t->isImmutable() || t->isShared())
{
visit((Type *)t);
}
if (t->isConst())
buf.writeByte('K');
assert(t->basetype && t->basetype->ty == Tsarray);
assert(((TypeSArray *)t->basetype)->dim);
//buf.printf("Dv%llu_", ((TypeSArray *)t->basetype)->dim->toInteger());// -- Gnu ABI v.4
buf.writestring("U8__vector"); //-- Gnu ABI v.3
t->basetype->nextOf()->accept(this);
}
示例15: assert
/**
* Creates the data symbol for a TLS variable for Mach-O.
*
* Input:
* vd the variable declaration for the symbol
* s the regular symbol for the variable
*
* Returns: the newly create symbol
*/
Symbol *createTLVDataSymbol(VarDeclaration *vd, Symbol *s)
{
assert(config.objfmt == OBJ_MACH && I64 && (s->ty() & mTYLINK) == mTYthread);
OutBuffer buffer;
buffer.writestring(s->Sident);
buffer.write("$tlv$init", 9);
const char *tlvInitName = buffer.extractString();
Symbol *tlvInit = symbol_name(tlvInitName, SCstatic, type_fake(vd->type->ty));
tlvInit->Sdt = NULL;
tlvInit->Salignment = type_alignsize(s->Stype);
type_setty(&tlvInit->Stype, tlvInit->Stype->Tty | mTYthreadData);
type_setmangle(&tlvInit->Stype, mangle(vd, tlvInit));
return tlvInit;
}