Пример #1
0
std::shared_ptr<ir::Expr> MathFuncDecl::getNew(
    std::vector<std::shared_ptr<ir::Expr>>& args,
    fabrica::TypeFactory* fact) const {
  // Type Checking
  if (args.size() != 1 || args[0] == nullptr)
    return nullptr;

  auto int_ty = fact->getTy(ir::IRConstString::INT);
  auto real_ty = fact->getTy(ir::IRConstString::DOUBLE);
  auto mat_ty = fact->getTy(ir::IRConstString::MATRIX);

  // Note: We accept Int/Real/Matrix
  if (args[0]->getTyp() != int_ty
    && args[0]->getTyp() != real_ty
    && args[0]->getTyp() != mat_ty)
    return nullptr;

  auto ret_ty = (args[0]->getTyp() == mat_ty ? mat_ty : real_ty);

  auto func = std::make_shared<ir::FunctionCall>(this);

  func->addArg(args[0]);

  // check randomness
  func->setRandom(func->get(0)->isRandom());
  func->setTyp(ret_ty);

  return func;
}
Пример #2
0
std::shared_ptr<ir::Expr> LoadRealMatrixFuncDecl::getNew(
    std::vector<std::shared_ptr<ir::Expr>>& args,
    fabrica::TypeFactory* fact) const {
  // Type Checking
  auto mat_ty = fact->getTy(ir::IRConstString::MATRIX);
  auto int_ty = fact->getTy(ir::IRConstString::INT);
  auto str_ty = fact->getTy(ir::IRConstString::STRING);
  if (args.size() < 1 || args[0] == nullptr || args[0]->getTyp() != str_ty)
    return nullptr;
  for (size_t i = 1; i < args.size(); ++i) {
    if (args[i] == nullptr || args[i]->getTyp() != int_ty)
      return nullptr;
  }
  if (args.size() > 5) return nullptr;
  if (args.size() == 4) return nullptr;

  auto func = std::make_shared<ir::FunctionCall>(this);

  func->setArgs(args);

  // check randomness
  for (auto& a : args) {
    if (a->isRandom())
      func->setRandom(true);
  }

  func->setTyp(mat_ty);

  return func;
}
Пример #3
0
GroupShareKey::GroupShareKey(QWidget *parent, const RsGxsGroupId &grpId, int grpType) :
	QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint), mGrpId(grpId), mGrpType(grpType)
{
	ui = new Ui::ShareKey();
	ui->setupUi(this);

	ui->headerFrame->setHeaderImage(QPixmap(":/images/user/agt_forum64.png"));
	ui->headerFrame->setHeaderText(tr("Share"));

	connect( ui->buttonBox, SIGNAL(accepted()), this, SLOT(shareKey()));
	connect( ui->buttonBox, SIGNAL(rejected()), this, SLOT(close()));

	/* initialize key share list */
	ui->keyShareList->setHeaderText(tr("Contacts:"));
	ui->keyShareList->setModus(FriendSelectionWidget::MODUS_CHECK);
	ui->keyShareList->setShowType(FriendSelectionWidget::SHOW_GROUP | FriendSelectionWidget::SHOW_SSL);
	ui->keyShareList->start();
	
	setTyp();
}
Пример #4
0
std::shared_ptr<ir::Expr> DiscreteDistrDecl::getNew(
    std::vector<std::shared_ptr<ir::Expr>>& args,
    fabrica::TypeFactory* fact) const {
  // Type Checking
  if (args.size() != 1 || args[0] == nullptr)
    return nullptr;

  // Note: We only accept array<double>
  auto dbl = fact->getTy(ir::IRConstString::DOUBLE);
  auto ary_dbl = fact->getUpdateTy(new ir::ArrayTy(dbl, 1));
  auto mtrx = fact->getTy(ir::IRConstString::MATRIX);
  if (args[0]->getTyp() != ary_dbl && args[0]->getTyp() != mtrx)
    return nullptr;

  auto ret = std::make_shared<ir::Distribution>(this->getName(), this);
  ret->setArgs(args);
  ret->setTyp(fact->getTy(ir::IRConstString::INT));
  ret->processArgRandomness();
  ret->setRandom(true);
  return ret;
}