Exemple #1
0
void RexxEnvelope::addTable(
    RexxObject *obj)                   /* table object to rehash            */
/******************************************************************************/
/* Function:  Add an object to the rehash table for later processing          */
/******************************************************************************/
{
    /*  the following table will be used */
    /* by the table_unflatten method.    */
    /*                                   */
    /* Every table that gets unflattened */
    /* place itself in this table.  Once */
    /* every object has been unflattened */
    /* we traverse this table and allow  */
    /* the hashtables to re-hash their   */
    /* since some hash value may have    */
    /* change                            */
    if (this->rehashtable == OREF_NULL)  /* first table added?                */
    {
        /* create the table now              */
        OrefSet(this, this->rehashtable, new_identity_table());
    }
    /* use put to make sure we only get  */
    /* a single version of each table    */
    this->rehashtable->put(TheNilObject, obj);
}
/**
 * Initialize an interpreter instance.
 *
 * @param activity The root activity for the interpreter instance.
 * @param handlers The exit handlers used by all threads running under this instance.
 * @param defaultEnvironment
 *                 The default address environment for this interpreter instance.  Each
 *                 active interpreter instance can define its own default environment.
 */
void InterpreterInstance::initialize(RexxActivity *activity, RexxOption *options)
{
    rootActivity = activity;
    allActivities = new_list();
    searchExtensions = new_list();     // this will be filled in during options processing
    requiresFiles = new_directory();   // our list of loaded requires packages
    // this gets added to the entire active list.
    allActivities->append((RexxObject *)activity);
    globalReferences = new_identity_table();
    // create a default wrapper for this security manager
    securityManager = new SecurityManager(OREF_NULL);
    // set the default system address environment (can be overridden by options)
    defaultEnvironment = SystemInterpreter::getDefaultAddressName();
    // our list of command handlers (must be done before options are processed)
    commandHandlers = new_directory();

    // associate the thread with this instance
    activity->setupAttachedActivity(this);
    // create a local environment
    localEnvironment = new_directory();
    processOptions(options);
    // when handled originally, we didn't have the exits setup
    // do this now.
    activity->setupExits();
    // do system specific initialization
    sysInstance.initialize(this, options);
    // register the system command handlers for this platform.
    sysInstance.registerCommandHandlers(this);
    // now do the local initialization;
    Interpreter::initLocal();
}
/**
 * Request that an activity be informed of any variable
 * modifications.
 *
 * @param informee The requesting activity.
 */
void RexxVariable::inform(Activity *informee)
{
    // we don't typically have a dependents list until the
    // first time this is needed
    if (dependents == OREF_NULL)
    {
        // use an object table for this
        setField(dependents, new_identity_table());
    }
    // add this to the table as the index
    dependents->put(TheNilObject, informee);
}
Exemple #4
0
void RexxVariable::inform(
     RexxActivity *informee)           /* activity to inform of changes     */
/****************************************************************************/
/* Function:  Set up an activity notification for a variable change         */
/****************************************************************************/
{
    if (this->dependents == OREF_NULL)   /* no dependents yet?                */
    {
        /* set this up as an object table    */
        OrefSet(this, this->dependents, new_identity_table());
    }
    /* add this to the table             */
    this->dependents->put(TheNilObject, (RexxObject *)informee);
}
Exemple #5
0
RexxObject *RexxBehaviour::addScope(
    RexxObject *scope)                 /* new scope for the scope table     */
/******************************************************************************/
/* Function:  Set a new set of scoping information for an object              */
/******************************************************************************/
{
    if (this->scopes == OREF_NULL)       /* no scopes set?                     */
    {
        /* add a scope table to add to        */
        OrefSet(this, this->scopes, new_identity_table());
    }
    /* set the scoping info              */
    this->scopes->add(scope, TheNilObject);
    /* add the scope list for this scope */
    this->scopes->add(this->scopes->allAt(TheNilObject), scope);
    return OREF_NULL;                    /* return the big nothing            */
}
Exemple #6
0
RexxBuffer *RexxEnvelope::pack(
    RexxObject *_receiver)              /* the receiver object               */
/******************************************************************************/
/* Function:  Pack an envelope item                                           */
/******************************************************************************/
{
    RexxObject *flattenObj;              /* flattened object                  */
    RexxObject *newSelf;                 /* the flattened envelope            */
    RexxObject *firstObject;             /* first object to flatten           */

    OrefSet(this, this->receiver, _receiver);
    // create a save table to protect any objects (such as proxy
    // objects) we create during flattening.
    OrefSet(this, this->savetable, new_identity_table());
    OrefSet(this, this->duptable, new_identity_table());
    // this is a bit of a hack, but necessary.  This allows us to store
    // object offsets into a hashtable without having the hashtable
    // attempt to mark the references.
    duptable->contents->setHasNoReferences();
    OrefSet(this, this->buffer, new RexxSmartBuffer(DEFAULT_ENVELOPE_BUFFER));
    // get a flatten stack from the memory object
    this->flattenStack = memoryObject.getFlattenStack();
    // push unique terminator onto stack
    this->flattenStack->fastPush(OREF_NULL);

    // First, put a header into the buffer.  This is necessary because without
    // it, the envelope object would be at 0 offset into the buffer, which is not
    // distinguishable from OREF_NULL when the objects are unpacked from buffer.


    // the header is just a dummy minimal object instance.  We don't bother adding
    // this to the dup table, as it won't ever be duped.
    this->copyBuffer(TheObjectClass->newObject());
    // we start the flattening process with the received object
    firstObject = this->receiver;

    this->currentOffset = this->copyBuffer(firstObject);
    // make sure we add this to the dup table in case it's self-referential at any point
    associateObject(firstObject, this->currentOffset);
    /* point to the copied one           */
    newSelf = (RexxObject *)(this->bufferStart() + this->currentOffset);

    // ok, keep flattening until will find our marker object on the stack
    newSelf->flatten(this);              /* start the flatten process.        */

    for (flattenObj = this->flattenStack->fastPop();
        flattenObj != OREF_NULL;
        flattenObj = this->flattenStack->fastPop())
    {
        // the popped object is actuall an object offset.  We need to convert this into a
        // real object pointer
        this->currentOffset = (size_t)flattenObj;
        flattenObj = (RexxObject *)(this->bufferStart() + this->currentOffset);
        // and flatten the next object
        flattenObj->flatten(this);         /* let this obj flatten its refs     */
    }
    memoryObject.returnFlattenStack();   /* done with the flatten stack       */
    // now unwrap the smart buffer and fix the length of the real buffer
    // behind it to the size we've written to it.
    RexxBuffer *letter = buffer->getBuffer();
    letter->setDataLength(buffer->getDataLength());
    return letter;
}