⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 interp.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 3 页
字号:
			continue;		case O_PXPBUF:			pc.cp++;			PCLONGVAL(tl);			_cntrs = tl;			PCLONGVAL(tl);			_rtns = tl;			NEW(&_pcpcount, (_cntrs + 1) * sizeof(long));			blkclr(_pcpcount, (_cntrs + 1) * sizeof(long));			continue;		case O_COUNT:			pc.cp++;			_pcpcount[*pc.usp++]++;			continue;		case O_CASE1OP:			tl = *pc.cp++;		/* tl = number of cases */			if (tl == 0)				tl = *pc.usp++;			tsp = pc.sp + tl;	/* ptr to end of jump table */			tcp = (char *)tsp;	/* tcp = ptr to case values */			tl1 = pop2();		/* tl1 = element to find */			for(; tl > 0; tl--)	/* look for element */				if (tl1 == *tcp++)					break;			if (tl == 0)		/* default case => error */				CASERNG(tl1);			pc.cp += *(tsp - tl);			continue;		case O_CASE2OP:			tl = *pc.cp++;		/* tl = number of cases */			if (tl == 0)				tl = *pc.usp++;			tsp = pc.sp + tl;	/* ptr to end of jump table */			tsp1 = tsp;		/* tsp1 = ptr to case values */			tl1 = (unsigned short)pop2();/* tl1 = element to find */			for(; tl > 0; tl--)	/* look for element */				if (tl1 == *tsp++)					break;			if (tl == 0)		/* default case => error */				CASERNG(tl1);			pc.cp += *(tsp1 - tl);			continue;		case O_CASE4OP:			tl = *pc.cp++;		/* tl = number of cases */			if (tl == 0)				tl = *pc.usp++;			tsp1 = pc.sp + tl;	/* ptr to end of jump table */			tlp = (long *)tsp1;	/* tlp = ptr to case values */			tl1 = pop4();		/* tl1 = element to find */			for(; tl > 0; tl--) {	/* look for element */				GETLONGVAL(tl2, tlp++);				if (tl1 == tl2)					break;			}			if (tl == 0)		/* default case => error */				CASERNG(tl1);			pc.cp += *(tsp1 - tl);			continue;		case O_ADDT:			tl = *pc.cp++;		/* tl has comparison length */			if (tl == 0)				tl = *pc.usp++;			tcp = pushsp((long)(0));/* tcp pts to first arg */			ADDT(tcp + tl, tcp + tl, tcp, tl >> 2);			popsp(tl);			continue;		case O_SUBT:			tl = *pc.cp++;		/* tl has comparison length */			if (tl == 0)				tl = *pc.usp++;			tcp = pushsp((long)(0));/* tcp pts to first arg */			SUBT(tcp + tl, tcp + tl, tcp, tl >> 2);			popsp(tl);			continue;		case O_MULT:			tl = *pc.cp++;		/* tl has comparison length */			if (tl == 0)				tl = *pc.usp++;			tcp = pushsp((long)(0));/* tcp pts to first arg */			MULT(tcp + tl, tcp + tl, tcp, tl >> 2);			popsp(tl);			continue;		case O_INCT:			tl = *pc.cp++;		/* tl has number of args */			if (tl == 0)				tl = *pc.usp++;			tb = INCT();			popsp(tl*sizeof(long));			push2((short)(tb));			continue;		case O_CTTOT:			tl = *pc.cp++;		/* tl has number of args */			if (tl == 0)				tl = *pc.usp++;			tl1 = tl * sizeof(long);	/* Size of all args */			tcp = pushsp((long)(0)) + tl1; /* tcp pts to result */			tl1 = pop4();		/* Pop the 4 fixed args */			tl2 = pop4();			tl3 = pop4();			tl4 = pop4();			tcp2 = pushsp((long)0);	/* tcp2 -> data values */			CTTOTA(tcp, tl1, tl2, tl3, tl4, tcp2);			popsp(tl*sizeof(long) - 4*sizeof(long)); /* Pop data */			continue;		case O_CARD:			tl = *pc.cp++;		/* tl has comparison length */			if (tl == 0)				tl = *pc.usp++;			tcp = pushsp((long)(0));/* tcp pts to set */			tl1 = CARD(tcp, tl);			popsp(tl);			push2((short)(tl1));			continue;		case O_IN:			tl = *pc.cp++;		/* tl has comparison length */			if (tl == 0)				tl = *pc.usp++;			tl1 = pop4();		/* tl1 is the element */			tcp = pushsp((long)(0));/* tcp pts to set */			tl2 = *pc.sp++;	/* lower bound */			tb = IN(tl1, tl2, (long)(*pc.usp++), tcp);			popsp(tl);			push2((short)(tb));			continue;		case O_ASRT:			pc.cp++;			tl = pop4();			tcp = popaddr();			ASRTS(tl, tcp);			continue;		case O_FOR1U:			tl1 = *pc.cp++;		/* tl1 loop branch */			if (tl1 == 0)				tl1 = *pc.sp++;			tcp = popaddr();	/* tcp = ptr to index var */			tl = pop4();		/* tl upper bound */			if (*tcp == tl)		/* loop is done, fall through */				continue;			*tcp += 1;		/* inc index var */			pc.cp += tl1;		/* return to top of loop */			continue;		case O_FOR2U:			tl1 = *pc.cp++;		/* tl1 loop branch */			if (tl1 == 0)				tl1 = *pc.sp++;			tsp = (short *)popaddr(); /* tsp = ptr to index var */			tl = pop4();		/* tl upper bound */			if (*tsp == tl)		/* loop is done, fall through */				continue;			*tsp += 1;		/* inc index var */			pc.cp += tl1;		/* return to top of loop */			continue;		case O_FOR4U:			tl1 = *pc.cp++;		/* tl1 loop branch */			if (tl1 == 0)				tl1 = *pc.sp++;			tlp = (long *)popaddr(); /* tlp = ptr to index var */			tl = pop4();		/* tl upper bound */			if (*tlp == tl)		/* loop is done, fall through */				continue;			*tlp += 1;		/* inc index var */			pc.cp += tl1;		/* return to top of loop */			continue;		case O_FOR1D:			tl1 = *pc.cp++;		/* tl1 loop branch */			if (tl1 == 0)				tl1 = *pc.sp++;			tcp = popaddr();	/* tcp = ptr to index var */			tl = pop4();		/* tl upper bound */			if (*tcp == tl)		/* loop is done, fall through */				continue;			*tcp -= 1;		/* dec index var */			pc.cp += tl1;		/* return to top of loop */			continue;		case O_FOR2D:			tl1 = *pc.cp++;		/* tl1 loop branch */			if (tl1 == 0)				tl1 = *pc.sp++;			tsp = (short *)popaddr(); /* tsp = ptr to index var */			tl = pop4();		/* tl upper bound */			if (*tsp == tl)		/* loop is done, fall through */				continue;			*tsp -= 1;		/* dec index var */			pc.cp += tl1;		/* return to top of loop */			continue;		case O_FOR4D:			tl1 = *pc.cp++;		/* tl1 loop branch */			if (tl1 == 0)				tl1 = *pc.sp++;			tlp = (long *)popaddr(); /* tlp = ptr to index var */			tl = pop4();		/* tl upper bound */			if (*tlp == tl)		/* loop is done, fall through */				continue;			*tlp -= 1;		/* dec index var */			pc.cp += tl1;		/* return to top of loop */			continue;		case O_READE:			pc.cp++;			PCLONGVAL(tl);			push2((short)(READE(curfile, base + tl)));			continue;		case O_READ4:			pc.cp++;			push4(READ4(curfile));			continue;		case O_READC:			pc.cp++;			push2((short)(READC(curfile)));			continue;		case O_READ8:			pc.cp++;			push8(READ8(curfile));			continue;		case O_READLN:			pc.cp++;			READLN(curfile);			continue;		case O_EOF:			pc.cp++;			tcp = popaddr();			push2((short)(TEOF(tcp)));			continue;		case O_EOLN:			pc.cp++;			tcp = popaddr();			push2((short)(TEOLN(tcp)));			continue;		case O_WRITEC:			pc.cp++;			ti = popint();			tf = popfile();			if (_runtst) {				WRITEC(curfile, ti, tf);				continue;			}			fputc(ti, tf);			continue;		case O_WRITES:			pc.cp++;		/* Skip arg size */			tf = popfile();			ti = popint();			ti2 = popint();			tcp2 = popaddr();			if (_runtst) {				WRITES(curfile, tf, ti, ti2, tcp2);				continue;			}			fwrite(tf, ti, ti2, tcp2);			continue;		case O_WRITEF:			tf = popfile();			tcp = popaddr();			tcp2 = pushsp((long)0);	/* Addr of printf's args */			if (_runtst) {				VWRITEF(curfile, tf, tcp, tcp2);			} else {				vfprintf(tf, tcp, tcp2);			}			popsp((long)			    (*pc.cp++) - (sizeof (FILE *)) - sizeof (char *));			continue;		case O_WRITLN:			pc.cp++;			if (_runtst) {				WRITLN(curfile);				continue;			}			fputc('\n', ACTFILE(curfile));			continue;		case O_PAGE:			pc.cp++;			if (_runtst) {				PAGE(curfile);				continue;			}			fputc('', ACTFILE(curfile));			continue;		case O_NAM:			pc.cp++;			tl = pop4();			PCLONGVAL(tl1);			pushaddr(NAM(tl, base + tl1));			continue;		case O_MAX:			tl = *pc.cp++;			if (tl == 0)				tl = *pc.usp++;			tl1 = pop4();			if (_runtst) {				push4(MAX(tl1, tl, (long)(*pc.usp++)));				continue;			}			tl1 -= tl;			tl = *pc.usp++;			push4(tl1 > tl ? tl1 : tl);			continue;		case O_MIN:			tl = *pc.cp++;			if (tl == 0)				tl = *pc.usp++;			tl1 = pop4();			push4(tl1 < tl ? tl1 : tl);			continue;		case O_UNIT:			pc.cp++;			curfile = UNIT(popaddr());			continue;		case O_UNITINP:			pc.cp++;			curfile = INPUT;			continue;		case O_UNITOUT:			pc.cp++;			curfile = OUTPUT;			continue;		case O_MESSAGE:			pc.cp++;			PFLUSH();			curfile = ERR;			continue;		case O_PUT:			pc.cp++;			PUT(curfile);			continue;		case O_GET:			pc.cp++;			GET(curfile);			continue;		case O_FNIL:			pc.cp++;			tcp = popaddr();			pushaddr(FNIL(tcp));			continue;		case O_DEFNAME:			pc.cp++;			tcp2 = popaddr();			tcp = popaddr();			tl = pop4();			tl2 = pop4();			DEFNAME((struct iorec *)tcp2, tcp, tl, tl2);			continue;		case O_RESET:			pc.cp++;			tcp2 = popaddr();			tcp = popaddr();			tl = pop4();			tl2 = pop4();			RESET((struct iorec *)tcp2, tcp, tl, tl2);			continue;		case O_REWRITE:			pc.cp++;			tcp2 = popaddr();			tcp = popaddr();			tl = pop4();			tl2 = pop4();			REWRITE((struct iorec *)tcp2, tcp, tl, tl2);			continue;		case O_FILE:			pc.cp++;			pushaddr(ACTFILE(curfile));			continue;		case O_REMOVE:			pc.cp++;			tcp = popaddr();			tl = pop4();			REMOVE(tcp, tl);			continue;		case O_FLUSH:			pc.cp++;			tcp = popaddr();			FLUSH((struct iorec *)tcp);			continue;		case O_PACK:			pc.cp++;			tl = pop4();			tcp = popaddr();			tcp2 = popaddr();			tl1 = pop4();			tl2 = pop4();			tl3 = pop4();			tl4 = pop4();			PACK(tl, tcp, tcp2, tl1, tl2, tl3, tl4);			continue;		case O_UNPACK:			pc.cp++;			tl = pop4();			tcp = popaddr();			tcp2 = popaddr();			tl1 = pop4();			tl2 = pop4();			tl3 = pop4();			tl4 = pop4();			UNPACK(tl, tcp, tcp2, tl1, tl2, tl3, tl4);			continue;		case O_ARGC:			pc.cp++;			push4((long)_argc);			continue;		case O_ARGV:			tl = *pc.cp++;		/* tl = size of char array */			if (tl == 0)				tl = *pc.usp++;			tcp = popaddr();	/* tcp = addr of char array */			tl1 = pop4();		/* tl1 = argv subscript */			ARGV(tl1, tcp, tl);			continue;		case O_CLCK:			pc.cp++;			push4(CLCK());			continue;		case O_WCLCK:			pc.cp++;			push4(time(0));			continue;		case O_SCLCK:			pc.cp++;			push4(SCLCK());			continue;		case O_NEW:			tl = *pc.cp++;		/* tl = size being new'ed */			if (tl == 0)				tl = *pc.usp++;			tcp = popaddr();	/* ptr to ptr being new'ed */			NEW(tcp, tl);			if (_runtst) {				blkclr(*((char **)(tcp)), tl);			}			continue;		case O_DISPOSE:			tl = *pc.cp++;		/* tl = size being disposed */			if (tl == 0)				tl = *pc.usp++;			tcp = popaddr();	/* ptr to ptr being disposed */			DISPOSE(tcp, tl);			*(char **)tcp = (char *)0;			continue;		case O_DFDISP:			tl = *pc.cp++;		/* tl = size being disposed */			if (tl == 0)				tl = *pc.usp++;			tcp = popaddr();	/* ptr to ptr being disposed */			DFDISPOSE(tcp, tl);			*(char **)tcp = (char *)0;			continue;		case O_DATE:			pc.cp++;			DATE(popaddr());			continue;		case O_TIME:			pc.cp++;			TIME(popaddr());			continue;		case O_UNDEF:			pc.cp++;			td = pop8();			push2((short)(0));			continue;		case O_ATAN:			pc.cp++;			td = pop8();			if (_runtst) {				push8(ATAN(td));				continue;			}			push8(atan(td));			continue;		case O_COS:			pc.cp++;			td = pop8();			if (_runtst) {				push8(COS(td));				continue;			}			push8(cos(td));			continue;		case O_EXP:			pc.cp++;			td = pop8();			if (_runtst) {				push8(EXP(td));				continue;			}			push8(exp(td));			continue;		case O_LN:			pc.cp++;			td = pop8();			if (_runtst) {				push8(LN(td));				continue;			}			push8(log(td));			continue;		case O_SIN:			pc.cp++;			td = pop8();			if (_runtst) {				push8(SIN(td));				continue;			}			push8(sin(td));			continue;		case O_SQRT:			pc.cp++;			td = pop8();			if (_runtst) {				push8(SQRT(td));				continue;			}			push8(sqrt(td));			continue;		case O_CHR2:		case O_CHR4:			pc.cp++;			tl = pop4();			if (_runtst) {				push2((short)(CHR(tl)));				continue;			}			push2((short)tl);			continue;		case O_ODD2:		case O_ODD4:			pc.cp++;			tl = pop4();			push2((short)(tl & 1));			continue;		case O_SUCC2:			tl = *pc.cp++;			if (tl == 0)				tl = *pc.sp++;			tl1 = pop4();			if (_runtst) {				push2((short)(SUCC(tl1, tl, (long)(*pc.sp++))));				continue;			}			push2((short)(tl1 + 1));			pc.sp++;			continue;		case O_SUCC24:			tl = *pc.cp++;			if (tl == 0)				tl = *pc.sp++;			tl1 = pop4();			if (_runtst) {				push4(SUCC(tl1, tl, (long)(*pc.sp++)));				continue;			}			push4(tl1 + 1);			pc.sp++;			continue;		case O_SUCC4:			tl = *pc.cp++;			if (tl == 0)				PCLONGVAL(tl);			tl1 = pop4();			if (_runtst) {				PCLONGVAL(tl2);				push4(SUCC(tl1, tl, (long)(tl2)));				continue;			}			push4(tl1 + 1);			pc.lp++;			continue;		case O_PRED2:			tl = *pc.cp++;			if (tl == 0)				tl = *pc.sp++;			tl1 = pop4();			if (_runtst) {				push2((short)(PRED(tl1, tl, (long)(*pc.sp++))));				continue;			}			push2((short)(tl1 - 1));			pc.sp++;			continue;		case O_PRED24:			tl = *pc.cp++;			if (tl == 0)				tl = *pc.sp++;			tl1 = pop4();			if (_runtst) {				push4(PRED(tl1, tl, (long)(*pc.sp++)));				continue;			}			push4(tl1 - 1);			pc.sp++;			continue;		case O_PRED4:			tl = *pc.cp++;			if (tl == 0)				PCLONGVAL(tl);			tl1 = pop4();			if (_runtst) {				PCLONGVAL(tl2);				push4(PRED(tl1, tl, (long)(tl2)));				continue;			}			push4(tl1 - 1);			pc.lp++;			continue;		case O_SEED:			pc.cp++;			tl = pop4();			push4(SEED(tl));			continue;		case O_RANDOM:			pc.cp++;			td = pop8();		/* Argument is ignored */			push8(RANDOM());			continue;		case O_EXPO:			pc.cp++;			td = pop8();			push4(EXPO(td));			continue;		case O_SQR2:		case O_SQR4:			pc.cp++;			tl = pop4();			push4(tl * tl);			continue;		case O_SQR8:			pc.cp++;			td = pop8();			push8(td * td);			continue;		case O_ROUND:			pc.cp++;			td = pop8();			push4(ROUND(td));			continue;		case O_TRUNC:			pc.cp++;			td = pop8();			push4(TRUNC(td));			continue;		default:			ERROR("Panic: bad op code\n");			continue;		}	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -