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


C++ GETARG_C函数代码示例

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


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

示例1: patchtestreg

static int patchtestreg (FuncState *fs, int node, int reg) {
  Instruction *i = getjumpcontrol(fs, node);
  if (GET_OPCODE(*i) != OP_TESTSET)
    return 0;  /* cannot patch other instructions */
  if (reg != NO_REG && reg != GETARG_B(*i))
    SETARG_A(*i, reg);
  else  /* no register to put value or register already has the value */
    *i = CREATE_ABC(OP_TEST, GETARG_B(*i), 0, GETARG_C(*i));

  return 1;
}
开发者ID:ggreco,项目名称:lpcgame,代码行数:11,代码来源:lcode.c

示例2: 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

示例3: 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 bx=GETARG_Bx(i);
 int sbx=GETARG_sBx(i);
 int line=getline(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) ? (-1-INDEXK(b)) : b);
   else lua_pushnil(L);
   if (getCMode(o)!=OpArgN) lua_pushinteger(L,ISK(c) ? (-1-INDEXK(c)) : c);
   else lua_pushnil(L);
   break;
  case iABx:
   lua_pushinteger(L,a);
   if (getBMode(o)==OpArgK) lua_pushinteger(L,-1-bx); else lua_pushinteger(L,bx);
   lua_pushnil(L);
   break;
  case iAsBx:
   if (o!=OP_JMP) lua_pushinteger(L,a);
   lua_pushinteger(L,sbx);
   lua_pushnil(L);
   break;
 }
 switch (o)
 {
   case OP_JMP:
   case OP_FORLOOP:
   case OP_FORPREP:
    lua_pop(L,1);
    lua_pushinteger(L,sbx+pc+2);
    lua_pushnil(L);
    break;
   default:
    break;
 }
 }
 return 5;
}
开发者ID:Stevie-O,项目名称:SharpLua,代码行数:53,代码来源:lbci.c

示例4: luaK_setoneret

/*
** Fix an expression to return one result.
** If expression is not a multi-ret expression (function call or
** vararg), it already returns one result, so nothing needs to be done.
** Function calls become VNONRELOC expressions (as its result comes
** fixed in the base register of the call), while vararg expressions
** become VRELOCABLE (as OP_VARARG puts its results where it wants).
** (Calls are created returning one result, so that does not need
** to be fixed.)
*/
void luaK_setoneret (FuncState *fs, expdesc *e) {
  if (e->k == VCALL) {  /* expression is an open function call? */
    /* already returns 1 value */
    lua_assert(GETARG_C(getinstruction(fs, e)) == 2);
    e->k = VNONRELOC;  /* result has fixed position */
    e->u.info = GETARG_A(getinstruction(fs, e));
  }
  else if (e->k == VVARARG) {
    SETARG_B(getinstruction(fs, e), 2);
    e->k = VRELOCABLE;  /* can relocate its simple result */
  }
}
开发者ID:celskeggs,项目名称:selkie,代码行数:22,代码来源:lcode.c

示例5: ci_func

static const char *getobjname (CallInfo *ci, int stackpos, const char **name) {
    if (isLua(ci)) {  /* a Lua function? */
        Proto *p = ci_func(ci)->l.p;
        int pc = currentpc(ci);
        Instruction i;
        *name = luaF_getlocalname(p, stackpos+1, pc);
        if (*name)  /* is a local? */
            return "local";
        i = luaG_symbexec(p, pc, stackpos);  /* try symbolic execution */
        lua_assert(pc != -1);
        switch (GET_OPCODE(i)) {
        case OP_GETGLOBAL: {
            int g = GETARG_Bx(i);  /* global index */
            lua_assert(ttisstring(&p->k[g]));
            *name = svalue(&p->k[g]);
            return "global";
        }
        case OP_MOVE: {
            int a = GETARG_A(i);
            int b = GETARG_B(i);  /* move from `b' to `a' */
            if (b < a)
                return getobjname(ci, b, name);  /* get name for `b' */
            break;
        }
        case OP_GETTABLE: {
            int k = GETARG_C(i);  /* key index */
            *name = kname(p, k);
            return "field";
        }
        case OP_SELF: {
            int k = GETARG_C(i);  /* key index */
            *name = kname(p, k);
            return "method";
        }
        default:
            break;
        }
    }
    return NULL;  /* no useful name found */
}
开发者ID:0xmono,项目名称:miranda-ng,代码行数:40,代码来源:ldebug.c

示例6: Opcode

Logical::Logical(CompilerState& cs, Stack& stack) :
    Opcode(cs, stack),
    ra_(stack.GetR(GETARG_A(cs.instr_))),
    rkb_(stack.GetRK(GETARG_B(cs.instr_))),
    rkc_(stack.GetRK(GETARG_C(cs.instr_))),
    trytm_(cs.CreateSubBlock("trytm")) {
    
    assert(GET_OPCODE(cs.instr_) == OP_BAND ||
           GET_OPCODE(cs.instr_) == OP_BOR ||
           GET_OPCODE(cs.instr_) == OP_BXOR ||
           GET_OPCODE(cs.instr_) == OP_SHL ||
           GET_OPCODE(cs.instr_) == OP_SHR);
}
开发者ID:gligneul,项目名称:Lua-Low-Level,代码行数:13,代码来源:llllogical.cpp

示例7: CompileCmp

void Compiler::CompileCmp(const std::string& function) {
    auto& rkb = stack_.GetRK(GETARG_B(cs_.instr_));
    auto& rkc = stack_.GetRK(GETARG_C(cs_.instr_));
    auto args = {cs_.values_.state, rkb.GetTValue(), rkc.GetTValue()};
    auto result = cs_.CreateCall(function, args, "result");
    stack_.Update();

    auto a = cs_.MakeInt(GETARG_A(cs_.instr_));
    auto cmp = cs_.B_.CreateICmpNE(result, a, "cmp");
    auto nextblock = cs_.blocks_[cs_.curr_ + 2];
    auto jmpblock = cs_.blocks_[cs_.curr_ + 1];
    cs_.B_.CreateCondBr(cmp, nextblock, jmpblock);
}
开发者ID:gligneul,项目名称:Lua-Low-Level,代码行数:13,代码来源:lllcompiler.cpp

示例8: Opcode

Arith::Arith(CompilerState& cs, Stack& stack) :
    Opcode(cs, stack),
    ra_(stack.GetR(GETARG_A(cs.instr_))),
    rkb_(stack.GetRK(GETARG_B(cs.instr_))),
    rkc_(stack.GetRK(GETARG_C(cs.instr_))),
    x_(rkb_),
    y_(rkc_),
    check_y_(cs.CreateSubBlock("check_y")),
    intop_(cs.CreateSubBlock("intop", check_y_)),
    floatop_(cs.CreateSubBlock("floatop", intop_)),
    tmop_(cs.CreateSubBlock("tmop", floatop_)),
    x_int_(nullptr),
    x_float_(nullptr) {
}
开发者ID:gligneul,项目名称:Lua-Low-Level,代码行数:14,代码来源:lllarith.cpp

示例9: GETARG_A

void Compiler::CompileCall() {
    int a = GETARG_A(cs_.instr_);
    int b = GETARG_B(cs_.instr_);
    if (b != 0)
        cs_.SetTop(a + b);
    auto& ra = stack_.GetR(a);
    auto args = {
        cs_.values_.state,
        ra.GetTValue(),
        cs_.MakeInt(GETARG_C(cs_.instr_) - 1)
    };
    cs_.CreateCall("luaD_callnoyield", args);
    stack_.Update();
}
开发者ID:gligneul,项目名称:Lua-Low-Level,代码行数:14,代码来源:lllcompiler.cpp

示例10: patchtestreg

/* Patch register of test instructions. */
static int patchtestreg (FuncState *fs, int node, int reg) {
  Instruction *i = getjumpcontrol(fs, node);
  if (GET_OPCODE(*i) != OP_TESTSET)
    return 0;  /* cannot patch other instructions */
  if (reg != NO_REG && reg != GETARG_B(*i)) {
    SETARG_A(*i, reg);
    DEBUG_CODEGEN(raviY_printf(fs, "[?]* %o ; set A to %d\n", *i, reg));
  }
  else  /* no register to put value or register already has the value */ {
    *i = CREATE_ABC(OP_TEST, GETARG_B(*i), 0, GETARG_C(*i));
    DEBUG_CODEGEN(raviY_printf(fs, "[?]* %o ; generate OP_TEST\n", *i));
  }

  return 1;
}
开发者ID:galek,项目名称:ravi,代码行数:16,代码来源:lcode.c

示例11: patch_irep

static void
patch_irep(mrb_state *mrb, mrb_irep *irep, int bnest)
{
  size_t i;
  mrb_code c;

  for (i = 0; i < irep->rlen; i++) {
    patch_irep(mrb, irep->reps[i], bnest + 1);
  }

  for (i = 0; i < irep->ilen; i++) {
    c = irep->iseq[i];
    switch(GET_OPCODE(c)){
    case OP_SEND:
      if (GETARG_C(c) != 0) {
        break;
      }
      {
        mrb_code arg = search_variable(mrb, irep->syms[GETARG_B(c)], bnest);
        if (arg != 0) {
          /* must replace */
          irep->iseq[i] = MKOPCODE(OP_GETUPVAR) | MKARG_A(GETARG_A(c)) | arg;
        }
      }
      break;

    case OP_MOVE:
      /* src part */
      if (GETARG_B(c) < irep->nlocals) {
        mrb_code arg = search_variable(mrb, irep->lv[GETARG_B(c) - 1].name, bnest);
        if (arg != 0) {
          /* must replace */
          irep->iseq[i] = MKOPCODE(OP_GETUPVAR) | MKARG_A(GETARG_A(c)) | arg;
        }
      }
      /* dst part */
      if (GETARG_A(c) < irep->nlocals) {
        mrb_code arg = search_variable(mrb, irep->lv[GETARG_A(c) - 1].name, bnest);
        if (arg != 0) {
          /* must replace */
          irep->iseq[i] = MKOPCODE(OP_SETUPVAR) | MKARG_A(GETARG_B(c)) | arg;
        }
      }
      break;
    }
  }
}
开发者ID:AE9RB,项目名称:mruby-complex,代码行数:47,代码来源:eval.c

示例12: print_op

/* helper function to print out the opcode
 * as well as the arguments
 */
static void print_op(bInst op)
{
    int args = opcode_args[GET_OPCODE(op)];
    printf("\t%s", opcode_names[GET_OPCODE(op)]);
    if (args == ARG_NONE)
        return;
    if (HASARG_A(args))
        printf(" %d", GETARG_A(op));
    if (HASARG_B(args))
        printf(" %d", GETARG_B(op));
    if (HASARG_C(args))
        printf(" %d", GETARG_C(op));
    if (HASARG_Bx(args))
        printf(" %d", GETARG_Bx(op));
    if (HASARG_sBx(args))
        printf(" %d", GETARG_sBx(op));
    return;
}
开发者ID:erik,项目名称:bijou,代码行数:21,代码来源:block.c

示例13: 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:Neoniet,项目名称:upspring,代码行数:45,代码来源:ljitlib.c

示例14: CompileTestset

void Compiler::CompileTestset() {
    auto checkbool = cs_.CreateSubBlock("checkbool");
    auto checkfalse = cs_.CreateSubBlock("checkfalse", checkbool);
    auto fail = cs_.CreateSubBlock("set", checkfalse);
    auto success = cs_.blocks_[cs_.curr_ + 2];

    auto& r = stack_.GetR(GETARG_B(cs_.instr_));
    if (GETARG_C(cs_.instr_)) {
        auto isnil = r.HasTag(LUA_TNIL);
        cs_.B_.CreateCondBr(isnil, success, checkbool);

        cs_.B_.SetInsertPoint(checkbool);
        auto isbool = r.HasTag(LUA_TBOOLEAN);
        cs_.B_.CreateCondBr(isbool, checkfalse, fail);

        cs_.B_.SetInsertPoint(checkfalse);
        auto bvalue = r.GetBoolean();
        auto isfalse = cs_.B_.CreateICmpEQ(bvalue, cs_.MakeInt(0));
        cs_.B_.CreateCondBr(isfalse, success, fail);
    } else {
        auto isnil = r.HasTag(LUA_TNIL);
        cs_.B_.CreateCondBr(isnil, fail, checkbool);

        cs_.B_.SetInsertPoint(checkbool);
        auto isbool = r.HasTag(LUA_TBOOLEAN);
        cs_.B_.CreateCondBr(isbool, checkfalse, success);

        cs_.B_.SetInsertPoint(checkfalse);
        auto bvalue = r.GetBoolean();
        auto isfalse = cs_.B_.CreateICmpEQ(bvalue, cs_.MakeInt(0));
        cs_.B_.CreateCondBr(isfalse, fail, success);
    }

    cs_.B_.SetInsertPoint(fail);
    auto& ra = stack_.GetR(GETARG_A(cs_.instr_));
    ra.Assign(r);
    cs_.B_.CreateBr(cs_.blocks_[cs_.curr_ + 1]);
}
开发者ID:gligneul,项目名称:Lua-Low-Level,代码行数:38,代码来源:lllcompiler.cpp

示例15: luaK_patchlistaux

static void luaK_patchlistaux (FuncState *fs, int list,
          int ttarget, int treg, int ftarget, int freg, int dtarget) {
  while (list != NO_JUMP) {
    int next = luaK_getjump(fs, list);
    Instruction *i = getjumpcontrol(fs, list);
    if (GET_OPCODE(*i) != OP_TEST) {
      lua_assert(dtarget != NO_JUMP);
      luaK_fixjump(fs, list, dtarget);  /* jump to default target */
    }
    else {
      if (GETARG_C(*i)) {
        lua_assert(ttarget != NO_JUMP);
        patchtestreg(i, treg);
        luaK_fixjump(fs, list, ttarget);
      }
      else {
        lua_assert(ftarget != NO_JUMP);
        patchtestreg(i, freg);
        luaK_fixjump(fs, list, ftarget);
      }
    }
    list = next;
  }
}
开发者ID:yuanxiubin1128,项目名称:mmo-resourse,代码行数:24,代码来源:lcode.c


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