Exemplo n.º 1
0
bool Parser::Factor()
{
	if ("identifier" == tok) { //identifier or function call
//		ident();
		int a;
		if (!get_symbol_addr(lex, a)) {
//++++++++++++++++++++++++++++++++++++++
// check funcs. if found call FuncCall(), else not declared
			std::cout << "Error: Variable '" << lex << "' not declared.\n";
			return false;
		}
		assembly.push_back(icode(a_line,"PUSHM",std::to_string(a)));
		++a_line;
		L.getTokLex(tok,lex);		
//		std::cout << "Factor => ident\n";
		return true;
	} else if ("integer" == tok) { //integer
		assembly.push_back(icode(a_line,"PUSHV",lex));
		++a_line;
//		std::cout << "int = " << lex << std::endl;
		L.getTokLex(tok,lex);
//		std::cout << "Factor => int\n";
		return true;
	} else if ("real number" == tok) { // real
		assembly.push_back(icode(a_line,"PUSHV",lex));
		++a_line;
//		std::cout << "real = " << lex << std::endl;
		L.getTokLex(tok,lex);
//		std::cout << "Factor => real\n";
		return true;
	} else if ("true" == lex) { //true
		assembly.push_back(icode(a_line,"PUSHV","1"));
		++a_line;
		L.getTokLex(tok,lex);
//		std::cout << "Factor => bool\n";
		return true;
	} else if ("false" == lex) { //false
		assembly.push_back(icode(a_line,"PUSHV","0"));
		++a_line;
		L.getTokLex(tok,lex);
//		std::cout << "Factor => bool\n";
		return true;
	} else if ("(" == lex) { // ( Expr )
		L.getTokLex(tok,lex);
		if (!Expr()) return false;
		if (!(")" == lex)) {
			std::cout << "Expression not closed by ')'\n";
			return false;
		} else {
			L.getTokLex(tok,lex);
//			std::cout << "Factor => ( Expr )\n";
			return true;
		}
	} else {
		std::cout << "Error parsing factor\n";
		return false;
	}
}
Exemplo n.º 2
0
Arquivo: vfs.c Projeto: mponcet/Anima
void vfs_hook(void)
{
	unsigned long iterate_dir_p = get_symbol_addr("iterate_dir");

	if (!iterate_dir_p)
		return;

#if ARCH_X86
	x86_hw_breakpoint_register(1, iterate_dir_p, DR_RW_EXECUTE,
					0, iterate_dir_hook);
#endif
}
Exemplo n.º 3
0
/* find die_chain */
static unsigned long x86_get_die_chain_addr(void)
{
	unsigned long die_chain = 0;
	unsigned char *ptr;

	ptr = (unsigned char *)get_symbol_addr("unregister_die_notifier");
	if (!ptr)
		goto exit;

	for (int i = 0; i < 32; i++) {
		if (ptr[i] == 0x48 && ptr[i+1] == 0xc7 && ptr[i+2] == 0xc7) {
			/* mov $die_chain,%rdi */
			die_chain = *(unsigned int *)&ptr[i+3] | ~0xffffffffUL;
			break;
		}
	}
exit:
	return die_chain;
}
Exemplo n.º 4
0
bool Parser::Assign()
{
	int rhs;
	if (!("identifier" == tok)) {
		std::cout << "Expected identifier\n";
		return false;
	} else {
//		ident();
		if (!get_symbol_addr(lex, rhs)) {
			std::cout << "Error: Variable '" << lex << "' not declared.\n";
			return false;
		}
		L.getTokLex(tok,lex);
	}
	
	if (!("<-" == lex)) {
		std::cout << "Expected assignment, missing '<-'\n" << lex;
		return false;
	} else {
		L.getTokLex(tok,lex);
	}
	
	if (!Expr()) return false;
	
	assembly.push_back(icode(a_line,"POPM",std::to_string(rhs)));
	++a_line;
	
	if (!(";" == lex)) {
		std::cout << "Assignment not terminated by';'\n";
		return false;
	} else {
		L.getTokLex(tok,lex);
	}
	
//	std::cout << "Assign => ident <- Expr ;\n";
	return true;
}
Exemplo n.º 5
0
bool Parser::OptReads()
{
	if (")" == lex) {
//		std::cout << "OptVars => null\n";
		return true;
	}
	
	if (!("," == lex)) {
		std::cout << "Variable list not delimited by ','\n";
		return false;
	} else {
		L.getTokLex(tok,lex);
	}

	if (!("identifier" == tok)) {
		std::cout << "Invalid identifier in variable list\n";
		return false;
	} else {
//		ident();
		int a;
		if (!get_symbol_addr(lex, a)) {
			std::cout << "Error: Variable '" << lex << "' not declared.\n";
			return false;
		}
		assembly.push_back(icode(a_line,"PUSHI"));
		++a_line;
		assembly.push_back(icode(a_line,"POPM",std::to_string(a)));
		++a_line;
		L.getTokLex(tok,lex);
	}
	
	if (!OptReads()) return false;
	
//	std::cout << "OptVars => , ident OptVars\n";
	return true;
}