void EvolutionGraphWidget::mousePressEvent(QMouseEvent* event)
{
	event->accept();

	if (event->button() == Qt::LeftButton)	
	{
		if (event->modifiers().testFlag(Qt::ControlModifier))// + Control  的话  连接线  边加入到图中 
		{

			m_dotAddSelected=hitDot(Vector2f(event->x(), event->y()));
			if ( m_dotAddSelected.x>=0 &&  m_dotAddSelected.y>=0  ) 
				if (m_startPoint==Vector2i(2500,2500))
				{
					m_startPoint=m_dotAddSelected;
				} 
				else
				{
					m_endPoint=m_dotAddSelected;
					dag.addEdge(m_startPoint,m_endPoint);

					m_newAddEdge=Edge(m_startPoint,m_endPoint);
					m_startPoint=Vector2i(2500,2500);
					m_endPoint=Vector2i(2500,2500);
				}
				//第一个  加入  start

				//第二个
		} 
		else
		{
			// see if a key was selected
			Vector2f sHit = Vector2f(event->x(), static_cast<float>(height()) - event->y());
			Vector2f hit = stow(sHit);


			m_dotSelected=hitDot(Vector2f(event->x(), event->y()));
			cout<<m_dotSelected<<endl;

			if (m_dotSelected.x>=0)
			{
				m_curTimeStep=m_dotSelected.x;
				setupTransfunc();
				emit sendTimeNumSelected(m_dotSelected.x+1);
				if (m_dotSelected.y>=0 && m_dotSelected.y<m_arryNumFeature[m_dotSelected.x+1])
				{
					m_clusterNumSelected=m_dotSelected.y;
					m_pSelectedKey=m_keyColletionFull[m_dotSelected.x]->getKey(m_dotSelected.y);
				}
			}
		}
		
		update();
	}



}
示例#2
0
void
execinit(void)
{
	char **p;

	nextv = 0;
	for(p = myenv; *p; p++)
		envinsert(*p, stow(""));

	symtraverse(S_VAR, ecopy);
	envinsert(0, 0);
}
示例#3
0
static Word*
extractpat(char *s, char **r, char *term, char *end)
{
	int save;
	char *cp;
	Word *w;

	cp = charin(s, term);
	if(cp){
		*r = cp;
		if(cp == s)
			return 0;
		save = *cp;
		*cp = 0;
		w = stow(s);
		*cp = save;
	} else {
		*r = end;
		w = stow(s);
	}
	return w;
}
示例#4
0
static Word*
subsub(Word *v, char *s, char *end)
{
	int nmid;
	Word *head, *tail, *w, *h;
	Word *a, *b, *c, *d;
	Bufblock *buf;
	char *cp, *enda;

	a = extractpat(s, &cp, "=%&", end);
	b = c = d = 0;
	if(PERCENT(*cp))
		b = extractpat(cp+1, &cp, "=", end);
	if(*cp == '=')
		c = extractpat(cp+1, &cp, "&%", end);
	if(PERCENT(*cp))
		d = stow(cp+1);
	else if(*cp)
		d = stow(cp);

	head = tail = 0;
	buf = newbuf();
	for(; v; v = v->next){
		h = w = 0;
		if(submatch(v->s, a, b, &nmid, &enda)){
			/* enda points to end of A match in source;
			 * nmid = number of chars between end of A and start of B
			 */
			if(c){
				h = w = wdup(c);
				while(w->next)
					w = w->next;
			}
			if(PERCENT(*cp) && nmid > 0){	
				if(w){
					bufcpy(buf, w->s, strlen(w->s));
					bufcpy(buf, enda, nmid);
					insert(buf, 0);
					free(w->s);
					w->s = strdup(buf->start);
				} else {
					bufcpy(buf, enda, nmid);
					insert(buf, 0);
					h = w = newword(buf->start);
				}
				buf->current = buf->start;
			}
			if(d && *d->s){
				if(w){

					bufcpy(buf, w->s, strlen(w->s));
					bufcpy(buf, d->s, strlen(d->s));
					insert(buf, 0);
					free(w->s);
					w->s = strdup(buf->start);
					w->next = wdup(d->next);
					while(w->next)
						w = w->next;
					buf->current = buf->start;
				} else
					h = w = wdup(d);
			}
		}
		if(w == 0)
			h = w = newword(v->s);
	
		if(head == 0)
			head = h;
		else
			tail->next = h;
		tail = w;
	}
	freebuf(buf);
	delword(a);
	delword(b);
	delword(c);
	delword(d);
	return head;
}
示例#5
0
void
main(int argc, char **argv)
{
	Word *w;
	char *s, *temp;
	char *files[256], **f = files, **ff;
	int sflag = 0;
	int i;
	int tfd = -1;
	Biobuf tb;
	Bufblock *buf;
	Bufblock *whatif;

	/*
	 *  start with a copy of the current environment variables
	 *  instead of sharing them
	 */

	Binit(&bout, 1, OWRITE);
	buf = newbuf();
	whatif = 0;
	USED(argc);
	for(argv++; *argv && (**argv == '-'); argv++)
	{
		bufcpy(buf, argv[0], strlen(argv[0]));
		insert(buf, ' ');
		switch(argv[0][1])
		{
		case 'a':
			aflag = 1;
			break;
		case 'd':
			if(*(s = &argv[0][2]))
				while(*s) switch(*s++)
				{
				case 'p':	debug |= D_PARSE; break;
				case 'g':	debug |= D_GRAPH; break;
				case 'e':	debug |= D_EXEC; break;
				}
			else
				debug = 0xFFFF;
			break;
		case 'e':
			explain = &argv[0][2];
			break;
		case 'f':
			if(*++argv == 0)
				badusage();
			*f++ = *argv;
			bufcpy(buf, argv[0], strlen(argv[0]));
			insert(buf, ' ');
			break;
		case 'i':
			iflag = 1;
			break;
		case 'k':
			kflag = 1;
			break;
		case 'n':
			nflag = 1;
			break;
		case 's':
			sflag = 1;
			break;
		case 't':
			tflag = 1;
			break;
		case 'u':
			uflag = 1;
			break;
		case 'w':
			if(whatif == 0)
				whatif = newbuf();
			else
				insert(whatif, ' ');
			if(argv[0][2])
				bufcpy(whatif, &argv[0][2], strlen(&argv[0][2]));
			else {
				if(*++argv == 0)
					badusage();
				bufcpy(whatif, &argv[0][0], strlen(&argv[0][0]));
			}
			break;
		default:
			badusage();
		}
	}
#ifdef	PROF
	{
		extern etext();
		monitor(main, etext, buf, sizeof buf, 300);
	}
#endif

	if(aflag)
		iflag = 1;
	usage();
	syminit();
	initenv();
	usage();

	/*
		assignment args become null strings
	*/
	temp = 0;
	for(i = 0; argv[i]; i++) if(utfrune(argv[i], '=')){
		bufcpy(buf, argv[i], strlen(argv[i]));
		insert(buf, ' ');
		if(tfd < 0){
			temp = maketmp();
			if(temp == 0) {
				perror("temp file");
				Exit();
			}
			close(create(temp, OWRITE, 0600));
			if((tfd = open(temp, 2)) < 0){
				perror(temp);
				Exit();
			}
			Binit(&tb, tfd, OWRITE);
		}
		Bprint(&tb, "%s\n", argv[i]);
		*argv[i] = 0;
	}
	if(tfd >= 0){
		Bflush(&tb);
		LSEEK(tfd, 0L, 0);
		parse("command line args", tfd, 1);
		remove(temp);
	}

	if (buf->current != buf->start) {
		buf->current--;
		insert(buf, 0);
	}
	symlook("MKFLAGS", S_VAR, (void *) stow(buf->start));
	buf->current = buf->start;
	for(i = 0; argv[i]; i++){
		if(*argv[i] == 0) continue;
		if(i)
			insert(buf, ' ');
		bufcpy(buf, argv[i], strlen(argv[i]));
	}
	insert(buf, 0);
	symlook("MKARGS", S_VAR, (void *) stow(buf->start));
	freebuf(buf);

	if(f == files){
		if(access(MKFILE, 4) == 0)
			parse(MKFILE, open(MKFILE, 0), 0);
	} else
		for(ff = files; ff < f; ff++)
			parse(*ff, open(*ff, 0), 0);
	if(DEBUG(D_PARSE)){
		dumpw("default targets", target1);
		dumpr("rules", rules);
		dumpr("metarules", metarules);
		dumpv("variables");
	}
	if(whatif){
		insert(whatif, 0);
		timeinit(whatif->start);
		freebuf(whatif);
	}
	execinit();
	/* skip assignment args */
	while(*argv && (**argv == 0))
		argv++;

	catchnotes();
	if(*argv == 0){
		if(target1)
			for(w = target1; w; w = w->next)
				mk(w->s);
		else {
			fprint(2, "mk: nothing to mk\n");
			Exit();
		}
	} else {
		if(sflag){
			for(; *argv; argv++)
				if(**argv)
					mk(*argv);
		} else {
			Word *head, *tail, *t;

			/* fake a new rule with all the args as prereqs */
			tail = 0;
			t = 0;
			for(; *argv; argv++)
				if(**argv){
					if(tail == 0)
						tail = t = newword(*argv);
					else {
						t->next = newword(*argv);
						t = t->next;
					}
				}
			if(tail->next == 0)
				mk(tail->s);
			else {
				head = newword("command line arguments");
				addrules(head, tail, strdup(""), VIR, mkinline, 0);
				mk(head->s);
			}
		}
	}
	if(uflag)
		prusage();
	exits(0);
}
示例#6
0
文件: fsm.c 项目: dejarc/372Project
/* *****************************************************************************
 * finitestatemachine (fsm)
 * *****************************************************************************
 * The finite state machine, containing an array of all possible microstates the
 * computer can be in. Apart from containing the ROM of microstates, relies on
 * external control by the LC2200 to progress to the next finite state. Used for
 * state transition by flipping the appropriate load, drive, and write switches
 * and updating the state to be next executed. The fsm is organized with the
 * first 10 bits representing the current state's opcode, z-value, and state--
 * these are used for finding the next appropriate state later. The next 13 bits
 * tell the control unit what drive, load, and write signals should be on or
 * off. The next 5 bits tell the control unit what function the alu should
 * execute and which of the three registers the ir should drive.
 *
 * Layout of FSM by line:
 * sig	opcode	z-value	state	drive	load	write	alufunc	irreg 	nextstate
 * com	-		-		-		PARMO	PABMIZ	MR		-		-		-
 * idx	0123	4		56789	01234	567890	12		345		67		8901
 * bin	0000	0		00000	00000	000000	00		000		00		0000
 *
 * For bit flipping and signaling, when updating, the fsm will provide bit
 * switches to explain how each current state should determine the next
 * sequential state by using the last four bits in the microstate line. It is
 * expected that the control unit take care of the following conditions: if the
 * current state is ifetch3, the bit sequence 1000 will search only opcodes
 * using the opcode in the ir; if the current state is beq3, the control unit
 * reads primes the z-value by triggering the alu. The default starting state
 * upon boot-up is at ifetch1.
 */
fsm_ fsm_ctor() {
	int romaddress;
	finitestatemachine *fsm = malloc(sizeof(finitestatemachine));
	fsm->state = 0; //ifetch1
				   /* MICROSTATE BIT DETAIL
				    *
				    *			 MICROSTATE ROM LAYOUT
				    * 	         op   z st    dr    ld     wr fn  rg +
				    * 	         code - ##### PARMO PABMIZ MR ### ## OZ+S
					* 			 0123 4 56789 01234 567890 12 345 67 8901
				    *
				    * op 0123		the opcode address of the command
				    * z  4			the z address of the command
				    * st 56789		the state address of the command
				    * dr 01234		drive bits in order: PC,ALU,REG,MEM,OFF
				    * ld 567890		load bits in order:  PC,ALU-A,ALU-B,MAR,IR,Z
				    * wr 12			write bits in order: MEM,REG
				    * fn 345		function bits to ALU
				    * rg 67			register bits to IR
				    * +  8901		how to go to the next step:
				    * 					O 27: use opcode in address
				    * 					Z 28: use z-val in address
				    * 					+ 29: increment and use state in address
				    * 					S 30: whether to invoke callee-save
				    *
				    */
	word states[] = {/* FETCH */
				/* 	         	 op   z st    dr    ld     wr fn  rg +
				* 	       	     code - ##### PARMO PABMIZ MR ### ## OZ+S
				*				 0123 4 56789 01234 567890 12 345 67 8901 */
				/*ifetch1*/stow("1111 0 00000 10000 010100 00 000 00 0010"),//0
				/*ifetchc*/stow("1111 0 10011 00000 000000 00 000 00 0000"),//1
				/*ifetch2*/stow("1111 0 00001 00010 000010 00 000 00 0010"),//2
				/*ifetch3*/stow("1111 0 00010 01000 100000 00 011 00 1000"),//3

					 /* ADD */
				/* 	         	 op   z st    dr    ld     wr fn  rg +
				* 	       	     code - ##### PARMO PABMIZ MR ### ## OZ+S
				*				 0123 4 56789 01234 567890 12 345 67 8901 */
				/*add1   */stow("0000 0 10000 00100 010000 00 000 01 1010"),//4
				/*add2   */stow("0000 0 10001 00100 001000 00 000 10 1010"),//5
				/*add3   */stow("0000 0 10010 01000 000000 01 000 00 0000"),//6

					 /* NAND */
			    /* 	        	 op   z st    dr    ld     wr fn  rg +
			    * 	         	 code - ##### PARMO PABMIZ MR ### ## OZ+S
				*				 0123 4 56789 01234 567890 12 345 67 8901 */
				/*nand1  */stow("0001 0 10000 00100 010000 00 000 01 1010"),//7
				/*nand2  */stow("0001 0 10001 00100 001000 00 000 10 1010"),//8
				/*nand3  */stow("0001 0 10010 01000 000000 01 001 00 0000"),//9

					 /* ADDI */
				/* 	        	 op   z st    dr    ld     wr fn  rg +
				* 	         	 code - ##### PARMO PABMIZ MR ### ## OZ+S
				*				 0123 4 56789 01234 567890 12 345 67 8901 */
				/*addi1  */stow("0010 0 10000 00100 010000 00 000 01 1010"),//10
				/*addi2  */stow("0010 0 10001 00001 001000 00 000 10 1010"),//11
				/*addi3  */stow("0010 0 10010 01000 000000 01 000 00 0000"),//12

					 /* LW */
			    /* 	        	 op   z st    dr    ld     wr fn  rg +
			    * 	         	 code - ##### PARMO PABMIZ MR ### ## OZ+S
				*				 0123 4 56789 01234 567890 12 345 67 8901 */
				/*lw1    */stow("0011 0 10000 00100 010000 00 000 01 1010"),//13
				/*lw2    */stow("0011 0 10001 00001 001000 00 000 00 1010"),//14
				/*lw3    */stow("0011 0 10010 01000 000100 00 000 00 1010"),//15
				/*lw4    */stow("0011 0 10011 00010 000000 01 000 00 0000"),//16

					 /* SW */
				/* 	        	 op   z st    dr    ld     wr fn  rg +
				* 	         	 code - ##### PARMO PABMIZ MR ### ## OZ+S
				*				 0123 4 56789 01234 567890 12 345 67 8901 */
				/*sw1    */stow("0100 0 10000 00100 010000 00 000 01 1010"),//17
				/*sw2    */stow("0100 0 10001 00001 001000 00 000 00 1010"),//18
				/*sw3    */stow("0100 0 10010 01000 000100 00 000 00 1010"),//19
				/*sw4    */stow("0100 0 10011 00100 000000 10 000 00 0000"),//20

					 /* BEQ */
			    /* 	        	 op   z st    dr    ld     wr fn  rg +
			    * 	         	 code - ##### PARMO PABMIZ MR ### ## OZ+S
				*				 0123 4 56789 01234 567890 12 345 67 8901 */
				/*beq1   */stow("0101 0 10000 00100 010000 00 000 00 1010"),//21
				/*beq2   */stow("0101 0 10001 00100 001000 00 000 01 1010"),//22
				/*beq3   */stow("0101 0 10010 01000 000001 00 010 00 0110"),//23
				/*beq4   */stow("0101 1 10011 10000 010000 00 000 00 1010"),//24
				/*beq5   */stow("0101 0 10100 00001 001000 00 000 00 1010"),//25
				/*beq6   */stow("0101 0 10101 01000 100000 00 000 00 0000"),//26

					 /* JALR */
			    /* 	        	 op   z st    dr    ld     wr fn  rg +
			    * 	         	 code - ##### PARMO PABMIZ MR ### ## OZ+S
				*				 0123 4 56789 01234 567890 12 345 67 8901 */
				/*jalr1  */stow("0110 0 10000 10000 000000 01 000 01 1010"),//27
				/*jalr2  */stow("0110 0 10001 00100 010000 00 000 00 1010"),//28
				/*jalr3  */stow("0110 0 10010 00001 001000 00 000 10 1010"),//29
				/*jalr4  */stow("0110 0 10011 01000 100000 00 000 00 0000"),//30
				// note: JALR has been modified to additionally read immediate
				//		 values and add them to the second register's value
				//		 to determine the pc value--similar to addi, lw, sw, beq


					 /* HALT */
				/* 	        	 op   z st    dr    ld     wr fn  rg +
				* 	         	 code - ##### PARMO PABMIZ MR ### ## OZ+S
				*				 0123 4 56789 01234 567890 12 345 67 8901 */
				/*halt   */stow("0111 0 10000 00000 000000 00 000 00 0000") //31

				//		APPENDIX
				////							  |						 |						  |			 |			   |
				////            CODE      STATE | PC	ALU		REG	MEM	 OFF | PC  A  B  MAR   IR   Z | MEM  REG | FUNC  REGNO | M  T
				/*		 ORIGNAL JALR REGISTER ONLY CODE: 				  */
				/*jalr1  stow("0110 0 10000 10000 000000 01 000 01 1010"),//27*/
				/*jalr2  stow("0110 0 10001 00100 100000 00 000 00 0000"),//28*/
	};
	for(romaddress = 0; romaddress < ROM_SIZE; romaddress++)
		fsm->ROM[romaddress] = states[romaddress];
	return fsm;
}
示例#7
0
文件: main.c 项目: dejarc/372Project
/* OPEN FILE
 * -----------------------------------------------------------------------------
 * Opens the file.
 */
static void open_file(FILE *inputfile) {
	FILE *asmfile = fopen("asm_convert", "w");

	FILE *parsefile;
//	printf("%d", fgetc(file));
    char **binary;
    char lastline[WORD_LEN+1];
    char line[WORD_LEN+1];
    char data[WORD_LEN+1];
    int row = 0;
    int col = 0;
//    char *line = NULL;
//    size_t len = 0;
//    ssize_t read;
    int r;
    int c;
    int plusone = 0;
    int rows = 0;
    if (inputfile) {
        while ((c = getc(inputfile)) != EOF) {
        	if (c < 128)
        		fprintf(asmfile, "%c", c);
//        	printf("%d\n",c);
        }
//            putchar(c);
        fclose(inputfile);
        fclose(asmfile);
    }
    printf("------------------------------\n");
    parsefile = fopen("asm_convert", "r");
//    if (parsefile) {
//        while ((c = getc(parsefile)) != EOF) {
////        	if (c < 128)
////        		fprintf(asmfile, "%c", c);
//        	printf("%d\n",c);
////            putchar(c);
//        }
//        fclose(inputfile);
//        fclose(asmfile);
//    }
//    if (true) return;
    binary = getAllInstructions(parsefile, &row, &col);
//    if (true) return;

    printf("%d %d\n", row, col);

//    while ((read = getline(&line, &len, )) != -1) {
//        printf("Retrieved line of length %zu :\n", read);
//        printf("%s", line);
//    }
    for (c = WORD_LEN; c < WORD_LEN * 2; c++) {
    	line[c-WORD_LEN] = binary[0][c];
    }
    line[WORD_LEN] = 0;
    printf("LINE:%s\n", line);
	LC2200->pc->pc = stow(line);
	printf("PC:%lu %s\n", LC2200->pc->pc, wtos(LC2200->pc->pc));
	for (c = 0; c < WORD_LEN ; c++) {
	    	lastline[c] = '1';
	    }
//	lastline = "11111111111111111111111111111111";
	lastline[WORD_LEN] = 0;
//    if (true) return;
    for (r = 1; r < row; r++) {
        for (c = 0; c < WORD_LEN; c++) {
        	line[c] = binary[r][c];
        }

        line[WORD_LEN] = 0;
//        line
//        if (stow(line) == stow(lastline)) plusone = 1;
//        else plusone = 0;
////    	LC2200->pc->pc = stow(line);
//        for (c = 0; c < WORD_LEN ; c++) {
//        	    	lastline[c] = bitt(wtos(stow(line) + plusone), c)+'0';
//        	    }
//
//        for (c = 0; c < WORD_LEN ; c++) {
//        	    	line[c] = bitt(lastline, c)+'0';
//        	    }
////        lastline = wtos(stow(line) + plusone);
//
        printf("LINE:%s\n", line);

        for (c = WORD_LEN; c < WORD_LEN * 2; c++) {
        	data[c-WORD_LEN] = binary[r][c];
        }
        data[WORD_LEN] = 0;
        printf("DATA:%s\n", data);
    	LC2200->mem->MEM[stow(line)+plusone] = stow(data);
    	printf("MEM:%lu %s\n", LC2200->mem->MEM[stow(line)+plusone], wtos(LC2200->mem->MEM[stow(line)+plusone]));
//    while(binary[rows] != NULL) {
    	printf("012345678901234567890123456789012345678901234567890123456789012345\n");
        printf("\nassembly instruction at row %d is %s\n", r, binary[r]);
        plusone++;
//        rows++;
    }
    LC2200->mem->MEM[stow(line)+plusone+1] =
    		stow("0111 0000 0000 0000 0000 0000 0000 0000"); //halt

    fclose(parsefile);
}
示例#8
0
		DWORD InstallThread::proc(LPVOID args) {
			InstallThread* thread = static_cast<InstallThread*>(args);
			thread->setRunning(true);

			// TODO: check dependencies

			// check conflicts
			int failed = 0;
			std::vector<json::Addon> conflicts1 = thread->_toRemove.removeConflicted(); // this will probably never happen
			size_t i, len = conflicts1.size();
			failed += len;
			for (i = 0; i < len; i++)
				LOG_ERR(L"Addon %s conflicts with other addon", stow(conflicts1[i].getId()).c_str());

			std::vector<json::Addon> conflicts2 = thread->_toInstall.removeConflicted();
			i, len = conflicts2.size();
			failed += len;
			for (i = 0; i < len; i++)
				LOG_ERR(L"Addon %s conflicts with other addon", stow(conflicts2[i].getId()).c_str());

			// remove
			wtwUtils::Settings s;
			i, len = thread->_toRemove.size();
			int removed = 0;
			for (i = 0; i < len; i++) {
				const json::Addon& addon = thread->_toRemove[i];

				if (addon.getState() == json::Addon::INSTALLED) {
					AddonDeleter deleter(addon);
					deleter.del(s) ? removed++ : failed++;
				}

				if (thread->isAborted()) {
					thread->setRunning(false);
					return 0;
				}
			}

			// install
			len = thread->_toInstall.size();
			int installed = 0, updated = 0;
			for (i = 0; i < len; i++) {
				const json::Addon& addon = thread->_toInstall[i];

				if (addon.getState() == json::Addon::INSTALLED)
					continue;

				utils::BinaryFile f;
				utils::Http http;
				if (http.download2file(stow(addon.getZipUrl()).c_str(), &f)) {
					ZipFile zip(f.getPath());
					if (!zip.isValid()) {
						LOG_ERR(L"Zip file for %s is invalid", stow(addon.getId()).c_str());
						failed++;
					}
					else if (!zip.unzip()) {
						LOG_ERR(L"Failed to install (unzip) %s", stow(addon.getId()).c_str());
						failed++;
					}
					else {
						s.setInt64(stow(addon.getId()).c_str(), addon.getTime());
						s.write();
						switch (addon.getState()) {
						case json::Addon::NOT_INSTALLED:
							installed++;
							break;
						case json::Addon::MODIFIED:
							updated++;
							break;
						}
					}
				}
				else
					LOG_ERR(L"Failed to download %s", stow(addon.getZipUrl()).c_str());

				f.del();

				if (thread->isAborted()) {
					thread->setRunning(false);
					return 0;
				}
			}

			notify(L"Zainstalowano %u, zaktualizowano %u, usunięto %u, błędów %u", installed, updated, removed, failed);
			thread->_toInstall.clear();
			thread->_toRemove.clear();
			thread->setRunning(false);
			return 0;
		}
示例#9
0
static int
rhead(char *line, Word **h, Word **t, int *attr, char **prog)
{
    char *p;
    char *pp;
    int sep;
    Rune r;
    int n;
    Word *w;

    p = charin(line,":=<");
    if(p == 0)
        return('?');
    sep = *p;
    *p++ = 0;
    if(sep == '<' && *p == '|') {
        sep = '|';
        p++;
    }
    *attr = 0;
    *prog = 0;
    if(sep == '=') {
        pp = charin(p, termchars);	/* termchars is shell-dependent */
        if (pp && *pp == '=') {
            while (p != pp) {
                n = chartorune(&r, p);
                switch(r)
                {
                default:
                    SYNERR(-1);
                    fprint(2, "unknown attribute '%c'\n",*p);
                    Exit();
                case 'U':
                    *attr = 1;
                    break;
                }
                p += n;
            }
            p++;		/* skip trailing '=' */
        }
    }
    if((sep == ':') && *p && (*p != ' ') && (*p != '\t')) {
        while (*p) {
            n = chartorune(&r, p);
            if (r == ':')
                break;
            p += n;
            switch(r)
            {
            default:
                SYNERR(-1);
                fprint(2, "unknown attribute '%c'\n", p[-1]);
                Exit();
            case 'D':
                *attr |= DEL;
                break;
            case 'E':
                *attr |= NOMINUSE;
                break;
            case 'n':
                *attr |= NOVIRT;
                break;
            case 'N':
                *attr |= NOREC;
                break;
            case 'P':
                pp = utfrune(p, ':');
                if (pp == 0 || *pp == 0)
                    goto eos;
                *pp = 0;
                *prog = strdup(p);
                *pp = ':';
                p = pp;
                break;
            case 'Q':
                *attr |= QUIET;
                break;
            case 'R':
                *attr |= REGEXP;
                break;
            case 'U':
                *attr |= UPD;
                break;
            case 'V':
                *attr |= VIR;
                break;
            }
        }
        if (*p++ != ':') {
eos:
            SYNERR(-1);
            fprint(2, "missing trailing :\n");
            Exit();
        }
    }
    *h = w = stow(line);
    if(*w->s == 0 && sep != '<' && sep != '|') {
        SYNERR(mkinline-1);
        fprint(2, "no var on left side of assignment/rule\n");
        Exit();
    }
    *t = stow(p);
    return(sep);
}
示例#10
0
文件: test.c 项目: dejarc/372Project
void testBits(LC2200_ LC2200) {
	word w = stow("1001");
	printf("I am %lu\n", w);
}
示例#11
0
文件: test.c 项目: dejarc/372Project
void testSystem(LC2200_ LC2200) {

	debug(LC2200);
	LC2200->pc->pc = 0;

	LC2200->reg->REG[3] = stow("0000 0000 0000 0000 0000 0000 0000 1110"); //reg3 starts at 14
	LC2200->mem->MEM[0] = stow("0101 0011 0000 0000 0000 0000 0000 1011"); //beq fail
	LC2200->mem->MEM[1] = stow("0010 0101 0011 1111 1111 1111 1111 1100"); //reg5 =adds -4 to reg3
	LC2200->mem->MEM[2] = stow("0010 1010 0011 0000 0000 0000 0000 0100"); //reg10=adds 4  to reg3
 	LC2200->mem->MEM[3] = stow("0000 0000 0000 0000 0000 0000 0000 0101"); //attempts to add reg5 to $zero
 	LC2200->mem->MEM[4] = stow("0000 1110 0011 0000 0000 0000 0000 0101"); //reg14=reg3+reg5
 	LC2200->mem->MEM[5] = stow("0001 0010 0011 0000 0000 0000 0000 0011"); //reg2=reg3nandreg3
 	LC2200->mem->MEM[6] = stow("0010 0100 0000 0000 0000 0000 0000 0010"); //reg4+=2
 	LC2200->mem->MEM[7] = stow("0011 0110 0100 0000 0000 0000 0000 0100"); //reg6=mem[reg4+4]
 	LC2200->mem->MEM[8] = stow("0100 1010 0011 0000 0000 0000 0000 0101"); //mem[reg3+5]=reg10
 	LC2200->mem->MEM[9] = stow("0010 0100 0100 0000 0000 0000 0000 0001"); //reg4++
 	LC2200->mem->MEM[10]= stow("0011 0010 0100 0000 0000 0000 0000 0000"); //reg2=mem[reg4]
 	LC2200->mem->MEM[11]= stow("0110 0011 1111 0000 0000 0000 0000 0000"); //jump to 14
 	LC2200->mem->MEM[12]= stow("0111 0000 0000 0000 0000 0000 0000 0000"); //halt (jumped)
 	LC2200->mem->MEM[13]= stow("0111 0000 0000 0000 0000 0000 0000 0000"); //halt (jumped)
 	LC2200->mem->MEM[14]= stow("0100 0110 0011 0000 0000 0000 0000 0001"); //mem[reg3+1] = reg6
 	LC2200->mem->MEM[15]= stow("0111 0000 0000 0000 0000 0000 0000 0000"); //halt (overwritten)
 	LC2200->mem->MEM[16]= stow("0101 0000 0000 0000 0000 0000 0000 0011"); //beq->pc19
 	LC2200->mem->MEM[17]= stow("0111 0000 0000 0000 0000 0000 0000 0000"); //halt
 	LC2200->mem->MEM[18]= stow("0111 0000 0000 0000 0000 0000 0000 0000"); //halt
 	LC2200->mem->MEM[19]= stow("0111 0000 0000 0000 0000 0000 0000 0000"); //halt (overwritten)
 	LC2200->mem->MEM[20]= stow("0110 0000 0000 0000 0000 0000 0001 1000"); //jump pc24
 	LC2200->mem->MEM[21]= stow("0111 0000 0000 0000 0000 0000 0000 0000"); //halt
 	LC2200->mem->MEM[22]= stow("0111 0000 0000 0000 0000 0000 0000 0000"); //halt
 	LC2200->mem->MEM[23]= stow("0111 0000 0000 0000 0000 0000 0000 0000"); //halt
 	LC2200->mem->MEM[24]= stow("0010 1000 1000 0000 0000 0000 0100 0000"); //reg8=reg8+64
	LC2200->mem->MEM[25]= stow("0111 0000 0000 0000 0000 0000 0000 0000"); //halt
 	LC2200->mem->MEM[50]= stow("0111 0000 0000 0000 0000 0000 0000 0000"); //emergency halt

// 	LC2200->safetydebug = true;
 	LC2200->statedebug = true;
// 	LC2200->microdebug = true;
//	start(LC2200, 'h');
}
示例#12
0
 uint32_t Iconv::charCodeAt(const string& ansiStr, uint32_t idx) {
   return stow(ansiStr)[idx];
 }
示例#13
0
 string Iconv::stou8(const string& s) {
   return wtou8(stow(s));
 }