本文整理汇总了C++中GETARG_Bx函数的典型用法代码示例。如果您正苦于以下问题:C++ GETARG_Bx函数的具体用法?C++ GETARG_Bx怎么用?C++ GETARG_Bx使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GETARG_Bx函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: riPrintCode
static void riPrintCode(const Proto* p)
{
const Instruction* code=p->code;
int pc,n=p->sizecode;
for (pc=0; pc<n; pc++)
{
Instruction i = code[pc];
OpCode o = GET_OPCODE(i);
const char *name = luaP_opnames[o];
int line = luaG_getfuncline(p, pc);
printf("(%4d) %4d - ", line, pc);
switch (getOpMode(o)) {
case iABC:
printf("%-12s%4d %4d %4d%s", name,
GETARG_A(i), GETARG_B(i), GETARG_C(i),
GETARG_k(i) ? " (k)" : "");
break;
case iABx:
printf("%-12s%4d %4d", name, GETARG_A(i), GETARG_Bx(i));
break;
case iAsBx:
printf("%-12s%4d %4d", name, GETARG_A(i), GETARG_sBx(i));
break;
case iAx:
printf("%-12s%4d", name, GETARG_Ax(i));
break;
case isJ:
printf("%-12s%4d (%1d)", name, GETARG_sJ(i), !!GETARG_m(i));
break;
}
printf("\n");
}
}
开发者ID:luciouskami,项目名称:YDWE,代码行数:33,代码来源:luac.c
示例2: GETARG_Ax
void Compiler::CompileLoadk(bool extraarg) {
auto& ra = stack_.GetR(GETARG_A(cs_.instr_));
int karg = extraarg ? GETARG_Ax(cs_.proto_->code[cs_.curr_ + 1])
: GETARG_Bx(cs_.instr_);
auto& k = stack_.GetK(karg);
ra.Assign(k);
}
开发者ID:gligneul,项目名称:Lua-Low-Level,代码行数:7,代码来源:lllcompiler.cpp
示例3: raviP_instruction_to_str
const char* raviP_instruction_to_str(char *buf, size_t n, Instruction i) {
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);
snprintf(buf, n, "%s ", luaP_opnames[o]);
switch (getOpMode(o)) {
case iABC:
snprintf(buf+strlen(buf), n-strlen(buf), "A=%d", a);
if (getBMode(o) != OpArgN)
snprintf(buf + strlen(buf), n - strlen(buf), " B=%d", (getBMode(o) == OpArgK && ISK(b)) ? (MYK(INDEXK(b))) : b);
if (getCMode(o) != OpArgN)
snprintf(buf + strlen(buf), n - strlen(buf), " C=%d", (getCMode(o) == OpArgK && ISK(c)) ? (MYK(INDEXK(c))) : c);
break;
case iABx:
snprintf(buf + strlen(buf), n - strlen(buf), "A=%d", a);
if (getBMode(o) == OpArgK)
snprintf(buf + strlen(buf), n - strlen(buf), " Bx=%d", MYK(bx));
if (getBMode(o) == OpArgU)
snprintf(buf + strlen(buf), n - strlen(buf), " Bx=%d", bx);
break;
case iAsBx:
snprintf(buf + strlen(buf), n - strlen(buf), "As=%d Bx=%d", a, sbx);
break;
case iAx:
snprintf(buf + strlen(buf), n - strlen(buf), "Ax=%d", MYK(ax));
break;
}
return buf;
}
开发者ID:galek,项目名称:ravi,代码行数:33,代码来源:lopcodes.c
示例4: findsetreg
const char *getobjname2 (LuaProto *p, int lastpc, int reg, std::string& name) {
int pc;
const char* name2 = p->getLocalName(reg + 1, lastpc);
if(name2) {
name = name2;
}
else {
name.clear();
}
if (!name.empty()) /* is a local? */
return "local";
/* else try symbolic execution */
pc = findsetreg(p, lastpc, reg);
if (pc != -1) { /* could find instruction? */
Instruction i = p->instructions_[pc];
OpCode op = GET_OPCODE(i);
switch (op) {
case OP_MOVE: {
int b = GETARG_B(i); /* move from 'b' to 'a' */
if (b < GETARG_A(i))
return getobjname2(p, pc, b, name); /* get name for 'b' */
break;
}
case OP_GETTABUP:
case OP_GETTABLE: {
int k = GETARG_C(i); /* key index */
int t = GETARG_B(i); /* table index */
const char *vn = (op == OP_GETTABLE) /* name of indexed variable */
? p->getLocalName(t + 1, pc)
: p->getUpvalName(t);
kname2(p, pc, k, name);
return (vn && strcmp(vn, LUA_ENV) == 0) ? "global" : "field";
}
case OP_GETUPVAL: {
name = p->getUpvalName(GETARG_B(i));
return "upvalue";
}
case OP_LOADK:
case OP_LOADKX: {
int b = (op == OP_LOADK) ? GETARG_Bx(i)
: GETARG_Ax(p->instructions_[pc + 1]);
if (p->constants[b].isString()) {
name = p->constants[b].getString()->c_str();
return "constant";
}
break;
}
case OP_SELF: {
int k = GETARG_C(i); /* key index */
kname2(p, pc, k, name);
return "method";
}
default: break; /* go through to return NULL */
}
}
return NULL; /* could not find reasonable name */
}
开发者ID:aappleby,项目名称:Lumina,代码行数:59,代码来源:ldebug.cpp
示例5: 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
示例6: 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
示例7: getobjname
static const char* getobjname(lua_State* L, CallInfo* ci, int stackpos,
const char** name)
{
if (isLua(ci)) /* a Lua function? */
{
Proto* p = ci_func(ci)->l.p;
int pc = currentpc(L, ci);
Instruction i;
*name = luaF_getlocalname(p, stackpos + 1, pc);
if (*name) /* is a local? */
return "local";
i = 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(L, 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_GETUPVAL:
{
int u = GETARG_B(i); /* upvalue index */
*name = p->upvalues ? getstr(p->upvalues[u]) : "?";
return "upvalue";
}
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:migerh,项目名称:DCPUToolchain,代码行数:54,代码来源:ldebug.c
示例8: findsetreg
static const char *getobjname (Proto *p, int lastpc, int reg,
const char **name) {
int pc;
*name = luaF_getlocalname(p, reg + 1, lastpc);
if (*name) /* is a local? */
return "local";
/* else try symbolic execution */
pc = findsetreg(p, lastpc, reg);
if (pc != -1) { /* could find instruction? */
Instruction i = p->code[pc];
OpCode op = GET_OPCODE(i);
switch (op) {
case OP_MOVE: {
int b = GETARG_B(i); /* move from 'b' to 'a' */
if (b < GETARG_A(i))
return getobjname(p, pc, b, name); /* get name for 'b' */
break;
}
case OP_GETTABUP:
case OP_GETTABLE: {
int k = GETARG_C(i); /* key index */
int t = GETARG_B(i); /* table index */
const char *vn = (op == OP_GETTABLE) /* name of indexed variable */
? luaF_getlocalname(p, t + 1, pc)
: upvalname(p, t);
kname(p, pc, k, name);
return (vn && strcmp(vn, LUA_ENV) == 0) ? "global" : "field";
}
case OP_GETUPVAL: {
*name = upvalname(p, GETARG_B(i));
return "upvalue";
}
case OP_LOADK:
case OP_LOADKX: {
int b = (op == OP_LOADK) ? GETARG_Bx(i)
: GETARG_Ax(p->code[pc + 1]);
if (ttisstring(&p->k[b])) {
*name = svalue(&p->k[b]);
return "constant";
}
break;
}
case OP_SELF: {
int k = GETARG_C(i); /* key index */
kname(p, pc, k, name);
return "method";
}
default:
break; /* go through to return NULL */
}
}
return NULL; /* could not find reasonable name */
}
开发者ID:Chronodt,项目名称:emscripten,代码行数:53,代码来源:ldebug.c
示例9: GETARG_A
void Compiler::CompileClosure() {
int a = GETARG_A(cs_.instr_);
auto& ra = stack_.GetR(a);
auto args = {
cs_.values_.state,
cs_.values_.closure,
cs_.GetBase(),
ra.GetTValue(),
cs_.MakeInt(GETARG_Bx(cs_.instr_))
};
cs_.CreateCall("lll_closure", args);
auto& ra1 = stack_.GetR(a + 1);
CompileCheckcg(ra1.GetTValue());
}
开发者ID:gligneul,项目名称:Lua-Low-Level,代码行数:14,代码来源:lllcompiler.cpp
示例10: luaV_execute
void luaV_execute (lua_State *L) {
CallInfo *ci = L->ci;
LClosure *cl;
TValue *k;
StkId base;
newframe: /* reentry point when frame changes (call/return) */
lua_assert(ci == L->ci);
cl = clLvalue(ci->func);
k = cl->p->k;
base = ci->u.l.base;
//printf( "s:%p\n", ci->u.l.savedpc );
/* main loop of interpreter */
for (;;) {
Instruction i = *(ci->u.l.savedpc++);
StkId ra;
if ((L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) &&
(--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) {
Protect(traceexec(L));
}
/* warning!! several calls may realloc the stack and invalidate `ra' */
ra = RA(i);
lua_assert(base == ci->u.l.base);
lua_assert(base <= L->top && L->top < L->stack + L->stacksize);
// 命令出力
//printInst( ci->u.l.savedpc - 1 );
vmdispatch (GET_OPCODE(i)) {
vmcase(OP_MOVE,
setobjs2s(L, ra, RB(i));
)
vmcase(OP_LOADK,
TValue *rb = k + GETARG_Bx(i);
setobj2s(L, ra, rb);
)
vmcase(OP_LOADKX,
TValue *rb;
lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_EXTRAARG);
rb = k + GETARG_Ax(*ci->u.l.savedpc++);
setobj2s(L, ra, rb);
)
开发者ID:lriki,项目名称:Volkoff,代码行数:45,代码来源:lvm.c
示例11: 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
示例12: 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,代码来源:print.c
示例13: luaU_guess_locals
//.........这里部分代码省略.........
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;
}
for (ixx = lastfree; ixx <= num_nil; ixx++) {
if (ixx!=num_nil) {
add(locallist,0,last(blocklist));
lastfree++;
}
regassign[lastfree] = 0;
regusage[lastfree] = 1;
regblock[lastfree] = last(blocklist);
lastfree++;
}
}
#endif
// start code checking
for (pc = 0; pc < f->sizecode; pc++) {
Instruction instr = f->code[pc];
OpCode o = GET_OPCODE(instr);
int a = GETARG_A(instr);
int b = GETARG_B(instr);
int c = GETARG_C(instr);
int bc = GETARG_Bx(instr);
int sbc = GETARG_sBx(instr);
int dest = 0;
int setreg = -1;
int setregto = -1;
int setreg2 = -1;
int loadreg = -1;
int loadreg2 = -1;
int loadreg3 = -1;
int loadregto = -1;
int intlocfrom = -1;
int intlocto = -1;
if ((o==OP_JMP) || (o==OP_FORPREP)) {
dest = pc + sbc + 2;
} else if ((pc+1!=f->sizecode) && (GET_OPCODE(f->code[pc+1])==OP_JMP)) {
dest = pc + 1 + GETARG_sBx(f->code[pc+1]) + 2;
}
// check which registers were read or written to.
switch (o) {
case OP_MOVE:
setreg = a;
if (b<=a) {
intlocfrom = b;
intlocto = b;
}
loadreg = b;
break;
case OP_UNM:
case OP_NOT:
case OP_LEN:
setreg = a;
loadreg = b;
开发者ID:funny-sultan,项目名称:luadec,代码行数:67,代码来源:guess.c
示例14: luaG_symbexec
static 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,代码来源:ldebug.c
示例15: luaV_execute
//.........这里部分代码省略.........
nresults = GETARG_C(*(ci->u.l.savedpc - 1)) - 1;
luaD_poscall(L, nresults, ra);
if (nresults >= 0) L->top = L->ci->top;
goto retentry;
}
}
case OP_FORLOOP: {
lua_Number step, idx, limit;
const TObject *plimit = ra+1;
const TObject *pstep = ra+2;
if (!ttisnumber(ra))
luaG_runerror(L, "`for' initial value must be a number");
if (!tonumber(plimit, ra+1))
luaG_runerror(L, "`for' limit must be a number");
if (!tonumber(pstep, ra+2))
luaG_runerror(L, "`for' step must be a number");
step = nvalue(pstep);
idx = nvalue(ra) + step; /* increment index */
limit = nvalue(plimit);
if (step > 0 ? idx <= limit : idx >= limit) {
dojump(pc, GETARG_sBx(i)); /* jump back */
chgnvalue(ra, idx); /* update index */
}
break;
}
case OP_TFORLOOP: {
int nvar = GETARG_C(i) + 1;
StkId cb = ra + nvar + 2; /* call base */
setobjs2s(cb, ra);
setobjs2s(cb+1, ra+1);
setobjs2s(cb+2, ra+2);
L->top = cb+3; /* func. + 2 args (state and index) */
luaD_call(L, cb, nvar);
L->top = L->ci->top;
ra = XRA(i) + 2; /* final position of first result */
cb = ra + nvar;
do { /* move results to proper positions */
nvar--;
setobjs2s(ra+nvar, cb+nvar);
} while (nvar > 0);
if (ttisnil(ra)) /* break loop? */
pc++; /* skip jump (break loop) */
else
dojump(pc, GETARG_sBx(*pc) + 1); /* jump back */
break;
}
case OP_TFORPREP: { /* for compatibility only */
if (ttistable(ra)) {
setobjs2s(ra+1, ra);
setobj2s(ra, luaH_getstr(hvalue(gt(L)), luaS_new(L, "next")));
}
dojump(pc, GETARG_sBx(i));
break;
}
case OP_SETLIST:
case OP_SETLISTO: {
int bc;
int n;
Table *h;
runtime_check(L, ttistable(ra));
h = hvalue(ra);
bc = GETARG_Bx(i);
if (GET_OPCODE(i) == OP_SETLIST)
n = (bc&(LFIELDS_PER_FLUSH-1)) + 1;
else {
n = L->top - ra - 1;
L->top = L->ci->top;
}
bc &= ~(LFIELDS_PER_FLUSH-1); /* bc = bc - bc%FPF */
for (; n > 0; n--)
setobj2t(luaH_setnum(L, h, bc+n), ra+n); /* write barrier */
break;
}
case OP_CLOSE: {
luaF_close(L, ra);
break;
}
case OP_CLOSURE: {
Proto *p;
Closure *ncl;
int nup, j;
p = cl->p->p[GETARG_Bx(i)];
nup = p->nups;
ncl = luaF_newLclosure(L, nup, &cl->g);
ncl->l.p = p;
for (j=0; j<nup; j++, pc++) {
if (GET_OPCODE(*pc) == OP_GETUPVAL)
ncl->l.upvals[j] = cl->upvals[GETARG_B(*pc)];
else {
lua_assert(GET_OPCODE(*pc) == OP_MOVE);
ncl->l.upvals[j] = luaF_findupval(L, base + GETARG_B(*pc));
}
}
setclvalue(ra, ncl);
luaC_checkGC(L);
break;
}
}
}
}
开发者ID:TheWaWaR,项目名称:my-lua5.0,代码行数:101,代码来源:lvm.c
示例16: patch_irep
static void
patch_irep(mrb_state *mrb, mrb_irep *irep, int bnest)
{
size_t i;
mrb_code c;
int argc = 0;
for (i = 0; i < irep->ilen; i++) {
c = irep->iseq[i];
switch(GET_OPCODE(c)){
case OP_ENTER:
{
mrb_aspec ax = GETARG_Ax(c);
/* extra 1 means a slot for block */
argc = MRB_ASPEC_REQ(ax)+MRB_ASPEC_OPT(ax)+MRB_ASPEC_REST(ax)+MRB_ASPEC_POST(ax)+1;
}
break;
case OP_EPUSH:
patch_irep(mrb, irep->reps[GETARG_Bx(c)], bnest + 1);
break;
case OP_LAMBDA:
{
int arg_c = GETARG_c(c);
if (arg_c & OP_L_CAPTURE) {
patch_irep(mrb, irep->reps[GETARG_b(c)], bnest + 1);
}
}
break;
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 (potential_upvar_p(irep->lv, GETARG_B(c), argc, 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 (potential_upvar_p(irep->lv, GETARG_A(c), argc, 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:pbosetti,项目名称:mruby,代码行数:65,代码来源:eval.c
示例17: vm_op_hint_locals
/*
* This function is used to update the local variable type hints.
*
*/
void vm_op_hint_locals(char *locals, int stacksize, TValue *k, const Instruction i) {
int ra,rb,rc;
char ra_type = LUA_TNONE;
#define reset_local() memset(locals, LUA_TNONE, stacksize * sizeof(char))
#define RK_TYPE(rk) (ISK(rk) ? ttype(k+INDEXK(rk)) : locals[rk])
// make sure ra is a valid local register.
switch (GET_OPCODE(i)) {
case OP_MOVE:
rb = GETARG_B(i);
ra_type = locals[rb];
break;
case OP_LOADK:
rb = GETARG_Bx(i);
ra_type = ttype(k + rb);
break;
case OP_LOADBOOL:
if (GETARG_C(i)) {
reset_local(); // jmp, reset types.
} else {
ra_type = LUA_TBOOLEAN;
}
break;
case OP_LOADNIL:
ra = GETARG_A(i);
rb = GETARG_B(i);
do {
locals[rb--] = LUA_TNIL;
} while (rb >= ra);
return;
case OP_GETUPVAL:
case OP_GETGLOBAL:
case OP_GETTABLE:
// reset 'ra' type don't know type at compile-time.
break;
case OP_SETUPVAL:
case OP_SETGLOBAL:
case OP_SETTABLE:
// no changes to locals.
return;
case OP_NEWTABLE:
ra_type = LUA_TTABLE;
break;
case OP_SELF:
// 'ra + 1' will be a table.
ra = GETARG_A(i);
locals[ra + 1] = LUA_TTABLE;
// reset 'ra' type don't know type at compile-time.
break;
case OP_ADD:
case OP_SUB:
case OP_MUL:
case OP_DIV:
case OP_MOD:
case OP_POW:
// if 'b' & 'c' are numbers, then 'ra' will be a number
rb = GETARG_B(i);
rc = GETARG_C(i);
if(RK_TYPE(rb) == LUA_TNUMBER && RK_TYPE(rc) == LUA_TNUMBER) {
ra_type = LUA_TNUMBER;
}
break;
case OP_UNM:
// if 'b' is a number, then 'ra' will be a number
rb = GETARG_B(i);
if(RK_TYPE(rb) == LUA_TNUMBER) {
ra_type = LUA_TNUMBER;
}
break;
case OP_NOT:
ra_type = LUA_TBOOLEAN;
break;
case OP_LEN:
rb = GETARG_B(i);
switch (locals[rb]) {
case LUA_TTABLE:
case LUA_TSTRING:
ra_type = LUA_TNUMBER;
break;
default:
// 'ra' type unknown.
break;
}
break;
case OP_CONCAT:
rb = GETARG_B(i);
rc = GETARG_C(i);
// if all values 'rb' -> 'rc' are strings/numbers then 'ra' will be a string.
ra_type = LUA_TSTRING;
while(rb <= rc) {
if(locals[rb] != LUA_TNUMBER && locals[rb] != LUA_TSTRING) {
// we don't know what type 'ra' will be.
ra_type = LUA_TNONE;
break;
}
rb++;
//.........这里部分代码省略.........
开发者ID:GranPC,项目名称:llvm-lua,代码行数:101,代码来源:lua_vm_ops_static.c
示例18: BijouBlock_dump2
void BijouBlock_dump2(VM, BijouBlock* b, int level)
{
char * str;
size_t x;
INDENT;
printf("; block at: %p, %s (level %d)\n", (void *)b, b->funcname != NULL ?
b->funcname : "", level);
INDENT;
printf("; %zu registers\n", b->regc);
INDENT;
printf("; constants (%zu)\n", kv_size(b->k));
for (x = 0; x < kv_size(b->k); ++x) {
str = TValue_to_string(kv_A(b->k, x));
int s = ttisstring(&kv_A(b->k, x));
INDENT;
printf("\t%zu: (%s) %s%s%s\n", x, TValue_type_to_string(kv_A(b->k, x)), s ? "\"" : "",
str, s ? "\"" : "");
if (ttisnumber(&kv_A(b->k, x))) B_FREE(str);
}
INDENT;
printf("; locals (%zu)\n", kv_size(b->locals));
for (x = 0; x < kv_size(b->locals); ++x) {
str = TValue_to_string(kv_A(b->locals, x));
INDENT;
printf("\t%zu: (%s) %s\n", x, TValue_type_to_string(kv_A(b->locals, x)), str);
if (ttisnumber(&kv_A(b->locals, x))) B_FREE(str);
}
INDENT;
printf("; upvals (%zu)\n", kv_size(b->upvals));
for (x = 0; x < kv_size(b->upvals); ++x) {
str = TValue_to_string(kv_A(b->upvals, x));
INDENT;
printf("\t%zu: (%s) %s\n", x, TValue_type_to_string(kv_A(b->upvals, x)), str);
if (ttisnumber(&kv_A(b->upvals, x))) B_FREE(str);
}
INDENT;
printf("; code section (%zu instructions)\n", kv_size(b->code));
for (x = 0; x < kv_size(b->code); ++x) {
bInst i = kv_A(b->code, x);
INDENT;
print_op(i);
printf("\t");
switch (GET_OPCODE(i)) {
case OP_MOVE:
printf("; R[%d] = R[%d]", GETARG_A(i), GETARG_B(i));
break;
case OP_LOADK:
printf("; R[%d] = K[%d]", GETARG_A(i), GETARG_Bx(i));
break;
case OP_LOADBOOL:
printf("; R[%d] = %s", GETARG_A(i), GETARG_B(i) == 0 ? "false" : "true" );
break;
case OP_LOADNULL:
printf("; R[%d] = null", GETARG_A(i));
break;
case OP_GETGLOBAL:
printf("; R[%d] = globals[K[%d]]", GETARG_A(i), GETARG_Bx(i));
break;
case OP_SETGLOBAL:
printf("; globals[K[%d]] = R[%d]", GETARG_Bx(i), GETARG_A(i));
break;
case OP_GETLOCAL:
printf("; R[%d] = locals[K[%d]]", GETARG_A(i), GETARG_Bx(i));
break;
case OP_SETLOCAL:
printf("; locals[K[%d]] = R[%d]", GETARG_Bx(i), GETARG_A(i));
break;
case OP_ADD:
printf("; R[%d] = RK[%d] + RK[%d]", GETARG_A(i), GETARG_B(i),
GETARG_C(i));
break;
case OP_SUB:
printf("; R[%d] = RK[%d] - RK[%d]", GETARG_A(i), GETARG_B(i),
GETARG_C(i));
break;
case OP_MUL:
printf("; R[%d] = RK[%d] * RK[%d]", GETARG_A(i), GETARG_B(i),
GETARG_C(i));
break;
case OP_DIV:
printf("; R[%d] = RK[%d] / RK[%d]", GETARG_A(i), GETARG_B(i),
GETARG_C(i));
break;
case OP_POW:
printf("; R[%d] = RK[%d] ** RK[%d]", GETARG_A(i), GETARG_B(i),
GETARG_C(i));
break;
case OP_REM:
printf("; R[%d] = RK[%d] %% RK[%d]", GETARG_A(i), GETARG_B(i),
GETARG_C(i));
break;
case OP_UNM:
printf("; R[%d] = -RK[%d]", GETARG_A(i), GETARG_B(i));
break;
//.........这里部分代码省略.........
开发者ID:erik,项目名称:bijou,代码行数:101,代码来源:block.c
示例19: 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 sb=GETARG_sB(i);
int sc=GETARG_sC(i);
int sbx=GETARG_sBx(i);
int isk=GETARG_k(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 (o)
{
case OP_MOVE:
printf("%d %d",a,b);
break;
case OP_LOADI:
printf("%d %d",a,sbx);
break;
case OP_LOADF:
printf("%d %d",a,sbx);
break;
case OP_LOADK:
printf("%d %d",a,bx);
printf("\t; "); PrintConstant(f,bx);
break;
case OP_LOADKX:
printf("%d",a);
break;
case OP_LOADBOOL:
printf("%d %d %d",a,b,c);
if (c) printf("\t; to %d",pc+2);
break;
case OP_LOADNIL:
printf("%d %d",a,b);
printf("\t; %d out",b+1);
break;
case OP_GETUPVAL:
printf("%d %d",a,b);
printf("\t; %s",UPVALNAME(b));
break;
case OP_SETUPVAL:
printf("%d %d",a,b);
printf("\t; %s",UPVALNAME(b));
break;
case OP_GETTABUP:
printf("%d %d %d",a,b,c);
printf("\t; %s",UPVALNAME(b));
printf(" "); PrintConstant(f,c);
break;
case OP_GETTABLE:
printf("%d %d %d",a,b,c);
break;
case OP_GETI:
printf("%d %d %d",a,b,c);
break;
case OP_GETFIELD:
printf("%d %d %d",a,b,c);
printf("\t; "); PrintConstant(f,c);
break;
case OP_SETTABUP:
printf("%d %d %d%s",a,b,c, isk ? "k" : "");
printf("\t; %s",UPVALNAME(a));
printf(" "); PrintConstant(f,b);
if (isk) { printf(" "); PrintConstant(f,c); }
break;
case OP_SETTABLE:
printf("%d %d %d%s",a,b,c, isk ? "k" : "");
if (isk) { printf("\t; "); PrintConstant(f,c); }
break;
case OP_SETI:
printf("%d %d %d%s",a,b,c, isk ? "k" : "");
if (isk) { printf("\t; "); PrintConstant(f,c); }
break;
case OP_SETFIELD:
printf("%d %d %d%s",a,b,c, isk ? "k" : "");
printf("\t; "); PrintConstant(f,b);
if (isk) { printf(" "); PrintConstant(f,c); }
break;
case OP_NEWTABLE:
printf("%d %d %d",a,b,c);
break;
case OP_SELF:
printf("%d %d %d%s",a,b,c, isk ? "k" : "");
if (isk) { printf("\t; "); PrintConstant(f,c); }
break;
case OP_ADDI:
printf("%d %d %d",a,b,sc);
break;
case OP_SUBI:
//.........这里部分代码省略.........
开发者ID:luciouskami,项目名称:YDWE,代码行数:101,代码来源:luac.c
示例20: symbexec
static 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
|
请发表评论