本文整理汇总了C++中GETARG_Ax函数的典型用法代码示例。如果您正苦于以下问题:C++ GETARG_Ax函数的具体用法?C++ GETARG_Ax怎么用?C++ GETARG_Ax使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GETARG_Ax函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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");
}
}
示例3: 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);
}
示例4: mrb_proc_arity
/* 15.2.17.4.2 */
static mrb_value
mrb_proc_arity(mrb_state *mrb, mrb_value self)
{
struct RProc *p = mrb_proc_ptr(self);
struct mrb_irep *irep;
mrb_code *iseq;
mrb_aspec aspec;
int ma, op, ra, pa, arity;
if (MRB_PROC_CFUNC_P(p)) {
/* TODO cfunc aspec not implemented yet */
return mrb_fixnum_value(-1);
}
irep = p->body.irep;
if (!irep) {
return mrb_fixnum_value(0);
}
iseq = irep->iseq;
/* arity is depend on OP_ENTER */
if (GET_OPCODE(*iseq) != OP_ENTER) {
return mrb_fixnum_value(0);
}
aspec = GETARG_Ax(*iseq);
ma = MRB_ASPEC_REQ(aspec);
op = MRB_ASPEC_OPT(aspec);
ra = MRB_ASPEC_REST(aspec);
pa = MRB_ASPEC_POST(aspec);
arity = ra || (MRB_PROC_STRICT_P(p) && op) ? -(ma + pa + 1) : ma + pa;
return mrb_fixnum_value(arity);
}
示例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;
}
示例6: mrb_proc_parameters
static mrb_value
mrb_proc_parameters(mrb_state *mrb, mrb_value self)
{
struct parameters_type {
int size;
const char *name;
} *p, parameters_list [] = {
{0, "req"},
{0, "opt"},
{0, "rest"},
{0, "req"},
{0, "block"},
{0, NULL}
};
const struct RProc *proc = mrb_proc_ptr(self);
const struct mrb_irep *irep = proc->body.irep;
mrb_aspec aspec;
mrb_value parameters;
int i, j;
if (MRB_PROC_CFUNC_P(proc)) {
// TODO cfunc aspec is not implemented yet
return mrb_ary_new(mrb);
}
if (!irep) {
return mrb_ary_new(mrb);
}
if (!irep->lv) {
return mrb_ary_new(mrb);
}
if (GET_OPCODE(*irep->iseq) != OP_ENTER) {
return mrb_ary_new(mrb);
}
if (!MRB_PROC_STRICT_P(proc)) {
parameters_list[0].name = "opt";
parameters_list[3].name = "opt";
}
aspec = GETARG_Ax(*irep->iseq);
parameters_list[0].size = MRB_ASPEC_REQ(aspec);
parameters_list[1].size = MRB_ASPEC_OPT(aspec);
parameters_list[2].size = MRB_ASPEC_REST(aspec);
parameters_list[3].size = MRB_ASPEC_POST(aspec);
parameters_list[4].size = MRB_ASPEC_BLOCK(aspec);
parameters = mrb_ary_new_capa(mrb, irep->nlocals-1);
for (i = 0, p = parameters_list; p->name; p++) {
mrb_value sname = mrb_symbol_value(mrb_intern_cstr(mrb, p->name));
for (j = 0; j < p->size; i++, j++) {
mrb_assert(i < (irep->nlocals-1));
mrb_ary_push(mrb, parameters, mrb_assoc_new(mrb,
sname,
mrb_symbol_value(irep->lv[i].name)
));
}
}
return parameters;
}
示例7: 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 */
}
示例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 */
}
示例9: irep_argc
static int
irep_argc(mrb_irep *irep)
{
mrb_code c;
c = irep->iseq[0];
if (GET_OPCODE(c) == OP_ENTER) {
mrb_aspec ax = GETARG_Ax(c);
/* extra 1 means a slot for block */
return MRB_ASPEC_REQ(ax)+MRB_ASPEC_OPT(ax)+MRB_ASPEC_REST(ax)+MRB_ASPEC_POST(ax)+1;
}
return 0;
}
示例10: mrb_proc_arity
/* 15.2.17.4.2 */
static mrb_value
mrb_proc_arity(mrb_state *mrb, mrb_value self)
{
struct RProc *p = mrb_proc_ptr(self);
mrb_code *iseq = mrb_proc_iseq(mrb, p);
mrb_aspec aspec = GETARG_Ax(*iseq);
int ma, ra, pa, arity;
ma = MRB_ASPEC_REQ(aspec);
ra = MRB_ASPEC_REST(aspec);
pa = MRB_ASPEC_POST(aspec);
arity = ra ? -(ma + pa + 1) : ma + pa;
return mrb_fixnum_value(arity);
}
示例11: GETARG_A
void Compiler::CompileSetlist() {
int a = GETARG_A(cs_.instr_);
int b = GETARG_B(cs_.instr_);
int c = GETARG_C(cs_.instr_);
if (c == 0)
c = GETARG_Ax(cs_.proto_->code[cs_.curr_ + 1]);
auto n = (b != 0 ? cs_.MakeInt(b) : cs_.TopDiff(a + 1));
auto fields = cs_.MakeInt((c - 1) * LFIELDS_PER_FLUSH);
auto& ra = stack_.GetR(a);
auto args = {cs_.values_.state, ra.GetTValue(), fields, n};
cs_.CreateCall("lll_setlist", args);
cs_.ReloadTop();
}
示例12: 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);
)
示例13: 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;
}
}
}
示例14: ktap_execute
static void ktap_execute(ktap_state *ks)
{
int exec_count = 0;
ktap_callinfo *ci;
ktap_lclosure *cl;
ktap_value *k;
unsigned int instr, opcode;
StkId base; /* stack pointer */
StkId ra; /* register pointer */
int res, nresults; /* temp varible */
ci = ks->ci;
newframe:
cl = CLVALUE(ci->func);
k = cl->p->k;
base = ci->u.l.base;
mainloop:
/* main loop of interpreter */
/* dead loop detaction */
if (exec_count++ == 10000) {
if (G(ks)->mainthread != ks) {
kp_error(ks, "non-mainthread executing too much, "
"please try to enlarge execution limit\n");
return;
}
cond_resched();
if (signal_pending(current)) {
flush_signals(current);
return;
}
exec_count = 0;
}
instr = *(ci->u.l.savedpc++);
opcode = GET_OPCODE(instr);
/* ra is target register */
ra = RA(instr);
switch (opcode) {
case OP_MOVE:
setobj(ra, base + GETARG_B(instr));
break;
case OP_LOADK:
setobj(ra, k + GETARG_Bx(instr));
break;
case OP_LOADKX:
setobj(ra, k + GETARG_Ax(*ci->u.l.savedpc++));
break;
case OP_LOADBOOL:
setbvalue(ra, GETARG_B(instr));
if (GETARG_C(instr))
ci->u.l.savedpc++;
break;
case OP_LOADNIL: {
int b = GETARG_B(instr);
do {
setnilvalue(ra++);
} while (b--);
break;
}
case OP_GETUPVAL: {
int b = GETARG_B(instr);
setobj(ra, cl->upvals[b]->v);
break;
}
case OP_GETTABUP: {
int b = GETARG_B(instr);
gettable(ks, cl->upvals[b]->v, RKC(instr), ra);
base = ci->u.l.base;
break;
}
case OP_GETTABLE:
gettable(ks, RB(instr), RKC(instr), ra);
base = ci->u.l.base;
break;
case OP_SETTABUP: {
int a = GETARG_A(instr);
settable(ks, cl->upvals[a]->v, RKB(instr), RKC(instr));
base = ci->u.l.base;
break;
}
case OP_SETUPVAL: {
ktap_upval *uv = cl->upvals[GETARG_B(instr)];
setobj(uv->v, ra);
break;
}
case OP_SETTABLE:
settable(ks, ra, RKB(instr), RKC(instr));
base = ci->u.l.base;
break;
case OP_NEWTABLE: {
int b = GETARG_B(instr);
int c = GETARG_C(instr);
ktap_table *t = kp_table_new(ks);
sethvalue(ra, t);
//.........这里部分代码省略.........
示例15: 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:
//.........这里部分代码省略.........