Ejemplo n.º 1
0
vector<InvokeSet*> lookupInvokeSets(ObjectPtr callable) {
    assert(invokeTablesInitialized);
    vector<InvokeSet*> r;
    for (size_t i = 0; i < invokeTable.size(); ++i) {
        for (size_t j = 0; j < invokeTable[i].size(); ++j) {
            InvokeSet* set = invokeTable[i][j];
            if (objectEquals(set->callable, callable)) {
                r.push_back(set);
            }
        }
    }
    return r;
}
Ejemplo n.º 2
0
TypePtr staticType(ObjectPtr obj)
{
    int h = objectHash(obj);
    h &= staticTypes.size() - 1;
    vector<StaticTypePtr> &bucket = staticTypes[h];
    for (unsigned i = 0; i < bucket.size(); ++i) {
        if (objectEquals(obj, bucket[i]->obj))
            return bucket[i].ptr();
    }
    StaticTypePtr t = new StaticType(obj);
    bucket.push_back(t);
    return t.ptr();
}
Ejemplo n.º 3
0
InvokeSetPtr lookupInvokeSet(ObjectPtr callable,
                             const vector<TypePtr> &argsKey)
{
    if (!invokeTablesInitialized)
        initInvokeTables();
    int h = objectHash(callable) + objectVectorHash(argsKey);
    h &= (invokeTable.size() - 1);
    vector<InvokeSetPtr> &bucket = invokeTable[h];
    for (unsigned i = 0; i < bucket.size(); ++i) {
        InvokeSetPtr invokeSet = bucket[i];
        if (objectEquals(invokeSet->callable, callable) &&
            objectVectorEquals(invokeSet->argsKey, argsKey))
        {
            return invokeSet;
        }
    }
    OverloadPtr interface = callableInterface(callable);
    const vector<OverloadPtr> &overloads = callableOverloads(callable);
    InvokeSetPtr invokeSet = new InvokeSet(callable, argsKey, interface, overloads);
    bucket.push_back(invokeSet);
    return invokeSet;
}
Ejemplo n.º 4
0
InvokeSet* lookupInvokeSet(ObjectPtr callable,
                             llvm::ArrayRef<TypePtr> argsKey)
{
    if (!invokeTablesInitialized)
        initInvokeTables();
    int h = objectHash(callable) + objectVectorHash(argsKey);
    h &= (invokeTable.size() - 1);
    llvm::SmallVector<InvokeSet*, 2> &bucket = invokeTable[h];
    for (unsigned i = 0; i < bucket.size(); ++i) {
        InvokeSet* invokeSet = bucket[i];
        if (objectEquals(invokeSet->callable, callable) &&
            objectVectorEquals(invokeSet->argsKey, argsKey))
        {
            return invokeSet;
        }
    }
    OverloadPtr interface = callableInterface(callable);
    llvm::ArrayRef<OverloadPtr> overloads = callableOverloads(callable);
    InvokeSet* invokeSet = new InvokeSet(callable, argsKey, interface, overloads);
    invokeSet->shouldLog = shouldLogCallable(callable);

    bucket.push_back(invokeSet);
    return invokeSet;
}