void RexxInstructionAddress::execute( RexxActivation *context, /* current activation context */ RexxExpressionStack *stack ) /* evaluation stack */ /****************************************************************************/ /* Function: Execute a REXX LEAVE instruction */ /****************************************************************************/ { context->traceInstruction(this); /* trace if necessary */ /* is this an address toggle? */ if (this->environment == OREF_NULL && this->expression == OREF_NULL) { context->toggleAddress(); /* toggle the address settings */ context->pauseInstruction(); /* do debug pause if necessary */ } /* have a constant address name? */ else if (this->environment != OREF_NULL) { if (this->command != OREF_NULL) { /* actually the command form? */ /* get the expression value */ RexxObject *result = this->command->evaluate(context, stack); RexxString *_command = REQUEST_STRING(result);/* force to string form */ context->traceResult(_command); /* trace if necessary */ /* validate the address name */ SystemInterpreter::validateAddressName(this->environment); /* go process the command */ context->command(this->environment, _command); } else { /* just change the address */ /* validate the address name */ SystemInterpreter::validateAddressName(this->environment); /* now perform the switch */ context->setAddress(this->environment); context->pauseInstruction(); /* do debug pause if necessary */ } } else { /* we have an ADDRESS VALUE form */ /* get the expression value */ RexxObject *result = this->expression->evaluate(context, stack); RexxString *_address = REQUEST_STRING(result); /* force to string form */ context->traceResult(_address); /* trace if necessary */ SystemInterpreter::validateAddressName(_address); /* validate the address name */ context->setAddress(_address); /* just change the address */ context->pauseInstruction(); /* do debug pause if necessary */ } }
void RexxInstructionTrace::execute( RexxActivation *context, /* current activation context */ RexxExpressionStack *stack) /* evaluation stack */ /******************************************************************************/ /* Function: Execute a REXX TRACE instruction */ /******************************************************************************/ { RexxObject *result; /* expression result */ RexxString *value; /* string version of expression */ context->traceInstruction(this); /* trace if necessary */ // is this a debug skip request (the setting value is zero in that case) if ((traceSetting&TRACE_SETTING_MASK) == 0) { /* turn on the skip mode */ context->debugSkip(this->debugskip, (traceSetting&DEBUG_NOTRACE) != 0); } /* non-dynamic form? */ else if (this->expression == OREF_NULL) { if (!context->inDebug()) /* not in debug mode? */ { /* just change the setting */ context->setTrace(traceSetting, traceFlags); } else { context->pauseInstruction(); /* do debug pause if necessary */ } } else /* need to evaluate an expression */ { /* get the expression value */ result = this->expression->evaluate(context, stack); ProtectedObject p_result(result); value = REQUEST_STRING(result); /* force to string form */ ProtectedObject p_value(value); context->traceResult(result); /* trace if necessary */ if (!context->inDebug()) /* not in debug mode? */ { /* now change the setting */ context->setTrace(value); } else { context->pauseInstruction(); /* do debug pause if necessary */ } } }
void RexxInstructionCommand::execute( RexxActivation *context, /* current activation context */ RexxExpressionStack *stack ) /* evaluation stack */ /****************************************************************************/ /* Function: Execute a REXX command instruction */ /****************************************************************************/ { context->traceCommand(this); /* trace if necessary */ /* get the expression value */ RexxObject *result = this->expression->evaluate(context, stack); if (context->enableCommands()) { RexxString *command = REQUEST_STRING(result); /* force to string form */ /* are we tracing commands? */ if (context->tracingCommands()) { /* then we always trace full command */ context->traceValue((RexxObject *)command, TRACE_PREFIX_RESULT); } /* go process the command */ context->command(context->getAddress(), command); } else { if (result != OREF_NULL) /* result returned? */ { /* set the RESULT variable to the */ /* message return value */ context->setLocalVariable(OREF_RESULT, VARIABLE_RESULT, (RexxObject *)result); context->traceResult((RexxObject *)result); /* trace if necessary */ } else /* drop the variable RESULT */ { context->dropLocalVariable(OREF_RESULT, VARIABLE_RESULT); } } }
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 */ } }