Exemplo n.º 1
0
void QNetworkProtocol::processNextOperation( QNetworkOperation *old )
{
#ifdef QNETWORKPROTOCOL_DEBUG
    qDebug( "QNetworkOperation: process next operation, old: %p", old );
#endif
    d->removeTimer->stop();

    if ( old )
	d->oldOps.append( old );
    if ( d->opInProgress && d->opInProgress!=old )
	d->oldOps.append( d->opInProgress );

    if ( d->operationQueue.isEmpty() ) {
	d->opInProgress = 0;
	if ( d->autoDelete )
	    d->removeTimer->start( d->removeInterval, TRUE );
	return;
    }

    QNetworkOperation *op = d->operationQueue.head();

    d->opInProgress = 0;

    if ( !checkConnection( op ) ) {
	if ( op->state() != QNetworkProtocol::StFailed ) {
	    d->opStartTimer->start( 0, TRUE );
	    d->opInProgress = op;
	} else {
	    d->opInProgress = op;
	    d->operationQueue.dequeue();
	    clearOperationQueue();
	    emit finished( op );
	}

	return;
    }

    d->opInProgress = op;
    d->operationQueue.dequeue();
    processOperation( op );
}
Exemplo n.º 2
0
Value *ValueProcessor::processStatement(TokenList::const_iterator &i,
                                        TokenList::const_iterator &end,
                                        const ValueScope &scope,
                                        bool defaultVal) const {
  Value *op, *v;

  skipWhitespace(i, end);
  v = processConstant(i, end, scope, defaultVal);

  if (v != NULL) {
    skipWhitespace(i, end);

    while ((op = processOperation(i, end, *v, scope, OP_NONE, defaultVal)) != NULL) {
      delete v;
      v = op;

      skipWhitespace(i, end);
    }

    return v;
  } else
    return NULL;
}
Exemplo n.º 3
0
Value *ValueProcessor::processOperation(TokenList::const_iterator &i,
                                        TokenList::const_iterator &end,
                                        const Value &operand1,
                                        const ValueScope &scope,
                                        ValueProcessor::Operator lastop,
                                        bool defaultVal) const {
  TokenList::const_iterator tmp;
  const Value *operand2;
  Value *result;
  Operator op;
  const Token *opToken;

  if (i == end)
    return NULL;

  opToken = &(*i);
  tmp = i;

  if ((op = processOperator(tmp, end)) == OP_NONE ||
      (lastop != OP_NONE && lastop >= op))
    return NULL;

  i = tmp;
  skipWhitespace(i, end);

  operand2 = processConstant(i, end, scope, defaultVal);
  if (operand2 == NULL) {
    if (i == end)
      throw new ParseException("end of line",
                               "Constant or @-variable",
                               opToken->line,
                               opToken->column,
                               opToken->source);
    else
      throw new ParseException(
          *i, "Constant or @-variable", (*i).line, (*i).column, (*i).source);
  }

  skipWhitespace(i, end);

  while ((result = processOperation(i, end, *operand2, scope, op, defaultVal))) {
    delete operand2;
    operand2 = result;

    skipWhitespace(i, end);
  }

  if (op == OP_ADD)
    result = operand1 + *operand2;
  else if (op == OP_SUBSTRACT)
    result = operand1 - *operand2;
  else if (op == OP_MULTIPLY)
    result = operand1 * *operand2;
  else if (op == OP_DIVIDE)
    result = operand1 / *operand2;
  else if (op == OP_EQUALS)
    result = new BooleanValue(operand1 == *operand2);
  else if (op == OP_LESS)
    result = new BooleanValue(operand1 < *operand2);
  else if (op == OP_GREATER)
    result = new BooleanValue(operand1 > *operand2);
  else if (op == OP_LESS_EQUALS)
    result = new BooleanValue(operand1 <= *operand2);
  else if (op == OP_GREATER_EQUALS)
    result = new BooleanValue(operand1 >= *operand2);

  delete operand2;
  result->setLocation(*opToken);
  return result;
}