Пример #1
0
/// @todo Port this up to the new expression handling code
void MultiDispatch::operator()(
    RLMachine& machine,
    const libReallive::CommandElement& ff) {
  const ptr_vector<ExpressionPiece>& parameter_pieces = ff.getParameters();

  for (unsigned int i = 0; i < parameter_pieces.size(); ++i) {
    const ptr_vector<ExpressionPiece>& element =
        dynamic_cast<const ComplexExpressionPiece&>(parameter_pieces[i]).
        getContainedPieces();

    handler_->dispatch(machine, element);
  }

  machine.advanceInstructionPointer();
}
Пример #2
0
void RLOperation::dispatchFunction(RLMachine& machine,
                                   const CommandElement& ff) {
  if (!ff.areParametersParsed()) {
    vector<string> unparsed = ff.getUnparsedParameters();
    vector<unique_ptr<ExpressionPiece>> output;
    parseParameters(unparsed, output);
    ff.setParsedParameters(output);
  }

  const vector<unique_ptr<ExpressionPiece>>& parameter_pieces =
      ff.getParameters();

  // Now dispatch based on these parameters.
  dispatch(machine, parameter_pieces);

  // By default, we advacne the instruction pointer on any instruction we
  // perform. Weird special cases all derive from RLOp_SpecialCase, which
  // redefines the dispatcher, so this is ok.
  if (advanceInstructionPointer())
    machine.advanceInstructionPointer();
}
Пример #3
0
void ChildObjAdapter::operator()(RLMachine& machine,
                                 const libReallive::CommandElement& ff) {
  const ptr_vector<ExpressionPiece>& allParameters = ff.getParameters();

  // Range check the data
  if (allParameters.size() < 1)
    throw rlvm::Exception("Less than one argument to an objLayered function!");

  int objset = allParameters[0].integerValue(machine);

  // Copy everything after the first item
  ptr_vector<ExpressionPiece> currentInstantiation;
  ptr_vector<ExpressionPiece>::const_iterator it = allParameters.begin();
  ++it;
  for (; it != allParameters.end(); ++it) {
    currentInstantiation.push_back(it->clone());
  }

  handler->setProperty(P_PARENTOBJ, objset);
  handler->dispatch(machine, currentInstantiation);

  machine.advanceInstructionPointer();
}