Пример #1
0
/**
 * Return the information that needs to be saved in the saved
 * image.
 *
 * @return An array of the items added to the saved image.
 */
RexxArray *PackageManager::getImageData()
{

    RexxArray *imageArray = new_array(IMAGE_ARRAY_SIZE);
    imageArray->put(packages, IMAGE_PACKAGES);
    imageArray->put(packageRoutines, IMAGE_PACKAGE_ROUTINES);
    imageArray->put(registeredRoutines, IMAGE_REGISTERED_ROUTINES);
    imageArray->put(loadedRequires, IMAGE_REQUIRES);

    return imageArray;
}
Пример #2
0
/**
 * Run a routine for a thread context API call.
 */
void CallProgramDispatcher::run()
{
    RexxString *targetName = new_string(program);
    /* go resolve the name               */
    RexxString *name = activity->resolveProgramName(targetName, OREF_NULL, OREF_NULL);
    if (name == OREF_NULL)                /* not found?                        */
    {
        /* got an error here                 */
        reportException(Error_Program_unreadable_notfound, targetName);
    }
    ProtectedObject p(name);
    // create a routine from this file
    RoutineClass *routine = RoutineClass::fromFile(name);
    p = routine;

    if (arguments != OREF_NULL)
    {
        size_t argumentsCount = arguments->size();
        RexxArray *argumentsCopy = (RexxArray *)arguments->copy();
        ProtectedObject p(argumentsCopy);
        argumentsCopy->put(IntegerZero, argumentsCount + 1); // Counter of named arguments (Zero). To support correctly omitted positional arguments, don't use append!
        // use the provided name for the call name
        routine->runProgram(activity, argumentsCopy->data(), argumentsCount, result);
    }
    else
    {
        // we use a null string for the name when things are called directly
        routine->runProgram(activity, NULL, 0, result);
    }
}
Пример #3
0
/**
 * Extract from the method dictionary all methods defined with
 * a given scope.
 *
 * @param scope  The target scope.  If null, then all methods
 *               are returned.
 *
 * @return A supplier holding the names and methods with the target
 *         scope.  This supplier can be empty.
 */
RexxSupplier *RexxBehaviour::getMethods(RexxObject *scope)
{
    // if asking for everything, just return the supplier.
    if (scope == OREF_NULL)
    {
        return this->methodDictionary->supplier();
    }

    size_t count = 0;
    HashLink i;

    // travese the method dictionary, searching for methods with the target scope
    for (i = this->methodDictionary->first(); this->methodDictionary->index(i) != OREF_NULL; i = this->methodDictionary->next(i))
    {
        if (((RexxMethod *)this->methodDictionary->value(i))->getScope() == scope)
        {
            count++;
        }
    }

    RexxArray *names = new_array(count);
    RexxArray *methods = new_array(count);
    count = 1;

    // pass two, copy the entries into the array
    for (i = this->methodDictionary->first(); this->methodDictionary->index(i) != OREF_NULL; i = this->methodDictionary->next(i))
    {
        if (((RexxMethod *)this->methodDictionary->value(i))->getScope() == scope)
        {
            names->put(this->methodDictionary->index(i), count);
            methods->put(this->methodDictionary->value(i), count);
            count++;
        }
    }

    return (RexxSupplier *)new_supplier(methods, names);
}