Example #1
0
 ForEachItemIn(i2, expandedOrder)
 {
     IHqlExpression * cur = &expandedOrder.item(i2);
     if (explicitStepped)
     {
         if (!extractCondition(stepArgs, cur))
         {
             StringBuffer s;
             if (cur->getOperator() == no_select)
                 s.append(cur->queryChild(1)->queryName());
             else
                 getExprECL(cur, s);
             throwError1(HQLERR_SteppingNotMatchSortCondition, s.str());
         }
         if (stepArgs.ordinality() == 0)
             break;
     }
     else
     {
         if (!extractCondition(args, cur))
             break;
         foundStepped = true;
     }
     if (compareLhs)
         break;
 }
Example #2
0
void HqlCppLibrary::extractOutputs()
{
    HqlExprArray symbols;
    scopeExpr->queryScope()->getSymbols(symbols);

    IHqlScope * scope = scopeExpr->queryScope();
    HqlDummyLookupContext dummyctx(NULL);
    ForEachItemIn(i, symbols)
    {
        IHqlExpression & cur = symbols.item(i);
        if (isExported(&cur))
        {
            _ATOM name = cur.queryName();
            OwnedHqlExpr value = scope->lookupSymbol(name, LSFpublic, dummyctx);

            if (value && !value->isFunction())
            {
                if (value->isDataset() || value->isDatarow() || value->queryType()->isScalar())
                {
                    OwnedHqlExpr null = createNullExpr(value);
                    outputs.append(*cur.cloneAllAnnotations(null));
                }
            }
        }
    }
Example #3
0
unsigned getNumUniqueExpressions(const HqlExprArray & exprs)
{
    TransformMutexBlock block;
    ExpressionStatsInfo info;
    ForEachItemIn(i, exprs)
        calcNumUniqueExpressions(&exprs.item(i),info);
    return info.count;
}
Example #4
0
void LogicalGraphCreator::createLogicalGraph(HqlExprArray & exprs)
{
    graph.setown(createPTree("graph"));

//  beginSubGraph(NULL, false);
    ForEachItemIn(i, exprs)
        createRootGraphActivity(&exprs.item(i));
//  endSubGraph();
    wu->createGraph("Logical", NULL, GraphTypeEcl, graph.getClear(), 0);
}
Example #5
0
void ScopeConsistencyChecker::checkConsistent(IHqlExpression * root, const HqlExprArray & _activeTables)
{
    ForEachItemIn(i, _activeTables)
        activeTables.append(OLINK(_activeTables.item(i)));
    if (root->isDataset())
        pushScope();
    analyse(root, 0);
    if (root->isDataset())
        popScope();
}
static void getRootScopes(HqlScopeArray & rootScopes, IHqlScope * scope)
{
    HqlExprArray rootSymbols;
    scope->getSymbols(rootSymbols);
    ForEachItemIn(i, rootSymbols)
    {
        IHqlExpression & cur = rootSymbols.item(i);
        IHqlScope * scope = cur.queryScope();
        if (scope)
            rootScopes.append(*LINK(scope));
    }
Example #7
0
void LogicalGraphCreator::createLogicalGraph(HqlExprArray & exprs)
{
    graph.setown(createPTree("graph"));

//  beginSubGraph(NULL, false);
    ForEachItemIn(i, exprs)
        createRootGraphActivity(&exprs.item(i));
//  endSubGraph();

    Owned<IWUGraph> wug = wu->updateGraph("Logical");
    wug->setXGMMLTree(graph.getClear());
    wug->setType(GraphTypeEcl);
}
bool HqlGram::checkTemplateFunctionParameters(IHqlExpression* func, HqlExprArray& actuals, const attribute& errpos)
{
    bool anyErrors = false;
    IHqlExpression * formals = func->queryChild(1);
    ForEachItemIn(idx, actuals)
    {
        IHqlExpression* formal = formals->queryChild(idx);
        if (isAbstractDataset(formal))
        {
            IHqlExpression * actual = &actuals.item(idx);
            IHqlExpression* mapping = queryFieldMap(actual);
            bool hadError = false;
            OwnedHqlExpr ignore = processAbstractDataset(NULL, formal, actual, mapping, errpos, true, hadError);
            if (hadError)
                anyErrors = true;
        }
    }
Example #9
0
void reportAbstractModule(IErrorReceiver & errors, IHqlExpression * expr, const ECLlocation & errpos)
{
    IHqlScope * scope = expr->queryScope();
    StringBuffer fieldText;
    if (scope)
    {
        HqlExprArray symbols;
        scope->getSymbols(symbols);
        symbols.sort(compareSymbolsByName);
        ForEachItemIn(i, symbols)
        {
            IHqlExpression & cur = symbols.item(i);
            if (isPureVirtual(&cur))
            {
                if (fieldText.length())
                    fieldText.append(",");
                fieldText.append(cur.queryName());
            }
        }
    }
Example #10
0
void ViewTransformerRegistry::addPlugins(const char * name)
{
    loadedPlugins.setown(new SafePluginMap(&pluginCtx, true));
    loadedPlugins->loadFromList(name);

    Owned<IErrorReceiver> errorReporter = createThrowingErrorReceiver();
    dataServer.setown(createNewSourceFileEclRepository(errorReporter, name, ESFallowplugins, 0));

    HqlScopeArray scopes;
    HqlParseContext parseCtx(dataServer, NULL, NULL);
    HqlLookupContext ctx(parseCtx, errorReporter);
    getRootScopes(scopes, dataServer, ctx);

    ForEachItemIn(i, scopes)
    {
        IHqlScope * scope = &scopes.item(i);
        HqlExprArray symbols;
        try
        {
            scope->ensureSymbolsDefined(ctx);
            scope->getSymbols(symbols);

            ForEachItemIn(j, symbols)
            {
                IHqlExpression & cur = symbols.item(j);
                if (cur.getOperator() == no_service)
                    addServiceDefinition(&cur);
            }
        }
        catch (IException * e)
        {
            const char * name = str(scope->queryName());
            VStringBuffer msg("Error loading plugin %s", name);
            EXCLOG(e, msg.str());
        }
    }
Example #11
0
void HqlCppCaseInfo::addPairs(HqlExprArray & _pairs)
{
    pairs.ensure(_pairs.ordinality());
    ForEachItemIn(idx, _pairs)
        addPair(&_pairs.item(idx));
}
Example #12
0
IHqlExpression * HqlCppCaseInfo::buildIndexedMap(BuildCtx & ctx, const CHqlBoundExpr & test)
{
    ITypeInfo * compareType = test.queryType()->queryPromotedType();
    type_t compareTypeCode = compareType->getTypeCode();

    HqlExprArray values;
    IHqlExpression * dft = queryActiveTableSelector();  // value doesn't matter as long as it will not occur
    __int64 lower = getIntValue(lowerTableBound, 0);
    unsigned num = (getIntValue(upperTableBound, 0)-lower)+1;

    CHqlBoundExpr indexExpr;
    switch (compareTypeCode)
    {
        case type_int:
            indexExpr.set(test);
            break;
        case type_string:
            indexExpr.expr.setown(createValue(no_index, makeCharType(), LINK(test.expr), getZero()));
            indexExpr.expr.setown(createValue(no_cast, makeIntType(1, false), LINK(indexExpr.expr)));
            break;
        default:
            throwUnexpectedType(compareType);
    }

    if (useRangeIndex && (num != 1))
        translator.ensureSimpleExpr(ctx, indexExpr);

    OwnedHqlExpr mapped;
    ITypeInfo * retType = resultType;
    //if num == pairs.ordinality() and all results are identical, avoid the table lookup.
    if (allResultsMatch && (num == pairs.ordinality()))
    {
        mapped.set(pairs.item(0).queryChild(1));
    }
    else
    {
        values.ensure(num);
        unsigned idx;
        for (idx = 0; idx < num; idx++)
            values.append(*LINK(dft));

        ForEachItemIn(idx2, pairs)
        {
            IHqlExpression & cur = pairs.item(idx2);
            IValue * value = cur.queryChild(0)->queryValue();
            unsigned replaceIndex;
            switch (compareTypeCode)
            {
            case type_int:
                replaceIndex = (unsigned)(value->getIntValue()-lower);
                break;
            case type_string:
                {
                    StringBuffer temp;
                    value->getStringValue(temp);
                    replaceIndex = (unsigned)((unsigned char)temp.charAt(0)-lower);
                    break;
                }
            default:
                throwUnexpectedType(compareType);
            }

            IHqlExpression * mapTo = cur.queryChild(1);
            if (mapTo->getOperator() != no_constant)
                throwUnexpected();
            if (replaceIndex >= num)
                translator.reportWarning(CategoryIgnored, HQLWRN_CaseCanNeverMatch, "CASE entry %d can never match the test condition", replaceIndex);
            else
                values.replace(*LINK(mapTo),replaceIndex);
        }

        //Now replace the placeholders with the default values.
        for (idx = 0; idx < num; idx++)
        {
            if (&values.item(idx) == dft)
                values.replace(*defaultValue.getLink(),idx);
        }

        // use a var string type to get better C++ generated...
        ITypeInfo * storeType = getArrayElementType(resultType);
        ITypeInfo * listType = makeArrayType(storeType, values.ordinality());
        OwnedHqlExpr lvalues = createValue(no_list, listType, values);

        CHqlBoundExpr boundTable;
        translator.buildExpr(ctx, lvalues, boundTable);

        LinkedHqlExpr tableIndex = indexExpr.expr;
        if (getIntValue(lowerTableBound, 0))
            tableIndex.setown(createValue(no_sub, tableIndex->getType(), LINK(tableIndex), LINK(lowerTableBound)));

        IHqlExpression * ret = createValue(no_index, LINK(retType), LINK(boundTable.expr), LINK(tableIndex));
        mapped.setown(createTranslatedOwned(ret));
    }