Example #1
0
bool
sp::AreFunctionTypesEqual(FunctionType *a, FunctionType *b)
{
  FunctionSignature *af = a->signature();
  FunctionSignature *bf = b->signature();
  if (!AreTypesEquivalent(af->returnType().resolved(),
                          bf->returnType().resolved(),
                          Qualifiers::None))
  {
    return false;
  }

  ParameterList *ap = af->parameters();
  ParameterList *bp = bf->parameters();
  if (ap->length() != bp->length())
    return false;

  for (size_t i = 0; i < ap->length(); i++) {
    VarDecl *arga = ap->at(i);
    VarDecl *argb = bp->at(i);
    if (!AreTypesEquivalent(arga->te().resolved(),
                            argb->te().resolved(),
                            Qualifiers::None))
    {
      return false;
    }
  }
  return true;
}
Example #2
0
/* Action 1: StartBattle */
void EventInterpreter::action1(Event *e) {
	ParameterList *params = getParameters(e);

	if(params->at(0)->isInteger() && !e->isLocked() && params->at(1)->isBoolean()) {
		Troop *troop = ResourceHelper::getTroop(*(int*)(params->at(0)->value()));
		gk::ApplicationStateStack::getInstance().push<BattleState>(troop, *(bool*)(params->at(1)->value()));

		e->lock();
	}
	else {
		e->currentActionID(*(int*)params->at(2 + EventListener::lastBattleResult())->value());

		e->unlock();
	}
}
Example #3
0
/* Action 0: DrawText */
void EventInterpreter::action0(Event *e) {
	ParameterList *params = getParameters(e);

	if(params->at(0)->isString() && !e->isLocked()) {
		gk::ApplicationStateStack::getInstance().push<MessageState>(*(std::string*)(params->at(0)->value()));
		e->lock();
	}
	else {
		if(params->size() == 2 && params->at(1)->isInteger()) {
			e->currentActionID(*(int*)params->at(1)->value());
		}

		e->unlock();
		update(e);
	}
}
Example #4
0
/* Action 2: AskQuestion */
void EventInterpreter::action2(Event *e) {
	ParameterList *params = getParameters(e);

	if(params->at(0)->isString() && !e->isLocked()) {
		MessageState &state = gk::ApplicationStateStack::getInstance().push<MessageState>(*(std::string*)(params->at(0)->value()));

		for(u16 i = 1 ; i < params->size() ; i+=2) {
			if(params->at(i)->isString()) {
				state.addCommand(*(std::string*)params->at(i)->value());
			}
		}

		e->lock();
	}
	else {
		if(params->at((SelectableWindow::lastPos + 1) * 2)->isInteger()) {
			e->currentActionID(*(int*)params->at((SelectableWindow::lastPos + 1) * 2)->value());
		}

		e->unlock();
		update(e);
	}
}
double costDrive(const ParameterList & parameterList, predicateCallbackType predicateCallback, numericalFluentCallbackType numericalFluentCallback, int relaxed)
{
   ROS_DEBUG("Calling %s module", __func__);

   string from = parameterList.at(0).value;
   string to = parameterList.at(1).value;

   //cout << "driving from " << from << " to " << to << endl;

   if(from == "l1") {
      if(to == "l1") {
         return 1.0;
      } else if(to == "l2") {
         return 10.0;
      } else if(to == "l3") {
         return 42.0;
      }
   } else if(from == "l2") {
      if(to == "l1") {
         return 10.0;
      } else if(to == "l2") {
         return 1.0;
      } else if(to == "l3") {
         return 10.0;
      }
   } else if(from == "l3") {
      if(to == "l1") {
         return 42.0;
      } else if(to == "l2") {
         return 10.0;
      } else if(to == "l3") {
         return 1.0;
      }
   }

   return 1.0;
}
Example #6
0
int Loadable::writeToDB(const QByteArray &pdata, const QString pkgname,
                        QString &errMsg, ParameterList &params)
{
  params.append("name",   _name);
  params.append("type",   _pkgitemtype);
  params.append("source", QString(pdata));
  params.append("notes",  _comment);

  // alter the name of the loadable's table if necessary
  QString destschema = "public";
  QString prefix;
  if (_schema.isEmpty()        &&   pkgname.isEmpty())
    ;   // leave it alone
  else if (_schema.isEmpty()   && ! pkgname.isEmpty())
  {
    prefix = "pkg";
    destschema = pkgname;
  }
  else if ("public" == _schema &&   pkgname.isEmpty())
    ;   // leave it alone
  else if ("public" == _schema && ! pkgname.isEmpty())
    prefix = "public.";
  else if (! _schema.isEmpty())
  {
    prefix = _schema + ".pkg";
    destschema = _schema;
  }

  if (! prefix.isEmpty())
  {
    params.append("pkgname", destschema);

    // yuck - no Parameter::operator==(Parameter&) and no replace()
    QString tablename = params.value("tablename").toString();
    for (int i = 0; i < params.size(); i++)
    {
      if (params.at(i).name() == "tablename")
      {
        params.takeAt(i);
        params.append("tablename", prefix + tablename);
        break;
      }
    }
  }

  if (_minMql && _minMql->isValid() && _grade == INT_MIN)
  {
    XSqlQuery minOrder = _minMql->toQuery(params);
    if (minOrder.first())
      _grade = minOrder.value(0).toInt();
    else if (minOrder.lastError().type() != QSqlError::NoError)
    {
      QSqlError err = minOrder.lastError();
      errMsg = _sqlerrtxt.arg(_filename).arg(err.driverText()).arg(err.databaseText());
      return -3;
    }
    else
      _grade = 0;
  }
  else if (_maxMql && _maxMql->isValid() && _grade == INT_MAX)
  {
    XSqlQuery maxOrder = _maxMql->toQuery(params);
    if (maxOrder.first())
      _grade = maxOrder.value(0).toInt();
    else if (maxOrder.lastError().type() != QSqlError::NoError)
    {
      QSqlError err = maxOrder.lastError();
      errMsg = _sqlerrtxt.arg(_filename).arg(err.driverText()).arg(err.databaseText());
      return -4;
    }
    else
      _grade = 0;
  }

  params.append("grade", _grade);

  XSqlQuery select;
  int itemid = -1;
  select = _selectMql->toQuery(params);

  if (select.first())
    itemid = select.value(0).toInt();
  else if (select.lastError().type() != QSqlError::NoError)
  {
    QSqlError err = select.lastError();
    errMsg = _sqlerrtxt.arg(_filename).arg(err.driverText()).arg(err.databaseText());
    return -5;
  }
  params.append("id", itemid);

  XSqlQuery upsert;
  if (itemid >= 0)
    upsert = _updateMql->toQuery(params);
  else
    upsert = _insertMql->toQuery(params);

  if (upsert.first())
    itemid = upsert.value("id").toInt();
  else if (upsert.lastError().type() != QSqlError::NoError)
  {
    QSqlError err = upsert.lastError();
    errMsg = _sqlerrtxt.arg(_filename)
                .arg(err.driverText())
                .arg(err.databaseText());
    return -7;
  }

  return itemid;
}