您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ GETARG_Bx函数代码示例

51自学网 2021-06-01 20:50:35
  C++
这篇教程C++ GETARG_Bx函数代码示例写得很实用,希望能帮到您。

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

在下文中一共展示了GETARG_Bx函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例16: patch_irep

static voidpatch_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,


示例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,


示例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,


示例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,


示例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 (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,


示例21: mrb_run

mrb_valuemrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self){  /* assert(mrb_proc_cfunc_p(proc)) */  mrb_irep *irep = proc->body.irep;  mrb_code *pc = irep->iseq;  mrb_value *pool = irep->pool;  mrb_sym *syms = irep->syms;  mrb_value *regs;  mrb_code i;  int ai = mrb->arena_idx;  jmp_buf c_jmp;  jmp_buf *prev_jmp;#ifdef DIRECT_THREADED  static void *optable[] = {    &&L_OP_NOP, &&L_OP_MOVE,    &&L_OP_LOADL, &&L_OP_LOADI, &&L_OP_LOADSYM, &&L_OP_LOADNIL,    &&L_OP_LOADSELF, &&L_OP_LOADT, &&L_OP_LOADF,    &&L_OP_GETGLOBAL, &&L_OP_SETGLOBAL, &&L_OP_GETSPECIAL, &&L_OP_SETSPECIAL,    &&L_OP_GETIV, &&L_OP_SETIV, &&L_OP_GETCV, &&L_OP_SETCV,    &&L_OP_GETCONST, &&L_OP_SETCONST, &&L_OP_GETMCNST, &&L_OP_SETMCNST,    &&L_OP_GETUPVAR, &&L_OP_SETUPVAR,    &&L_OP_JMP, &&L_OP_JMPIF, &&L_OP_JMPNOT,    &&L_OP_ONERR, &&L_OP_RESCUE, &&L_OP_POPERR, &&L_OP_RAISE, &&L_OP_EPUSH, &&L_OP_EPOP,    &&L_OP_SEND, &&L_OP_FSEND, &&L_OP_VSEND,    &&L_OP_CALL, &&L_OP_SUPER, &&L_OP_ARGARY, &&L_OP_ENTER,    &&L_OP_KARG, &&L_OP_KDICT, &&L_OP_RETURN, &&L_OP_TAILCALL, &&L_OP_BLKPUSH,    &&L_OP_ADD, &&L_OP_ADDI, &&L_OP_SUB, &&L_OP_SUBI, &&L_OP_MUL, &&L_OP_DIV,    &&L_OP_EQ, &&L_OP_LT, &&L_OP_LE, &&L_OP_GT, &&L_OP_GE,    &&L_OP_ARRAY, &&L_OP_ARYCAT, &&L_OP_ARYPUSH, &&L_OP_AREF, &&L_OP_ASET, &&L_OP_APOST,    &&L_OP_STRING, &&L_OP_STRCAT, &&L_OP_HASH,    &&L_OP_LAMBDA, &&L_OP_RANGE, &&L_OP_OCLASS,    &&L_OP_CLASS, &&L_OP_MODULE, &&L_OP_EXEC,    &&L_OP_METHOD, &&L_OP_SCLASS, &&L_OP_TCLASS,    &&L_OP_DEBUG, &&L_OP_STOP, &&L_OP_ERR,  };#endif  if (setjmp(c_jmp) == 0) {    prev_jmp = mrb->jmp;    mrb->jmp = &c_jmp;  }  else {    goto L_RAISE;  }  if (!mrb->stack) {    stack_init(mrb);  }  mrb->ci->proc = proc;  mrb->ci->nregs = irep->nregs + 2;  regs = mrb->stack;  INIT_DISPACTH {    CASE(OP_NOP) {      /* do nothing */      NEXT;    }    CASE(OP_MOVE) {      /* A B    R(A) := R(B) */#if 0      regs[GETARG_A(i)] = regs[GETARG_B(i)];#elif 1      int a = GETARG_A(i);      int b = GETARG_B(i);      regs[a].tt = regs[b].tt;      regs[a].value = regs[b].value;#else      memcpy(regs+GETARG_A(i), regs+GETARG_B(i), sizeof(mrb_value));#endif      NEXT;    }    CASE(OP_LOADL) {      /* A Bx   R(A) := Pool(Bx) */      regs[GETARG_A(i)] = pool[GETARG_Bx(i)];      NEXT;    }    CASE(OP_LOADI) {      /* A Bx   R(A) := sBx */      SET_INT_VALUE(regs[GETARG_A(i)], GETARG_sBx(i));      NEXT;    }    CASE(OP_LOADSYM) {      /* A B    R(A) := Sym(B) */      SET_SYM_VALUE(regs[GETARG_A(i)], syms[GETARG_Bx(i)]);      NEXT;    }    CASE(OP_LOADNIL) {      /* A B    R(A) := nil */      int a = GETARG_A(i);      SET_NIL_VALUE(regs[a]);      NEXT;//.........这里部分代码省略.........
开发者ID:kstephens,项目名称:mruby,代码行数:101,


示例22: patch_irep

static voidpatch_irep(mrb_state *mrb, mrb_irep *irep, int bnest, mrb_irep *top){  int i;  mrb_code c;  int argc = irep_argc(irep);  for (i = 0; i < irep->ilen; i++) {    c = irep->iseq[i];    switch(GET_OPCODE(c)){    case OP_EPUSH:      patch_irep(mrb, irep->reps[GETARG_Bx(c)], bnest + 1, top);      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, top);        }      }      break;    case OP_SEND:      if (GETARG_C(c) != 0) {        break;      }      else {        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;    case OP_GETUPVAR:      {        int lev = GETARG_C(c)+1;        mrb_irep *tmp = search_irep(top, bnest, lev, irep);        if (potential_upvar_p(tmp->lv, GETARG_B(c), irep_argc(tmp), tmp->nlocals)) {          mrb_code arg = search_variable(mrb, tmp->lv[GETARG_B(c)-1].name, bnest);          if (arg != 0) {            /* must replace */            irep->iseq[i] = MKOPCODE(OP_GETUPVAR) | MKARG_A(GETARG_A(c)) | arg;          }        }      }      break;    case OP_SETUPVAR:      {        int lev = GETARG_C(c)+1;        mrb_irep *tmp = search_irep(top, bnest, lev, irep);        if (potential_upvar_p(tmp->lv, GETARG_B(c), irep_argc(tmp), tmp->nlocals)) {          mrb_code arg = search_variable(mrb, tmp->lv[GETARG_B(c)-1].name, bnest);          if (arg != 0) {            /* must replace */            irep->iseq[i] = MKOPCODE(OP_SETUPVAR) | MKARG_A(GETARG_A(c)) | arg;          }        }      }      break;    case OP_STOP:      if (mrb->c->ci->acc >= 0) {        irep->iseq[i] = MKOP_AB(OP_RETURN, irep->nlocals, OP_R_NORMAL);      }      break;    }  }}
开发者ID:devnexen,项目名称:h2o,代码行数:91,


示例23: mrb_run

mrb_valuemrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self){  /* assert(mrb_proc_cfunc_p(proc)) */  mrb_irep *irep = proc->body.irep;  mrb_code *pc = irep->iseq;  mrb_value *pool = irep->pool;  mrb_sym *syms = irep->syms;  mrb_value *regs = NULL;  mrb_code i;  int ai = mrb->arena_idx;  jmp_buf *prev_jmp = mrb->jmp;  jmp_buf c_jmp;#ifdef DIRECT_THREADED  static void *optable[] = {    &&L_OP_NOP, &&L_OP_MOVE,    &&L_OP_LOADL, &&L_OP_LOADI, &&L_OP_LOADSYM, &&L_OP_LOADNIL,    &&L_OP_LOADSELF, &&L_OP_LOADT, &&L_OP_LOADF,    &&L_OP_GETGLOBAL, &&L_OP_SETGLOBAL, &&L_OP_GETSPECIAL, &&L_OP_SETSPECIAL,    &&L_OP_GETIV, &&L_OP_SETIV, &&L_OP_GETCV, &&L_OP_SETCV,    &&L_OP_GETCONST, &&L_OP_SETCONST, &&L_OP_GETMCNST, &&L_OP_SETMCNST,    &&L_OP_GETUPVAR, &&L_OP_SETUPVAR,    &&L_OP_JMP, &&L_OP_JMPIF, &&L_OP_JMPNOT,    &&L_OP_ONERR, &&L_OP_RESCUE, &&L_OP_POPERR, &&L_OP_RAISE, &&L_OP_EPUSH, &&L_OP_EPOP,    &&L_OP_SEND, &&L_OP_FSEND, &&L_OP_VSEND,    &&L_OP_CALL, &&L_OP_SUPER, &&L_OP_ARGARY, &&L_OP_ENTER,    &&L_OP_KARG, &&L_OP_KDICT, &&L_OP_RETURN, &&L_OP_TAILCALL, &&L_OP_BLKPUSH,    &&L_OP_ADD, &&L_OP_ADDI, &&L_OP_SUB, &&L_OP_SUBI, &&L_OP_MUL, &&L_OP_DIV,    &&L_OP_EQ, &&L_OP_LT, &&L_OP_LE, &&L_OP_GT, &&L_OP_GE,    &&L_OP_ARRAY, &&L_OP_ARYCAT, &&L_OP_ARYPUSH, &&L_OP_AREF, &&L_OP_ASET, &&L_OP_APOST,    &&L_OP_STRING, &&L_OP_STRCAT, &&L_OP_HASH,    &&L_OP_LAMBDA, &&L_OP_RANGE, &&L_OP_OCLASS,    &&L_OP_CLASS, &&L_OP_MODULE, &&L_OP_EXEC,    &&L_OP_METHOD, &&L_OP_SCLASS, &&L_OP_TCLASS,    &&L_OP_DEBUG, &&L_OP_STOP, &&L_OP_ERR,  };#endif  if (setjmp(c_jmp) == 0) {    mrb->jmp = &c_jmp;  }  else {    goto L_RAISE;  }  if (!mrb->stack) {    stack_init(mrb);  }  mrb->ci->proc = proc;  mrb->ci->nregs = irep->nregs + 2;  regs = mrb->stack;  INIT_DISPATCH {    CASE(OP_NOP) {      /* do nothing */      NEXT;    }    CASE(OP_MOVE) {      /* A B    R(A) := R(B) */#if 0      regs[GETARG_A(i)] = regs[GETARG_B(i)];#elif 1      int a = GETARG_A(i);      int b = GETARG_B(i);      regs[a].tt = regs[b].tt;      regs[a].value = regs[b].value;#else      memcpy(regs+GETARG_A(i), regs+GETARG_B(i), sizeof(mrb_value));#endif      NEXT;    }    CASE(OP_LOADL) {      /* A Bx   R(A) := Pool(Bx) */      regs[GETARG_A(i)] = pool[GETARG_Bx(i)];      NEXT;    }    CASE(OP_LOADI) {      /* A Bx   R(A) := sBx */      SET_INT_VALUE(regs[GETARG_A(i)], GETARG_sBx(i));      NEXT;    }    CASE(OP_LOADSYM) {      /* A B    R(A) := Sym(B) */      SET_SYM_VALUE(regs[GETARG_A(i)], syms[GETARG_Bx(i)]);      NEXT;    }    CASE(OP_LOADNIL) {      /* A B    R(A) := nil */      int a = GETARG_A(i);      SET_NIL_VALUE(regs[a]);      NEXT;    }//.........这里部分代码省略.........
开发者ID:Blorgus,项目名称:mruby,代码行数:101,


示例24: luaU_guess_locals

int luaU_guess_locals(Proto* f, int main) {	int blockend[255];	int block;	int regassign[MAXARG_A];	int regusage[MAXARG_A];	int regblock[MAXARG_A];	int lastfree;	int i,i2,x,y,pc;	llist list_begin;	llist* list_next = &list_begin;	if (f->lineinfo != NULL) {		return 0;	}	if (f->sizelocvars>0) {		return 0;	}	list_begin.next = NULL;	block = 0;	lastfree = 0;	blockend[block] = f->sizecode-1;	for (i=0; i<f->maxstacksize; i++) {		regassign[i] = 0;		regusage[i] = 0;		regblock[i] = 0;	}	// parameters, varargs, nil optimizations	for (i = 0; i < f->numparams; i++) {		list_next = add(list_next,0,blockend[block]);		regassign[lastfree] = 0;		regusage[lastfree] = 1;		regblock[lastfree] = blockend[block];		lastfree++;	}	if ((f->is_vararg==7) || ((f->is_vararg&2))) {		if (main!=0) {			list_next = add(list_next,0,blockend[block]);			lastfree++;			regassign[lastfree] = 0;			regusage[lastfree] = 1;			regblock[lastfree] = blockend[block];			lastfree++;		}	}	{		Instruction i = f->code[0];		OpCode o = GET_OPCODE(i);		int a = GETARG_A(i);		if ((o == OP_SETGLOBAL) || (o == OP_SETUPVAL)) {			int ixx;			for (ixx = lastfree; ixx <= a; ixx++) {				if (ixx!=a) {					list_next = add(list_next,0,blockend[block]);					lastfree++;				}				regassign[lastfree] = 0;				regusage[lastfree] = 1;				regblock[lastfree] = blockend[block];				lastfree++;			}		} else if (o != OP_JMP) {			int ixx;			for (ixx = lastfree; ixx <= a-1; ixx++) {				list_next = add(list_next,0,blockend[block]);				lastfree++;				regassign[lastfree] = 0;				regusage[lastfree] = 1;				regblock[lastfree] = blockend[block];				lastfree++;			}		}	}	// 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;//.........这里部分代码省略.........
开发者ID:Infinity17,项目名称:luadec,代码行数:101,


示例25: 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 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: 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)					{						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,


示例27: decode_instruction

static void decode_instruction(ktap_proto *f, int instr){	int opcode = GET_OPCODE(instr);	ktap_value *k;	k = f->k;	printf("%.8x/t", instr);	printf("%s/t", ktap_opnames[opcode]);	switch (opcode) {	case OP_MOVE:		printf("/t");		print_base(GETARG_A(instr));		printf(" <- ");		print_base(GETARG_B(instr));		break;	case OP_GETTABUP:		print_base(GETARG_A(instr));		printf(" <- ");		print_upvalue(GETARG_B(instr));		printf("{"); print_RKC(instr); printf("}");		break;	case OP_GETTABLE:		print_base(GETARG_A(instr));		printf(" <- ");		print_base(GETARG_B(instr));		printf("{");		print_RKC(instr);		printf("}");		break;	case OP_SETTABLE:		print_base(GETARG_A(instr));		printf("{");		print_RKB(instr);		printf("}");		printf(" <- ");		print_RKC(instr);		break;	case OP_LOADK:		printf("/t");		print_base(GETARG_A(instr));		printf(" <- ");		kp_showobj(NULL, k + GETARG_Bx(instr));		break;	case OP_CALL:		printf("/t");		print_base(GETARG_A(instr));		break;	case OP_JMP:		printf("/t%d", GETARG_sBx(instr));		break;	case OP_CLOSURE:		printf("/t");		print_base(GETARG_A(instr));		printf(" <- closure(func starts from line %d)",			f->p[GETARG_Bx(instr)]->lineinfo[0]);		break;	case OP_SETTABUP:		print_upvalue(GETARG_A(instr));		printf("{");		print_RKB(instr);		printf("} <- ");		print_RKC(instr);		break;	case OP_GETUPVAL:		print_base(GETARG_A(instr));		printf(" <- ");		print_upvalue(GETARG_B(instr));		break;	case OP_NEWTABLE:		print_base(GETARG_A(instr));		printf(" <- {}");	default:		break;	}	printf("/n");}
开发者ID:cfregly,项目名称:ktap,代码行数:85,


示例28: PrintCode

static void PrintCode(const Proto* f){ const Instruction* code=f->code; int pc,n=f->sizecode; for (pc=0; pc<n; pc++) {  Instruction i=code[pc];  OpCode o=GET_OPCODE(i);  int a=GETARG_A(i);  int b=GETARG_B(i);  int c=GETARG_C(i);  int ax=GETARG_Ax(i);  int bx=GETARG_Bx(i);  int sbx=GETARG_sBx(i);  int line=getfuncline(f,pc);  printf("/t%d/t",pc+1);  if (line>0) printf("[%d]/t",line); else printf("[-]/t");  printf("%-9s/t",luaP_opnames[o]);  switch (getOpMode(o))  {   case iABC:    printf("%d",a);    if (getBMode(o)!=OpArgN) printf(" %d",ISK(b) ? (MYK(INDEXK(b))) : b);    if (getCMode(o)!=OpArgN) printf(" %d",ISK(c) ? (MYK(INDEXK(c))) : c);    break;   case iABx:    printf("%d",a);    if (getBMode(o)==OpArgK) printf(" %d",MYK(bx));    if (getBMode(o)==OpArgU) printf(" %d",bx);    break;   case iAsBx:    printf("%d %d",a,sbx);    break;   case iAx:    printf("%d",MYK(ax));    break;  }  switch (o)  {   case OP_LOADK:    printf("/t; "); PrintConstant(f,bx);    break;   case OP_GETUPVAL:   case OP_SETUPVAL:    printf("/t; %s",UPVALNAME(b));    break;   case OP_GETTABUP:    printf("/t; %s",UPVALNAME(b));    if (ISK(c)) { printf(" "); PrintConstant(f,INDEXK(c)); }    break;   case OP_SETTABUP:    printf("/t; %s",UPVALNAME(a));    if (ISK(b)) { printf(" "); PrintConstant(f,INDEXK(b)); }    if (ISK(c)) { printf(" "); PrintConstant(f,INDEXK(c)); }    break;   case OP_GETTABLE:   case OP_SELF:    if (ISK(c)) { printf("/t; "); PrintConstant(f,INDEXK(c)); }    break;   case OP_SETTABLE:   case OP_ADD:   case OP_SUB:   case OP_MUL:   case OP_POW:   case OP_DIV:   case OP_IDIV:   case OP_BAND:   case OP_BOR:   case OP_BXOR:   case OP_SHL:   case OP_SHR:   case OP_EQ:   case OP_LT:   case OP_LE:    if (ISK(b) || ISK(c))    {     printf("/t; ");     if (ISK(b)) PrintConstant(f,INDEXK(b)); else printf("-");     printf(" ");     if (ISK(c)) PrintConstant(f,INDEXK(c)); else printf("-");    }    break;   case OP_JMP:   case OP_FORLOOP:   case OP_FORPREP:   case OP_TFORLOOP:    printf("/t; to %d",sbx+pc+2);    break;   case OP_CLOSURE:    printf("/t; %p",VOID(f->p[bx]));    break;   case OP_SETLIST:    if (c==0) printf("/t; %d",(int)code[++pc]); else printf("/t; %d",c);    break;   case OP_EXTRAARG:    printf("/t; "); PrintConstant(f,ax);    break;   default:    break;  }//.........这里部分代码省略.........
开发者ID:bysdxt,项目名称:xLua,代码行数:101,


示例29: codedump

static voidcodedump(mrb_state *mrb, mrb_irep *irep){#ifndef MRB_DISABLE_STDIO  int i;  int ai;  mrb_code c;  const char *file = NULL, *next_file;  int32_t line;  if (!irep) return;  printf("irep %p nregs=%d nlocals=%d pools=%d syms=%d reps=%d/n", (void*)irep,         irep->nregs, irep->nlocals, (int)irep->plen, (int)irep->slen, (int)irep->rlen);  for (i = 0; i < (int)irep->ilen; i++) {    ai = mrb_gc_arena_save(mrb);    next_file = mrb_debug_get_filename(irep, i);    if (next_file && file != next_file) {      printf("file: %s/n", next_file);      file = next_file;    }    line = mrb_debug_get_line(irep, i);    if (line < 0) {      printf("      ");    }    else {      printf("%5d ", line);    }    printf("%03d ", i);    c = irep->iseq[i];    switch (GET_OPCODE(c)) {    case OP_NOP:      printf("OP_NOP/n");      break;    case OP_MOVE:      printf("OP_MOVE/tR%d/tR%d/t", GETARG_A(c), GETARG_B(c));      print_lv(mrb, irep, c, RAB);      break;    case OP_LOADL:      {        mrb_value v = irep->pool[GETARG_Bx(c)];        mrb_value s = mrb_inspect(mrb, v);        printf("OP_LOADL/tR%d/tL(%d)/t; %s", GETARG_A(c), GETARG_Bx(c), RSTRING_PTR(s));      }      print_lv(mrb, irep, c, RA);      break;    case OP_LOADI:      printf("OP_LOADI/tR%d/t%d/t", GETARG_A(c), GETARG_sBx(c));      print_lv(mrb, irep, c, RA);      break;    case OP_LOADSYM:      printf("OP_LOADSYM/tR%d/t:%s", GETARG_A(c),             mrb_sym2name(mrb, irep->syms[GETARG_Bx(c)]));      print_lv(mrb, irep, c, RA);      break;    case OP_LOADNIL:      printf("OP_LOADNIL/tR%d/t/t", GETARG_A(c));      print_lv(mrb, irep, c, RA);      break;    case OP_LOADSELF:      printf("OP_LOADSELF/tR%d/t/t", GETARG_A(c));      print_lv(mrb, irep, c, RA);      break;    case OP_LOADT:      printf("OP_LOADT/tR%d/t/t", GETARG_A(c));      print_lv(mrb, irep, c, RA);      break;    case OP_LOADF:      printf("OP_LOADF/tR%d/t/t", GETARG_A(c));      print_lv(mrb, irep, c, RA);      break;    case OP_GETGLOBAL:      printf("OP_GETGLOBAL/tR%d/t:%s", GETARG_A(c),             mrb_sym2name(mrb, irep->syms[GETARG_Bx(c)]));      print_lv(mrb, irep, c, RA);      break;    case OP_SETGLOBAL:      printf("OP_SETGLOBAL/t:%s/tR%d/t",             mrb_sym2name(mrb, irep->syms[GETARG_Bx(c)]),             GETARG_A(c));      print_lv(mrb, irep, c, RA);      break;    case OP_GETCONST:      printf("OP_GETCONST/tR%d/t:%s", GETARG_A(c),             mrb_sym2name(mrb, irep->syms[GETARG_Bx(c)]));      print_lv(mrb, irep, c, RA);      break;    case OP_SETCONST:      printf("OP_SETCONST/t:%s/tR%d/t",             mrb_sym2name(mrb, irep->syms[GETARG_Bx(c)]),             GETARG_A(c));      print_lv(mrb, irep, c, RA);      break;    case OP_GETMCNST:      printf("OP_GETMCNST/tR%d/tR%d::%s", GETARG_A(c), GETARG_A(c),             mrb_sym2name(mrb, irep->syms[GETARG_Bx(c)]));      print_lv(mrb, irep, c, RAB);      break;//.........这里部分代码省略.........
开发者ID:cremno,项目名称:mruby,代码行数:101,



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


C++ GETARG_C函数代码示例
C++ GETARG_Ax函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。