这篇教程C++ GET_OPCODE函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中GET_OPCODE函数的典型用法代码示例。如果您正苦于以下问题:C++ GET_OPCODE函数的具体用法?C++ GET_OPCODE怎么用?C++ GET_OPCODE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了GET_OPCODE函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: check_an_msg//-1 error//1 tc//0 normal//2 retryintcheck_an_msg(ushort flag, uchar * domain, int *bk){ uint get = 0; flag = ntohs(flag); //printf("flag is 0x%x/n",flag); get = GET_QR(flag); if (get == QR_Q) //query { printf("answer set Q sign/n"); return -1; } get = GET_OPCODE(flag); //ignore. get = GET_AA(flag); //ignore get = GET_TC(flag); if (get == 1) return 1; //tc get = GET_RD(flag); //ignore get = GET_ERROR(flag); if ((get != 0) && (get != NAME_ERROR)) //soa { switch (get) { case SERVER_FAIL: //printf("2server fail/n"); break; //case NAME_ERROR: SOA //*bk = 1; //printf("3name error/n"); //break; case FORMAT_ERROR: //*bk = 1; //printf("1format error/n"); break; case NOT_IMPL: //printf("4not implation/n"); break; case REFUSED: //printf("5server refused/n"); break; } return 2; } return 0;}
开发者ID:han4235,项目名称:dnspod-sr,代码行数:48,
示例2: findsetreg/*** try to find last instruction before 'lastpc' that modified register 'reg'*/static int findsetreg (Proto *p, int lastpc, int reg) { int pc; int setreg = -1; /* keep last instruction that changed 'reg' */ int jmptarget = 0; /* any code before this address is conditional */ for (pc = 0; pc < lastpc; pc++) { Instruction i = p->code[pc]; OpCode op = GET_OPCODE(i); int a = GETARG_A(i); switch (op) { case OP_LOADNIL: { int b = GETARG_B(i); if (a <= reg && reg <= a + b) /* set registers from 'a' to 'a+b' */ setreg = filterpc(pc, jmptarget); break; } case OP_TFORCALL: { if (reg >= a + 2) /* affect all regs above its base */ setreg = filterpc(pc, jmptarget); break; } case OP_CALL: case OP_TAILCALL: { if (reg >= a) /* affect all registers above base */ setreg = filterpc(pc, jmptarget); break; } case OP_JMP: { int b = GETARG_sBx(i); int dest = pc + 1 + b; /* jump is forward and do not skip 'lastpc'? */ if (pc < dest && dest <= lastpc) { if (dest > jmptarget) jmptarget = dest; /* update 'jmptarget' */ } break; } default: if (testAMode(op) && reg == a) /* any instruction that set A */ setreg = filterpc(pc, jmptarget); break; } } return setreg;}
开发者ID:Ardakaniz,项目名称:NazaraEngine,代码行数:47,
示例3: switchllvm::Value* Logical::PerformIntOp(llvm::Value* a, llvm::Value* b) { auto name = "result"; switch (GET_OPCODE(cs_.instr_)) { case OP_BAND: return cs_.B_.CreateAnd(a, b, name); case OP_BOR: return cs_.B_.CreateOr(a, b, name); case OP_BXOR: return cs_.B_.CreateXor(a, b, name); case OP_SHL: return cs_.CreateCall("luaV_shiftl", {a, b}, name); case OP_SHR: return cs_.CreateCall("luaV_shiftl", {a, cs_.B_.CreateNeg(b)}, name); default: break; } assert(false); return nullptr;}
开发者ID:gligneul,项目名称:Lua-Low-Level,代码行数:19,
示例4: PrintCodestatic void PrintCode(const Proto* tf){ const Instruction* code=tf->code; const Instruction* p=code; for (;;) { int at=p-code+1; Instruction i=*p; int line=luaG_getline(tf->lineinfo,at-1,1,NULL); printf("%6d/t",at); if (line>=0) printf("[%d]/t",line); else printf("[-]/t"); switch (GET_OPCODE(i)) {#include "print.h" } printf("/n"); if (i==OP_END) break; p++; }}
开发者ID:jessicah,项目名称:Vision,代码行数:19,
示例5: luaK_patchlistauxstatic void luaK_patchlistaux (FuncState *fs, int list, int target, OpCode special, int special_target) { Instruction *code = fs->f->code; while (list != NO_JUMP) { int next = luaK_getjump(fs, list); Instruction *i = &code[list]; OpCode op = GET_OPCODE(*i); if (op == special) /* this `op' already has a value */ luaK_fixjump(fs, list, special_target); else { luaK_fixjump(fs, list, target); /* do the patch */ if (op == OP_JMPONT) /* remove eventual values */ SET_OPCODE(*i, OP_JMPT); else if (op == OP_JMPONF) SET_OPCODE(*i, OP_JMPF); } list = next; }}
开发者ID:xiaobinshe,项目名称:multitv,代码行数:19,
示例6: tws_dmamap_data_load_cbfnstatic voidtws_dmamap_data_load_cbfn(void *arg, bus_dma_segment_t *segs, int nseg, int error){ struct tws_request *req = (struct tws_request *)arg; struct tws_softc *sc = req->sc; u_int16_t sgls = nseg; void *sgl_ptr; struct tws_cmd_generic *gcmd; if ( error == EFBIG ) TWS_TRACE(sc, "not enough data segs", 0, nseg); if ( req->flags & TWS_DIR_IN ) bus_dmamap_sync(req->sc->data_tag, req->dma_map, BUS_DMASYNC_PREREAD); if ( req->flags & TWS_DIR_OUT ) bus_dmamap_sync(req->sc->data_tag, req->dma_map, BUS_DMASYNC_PREWRITE); if ( segs ) { if ( (req->type == TWS_PASSTHRU_REQ && GET_OPCODE(req->cmd_pkt->cmd.pkt_a.res__opcode) != TWS_FW_CMD_EXECUTE_SCSI) || req->type == TWS_GETSET_PARAM_REQ) { gcmd = &req->cmd_pkt->cmd.pkt_g.generic; sgl_ptr = (u_int32_t *)(gcmd) + gcmd->size; gcmd->size += sgls * ((req->sc->is64bit && !tws_use_32bit_sgls) ? 4 :2 ); tws_fill_sg_list(req->sc, segs, sgl_ptr, sgls); } else { tws_fill_sg_list(req->sc, segs, (void *)req->cmd_pkt->cmd.pkt_a.sg_list, sgls); req->cmd_pkt->cmd.pkt_a.lun_h4__sgl_entries |= sgls ; } } req->error_code = tws_submit_command(req->sc, req);}
开发者ID:kusumi,项目名称:DragonFlyBSD,代码行数:43,
示例7: findsetreg/*** try to find last instruction before 'lastpc' that modified register 'reg'*/static int findsetreg (Proto *p, int lastpc, int reg) { int pc; int setreg = -1; /* keep last instruction that changed 'reg' */ for (pc = 0; pc < lastpc; pc++) { Instruction i = p->code[pc]; OpCode op = GET_OPCODE(i); int a = GETARG_A(i); switch (op) { case OP_LOADNIL: { int b = GETARG_B(i); if (a <= reg && reg <= a + b) /* set registers from 'a' to 'a+b' */ setreg = pc; break; } case OP_TFORCALL: { if (reg >= a + 2) setreg = pc; /* affect all regs above its base */ break; } case OP_CALL: case OP_TAILCALL: { if (reg >= a) setreg = pc; /* affect all registers above base */ break; } case OP_JMP: { int b = GETARG_sBx(i); int dest = pc + 1 + b; /* jump is forward and do not skip `lastpc'? */ if (pc < dest && dest <= lastpc) pc += b; /* do the jump */ break; } case OP_TEST: { if (reg == a) setreg = pc; /* jumped code can change 'a' */ break; } default: if (testAMode(op) && reg == a) /* any instruction that set A */ setreg = pc; break; } } return setreg;}
开发者ID:shitfSign,项目名称:lua4cn,代码行数:46,
示例8: luaK_nil/*** Create a OP_LOADNIL instruction, but try to optimize: if the previous** instruction is also OP_LOADNIL and ranges are compatible, adjust** range of previous instruction instead of emitting a new one. (For** instance, 'local a; local b' will generate a single opcode.)*/void luaK_nil (FuncState *fs, int from, int n) { Instruction *previous; int l = from + n - 1; /* last register to set nil */ if (fs->pc > fs->lasttarget) { /* no jumps to current position? */ previous = &fs->f->code[fs->pc-1]; if (GET_OPCODE(*previous) == OP_LOADNIL) { /* previous is LOADNIL? */ int pfrom = GETARG_A(*previous); /* get previous range */ int pl = pfrom + GETARG_B(*previous); if ((pfrom <= from && from <= pl + 1) || (from <= pfrom && pfrom <= l + 1)) { /* can connect both? */ if (pfrom < from) from = pfrom; /* from = min(from, pfrom) */ if (pl > l) l = pl; /* l = max(l, pl) */ SETARG_A(*previous, from); SETARG_B(*previous, l - from); return; } } /* else go through */ } luaK_codeABC(fs, OP_LOADNIL, from, n - 1, 0); /* else no optimization */}
开发者ID:celskeggs,项目名称:selkie,代码行数:26,
示例9: switchllvm::Value* Arith::PerformIntOp(llvm::Value* lhs, llvm::Value* rhs) { auto name = "result"; switch (GET_OPCODE(cs_.instr_)) { case OP_ADD: return cs_.B_.CreateAdd(lhs, rhs, name); case OP_SUB: return cs_.B_.CreateSub(lhs, rhs, name); case OP_MUL: return cs_.B_.CreateMul(lhs, rhs, name); case OP_MOD: return cs_.CreateCall("luaV_mod", {cs_.values_.state, lhs, rhs}, name); case OP_IDIV: return cs_.CreateCall("luaV_div", {cs_.values_.state, lhs, rhs}, name); default: break; } assert(false); return nullptr;}
开发者ID:gligneul,项目名称:Lua-Low-Level,代码行数:21,
示例10: tgVM_execvoid tgVM_exec(tgState* T) { tgOpcode op; tgValue *base = T->stack; for (;;) { op = GET_OPCODE(T); switch (op) { case OP_ADDRR: arith_op(T, tgAdd); break; case OP_SUBRR: arith_op(T, tgSub); break; case OP_MULRR: arith_op(T, tgMul); break; case OP_DIVRR: arith_op(T, tgDiv); break; } }}
开发者ID:smorimura,项目名称:tiger,代码行数:21,
示例11: luaK_nilvoid luaK_nil (FuncState *fs, int from, int n) { Instruction *previous; if (fs->pc > fs->lasttarget) { /* no jumps to current position? */ if (fs->pc == 0) { /* function start? */ if (from >= fs->nactvar) return; /* positions are already clean */ } else { previous = &fs->f->code[fs->pc - 1]; if (GET_OPCODE(*previous) == OP_LOADNIL) { int pfrom = GETARG_A(*previous); int pto = GETARG_B(*previous); if (pfrom <= from && from <= pto + 1) { /* can connect both? */ if (from + n - 1 > pto) SETARG_B(*previous, from + n - 1); return; } } } } luaK_codeABC(fs, OP_LOADNIL, from, from + n - 1, 0); /* else no optimization */}
开发者ID:xiqingping,项目名称:embedded_template,代码行数:21,
示例12: OptConstantsstatic void OptConstants(Proto* tf){ Instruction* p; int n=tf->nknum+tf->nkstr; Hash* map=luaH_new(L,n); int m=MapConstants(tf,map);#ifdef DEBUG printf("%p n=%d m=%d %s/n",tf,n,m,(m==n)?"nothing to optimize":"yes!");#endif if (m==n) return; for (p=tf->code;; p++) { Instruction i=*p; int op=GET_OPCODE(i); switch (op) { TObject o; int j,k; case OP_PUSHNUM: case OP_PUSHNEGNUM: j=GETARG_U(i); ttype(&o)=LUA_TNUMBER; nvalue(&o)=tf->knum[j]; k=MapConstant(map,-1,&o); if (k!=j) *p=CREATE_U(op,k); break; case OP_PUSHSTRING: case OP_GETGLOBAL: case OP_GETDOTTED: case OP_PUSHSELF: case OP_SETGLOBAL: j=GETARG_U(i); ttype(&o)=LUA_TSTRING; tsvalue(&o)=tf->kstr[j]; k=MapConstant(map,-1,&o); if (k!=j) *p=CREATE_U(op,k); break; case OP_END: PackConstants(tf,map); luaH_free(L,map); return; default: break; } }}
开发者ID:jessicah,项目名称:Vision,代码行数:40,
示例13: ci_funcstatic 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,
示例14: TrObject_methodTrCallSite *TrVM::lookup(TrBlock *b, OBJ receiver, OBJ msg, TrInst *ip){ TrVM *vm = this; OBJ method = TrObject_method(this, receiver, msg); TrInst *boing = (ip - 1); /* TODO: do not prealloc TrCallSite here, every one is a memory leak and a new one is created on polymorphic calls. */ b->sites.emplace_back(); TrCallSite *s = &b->sites.back(); s->klass = TR_CLASS(receiver); s->miss = 0; s->method = method; s->message = msg; if (unlikely(method == TR_NIL)) { s->method = TrObject_method(this, receiver, tr_intern("method_missing")); s->method_missing = 1; } /* Implement Monomorphic method cache by replacing the previous instruction (BOING) w/ CACHE that uses the CallSite to find the method instead of doing a full lookup. */ if (GET_OPCODE(*boing) == TR_OP_CACHE) { /* Existing call site */ /* TODO: maybe take existing call site hit miss into consideration to replace it with this one. For now, we just don't replace it, the first one is always the cached one. */ } else { /* New call site, we cache it fo shizzly! */ SET_OPCODE(*boing, TR_OP_CACHE); SETARG_A(*boing, GETARG_A(*ip)); /* receiver register */ SETARG_B(*boing, 1); /* jmp */ SETARG_C(*boing, b->sites.size()-1); /* CallSite index */ } return s;}
开发者ID:jtomschroeder,项目名称:tinyrb,代码行数:40,
示例15: luaK_nil/* Emit bytecode to set a range of registers to nil. */void luaK_nil (FuncState *fs, int from, int n) { Instruction *previous; int l = from + n - 1; /* last register to set nil */ if (fs->pc > fs->lasttarget) { /* no jumps to current position? */ previous = &fs->f->code[fs->pc-1]; if (GET_OPCODE(*previous) == OP_LOADNIL) { /* Try to merge with the previous instruction. */ int pfrom = GETARG_A(*previous); int pl = pfrom + GETARG_B(*previous); if ((pfrom <= from && from <= pl + 1) || (from <= pfrom && pfrom <= l + 1)) { /* can connect both? */ if (pfrom < from) from = pfrom; /* from = min(from, pfrom) */ if (pl > l) l = pl; /* l = max(l, pl) */ SETARG_A(*previous, from); DEBUG_CODEGEN(raviY_printf(fs, "[%d]* %o ; set A to %d/n", fs->pc - 1, *previous, from)); SETARG_B(*previous, l - from); DEBUG_CODEGEN(raviY_printf(fs, "[%d]* %o ; set B to %d/n", fs->pc - 1, *previous, (l - from))); return; } } /* else go through */ } luaK_codeABC(fs, OP_LOADNIL, from, n - 1, 0); /* else no optimization */}
开发者ID:galek,项目名称:ravi,代码行数:23,
示例16: OptConstantsstatic void OptConstants(Proto* tf){ Instruction* p; int n=tf->nknum+tf->nkstr; Hash* map=luaH_new(compile_lua_state,n); int m=MapConstants(tf,map); if (m==n) return; for (p=tf->code;; p++) { Instruction i=*p; int op=GET_OPCODE(i); switch (op) { TObject o; int j,k; case OP_PUSHNUM: case OP_PUSHNEGNUM: j=GETARG_U(i); ttype(&o)=LUA_TNUMBER; nvalue(&o)=tf->knum[j]; k=MapConstant(map,-1,&o); if (k!=j) *p=CREATE_U(op,k); break; case OP_PUSHSTRING: case OP_GETGLOBAL: case OP_GETDOTTED: case OP_PUSHSELF: case OP_SETGLOBAL: j=GETARG_U(i); ttype(&o)=LUA_TSTRING; tsvalue(&o)=tf->kstr[j]; k=MapConstant(map,-1,&o); if (k!=j) *p=CREATE_U(op,k); break; case OP_END: PackConstants(tf,map); luaH_free(compile_lua_state,map); return; default: break; } }}
开发者ID:jcubic,项目名称:ToME,代码行数:38,
示例17: ci_funcstatic const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) { TMS tm; Proto *p = ci_func(ci)->p; /* calling function */ int pc = currentpc(ci); /* calling instruction index */ Instruction i = p->code[pc]; /* calling instruction */ switch (GET_OPCODE(i)) { case OP_CALL: case OP_TAILCALL: /* get function name */ return getobjname(p, pc, GETARG_A(i), name); case OP_TFORCALL: { /* for iterator */ *name = "for iterator"; return "for iterator"; } /* all other instructions can call only through metamethods */ case OP_SELF: case OP_GETTABUP: case OP_GETTABLE: tm = TM_INDEX; break; case OP_SETTABUP: case OP_SETTABLE: tm = TM_NEWINDEX; break; case OP_EQ: tm = TM_EQ; break; case OP_ADD: tm = TM_ADD; break; case OP_SUB: tm = TM_SUB; break; case OP_MUL: tm = TM_MUL; break; case OP_DIV: tm = TM_DIV; break; case OP_IDIV: tm = TM_IDIV; break; case OP_MOD: tm = TM_MOD; break; case OP_POW: tm = TM_POW; break; case OP_UNM: tm = TM_UNM; break; case OP_LEN: tm = TM_LEN; break; case OP_LT: tm = TM_LT; break; case OP_LE: tm = TM_LE; break; case OP_CONCAT: tm = TM_CONCAT; break; default: return NULL; /* else no useful name can be found */ } *name = getstr(G(L)->tmname[tm]); return "metamethod";}
开发者ID:hongzhidao,项目名称:yet-another-lua,代码行数:38,
示例18: check_method_breakpointstatic int32_tcheck_method_breakpoint(mrb_state *mrb, mrb_irep *irep, mrb_code *pc, mrb_value *regs){ struct RClass* c; mrb_sym sym; int32_t bpno; mrb_bool isCfunc; mrb_debug_context *dbg = mrb_debug_context_get(mrb); isCfunc = FALSE; bpno = dbg->method_bpno; dbg->method_bpno = 0; switch(GET_OPCODE(*pc)) { case OP_SEND: case OP_SENDB: c = mrb_class(mrb, regs[GETARG_A(*pc)]); sym = irep->syms[GETARG_B(*pc)]; break; case OP_SUPER: c = mrb->c->ci->target_class->super; sym = mrb->c->ci->mid; break; default: sym = 0; break; } if(sym != 0) { dbg->method_bpno = mrb_debug_check_breakpoint_method(mrb, dbg, c, sym, &isCfunc); if(isCfunc) { bpno = dbg->method_bpno; dbg->method_bpno = 0; } } dbg->isCfunc = isCfunc; return bpno;}
开发者ID:Asmod4n,项目名称:mruby,代码行数:38,
示例19: getfuncname2const char* getfuncname2 (LuaThread *L, LuaStackFrame *ci, std::string& name) { THREAD_CHECK(L); TMS tm; LuaProto *p = ci->getFunc()->getLClosure()->proto_; /* calling function */ int pc = ci->getCurrentPC(); /* calling instruction index */ Instruction i = p->instructions_[pc]; /* calling instruction */ switch (GET_OPCODE(i)) { case OP_CALL: case OP_TAILCALL: /* get function name */ return getobjname2(p, pc, GETARG_A(i), name); case OP_TFORCALL: { /* for iterator */ name = "for iterator"; return "for iterator"; } /* all other instructions can call only through metamethods */ case OP_SELF: case OP_GETTABUP: case OP_GETTABLE: tm = TM_INDEX; break; case OP_SETTABUP: case OP_SETTABLE: tm = TM_NEWINDEX; break; case OP_EQ: tm = TM_EQ; break; case OP_ADD: tm = TM_ADD; break; case OP_SUB: tm = TM_SUB; break; case OP_MUL: tm = TM_MUL; break; case OP_DIV: tm = TM_DIV; break; case OP_MOD: tm = TM_MOD; break; case OP_POW: tm = TM_POW; break; case OP_UNM: tm = TM_UNM; break; case OP_LEN: tm = TM_LEN; break; case OP_LT: tm = TM_LT; break; case OP_LE: tm = TM_LE; break; case OP_CONCAT: tm = TM_CONCAT; break; default: return NULL; /* else no useful name can be found */ } name = G(L)->tagmethod_names_[tm]->c_str(); return "metamethod";}
开发者ID:aappleby,项目名称:Lumina,代码行数:38,
示例20: luaK_patchlistauxstatic 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,
示例21: luaV_executevoid luaV_execute (lua_State *L, int nexeccalls) { LClosure *cl; StkId base; TValue *k; const Instruction *pc; reentry: /* entry point */ lua_assert(isLua(L->ci)); pc = L->savedpc; cl = &clvalue(L->ci->func)->l; base = L->base; k = cl->p->k; /* main loop of interpreter */ for (;;) { const Instruction i = *pc++; StkId ra; if ((L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) && (--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) { traceexec(L, pc); if (L->status == LUA_YIELD) { /* did hook yield? */ L->savedpc = pc - 1; return; } base = L->base; } /* warning!! several calls may realloc the stack and invalidate `ra' */ ra = RA(i); lua_assert(base == L->base && L->base == L->ci->base); lua_assert(base <= L->top && L->top <= L->stack + L->stacksize); lua_assert(L->top == L->ci->top || luaG_checkopenop(i)); switch (GET_OPCODE(i)) { case OP_MOVE: { setobjs2s(L, ra, RB(i)); continue; } case OP_LOADK: { setobj2s(L, ra, KBx(i)); continue; } case OP_LOADBOOL: { setbvalue(ra, GETARG_B(i)); if (GETARG_C(i)) pc++; /* skip next instruction (if C) */ continue; } case OP_LOADNIL: { TValue *rb = RB(i); do { setnilvalue(rb--); } while (rb >= ra); continue; } case OP_GETUPVAL: { int b = GETARG_B(i); setobj2s(L, ra, cl->upvals[b]->v); continue; } case OP_GETGLOBAL: { TValue g; TValue *rb = KBx(i); sethvalue(L, &g, cl->env); lua_assert(ttisstring(rb)); Protect(luaV_gettable(L, &g, rb, ra)); continue; } case OP_GETTABLE: { Protect(luaV_gettable(L, RB(i), RKC(i), ra)); continue; } case OP_SETGLOBAL: { TValue g; sethvalue(L, &g, cl->env); lua_assert(ttisstring(KBx(i))); Protect(luaV_settable(L, &g, KBx(i), ra)); continue; } case OP_SETUPVAL: { UpVal *uv = cl->upvals[GETARG_B(i)]; setobj(L, uv->v, ra); luaC_barrier(L, uv, ra); continue; } case OP_SETTABLE: { Protect(luaV_settable(L, ra, RKB(i), RKC(i))); continue; } case OP_NEWTABLE: { int b = GETARG_B(i); int c = GETARG_C(i); sethvalue(L, ra, luaH_new(L, luaO_fb2int(b), luaO_fb2int(c))); Protect(luaC_checkGC(L)); continue; } case OP_SELF: { StkId rb = RB(i); setobjs2s(L, ra+1, rb); Protect(luaV_gettable(L, rb, RKC(i), ra)); continue; } case OP_ADD: { arith_op(luai_numadd, TM_ADD); continue;//.........这里部分代码省略.........
开发者ID:angryzor,项目名称:luajit-tilepro64,代码行数:101,
示例22: luaV_execute/*** Executes the given Lua function. Parameters are between [base,top).** Returns n such that the the results are between [n,top).*/StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) { const Proto *const tf = cl->f.l; StkId top; /* keep top local, for performance */ const Instruction *pc = tf->code; TString **const kstr = tf->kstr; const lua_Hook linehook = L->linehook; infovalue(base-1)->pc = &pc; luaD_checkstack(L, tf->maxstacksize+EXTRA_STACK); if (tf->is_vararg) /* varargs? */ adjust_varargs(L, base, tf->numparams); else luaD_adjusttop(L, base, tf->numparams); top = L->top; /* main loop of interpreter */ for (;;) { const Instruction i = *pc++; if (linehook) traceexec(L, base, top, linehook); switch (GET_OPCODE(i)) { case OP_END: { L->top = top; return top; } case OP_RETURN: { L->top = top; return base+GETARG_U(i); } case OP_CALL: { int nres = GETARG_B(i); if (nres == MULT_RET) nres = LUA_MULTRET; L->top = top; luaD_call(L, base+GETARG_A(i), nres); top = L->top; break; } case OP_TAILCALL: { L->top = top; luaD_call(L, base+GETARG_A(i), LUA_MULTRET); return base+GETARG_B(i); } case OP_PUSHNIL: { int n = GETARG_U(i); LUA_ASSERT(n>0, "invalid argument"); do { ttype(top++) = LUA_TNIL; } while (--n > 0); break; } case OP_POP: { top -= GETARG_U(i); break; } case OP_PUSHINT: { ttype(top) = LUA_TNUMBER; nvalue(top) = (Number)GETARG_S(i); top++; break; } case OP_PUSHSTRING: { ttype(top) = LUA_TSTRING; tsvalue(top) = kstr[GETARG_U(i)]; top++; break; } case OP_PUSHNUM: { ttype(top) = LUA_TNUMBER; nvalue(top) = tf->knum[GETARG_U(i)]; top++; break; } case OP_PUSHNEGNUM: { ttype(top) = LUA_TNUMBER; nvalue(top) = -tf->knum[GETARG_U(i)]; top++; break; } case OP_PUSHUPVALUE: { *top++ = cl->upvalue[GETARG_U(i)]; break; } case OP_GETLOCAL: { *top++ = *(base+GETARG_U(i)); break; } case OP_GETGLOBAL: { L->top = top; *top = *luaV_getglobal(L, kstr[GETARG_U(i)]); top++; break; } case OP_GETTABLE: { L->top = top; top--; *(top-1) = *luaV_gettable(L, top-1); break; }//.........这里部分代码省略.........
开发者ID:uvbs,项目名称:wx2Server,代码行数:101,
示例23: PrintCodestatic 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,
示例24: symbexecstatic Instruction symbexec(const Proto* pt, int lastpc, int reg){ int pc; int last; /* stores position of last instruction that changed `reg' */ last = pt->sizecode - 1; /* points to final return (a `neutral' instruction) */ check(precheck(pt)); for (pc = 0; pc < lastpc; pc++) { Instruction i = pt->code[pc]; OpCode op = GET_OPCODE(i); int a = GETARG_A(i); int b = 0; int c = 0; check(op < NUM_OPCODES); checkreg(pt, a); switch (getOpMode(op)) { case iABC: { b = GETARG_B(i); c = GETARG_C(i); check(checkArgMode(pt, b, getBMode(op))); check(checkArgMode(pt, c, getCMode(op))); break; } case iABx: { b = GETARG_Bx(i); if (getBMode(op) == OpArgK) check(b < pt->sizek); break; } case iAsBx: { b = GETARG_sBx(i); if (getBMode(op) == OpArgR) { int dest = pc + 1 + b; check(0 <= dest && dest < pt->sizecode); if (dest > 0) { int j; /* check that it does not jump to a setlist count; this is tricky, because the count from a previous setlist may have the same value of an invalid setlist; so, we must go all the way back to the first of them (if any) */ for (j = 0; j < dest; j++) { Instruction d = pt->code[dest - 1 - j]; if (!(GET_OPCODE(d) == OP_SETLIST && GETARG_C(d) == 0)) break; } /* if 'j' is even, previous value is not a setlist (even if it looks like one) */ check((j & 1) == 0); } } break; } } if (testAMode(op)) { if (a == reg) last = pc; /* change register `a' */ } if (testTMode(op)) { check(pc + 2 < pt->sizecode); /* check skip */ check(GET_OPCODE(pt->code[pc + 1]) == OP_JMP); } switch (op) { case OP_LOADBOOL: { if (c == 1) /* does it jump? */ { check(pc + 2 < pt->sizecode); /* check its jump */ check(GET_OPCODE(pt->code[pc + 1]) != OP_SETLIST || GETARG_C(pt->code[pc + 1]) != 0); } break; } case OP_LOADNIL: { if (a <= reg && reg <= b) last = pc; /* set registers from `a' to `b' */ break; } case OP_GETUPVAL: case OP_SETUPVAL: { check(b < pt->nups); break; } case OP_GETGLOBAL: case OP_SETGLOBAL: { check(ttisstring(&pt->k[b])); break; } case OP_SELF: { checkreg(pt, a + 1);//.........这里部分代码省略.........
开发者ID:migerh,项目名称:DCPUToolchain,代码行数:101,
示例25: PrintCodestatic 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,
示例26: symbexecstatic Instruction symbexec (const Proto *pt, int lastpc, int reg) { int pc; int last; /* stores position of last instruction that changed `reg' */ last = pt->sizecode-1; /* points to final return (a `neutral' instruction) */ check(precheck(pt)); for (pc = 0; pc < lastpc; pc++) { Instruction i = pt->code[pc]; OpCode op = GET_OPCODE(i); int a = GETARG_A(i); int b = 0; int c = 0; check(op < NUM_OPCODES); checkreg(pt, a); switch (getOpMode(op)) { case iABC: { b = GETARG_B(i); c = GETARG_C(i); check(checkArgMode(pt, b, getBMode(op))); check(checkArgMode(pt, c, getCMode(op))); break; } case iABx: { b = GETARG_Bx(i); if (getBMode(op) == OpArgK) check(b < pt->sizek); break; } case iAsBx: { b = GETARG_sBx(i); if (getBMode(op) == OpArgR) { int dest = pc+1+b; check(0 <= dest && dest < pt->sizecode); if (dest > 0) { /* cannot jump to a setlist count */ Instruction d = pt->code[dest-1]; check(!(GET_OPCODE(d) == OP_SETLIST && GETARG_C(d) == 0)); } } break; } } if (testAMode(op)) { if (a == reg) last = pc; /* change register `a' */ } if (testTMode(op)) { check(pc+2 < pt->sizecode); /* check skip */ check(GET_OPCODE(pt->code[pc+1]) == OP_JMP); } switch (op) { case OP_LOADBOOL: { check(c == 0 || pc+2 < pt->sizecode); /* check its jump */ break; } case OP_LOADNIL: { if (a <= reg && reg <= b) last = pc; /* set registers from `a' to `b' */ break; } case OP_GETUPVAL: case OP_SETUPVAL: { check(b < pt->nups); break; } case OP_GETGLOBAL: case OP_SETGLOBAL: { check(ttisstring(&pt->k[b])); break; } case OP_SELF: { checkreg(pt, a+1); if (reg == a+1) last = pc; break; } case OP_CONCAT: { check(b < c); /* at least two operands */ break; } case OP_TFORLOOP: { check(c >= 1); /* at least one result (control variable) */ checkreg(pt, a+2+c); /* space for results */ if (reg >= a+2) last = pc; /* affect all regs above its base */ break; } case OP_FORLOOP: case OP_FORPREP: checkreg(pt, a+3); /* go through */ case OP_JMP: { int dest = pc+1+b; /* not full check and jump is forward and do not skip `lastpc'? */ if (reg != NO_REG && pc < dest && dest <= lastpc) pc += b; /* do the jump */ break; } case OP_CALL: case OP_TAILCALL: { if (b != 0) { checkreg(pt, a+b-1); } c--; /* c = num. returns */ if (c == LUA_MULTRET) {//.........这里部分代码省略.........
开发者ID:robinelfrink,项目名称:squeezeplay,代码行数:101,
示例27: PrintCodestatic 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,
示例28: luaU_guess_localsint luaU_guess_locals(Proto* f, int main) { intArray blocklist; LocVarArray locallist; int regassign[MAXARG_A+1]; int regusage[MAXARG_A+1]; int regblock[MAXARG_A+1]; int lastfree; int i,i2,x,pc; int func_endpc = FUNC_BLOCK_END(f); if (f->lineinfo != NULL) { return 0; } if (f->sizelocvars > 0) { return 0; } intArray_Init(&blocklist, MAXARG_A+1); addi(blocklist, func_endpc); LocVarArray_Init(&locallist, MAXARG_A+1); lastfree = 0; for (i=0; i<f->maxstacksize; i++) { regassign[i] = 0; regusage[i] = 0; regblock[i] = 0; } // parameters for (i = 0; i < f->numparams; i++) { add(locallist,0,func_endpc); regassign[lastfree] = 0; regusage[lastfree] = 1; regblock[lastfree] = func_endpc; lastfree++; } // vararg if (NEED_ARG(f)) { add(locallist,0,func_endpc); lastfree++; regassign[lastfree] = 0; regusage[lastfree] = 1; regblock[lastfree] = func_endpc; lastfree++; }#if LUA_VERSION_NUM == 501 // nil optimizations { Instruction i = f->code[0]; OpCode o = GET_OPCODE(i); int a = GETARG_A(i); int b = GETARG_B(i); int c = GETARG_C(i); int ixx,num_nil = -1; switch (o) { // read Ra only case OP_SETGLOBAL: case OP_SETUPVAL: case OP_TESTSET: num_nil = a; break; // read Rb only case OP_MOVE: case OP_UNM: case OP_NOT: case OP_LEN: if (!ISK(b)) { num_nil = b; } break; // read Rb and Rc case OP_GETTABLE: case OP_SETTABLE: case OP_SELF: case OP_ADD: case OP_SUB: case OP_MUL: case OP_DIV: case OP_MOD: case OP_POW: case OP_EQ: case OP_LT: case OP_LE: if (!ISK(b)) { num_nil = b; } if (!ISK(c)) { num_nil = MAX(num_nil, c); } break; case OP_RETURN: // read Ra to a+b-2 // only return 1 value // move before return multiple values num_nil = MAX(num_nil, a+b-2); break;//.........这里部分代码省略.........
开发者ID:funny-sultan,项目名称:luadec,代码行数:101,
示例29: luaG_symbexecstatic Instruction luaG_symbexec (const Proto *pt, int lastpc, int reg) { int pc; int last; /* stores position of last instruction that changed `reg' */ last = pt->sizecode-1; /* points to final return (a `neutral' instruction) */ check(precheck(pt)); for (pc = 0; pc < lastpc; pc++) { const Instruction i = pt->code[pc]; OpCode op = GET_OPCODE(i); int a = GETARG_A(i); int b = 0; int c = 0; checkreg(pt, a); switch (getOpMode(op)) { case iABC: { b = GETARG_B(i); c = GETARG_C(i); if (testOpMode(op, OpModeBreg)) { checkreg(pt, b); } else if (testOpMode(op, OpModeBrk)) check(checkRK(pt, b)); if (testOpMode(op, OpModeCrk)) check(checkRK(pt, c)); break; } case iABx: { b = GETARG_Bx(i); if (testOpMode(op, OpModeK)) check(b < pt->sizek); break; } case iAsBx: { b = GETARG_sBx(i); break; } } if (testOpMode(op, OpModesetA)) { if (a == reg) last = pc; /* change register `a' */ } if (testOpMode(op, OpModeT)) { check(pc+2 < pt->sizecode); /* check skip */ check(GET_OPCODE(pt->code[pc+1]) == OP_JMP); } switch (op) { case OP_LOADBOOL: { check(c == 0 || pc+2 < pt->sizecode); /* check its jump */ break; } case OP_LOADNIL: { if (a <= reg && reg <= b) last = pc; /* set registers from `a' to `b' */ break; } case OP_GETUPVAL: case OP_SETUPVAL: { check(b < pt->nups); break; } case OP_GETGLOBAL: case OP_SETGLOBAL: { check(ttisstring(&pt->k[b])); break; } case OP_SELF: { checkreg(pt, a+1); if (reg == a+1) last = pc; break; } case OP_CONCAT: { /* `c' is a register, and at least two operands */ check(c < MAXSTACK && b < c); break; } case OP_TFORLOOP: checkreg(pt, a+c+5); if (reg >= a) last = pc; /* affect all registers above base */ /* go through */ case OP_FORLOOP: checkreg(pt, a+2); /* go through */ case OP_JMP: { int dest = pc+1+b; check(0 <= dest && dest < pt->sizecode); /* not full check and jump is forward and do not skip `lastpc'? */ if (reg != NO_REG && pc < dest && dest <= lastpc) pc += b; /* do the jump */ break; } case OP_CALL: case OP_TAILCALL: { if (b != 0) { checkreg(pt, a+b-1); } c--; /* c = num. returns */ if (c == LUA_MULTRET) { check(checkopenop(pt, pc)); } else if (c != 0) checkreg(pt, a+c-1); if (reg >= a) last = pc; /* affect all registers above base */ break;//.........这里部分代码省略.........
开发者ID:gitrider,项目名称:wxsj2,代码行数:101,
注:本文中的GET_OPCODE函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ GET_OVERLAY_PRIV函数代码示例 C++ GET_NODE函数代码示例 |