Beispiel #1
0
Function* createFunction(const String& name, const Vector<Expression*>& args)
{
    if (!functionMap)
        createFunctionMap();

    if (!functionMap->contains(name)) {
        deleteAllValues(args);

        // Return a dummy function instead of 0.
        Function* funcTrue = functionMap->get("true").factoryFn();
        funcTrue->setName("true");
        return funcTrue;
    }

    FunctionRec functionRec = functionMap->get(name);
    if (!functionRec.args.contains(args.size())) {
        deleteAllValues(args);
        return 0;
    }

    Function* function = functionRec.factoryFn();
    function->setArguments(args);
    function->setName(name);
    return function;
}
Beispiel #2
0
Function* createFunction(const String& name, const Vector<Expression*>& args)
{
    if (!functionMap)
        createFunctionMap();

    HashMap<String, FunctionRec>::iterator functionMapIter = functionMap->find(name);
    FunctionRec* functionRec = 0;

    if (functionMapIter == functionMap->end() || !(functionRec = &functionMapIter->second)->args.contains(args.size()))
        return 0;

    Function* function = functionRec->factoryFn();
    function->setArguments(args);
    function->setName(name);
    return function;
}