您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ svalue函数代码示例

51自学网 2021-06-03 08:33:53
  C++
这篇教程C++ svalue函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中svalue函数的典型用法代码示例。如果您正苦于以下问题:C++ svalue函数的具体用法?C++ svalue怎么用?C++ svalue使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了svalue函数的24个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: luaV_concat

void luaV_concat (lua_State *L, int total, int last) {  do {    StkId top = L->base + last + 1;    int n = 2;  /* number of elements handled in this pass (at least 2) */    if (!(ttisstring(top-2) || ttisnumber(top-2)) || !tostring(L, top-1)) {      setpvalue(L->top, (void *)(ptrdiff_t)(last - 1));  /* for luaV_resume */      L->top++;      if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT))        luaG_concaterror(L, top-2, top-1);      L->top--;    } else if (tsvalue(top-1)->len == 0)  /* second op is empty? */      (void)tostring(L, top - 2);  /* result is first op (as string) */    else {      /* at least two string values; get as many as possible */      size_t tl = tsvalue(top-1)->len;      char *buffer;      int i;      /* collect total length */      for (n = 1; n < total && tostring(L, top-n-1); n++) {        size_t l = tsvalue(top-n-1)->len;        if (l >= MAX_SIZET - tl) luaG_runerror(L, "string length overflow");        tl += l;      }      buffer = luaZ_openspace(L, &G(L)->buff, tl);      tl = 0;      for (i=n; i>0; i--) {  /* concat all strings */        size_t l = tsvalue(top-i)->len;        memcpy(buffer+tl, svalue(top-i), l);        tl += l;      }      setsvalue2s(L, top-n, luaS_newlstr(L, buffer, tl));    }    total -= n-1;  /* got `n' strings to create 1 new */    last -= n-1;  } while (total > 1);  /* repeat until only 1 result left */}
开发者ID:dividuum,项目名称:infon,代码行数:36,


示例2: PrintString

static void PrintString(const Proto* f, int n){ const char* s=svalue(&f->k[n]); putchar('"'); for (; *s; s++) {  switch (*s)  {   case '"': printf("///""); break;   case '/a': printf("//a"); break;   case '/b': printf("//b"); break;   case '/f': printf("//f"); break;   case '/n': printf("//n"); break;   case '/r': printf("//r"); break;   case '/t': printf("//t"); break;   case '/v': printf("//v"); break;   default:	if (isprint((unsigned char)*s))   			printf("%c",*s);		else			printf("//%03u",(unsigned char)*s);  } } putchar('"');}
开发者ID:ClowReed32,项目名称:Cthugha-Engine-Demos,代码行数:24,


示例3: luaV_tointeger

/*** try to convert a value to an integer, rounding according to 'mode':** mode == 0: accepts only integral values** mode == 1: takes the floor of the number** mode == 2: takes the ceil of the number*/int luaV_tointeger (const TValue *obj, lua_Integer *p, int mode) {  TValue v; again:  if (ttisfloat(obj)) {    lua_Number n = fltvalue(obj);    lua_Number f = l_floor(n);    if (n != f) {  /* not an integral value? */      if (mode == 0) return 0;  /* fails if mode demands integral value */      else if (mode > 1)  /* needs ceil? */        f += 1;  /* convert floor to ceil (remember: n != f) */    }    return lua_numbertointeger(f, p);  }  else if (ttisinteger(obj)) {    *p = ivalue(obj);    return 1;  }  else if (cvt2num(obj) &&            luaO_str2num(svalue(obj), &v) == vslen(obj) + 1) {    obj = &v;    goto again;  /* convert result from 'luaO_str2num' to an integer */  }  return 0;  /* conversion failed */}
开发者ID:Wezthal,项目名称:DerpEngine,代码行数:30,


示例4: return

/*** Given an object handle, return its string pointer. On error, return NULL.*/char *lua_getstring (lua_Object object){ if (object == LUA_NOOBJECT) return NULL; if (tostring (Address(object))) return NULL; else return (svalue(Address(object)));}
开发者ID:cskau,项目名称:VM,代码行数:9,


示例5: dump_function

/* this is a debug function used for check bytecode chunk file */static void dump_function(int level, ktap_proto *f){	int i;	printf("/n----------------------------------------------------/n");	printf("function %d [level %d]:/n", function_nr++, level);	printf("linedefined: %d/n", f->linedefined);	printf("lastlinedefined: %d/n", f->lastlinedefined);	printf("numparams: %d/n", f->numparams);	printf("is_vararg: %d/n", f->is_vararg);	printf("maxstacksize: %d/n", f->maxstacksize);	printf("source: %s/n", getstr(f->source));	printf("sizelineinfo: %d /t", f->sizelineinfo);	for (i = 0; i < f->sizelineinfo; i++)		printf("%d ", f->lineinfo[i]);	printf("/n");	printf("sizek: %d/n", f->sizek);	for (i = 0; i < f->sizek; i++) {		switch(f->k[i].type) {		case KTAP_TNIL:			printf("/tNIL/n");			break;		case KTAP_TBOOLEAN:			printf("/tBOOLEAN: ");			printf("%d/n", f->k[i].val.b);			break;		case KTAP_TNUMBER:			printf("/tTNUMBER: ");			printf("%ld/n", f->k[i].val.n);			break;		case KTAP_TSHRSTR:		case KTAP_TLNGSTR:			printf("/tTSTRING: ");			printf("%s/n", svalue(&(f->k[i])));			break;		default:			printf("/tUnknow constant type %d: ", f->k[i].type);			kp_showobj(NULL, &(f->k[i]));			printf("/n");		}	}	printf("sizelocvars: %d/n", f->sizelocvars);	for (i = 0; i < f->sizelocvars; i++) {		printf("/tlocvars: %s startpc: %d endpc: %d/n",			getstr(f->locvars[i].varname), f->locvars[i].startpc,			f->locvars[i].endpc);	}	printf("sizeupvalues: %d/n", f->sizeupvalues);	for (i = 0; i < f->sizeupvalues; i++) {		printf("/tname: %s instack: %d idx: %d/n",			getstr(f->upvalues[i].name), f->upvalues[i].instack,			f->upvalues[i].idx);	}	printf("/n");	printf("sizecode: %d/n", f->sizecode);	for (i = 0; i < f->sizecode; i++)		decode_instruction(f, f->code[i]);	printf("sizep: %d/n", f->sizep);	for (i = 0; i < f->sizep; i++)		dump_function(level + 1, f->p[i]);}
开发者ID:cfregly,项目名称:ktap,代码行数:68,


示例6: svalue

// PrintString from luac is not 8-bit cleanchar *DecompileString(const Proto * f, int n){    int i;    const unsigned char *s = svalue(&f->k[n]);    int len = tsvalue(&f->k[n])->tsv.len;    char *ret = malloc(strlen(s) * 4 + 3);    int p = 0;    ret[p++] = '"';    for (i = 0; i < len; i++, s++) {        switch (*s) {        case '"':            ret[p++] = '//';            ret[p++] = '"';            break;        case '/a':            ret[p++] = '//';            ret[p++] = 'a';            break;        case '/b':            ret[p++] = '//';            ret[p++] = 'b';            break;        case '/f':            ret[p++] = '//';            ret[p++] = 'f';            break;        case '/n':            ret[p++] = '//';            ret[p++] = 'n';            break;        case '/r':            ret[p++] = '//';            ret[p++] = 'r';            break;        case '/t':            ret[p++] = '//';            ret[p++] = 't';            break;        case '/v':            ret[p++] = '//';            ret[p++] = 'v';            break;        case '//':            ret[p++] = '//';            ret[p++] = '//';            break;        default:            if (*s < 32 || *s > 127) {               char* pos = &(ret[p]);               sprintf(pos, "//%d", *s);               p += strlen(pos);            } else {               ret[p++] = *s;            }            break;        }    }    ret[p++] = '"';    ret[p] = '/0';    return ret;}
开发者ID:eaglePwn,项目名称:CTFwriteup,代码行数:62,


示例7: get_instr_len

//.........这里部分代码省略.........    case PUSHNUMBER1:    case PUSHNUMBER2:      aux = opc - PUSHNUMBER0;      goto pushnumber;    case PUSHNUMBERW:      aux = start[0] | (start[1] << 8);      start += 2;    pushnumber:      stk->push(new NumberExpr(start, aux));      break;    case PUSHCONSTANT:      aux = *start++;      goto pushconst;    case PUSHCONSTANT0:    case PUSHCONSTANT1:    case PUSHCONSTANT2:    case PUSHCONSTANT3:    case PUSHCONSTANT4:    case PUSHCONSTANT5:    case PUSHCONSTANT6:    case PUSHCONSTANT7:      aux = opc - PUSHCONSTANT0;      goto pushconst;    case PUSHCONSTANTW:      aux = start[0] | (start[1] << 8);      start += 2;    pushconst:      switch (ttype(tf->consts + aux)) {      case LUA_T_STRING:	stk->push(new StringExpr(start, tsvalue(tf->consts + aux)));	break;      case LUA_T_NUMBER:	stk->push(new NumberExpr(start, nvalue(tf->consts + aux)));	break;      case LUA_T_PROTO:	stk->push(new FuncExpr(start, tfvalue(tf->consts + aux), indent_str));	break;      default:	*os << indent_str << "error: invalid constant type "	    << int(ttype(tf->consts + aux)) << std::endl;      }      break;    case PUSHUPVALUE:      aux = *start++;      goto pushupvalue;    case PUSHUPVALUE0:    case PUSHUPVALUE1:      aux = opc - PUSHUPVALUE0;    pushupvalue:      {	if (aux >= num_upvals) {	  *os << indent_str << "error: invalid upvalue #"	      << aux << std::endl;	}	std::ostringstream s;	s << "%" << *upvals[aux];	stk->push(new VarExpr(start, s.str()));      }      break;
开发者ID:Botje,项目名称:residualvm-tools,代码行数:67,


示例8: svalue

static const char *kname (Proto *p, int c) {  if (ISK(c) && ttisstring(&p->k[INDEXK(c)]))    return svalue(&p->k[INDEXK(c)]);  else    return "?";}
开发者ID:GranPC,项目名称:llvm-lua,代码行数:6,


示例9: PrintCode

static void PrintCode(const Proto* f){ const Instruction* code=f->code; int pc,n=f->sizecode; for (pc=0; pc<n; pc++) {  Instruction i=code[pc];  OpCode o=GET_OPCODE(i);  int a=GETARG_A(i);  int b=GETARG_B(i);  int c=GETARG_C(i);  int bx=GETARG_Bx(i);  int sbx=GETARG_sBx(i);  int line=getline(f,pc);  printf("/t%d/t",pc+1);  if (line>0) printf("[%d]/t",line); else printf("[-]/t");  printf("%-9s/t",luaP_opnames[o]);  switch (getOpMode(o))  {   case iABC:    printf("%d",a);    if (getBMode(o)!=OpArgN) printf(" %d",ISK(b) ? (-1-INDEXK(b)) : b);    if (getCMode(o)!=OpArgN) printf(" %d",ISK(c) ? (-1-INDEXK(c)) : c);    break;   case iABx:    if (getBMode(o)==OpArgK) printf("%d %d",a,-1-bx); else printf("%d %d",a,bx);    break;   case iAsBx:    if (o==OP_JMP) printf("%d",sbx); else printf("%d %d",a,sbx);    break;  }  switch (o)  {   case OP_LOADK:    printf("/t; "); PrintConstant(f,bx);    break;   case OP_GETUPVAL:   case OP_SETUPVAL:    printf("/t; %s", (f->sizeupvalues>0) ? getstr(f->upvalues[b]) : "-");    break;   case OP_GETGLOBAL:   case OP_SETGLOBAL:    printf("/t; %s",svalue(&f->k[bx]));    break;   case OP_GETTABLE:   case OP_SELF:    if (ISK(c)) { printf("/t; "); PrintConstant(f,INDEXK(c)); }    break;   case OP_SETTABLE:   case OP_ADD:   case OP_SUB:   case OP_MUL:   case OP_DIV:   case OP_POW:   case OP_EQ:   case OP_LT:   case OP_LE:    if (ISK(b) || ISK(c))    {     printf("/t; ");     if (ISK(b)) PrintConstant(f,INDEXK(b)); else printf("-");     printf(" ");     if (ISK(c)) PrintConstant(f,INDEXK(c)); else printf("-");    }    break;   case OP_JMP:   case OP_FORLOOP:   case OP_FORPREP:    printf("/t; to %d",sbx+pc+2);    break;   case OP_CLOSURE:    printf("/t; %p",VOID(f->p[bx]));    break;   case OP_SETLIST:    if (c==0) printf("/t; %d",(int)code[++pc]);    else printf("/t; %d",c);    break;   default:    break;  }  printf("/n"); }}
开发者ID:DuMuT6p,项目名称:Epiar,代码行数:83,


示例10: glob

/* * Glob the argument words in genbuf, or if no globbing * is implied, just split them up directly. */voidglob(struct glob *gp){	int pvec[2];	register char **argv = gp->argv;	register char *cp = gp->argspac;	register int c;	char ch;	int nleft = NCARGS;	gp->argc0 = 0;	if (gscan() == 0) {		register char *v = genbuf + 5;		/* strlen("echo ") */		for (;;) {			while (isspace((int)*v))				v++;			if (!*v)				break;			*argv++ = cp;			while (*v && !isspace((int)*v))				*cp++ = *v++;			*cp++ = 0;			gp->argc0++;		}		*argv = 0;		return;	}	if (pipe(pvec) < 0)		error("Can't make pipe to glob");	pid = fork();	io = pvec[0];	if (pid < 0) {		close(pvec[1]);		error("Can't fork to do glob");	}	if (pid == 0) {		int oerrno;		close(1);		dup(pvec[1]);		close(pvec[0]);		close(2);	/* so errors don't mess up the screen */		open("/dev/null", O_WRONLY);		execl(svalue(SHELL), "sh", "-c", genbuf, NULL);		oerrno = errno; close(1); dup(2); errno = oerrno;		filioerr(svalue(SHELL));	}	close(pvec[1]);	do {		*argv = cp;		for (;;) {			if (read(io, &ch, 1) != 1) {				close(io);				c = -1;			} else				c = ch & TRIM;			if (c <= 0 || isspace(c))				break;			*cp++ = c;			if (--nleft <= 0)				error("Arg list too long");		}		if (cp != *argv) {			--nleft;			*cp++ = 0;			gp->argc0++;			if (gp->argc0 >= NARGS)				error("Arg list too long");			argv++;		}	} while (c >= 0);	waitfor();	if (gp->argc0 == 0)		error("No match");}
开发者ID:n-t-roff,项目名称:ex-3.6,代码行数:80,


示例11: luaO_pushvfstring

/* this function handles only `%d', `%c', %f, %p, and `%s' formats */const char* luaO_pushvfstring(lua_State* L, const char* fmt, va_list argp){	int n = 1;	pushstr(L, "");	for (;;)	{		const char* e = strchr(fmt, '%');		if (e == NULL) break;		setsvalue2s(L, L->top, luaS_newlstr(L, fmt, e - fmt));		incr_top(L);		switch (*(e + 1))		{			case 's':			{				const char* s = va_arg(argp, char*);				if (s == NULL) s = "(null)";				pushstr(L, s);				break;			}			case 'c':			{				char buff[2];				buff[0] = cast(char, va_arg(argp, int));				buff[1] = '/0';				pushstr(L, buff);				break;			}			case 'd':			{				setnvalue(L->top, cast_num(va_arg(argp, int)));				incr_top(L);				break;			}			case 'f':			{				setnvalue(L->top, cast_num(va_arg(argp, l_uacNumber)));				incr_top(L);				break;			}			case 'p':			{				char buff[4 * sizeof(void*) + 8]; /* should be enough space for a `%p' */				sprintf(buff, "%p", va_arg(argp, void*));				pushstr(L, buff);				break;			}			case '%':			{				pushstr(L, "%");				break;			}			default:			{				char buff[3];				buff[0] = '%';				buff[1] = *(e + 1);				buff[2] = '/0';				pushstr(L, buff);				break;			}		}		n += 2;		fmt = e + 2;	}	pushstr(L, fmt);	luaV_concat(L, n + 1, cast_int(L->top - L->base) - 1);	L->top -= n;	return svalue(L->top - 1);}
开发者ID:Ape,项目名称:DCPUToolchain,代码行数:70,


示例12: kp_table_histogram

/* histogram: key should be number or string, value must be number */void kp_table_histogram(ktap_State *ks, Table *t){	struct table_hist_record *thr;	char dist_str[40];	int i, ratio, total = 0, count = 0;	thr = kp_malloc(ks, sizeof(*thr) * (t->sizearray + sizenode(t)));	for (i = 0; i < t->sizearray; i++) {		Tvalue *v = &t->array[i];		if (isnil(v))			continue;		if (!ttisnumber(v))			goto error;		setnvalue(&thr[count++].key, i + 1);		total += nvalue(v);	}	for (i = 0; i < sizenode(t); i++) {		Node *n = &t->node[i];		int num;		if (isnil(gkey(n)))			continue;		if (!ttisnumber(gval(n)))			goto error;		num = nvalue(gval(n));		setobj(ks, &thr[count].key, gkey(n));		setobj(ks, &thr[count].val, gval(n));		count++;		total += nvalue(gval(n));	}	sort(thr, count, sizeof(struct table_hist_record), hist_record_cmp, NULL);	kp_printf(ks, "%32s%s%s/n", "value ", DISTRIBUTION_STR, " count");	dist_str[sizeof(dist_str) - 1] = '/0';	for (i = 0; i < count; i++) {		Tvalue *key = &thr[i].key;		Tvalue *val = &thr[i].val;		memset(dist_str, ' ', sizeof(dist_str) - 1);		ratio = (nvalue(val) * (sizeof(dist_str) - 1)) / total;		memset(dist_str, '@', ratio);		if (ttisstring(key)) {			char buf[32 + 1] = {0};			char *keystr;			if (strlen(svalue(key)) > 32) {				strncpy(buf, svalue(key), 32-4);				memset(buf + 32-4, '.', 3);				keystr = buf;			} else				keystr = svalue(key);			kp_printf(ks, "%32s |%s%-10d/n", keystr, dist_str,					nvalue(val));		} else			kp_printf(ks, "%32d | %s%-10d/n", nvalue(key),					dist_str, nvalue(val));	}	goto out; error:	kp_printf(ks, "error: table histogram only handle "			" (key: string/number val: number)/n"); out:	kp_free(ks, thr);}
开发者ID:eric-zhu,项目名称:ktap,代码行数:77,


示例13: lua_execute

/*** Execute the given opcode, until a RET. Parameters are between** [stack+base,top). Returns n such that the the results are between** [stack+n,top).*/static StkId lua_execute (Byte *pc, StkId base){  if (lua_callhook)    callHook (base, LUA_T_MARK, 0); while (1) {  OpCode opcode;  switch (opcode = (OpCode)*pc++)  {   case PUSHNIL: ttype(top) = LUA_T_NIL; incr_top; break;   case PUSH0: case PUSH1: case PUSH2:     ttype(top) = LUA_T_NUMBER;     nvalue(top) = opcode-PUSH0;     incr_top;     break;   case PUSHBYTE:      ttype(top) = LUA_T_NUMBER; nvalue(top) = *pc++; incr_top; break;   case PUSHWORD:   {    Word w;    get_word(w,pc);    ttype(top) = LUA_T_NUMBER; nvalue(top) = w;    incr_top;   }   break;   case PUSHFLOAT:   {    real num;    get_float(num,pc);    ttype(top) = LUA_T_NUMBER; nvalue(top) = num;    incr_top;   }   break;   case PUSHSTRING:   {    Word w;    get_word(w,pc);    ttype(top) = LUA_T_STRING; tsvalue(top) = lua_constant[w];    incr_top;   }   break;   case PUSHFUNCTION:   {    TFunc *f;    get_code(f,pc);    luaI_insertfunction(f);  /* may take part in GC */    top->ttype = LUA_T_FUNCTION;    top->value.tf = f;    incr_top;   }   break;   case PUSHLOCAL0: case PUSHLOCAL1: case PUSHLOCAL2:   case PUSHLOCAL3: case PUSHLOCAL4: case PUSHLOCAL5:   case PUSHLOCAL6: case PUSHLOCAL7: case PUSHLOCAL8:   case PUSHLOCAL9:      *top = *((stack+base) + (int)(opcode-PUSHLOCAL0)); incr_top; break;   case PUSHLOCAL: *top = *((stack+base) + (*pc++)); incr_top; break;   case PUSHGLOBAL:   {    Word w;    get_word(w,pc);    getglobal(w);   }   break;   case PUSHINDEXED:    pushsubscript();    break;   case PUSHSELF:   {     TObject receiver = *(top-1);     Word w;     get_word(w,pc);     ttype(top) = LUA_T_STRING; tsvalue(top) = lua_constant[w];     incr_top;     pushsubscript();     *top = receiver;     incr_top;     break;   }   case STORELOCAL0: case STORELOCAL1: case STORELOCAL2:   case STORELOCAL3: case STORELOCAL4: case STORELOCAL5:   case STORELOCAL6: case STORELOCAL7: case STORELOCAL8:   case STORELOCAL9://.........这里部分代码省略.........
开发者ID:Akagi201,项目名称:learning-lua,代码行数:101,


示例14: luaV_execute

StkId luaV_execute(lua_Task *task) {	if (!task->some_flag) {		luaD_checkstack((*task->pc++) + EXTRA_STACK);		if (*task->pc < ZEROVARARG) {			luaD_adjusttop(task->base + *(task->pc++));		} else {			luaC_checkGC();			adjust_varargs(task->base + (*task->pc++) - ZEROVARARG);		}		task->some_flag = 1;	}	lua_state->state_counter2++;	while (1) {		switch ((OpCode)(task->aux = *task->pc++)) {		case PUSHNIL0:			ttype(task->S->top++) = LUA_T_NIL;			break;		case PUSHNIL:			task->aux = *task->pc++;			do {				ttype(task->S->top++) = LUA_T_NIL;			} while (task->aux--);			break;		case PUSHNUMBER:			task->aux = *task->pc++;			goto pushnumber;		case PUSHNUMBERW:			task->aux = next_word(task->pc);			goto pushnumber;		case PUSHNUMBER0:		case PUSHNUMBER1:		case PUSHNUMBER2:			task->aux -= PUSHNUMBER0;pushnumber:			ttype(task->S->top) = LUA_T_NUMBER;			nvalue(task->S->top) = (float)task->aux;			task->S->top++;			break;		case PUSHLOCAL:			task->aux = *task->pc++;			goto pushlocal;		case PUSHLOCAL0:		case PUSHLOCAL1:		case PUSHLOCAL2:		case PUSHLOCAL3:		case PUSHLOCAL4:		case PUSHLOCAL5:		case PUSHLOCAL6:		case PUSHLOCAL7:			task->aux -= PUSHLOCAL0;pushlocal:			*task->S->top++ = *((task->S->stack + task->base) + task->aux);			break;		case GETGLOBALW:			task->aux = next_word(task->pc);			goto getglobal;		case GETGLOBAL:			task->aux = *task->pc++;			goto getglobal;		case GETGLOBAL0:		case GETGLOBAL1:		case GETGLOBAL2:		case GETGLOBAL3:		case GETGLOBAL4:		case GETGLOBAL5:		case GETGLOBAL6:		case GETGLOBAL7:			task->aux -= GETGLOBAL0;getglobal:			luaV_getglobal(tsvalue(&task->consts[task->aux]));			break;		case GETTABLE:			luaV_gettable();			break;		case GETDOTTEDW:			task->aux = next_word(task->pc); goto getdotted;		case GETDOTTED:			task->aux = *task->pc++;			goto getdotted;		case GETDOTTED0:		case GETDOTTED1:		case GETDOTTED2:		case GETDOTTED3:		case GETDOTTED4:		case GETDOTTED5:		case GETDOTTED6:		case GETDOTTED7:			task->aux -= GETDOTTED0;getdotted:			*task->S->top++ = task->consts[task->aux];			luaV_gettable();			break;		case PUSHSELFW:			task->aux = next_word(task->pc);			goto pushself;		case PUSHSELF:			task->aux = *task->pc++;			goto pushself;		case PUSHSELF0://.........这里部分代码省略.........
开发者ID:Templier,项目名称:residual,代码行数:101,


示例15: lua_execute

//.........这里部分代码省略.........   pushnil: tag(top) = LUA_T_NIL; incr_top; goto *table[*pc++];   push0: push1: push2:     tag(top) = LUA_T_NUMBER;     nvalue(top) = ((OpCode)*(pc-1))-PUSH0;     incr_top;     goto *table[*pc++];   pushbyte:      tag(top) = LUA_T_NUMBER; nvalue(top) = *pc++; incr_top; goto *table[*pc++];   pushword:   {    Word w;    get_word(w,pc);    tag(top) = LUA_T_NUMBER; nvalue(top) = w;    incr_top;   }   goto *table[*pc++];   pushfloat:   {    real num;    get_float(num,pc);    tag(top) = LUA_T_NUMBER; nvalue(top) = num;    incr_top;   }   goto *table[*pc++];   pushstring:   {    Word w;    get_word(w,pc);    tag(top) = LUA_T_STRING; tsvalue(top) = lua_constant[w];    incr_top;   }   goto *table[*pc++];   pushfunction:   {    TFunc *f;    get_code(f,pc);    luaI_insertfunction(f);  /* may take part in GC */    top->tag = LUA_T_FUNCTION;    top->value.tf = f;    incr_top;   }   goto *table[*pc++];   pushlocal0: pushlocal1: pushlocal2:   pushlocal3: pushlocal4: pushlocal5:   pushlocal6: pushlocal7: pushlocal8:   pushlocal9:      *top = *((stack+base) + (int)(((OpCode)*(pc-1))-PUSHLOCAL0)); incr_top; goto *table[*pc++];   pushlocal: *top = *((stack+base) + (*pc++)); incr_top; goto *table[*pc++];   pushglobal:   {    Word w;    get_word(w,pc);    getglobal(w);   }   goto *table[*pc++];   pushindexed:
开发者ID:cskau,项目名称:VM,代码行数:67,


示例16: luaV_concat

void luaV_concat (lua_State *L, int total, int last) {  int useType = LUA_TSTRING;  int i;  StkId top = L->base + last + 1;  for (i = 0; i < total; ++i)  {    if (ttype(top-1-i) == LUA_TSTRING || ttype(top-1-i) == LUA_TWSTRING)    {      useType = ttype(top-1-i);      break;    }  }  if (useType == LUA_TSTRING)  {    do {      StkId top = L->base + last + 1;      int n = 2;  /* number of elements handled in this pass (at least 2) */      if (!tostring(L, top-2) || !tostring(L, top-1)) {        if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT))          luaG_concaterror(L, top-2, top-1);      } else if (tsvalue(top-1)->len > 0) {  /* if len=0, do nothing */        /* at least two string values; get as many as possible */        size_t tl = tsvalue(top-1)->len;        char *buffer;        int i;        /* collect total length */        for (n = 1; n < total && tostring(L, top-n-1); n++) {          size_t l = tsvalue(top-n-1)->len;          if (l >= MAX_SIZET - tl) luaG_runerror(L, "string length overflow");          tl += l;        }        buffer = luaZ_openspace(L, &G(L)->buff, tl);        tl = 0;        for (i=n; i>0; i--) {  /* concat all strings */          size_t l = tsvalue(top-i)->len;          memcpy(buffer+tl, svalue(top-i), l);          tl += l;#if LUA_REFCOUNT          luarc_cleanvalue(top-i);#endif /* LUA_REFCOUNT */        }        setsvalue2s(L, top-n, luaS_newlstr(L, buffer, tl));      }      total -= n-1;  /* got `n' strings to create 1 new */      last -= n-1;    } while (total > 1);  /* repeat until only 1 result left */  } else {    do {      StkId top = L->base + last + 1;      int n = 2;  /* number of elements handled in this pass (at least 2) */      if (!towstring(L, top-2) || !towstring(L, top-1)) {        if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT))          luaG_concaterror(L, top-2, top-1);      } else if (tsvalue(top-1)->len > 0) {  /* if len=0, do nothing */        /* at least two string values; get as many as possible */        size_t tl = tsvalue(top-1)->len;        char *buffer;        int i;        /* collect total length */        for (n = 1; n < total && towstring(L, top-n-1); n++) {          size_t l = tsvalue(top-n-1)->len;          if (l >= MAX_SIZET - tl) luaG_runerror(L, "string length overflow");          tl += l;        }        buffer = luaZ_openspace(L, &G(L)->buff, tl*2);        tl = 0;        for (i=n; i>0; i--) {  /* concat all strings */          size_t l = tsvalue(top-i)->len;          memcpy(buffer+tl*2, wsvalue(top-i), l*2);          tl += l;#if LUA_REFCOUNT          luarc_cleanvalue(top-i);#endif /* LUA_REFCOUNT */        }        setwsvalue2s(L, top-n, luaS_newlwstr(L, (const lua_WChar*)buffer, tl));      }      total -= n-1;  /* got `n' strings to create 1 new */      last -= n-1;    } while (total > 1);  /* repeat until only 1 result left */  }}
开发者ID:zapline,项目名称:zlib,代码行数:83,


示例17: return

const char *lua_getstring (lua_Object object) {	if (object == LUA_NOOBJECT || tostring(Address(object)))		return nullptr;	else		return (svalue(Address(object)));}
开发者ID:Akz-,项目名称:residual,代码行数:6,


示例18: luaA_indexAcceptable

LUA_API const char *lua_tostring (lua_State *L, int index) {  StkId o = luaA_indexAcceptable(L, index);  return (o == NULL || tostring(L, o)) ? NULL : svalue(o);}
开发者ID:XeanoRRR,项目名称:mmo-resourse,代码行数:4,


示例19: _vscprintf

/* this function handles only `%d', `%c', %f, %p, and `%s' formats   and now it handles %x and %X as well */const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp){#if LUAXS_CORE_FORMAT == 2    size_t alloclen = _vscprintf(fmt, argp) + 1;    char* buf = luaM_malloc(L, alloclen);    vsprintf_s(buf, alloclen, fmt, argp);    pushstr(L, buf);    luaM_freemem(L, buf, alloclen);    return svalue(L->top - 1);#else    int n = 1;    pushstr(L, "");    for (;;) {        const char *e = strchr(fmt, '%');        if (e == NULL) break;        setsvalue2s(L, L-&gt;top, luaS_newlstr(L, fmt, e-fmt));        incr_top(L);        switch (*(e+1)) {        case 's': {            const char *s = va_arg(argp, char *);            if (s == NULL) s = "(null)";            pushstr(L, s);            break;            }        case 'c': {            char buff[2];            buff[0] = cast(char, va_arg(argp, int));            buff[1] = '/0';            pushstr(L, buff);            break;            }        case 'd': {            setnvalue(L-&gt;top, cast_num(va_arg(argp, int)));            incr_top(L);            break;            }        case 'f': {            setnvalue(L-&gt;top, cast_num(va_arg(argp, l_uacNumber)));            incr_top(L);            break;            }        case 'p': {            char buff[4*sizeof(void *) + 8]; /* should be enough space for a `%p' */            sprintf(buff, "%p", va_arg(argp, void *));            pushstr(L, buff);            break;            }#if LUAXS_CORE_FORMAT == 1        case 'X': {            char buff[sizeof(int)*2+3];            sprintf(buff, "%X", va_arg(argp, int));            pushstr(L, buff);            break;            }        case 'x': {            char buff[sizeof(int)*2+3];            sprintf(buff, "%x", va_arg(argp, int));            pushstr(L, buff);            break;            }#endif        case '%': {            pushstr(L, "%");            break;            }        default: {            char buff[3];            buff[0] = '%';            buff[1] = *(e+1);            buff[2] = '/0';            pushstr(L, buff);            break;            }        }        n += 2;        fmt = e+2;    }    pushstr(L, fmt);    luaV_concat(L, n+1, cast_int(L-&gt;top - L-&gt;base) - 1);    L-&gt;top -= n;    return svalue(L-&gt;top - 1);#endif}
开发者ID:Xetrill,项目名称:XsLuaJIT,代码行数:85,


示例20: PrintCode

static void PrintCode(const Proto* f){    const Instruction* code=f->code;    int pc,n=f->sizecode;    for (pc=0; pc<n; pc++)    {        Instruction i=code[pc];        OpCode o=GET_OPCODE(i);        int a=GETARG_A(i);        int b=GETARG_B(i);        int c=GETARG_C(i);        int bc=GETARG_Bx(i);        int sbc=GETARG_sBx(i);        int line=getline(f,pc);#if 0        printf("%0*lX",Sizeof(i)*2,i);#endif        printf("/t%d/t",pc+1);        if (line>0) printf("[%d]/t",line);        else printf("[-]/t");        printf("%-9s/t",luaP_opnames[o]);        switch (getOpMode(o))        {        case iABC:            printf("%d %d %d",a,b,c);            break;        case iABx:            printf("%d %d",a,bc);            break;        case iAsBx:            printf("%d %d",a,sbc);            break;        }        switch (o)        {        case OP_LOADK:            printf("/t; ");            PrintConstant(f,bc);            break;        case OP_GETUPVAL:        case OP_SETUPVAL:            printf("/t; %s", (f->sizeupvalues>0) ? getstr(f->upvalues[b]) : "-");            break;        case OP_GETGLOBAL:        case OP_SETGLOBAL:            printf("/t; %s",svalue(&f->k[bc]));            break;        case OP_GETTABLE:        case OP_SELF:            if (c>=MAXSTACK) {                printf("/t; ");                PrintConstant(f,c-MAXSTACK);            }            break;        case OP_SETTABLE:        case OP_ADD:        case OP_SUB:        case OP_MUL:        case OP_DIV:        case OP_POW:        case OP_EQ:        case OP_LT:        case OP_LE:            if (b>=MAXSTACK || c>=MAXSTACK)            {                printf("/t; ");                if (b>=MAXSTACK) PrintConstant(f,b-MAXSTACK);                else printf("-");                printf(" ");                if (c>=MAXSTACK) PrintConstant(f,c-MAXSTACK);            }            break;        case OP_JMP:        case OP_FORLOOP:        case OP_TFORPREP:            printf("/t; to %d",sbc+pc+2);            break;        case OP_CLOSURE:            printf("/t; %p",VOID(f->p[bc]));            break;        default:            break;        }        printf("/n");    }}
开发者ID:nuclewall,项目名称:bsdinstaller,代码行数:86,


示例21: kp_strfmt

int kp_strfmt(ktap_state *ks, struct trace_seq *seq){	int arg = 1;	size_t sfl;	ktap_value *arg_fmt = kp_arg(ks, 1);	int argnum = kp_arg_nr(ks);	const char *strfrmt, *strfrmt_end;	strfrmt = svalue(arg_fmt);	sfl = rawtsvalue(arg_fmt)->tsv.len;	strfrmt_end = strfrmt + sfl;	while (strfrmt < strfrmt_end) {		if (*strfrmt != L_ESC)			trace_seq_putc(seq, *strfrmt++);		else if (*++strfrmt == L_ESC)			trace_seq_putc(seq, *strfrmt++);		else { /* format item */			char form[MAX_FORMAT];			if (++arg > argnum) {				ktap_argerror(ks, arg, "no value");				return -1;			}			strfrmt = scanformat(ks, strfrmt, form);			switch (*strfrmt++) {			case 'c':				trace_seq_printf(seq, form,						 nvalue(kp_arg(ks, arg)));				break;			case 'd':  case 'i': {				ktap_number n = nvalue(kp_arg(ks, arg));				INTFRM_T ni = (INTFRM_T)n;				addlenmod(form, INTFRMLEN);				trace_seq_printf(seq, form, ni);				break;			}			case 'p': {				char str[KSYM_SYMBOL_LEN];				SPRINT_SYMBOL(str, nvalue(kp_arg(ks, arg)));				trace_seq_puts(seq, str);				break;			}			case 'o':  case 'u':  case 'x':  case 'X': {				ktap_number n = nvalue(kp_arg(ks, arg));				unsigned INTFRM_T ni = (unsigned INTFRM_T)n;				addlenmod(form, INTFRMLEN);				trace_seq_printf(seq, form, ni);				break;			}			case 's': {				ktap_value *v = kp_arg(ks, arg);				const char *s;				size_t l;				if (isnil(v)) {					trace_seq_puts(seq, "nil");					return 0;				}				if (ttisevent(v)) {					kp_event_tostring(ks, seq);					return 0;				}				s = svalue(v);				l = rawtsvalue(v)->tsv.len;				if (!strchr(form, '.') && l >= 100) {					/*					 * no precision and string is too long					 * to be formatted;					 * keep original string					 */					trace_seq_puts(seq, s);					break;				} else {					trace_seq_printf(seq, form, s);					break;				}			}			default: /* also treat cases `pnLlh' */				kp_error(ks, "invalid option " KTAP_QL("%%%c")					     " to " KTAP_QL("format"),					     *(strfrmt - 1));			}		}	}	return 0;}
开发者ID:5victor,项目名称:ktap,代码行数:91,


示例22: switch

// Scan for a series of assignmentsvoid Decompiler::do_multi_assign(Byte *&start) {  std::queue<Expression *> results;  ExprStack values;  bool done;  int num_tables = 0;  do {    int aux, opc;    done = false;    opc = *start++;    switch (opc) {    case SETLOCAL:      aux = *start++;      goto setlocal;    case SETLOCAL0:    case SETLOCAL1:    case SETLOCAL2:    case SETLOCAL3:    case SETLOCAL4:    case SETLOCAL5:    case SETLOCAL6:    case SETLOCAL7:      aux = opc - SETLOCAL0;    setlocal:      results.push(new VarExpr(start, localname(tf, aux)));      break;    case SETGLOBAL:      aux = *start++;      goto setglobal;    case SETGLOBAL0:    case SETGLOBAL1:    case SETGLOBAL2:    case SETGLOBAL3:    case SETGLOBAL4:    case SETGLOBAL5:    case SETGLOBAL6:    case SETGLOBAL7:      aux = opc - SETGLOBAL0;      goto setglobal;    case SETGLOBALW:      aux = start[0] | (start[1] << 8);      start += 2;    setglobal:      results.push(new VarExpr(start, svalue(tf->consts + aux)));      break;    case SETTABLE:      start++;			// assume offset is correct      num_tables++;      // this needs stuff from farther up the stack, wait until      // it's available    case SETTABLE0:      results.push(new IndexExpr(start, NULL, NULL));      break;    default:      start--;      done = true;    }    if (! done) {      Expression *e = stk->top();      // Check for fake result from function calls with multiple return values      VarExpr *v = dynamic_cast<VarExpr *>(e);      if (v != NULL && v->name == "<extra result>")	delete e;      else	values.push(e);      stk->pop();    }  } while (! done);  // Check for popping tables and indices  if (num_tables > 0 && (*start == POP || *start == POP0 || *start == POP1)) {    start++;    if (start[-1] == POP)      start++;  }  // Now get actual tables and indices from the stack, reversing  // the list to the right order at the same time  ExprStack results2;  while (! results.empty()) {    Expression *var = results.front(); results.pop();    IndexExpr *tbl = dynamic_cast<IndexExpr *>(var);    if (tbl != NULL) {      tbl->index = stk->top(); stk->pop();      tbl->table = stk->top(); stk->pop();    }    results2.push(var);  }//.........这里部分代码省略.........
开发者ID:Botje,项目名称:residualvm-tools,代码行数:101,


示例23: luaV_tointeger

/*** try to convert a value to an integer, rounding according to 'mode':** mode == 0: accepts only integral values** mode == 1: takes the floor of the number** mode == 2: takes the ceil of the number*/int luaV_tointeger (const TValue *obj, lua_Integer *p, int mode) {  TValue v; again:#ifndef _KERNEL  if (ttisfloat(obj)) {    lua_Number n = fltvalue(obj);    lua_Number f = l_floor(n);    if (n != f) {  /* not an integral value? */      if (mode == 0) return 0;  /* fails if mode demands integral value */      else if (mode > 1)  /* needs ceil? */        f += 1;  /* convert floor to ceil (remember: n != f) */    }    return lua_numbertointeger(f, p);  }  else if (ttisinteger(obj)) {#else /* _KERNEL */  if (ttisinteger(obj)) {    UNUSED(mode);#endif    *p = ivalue(obj);    return 1;  }  else if (cvt2num(obj) &&            luaO_str2num(svalue(obj), &v) == vslen(obj) + 1) {    obj = &v;    goto again;  /* convert result from 'luaO_str2num' to an integer */  }  return 0;  /* conversion failed */}#ifndef _KERNEL/*** Try to convert a 'for' limit to an integer, preserving the** semantics of the loop.** (The following explanation assumes a non-negative step; it is valid** for negative steps mutatis mutandis.)** If the limit can be converted to an integer, rounding down, that is** it.** Otherwise, check whether the limit can be converted to a number.  If** the number is too large, it is OK to set the limit as LUA_MAXINTEGER,** which means no limit.  If the number is too negative, the loop** should not run, because any initial integer value is larger than the** limit. So, it sets the limit to LUA_MININTEGER. 'stopnow' corrects** the extreme case when the initial value is LUA_MININTEGER, in which** case the LUA_MININTEGER limit would still run the loop once.*/static int forlimit (const TValue *obj, lua_Integer *p, lua_Integer step,                     int *stopnow) {  *stopnow = 0;  /* usually, let loops run */  if (!luaV_tointeger(obj, p, (step < 0 ? 2 : 1))) {  /* not fit in integer? */    lua_Number n;  /* try to convert to float */    if (!tonumber(obj, &n)) /* cannot convert to float? */      return 0;  /* not a number */    if (luai_numlt(0, n)) {  /* if true, float is larger than max integer */      *p = LUA_MAXINTEGER;      if (step < 0) *stopnow = 1;    }    else {  /* float is smaller than min integer */      *p = LUA_MININTEGER;      if (step >= 0) *stopnow = 1;    }  }  return 1;}
开发者ID:fgken,项目名称:netbsd-src,代码行数:71,


示例24: fileinit

fileinit(){	register char *p;	register int i, j;	struct stat stbuf;	if (tline == INCRMT * (HBLKS+2))		return;	cleanup(0);	if (tfile >= 0)		close(tfile);	tline = INCRMT * (HBLKS+2);	blocks[0] = HBLKS;	blocks[1] = HBLKS+1;	blocks[2] = -1;	dirtcnt = 0;	iblock = -1;	iblock2 = -1;	oblock = -1;	CP(tfname, svalue(DIRECTORY));#ifndef vms	if (stat(tfname, &stbuf))#else	goto vms_no_check_dir;#endif	{dumbness:		if (setexit() == 0)			filioerr(tfname);		else			putNFL();		cleanup(1);		ex_exit(1);	}#ifndef	vms	if ((stbuf.st_mode & S_IFMT) != S_IFDIR) {		errno = ENOTDIR;		goto dumbness;	}#elsevms_no_check_dir:#endif	ichanged = 0;	ichang2 = 0;#ifndef	vms	ignore(strcat(tfname, "/ExXXXXX"));#else	ignore(strcat(tfname, "ExXXXXX"));#endif	for (p = strend(tfname), i = 5, j = getpid(); i > 0; i--, j /= 10)		*--p = j % 10 | '0';#ifdef vms	ignore(strcat(tfname, ".txt.1"));	unlink(tfname);#endif	tfile = creat(tfname, 0600);	if (tfile < 0)		goto dumbness;#ifdef VMUNIX	{		extern stilinc;		/* see below */		stilinc = 0;	}#endif	havetmp = 1;	if (tfile >= 0)		close(tfile);	tfile = open(tfname, 2);	if (tfile < 0)		goto dumbness;#ifdef UNIX_SBRK/* 	brk((char *)fendcore); */#endif}
开发者ID:dank101,项目名称:4.4BSD-Alpha,代码行数:74,



注:本文中的svalue函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ svcCloseHandle函数代码示例
C++ sval函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。