Exemplo n.º 1
0
Arquivo: code.c Projeto: WeiY/ktap
static void discharge2anyreg(FuncState *fs, expdesc *e)
{
	if (e->k != VNONRELOC) {
		codegen_reserveregs(fs, 1);
		discharge2reg(fs, e, fs->freereg-1);
	}
}
Exemplo n.º 2
0
/*
** Ensures final expression result (including results from its jump
** lists) is in register 'reg'.
** If expression has jumps, need to patch these jumps either to
** its final position or to "load" instructions (for those tests
** that do not produce values).
*/
static void exp2reg (FuncState *fs, expdesc *e, int reg) {
  discharge2reg(fs, e, reg);
  if (e->k == VJMP)  /* expression itself is a test? */
    luaK_concat(fs, &e->t, e->u.info);  /* put this jump in 't' list */
  if (hasjumps(e)) {
    int final;  /* position after whole expression */
    int p_f = NO_JUMP;  /* position of an eventual LOAD false */
    int p_t = NO_JUMP;  /* position of an eventual LOAD true */
    if (need_value(fs, e->t) || need_value(fs, e->f)) {
      int fj = (e->k == VJMP) ? NO_JUMP : luaK_jump(fs);
      p_f = code_loadbool(fs, reg, 0, 1);
      p_t = code_loadbool(fs, reg, 1, 0);
      luaK_patchtohere(fs, fj);
    }
    final = luaK_getlabel(fs);
    patchlistaux(fs, e->f, final, reg, p_f);
    patchlistaux(fs, e->t, final, reg, p_t);
  }
Exemplo n.º 3
0
static void exp2reg (FuncState *fs, expdesc *e, int reg) {
  discharge2reg(fs, e, reg);
  if (e->k == VJMP)
    luaK_concat(fs, &e->t, e->u.info);  /* put this jump in `t' list */
  if (hasjumps(e)) {
	if (e->k != VJMP)
	  luaK_goiftrue(fs, e);
    int fj = (e->k == VJMP) ? NO_JUMP : luaK_jump(fs);
    int p_f = code_label(fs, reg, 0, 1);
    luaK_patchtohere(fs, fj);
    int p_t = code_label(fs, reg, 1, 0);
    patchlistaux(fs, e->f, p_f);
    patchlistaux(fs, e->t, p_t);
  }
  e->f = e->t = NO_JUMP;
  e->u.info = reg;
  e->k = VNONRELOC;
}
Exemplo n.º 4
0
Arquivo: lcode.cpp Projeto: swizl/lua
/*static*/ void FuncState::exp2reg (/*FuncState *fs,*/ expdesc *e, int reg) {
	discharge2reg(e, reg);
	if (e->k == VJMP)
		luaK_concat(&e->t, e->u.info);  /* put this jump in 't' list */
	if (hasjumps(e)) {
		int final;  /* position after whole expression */
		int p_f = NO_JUMP;  /* position of an eventual LOAD false */
		int p_t = NO_JUMP;  /* position of an eventual LOAD true */
		if (need_value(e->t) || need_value(e->f)) {
			int fj = (e->k == VJMP) ? NO_JUMP : luaK_jump();
			p_f = code_label(reg, 0, 1);
			p_t = code_label(reg, 1, 0);
			luaK_patchtohere(fj);
		}
		final = luaK_getlabel();
		patchlistaux(e->f, final, reg, p_f);
		patchlistaux(e->t, final, reg, p_t);
	}
Exemplo n.º 5
0
static void exp2reg(ktap_funcstate *fs, ktap_expdesc *e, int reg)
{
	discharge2reg(fs, e, reg);
	if (e->k == VJMP)
		codegen_concat(fs, &e->t, e->u.info);  /* put this jump in `t' list */
	if (hasjumps(e)) {
		int final;  /* position after whole expression */
		int p_f = NO_JUMP;  /* position of an eventual LOAD false */
		int p_t = NO_JUMP;  /* position of an eventual LOAD true */

		if (need_value(fs, e->t) || need_value(fs, e->f)) {
			int fj = (e->k == VJMP) ? NO_JUMP : codegen_jump(fs);

			p_f = code_label(fs, reg, 0, 1);
			p_t = code_label(fs, reg, 1, 0);
			codegen_patchtohere(fs, fj);
		}
		final = codegen_getlabel(fs);
		patchlistaux(fs, e->f, final, reg, p_f);
		patchlistaux(fs, e->t, final, reg, p_t);
	}
Exemplo n.º 6
0
/*
** Ensures expression value is in any register.
*/
static void discharge2anyreg (FuncState *fs, expdesc *e) {
  if (e->k != VNONRELOC) {  /* no fixed register yet? */
    luaK_reserveregs(fs, 1);  /* get a register */
    discharge2reg(fs, e, fs->freereg-1);  /* put value there */
  }
}
Exemplo n.º 7
0
static void ICACHE_FLASH_ATTR discharge2anyreg (FuncState *fs, expdesc *e) {
  if (e->k != VNONRELOC) {
    luaK_reserveregs(fs, 1);
    discharge2reg(fs, e, fs->freereg-1);
  }
}
Exemplo n.º 8
0
Arquivo: lcode.cpp Projeto: swizl/lua
/*static*/ void FuncState::discharge2anyreg (/*FuncState *fs,*/ expdesc *e) {
	if (e->k != VNONRELOC) {
		luaK_reserveregs(1);
		discharge2reg(e, free_reg-1);
	}
}