Exemplo n.º 1
0
/*
** Emit a "load constant" instruction, using either 'OP_LOADK'
** (if constant index 'k' fits in 18 bits) or an 'OP_LOADKX'
** instruction with "extra argument".
*/
int luaK_codek (FuncState *fs, int reg, int k) {
  if (k <= MAXARG_Bx)
    return luaK_codeABx(fs, OP_LOADK, reg, k);
  else {
    int p = luaK_codeABx(fs, OP_LOADKX, reg, 0);
    codeextraarg(fs, k);
    return p;
  }
}
Exemplo n.º 2
0
int luaK_codeABxX (FuncState *fs, OpCode o, int reg, int k) {
  if (k < MAXARG_Bx)
    return luaK_codeABx(fs, o, reg, k + 1);
  else {
    int p = luaK_codeABx(fs, o, reg, 0);
    codeextraarg(fs, k);
    return p;
  }
}
Exemplo n.º 3
0
Arquivo: lcode.cpp Projeto: swizl/lua
int FuncState::luaK_codek (/*FuncState *fs,*/ int reg, int k) {
	if (k <= MAXARG_Bx)
		return luaK_codeABx(OP_LOADK, reg, k);
	else {
		int p = luaK_codeABx(OP_LOADKX, reg, 0);
		codeextraarg(k);
		return p;
	}
}
Exemplo n.º 4
0
int codegen_codek(ktap_funcstate *fs, int reg, int k)
{
	if (k <= MAXARG_Bx)
		return codegen_codeABx(fs, OP_LOADK, reg, k);
	else {
		int p = codegen_codeABx(fs, OP_LOADKX, reg, 0);
		codeextraarg(fs, k);
		return p;
	}
}
Exemplo n.º 5
0
void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) {
  int c =  (nelems - 1)/LFIELDS_PER_FLUSH + 1;
  int b = (tostore == LUA_MULTRET) ? 0 : tostore;
  lua_assert(tostore != 0);
  if (c <= MAXARG_C)
    luaK_codeABC(fs, OP_SETLIST, base, b, c);
  else if (c <= MAXARG_Ax) {
    luaK_codeABC(fs, OP_SETLIST, base, b, 0);
    codeextraarg(fs, c);
  }
  else
    luaX_syntaxerror(fs->ls, "constructor too long");
  fs->freereg = base + 1;  /* free registers with list values */
}