/** * Supplier initializer for suppliers created via * .supplier~new(values, indexes). * * @param values The values array object * @param indexes The indexes array object * * @return Nothing */ RexxObject *RexxSupplier::initRexx(RexxArray *_values, RexxArray *_indexes) { requiredArgument(_values, ARG_ONE); // both values are required requiredArgument(_indexes, ARG_TWO); // now verify both values RexxArray *new_values = REQUEST_ARRAY(_values); RexxArray *new_indexes = REQUEST_ARRAY(_indexes); if (new_values == (RexxArray *)TheNilObject || new_values->getDimension() != 1) { reportException(Error_Incorrect_method_noarray, values); } if (new_indexes == (RexxArray *)TheNilObject || new_indexes->getDimension() != 1) { reportException(Error_Incorrect_method_noarray, indexes); } OrefSet(this, this->values, new_values); OrefSet(this, this->indexes, new_indexes); this->position = 1; return OREF_NULL; }
void RexxInstructionForward::execute( RexxActivation *context, /* current activation context */ RexxExpressionStack *stack) /* evaluation stack */ /******************************************************************************/ /* Function: Execute a forward instruction */ /******************************************************************************/ { RexxObject *_target; /* evaluated target */ RexxString *_message; /* evaluated message */ RexxObject *_superClass; /* evaluated super class */ RexxObject *result; /* message result */ RexxObject *temp; /* temporary object */ size_t count = 0; /* count of array expressions */ size_t i; /* loop counter */ RexxObject **_arguments; ProtectedObject p_message; context->traceInstruction(this); /* trace if necessary */ if (!context->inMethod()) /* is this a method clause? */ { /* raise an error */ reportException(Error_Execution_forward); } _target = OREF_NULL; /* no object yet */ _message = OREF_NULL; /* no message over ride */ _superClass = OREF_NULL; /* no super class over ride */ _arguments = OREF_NULL; /* no argument over ride */ if (this->target != OREF_NULL) /* sent to a different object? */ { /* get the expression value */ _target = this->target->evaluate(context, stack); } if (this->message != OREF_NULL) /* sending a different message? */ { /* get the expression value */ temp = this->message->evaluate(context, stack); _message = REQUEST_STRING(temp); /* get the string version */ p_message = _message; _message = _message->upper(); /* and force to uppercase */ p_message = _message; } if (this->superClass != OREF_NULL) /* overriding the super class? */ { /* get the expression value */ _superClass = this->superClass->evaluate(context, stack); } if (this->arguments != OREF_NULL) /* overriding the arguments? */ { /* get the expression value */ temp = this->arguments->evaluate(context, stack); /* get an array version */ RexxArray *argArray = REQUEST_ARRAY(temp); stack->push(argArray); /* protect this on the stack */ /* not an array item or a multiple */ /* dimension one? */ if (argArray == TheNilObject || argArray->getDimension() != 1) { /* this is an error */ reportException(Error_Execution_forward_arguments); } count = argArray->size(); /* get the size */ /* omitted trailing arguments? */ if (count != 0 && argArray->get(count) == OREF_NULL) { count--; /* decrement the count */ while (count > 0) /* loop down to first full one */ { /* find a real argument */ if (argArray->get(count) != OREF_NULL) { break; /* break out of here */ } count--; /* step back the count */ } } _arguments = argArray->data(); /* point directly to the argument data */ } if (this->array != OREF_NULL) /* have an array of extra info? */ { count = this->array->size(); /* get the expression count */ for (i = 1; i <= count; i++) /* loop through the expression list */ { RexxObject *argElement = this->array->get(i); /* real argument? */ if (argElement != OREF_NULL) { /* evaluate the expression */ argElement->evaluate(context, stack); } else { /* just push a null reference for the missing ones */ stack->push(OREF_NULL); } } /* now point at the stacked values */ _arguments = stack->arguments(count); } /* go forward this */ result = context->forward(_target, _message, _superClass, _arguments, count, instructionFlags&forward_continue); if (instructionFlags&forward_continue) /* not exiting? */ { if (result != OREF_NULL) /* result returned? */ { context->traceResult(result); /* trace if necessary */ /* set the RESULT variable to the */ /* message return value */ context->setLocalVariable(OREF_RESULT, VARIABLE_RESULT, result); } else /* drop the variable RESULT */ { context->dropLocalVariable(OREF_RESULT, VARIABLE_RESULT); } context->pauseInstruction(); /* do debug pause if necessary */ } }