Example #1
0
File: utility.c Project: lenywv/xsm
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;
	}
}
Example #2
0
File: utility.c Project: lenywv/xsm
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;
	}
}
Example #3
0
File: utility.c Project: lenywv/xsm
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;
}
Example #4
0
File: utility.c Project: lenywv/xsm
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;
}
Example #5
0
File: utility.c Project: lenywv/xsm
/*
 * 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;
}
Example #6
0
File: utility.c Project: lenywv/xsm
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;
	}
}
Example #7
0
File: utility.c Project: lenywv/xsm
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;
}
Example #8
0
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: ;
}
Example #9
0
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;
}
Example #10
0
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;
}
Example #11
0
N_NIMCALL(void, HEX5BHEX5D_182417)(Table181466 t, int key, Selectorkey181439* Result) {
	NI hc_182428;
	NI index_182430;
	hc_182428 = 0;
	index_182430 = rawget_181585(t, key, (&hc_182428));
	{
		if (!(((NI) 0) <= index_182430)) goto LA3;
		(*Result).fd = t.data->data[index_182430].Field2.fd;
		(*Result).events = t.data->data[index_182430].Field2.events;
		unsureAsgnRef((void**) (&(*Result).data), t.data->data[index_182430].Field2.data);
	}
	goto LA1;
	LA3: ;
	{
		Keyerror3851* e_182602;
		NimStringDesc* LOC6;
		NimStringDesc* LOC7;
		e_182602 = 0;
		e_182602 = (Keyerror3851*) newObj((&NTI182603), sizeof(Keyerror3851));
		(*e_182602).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_182602).Sup.Sup.message), LOC6);
		raiseException((Exception*)e_182602, "KeyError");
	}
	LA1: ;
}
Example #12
0
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;
}
Example #13
0
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();
}
Example #14
0
  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);
      }
    }
  }
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);
  }
}
Example #16
0
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;
}
Example #17
0
N_NIMCALL(NimStringDesc*, paramstr_124809)(NI i) {
	NimStringDesc* result;
	Indexerror3455* e_124815;
	NimStringDesc* LOC7;
{	result = 0;
	{
		NIM_BOOL LOC3;
		LOC3 = 0;
		LOC3 = (i < ((NI) (cmdCount)));
		if (!(LOC3)) goto LA4;
		LOC3 = (((NI) 0) <= i);
		LA4: ;
		if (!LOC3) goto LA5;
		result = cstrToNimstr(cmdLine[(i)- 0]);
		goto BeforeRet;
	}
	LA5: ;
	e_124815 = 0;
	e_124815 = (Indexerror3455*) newObj((&NTI124816), sizeof(Indexerror3455));
	(*e_124815).Sup.Sup.m_type = (&NTI3455);
	LOC7 = 0;
	LOC7 = (*e_124815).Sup.message; (*e_124815).Sup.message = copyStringRC1(((NimStringDesc*) &TMP1146));
	if (LOC7) nimGCunrefNoCycle(LOC7);
	raiseException((Exception*)e_124815, "IndexError");
	}BeforeRet: ;
	return result;
}
Example #18
0
N_NIMCALL(struct addrinfo*, getaddrinfo_510408)(NimStringDesc* address, NU16 port, NU8 af, NU8 typ, NU8 prot) {
	struct addrinfo* result;
	struct addrinfo hints;
	int gairesult;
	NimStringDesc* LOC1;
	result = 0;
	memset((void*)(&hints), 0, sizeof(hints));
	result = NIM_NIL;
	hints.ai_family = toint_509829(af);
	hints.ai_socktype = toint_509835(typ);
	hints.ai_protocol = toint_509841(prot);
	LOC1 = 0;
	LOC1 = HEX24_6401(port);
	gairesult = getaddrinfo(address->data, LOC1->data, (&hints), &result);
	{
		Oserror3433* e_510603;
		NCSTRING LOC6;
		if (!!((gairesult == ((NI32) 0)))) goto LA4;
		e_510603 = 0;
		e_510603 = (Oserror3433*) newObj((&NTI116812), sizeof(Oserror3433));
		(*e_510603).Sup.Sup.Sup.m_type = (&NTI3433);
		LOC6 = 0;
		LOC6 = gai_strerror(gairesult);
		asgnRefNoCycle((void**) (&(*e_510603).Sup.Sup.message), cstrToNimstr(LOC6));
		raiseException((Exception*)e_510603, "OSError");
	}
	LA4: ;
	return result;
}
Example #19
0
N_NIMCALL(void, getservbyname_511027)(NimStringDesc* name, NimStringDesc* proto, Servent509610* Result) {
	struct servent* s;
	nimfr("getServByName", "rawsockets.nim")
	nimln(245, "rawsockets.nim");
	s = getservbyname(name->data, proto->data);
	nimln(246, "rawsockets.nim");
	{
		Oserror3433* e_511216;
		NimStringDesc* LOC5;
		if (!(s == NIM_NIL)) goto LA3;
		e_511216 = 0;
		nimln(2265, "system.nim");
		e_511216 = (Oserror3433*) newObj((&NTI116812), sizeof(Oserror3433));
		(*e_511216).Sup.Sup.Sup.m_type = (&NTI3433);
		nimln(2266, "system.nim");
		LOC5 = 0;
		LOC5 = (*e_511216).Sup.Sup.message; (*e_511216).Sup.Sup.message = copyStringRC1(((NimStringDesc*) &TMP10617));
		if (LOC5) nimGCunrefNoCycle(LOC5);
		nimln(246, "rawsockets.nim");
		raiseException((Exception*)e_511216, "OSError");
	}
	LA3: ;
	nimln(247, "rawsockets.nim");
	unsureAsgnRef((void**) (&(*Result).name), cstrToNimstr((*s).s_name));
	nimln(248, "rawsockets.nim");
	unsureAsgnRef((void**) (&(*Result).aliases), cstringarraytoseq_13843((*s).s_aliases));
	nimln(249, "rawsockets.nim");
	(*Result).port = ((NU16) ((*s).s_port));
	nimln(250, "rawsockets.nim");
	unsureAsgnRef((void**) (&(*Result).proto), cstrToNimstr((*s).s_proto));
	popFrame();
}
Example #20
0
eOperandType Chipset::checkNumber(const std::string &val)
{
	bool foundValue = false;
	size_t i;
	std::string type_only;

	size_t nb_begin;
	size_t nb_end;

	nb_end = val.find(")");
	nb_begin = val.find("(");
	if (nb_begin == val.npos || nb_end == val.npos || nb_end != (val.size() - 1)
		|| nb_end - nb_begin < 2)
		raiseException(SyntaxException());
	type_only = val.substr(0, nb_begin);

	for (i = 0; i < _valuesVect.size(); i++)
	{
		if (type_only == _valuesVect[i].name)
		{
			foundValue = true;
			break;
		}
	}
	if (foundValue == false)
		raiseException(SyntaxException());

	std::string nb;

	nb = val.substr(nb_begin + 1, (nb_end - nb_begin) - 1);

	NumberType nbType = findNumberType(nb);
	if (nbType == UNKNOWN)
		raiseException(SyntaxException());
	if (nbType == ENTIER)
	{
		if (_valuesVect[i].opeType >= 3)
			raiseException(SyntaxException());
	}
	else
	{
		if (_valuesVect[i].opeType <= 2)
			raiseException(SyntaxException());
	}
	return (_valuesVect[i].opeType);
}
Example #21
0
void Chipset::sendToRamString(const std::string &msg)
{
	std::string word;
	std::vector<std::string> words;

	std::stringstream stream(msg);
	while (std::getline(stream, word, ' '))
	{
		if (word.length() > 0)
			words.push_back(word.c_str());
	}

	bool foundInstruction = false;
	size_t i;
	for (i = 0; i < _instVect.size(); i++)
	{
		if (words[0] == _instVect[i].name)
		{
			foundInstruction = true;
			break;
		}
	}

	if (foundInstruction == false)
		raiseException(BadInstException());
	if (_instVect[i].nb_param != (words.size() - 1))
		raiseException(SyntaxException());

	Inst *new_Instruction;
	if (_instVect[i].nb_param >= 1)
	{
		eOperandType type = checkNumber(words[1]);
		size_t nb_end = words[1].find(")");
		size_t nb_begin = words[1].find("(");
		std::string numberOnly = words[1].substr(nb_begin + 1, (nb_end - nb_begin) - 1);

		new_Instruction = new Inst(_instVect[i].inst, numberOnly, type);
	}
	else
	{
		new_Instruction = new Inst(_instVect[i].inst);
	}
	if (new_Instruction->getOpCode() == EXIT)
		_isExited = true;
	_ram.PutInst(new_Instruction);
}
bool MessageQueue::raiseAndClearException(JNIEnv* env, const char* msg) {
    if (env->ExceptionCheck()) {
        jthrowable exceptionObj = env->ExceptionOccurred();
        env->ExceptionClear();
        raiseException(env, msg, exceptionObj);
        env->DeleteLocalRef(exceptionObj);
        return true;
    }
    return false;
}
Example #23
0
N_NIMCALL(void, gethostbyname_511824)(NimStringDesc* name, Hostent509612* Result) {
	struct hostent* s;
	nimfr("getHostByName", "rawsockets.nim")
	nimln(302, "rawsockets.nim");
	s = gethostbyname(name->data);
	nimln(303, "rawsockets.nim");
	{
		NI32 LOC5;
		if (!(s == NIM_NIL)) goto LA3;
		LOC5 = 0;
		LOC5 = oslasterror_116833();
		raiseoserror_116809(LOC5);
	}
	LA3: ;
	nimln(304, "rawsockets.nim");
	unsureAsgnRef((void**) (&(*Result).name), cstrToNimstr((*s).h_name));
	nimln(305, "rawsockets.nim");
	unsureAsgnRef((void**) (&(*Result).aliases), cstringarraytoseq_13843((*s).h_aliases));
	nimln(309, "rawsockets.nim");
	{
		if (!((*s).h_addrtype == AF_INET)) goto LA8;
		nimln(310, "rawsockets.nim");
		(*Result).addrtype = ((NU8) 2);
	}
	goto LA6;
	LA8: ;
	{
		nimln(311, "rawsockets.nim");
		if (!((*s).h_addrtype == AF_INET6)) goto LA11;
		nimln(312, "rawsockets.nim");
		(*Result).addrtype = ((NU8) 23);
	}
	goto LA6;
	LA11: ;
	{
		Oserror3433* e_512203;
		NimStringDesc* LOC14;
		e_512203 = 0;
		nimln(2265, "system.nim");
		e_512203 = (Oserror3433*) newObj((&NTI116812), sizeof(Oserror3433));
		(*e_512203).Sup.Sup.Sup.m_type = (&NTI3433);
		nimln(2266, "system.nim");
		LOC14 = 0;
		LOC14 = (*e_512203).Sup.Sup.message; (*e_512203).Sup.Sup.message = copyStringRC1(((NimStringDesc*) &TMP10618));
		if (LOC14) nimGCunrefNoCycle(LOC14);
		nimln(314, "rawsockets.nim");
		raiseException((Exception*)e_512203, "OSError");
	}
	LA6: ;
	nimln(315, "rawsockets.nim");
	unsureAsgnRef((void**) (&(*Result).addrlist), cstringarraytoseq_13843((*s).h_addr_list));
	nimln(316, "rawsockets.nim");
	(*Result).length = ((NI) ((*s).h_length));
	popFrame();
}
Example #24
0
N_NOINLINE(void, nosraiseOSError)(NimStringDesc* msg) {
	{
		NimStringDesc* m;
		Oserror3433* e_115416;
		if (!((msg ? msg->Sup.len : 0) == ((NI) 0))) goto LA3;
		m = nososErrorMsg();
		e_115416 = 0;
		e_115416 = (Oserror3433*) newObj((&NTI115812), sizeof(Oserror3433));
		(*e_115416).Sup.Sup.Sup.m_type = (&NTI3433);
		{
			NimStringDesc* LOC9;
			if (!(((NI) 0) < (m ? m->Sup.len : 0))) goto LA7;
			LOC9 = 0;
			LOC9 = (*e_115416).Sup.Sup.message; (*e_115416).Sup.Sup.message = copyStringRC1(m);
			if (LOC9) nimGCunrefNoCycle(LOC9);
		}
		goto LA5;
		LA7: ;
		{
			NimStringDesc* LOC11;
			LOC11 = 0;
			LOC11 = (*e_115416).Sup.Sup.message; (*e_115416).Sup.Sup.message = copyStringRC1(((NimStringDesc*) &TMP1143));
			if (LOC11) nimGCunrefNoCycle(LOC11);
		}
		LA5: ;
		raiseException((Exception*)e_115416, "OSError");
	}
	goto LA1;
	LA3: ;
	{
		Oserror3433* e_115428;
		NimStringDesc* LOC13;
		e_115428 = 0;
		e_115428 = (Oserror3433*) newObj((&NTI115812), sizeof(Oserror3433));
		(*e_115428).Sup.Sup.Sup.m_type = (&NTI3433);
		LOC13 = 0;
		LOC13 = (*e_115428).Sup.Sup.message; (*e_115428).Sup.Sup.message = copyStringRC1(msg);
		if (LOC13) nimGCunrefNoCycle(LOC13);
		raiseException((Exception*)e_115428, "OSError");
	}
	LA1: ;
}
Example #25
0
File: utility.c Project: lenywv/xsm
int performMOV(int X, int flagX1, int flagX2, int Y, int flagY1, int flagY2, char * value) {
	char * resolvedValue = resolveOperand(Y, flagY1, flagY2, value);
	if (resolvedValue == NULL) return 0;
	if ((flagY1 == MEM_DIR_REG || flagY1 == MEM_DIR_SP || flagY1 == MEM_DIR_BP || flagY1 == MEM_DIR_PTBR || flagY1 == MEM_DIR_PTLR
		|| flagY1 == MEM_DIR_IN) && (flagX1 == MEM_DIR_REG || flagX1 == MEM_DIR_SP || flagX1 == MEM_DIR_BP || flagX1 == MEM_DIR_PTBR
		|| flagX1 == MEM_DIR_PTLR || flagX1 == MEM_DIR_IN)) {
		raiseException(newException(EX_ILLOPERAND, "Illegal Operands", 0));
		return 0;
	}
	return (storeValue(X, flagX1, flagX2, resolvedValue));
}
Example #26
0
bool
VolumeWrap::handleMethod(qmf::AgentSession& session, qmf::AgentEvent& event)
{
    int ret;

    if (*this != event.getDataAddr()) {
        return false;
    }

    const std::string& methodName(event.getMethodName());
    qpid::types::Variant::Map args(event.getArguments());

    if (methodName == "getXMLDesc") {
        const char *desc = virStorageVolGetXMLDesc(_volume_ptr, 0);
        if (!desc) {
            std::string err = FORMAT_ERR(_conn, "Error getting xml description for volume (virStorageVolGetXMLDesc).", &ret);
            raiseException(session, event, err, STATUS_USER + ret);
        } else {
            event.addReturnArgument("description", desc);
            session.methodSuccess(event);
        }
        return true;
    }

    if (methodName == "delete") {
        ret = virStorageVolDelete(_volume_ptr, 0);
        if (ret < 0) {
            std::string err = FORMAT_ERR(_conn, "Error deleting storage volume (virStorageVolDelete).", &ret);
            raiseException(session, event, err, STATUS_USER + ret);
        } else {
            update();
            session.methodSuccess(event);
        }
        return true;
    }

    raiseException(session, event,
                   ERROR_UNKNOWN_METHOD, STATUS_UNKNOWN_METHOD);
    return true;
}
Example #27
0
File: utility.c Project: lenywv/xsm
int isSafeState() {
	if (getType(reg[SP_REG]) == TYPE_STR || getType(reg[BP_REG]) == TYPE_STR || getType(reg[PTLR_REG]) == TYPE_STR) {
		raiseException(newException(EX_ILLMEM, "Illegal Register Value.\n", 0));
		return 0;
	}
	if (getInteger(reg[PTLR_REG]) < 0 || getInteger(reg[PTLR_REG]) >= SIZE_OF_MEM) {
		raiseException(newException(EX_ILLMEM, "Illegal address access.\n PTLR value is out of bounds.\n", 0));
		return 0;
	}
	if (getInteger(reg[SP_REG]) + 1 < 0) {
		raiseException(newException(EX_ILLMEM, "Stack underflow.\n", 0));
		return 0;
	}
	if (getInteger(reg[SP_REG]) >= SIZE_OF_MEM || (mode==USER_MODE && getInteger(reg[SP_REG]) >= getInteger(reg[PTLR_REG]) * PAGE_SIZE)) {
		raiseException(newException(EX_ILLMEM, "Stack overflow.\n", 0));
		return 0;
	}
	if (getInteger(reg[BP_REG]) < 0) {
		raiseException(newException(EX_ILLMEM, "Negative value for BP.\n", 0));
		return 0;
	}
	if (getInteger(reg[BP_REG]) >= SIZE_OF_MEM || (mode==USER_MODE && getInteger(reg[BP_REG]) >= getInteger(reg[PTLR_REG]) * PAGE_SIZE)) {
		raiseException(newException(EX_ILLMEM, "BP Register Value out of bounds.\n", 0));
		return 0;
	}
	return 1;
}
Example #28
0
N_LIB_PRIVATE N_NIMCALL(void, raiseFormatException_UlRj9cCVaVq3wqa9ckfyqy9cQ)(NimStringDesc* s) {
	tyObject_ValueError_5aqBlilCK53e9cDu4kUyN5Q* e;
	NimStringDesc* T1_;
	e = (tyObject_ValueError_5aqBlilCK53e9cDu4kUyN5Q*)0;
	e = (tyObject_ValueError_5aqBlilCK53e9cDu4kUyN5Q*) newObj((&NTI_yQYk49cCS1VAqkplQuc6KdQ_), sizeof(tyObject_ValueError_5aqBlilCK53e9cDu4kUyN5Q));
	(*e).Sup.Sup.Sup.m_type = (&NTI_5aqBlilCK53e9cDu4kUyN5Q_);
	T1_ = (NimStringDesc*)0;
	T1_ = rawNewString((s ? s->Sup.len : 0) + 30);
appendString(T1_, ((NimStringDesc*) &TM_ZT9crccxweoChVXn9cHcxIXQ_8));
appendString(T1_, s);
	asgnRefNoCycle((void**) (&(*e).Sup.Sup.message), T1_);
	raiseException((Exception*)e, "ValueError");
}
N_NIMCALL(void, fswritedata_158925_1780494535)(Streamobj157818* s0, void* buffer0, NI buflen0) {
	{
		NI LOC3;
		Ioerror3628* LOC6;
		LOC3 = (NI)0;
		LOC3 = writebuffer_14978_1689653243((*((Filestreamobj158877*) (s0))).f, buffer0, ((NI) (buflen0)));
		if (!!((LOC3 == buflen0))) goto LA4;
		LOC6 = (Ioerror3628*)0;
		LOC6 = neweio_157802_1780494535(((NimStringDesc*) &T1780494535_6));
		raiseException((Exception*)LOC6, "IOError");
	}
	LA4: ;
}
Example #30
0
File: utility.c Project: lenywv/xsm
int performCall(int X, int flagX) {
	Exception e = isSafeState2();
	if (e.code != EX_NONE) {
		raiseException(e);
		return 0;
	}
	if (flagX != NUM) {
		raiseException(newException(EX_ILLOPERAND, "Illegal operand", 0));
		return 0;
	}		
	e = isRestrictedMemoryLocation(X);
	if (e.code != EX_NONE) {
		raiseException(e);
		return 0;
	}
	Address	T = translateAddress(getInteger(reg[SP_REG]) + 1);
	if (T.page == -1 && T.word == -1) return;
	storeInteger(reg[SP_REG], getInteger(reg[SP_REG]) + 1);
	storeInteger(page[T.page].word[T.word], getInteger(reg[IP_REG]) + WORDS_PER_INSTR);
	storeInteger(reg[IP_REG], X);
	return 1;
}