示例#1
0
文件: pointers.c 项目: kton/ecs30
void operate(int*num, int*num2, int*num3) // NO printfs allowed here
{
  int *ptr1, *ptr2;
  
  if((ptr1 = read_address(1)) && check_address(ptr1, num, num2, num3)
    && (ptr2 = read_address(2)) && check_address(ptr2, num, num2, num3))
  {
    int operand = read_operand(); // read operand as int
    char operator = read_operator(); // read operator as char
    run_operation(ptr1, ptr2, operand, operator); // operate
  } // endif
  // done, thank god
} // operate();
示例#2
0
void operate(int *address1, int *address2, int *address3)
{
  int *ptr1, *ptr2, operand;
  char operator;
  ptr1 = read_address(1);
    // if the user inputs 2 addresses and they are both true call for operand and operator
  if (check_address(ptr1, address1, address2, address3) && (ptr2 = read_address(2)) && check_address(ptr2, address1, address2, address3))
  {
    operand = read_operand();
    operator = read_operator();
    run_operation(ptr1, ptr2, operand, operator);
  }
  return;
}//operate()
示例#3
0
bool script::run(const message::transaction& parent_tx, uint32_t input_index)
{
    stack_.clear();
    for (const operation oper: operations_)
    {
        log_debug() << "Run: " << opcode_to_string(oper.code);
        if (!run_operation(oper, parent_tx, input_index))
            return false;
        if (oper.data.size() > 0)
        {
            BITCOIN_ASSERT(oper.code == opcode::special ||
                oper.code == opcode::pushdata1 ||
                oper.code == opcode::pushdata2 ||
                oper.code == opcode::pushdata4);
            stack_.push_back(oper.data);
        }
    }
    if (stack_.size() != 0)
    {
        log_error() << "Script left junk on top of the stack";
        return false;
    }
    return true;
}