Beispiel #1
0
exprtree*
make_for (scanner_ident_t *counter_name_ident, exprtree *counter_init, exprtree *start, exprtree *end, exprtree *body)
{
    scanner_region_t region = counter_name_ident->region;

    if (start->result.length != 1 || end->result.length != 1 || start->result.number != end->result.number)
    {
	sprintf(error_string, _("The start and end of a for loop interval must be tuples of the same tag and length 1."));
	error_region = region;
	JUMP(1);
    }
    else
    {
	char end_name_buf[MAX_GENSYM_LEN];
	char *end_name = gensym(end_name_buf);
	scanner_ident_t *end_name_ident = scanner_make_ident(scanner_null_region, end_name);
	exprtree *end_init = make_assignment(end_name_ident, end);
	exprtree *init = make_sequence(counter_init, end_init);
	exprtree *inc = make_assignment(counter_name_ident,
					make_function_from_string("__add",
								  exprlist_append(make_var(counter_name_ident),
										  make_int_number(1, scanner_null_region)),
								  scanner_null_region));
	exprtree *invariant = make_function_from_string("__lessequal", exprlist_append(make_var(counter_name_ident),
										       make_var(end_name_ident)),
							scanner_null_region);

	free(end_name_ident);

	return make_sequence(init, make_while(invariant, make_sequence(body, inc)));
    }
}
Beispiel #2
0
void		do_in4_in8(t_list **a, t_list **b, t_list **in)
{
	char	**patterns;
	int		count;
	int		*abcd;
	int		*ops;
	int		j;

	patterns = load_file("patterns/IN4");
	count = lstlen(*a);
	abcd = make_sequence(count, 1, 1, 4);
	while (count)
	{
		ops = make_instr_arr(recognize_4pat(patterns, \
			grab_next_n(*a, 4), abcd));
		while (*ops != -1)
			make_move(a, b, in, *ops++);
		j = -1;
		while (++j < 4)
			abcd[j] = abcd[j] + 4;
		count -= 4;
	}
	free(abcd);
	free_split(patterns);
}
Beispiel #3
0
int			*in8map(int count)
{
	int *map;
	int *seq;

	map = (int *)ft_memalloc(sizeof(int) * count);
	seq = make_sequence(count / 8 - 1, -1, 2, count / 4);
	ft_memcpy(map, seq, sizeof(int) * count / 4);
	free(seq);
	seq = make_sequence(0, 1, 2, count / 4);
	ft_memcpy(map + (count / 4), seq, sizeof(int) * count / 4);
	free(seq);
	seq = make_sequence(0, 1, 4, count / 2);
	ft_memcpy(map + (count / 2), seq, sizeof(int) * count / 2);
	free(seq);
	return (map);
}
Beispiel #4
0
void		do_tr4_in8(t_list **a, t_list **b, t_list **in)
{
	char	**patterns;
	int		*abcd;
	t_kit	*k;

	patterns = load_file("patterns/IN8");
	abcd = make_sequence(lstlen(*a) / 4 + 1, -1, 1, 4);
	while (lstlen(*a) != lstlen(*b))
	{
		k = new_kit(a, b, in, abcd);
		do_ops_kit(make_instr_arr(recognize_8pat(patterns, \
			grab_next_n(*a, 8), abcd)), k, 8, 0);
		add_vec(abcd, make_sequence(2, -4, 2, 4), 4);
	}
	free(abcd);
	free_split(patterns);
}
Beispiel #5
0
inline ser_result_type
write(
	tag_write,
	Ser& ser,
	vector_cfg<S, V, C> const& cfg
) {
	DUCT_ASSERTE(std::numeric_limits<S>::max() >= cfg.vec.size());
	ser(static_cast<S>(cfg.vec.size()));
	if (!cfg.vec.empty()) {
		ser(make_sequence(cfg.vec.data(), cfg.vec.size()));
	}
}
        connection::status::type connection::set_connected() {
            status::type ret = conn_status;
            if (status::CONNECTING != conn_status || NULL == context) {
                return ret;
            }

            conn_status = status::CONNECTED;

            // new operation sequence
            make_sequence();

            return ret;
        }
        connection::status::type connection::set_disconnected(bool close_fd) {
            status::type ret = conn_status;
            if (status::DISCONNECTED == conn_status) {
                return ret;
            }

            // 先设置,防止重入
            conn_status = status::DISCONNECTED;

            release(close_fd);

            // new operation sequence
            make_sequence();
            return ret;
        }
Beispiel #8
0
int main(int argc, char ** argv) {
  float cutoff = 2000;

  if(argc > 1) {
    cutoff = atoi(argv[1]);
  }

  if(argc > 2) {
    gamp = atoi(argv[2]);
  }

  float freqs[] = {C_(1), D_(1), E_(1), E_(1),
                   C_(1), D_(1), E_(1),
                   C_(1), D_(1), E_(1), D_(1), C_(1), D_(1), C_(1)};

  gsequence = make_sequence(freqs, array_size(freqs), gamp, 0.13);
  gfilter = lowpass_make((Sampler)gsequence, cutoff, SAMPLE_FREQ);

  FILE * seqfile = fopen("seq.csv", "w");
  sample_to_file((Sampler)gsequence, SAMPLE_FREQ, 1.0, seqfile);
  fclose(seqfile);

  SDL_AudioSpec wanted;
  
  // Set the audio format 
  wanted.freq = SAMPLE_FREQ;
  wanted.format = AUDIO_S16SYS;
  wanted.channels = 1;    // 1 = mono, 2 = stereo 
  wanted.samples = 1024;  // Good low-latency value for callback 
  //wanted.size = 4096;
  wanted.padding = 0;
  wanted.callback = fill_audio;
  wanted.userdata = NULL;
  
  // Open the audio device, forcing the desired format 
  if ( SDL_OpenAudio(&wanted, NULL) < 0 ) {
    fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError());
    return(-1);
  }

  SDL_PauseAudio(0);
  SDL_Delay(2500);

  RELEASE_SAMPLER(gfilter);

  SDL_CloseAudio();
  return 0;
}
Beispiel #9
0
inline ser_result_type
read(
	tag_read,
	Ser& ser,
	vector_cfg<S, V, false>& cfg
) {
	S size{};
	ser(size);

	if (0 < size) {
		cfg.vec.resize(size);
		ser(make_sequence(cfg.vec.data(), cfg.vec.size()));
	} else {
		cfg.vec.clear();
	}
}
        connection::status::type connection::set_connecting(redisAsyncContext* c) {
            status::type ret = conn_status;
            if (status::CONNECTING == conn_status) {
                return ret;
            }

            if (c == context) {
                return ret;
            }

            context = c;
            conn_status = status::CONNECTING;
            c->data = this;

            // new operation sequence
            make_sequence();
            return ret;
        }
 connection::connection(): sequence(0), context(NULL), conn_status(status::DISCONNECTED) {
     make_sequence();
     holder.clu = NULL;
 }