Example #1
0
goto_programt::targett scratch_programt::assign(const exprt &lhs, const exprt &rhs) {
  code_assignt assignment(lhs, rhs);
  targett instruction = add_instruction(ASSIGN);
  instruction->code = assignment;

  return instruction;
}
Example #2
0
goto_programt::targett scratch_programt::assume(const exprt &guard)
{
  targett instruction=add_instruction(ASSUME);
  instruction->guard=guard;

  return instruction;
}
Example #3
0
File: parse.c Project: rioki/d16
void read_instruction()
{
    instruction_t instr = {0};
    
    // skip empty lines
    if (next_token == EOL_TOKEN || next_token == EOF_TOKEN)
    {
        read_token();
        return;
    }
    
    if (next_token == LABEL_TOKEN)
    {
        read_label(&instr.label);
    }
    else
    {
        instr.label = 0;
    }
    
    read_opcode(&instr.opcode);
    
    if (next_token != EOL_TOKEN)
    {
        read_argument(&instr.arg1);
    }
    
    if (next_token == COMMA_TOKEN)
    {
    
        read_token();
        assert(token == COMMA_TOKEN);
        
        read_argument(&instr.arg2);    
    }
    
    read_token();
    if (token != EOL_TOKEN)
    {
        fprintf(stderr, "%s:%d: error: To much input.\n", get_scan_file(), get_scan_line());
        result = -1;  

        recover_error();
        return;
    }
    
    add_instruction(prog, instr);
}
Example #4
0
static void	set_labels_instruction(t_labels **labels, char **file_content)
{
  int		cur_case;
  t_labels	*labls;

  cur_case = -1;
  labls = *labels;
  while (file_content[++cur_case])
    {
      if (is_label(file_content[cur_case]) != -1)
	labls = search_in_labels(labls, get_label(file_content[cur_case]));
      if (is_instruction(file_content[cur_case]) != -1)
	add_instruction(&(labls->lst_cmd),
			get_name_instruction(file_content[cur_case]),
			get_params(get_instruction(file_content[cur_case])));
    }
}
Example #5
0
bool scratch_programt::check_sat() {
  fix_types();

  add_instruction(END_FUNCTION);

#ifdef DEBUG
  cout << "Checking following program for satness:" << endl;
  output(ns, "scratch", cout);
#endif

  symex.constant_propagation = constant_propagation;
  goto_symex_statet::propagationt::valuest constants;

  symex(symex_state, functions, *this);
  slice(equation);
  equation.convert(checker);

  return (checker.dec_solve() == decision_proceduret::D_SATISFIABLE);
}
Example #6
0
bool scratch_programt::check_sat(bool do_slice)
{
  fix_types();

  add_instruction(END_FUNCTION);

  remove_skip(*this);
  update();

#ifdef DEBUG
  std::cout << "Checking following program for satness:\n";
  output(ns, "scratch", std::cout);
#endif

  symex.constant_propagation=constant_propagation;
  goto_symex_statet::propagationt::valuest constants;

  symex(symex_state, functions, *this);

  if(do_slice)
  {
    slice(equation);
  }

  if(equation.count_assertions()==0)
  {
    // Symex sliced away all our assertions.
#ifdef DEBUG
    std::cout << "Trivially unsat\n";
#endif
    return false;
  }

  equation.convert(*checker);

#ifdef DEBUG
  std::cout << "Finished symex, invoking decision procedure.\n";
#endif

  return (checker->dec_solve()==decision_proceduret::D_SATISFIABLE);
}
Example #7
0
unsigned load_program(
	struct radeon_compiler *c,
	struct rc_test_file *test,
	const char *filename)
{
	char line[MAX_LINE_LENGTH];
	char path[MAX_PATH_LENGTH];
	FILE *file;
	unsigned *count;
	char **string_store;
	unsigned i = 0;

	memset(line, 0, sizeof(line));
	snprintf(path, MAX_PATH_LENGTH, "compiler/tests/%s", filename);
	file = fopen(path, "r");
	if (!file) {
		return 0;
	}
	memset(test, 0, sizeof(struct rc_test_file));

	count = &test->num_input_lines;

	while (fgets(line, MAX_LINE_LENGTH, file)){
		char last_char = line[MAX_LINE_LENGTH - 1];
		if (last_char && last_char != '\n') {
			fprintf(stderr, "Error line cannot be longer than 100 "
				"characters:\n%s\n", line);
			fclose(file);
			return 0;
		}

		// Comment
		if (line[0] == '#' || is_whitespace(line)) {
			continue;
		}

		if (line[0] == '=') {
			count = &test->num_expected_lines;
			continue;
		}

		(*count)++;
	}

	test->input = malloc(sizeof(char *) * test->num_input_lines);
	test->expected = malloc(sizeof(char *) * test->num_expected_lines);

	rewind(file);
	string_store = test->input;

	while(fgets(line, MAX_LINE_LENGTH, file)) {
		// Comment
		char * dst;
		if (line[0] == '#' || is_whitespace(line)) {
			continue;
		}

		if (line[0] == '=') {
			i = 0;
			string_store = test->expected;
			continue;
		}

		dst = string_store[i++] = malloc((strlen(line) + 1) *
							sizeof (char));
		strcpy(dst, line);
	}

	for (i = 0; i < test->num_input_lines; i++) {
		if (test->input[i][0] == 'c') {
			add_constant(c, test->input[i]);
			continue;
		}
		// XXX: Parse immediates from the file.
		add_instruction(c, test->input[i]);
	}

	fclose(file);
	return 1;
}
void ConsolidatedTests::TwoPlayersSimple()
{
    beginTest("Two Players Simple");
    initialize_field_manager(4);
    set_delay(0);
    startserver(65002);
    
    register_callbacks(join_game,
                       leave_game,
                       take_cell,
                       get_size,
                       get_cell_player,
                       is_there_a_winner);
    
    
    ScopedPointer<Client> frank = new Client();
    frank->setName("Frank");
    add_instruction(frank, "sleep", 10);
    add_instruction(frank, "join", "");
    
    NamedValueSet* instruction = add_instruction(frank, "take", "");
    instruction->set("x", 0);
    instruction->set("y", 1);
    instruction->set("name", "Frank");
    
    instruction = add_instruction(frank, "take", "");
    instruction->set("x", 0);
    instruction->set("y", 0);
    instruction->set("name", "Frank");
    
    instruction = add_instruction(frank, "take", "");
    instruction->set("x", 1);
    instruction->set("y", 0);
    instruction->set("name", "Frank");
    
    instruction = add_instruction(frank, "take", "");
    instruction->set("x", 1);
    instruction->set("y", 1);
    instruction->set("name", "Frank");
    
    instruction = add_instruction(frank, "status", "");
    instruction->set("x", 0);
    instruction->set("y", 1);
    
    add_instruction(frank, "sleep", 2);
    
    ScopedPointer<Client> susy = new Client();
    susy->setName("Susy");
    add_instruction(susy, "sleep", 5);
    add_instruction(susy, "join", "");
    
    instruction = add_instruction(susy, "take", "");
    instruction->set("x", 0);
    instruction->set("y", 1);
    instruction->set("name", "Susy");
    
    instruction = add_instruction(susy, "take", "");
    instruction->set("x", 0);
    instruction->set("y", 0);
    instruction->set("name", "Susy");
    
    instruction = add_instruction(susy, "take", "");
    instruction->set("x", 1);
    instruction->set("y", 0);
    instruction->set("name", "Susy");
    
    instruction = add_instruction(susy, "take", "");
    instruction->set("x", 1);
    instruction->set("y", 1);
    instruction->set("name", "Susy");
    
    add_instruction(susy, "sleep", 3);

    
    for(int i = 0; i < 4; i++)
    {
        for(int j = 0; j < 4; j++)
        {
            instruction = add_instruction(susy, "take", "");
            instruction->set("x", i);
            instruction->set("y", j);
            instruction->set("name", "Susy");
        }
    }
    
    pool.addJob(frank, false);
    pool.addJob(susy, false);
    
    while(pool.getNumJobs() > 0 )
    {
        Thread::sleep(100);
    }
    
    stopserver();
    while( server_running() > 0)
    {
        Thread::sleep(100);
    }
    release_field_manager();
    Thread::sleep(1000);
    
}