lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi everyone,
Would you give me some more detailed information about the following function?
Especially, I can't finger out the meaning of luaK_concat and luaK_patchtohere.

static void ifstat (LexState *ls, int line) {
/* ifstat -> IF cond THEN block {ELSEIF cond THEN block} [ELSE block] END */
FuncState *fs = ls->fs;
int flist;
int escapelist = NO_JUMP;
flist = test_then_block(ls);  /* IF cond THEN block */
while (ls->t.token == TK_ELSEIF) {
  luaK_concat(fs, &escapelist, luaK_jump(fs));
  luaK_patchtohere(fs, flist);
  flist = test_then_block(ls);  /* ELSEIF cond THEN block */
}
if (ls->t.token == TK_ELSE) {
  luaK_concat(fs, &escapelist, luaK_jump(fs));
  luaK_patchtohere(fs, flist);
  luaX_next(ls);  /* skip ELSE (after patch, for correct line info) */
  block(ls);  /* `else' part */
}
else
  luaK_concat(fs, &escapelist, flist);
luaK_patchtohere(fs, escapelist);
check_match(ls, TK_END, TK_IF, line);
}