Ejemplo n.º 1
0
void unittest_aa()
{
    AA* aa = NULL;
    Value v = _aaGetRvalue(aa, NULL);
    assert(!v);
    Value *pv = _aaGet(&aa, NULL);
    assert(pv);
    *pv = (void *)3;
    v = _aaGetRvalue(aa, NULL);
    assert(v == (void *)3);
}
Ejemplo n.º 2
0
/**
 * Collects all unit test functions from the given array of symbols.
 *
 * This is a helper function used by the implementation of __traits(getUnitTests).
 *
 * Input:
 *      symbols             array of symbols to collect the functions from
 *      uniqueUnitTests     an associative array (should actually be a set) to
 *                          keep track of already collected functions. We're
 *                          using an AA here to avoid doing a linear search of unitTests
 *
 * Output:
 *      unitTests           array of DsymbolExp's of the collected unit test functions
 *      uniqueUnitTests     updated with symbols from unitTests[ ]
 */
static void collectUnitTests(Dsymbols *symbols, AA *uniqueUnitTests, Expressions *unitTests)
{
    if (!symbols)
        return;
    for (size_t i = 0; i < symbols->dim; i++)
    {
        Dsymbol *symbol = (*symbols)[i];
        UnitTestDeclaration *unitTest = symbol->isUnitTestDeclaration();
        if (unitTest)
        {
            if (!_aaGetRvalue(uniqueUnitTests, unitTest))
            {
                FuncAliasDeclaration* alias = new FuncAliasDeclaration(unitTest, 0);
                alias->protection = unitTest->protection;
                Expression* e = new DsymbolExp(Loc(), alias);
                unitTests->push(e);
                bool* value = (bool*) _aaGet(&uniqueUnitTests, unitTest);
                *value = true;
            }
        }
        else
        {
            AttribDeclaration *attrDecl = symbol->isAttribDeclaration();

            if (attrDecl)
            {
                Dsymbols *decl = attrDecl->include(NULL, NULL);
                collectUnitTests(decl, uniqueUnitTests, unitTests);
            }
        }
    }
}
Ejemplo n.º 3
0
Dsymbol *DsymbolTable::lookup(Identifier *ident)
{
#if STRINGTABLE
#ifdef DEBUG
    assert(ident);
    assert(tab);
#endif
    //printf("DsymbolTable::lookup(%s)\n", (char*)ident->string);
    StringValue *sv = tab->lookup((char*)ident->string, ident->len);
    return (Dsymbol *)(sv ? sv->ptrvalue : NULL);
#else
    //printf("DsymbolTable::lookup(%s)\n", (char*)ident->string);
    return (Dsymbol *)_aaGetRvalue(tab, ident);
#endif
}
Ejemplo n.º 4
0
Archivo: dsymbol.c Proyecto: olgk/ldc
Dsymbol *DsymbolTable::lookup(Identifier *ident)
{
    //printf("DsymbolTable::lookup(%s)\n", (char*)ident->string);
    return (Dsymbol *)_aaGetRvalue(tab, ident);
}