当前位置: 首页>>代码示例>>C++>>正文


C++ raiseException函数代码示例

本文整理汇总了C++中raiseException函数的典型用法代码示例。如果您正苦于以下问题:C++ raiseException函数的具体用法?C++ raiseException怎么用?C++ raiseException使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了raiseException函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: performPop

int performPop(int X, int flagX) {
	char * value;
	Exception e;
	Address T = translateAddress(getInteger(reg[SP_REG]));
	if (T.page == -1 && T.word == -1) return 0;
	switch (flagX) {
		case REG:
			e = isRegisterInaccessible(X);
			if (e.code != EX_NONE) {
				raiseException(e);
				return 0;
			}				
			value = getWordFromAddress(T);
			strcpy(reg[X], value);
			storeInteger(reg[SP_REG], getInteger(reg[SP_REG]) - 1);
			return 1;
			break;
		case IP:
			raiseException(newException(EX_ILLOPERAND, "Illegal operand IP. Cannot alter readonly register", 0));
			return 0;
			break;
		case EFR:
			raiseException(newException(EX_ILLOPERAND, "Illegal operand EFR. Cannot alter readonly register", 0));
			return 0;
			break;
		default:
			raiseException(newException(EX_ILLOPERAND, "Illegal Operand", 0));
			return 0;
			break;
	}
}
开发者ID:lenywv,项目名称:xsm,代码行数:31,代码来源:utility.c

示例2: translate

struct address translate(int virtual_addr) {
	if (mode == USER_MODE) {
		struct address resultant_addr;
		int page_entry;
		resultant_addr.page_no = -1;
		resultant_addr.word_no = -1;
		if (getType(reg[PTBR_REG]) == TYPE_STR) {
			raiseException(newException(EX_ILLMEM, "Illegal Register Value.\n", 0));
			return resultant_addr;
		}
		page_entry = getInteger(reg[PTBR_REG]) + (virtual_addr / PAGE_SIZE) * 2;
		if (page[(page_entry+ 1 ) / PAGE_SIZE].word[(page_entry + 1) % PAGE_SIZE][1] == VALID ) { 
			resultant_addr.page_no = getInteger(page[page_entry / PAGE_SIZE].word[page_entry % PAGE_SIZE] );
			resultant_addr.word_no = virtual_addr % PAGE_SIZE;
			page[(page_entry + 1) / PAGE_SIZE].word[(page_entry + 1) % PAGE_SIZE][0] = REFERENCED;
		}
		else raiseException(newException(EX_PAGEFAULT, "Page Fault.\n", virtual_addr / PAGE_SIZE));
		return resultant_addr;
	} else {
		struct address resultant_addr;
		resultant_addr.page_no = virtual_addr / PAGE_SIZE;
		resultant_addr.word_no = virtual_addr % PAGE_SIZE;
		return resultant_addr;
	}
}
开发者ID:lenywv,项目名称:xsm,代码行数:25,代码来源:utility.c

示例3: performIRET

int performIRET() {
	if (mode == USER_MODE) {
		raiseException(newException(EX_ILLINSTR, "Call to Privileged Instruction IRET in USER mode", 0));
		return 0;
	}
	Exception e = isSafeState2();
	if (e.code != EX_NONE) {
		raiseException(e);
		return 0;
	}
	mode = USER_MODE;
	Address T = translateAddress(getInteger(reg[SP_REG]));
	if (T.page == -1 && T.word == -1) {
		mode = KERNEL_MODE;
		return 0;
	}
	char * value = getWordFromAddress(T);
	if (getType(value) == TYPE_STR) {
		mode = KERNEL_MODE;
		raiseException(newException(EX_ILLMEM, "Illegal return address", 0));
		return 0;
	}
	int result = getInteger(value);
	if (result < 0 || result >= getInteger(reg[PTLR_REG]) * PAGE_SIZE) {
		mode = KERNEL_MODE;
		raiseException(newException(EX_ILLMEM, "Illegal return address", 0));
		return 0;
	}
	storeInteger(reg[IP_REG], result);
	storeInteger(reg[SP_REG], getInteger(reg[SP_REG]) - 1);
	return 1;
}
开发者ID:lenywv,项目名称:xsm,代码行数:32,代码来源:utility.c

示例4: performIN

int performIN(int X, int flagX) {
	int value;
	Exception e;
	switch (flagX) {
		case REG:
		case SP:
		case BP:
		case PTBR:
		case PTLR:
			e = isRegisterInaccessible(X);
			if (e.code != EX_NONE) {
				raiseException(e);
				return 0;
			}
			break;
		case IP:
			raiseException(newException(EX_ILLOPERAND, "Illegal operand IP. Cannot alter readonly register", 0));
			return 0;
		case EFR:
			raiseException(newException(EX_ILLOPERAND, "Illegal operand EFR. Cannot alter readonly register", 0));
			return 0;
			break;
		default:
			raiseException(newException(EX_ILLOPERAND, "Illegal operand.", 0));
			return 0;
			break;
	}
	char input[WORD_SIZE];
	scanf("%s", input);
	FLUSH_STDIN(input);
	input[WORD_SIZE - 1] = '\0';
	strcpy(reg[X], input);
	return 1;
}
开发者ID:lenywv,项目名称:xsm,代码行数:34,代码来源:utility.c

示例5: getInstruction

/*
 * Gets the instruction pointed by IP, to the argument
 * Return 0 on success
 * Returns -1 on error after setting IP to exception handler
 */
int getInstruction(char *instruction) {
	struct address translatedAddr;
	int len;
	bzero(instruction, WORD_SIZE * WORDS_PER_INSTR);
	if (getType(reg[IP_REG]) == TYPE_STR) {	
		raiseException(newException(EX_ILLMEM, "Illegal IP value. Not an address.\n", 0));
		return -1;
	}
	if (mode == USER_MODE && getType(reg[PTLR_REG]) == TYPE_STR) {	
		raiseException(newException(EX_ILLMEM, "Illegal PTLR value.\n", 0));
		return -1;
	}
	if (getInteger(reg[IP_REG]) < 0 || getInteger(reg[IP_REG]) + 1 >= SIZE_OF_MEM) {
		raiseException(newException(EX_ILLMEM, "IP Register value out of bounds.\n", 0));
		return -1;
	}
	if (mode == USER_MODE) {
		if (getInteger(reg[IP_REG]) < 0 || getInteger(reg[IP_REG]) + 1 >= getInteger(reg[PTLR_REG]) * PAGE_SIZE) {
			printf("%d", getInteger(reg[IP_REG]));
			raiseException(newException(EX_ILLOPERAND, "Illegal IP Access.\n", 0));
			return -1;
		}
	}
	translatedAddr = translate(getInteger(reg[IP_REG]));
	if (translatedAddr.page_no == -1 && translatedAddr.word_no == -1) return -1;
	strcpy(instruction, page[translatedAddr.page_no].word[translatedAddr.word_no]);
	translatedAddr = translate(getInteger(reg[IP_REG]) + 1);
	if (translatedAddr.page_no == -1 && translatedAddr.word_no == -1) return -1;
	len = strlen(instruction);
	instruction[len]=' ';
	instruction[len + 1]='\0';
	strcat(instruction, page[translatedAddr.page_no].word[translatedAddr.word_no]);
	return 0;
}
开发者ID:lenywv,项目名称:xsm,代码行数:39,代码来源:utility.c

示例6: performPush

int performPush(int X, int flagX) {
	Address T = translateAddress(getInteger(reg[SP_REG]) + 1);
	if (T.page == -1 && T.word == -1) return 0;
	Exception e;

	switch (flagX) {
		case REG:
		case SP:
		case BP:
		case IP:
		case PTBR:
		case PTLR:
		case EFR:
			e = isRegisterInaccessible(X);
			if (e.code != EX_NONE) {
				raiseException(e);
				return 0;
			}
			if (storeWordToAddress(T, reg[X])) {
				storeInteger(reg[SP_REG], getInteger(reg[SP_REG]) + 1);
				return 1;
			} else return 0;
			break;
		default:
			raiseException(newException(EX_ILLOPERAND, "Illegal Operand", 0));
			return 0;
			break;
	}
}
开发者ID:lenywv,项目名称:xsm,代码行数:29,代码来源:utility.c

示例7: performINT

int performINT(int X, int flagX) {
	if (mode == KERNEL_MODE) {
		raiseException(newException(EX_ILLINSTR, "Cannot call INT in KERNEL Mode", 0));
		return 0;
	}
	if (flagX != NUM) {
		raiseException(newException(EX_ILLOPERAND, "Illegal operand", 0));
		return;
	}
	invokeInterrupt(X);
	return 1;
}
开发者ID:lenywv,项目名称:xsm,代码行数:12,代码来源:utility.c

示例8: N_NIMCALL

N_NIMCALL(void, send_518209)(Socketimpl513407* socket, NimStringDesc* data, NU8 flags) {
	NI sent;
{	sent = send_517716(socket, ((void*) (data->data)), (data ? data->Sup.len : 0));
	{
		NI32 lasterror;
		if (!(sent < ((NI) 0))) goto LA3;
		lasterror = oslasterror_115833();
		{
			NIM_BOOL LOC7;
			LOC7 = 0;
			LOC7 = isdisconnectionerror_513481(flags, lasterror);
			if (!LOC7) goto LA8;
			goto BeforeRet;
		}
		LA8: ;
		socketerror_514027(socket, ((NI) -1), NIM_FALSE, lasterror);
	}
	LA3: ;
	{
		Oserror3433* e_518220;
		NimStringDesc* LOC14;
		if (!!((sent == (data ? data->Sup.len : 0)))) goto LA12;
		e_518220 = 0;
		e_518220 = (Oserror3433*) newObj((&NTI115812), sizeof(Oserror3433));
		(*e_518220).Sup.Sup.Sup.m_type = (&NTI3433);
		LOC14 = 0;
		LOC14 = (*e_518220).Sup.Sup.message; (*e_518220).Sup.Sup.message = copyStringRC1(((NimStringDesc*) &TMP4996));
		if (LOC14) nimGCunrefNoCycle(LOC14);
		raiseException((Exception*)e_518220, "OSError");
	}
	LA12: ;
	}BeforeRet: ;
}
开发者ID:jlp765,项目名称:csources,代码行数:33,代码来源:stdlib_net.c

示例9: N_NIMCALL

N_NIMCALL(NimStringDesc**, nstTake)(Stringtableobj140209* t, NimStringDesc* key) {
	NimStringDesc** result;
	NI index_140432;
	result = 0;
	index_140432 = rawget_140406(t, key);
	{
		if (!(((NI) 0) <= index_140432)) goto LA3;
		result = (&(*t).data->data[index_140432].Field1);
	}
	goto LA1;
	LA3: ;
	{
		Keyerror3648* e_140603;
		NimStringDesc* LOC6;
		e_140603 = 0;
		e_140603 = (Keyerror3648*) newObj((&NTI181804), sizeof(Keyerror3648));
		(*e_140603).Sup.Sup.Sup.m_type = (&NTI3648);
		LOC6 = 0;
		LOC6 = rawNewString(key->Sup.len + 15);
appendString(LOC6, ((NimStringDesc*) &TMP1551));
appendString(LOC6, key);
		asgnRefNoCycle((void**) (&(*e_140603).Sup.Sup.message), LOC6);
		raiseException((Exception*)e_140603, "KeyError");
	}
	LA1: ;
	return result;
}
开发者ID:StetHD,项目名称:csources,代码行数:27,代码来源:stdlib_strtabs.c

示例10: N_NIMCALL

N_NIMCALL(Selectorkey181439*, mget_182057)(Table181466* t, int key) {
	Selectorkey181439* result;
	NI hc_182070;
	NI index_182072;
	result = 0;
	hc_182070 = 0;
	index_182072 = rawget_181585((*t), key, (&hc_182070));
	{
		if (!(((NI) 0) <= index_182072)) goto LA3;
		result = (&(*t).data->data[index_182072].Field2);
	}
	goto LA1;
	LA3: ;
	{
		Keyerror3851* e_182202;
		NimStringDesc* LOC6;
		NimStringDesc* LOC7;
		e_182202 = 0;
		e_182202 = (Keyerror3851*) newObj((&NTI182603), sizeof(Keyerror3851));
		(*e_182202).Sup.Sup.Sup.m_type = (&NTI3851);
		LOC6 = 0;
		LOC7 = 0;
		LOC7 = nimIntToStr(key);
		LOC6 = rawNewString(LOC7->Sup.len + 15);
appendString(LOC6, ((NimStringDesc*) &TMP1111));
appendString(LOC6, LOC7);
		asgnRefNoCycle((void**) (&(*e_182202).Sup.Sup.message), LOC6);
		raiseException((Exception*)e_182202, "KeyError");
	}
	LA1: ;
	return result;
}
开发者ID:JJjie,项目名称:RuCTF-2015,代码行数:32,代码来源:stdlib_tables.c

示例11: N_NIMCALL

N_NIMCALL(NI, npuParseInt)(NimStringDesc* S_23051, NI* Number_23053, NI Start_23054) {
NI Result_23055;
NI64 Res_23056;
NIM_BOOL LOC2;
NIM_BOOL LOC4;
EOverflow* E_23069;
Result_23055 = 0;
Res_23056 = 0;
Result_23055 = npuParseBiggestInt(S_23051, &Res_23056, Start_23054);
LOC2 = NIM_TRUE;
if (!(LOC2)) goto LA3;
LOC4 = (Res_23056 < (-2147483647 -1));
if (LOC4) goto LA5;
LOC4 = (2147483647 < Res_23056);
LA5: ;
LOC2 = LOC4;
LA3: ;
if (!LOC2) goto LA6;
E_23069 = 0;
E_23069 = (EOverflow*) newObj(NTI6051, sizeof(EOverflow));
(*E_23069).Sup.Sup.Sup.Sup.m_type = NTI432;
asgnRefNoCycle((void**) &(*E_23069).Sup.Sup.Sup.message, copyString(((NimStringDesc*) &TMP195656)));
raiseException((E_Base*)E_23069, "EOverflow");
goto LA1;
LA6: ;
(*Number_23053) = ((NI) (Res_23056));
LA1: ;
return Result_23055;
}
开发者ID:ddlsmurf,项目名称:Nimrod,代码行数:29,代码来源:parseutils.c

示例12: N_NIMCALL

N_NIMCALL(void, getservbyport_511233)(NU16 port, NimStringDesc* proto, Servent509610* Result) {
	struct servent* s;
	nimfr("getServByPort", "rawsockets.nim")
	nimln(261, "rawsockets.nim");
	s = getservbyport(((int) (((NI)(NU)(NU16)(((NI16)chckRange(port, ((NI16) -32768), ((NI16) 32767))))))), proto->data);
	nimln(262, "rawsockets.nim");
	{
		Oserror3433* e_511416;
		NimStringDesc* LOC5;
		if (!(s == NIM_NIL)) goto LA3;
		e_511416 = 0;
		nimln(2265, "system.nim");
		e_511416 = (Oserror3433*) newObj((&NTI116812), sizeof(Oserror3433));
		(*e_511416).Sup.Sup.Sup.m_type = (&NTI3433);
		nimln(2266, "system.nim");
		LOC5 = 0;
		LOC5 = (*e_511416).Sup.Sup.message; (*e_511416).Sup.Sup.message = copyStringRC1(((NimStringDesc*) &TMP10617));
		if (LOC5) nimGCunrefNoCycle(LOC5);
		nimln(262, "rawsockets.nim");
		raiseException((Exception*)e_511416, "OSError");
	}
	LA3: ;
	nimln(263, "rawsockets.nim");
	unsureAsgnRef((void**) (&(*Result).name), cstrToNimstr((*s).s_name));
	nimln(264, "rawsockets.nim");
	unsureAsgnRef((void**) (&(*Result).aliases), cstringarraytoseq_13843((*s).s_aliases));
	nimln(265, "rawsockets.nim");
	(*Result).port = ((NU16) ((*s).s_port));
	nimln(266, "rawsockets.nim");
	unsureAsgnRef((void**) (&(*Result).proto), cstrToNimstr((*s).s_proto));
	popFrame();
}
开发者ID:undecided,项目名称:csources,代码行数:32,代码来源:stdlib_rawsockets.c

示例13: absPathOfDMapContent

  void DMapFileParser::parseRegularLine(
      std::string file_name, std::string line, uint32_t line_nr, DeviceInfoMapPointer dmap) {
    std::istringstream inStream;
    DeviceInfoMap::DeviceInfo deviceInfo;

    inStream.str(line);
    inStream >> deviceInfo.deviceName >> deviceInfo.uri >> deviceInfo.mapFileName;

    if(inStream) {
      std::string absPathToDMapFile = utilities::convertToAbsolutePath(file_name);
      std::string absPathToMapFile = absPathOfDMapContent(deviceInfo.mapFileName, file_name);
      deviceInfo.mapFileName = absPathToMapFile;
      deviceInfo.dmapFileName = absPathToDMapFile;
      deviceInfo.dmapFileLineNumber = line_nr;
      dmap->insert(deviceInfo);
    }
    else {
      std::istringstream inStream2;
      inStream2.str(line);
      inStream2 >> deviceInfo.deviceName >> deviceInfo.uri;

      if(inStream2) {
        std::string absPathToDMapFile = utilities::convertToAbsolutePath(file_name);
        deviceInfo.mapFileName = "";
        deviceInfo.dmapFileName = absPathToDMapFile;
        deviceInfo.dmapFileLineNumber = line_nr;
        dmap->insert(deviceInfo);
      }
      else {
        raiseException(file_name, line, line_nr);
      }
    }
  }
开发者ID:ChimeraTK,项目名称:DeviceAccess,代码行数:33,代码来源:DMapFileParser.cpp

示例14: translateException

void translateException()
{
  try 
  {
    if (PyErr_Occurred()); // let the latest Python exn pass through and ignore the current one
  else
    throw;
  }
  catch(Hermes::Exceptions::NullException &e)
  {
    raiseNullException(&e);
  }
  catch(Hermes::Exceptions::LengthException &e)
  {
    raiseLengthException(&e);
  }
  catch(Hermes::Exceptions::LinearSolverException &e)
  {
    raiseLinearSolverException(&e);
  }
  catch(Hermes::Exceptions::ValueException &e)
  {
    raiseValueException(&e);
  }
  catch(Hermes::Exceptions::Exception &e)
  {
    raiseException(&e);
  }
}
开发者ID:l-korous,项目名称:hermes-python,代码行数:29,代码来源:translate_exception.cpp

示例15: N_NIMCALL

N_LIB_PRIVATE N_NIMCALL(NimStringDesc**, nstTake)(tyObject_StringTableObj_V5PVrt9bIxZEeV7lfvqqtNg* t, NimStringDesc* key) {
	NimStringDesc** result;
	NI index;
	result = (NimStringDesc**)0;
	index = rawGet_j2b5ExM8jHC3fdJfR8v9aMw(t, key);
	{
		if (!(((NI) 0) <= index)) goto LA3_;
		result = (&(*t).data->data[index].Field1);
	}
	goto LA1_;
	LA3_: ;
	{
		tyObject_KeyError_nRD4SGrdQPt47sk7LIklpA* e;
		NimStringDesc* T6_;
		e = (tyObject_KeyError_nRD4SGrdQPt47sk7LIklpA*)0;
		e = (tyObject_KeyError_nRD4SGrdQPt47sk7LIklpA*) newObj((&NTI_nuL5K2f5u8HXdjAg35PVfw_), sizeof(tyObject_KeyError_nRD4SGrdQPt47sk7LIklpA));
		(*e).Sup.Sup.Sup.Sup.m_type = (&NTI_nRD4SGrdQPt47sk7LIklpA_);
		T6_ = (NimStringDesc*)0;
		T6_ = rawNewString((key ? key->Sup.len : 0) + 15);
appendString(T6_, ((NimStringDesc*) &TM_ZT9crccxweoChVXn9cHcxIXQ_7));
appendString(T6_, key);
		asgnRefNoCycle((void**) (&(*e).Sup.Sup.Sup.message), T6_);
		asgnRef((void**) (&(*e).Sup.Sup.Sup.parent), NIM_NIL);
		raiseException((Exception*)e, "KeyError");
	}
	LA1_: ;
	return result;
}
开发者ID:nim-lang,项目名称:csources,代码行数:28,代码来源:stdlib_strtabs.c


注:本文中的raiseException函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。