Exemplo n.º 1
0
void VarDeclaration::checkNestedReference(Scope *sc, Loc loc)
{
    //printf("VarDeclaration::checkNestedReference() %s\n", toChars());
    if (parent && !isDataseg() && parent != sc->parent)
    {
        // The function that this variable is in
        FuncDeclaration *fdv = toParent()->isFuncDeclaration();
        // The current function
        FuncDeclaration *fdthis = sc->parent->isFuncDeclaration();

        if (fdv && fdthis)
        {
            if (loc.filename)
                fdthis->getLevel(loc, fdv);
            nestedref = 1;
            fdv->nestedFrameRef = 1;
#if IN_LLVM
#if DMDV1
        fdv->nestedVars.insert(this);
#endif
#endif
            //printf("var %s in function %s is nested ref\n", toChars(), fdv->toChars());
            // __dollar creates problems because it isn't a real variable Bugzilla 3326
            if (ident == Id::dollar)
                ::error(loc, "cannnot use $ inside a function literal");
        }
    }
}
Exemplo n.º 2
0
void VarDeclaration::checkNestedReference(Scope *sc, Loc loc)
{
    //printf("VarDeclaration::checkNestedReference() %s\n", toChars());
    if (parent && !isDataseg() && parent != sc->parent)
    {
        // The function that this variable is in
        FuncDeclaration *fdv = toParent()->isFuncDeclaration();
        // The current function
        FuncDeclaration *fdthis = sc->parent->isFuncDeclaration();

        if (fdv && fdthis)
        {
            if (loc.filename)
                fdthis->getLevel(loc, fdv);
            nestedref = 1;
            fdv->nestedFrameRef = 1;
            //printf("var %s in function %s is nested ref\n", toChars(), fdv->toChars());
        }
    }
}