本文整理汇总了C++中Dsymbol::toParent方法的典型用法代码示例。如果您正苦于以下问题:C++ Dsymbol::toParent方法的具体用法?C++ Dsymbol::toParent怎么用?C++ Dsymbol::toParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dsymbol
的用法示例。
在下文中一共展示了Dsymbol::toParent方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: prefix_name
void prefix_name(Dsymbol *s)
{
if (!substitute(s))
{
store(s);
Dsymbol *p = s->toParent();
if (p && p->isTemplateInstance())
{
s = p;
if (exist(p->isTemplateInstance()->tempdecl))
{
p = NULL;
}
else
{
p = p->toParent();
}
}
if (p && !p->isModule())
{
prefix_name(p);
}
source_name(s);
}
}
示例2: while
// Check if this function is a member of a template which has only been
// instantiated speculatively, eg from inside is(typeof()).
// Return the speculative template instance it is part of,
// or NULL if not speculative.
TemplateInstance *Dsymbol::isSpeculative()
{
Dsymbol * par = parent;
while (par)
{
TemplateInstance *ti = par->isTemplateInstance();
if (ti && ti->speculative)
return ti;
par = par->toParent();
}
return NULL;
}
示例3: createClass
Class* ModuleEmitter::createClass(ClassDeclaration& decl)
{
Class* c = NULL;
if (Dsymbol* parent = decl.toParent())
{
//start by assuming class is declared at module scope
block* blk = &DEREF(irState_).getBlock();
if (AggregateDeclaration* aggrDecl = parent->isAggregateDeclaration())
{
decl.isnested = true;
blk = &getAggregate(*aggrDecl).getBlock();
}
//if the class lives in another assembly, generate it in a hidden block
#if 0
for (Dsymbol* p = parent; p; p = p->toParent())
{
if (PragmaScope* pscope = p->isPragmaScope())
{
if (pscope->kind() == PragmaScope::pragma_assembly)
{
blk = &BackEnd::instance().getAssembly();
break;
}
}
}
#else
if (inPragmaAssembly(parent))
{
blk = &BackEnd::instance().getAssembly();
}
#endif
c = new Class(decl, blk->depth());
blk->add(*c);
assert(decl.csym == c);
}
return c;
}
示例4: cpp_mangle_name
void cpp_mangle_name(Dsymbol *s)
{
Dsymbol *p = s->toParent();
bool dont_write_prefix = false;
if (p && p->isTemplateInstance())
{
s = p;
if (exist(p->isTemplateInstance()->tempdecl))
dont_write_prefix = true;
p = p->toParent();
}
if (p && !p->isModule())
{
buf.writeByte('N');
if (!dont_write_prefix)
prefix_name(p);
source_name(s);
buf.writeByte('E');
}
else
source_name(s);
}
示例5: ErrorExp
//.........这里部分代码省略.........
if (!ok)
return new ErrorExp();
RootObject *o = (*e->args)[0];
Dsymbol *s = getDsymbol(o);
if (!s)
{
if (!isError(o))
e->error("argument %s has no protection", o->toChars());
goto Lfalse;
}
if (s->scope)
s->semantic(s->scope);
PROT protection = s->prot();
const char *protName = Pprotectionnames[protection];
assert(protName);
StringExp *se = new StringExp(e->loc, (char *) protName);
return se->semantic(sc);
}
else if (e->ident == Id::parent)
{
if (dim != 1)
goto Ldimerror;
RootObject *o = (*e->args)[0];
Dsymbol *s = getDsymbol(o);
if (s)
{
if (FuncDeclaration *fd = s->isFuncDeclaration()) // Bugzilla 8943
s = fd->toAliasFunc();
if (!s->isImport()) // Bugzilla 8922
s = s->toParent();
}
if (!s || s->isImport())
{
e->error("argument %s has no parent", o->toChars());
goto Lfalse;
}
if (FuncDeclaration *f = s->isFuncDeclaration())
{
if (TemplateDeclaration *td = getFuncTemplateDecl(f))
{
if (td->overroot) // if not start of overloaded list of TemplateDeclaration's
td = td->overroot; // then get the start
Expression *ex = new TemplateExp(e->loc, td, f);
ex = ex->semantic(sc);
return ex;
}
if (FuncLiteralDeclaration *fld = f->isFuncLiteralDeclaration())
{
// Directly translate to VarExp instead of FuncExp
Expression *ex = new VarExp(e->loc, fld, 1);
return ex->semantic(sc);
}
}
return (new DsymbolExp(e->loc, s))->semantic(sc);
}
else if (e->ident == Id::hasMember ||
e->ident == Id::getMember ||
e->ident == Id::getOverloads ||
e->ident == Id::getVirtualMethods ||
示例6: toObjFile
//.........这里部分代码省略.........
*/
if (isVirtual() && (fensure || frequire))
f->Fflags3 |= Ffakeeh;
#endif
#if TARGET_OSX
s->Sclass = SCcomdat;
#else
s->Sclass = SCglobal;
#endif
for (Dsymbol *p = parent; p; p = p->parent)
{
if (p->isTemplateInstance())
{
s->Sclass = SCcomdat;
break;
}
}
/* Vector operations should be comdat's
*/
if (isArrayOp)
s->Sclass = SCcomdat;
if (isNested())
{
// if (!(config.flags3 & CFG3pic))
// s->Sclass = SCstatic;
f->Fflags3 |= Fnested;
/* The enclosing function must have its code generated first,
* so we know things like where its local symbols are stored.
*/
FuncDeclaration *fdp = toAliasFunc()->toParent2()->isFuncDeclaration();
// Bug 8016 - only include the function if it is a template instance
Dsymbol * owner = NULL;
if (fdp)
{ owner = fdp->toParent();
while (owner && !owner->isTemplateInstance())
owner = owner->toParent();
}
if (owner && fdp && fdp->semanticRun == PASSsemantic3done &&
!fdp->isUnitTestDeclaration())
{
/* Can't do unittest's out of order, they are order dependent in that their
* execution is done in lexical order, and some modules (std.datetime *cough*
* *cough*) rely on this.
*/
fdp->toObjFile(multiobj);
}
}
else
{
const char *libname = (global.params.symdebug)
? global.params.debuglibname
: global.params.defaultlibname;
// Pull in RTL startup code (but only once)
if (func->isMain() && onlyOneMain(loc))
{
#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
objmod->external_def("_main");
objmod->ehsections(); // initialize exception handling sections
#endif
#if TARGET_WINDOS
示例7: source_name
void source_name(Dsymbol *s)
{
char *name = s->ident->toChars();
TemplateInstance *ti = s->isTemplateInstance();
if (ti)
{
if (!substitute(ti->tempdecl))
{
store(ti->tempdecl);
name = ti->name->toChars();
buf.printf("%d%s", strlen(name), name);
}
buf.writeByte('I');
bool is_var_arg = false;
for (size_t i = 0; i < ti->tiargs->dim; i++)
{
RootObject *o = (RootObject *)(*ti->tiargs)[i];
TemplateParameter *tp = NULL;
TemplateValueParameter *tv = NULL;
TemplateTupleParameter *tt = NULL;
if (!is_var_arg)
{
TemplateDeclaration *td = ti->tempdecl->isTemplateDeclaration();
tp = (*td->parameters)[i];
tv = tp->isTemplateValueParameter();
tt = tp->isTemplateTupleParameter();
}
/*
* <template-arg> ::= <type> # type or template
* ::= <expr-primary> # simple expressions
*/
if (tt)
{
buf.writeByte('I');
is_var_arg = true;
tp = NULL;
}
if (tv)
{
// <expr-primary> ::= L <type> <value number> E # integer literal
if (tv->valType->isintegral())
{
Expression* e = isExpression(o);
assert(e);
buf.writeByte('L');
tv->valType->accept(this);
if (tv->valType->isunsigned())
{
buf.printf("%llu", e->toUInteger());
}
else
{
dinteger_t val = e->toInteger();
if (val < 0)
{
val = -val;
buf.writeByte('n');
}
buf.printf("%lld", val);
}
buf.writeByte('E');
}
else
{
s->error("ICE: C++ %s template value parameter is not supported", tv->valType->toChars());
assert(0);
}
}
else if (!tp || tp->isTemplateTypeParameter())
{
Type *t = isType(o);
assert(t);
t->accept(this);
}
else if (tp->isTemplateAliasParameter())
{
Dsymbol* d = isDsymbol(o);
Expression* e = isExpression(o);
if (!d && !e)
{
s->error("ICE: %s is unsupported parameter for C++ template: (%s)", o->toChars());
assert(0);
}
if (d && d->isFuncDeclaration())
{
bool is_nested = d->toParent() && !d->toParent()->isModule() && ((TypeFunction *)d->isFuncDeclaration()->type)->linkage == LINKcpp;
if (is_nested) buf.writeByte('X');
buf.writeByte('L');
mangle_function(d->isFuncDeclaration());
buf.writeByte('E');
if (is_nested) buf.writeByte('E');
}
else if (e && e->op == TOKvar && ((VarExp*)e)->var->isVarDeclaration())
{
VarDeclaration *vd = ((VarExp*)e)->var->isVarDeclaration();
buf.writeByte('L');
mangle_variable(vd, true);
//.........这里部分代码省略.........
示例8: if
//.........这里部分代码省略.........
{
ISDSYMBOL((d = s->isDeclaration()) != NULL && d->isOut())
}
else if (ident == Id::isLazy)
{
ISDSYMBOL((d = s->isDeclaration()) != NULL && d->storage_class & STClazy)
}
else if (ident == Id::identifier)
{ // Get identifier for symbol as a string literal
// Specify 0 for the flags argument to semanticTiargs() so that
// a symbol should not be folded to a constant.
TemplateInstance::semanticTiargs(loc, sc, args, 0);
if (dim != 1)
goto Ldimerror;
Object *o = (Object *)args->data[0];
Dsymbol *s = getDsymbol(o);
if (!s || !s->ident)
{
error("argument %s has no identifier", o->toChars());
goto Lfalse;
}
StringExp *se = new StringExp(loc, s->ident->toChars());
return se->semantic(sc);
}
else if (ident == Id::parent)
{
if (dim != 1)
goto Ldimerror;
Object *o = (Object *)args->data[0];
Dsymbol *s = getDsymbol(o);
if (s)
s = s->toParent();
if (!s)
{
error("argument %s has no parent", o->toChars());
goto Lfalse;
}
return (new DsymbolExp(loc, s))->semantic(sc);
}
#endif
else if (ident == Id::hasMember ||
ident == Id::getMember ||
ident == Id::getOverloads ||
ident == Id::getVirtualFunctions)
{
if (dim != 2)
goto Ldimerror;
Object *o = (Object *)args->data[0];
Expression *e = isExpression((Object *)args->data[1]);
if (!e)
{ error("expression expected as second argument of __traits %s", ident->toChars());
goto Lfalse;
}
e = e->optimize(WANTvalue | WANTinterpret);
if (e->op != TOKstring)
{ error("string expected as second argument of __traits %s instead of %s", ident->toChars(), e->toChars());
goto Lfalse;
}
StringExp *se = (StringExp *)e;
se = se->toUTF8(sc);
if (se->sz != 1)
{ error("string must be chars");
goto Lfalse;