当前位置: 首页>>代码示例>>C++>>正文


C++ ISK函数代码示例

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


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

示例1: do_getinstruction

static int do_getinstruction(lua_State *L)	/** getinstruction(f,i) */
{
 const Proto* f=Pget(L,1);
 int pc=luaL_checkinteger(L,2);
 if (pc<=0 || pc>f->sizecode || f->code==NULL) return 0;
 pc--;
 {
 const Instruction* code=f->code;
 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 ax=GETARG_Ax(i);
 int bx=GETARG_Bx(i);
 int sbx=GETARG_sBx(i);
 int line=getfuncline(f,pc);
 if (line>0) lua_pushinteger(L,line); else lua_pushnil(L);
 lua_pushstring(L,luaP_opnames[o]);
 switch (getOpMode(o))
 {
  case iABC:
   lua_pushinteger(L,a);
   if (getBMode(o)!=OpArgN) lua_pushinteger(L,ISK(b) ? (MYK(INDEXK(b))) : b);
   else lua_pushnil(L);
   if (getCMode(o)!=OpArgN) lua_pushinteger(L,ISK(c) ? (MYK(INDEXK(c))) : c);
   else lua_pushnil(L);
   break;
  case iABx:
   lua_pushinteger(L,a);
   if (getBMode(o)==OpArgK) lua_pushinteger(L,MYK(bx)); else lua_pushinteger(L,bx);
   lua_pushnil(L);
   break;
  case iAsBx:
   lua_pushinteger(L,a);
   lua_pushinteger(L,sbx);
   lua_pushnil(L);
   break;
  case iAx:
   lua_pushinteger(L,MYK(ax));
   lua_pushnil(L);
   lua_pushnil(L);
   break;
 }
 switch (o)
 {
   case OP_JMP:
   case OP_FORLOOP:
   case OP_FORPREP:
   case OP_TFORLOOP:
    lua_pop(L,1);
    lua_pushinteger(L,sbx+pc+2);
    break;
   default:
    break;
 }
 }
 return 5;
}
开发者ID:siffiejoe,项目名称:lua-lbci,代码行数:59,代码来源:lbci-5.2.c

示例2: ju_bytecode

/* local op, a, b, c, test = jit.util.bytecode(func, pc) */
static int ju_bytecode(lua_State *L)
{
    Proto *pt = check_LCL(L)->l.p;
    int pc = luaL_checkint(L, 2);
    if (pc >= 1 && pc <= pt->sizecode) {
        Instruction ins = pt->code[pc-1];
        OpCode op = GET_OPCODE(ins);
        if (pc > 1 && (((int)OP_SETLIST) << POS_OP) ==
                (pt->code[pc-2] & (MASK1(SIZE_OP,POS_OP) | MASK1(SIZE_C,POS_C)))) {
            lua_pushstring(L, luaP_opnames[OP_SETLIST]);
            lua_pushnumber(L, (lua_Number)ins);  /* Fake extended op. */
            return 1;
        }
        if (op >= NUM_OPCODES) return 0;  /* Just in case. */
        lua_pushstring(L, luaP_opnames[op]);
        lua_pushinteger(L, GETARG_A(ins));
        switch (getOpMode(op)) {
        case iABC: {
            int b = GETARG_B(ins), c = GETARG_C(ins);
            switch (getBMode(op)) {
            case OpArgN:
                lua_pushnil(L);
                break;
            case OpArgK:
                if (ISK(b)) b = -1-INDEXK(b);
            case OpArgR:
            case OpArgU:
                lua_pushinteger(L, b);
                break;
            }
            switch (getCMode(op)) {
            case OpArgN:
                lua_pushnil(L);
                break;
            case OpArgK:
                if (ISK(c)) c = -1-INDEXK(c);
            case OpArgR:
            case OpArgU:
                lua_pushinteger(L, c);
                break;
            }
            lua_pushboolean(L, testTMode(op));
            return 5;
        }
        case iABx: {
            int bx = GETARG_Bx(ins);
            lua_pushinteger(L, getBMode(op) == OpArgK ? -1-bx : bx);
            return 3;
        }
        case iAsBx:
            lua_pushinteger(L, GETARG_sBx(ins));
            return 3;
        }
    }
    return 0;
}
开发者ID:vasilenkomike,项目名称:xray,代码行数:57,代码来源:ljitlib.c

示例3: freereg

static void freereg(FuncState *fs, int reg)
{
	if (!ISK(reg) && reg >= fs->nactvar) {
		fs->freereg--;
		ktap_assert(reg == fs->freereg);
	}
}
开发者ID:WeiY,项目名称:ktap,代码行数:7,代码来源:code.c

示例4: kp_optimize_code

/*
 * This function must be called before all code loaded.
 */
void kp_optimize_code(ktap_state *ks, int level, ktap_proto *f)
{
	int i;

	for (i = 0; i < f->sizecode; i++) {
		int instr = f->code[i];
		ktap_value *k = f->k;

		if (GET_OPCODE(instr) == OP_GETTABUP) {
			if ((GETARG_B(instr) == 0) && ISK(GETARG_C(instr))) {
				ktap_value *field = k + INDEXK(GETARG_C(instr));
				if (ttype(field) == KTAP_TSTRING) {
					int index = cfunction_cache_getindex(ks,
									field);
					if (index == -1)
						break;

					SET_OPCODE(instr, OP_LOAD_GLOBAL);
					SETARG_C(instr, index);
					f->code[i] = instr;
					break;
				}
			}
		}
	}

	/* continue optimize sub functions */
	for (i = 0; i < f->sizep; i++)
		kp_optimize_code(ks, level + 1, f->p[i]);
}
开发者ID:joelagnel,项目名称:ktap,代码行数:33,代码来源:vm.c

示例5: kname

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:migerh,项目名称:DCPUToolchain,代码行数:7,代码来源:ldebug.c

示例6: isshortstr

/**
 * Is the operand a reference to a short string constant?
 */
static int isshortstr(FuncState *fs, int kk) {
  if (ISK(kk)) {
    Proto *f = fs->f;
    kk = INDEXK(kk);
    lua_assert(kk >= 0 && kk < f->sizek);
    return ttisshrstring(&f->k[kk]);
  }
  return 0;
}
开发者ID:jadr2ddude,项目名称:ravi,代码行数:12,代码来源:lcode.c

示例7: luaV_finishOp

/*
** finish execution of an opcode interrupted by an yield
*/
void luaV_finishOp (lua_State *L) {
  CallInfo *ci = L->ci;
  StkId base = ci->u.l.base;
  Instruction inst = *(ci->u.l.savedpc - 1);  /* interrupted instruction */
  OpCode op = GET_OPCODE(inst);
  switch (op) {  /* finish its execution */
    case OP_ADD: case OP_SUB: case OP_MUL: case OP_DIV:
    case OP_MOD: case OP_POW: case OP_UNM: case OP_LEN:
    case OP_GETTABUP: case OP_GETTABLE: case OP_SELF: {
      setobjs2s(L, base + GETARG_A(inst), --L->top);
      break;
    }
    case OP_LE: case OP_LT: case OP_EQ: {
      int res = !l_isfalse(L->top - 1);
      L->top--;
      /* metamethod should not be called when operand is K */
      lua_assert(!ISK(GETARG_B(inst)));
      if (op == OP_LE &&  /* "<=" using "<" instead? */
          ttisnil(luaT_gettmbyobj(L, base + GETARG_B(inst), TM_LE)))
        res = !res;  /* invert result */
      lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_JMP);
      if (res != GETARG_A(inst))  /* condition failed? */
        ci->u.l.savedpc++;  /* skip jump instruction */
      break;
    }
    case OP_CONCAT: {
      StkId top = L->top - 1;  /* top when 'call_binTM' was called */
      int b = GETARG_B(inst);      /* first element to concatenate */
      int total = cast_int(top - 1 - (base + b));  /* yet to concatenate */
      setobj2s(L, top - 2, top);  /* put TM result in proper position */
      if (total > 1) {  /* are there elements to concat? */
        L->top = top - 1;  /* top is one after last element (at top-2) */
        luaV_concat(L, total);  /* concat them (may yield again) */
      }
      /* move final result to final position */
      setobj2s(L, ci->u.l.base + GETARG_A(inst), L->top - 1);
      L->top = ci->top;  /* restore top */
      break;
    }
    case OP_TFORCALL: {
      lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_TFORLOOP);
      L->top = ci->top;  /* correct top */
      break;
    }
    case OP_CALL: {
      if (GETARG_C(inst) - 1 >= 0)  /* nresults >= 0? */
        L->top = ci->top;  /* adjust results */
      break;
    }
    case OP_TAILCALL: case OP_SETTABUP:  case OP_SETTABLE:
      break;
    default: lua_assert(0);
  }
}
开发者ID:lriki,项目名称:Volkoff,代码行数:57,代码来源:lvm.c

示例8: checkArgMode

static int checkArgMode (const Proto *pt, int r, enum OpArgMask mode) {
  switch (mode) {
    case OpArgN: check(r == 0); break;
    case OpArgU: break;
    case OpArgR: checkreg(pt, r); break;
    case OpArgK:
      check(ISK(r) ? INDEXK(r) < pt->sizek : r < pt->maxstacksize);
      break;
  }
  return 1;
}
开发者ID:GranPC,项目名称:llvm-lua,代码行数:11,代码来源:ldebug.c

示例9: emit_debug_trace

void RaviCodeGenerator::emit_BITWISE_SHIFT_OP(RaviFunctionDef *def, OpCode op,
                                              int A, int B, int C, int pc) {
  bool traced = emit_debug_trace(def, op, pc);
  emit_load_base(def);
  llvm::Value *ra = emit_gep_register(def, A);

  // If the RHS is a constant and we know that LHS is
  // and integer then we can optimize the code generation
  if (op == OP_RAVI_SHL_II && ISK(C)) {
    lua_Integer y = def->p->k[INDEXK(C)].value_.i;
    emit_bitwise_shiftl(def, ra, B, y);
  } else if (op == OP_RAVI_SHR_II && ISK(C)) {
    lua_Integer y = def->p->k[INDEXK(C)].value_.i;
    emit_bitwise_shiftl(def, ra, B, -y);
  } else {
    // RHS is not a constant
    llvm::Value *rc = emit_gep_register_or_constant(def, C);
    llvm::Value *rb = emit_gep_register_or_constant(def, B);

    // Since the Lua OP_SHL and OP_SHR bytecodes
    // could invoke metamethods we need to set
    // 'savedpc'
    switch (op) {
    case OP_SHL:
      if (!traced) emit_update_savedpc(def, pc);
    case OP_RAVI_SHL_II:
      CreateCall4(def->builder, def->raviV_op_shlF, def->L, ra, rb, rc);
      break;
    case OP_SHR:
      if (!traced) emit_update_savedpc(def, pc);
    case OP_RAVI_SHR_II:
      CreateCall4(def->builder, def->raviV_op_shrF, def->L, ra, rb, rc);
      break;
    default:
      fprintf(stderr, "unexpected value of opcode %d\n", (int)op);
      abort();
    }
  }
}
开发者ID:duchuan123,项目名称:ravi,代码行数:39,代码来源:ravi_llvmarith1.cpp

示例10: kname

/*
** find a "name" for the RK value 'c'
*/
static void kname (Proto *p, int pc, int c, const char **name) {
	if (ISK(c)) {  /* is 'c' a constant? */
	TValue *kvalue = &p->k[INDEXK(c)];
	if (ttisstring(kvalue)) {  /* literal constant? */
		*name = svalue(kvalue);  /* it is its own name */
		return;
	}
	/* else no reasonable name found */
	}
	else {  /* 'c' is a register */
	const char *what = getobjname(p, pc, c, name); /* search for 'c' */
	if (what && *what == 'c') {  /* found a constant name? */
		return;  /* 'name' already filled */
	}
	/* else no reasonable name found */
	}
	*name = "?";  /* no reasonable name found */
}
开发者ID:crazii,项目名称:mameplus,代码行数:21,代码来源:ldebug.c

示例11: kname2

/*
** find a "name" for the RK value 'c'
*/
void kname2 (LuaProto *p, int pc, int c, std::string& name) {
  if (ISK(c)) {  /* is 'c' a constant? */
    LuaValue *kvalue = &p->constants[INDEXK(c)];
    if (kvalue->isString()) {  /* literal constant? */
      name = kvalue->getString()->c_str();  /* it is its own name */
      return;
    }
    /* else no reasonable name found */
  }
  else {  /* 'c' is a register */
    const char *what = getobjname2(p, pc, c, name); /* search for 'c' */
    if (what && *what == 'c') {  /* found a constant name? */
      return;  /* 'name' already filled */
    }
    /* else no reasonable name found */
  }
  name = "?";  /* no reasonable name found */
}
开发者ID:aappleby,项目名称:Lumina,代码行数:21,代码来源:ldebug.cpp

示例12: freereg

static void ICACHE_FLASH_ATTR freereg (FuncState *fs, int reg) {
  if (!ISK(reg) && reg >= fs->nactvar) {
    fs->freereg--;
    lua_assert(reg == fs->freereg);
  }
}
开发者ID:Squonk42,项目名称:nodelua,代码行数:6,代码来源:lcode.c

示例13:

/*static*/ void FuncState::freereg (/*FuncState *fs,*/ int reg) {
	if (!ISK(reg) && reg >= nactvar) {
		free_reg--;
		lua_assert(reg == free_reg);
	}
}
开发者ID:swizl,项目名称:lua,代码行数:6,代码来源:lcode.cpp

示例14: 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 ax=GETARG_Ax(i);
  int bx=GETARG_Bx(i);
  int sbx=GETARG_sBx(i);
  int line=getfuncline(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) ? (MYK(INDEXK(b))) : b);
    if (getCMode(o)!=OpArgN) printf(" %d",ISK(c) ? (MYK(INDEXK(c))) : c);
    break;
   case iABx:
    printf("%d",a);
    if (getBMode(o)==OpArgK) printf(" %d",MYK(bx));
    if (getBMode(o)==OpArgU) printf(" %d",bx);
    break;
   case iAsBx:
    printf("%d %d",a,sbx);
    break;
   case iAx:
    printf("%d",MYK(ax));
    break;
  }
  switch (o)
  {
   case OP_LOADK:
    printf("\t; "); PrintConstant(f,bx);
    break;
   case OP_GETUPVAL:
   case OP_SETUPVAL:
    printf("\t; %s",UPVALNAME(b));
    break;
   case OP_GETTABUP:
    printf("\t; %s",UPVALNAME(b));
    if (ISK(c)) { printf(" "); PrintConstant(f,INDEXK(c)); }
    break;
   case OP_SETTABUP:
    printf("\t; %s",UPVALNAME(a));
    if (ISK(b)) { printf(" "); PrintConstant(f,INDEXK(b)); }
    if (ISK(c)) { printf(" "); PrintConstant(f,INDEXK(c)); }
    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_POW:
   case OP_DIV:
   case OP_IDIV:
   case OP_BAND:
   case OP_BOR:
   case OP_BXOR:
   case OP_SHL:
   case OP_SHR:
   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:
   case OP_TFORLOOP:
    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;
   case OP_EXTRAARG:
    printf("\t; "); PrintConstant(f,ax);
    break;
   default:
    break;
  }
//.........这里部分代码省略.........
开发者ID:bysdxt,项目名称:xLua,代码行数:101,代码来源:luac.c

示例15: freereg

static void freereg (FuncState *fs, int reg) {
  if (!ISK(reg)) {
    fs->freereg--;
    lua_assert(reg == fs->freereg);
  }
}
开发者ID:hongzhidao,项目名称:yet-another-lua,代码行数:6,代码来源:lcode.c


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