本文整理汇总了C++中OutBuffer::prependstring方法的典型用法代码示例。如果您正苦于以下问题:C++ OutBuffer::prependstring方法的具体用法?C++ OutBuffer::prependstring怎么用?C++ OutBuffer::prependstring使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OutBuffer
的用法示例。
在下文中一共展示了OutBuffer::prependstring方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: if
/******************************************************************************
* isv : for the enclosing auto functions of an inner class/struct type.
* An aggregate type which defined inside auto function, it might
* become Voldemort Type so its object might be returned.
* This flag is necessary due to avoid mutual mangling
* between return type and enclosing scope. See bugzilla 8847.
*/
char *mangleDecl(Declaration *sthis, bool isv)
{
OutBuffer buf;
char *id;
Dsymbol *s;
//printf("::mangleDecl(%s)\n", sthis->toChars());
s = sthis;
do
{
//printf("mangle: s = %p, '%s', parent = %p\n", s, s->toChars(), s->parent);
if (s->getIdent())
{
FuncDeclaration *fd = s->isFuncDeclaration();
if (s != sthis && fd)
{
id = mangleDecl(fd, isv);
buf.prependstring(id);
goto L1;
}
else
{
id = s->ident->toChars();
size_t len = strlen(id);
char tmp[sizeof(len) * 3 + 1];
buf.prependstring(id);
sprintf(tmp, "%d", (int)len);
buf.prependstring(tmp);
}
}
else
buf.prependstring("0");
TemplateInstance *ti = s->isTemplateInstance();
if (ti && !ti->isTemplateMixin())
s = ti->tempdecl->parent;
else
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 (isv && fd && (fd->inferRetType || getFuncTemplateDecl(fd)))
{
#if DDMD
TypeFunction *tfn = (TypeFunction *)sthis->type->copy();
TypeFunction *tfo = (TypeFunction *)sthis->originalType;
tfn->purity = tfo->purity;
tfn->isnothrow = tfo->isnothrow;
tfn->isproperty = tfo->isproperty;
tfn->isref = fd->storage_class & STCauto ? false : tfo->isref;
tfn->trust = tfo->trust;
tfn->next = NULL; // do not mangle return type
tfn->toDecoBuffer(&buf, 0);
#else
TypeFunction tfn = *(TypeFunction *)sthis->type;
TypeFunction *tfo = (TypeFunction *)sthis->originalType;
tfn.purity = tfo->purity;
tfn.isnothrow = tfo->isnothrow;
tfn.isproperty = tfo->isproperty;
tfn.isref = fd->storage_class & STCauto ? false : tfo->isref;
tfn.trust = tfo->trust;
tfn.next = NULL; // do not mangle return type
tfn.toDecoBuffer(&buf, 0);
#endif
}
else 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 && fd->type->ty == Tfunction);
TypeFunction *tf = (TypeFunction *)sthis->type;
Type *tn = tf->next;
tf->next = NULL; // do not mangle undetermined return type
tf->toDecoBuffer(&buf, 0);
tf->next = tn;
}
id = buf.extractString();
return id;
}