예제 #1
0
void test_f_InfoClientes() {
    ParqueEstacionamento p1(10,20);
	p1.novo_cliente("Joao Santos");
	p1.novo_cliente("Pedro Morais");
	p1.novo_cliente("Rui Silva");
	p1.novo_cliente("Susana Costa");
	p1.novo_cliente("Maria Tavares");
	p1.entrar("Maria Tavares");
	p1.entrar("Susana Costa");
	p1.sair("Susana Costa");
	p1.entrar("Rui Silva");
	p1.entrar("Susana Costa");
	ASSERTM("Este teste nunca falha! VERIFICAR informação escrita no monitor", true);
	cout << p1;
	InfoCartao ic=p1.get_cliente_pos(2);
	ASSERT_EQUAL("Rui Silva", ic.nome);

	ASSERT_THROWS(p1.get_cliente_pos(6), PosicaoNaoExistente);
	try {
		p1.get_cliente_pos(6);
	}
	catch (PosicaoNaoExistente &e) {
		ASSERTM("Este teste nunca falha. Verifique no monitor a informação", true);
		cout << "Apanhou excepção. Posição não existente:" << e.getValor() << endl;
		ASSERT_EQUAL(6, e.getValor());
	}
}
예제 #2
0
파일: test_db.cpp 프로젝트: Hoglet/TimeIT
void database_testUpgrade()
{
	const char* dbname="/tmp/dbtest.db";
	createVersion4db(dbname);
	Database db("/tmp/dbtest.db");
	shared_ptr<ITaskAccessor> taskAccessor=db.getTaskAccessor();
	ASSERT_EQUALM("Numbers of tasks in tasks", 2, taskAccessor->getTasksChangedSince()->size());
	shared_ptr<Task> task1 = taskAccessor->getTask(1);
	ASSERT_EQUALM("Task 1 name ", string("Test"),task1->getName());
	ASSERT_EQUALM("Task 1 parent ", 0, task1->getParentID());
	ASSERTM("Task 1 uuid is valid ", UUID::isValid(task1->getUUID()));

	shared_ptr<Task> task2 = taskAccessor->getTask(2);
	ASSERT_EQUALM("Task 2 name ", string("Sub task"),task2->getName());
	ASSERT_EQUALM("Task 2 parent ", 1, task2->getParentID());
	ASSERTM("Task 2 uuid is valid ", UUID::isValid(task2->getUUID()));

	shared_ptr<ITimeAccessor> timeAccessor=db.getTimeAccessor();
	shared_ptr<vector<TimeEntry>> times=timeAccessor->getTimesChangedSince();
	ASSERT_EQUALM("Number of times ",1, times->size());
	TimeEntry te = times->at(0);
	ASSERT_EQUALM("Time id ", 1, te.getID());
	ASSERTM("Time uuid is valid ", UUID::isValid(te.getUUID()));
	ASSERT_EQUALM("Time taskID ", 2, te.getTaskID());
	ASSERT_EQUALM("Time start ", 10, te.getStart());
	ASSERT_EQUALM("Time stop ", 100, te.getStop());

	OSAbstraction::unlink("/tmp/dbtest.db");
}
예제 #3
0
/*---------------------------------------------------------------------*//**
	GUI の作成実装
**//*---------------------------------------------------------------------*/
EtkGui* AtArBody::makeGui()
{
	// 固定データの初期化
	if(!AtArFixedData::init())
	{
		ASSERTM(false, "FixedData::init failed.");
		return 0L;
	}

	// フォントセットの作成
	AtArFontSet* fontset = new AtArFontSet();
	if(!fontset->create())
	{
		delete fontset;
		ASSERTM(false, "GameFontSet::create failed.");
		return 0L;
	}
	_fontset = fontset;

	// GUI の作成
	AtArGui* gui = new AtArGui();
	if(!gui->create(_fontset, _tasksys))
	{
		delete gui;
		ASSERTM(false, "GameGui::create failed.");
		return 0L;
	}
	return gui;
}
예제 #4
0
void
specifyVar(uint u_varIndex, volatile void* pv_data, uint u_size,
           BOOL b_isWriteable, char* psz_format, char* psz_name,
           char* psz_desc) {
  uint u_len;

  // Make sure this variable exists
  ASSERTM("specifyVar:indexTooHigh", u_varIndex < NUM_XFER_VARS);
  // Make sure the data isn't NULL
  ASSERTM("specifyVar:nullData", pv_data != NULL);
  // Make sure the size is valid
  ASSERTM("specifyVar:invalidSize", (u_size > 0) && (u_size <= 256));

  // Update data structure
  xferVar[u_varIndex].pu8_data = (uint8_t*) pv_data;
  xferVar[u_varIndex].u8_size = u_size - 1;
  assignBit(u_varIndex, b_isWriteable);

  // Send a command
  OUT_CHAR(CMD_TOKEN);

  // Send a specification: The spec code, index, then length
  outCharXfer(b_isWriteable ? CMD_SEND_RECEIVE_VAR : CMD_SEND_ONLY);
  outCharXfer(u_varIndex);
  // Include the space taken by the three NULL characters, minus one since a
  // length of 1 is sent as 0, plus one for the variable size byte.
  u_len = strlen(psz_format) + strlen(psz_name) + strlen(psz_desc) + 3 - 1 + 1;
  // Allow a maximum string length of 255.
  outCharXfer(u_len <= 255 ? u_len : 255);

  // Send the size of this variable, minus 1 since a size of 1 is sent as a 0.
  outCharXfer(u_size - 1);

  // Send the strings
  u_len = 1;
  do {
    if (u_len++ > 256) return;
    outCharXfer(*psz_format);
  } while (*psz_format++);
  do {
    if (u_len++ > 256) return;
    outCharXfer(*psz_name);
  } while (*psz_name++);
  do {
    if (u_len++ > 256) return;
    outCharXfer(*psz_desc);
  } while (*psz_desc++);
}
예제 #5
0
		static void testLogicOperators()
		{
			float x=10.1,y=23.5,z=13.54;
			Z3D_Base::Vector3f temp(x,y,z), temp1(x,y,z);

			ASSERTM("Test failed for vector3f in operator arithematic(vector): x==y", (Z3D_Base::Vector3f)temp==(Z3D_Base::Vector3f)temp1);
		}
예제 #6
0
void ConfigEntryTest::testGetIntegerFormattedOptions() {
	std::string entr_str = "command option1=1 option2=2 option3=3";
	ConfigEntry conf_entry(entr_str);
	std::map<std::string, int> intmap = conf_entry.getIntegerFormattedOptions();

	// forall in intmap
	{
		std::map<std::string, int>::const_iterator it_intmap = intmap.begin();
		const std::map<std::string, int>::const_iterator it_intmap_end = intmap.end();
		while (it_intmap != it_intmap_end) {
			std::string opt = it_intmap->first;
			int val = it_intmap->second;

			if (opt == "option1") {
				ASSERT_EQUAL(1, val);
			} else if (opt == "option2") {
				ASSERT_EQUAL(2, val);
			} else if (opt == "option3") {
				ASSERT_EQUAL(3, val);
			} else {
				std::cout << "ConfigEntryTest::testGetIntegerFormattedOptions: " << "'" << opt << "'" << ":" << "'"
						<< val << "'" << std::endl;
				ASSERTM("Unknown option!", false);
			}
			++it_intmap;
		}
	}
}
예제 #7
0
void multiplyTest() {
        Calculate calc;
        int first = 5;
        int second = 5;

        ASSERTM("Multiplication was incorrect!", 25 == calc.multiply(first, second));
}
예제 #8
0
void subTest() {
        Calculate calc;
        int first = 5;
        int second = 3;

        ASSERTM("Subtraction was incorrect!", 2 == calc.sub(first, second));
}
예제 #9
0
void TimeEntry_setDeleted()
{
	TimeEntry te=getTestTimeEntry();
	time_t now=time(0);
	te.setDeleted(true);
	ASSERT_EQUAL(true, te.getDeleted());
	ASSERTM("Changed time should be at current time", te.getLastChanged()>=now);
}
예제 #10
0
void TimeEntry_changeEndTime()
{
	TimeEntry te=getTestTimeEntry();
	time_t now=time(0);
	te.setStop(2000);
	ASSERT_EQUAL(2000, te.getStop());
	ASSERTM("Changed time should be at current time", te.getLastChanged()>=now);
}
예제 #11
0
void sumTest() {
        Calculate calc;
        int first = 5;
        int second = 5;

        ASSERTM("Summation was incorrect!", 10 == calc.sum(first, second));

}
void Assertion::ASSERT_ANY_COMPARE(const ROAnything &inputAny, const ROAnything &masterAny, String location, char delimSlot, char idxdelim) {
	OStringStream s;
	String failingPath(location);
	if(!AnyUtils::AnyCompareEqual(inputAny, masterAny, failingPath,&s, delimSlot, idxdelim)) {
		String strfail(failingPath);
		strfail << "\n" << s.str();
		ASSERTM((const char*)strfail, false);
	}
}
void testValidInput() {
    char user_input[20] = {'1','2','3','4'};
    char good_input[20] = {'1','2','3','4'};
    int i = 0;
    while(user_input[i] != '\0' && user_input[i] != '\n' && i<20)
    {
        ASSERTM("Failed Valid Input Test", validateSelection(user_input[i],good_input));
        i++;
    }
}
예제 #14
0
			// Must define void operator() with no arguments
			void IXMLWriterTest::operator()()
			{
				writeXMLHeader();
				writeElement();
				writeComment();
				writeClosingTag();
				writeText();
				writeLineBreak();

				ASSERTM(mes.c_str(), mes.size() == 0);
			}
예제 #15
0
/*---------------------------------------------------------------------*//**
	テストモジュールの作成実装
**//*---------------------------------------------------------------------*/
Test* AtArBody::makeTest(f32 spfRender, f32 spfLogic)
{
	Test* test = new AtArTest();
	if(!test->create(spfRender, spfLogic))
	{
		delete test;
		ASSERTM(false, "Test::create failed.");
		return 0L;
	}
	return test;
}
void testSpecialCharacters()
{
    char user_input[4] = {'@', '!', '%', '$'};
    char good_input[20] = {'1','2','3', 'a', 'b', 's'};
    int i = 0;
    while ((user_input[i] != '\0') && (user_input[i] != '\n') && i<4)
    {
        ASSERTM("Failed Special Character Test", !validateSelection(user_input[i],good_input));
        i++;
    }
}
예제 #17
0
/*---------------------------------------------------------------------*//**
	アクションメッセージウインドウの作成実装
**//*---------------------------------------------------------------------*/
ActionMsgWindow* DimzGui::makeActionMsgWindow()
{
	// アクションメッセージウインドウを作成する
	ActionMsgWindow* wndActMsg = new ActionMsgWindow();
	if(!wndActMsg->create(_fontsetRef->getMainGuiFont(), _texGui))
	{
		delete wndActMsg;
		ASSERTM(false, "GameActMsgWindow::create failed.");
		return false;
	}
	return wndActMsg;
}
void testOutOfRange()
{
    char user_input[3] = {'0', '5', '6'};
    char good_input[20] = {'1','2','3','4'};
    int i = 0;
    while ((user_input[i] != '\0') && (user_input[i] != '\n') && i<3)
    {
        //printf("Input tested: %s\n", user_input[i]);
        ASSERTM("Failed Out of Range Test", !validateSelection(user_input[i],good_input));
        i++;
    }
}
예제 #19
0
void
sendVar(uint u_varIndex) {
  XFER_VAR* pXferVar;
  uint8_t u8_size;
  uint8_t* pu8_data;
  // Make sure this variable exists
  ASSERTM("sendVar:indexTooHigh", u_varIndex < NUM_XFER_VARS);
  // Note: The MS C compiler flags the statement
  // XFER_VAR* pXferVar = xferVar + u_varIndex;
  // as an error. It's OK in MS C++. Apparently, the C compiler doesn't
  // support the newer C99 syntax. Therefore, u8_size and pu8_data are
  // also declared above.
  pXferVar = xferVar + u_varIndex;
  ASSERTM("sendVar:indexNotSpecified", pXferVar->pu8_data != NULL);
  // Make sure it's read/write (PC only)
#ifndef __PIC__
  ASSERTM("sendVar:notWriteable", isVarWriteable(u_varIndex));
#endif

  // Send a command
  OUT_CHAR(CMD_TOKEN);

  // Send short/long var info
  u8_size = pXferVar->u8_size;
  if ((u8_size + 1) > SHORT_VAR_MAX_LEN) {
    // Send a long var: The long var code, index, then length
    outCharXfer(CMD_LONG_VAR);
    outCharXfer(u_varIndex);
    outCharXfer(u8_size);
  } else {
    // Send a short var
    outCharXfer((u_varIndex << VAR_SIZE_BITS) | u8_size);
  }

  // Send data
  pu8_data = pXferVar->pu8_data;
  do {
    outCharXfer(*pu8_data++);
  } while (u8_size--);
}
예제 #20
0
void test_g_InfoFrota() {

	Veiculo *v1 =new Automovel("Fiat",5,1997,"gasolina",1200);
	Veiculo *v2= new Camiao("Ford",3,1999,"gasolina",1400,1000);
	Veiculo *v3=new Bicicleta("XX",4,2002,"TodoTerreno");
	Frota f;
	f.adicionaVeiculo(v1);
	f.adicionaVeiculo(v2);
	f.adicionaVeiculo(v3);
	ASSERTM("Este teste nunca falha! VERIFICAR informação escrita no monitor", true);
	f.info();

}
예제 #21
0
int
formatVar(uint u_varIndex, char* psz_buf) {
  XFER_VAR* pXferVar;
  uint8_t u8_size;
  unsigned long long ull_buf = 0;  // The biggest data type available

  // Make sure this variable exists
  ASSERTM("formatVar:indexTooHigh", u_varIndex < NUM_XFER_VARS);
  // Note: The MS C compiler flags the statement
  // XFER_VAR* pXferVar = xferVar + u_varIndex;
  // as an error. It's OK in MS C++. Apparently, the C compiler doesn't
  // support the newer C99 syntax. Therefore, u8_size and pu8_data are
  // also declared above.
  pXferVar = xferVar + u_varIndex;
  ASSERTM("formatVar:indexNotSpecified", pXferVar->pu8_data != NULL);
  u8_size = pXferVar->u8_size + 1;

  // Copy the data over to the largest available var for formatting
  ASSERT(u8_size <= sizeof(ull_buf));
  memcpy(&ull_buf, pXferVar->pu8_data, u8_size);
  return sprintf(psz_buf, pXferVar->psz_format, ull_buf);
}
예제 #22
0
SRCR_BEGIN_NS

////////////////////////////////////////////////////////////////////////////
// クラス

//==========================================================================
// Flag メソッド

/*---------------------------------------------------------------------*//**
	XML 要素から読み込む
**//*---------------------------------------------------------------------*/
bool Flag::analyze(ActMatter* owner, const XmlNode* node, const EventMatterCreateParam* emcp)
{
	if(!Act::analyze(owner, node, emcp))
	{
		return false;
	}

	s32 iwk;

	// [オプション(いずれか必須)]表示か非表示か
	if(XmlParserUtils::analyzeAtrb(&iwk, node, "sfid"))
	{
		_sfid = iwk;
	}

	// [オプション(いずれか必須)]クエスト汎用値識別番号(クエスト用)
	if(XmlParserUtils::analyzeAtrb(&iwk, node, "quest_gval"))
	{
		_questgval = iwk;
	}

	// [オプション]新しい値
	if(XmlParserUtils::analyzeAtrb(&iwk, node, "value"))
	{
		_value = iwk;
	}

	// スキップ確認
	//	※	この Act はスキップすると致命的なバグになりかねないので、
	//		デフォルトでは、スキップを防止すべきと考える
	ASSERTM(TFW_IS_FLAG(_flags, F_NOSKIP | F_SKIPONLY | F_SKIPSTOP), "{Flag::analyze} Illegal skip-flag setting of Flag-Act.");
	if(!TFW_IS_FLAG(_flags, F_NOSKIP | F_SKIPONLY | F_SKIPSTOP))
	{
		TFW_SET_FLAG(_flags, F_NOSKIP, true);
	}

	return true;
}
예제 #23
0
/*---------------------------------------------------------------------*//**
	言語変更通知
**//*---------------------------------------------------------------------*/
void DimzGui::notifyChangeLanguage()
{
	// 親へ通知
	EtkGui::notifyChangeLanguage();

	// GUI テクスチャの再読み込み
	if(_texGui != 0L)
	{
		_texGui->destroy();
		if(!_texGui->create(FILEID_CONV_LANG( FILEID_CONV_RD( SYSTEM_GUI01_SD_EN_PNG ) ), Texture::FMT_PNG))
		{
			ASSERTM(false, "{notifyChangeLanguage} DimzGui Texture - create failed.");
		}
	}
}
예제 #24
0
/*---------------------------------------------------------------------*//**
	初期化
**//*---------------------------------------------------------------------*/
bool DimzBody::init(s32 widthView, s32 heightView, f32 scaleContent, TfwRightAngle rotz, f32 spfRender, f32 spfLogic, LangId langidDefault, StartBodyCase sbcase, u32 bcflags, OsDepMod* osdep, PsnsBase* psns)
{
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	// 基本設定

	#if defined(_DEBUG) && defined(_WINDOWS) && IS_WINDOWS_IDFILE_DEVMODE_UNPACK
		IdFile::enableDevMode(g_filedefTbfPack, "");
	#endif

	// 親クラス(ツールキット)による初期化
	if(!EtkBody::init(widthView, heightView, scaleContent, rotz, spfRender, spfLogic, langidDefault, sbcase, bcflags, osdep, psns))
	{
		return false;
	}

	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	// 各ゲームモジュールの初期化

#if 0
	// ソウマ スクリプトを作成する
	SoumaScript* script = new SoumaScript();
	if(!script->create())
	{
		delete script;
		ASSERTM(false, "SoumaScript::create failed.");
		return false;
	}
	_script = script;
#endif

	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	// ゲームシステムの開始

	#if DEBUG_FULLMODE
		debug_onDebugMode(999);
	#endif

	// フェードイン
	if(_screffScn != 0L)
	{
		ColorU8 colBlack(0, 0, 0, 255);
		_screffScn->setColor1(&colBlack);
		_screffScn->setMaxFrame(30);
		_screffScn->start(ScreenEffect::MODE_FADE_IN);
	}

	return true;
}
예제 #25
0
/*---------------------------------------------------------------------*//**
	パーティクルシステムの作成実装
**//*---------------------------------------------------------------------*/
ParticleSys* AtArBody::makeParticleSys()
{
	const ParticleDefTbl* ptcldftbl = AtArFixedData::getParticleDefTable();

	etk::SorSgm* sg = (etk::SorSgm*)getSceneGraphManager();
	SgNodeChain* sgnc = sg->getKindChain(etk::SorSgm::EK_ZSORT);

	ParticleSys* ptclsys = new AtArParticleSys();
	if(!ptclsys->create(ptcldftbl, sgnc))
	{
		delete ptclsys;
		ASSERTM(false, "ParticleSys::create failed.");
		return false;
	}
	return ptclsys;
}
예제 #26
0
/*---------------------------------------------------------------------*//**
	システムメッセージウインドウの作成実装
**//*---------------------------------------------------------------------*/
SysMsgWindow* DimzGui::makeSysMsgWindow()
{
	// システムメッセージウインドウを作成する
	SysMsgWindow* wndSysMsg = new SysMsgWindow();
	if(!wndSysMsg->create(
		_fontsetRef->getMainGuiFont(),
		_texGui,
		DimzFixedStrTbl::getString(DimzFixedStrTbl::SID_YES),
		DimzFixedStrTbl::getString(DimzFixedStrTbl::SID_NO)	))
	{
		delete wndSysMsg;
		ASSERTM(false, "GameSysMsgWindow::create failed.");
		return false;
	}
	return wndSysMsg;
}
예제 #27
0
/*---------------------------------------------------------------------*//**
	作成
**//*---------------------------------------------------------------------*/
bool DimzGui::create(FontSet* fontsetRef, FedTaskSys* tasksys)
{
	// GUI テクスチャの読み込み
	Texture* texGui = new Texture();
	if(!texGui->create(FILEID_CONV_LANG( FILEID_CONV_RD( SYSTEM_GUI01_SD_EN_PNG ) ), Texture::FMT_PNG))
	{
		delete texGui;
		ASSERTM(false, "gui Texture::create failed.");
		return false;
	}
	_texGui = texGui;

	// 親の作成
	if(!EtkGui::create(fontsetRef, tasksys))
	{
		return false;
	}

	return true;
}
예제 #28
0
void SimpleCollectionTest::testGetValueAt() {
	SimpleCollection<int> sc;

	sc.add(1);
	sc.add(2);
	sc.add(3);

	int first = sc[0];
	int last = sc[2];
	ASSERT_EQUAL(1, first);
	ASSERT_EQUAL(3, last);

	// test exception
	try {
		int none = sc[4];
		// add this to make use of pedantic int
		std::cout<<"SimpleCollectionTest::testGetValueAt: "<<"sc[4]="<<none<<std::endl;
		ASSERTM("Exception missed!", false);
	} catch (exceptions::IndexOutOfBoundsException & except) {
		ASSERT(true);
	}
}
예제 #29
0
파일: Evac.c 프로젝트: 23Skidoo/ghc
REGPARM1 GNUC_ATTR_HOT void
evacuate(StgClosure **p)
{
  bdescr *bd = NULL;
  nat gen_no;
  StgClosure *q;
  const StgInfoTable *info;
  StgWord tag;

  q = *p;

loop:
  /* The tag and the pointer are split, to be merged after evacing */
  tag = GET_CLOSURE_TAG(q);
  q = UNTAG_CLOSURE(q);

  ASSERTM(LOOKS_LIKE_CLOSURE_PTR(q), "invalid closure, info=%p", q->header.info);

  if (!HEAP_ALLOCED_GC(q)) {

      if (!major_gc) return;

      info = get_itbl(q);
      switch (info->type) {

      case THUNK_STATIC:
          if (info->srt_bitmap != 0) {
              evacuate_static_object(THUNK_STATIC_LINK((StgClosure *)q), q);
          }
          return;

      case FUN_STATIC:
          if (info->srt_bitmap != 0) {
              evacuate_static_object(FUN_STATIC_LINK((StgClosure *)q), q);
          }
          return;

      case IND_STATIC:
          /* If q->saved_info != NULL, then it's a revertible CAF - it'll be
           * on the CAF list, so don't do anything with it here (we'll
           * scavenge it later).
           */
          evacuate_static_object(IND_STATIC_LINK((StgClosure *)q), q);
          return;

      case CONSTR_STATIC:
          evacuate_static_object(STATIC_LINK(info,(StgClosure *)q), q);
          return;

      case CONSTR_NOCAF_STATIC:
          /* no need to put these on the static linked list, they don't need
           * to be scavenged.
           */
          return;

      default:
          barf("evacuate(static): strange closure type %d", (int)(info->type));
      }
  }

  bd = Bdescr((P_)q);

  if ((bd->flags & (BF_LARGE | BF_MARKED | BF_EVACUATED)) != 0) {

      // pointer into to-space: just return it.  It might be a pointer
      // into a generation that we aren't collecting (> N), or it
      // might just be a pointer into to-space.  The latter doesn't
      // happen often, but allowing it makes certain things a bit
      // easier; e.g. scavenging an object is idempotent, so it's OK to
      // have an object on the mutable list multiple times.
      if (bd->flags & BF_EVACUATED) {
          // We aren't copying this object, so we have to check
          // whether it is already in the target generation.  (this is
          // the write barrier).
          if (bd->gen_no < gct->evac_gen_no) {
              gct->failed_to_evac = rtsTrue;
              TICK_GC_FAILED_PROMOTION();
          }
          return;
      }

      /* evacuate large objects by re-linking them onto a different list.
       */
      if (bd->flags & BF_LARGE) {
          evacuate_large((P_)q);
          return;
      }

      /* If the object is in a gen that we're compacting, then we
       * need to use an alternative evacuate procedure.
       */
      if (!is_marked((P_)q,bd)) {
          mark((P_)q,bd);
          push_mark_stack((P_)q);
      }
      return;
  }

  gen_no = bd->dest_no;

  info = q->header.info;
  if (IS_FORWARDING_PTR(info))
  {
    /* Already evacuated, just return the forwarding address.
     * HOWEVER: if the requested destination generation (gct->evac_gen) is
     * older than the actual generation (because the object was
     * already evacuated to a younger generation) then we have to
     * set the gct->failed_to_evac flag to indicate that we couldn't
     * manage to promote the object to the desired generation.
     */
    /*
     * Optimisation: the check is fairly expensive, but we can often
     * shortcut it if either the required generation is 0, or the
     * current object (the EVACUATED) is in a high enough generation.
     * We know that an EVACUATED always points to an object in the
     * same or an older generation.  gen is the lowest generation that the
     * current object would be evacuated to, so we only do the full
     * check if gen is too low.
     */
      StgClosure *e = (StgClosure*)UN_FORWARDING_PTR(info);
      *p = TAG_CLOSURE(tag,e);
      if (gen_no < gct->evac_gen_no) {  // optimisation
          if (Bdescr((P_)e)->gen_no < gct->evac_gen_no) {
              gct->failed_to_evac = rtsTrue;
              TICK_GC_FAILED_PROMOTION();
          }
      }
      return;
  }

  switch (INFO_PTR_TO_STRUCT(info)->type) {

  case WHITEHOLE:
      goto loop;

  // For ints and chars of low value, save space by replacing references to
  //    these with closures with references to common, shared ones in the RTS.
  //
  // * Except when compiling into Windows DLLs which don't support cross-package
  //    data references very well.
  //
  case CONSTR_0_1:
  {
#if defined(COMPILING_WINDOWS_DLL)
      copy_tag_nolock(p,info,q,sizeofW(StgHeader)+1,gen_no,tag);
#else
      StgWord w = (StgWord)q->payload[0];
      if (info == Czh_con_info &&
          // unsigned, so always true:  (StgChar)w >= MIN_CHARLIKE &&
          (StgChar)w <= MAX_CHARLIKE) {
          *p =  TAG_CLOSURE(tag,
                            (StgClosure *)CHARLIKE_CLOSURE((StgChar)w)
                           );
      }
      else if (info == Izh_con_info &&
          (StgInt)w >= MIN_INTLIKE && (StgInt)w <= MAX_INTLIKE) {
          *p = TAG_CLOSURE(tag,
                             (StgClosure *)INTLIKE_CLOSURE((StgInt)w)
                             );
      }
      else {
          copy_tag_nolock(p,info,q,sizeofW(StgHeader)+1,gen_no,tag);
      }
#endif
      return;
  }

  case FUN_0_1:
  case FUN_1_0:
  case CONSTR_1_0:
      copy_tag_nolock(p,info,q,sizeofW(StgHeader)+1,gen_no,tag);
      return;

  case THUNK_1_0:
  case THUNK_0_1:
      copy(p,info,q,sizeofW(StgThunk)+1,gen_no);
      return;

  case THUNK_1_1:
  case THUNK_2_0:
  case THUNK_0_2:
#ifdef NO_PROMOTE_THUNKS
#error bitrotted
#endif
    copy(p,info,q,sizeofW(StgThunk)+2,gen_no);
    return;

  case FUN_1_1:
  case FUN_2_0:
  case FUN_0_2:
  case CONSTR_1_1:
  case CONSTR_2_0:
      copy_tag_nolock(p,info,q,sizeofW(StgHeader)+2,gen_no,tag);
      return;

  case CONSTR_0_2:
      copy_tag_nolock(p,info,q,sizeofW(StgHeader)+2,gen_no,tag);
      return;

  case THUNK:
      copy(p,info,q,thunk_sizeW_fromITBL(INFO_PTR_TO_STRUCT(info)),gen_no);
      return;

  case FUN:
  case CONSTR:
      copy_tag_nolock(p,info,q,sizeW_fromITBL(INFO_PTR_TO_STRUCT(info)),gen_no,tag);
      return;

  case BLACKHOLE:
  {
      StgClosure *r;
      const StgInfoTable *i;
      r = ((StgInd*)q)->indirectee;
      if (GET_CLOSURE_TAG(r) == 0) {
          i = r->header.info;
          if (IS_FORWARDING_PTR(i)) {
              r = (StgClosure *)UN_FORWARDING_PTR(i);
              i = r->header.info;
          }
          if (i == &stg_TSO_info
              || i == &stg_WHITEHOLE_info
              || i == &stg_BLOCKING_QUEUE_CLEAN_info
              || i == &stg_BLOCKING_QUEUE_DIRTY_info) {
              copy(p,info,q,sizeofW(StgInd),gen_no);
              return;
          }
          ASSERT(i != &stg_IND_info);
      }
      q = r;
      *p = r;
      goto loop;
  }

  case MUT_VAR_CLEAN:
  case MUT_VAR_DIRTY:
  case MVAR_CLEAN:
  case MVAR_DIRTY:
  case TVAR:
  case BLOCKING_QUEUE:
  case WEAK:
  case PRIM:
  case MUT_PRIM:
      copy(p,info,q,sizeW_fromITBL(INFO_PTR_TO_STRUCT(info)),gen_no);
      return;

  case BCO:
      copy(p,info,q,bco_sizeW((StgBCO *)q),gen_no);
      return;

  case THUNK_SELECTOR:
      eval_thunk_selector(p, (StgSelector *)q, rtsTrue);
      return;

  case IND:
    // follow chains of indirections, don't evacuate them
    q = ((StgInd*)q)->indirectee;
    *p = q;
    goto loop;

  case RET_BCO:
  case RET_SMALL:
  case RET_BIG:
  case UPDATE_FRAME:
  case UNDERFLOW_FRAME:
  case STOP_FRAME:
  case CATCH_FRAME:
  case CATCH_STM_FRAME:
  case CATCH_RETRY_FRAME:
  case ATOMICALLY_FRAME:
    // shouldn't see these
    barf("evacuate: stack frame at %p\n", q);

  case PAP:
      copy(p,info,q,pap_sizeW((StgPAP*)q),gen_no);
      return;

  case AP:
      copy(p,info,q,ap_sizeW((StgAP*)q),gen_no);
      return;

  case AP_STACK:
      copy(p,info,q,ap_stack_sizeW((StgAP_STACK*)q),gen_no);
      return;

  case ARR_WORDS:
      // just copy the block
      copy(p,info,q,arr_words_sizeW((StgArrBytes *)q),gen_no);
      return;

  case MUT_ARR_PTRS_CLEAN:
  case MUT_ARR_PTRS_DIRTY:
  case MUT_ARR_PTRS_FROZEN:
  case MUT_ARR_PTRS_FROZEN0:
      // just copy the block
      copy(p,info,q,mut_arr_ptrs_sizeW((StgMutArrPtrs *)q),gen_no);
      return;

  case SMALL_MUT_ARR_PTRS_CLEAN:
  case SMALL_MUT_ARR_PTRS_DIRTY:
  case SMALL_MUT_ARR_PTRS_FROZEN:
  case SMALL_MUT_ARR_PTRS_FROZEN0:
      // just copy the block
      copy(p,info,q,small_mut_arr_ptrs_sizeW((StgSmallMutArrPtrs *)q),gen_no);
      return;

  case TSO:
      copy(p,info,q,sizeofW(StgTSO),gen_no);
      return;

  case STACK:
    {
      StgStack *stack = (StgStack *)q;

      /* To evacuate a small STACK, we need to adjust the stack pointer
       */
      {
          StgStack *new_stack;
          StgPtr r, s;
          rtsBool mine;

          mine = copyPart(p,(StgClosure *)stack, stack_sizeW(stack),
                          sizeofW(StgStack), gen_no);
          if (mine) {
              new_stack = (StgStack *)*p;
              move_STACK(stack, new_stack);
              for (r = stack->sp, s = new_stack->sp;
                   r < stack->stack + stack->stack_size;) {
                  *s++ = *r++;
              }
          }
          return;
      }
    }

  case TREC_CHUNK:
      copy(p,info,q,sizeofW(StgTRecChunk),gen_no);
      return;

  default:
    barf("evacuate: strange closure type %d", (int)(INFO_PTR_TO_STRUCT(info)->type));
  }

  barf("evacuate");
}
예제 #30
0
파일: Test.cpp 프로젝트: marcelamsler/CPP
void thisIsATest() {
	ASSERTM("start writing tests", false);	
}