示例#1
0
int	check_framerw(void) {
	ematrix		*e1,*e2;
	framestruc	*fr1,*fr2, *frx=NULL, *frxx=NULL;
	int		r = 0;
	char		buf[300], **ov;
	
	if (!frame_autosave_pref)  return 0;
	e1 = check_randommatrix(10,10,20);
	fr1 = new_frame(NULL);
	frame_setmatrix(fr1,e1);
	fr2 = new_frame(fr1);
	e2 = check_randommatrix(10,10,20);
	frame_setmatrix(fr2,e2);
	frame_addoption(fr1,new_option_onestr("finherit","abc",0),1);
	frame_addoption(fr1,new_option_onestr("finherit","def ................:.............. xxxx",0),2);
	frame_addoption(fr1,new_option_onestr("finherit","finherit",0),3);
	
	snprintf(buf,250,"<%smacek-test-x",frame_autosave_pref);
	buf[250] = 0;  frame_setname(fr1,buf+1);
	r = frame_write_tree(fr1,"This file is created only for debug-testing of frame disk operations in Macek...");
	if (r>=0)  frx = frame_doinput(buf);
	if (r>=0)  r++;
	if (frx) if (FRSONS(frx))  frxx = FRSONS(frx)[0];
	if (frx && frxx) {
		if (FRNUMSONS(frx)!=1)  r = -1;
		if (!ematrix_isequal(e1,FRMATRIX(frx)))  r = -2;
		if (!ematrix_isequal(e2,FRMATRIX(frxx)))  r = -3;
		ov = frame_getoptionval_all(frxx,"finherit");
		if (alist_getlength(ov)!=3)  r = -4;
		if (ov)  dispose_alist(ov);
	} else  r = -10;
	
	strcat(buf,"x");	/* (the file name from above +x) */
	if (r>=0) {
		frame_setname(fr2,buf+1);
		r = frame_write_tree(fr2,"This file is created only for debug-testing of frame disk operations in Macek...");
	}
	if (r>=0)  frxx = frame_doinput(buf);
	else  frxx = NULL;
	if (frxx) {
		ov = frame_getoptionval_all(frxx,"finherit");
		if (alist_getlength(ov)!=1)  r = -6;
		if (ov)  dispose_alist(ov);
	}
	if (r>=0)  r++;
	dispose_frame_recur(fr1);
	if (frx)  dispose_frame_recur(frx);
	if (frxx)  dispose_frame_recur(frxx);
	return (perror_occured || uerror_occured)? -1:r;
}
示例#2
0
文件: frame.cpp 项目: griha41/PortAMP
ID3v2_frame* parse_frame(char* bytes, int offset, int version)
{
    ID3v2_frame* frame = new_frame();

    // Parse frame header
    memcpy(frame->frame_id, bytes + offset, ID3_FRAME_ID);
    // Check if we are into padding
    if(memcmp(frame->frame_id, "\0\0\0\0", 4) == 0)
    {
        return NULL;
    }

    frame->size = btoi(bytes, 4, offset += ID3_FRAME_ID);
    if(version == ID3v24)
    {
        frame->size = syncint_decode(frame->size);
    }

    memcpy(frame->flags, bytes + (offset += ID3_FRAME_SIZE), 2);

    // Load frame data
    frame->data = (char*) malloc(frame->size * sizeof(char*));
    memcpy(frame->data, bytes + (offset += ID3_FRAME_FLAGS), frame->size);

    return frame;
}
示例#3
0
static void *capture_loop( void *d )
{
	struct dc1394_input *conf = (struct dc1394_input *)d;
	struct frame *f;
	int cam;

	for(;;)
	{
		dc1394_dma_multi_capture( conf->camera, conf->cam_count );
		for( cam = 0; cam < conf->cam_count; ++cam )
		{
			if( conf->cam[cam].running && ( f = new_frame() ) )
			{
				f->length = HEIGHT * WIDTH * 2;
				f->format = FORMAT_RAW_UYVY;
				f->width = WIDTH;
				f->height = HEIGHT;
				f->key = 1;

				memcpy( f->d, conf->camera[cam].capture_buffer,
						f->length );

				if( soft_queue_add( conf->cam[cam].outq, f ) < 0 )
					unref_frame( f );
			}
			dc1394_dma_done_with_buffer( &conf->camera[cam] );
		}
	}

	return NULL;
}
示例#4
0
void V4fWriter::AddFrame(cv::Mat frame)
{
	if (!frame.empty() && Opened && CURRENT_POSITION().Value().abs_coord > 0)
	{
		try
		{
			counterFrames++;
			if(counterFrames != MISSED_FRAMES)
				return;
			counterFrames = -1;
			vector<int> p;
			p.push_back(CV_IMWRITE_JPEG_QUALITY);
			p.push_back(50);
			vector<unsigned char> buf;
			imencode(".jpg", frame, buf, p);
			//—охран¤ем информацию о кадре
			if(dataSet)
			{
				if(current_start_time!=CURRENT_POSITION().Value().start_time)
				{
					this->Open();
				}
				int bufLen = buf.size();
				V4fFrame new_frame(CURRENT_DPP().Value(), CURRENT_POSITION().Value().abs_coord, frame.cols, frame.rows, buf);
				dataSet->WriteFrame(new_frame.dpp, new_frame.absCoord, ENCODE_CV_50, new_frame.height, new_frame.width, new_frame.img.data(), new_frame.img.size());
			}
		}
		catch (std::exception e)
		{
			LOG_ERROR(L"ќшибка при записи кадра cv::Mat (ќбзорное видеонаблюдение)");
		}
	}
}
示例#5
0
void	yy_startframe(char *name, framestruc *frst) {
	ematrix	*ee;
	
	if (frst && curframe)  {PROGERROR("frst may be given only at the start of scanning!");}
	errhint = -1;
	if (frst)  DEBUG(CURDLEV,"%*s# Appending input frame \"%s\" (fr-lev %d) ...\n",framelev,"",FRNAME(frst),framelev);
	else  DEBUG(CURDLEV,"%*s# New input frame \"%s\" (fr-lev %d) starting...\n",framelev,"",name?name:"?",framelev);
	
	if (frst)  curframe = frst;		/* the given frame frst is used for input */
	else curframe = new_frame(curframe);	/* a new frame structure is created here */
	if (name)  frame_setname(curframe,name);
	if (!FRMATRIX(curframe)) {		/* a new matrix for the frame (stores also cur. pfield) */
		frame_setmatrix(curframe, new_ematrix(16,16,16,16));
		frst = NULL;	/* (not to be used as current matrix dimensions next) */
		savefrm = NULL;
	} else {
		savefrm = ematrix_copy(FRMATRIX(curframe));
	}			/* (we may set the previous matrix back to the frame on error) */
	if (frst) {
		ee = FRMATRIX(frst);		/* the current (real) matrix dimensions */
		FRMATRIXROWS(curframe) = mxline = ROWSM(ee);
		FRMATRIXCOLS(curframe) = COLSM(ee);
		ROWSM(ee) = ROWSMAX(ee);  COLSM(ee) = COLSMAX(ee);
	} else {
		mxline = FRMATRIXROWS(curframe) = FRMATRIXCOLS(curframe) = 0;
	}
}
示例#6
0
static int end_block( void *d )
{
	struct rtp_spook_input *conf = (struct rtp_spook_input *)d;
	int i;

	if( ! conf->output )
	{
		spook_log( SL_ERR, "rtpi: missing output stream name" );
		return -1;
	}
	if( conf->fps < 0 )
	{
		spook_log( SL_ERR,
			"v4l: framerate not specified for webcam" );
		return -1;
	} else if( conf->fps > 0 )
	{
		conf->fincr = 1;
		conf->fbase = conf->fps;
	} 
    else
    {
    	spook_log( SL_INFO, "v4l: must figure out framerate" );
        return -1;
    }
        
	if( rtp_setup( conf ) < 0 ) return -1;
	conf->ex = new_exchanger( conf->fps, get_back_frame1, conf );
	for( i = 0; i < conf->fps; ++i ) 
        exchange_frame( conf->ex, new_frame() );
	pthread_create( &conf->thread, NULL, capture_loop, conf );

	return 0;
}
示例#7
0
framestruc*	frame_copy_ext(framestruc *fr, char *nnm, int copt, int ccom) {
	framestruc	*frn;
	optionstruc	**ol,*op;
	
	frn = new_frame(NULL);
	if (FRMATRIX(fr)) {
		frame_setmatrix(frn,ematrix_copy(FRMATRIX(fr)));
		FRPFINDEX(frn) = FRPFINDEX(fr);
	}
	if (nnm)  frame_setname(frn,nnm);
	else  frame_setname_ext(frn,FRNAME(fr),NULL,FREXTENS(fr));
	if (FRCOMMENT(fr) && !nnm)  FRCOMMENT(frn) = MSTRDUP(FRCOMMENT(fr));
	FRNUMBER(frn) = FRNUMBER(fr);
	
	if (copt && FROPTIONS(fr))
		for (ol=FROPTIONS(fr); *ol; ol++) {
			op = option_copy(*ol);
			frame_addoption(frn,op,OPTINDEX(op));
		}
	if (ccom && FRCOMMANDS(fr))
		for (ol=FRCOMMANDS(fr); *ol; ol++) {
			op = option_copy(*ol);
			frame_addcommand(frn,op,OPTINDEX(op));
		}
	FRLASTOPTI(frn) = FRLASTOPTI(fr);
	return frn;
}
示例#8
0
void capture_thread::run()
{
    while(1) {
        stopped_mutex.lock();
        if (stopped) {
            stopped_mutex.unlock();
            break;
        }
        stopped_mutex.unlock();
        update_done_mutex.lock();
        if (!update_done) {
            update_done_mutex.unlock();
            continue;
        }
        update_done = false;
        this->cvimage2qimage(cvQueryFrame(capture), this->img_frame);
        this->orig_img_frame = this->img_frame;
        if (this->img_border != NULL) {
            _img_painter->begin(&this->img_frame);
            _img_painter->setOpacity(0.4);
            _img_painter->drawImage(0, 0, *this->img_border);
            _img_painter->end();
        }
        emit new_frame(&this->img_frame, &this->update_done_mutex, &this->update_done);
        update_done_mutex.unlock();
    }
    qDebug() << "Stopping capture thread...";
}
示例#9
0
static void *mpeg4_loop( void *d )
{
	struct mpeg4_decoder *en = (struct mpeg4_decoder *)d;
	xvid_dec_frame_t xvid_dec_frame;
	xvid_dec_stats_t xvid_dec_stats;
	struct frame *out, *input;
	int used, pos;

	for(;;)
	{
		input = get_next_frame( en->ex, 1 );

		if( en->reset_pending && en->xvid_handle ) mpeg4_stop( en );
		if( ! en->xvid_handle ) mpeg4_start( en, input );

		out = new_frame();
		out->width = en->width;
		out->height = en->height;

		pos = 0;

		while( input->length - pos > 0 )
		{
			memset( &xvid_dec_frame, 0, sizeof( xvid_dec_frame ) );
			xvid_dec_frame.version = XVID_VERSION;
			xvid_dec_frame.general = 0;
			xvid_dec_frame.bitstream = input->d + pos;
			xvid_dec_frame.length = input->length - pos;
			xvid_dec_frame.output.plane[0] = out->d;
			xvid_dec_frame.output.stride[0] = 2 * out->width;
			xvid_dec_frame.output.csp = XVID_CSP_UYVY;
			xvid_dec_stats.version = XVID_VERSION;

			used = xvid_decore( en->xvid_handle, XVID_DEC_DECODE,
					&xvid_dec_frame, &xvid_dec_stats );
			if( used < 0 )
			{
				out->length = 0;
				spook_log( SL_WARN, "mpeg4: XviD decoding failed!" );
			}
			if( xvid_dec_stats.type == XVID_TYPE_VOL )
			{
				out->width = en->width = xvid_dec_stats.data.vol.width;
				out->height = en->height = xvid_dec_stats.data.vol.height;
			}
			pos += used;
		}

		out->format = FORMAT_RAW_UYVY;
		out->length = 2 * out->width * out->height;
		out->key = 1;

		deliver_frame( en->ex, out );

		unref_frame( input );
	}

	return NULL;
}
示例#10
0
文件: type.c 项目: cherry-wb/Hot-Fuzz
/* anal_rel_type -- View a type as P (dom x ran) */
PUBLIC bool anal_rel_type(type t, type *dom, type *ran, tree cxt)
{
     frame f = arid;

     unpack(&t, &f, TRUE);
     switch (t->t_kind) {
     case POWERT:
	  t = t->t_base;
	  unpack(&t, &f, TRUE);
	  switch (t->t_kind) {
	  case CPRODUCT: {
	       if (t->t_nfields != 2)
		    return FALSE;
	       *dom = seal(t->t_field[0], f);
	       *ran = seal(t->t_field[1], f);
	       return TRUE;
	  }

	  case TYPEVAR: 
	       if (f == arid)
		    return FALSE;
	       else {
		    frame ff = new_frame(2, cxt);
		    tv_val(t, f) = mk_binprod(*dom = tv_ref(0, ff),
					      *ran = tv_ref(1, ff));
		    return TRUE;
	       }
	   
	  default:
	       return FALSE;
	  }

     case TYPEVAR: 
	  if (f == arid)
	       return FALSE;
	  else {
	       frame ff = new_frame(2, cxt);
	       tv_val(t, f) = mk_power(mk_binprod(*dom = tv_ref(0, ff),
						  *ran = tv_ref(1, ff)));
	       return TRUE;
	  }

     default:
	  return FALSE;
     }
}
示例#11
0
文件: dialog.c 项目: bbidulock/wmblob
static GtkWidget *create_dialog_right()
{
	GtkWidget *right;
	GtkWidget *widget;
	GtkWidget *vbox;

	right = gtk_vbox_new(FALSE, 10);

	/* save, apply, close, exit */

	widget = gtk_button_new_with_mnemonic("_Apply");
	g_signal_connect(G_OBJECT(widget), "clicked",
			G_CALLBACK(callback_apply), NULL);
	gtk_box_pack_start(GTK_BOX(right), widget, FALSE, FALSE, 0);


	widget = gtk_button_new_with_mnemonic("_Close dialog");
	g_signal_connect(G_OBJECT(widget), "clicked",
			G_CALLBACK(callback_close), NULL);
	gtk_box_pack_start(GTK_BOX(right), widget, FALSE, FALSE, 0);

	widget = gtk_button_new_with_mnemonic("E_xit wmblob");
	g_signal_connect(G_OBJECT(widget), "clicked",
			G_CALLBACK(callback_exit), NULL);
	gtk_box_pack_start(GTK_BOX(right), widget, FALSE, FALSE, 0);

	widget = gtk_button_new_with_mnemonic("A_bout...");
	g_signal_connect(G_OBJECT(widget), "clicked",
			G_CALLBACK(callback_about), NULL);
	gtk_box_pack_start(GTK_BOX(right), widget, FALSE, FALSE, 0);

	/* preset stuff */

	vbox = new_frame(right, "Presets");

	widget = gtk_button_new_with_mnemonic("_Load");
	g_signal_connect(G_OBJECT(widget), "clicked",
			G_CALLBACK(callback_preset_load), NULL);
	gtk_box_pack_start(GTK_BOX(vbox), widget, FALSE, FALSE, 0);

	widget = gtk_button_new_with_mnemonic("_Save");
	g_signal_connect(G_OBJECT(widget), "clicked",
			G_CALLBACK(callback_preset_save), NULL);
	gtk_box_pack_start(GTK_BOX(vbox), widget, FALSE, FALSE, 0);

	widget = gtk_button_new_with_mnemonic("_Delete");
	g_signal_connect(G_OBJECT(widget), "clicked",
			G_CALLBACK(callback_preset_delete), NULL);
	gtk_box_pack_start(GTK_BOX(vbox), widget, FALSE, FALSE, 0);

	wg_preset_list = gtk_combo_new();
	fill_in_presets(wg_preset_list);
	gtk_widget_set_size_request(wg_preset_list, 128, 20);
	gtk_box_pack_start(GTK_BOX(vbox), wg_preset_list, FALSE, FALSE, 0);

	return(right);
}
示例#12
0
frameT *read_csv (char *file_name)
{
	FILE			*fp;
	unsigned char	buf[CSV_BUF_SIZE];
	unsigned char	header_buf[CSV_BUF_SIZE];
	unsigned char	*row[MAX_COLUMNS];
	unsigned char	*header[MAX_COLUMNS];
	int				ncol, cols;
	int				n, i;
	frameT			*frame;
	csvT			*csv;

	csv = open_csv (file_name);
	fp = csv->fp;


	// Parse header
	n = csv_row_fread (fp, header_buf, CSV_BUF_SIZE, header, MAX_COLUMNS, ',', CSV_TRIM | CSV_QUOTES, &ncol);
	if (n <= 0)
	{
		fprintf (stderr, "Failed to read header from CSV file\n");
		exit (-1);
	}

	// Parse the first data row to determine data types

	n = csv_row_fread (fp, buf, CSV_BUF_SIZE, row, ncol, ',', CSV_TRIM | CSV_QUOTES, &cols);
	if (n <= 0)
	{
		fprintf (stderr, "File has no data\n");
		exit (-1);
	}
	frame = new_frame (file_name, ncol);
	frame->csv = csv;
	for (i=0; i<ncol; i++) init_column (frame, i, (char *)header[i], guess_type((char *) row[i]));

	for (i=0; i<ncol; i++) column_init_data (frame, i, csv->est_rows);
	frame->allocated_rows = csv->est_rows;
		
	frame->region_rows = (unsigned char *) malloc (frame->allocated_rows);
	if (!frame->region_rows)
	{
		fprintf (stderr, "Failed to allocate region_rows\n");	
		exit (-1);
	}
	frame->allocated_region_rows = frame->allocated_rows;

	if (csv->est_rows < 10000)
	{
		load_all_rows (frame);
	} else
	{
		load_random_rows (frame, 1.0);
	}

	return (frame);
}
示例#13
0
void tag_set_composer(char* composer, char encoding, ID3v2_tag* tag)
{
    ID3v2_frame* composer_frame = NULL;
    if( ! (composer_frame = tag_get_composer(tag)))
    {
        composer_frame = new_frame();
        add_to_list(tag->frames, composer_frame);
    }

    set_text_frame(composer, encoding, COMPOSER_FRAME_ID, composer_frame);
}
示例#14
0
Object *new_exception_frame(Object *cxt, Object *frame, Object *ex) {
  Object *catch_frame = new_object(cxt, find_catch_frame(cxt, frame));
  Object *ret_frame = get(cxt, catch_frame, "return");
  Object *self = get_self(cxt, catch_frame);
  Object *catch_block = get_catch_block(cxt, catch_frame);
  Object *new_catch_frame = new_frame(cxt, self, catch_block, ret_frame);
  Object *old_local = get(cxt, catch_frame, "local");
  set_lexical_parent(cxt, new_catch_frame, old_local);
  push(cxt, get(cxt, ret_frame, "stack"), ex);
  return new_catch_frame;
}
示例#15
0
void tag_set_title(char* title, char encoding, ID3v2_tag* tag)
{
    ID3v2_frame* title_frame = NULL;
    if( ! (title_frame = tag_get_title(tag)))
    {
        title_frame = new_frame();
        add_to_list(tag->frames, title_frame);
    }

    set_text_frame(title, encoding, TITLE_FRAME_ID, title_frame);
}
示例#16
0
void goto_symex_statet::initialize(const goto_programt::const_targett & start, const goto_programt::const_targett & end, const goto_programt *prog, unsigned int thread_id)
{
  new_frame(thread_id);

  source.is_set=true;
  source.thread_nr = thread_id;
  source.pc=start;
  source.prog = prog;
  top().end_of_function=end;
  top().calling_location=symex_targett::sourcet(top().end_of_function, prog);
}
示例#17
0
void tag_set_album_artist(char* album_artist, char encoding, ID3v2_tag* tag)
{
    ID3v2_frame* album_artist_frame = NULL;
    if( ! (album_artist_frame = tag_get_album_artist(tag)))
    {
        album_artist_frame = new_frame();
        add_to_list(tag->frames, album_artist_frame);
    }

    set_text_frame(album_artist, encoding, ALBUM_ARTIST_FRAME_ID, album_artist_frame);
}
示例#18
0
void tag_set_track(char* track, char encoding, ID3v2_tag* tag)
{
    ID3v2_frame* track_frame = NULL;
    if( ! (track_frame = tag_get_track(tag)))
    {
        track_frame = new_frame();
        add_to_list(tag->frames, track_frame);
    }

    set_text_frame(track, encoding, TRACK_FRAME_ID, track_frame);
}
示例#19
0
void tag_set_genre(char* genre, char encoding, ID3v2_tag* tag)
{
    ID3v2_frame* genre_frame = NULL;
    if( ! (genre_frame = tag_get_genre(tag)))
    {
        genre_frame = new_frame();
        add_to_list(tag->frames, genre_frame);
    }

    set_text_frame(genre, encoding, GENRE_FRAME_ID, genre_frame);
}
示例#20
0
void tag_set_album_cover_from_bytes(char* album_cover_bytes, char* mimetype, int picture_size, ID3v2_tag* tag)
{
    ID3v2_frame* album_cover_frame = NULL;
    if( ! (album_cover_frame = tag_get_album_cover(tag)))
    {
        album_cover_frame = new_frame();
        add_to_list(tag->frames, album_cover_frame);
    }

    set_album_cover_frame(album_cover_bytes, mimetype, picture_size, album_cover_frame);
}
示例#21
0
void tag_set_disc_number(char* disc_number, char encoding, ID3v2_tag* tag)
{
    ID3v2_frame* disc_number_frame = NULL;
    if( ! (disc_number_frame = tag_get_disc_number(tag)))
    {
        disc_number_frame = new_frame();
        add_to_list(tag->frames, disc_number_frame);
    }

    set_text_frame(disc_number, encoding, DISC_NUMBER_FRAME_ID, disc_number_frame);
}
示例#22
0
void tag_set_comment(char* comment, char encoding, ID3v2_tag* tag)
{
    ID3v2_frame* comment_frame = NULL;
    if( ! (comment_frame = tag_get_comment(tag)))
    {
        comment_frame = new_frame();
        add_to_list(tag->frames, comment_frame);
    }

    set_comment_frame(comment, encoding, comment_frame);
}
示例#23
0
void tag_set_year(char* year, char encoding, ID3v2_tag* tag)
{
    ID3v2_frame* year_frame = NULL;
    if( ! (year_frame = tag_get_year(tag)))
    {
        year_frame = new_frame();
        add_to_list(tag->frames, year_frame);
    }

    set_text_frame(year, encoding, YEAR_FRAME_ID, year_frame);
}
示例#24
0
void kiss_session::handle_incoming_data(const unsigned char* buffer, std::size_t length) {
	if (config::Instance()->debug())
		std::cout << "data: " << length << std::endl;

	inbuff_.insert(inbuff_.end(), buffer, buffer + length);

	unsigned int i = 0, start, end, last_good_pos = -1;

	/*
	 * A KISS frame begins and ends with a KISS_FEND, not having any KISS_FEND in the middle.
	 */

	while (i < inbuff_.size()) {
		for (; i < inbuff_.size(); ++i)
			if (inbuff_[i] == KISS_FEND)
				break;

		last_good_pos = i - 1;

		if (i < inbuff_.size() && inbuff_[i] == KISS_FEND) {
			start = i;
			i++;

			for (; i < inbuff_.size(); ++i)
				if (inbuff_[i] == KISS_FEND)
					break;

			if (i < inbuff_.size() && inbuff_[i] == KISS_FEND) {
				// Found a KISS frame.
				end = i;
				last_good_pos = i;
				i++;
				frame_ptr new_frame(new frame());
				int ret = kiss_decode(inbuff_.data() + start, end - start + 1, &(new_frame->get_data()));

				if (ret && (new_frame->get_data().size() > 0)) {
					if (config::Instance()->debug())
						std::cout << "NEW FRAME FROM TCP " << start << ", " << end << std::endl;
					else
						std::cout << "New local frame" << std::endl;

					new_frame->print();

					get_kiss_server()->get_modem()->output_packet_to_sc(new_frame);
				}
			}
		}
	}

	inbuff_.erase(inbuff_.begin(), inbuff_.begin() + last_good_pos + 1);

}
示例#25
0
文件: tac.c 项目: arakan94/ifj15
int run_tac(unsigned start, unsigned var_count) {
	Tl_var result;
	int err = add_frame(new_frame(var_count), 0, &result);
	if (err != OK)
		return err;

	current_line = start;

	//printf("Interpreting from %d:\n", start);

	while ((current_line < maxline) && (current_line > 8)) {
		//printf(":%d:\n", current_line);

		Tl_var *op1 = decode_op1(ta_table[current_line].op1);
		Tl_var *op2 = decode_op2(ta_table[current_line].op2);
		Tl_var *dest = decode_dest(ta_table[current_line].dest);

		if (run_error != OK)
			return run_error;

		if ((op1 != NULL) && (!op1->defined)) {
			fprintf(stderr, "Uninitialized variable '%s'\n",
				((Tlocal_sym_tab_node*)ta_table[current_line].op1)->name);
			return ERR_VARINIT;
		}

		if ((op2 != NULL) && (!op2->defined)) {
			fprintf(stderr, "Uninitialized variable '%s'\n",
				((Tlocal_sym_tab_node*)ta_table[current_line].op1)->name);
			return ERR_VARINIT;
		}

		if (dest != NULL)
			dest->defined = 1;

		i_func f = ta_table[current_line].f;

		if (f == NULL) {
			fprintf(stderr, "Unknown instruction\n");
			return ERR_RUN;
		}

		current_line++;

		f(op1, op2, dest);

		if (run_error != OK)
			return run_error;
	}

	return OK;
}
示例#26
0
文件: expr.c 项目: cherry-wb/Hot-Fuzz
/* ref_type -- find type of a reference */
PUBLIC type ref_type(sym x, tree p, env e, tree cxt)
{
     def d = find_def(x, e);
     frame f;

     if (d == NULL) {
#ifdef ASSUME
	  type t;
	  if (qflag && p == nil && (t = assume_type(x)) != NULL)
	       return t;
#endif

	  if (! partial_env(e)) {
	       tc_error(cxt->x_loc, "Identifier %n is not declared", x);
	       if (cxt->x_kind != REF)
		    tc_e_etc("Expression: %z", cxt);
	       tc_e_end();
	  }

	  return err_type;
     }

     f = new_frame(d->d_nparams, cxt);
     
     if (p != nil)
	  switch (d->d_kind) {
	  case GSET:
	  case VAR:
	       tc_error(cxt->x_loc, "%s %n cannot have parameters",
			d->d_kind == GSET ? "Basic type" : "Variable", x);
	       tc_e_etc("Expression: %z", cxt);
	       tc_e_end();
	       return err_type;

	  case GENCONST:
	       get_params("Generic constant", x, p, e, f, cxt->x_loc);
	       break;

	  default:
	       bad_tag("ref_type", d->d_kind);
	  }
	   
     if (! aflag && d->d_abbrev)
	  return mk_power(mk_abbrev(d, (p != nil ? f : alias(f))));
     else
	  return seal(d->d_type, f);
}
示例#27
0
static void get_back_frame1( struct frame *f, void *d )
{
	struct frame *newf;
	struct rtp_spook_input *conf = (struct rtp_spook_input *)d;

    newf = new_frame();
    if(newf)
    {
        exchange_frame( conf->ex, newf );
	    deliver_frame_to_stream( f, conf->output );
    }
    else
    {
		//printf("\r\ndrop frame!");
        unref_frame(f);
    }
}
示例#28
0
文件: env.c 项目: EarlGray/SECD
cell_t *setup_frame(secd_t *secd, cell_t *argnames, cell_t *argvals, cell_t *env) {
    cell_t *args_io = SECD_NIL;

    /* setup the new frame */
    cell_t *frame = new_frame(secd, argnames, argvals);

    cell_t *ret = walk_through_arguments(secd, frame, &args_io);
    assert_cell(ret, "setup_frame: argument check failed");

    cell_t *new_io = new_frame_io(secd, args_io, env);
    assert_cell(new_io, "setup_frame: failed to set new frame I/O\n");

    frame->as.frame.io = share_cell(secd, new_io);
    secd->input_port = get_car(new_io);
    secd->output_port = get_cdr(new_io);

    return frame;
}
示例#29
0
文件: env.c 项目: EarlGray/SECD
cell_t *make_native_frame(secd_t *secd,
                          const native_binding_t *binding)
{
    int i;
    cell_t *symlist = SECD_NIL;
    cell_t *vallist = SECD_NIL;

    for (i = 0; binding[i].name; ++i) {
        cell_t *sym = new_symbol(secd, binding[i].name);
        cell_t *val = new_const_clone(secd, binding[i].val);
        if (not_nil(val))
            sym->nref = val->nref = DONT_FREE_THIS;
        symlist = new_cons(secd, sym, symlist);
        vallist = new_cons(secd, val, vallist);
    }

    return new_frame(secd, symlist, vallist);
}
示例#30
0
void asm_proc_function_block(struct ir_code *head, struct ir_code *tail) {
    assert(head && tail && head != tail);
    assert(head->kind == IR_FUNCTION);
    assert(frame == NULL);
    new_frame();
    add_mips_inst(new_mips_inst(MIPS_LABEL, .label=head->op->name));
    // Generate prologue:
    // sw $fp, 0($sp)
    // sw $ra, -4($sp)
    // move $fp, $sp
    // addi $sp, $sp, -frame_size
    struct mips_inst *inst;
    add_mips_inst(new_mips_inst(MIPS_SW, .op1=reg_op[REG_FP], \
                .op2 = new_mips_op(MIPS_OP_ADDR, .reg=REG_SP, .offset=0)));
    add_mips_inst(new_mips_inst(MIPS_SW, .op1=reg_op[REG_RA], \
                .op2 = new_mips_op(MIPS_OP_ADDR, .reg=REG_SP, .offset=-4)));
    add_mips_inst(new_mips_inst(MIPS_MOVE, .op1=reg_op[REG_FP], .op2=reg_op[REG_SP]));
    add_mips_inst(inst = new_mips_inst(MIPS_ADDI, .op1=reg_op[REG_SP], \
                .op2=reg_op[REG_SP], .op3=new_mips_op(MIPS_OP_IMM)));
    int *p_frame_size = {&inst->op3->value}; // wait to be filled
    // put arguments in the frame variables table
    struct ir_code *p = head->next;
    while (p->kind == IR_PARAM) {
        add_arg_var(p->op->kind, p->op->no);
        p = p->next;
    }
    // Process other code (cut them into basic blocks)
    while (p != tail->next) {
        switch (p->kind) {
        case IR_FUNCTION:
        case IR_PARAM:
            assert(false);
        default:
            asm_proc_ir_code(p);
        }
        p = p->next;
    }
    // back fill
    *p_frame_size = frame->var_offset;
    release_frame();
}