Пример #1
0
/**
 * Resolve the "stem.[a,b,c]=" to the equivalent stem.a.b.c= form,
 * with all of the indices taken as constants
 *
 * @param tailElements
 *                 The array of arguments.  the first argument is the
 *                 assigned value.  All additional arguments are the
 *                 tail pieces.
 * @param argCount The count of arguments.
 *
 * @return Returns nothing.
 */
RexxObject *StemClass::bracketEqual(RexxObject **tailElements, size_t argCount)
{

    // no value to set?  This is an error
    if (argCount == 0)
    {
        reportException(Error_Incorrect_method_noarg, IntegerOne);
    }
    RexxObject *newValue = requiredArgument(tailElements[0], ARG_ONE);

    // if the argument count is 1, we're just setting the default value
    if (argCount == 1)
    {
        // stem value as default?  don't allow this as it leads to recursion loops
        if (isStem(newValue))
        {
            reportException(Error_Execution_nostem);
        }

        setField(value, newValue);
        // this clears out all of our elements and gets marked as having an
        // explicit value.
        tails.clear();
        dropped = false;
        return OREF_NULL;
    }

    // create a searchable tail from the array elements
    // and set the variable value
    CompoundVariableTail resolved_tail((RexxInternalObject **)(tailElements + 1), argCount - 1);
    CompoundTableElement *variable = getCompoundVariable(resolved_tail);
    variable->set(newValue);
    return OREF_NULL;
}
Пример #2
0
/**
 * Remove an item from the collection.  This is essentially
 * equivalent to a drop operation on the stem variable.
 *
 * @param tails    The set of tail indexes.
 * @param argCount The number of indexes.
 *
 * @return The removed object.  If nothing was removed, this returns
 *         .nil.
 */
RexxInternalObject *StemClass::remove(RexxObject **tailElements, size_t argCount)
{
    // if asked to remove the default value, reset this back to the name
    if (argCount == 0)
    {
        // replace with the name and return the old value.
        RexxInternalObject *oldValue = value;
        setField(value, getName());
        return oldValue;
    }

    // compose the tail element
    CompoundVariableTail resolved_tail((RexxInternalObject **)tailElements, argCount);
    CompoundTableElement *compound = findCompoundVariable(resolved_tail);
    // if there's a variable there, and it has a real value, then
    // we have something to remove
    if (compound != OREF_NULL && compound->getVariableValue() != OREF_NULL)
    {
        // get the value, which is the return value, and drop the variable.
        RexxInternalObject *oldValue = compound->getVariableValue();
        compound->drop();
        return oldValue;
    }
    return TheNilObject;       // nothing dropped.
}
Пример #3
0
/**
 * Perform a lookup on a stem object.
 *
 * @param tailElements
 *                 The array of tail elements used to construct
 *                 the tail.  All tail elements are constants at
 *                 this point.
 * @param argCount The count of tail arguments.
 *
 * @return The compound variable lookup value.
 */
RexxInternalObject *StemClass::bracket(RexxObject **tailElements, size_t argCount)
{
    // no arguments just returns the default value
    if (argCount == 0)
    {
        return value;
    }
    // create a searchable tail, and perform the lookup
    CompoundVariableTail resolved_tail((RexxInternalObject **)tailElements, argCount);
    return evaluateCompoundVariableValue(OREF_NULL, stemName, resolved_tail);
}
Пример #4
0
/**
 * Test if this compound variable has a given index.
 *
 * @param tails    The set of tail expressions.
 * @param argCount The argument count
 *
 * @return True if the fully resolved tail exists in the stem, false
 *         otherwise.
 */
RexxObject *StemClass::hasIndex(RexxObject **tailElements, size_t argCount)
{
    if (argCount == 0)
    {
        return TheTrueObject;          // we always have something here
    }
    // compose the tail element
    CompoundVariableTail resolved_tail((RexxInternalObject **)tailElements, argCount);
    // see if we have a compound
    CompoundTableElement *compound = findCompoundVariable(resolved_tail);
    // if there's a variable there, and it has a real value, then
    // this is true.
    return booleanObject(compound != OREF_NULL && compound->getVariableValue() != OREF_NULL);
}
Пример #5
0
RexxCompoundElement *RexxCompoundTable::findEntry(RexxString *tail, bool create)
{
                                       /* process the tail and search */
    RexxCompoundTail resolved_tail(tail);
    return findEntry(&resolved_tail, create);
}
Пример #6
0
/**
 * Drop an array element for an API class.
 *
 * @param tail   The direct tail value.
 */
void StemClass::dropElement(const char *tail)
{
    CompoundVariableTail resolved_tail(tail);
    dropElement(resolved_tail);
}
Пример #7
0
/**
 * Drop an array element for an API class.
 *
 * @param tail   The direct tail value.
 */
void StemClass::dropElement(size_t tail)
{
    CompoundVariableTail resolved_tail(tail);
    dropElement(resolved_tail);
}
Пример #8
0
/**
 * Evaluate an array element for an API class.
 *
 * @param tail   The direct tail value.
 *
 * @return The object value.  If the stem element does not exist or
 *         has been dropped, this returns OREF_NULL.
 */
RexxObject *StemClass::getElement(const char *tail)
{

    CompoundVariableTail resolved_tail(tail);
    return getElement(resolved_tail);
}
Пример #9
0
/**
 * Set a single stem variable object using a simple string
 * value tail as a result of an api call.
 *
 * @param tail   The index of the target value.
 * @param value  The new value to assign.
 */
void StemClass::setElement(size_t tail, RexxObject *newValue)
{
    CompoundVariableTail resolved_tail(tail);
    RexxVariable *variable = getCompoundVariable(resolved_tail);
    variable->set(newValue);
}