diff options
author | jbj <devnull@localhost> | 2004-03-23 05:09:13 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2004-03-23 05:09:13 +0000 |
commit | 7b5c3b42c9b847badc5c6f66f054ee536ce82edd (patch) | |
tree | e43fbc2496a3485768e5e45fe15f068a456e9a81 /lua/lcode.c | |
parent | 9ecefd3901e8d3dc5652247bb4ab02f73a949fb7 (diff) | |
download | rpm-7b5c3b42c9b847badc5c6f66f054ee536ce82edd.tar.gz rpm-7b5c3b42c9b847badc5c6f66f054ee536ce82edd.tar.bz2 rpm-7b5c3b42c9b847badc5c6f66f054ee536ce82edd.zip |
Splint annotations.
CVS patchset: 7182
CVS date: 2004/03/23 05:09:13
Diffstat (limited to 'lua/lcode.c')
-rw-r--r-- | lua/lcode.c | 82 |
1 files changed, 61 insertions, 21 deletions
diff --git a/lua/lcode.c b/lua/lcode.c index 033e8ecf3..7047adf36 100644 --- a/lua/lcode.c +++ b/lua/lcode.c @@ -1,5 +1,5 @@ /* -** $Id: lcode.c,v 1.1 2004/03/16 21:58:30 niemeyer Exp $ +** $Id: lcode.c,v 1.2 2004/03/23 05:09:14 jbj Exp $ ** Code generator for Lua ** See Copyright Notice in lua.h */ @@ -51,13 +51,17 @@ int luaK_jump (FuncState *fs) { } -static int luaK_condjump (FuncState *fs, OpCode op, int A, int B, int C) { +static int luaK_condjump (FuncState *fs, OpCode op, int A, int B, int C) + /*@modifies fs @*/ +{ luaK_codeABC(fs, op, A, B, C); return luaK_jump(fs); } -static void luaK_fixjump (FuncState *fs, int pc, int dest) { +static void luaK_fixjump (FuncState *fs, int pc, int dest) + /*@modifies fs @*/ +{ Instruction *jmp = &fs->f->code[pc]; int offset = dest-(pc+1); lua_assert(dest != NO_JUMP); @@ -77,7 +81,9 @@ int luaK_getlabel (FuncState *fs) { } -static int luaK_getjump (FuncState *fs, int pc) { +static int luaK_getjump (FuncState *fs, int pc) + /*@*/ +{ int offset = GETARG_sBx(fs->f->code[pc]); if (offset == NO_JUMP) /* point to itself represents end of list */ return NO_JUMP; /* end of list */ @@ -86,7 +92,9 @@ static int luaK_getjump (FuncState *fs, int pc) { } -static Instruction *getjumpcontrol (FuncState *fs, int pc) { +static Instruction *getjumpcontrol (FuncState *fs, int pc) + /*@*/ +{ Instruction *pi = &fs->f->code[pc]; if (pc >= 1 && testOpMode(GET_OPCODE(*(pi-1)), OpModeT)) return pi-1; @@ -99,7 +107,9 @@ static Instruction *getjumpcontrol (FuncState *fs, int pc) { ** check whether list has any jump that do not produce a value ** (or produce an inverted value) */ -static int need_value (FuncState *fs, int list, int cond) { +static int need_value (FuncState *fs, int list, int cond) + /*@*/ +{ for (; list != NO_JUMP; list = luaK_getjump(fs, list)) { Instruction i = *getjumpcontrol(fs, list); if (GET_OPCODE(i) != OP_TEST || GETARG_C(i) != cond) return 1; @@ -108,14 +118,18 @@ static int need_value (FuncState *fs, int list, int cond) { } -static void patchtestreg (Instruction *i, int reg) { +static void patchtestreg (Instruction *i, int reg) + /*@modifies *i @*/ +{ if (reg == NO_REG) reg = GETARG_B(*i); SETARG_A(*i, reg); } static void luaK_patchlistaux (FuncState *fs, int list, - int ttarget, int treg, int ftarget, int freg, int dtarget) { + int ttarget, int treg, int ftarget, int freg, int dtarget) + /*@modifies fs @*/ +{ while (list != NO_JUMP) { int next = luaK_getjump(fs, list); Instruction *i = getjumpcontrol(fs, list); @@ -140,7 +154,9 @@ static void luaK_patchlistaux (FuncState *fs, int list, } -static void luaK_dischargejpc (FuncState *fs) { +static void luaK_dischargejpc (FuncState *fs) + /*@modifies fs @*/ +{ luaK_patchlistaux(fs, fs->jpc, fs->pc, NO_REG, fs->pc, NO_REG, fs->pc); fs->jpc = NO_JUMP; } @@ -192,7 +208,9 @@ void luaK_reserveregs (FuncState *fs, int n) { } -static void freereg (FuncState *fs, int reg) { +static void freereg (FuncState *fs, int reg) + /*@modifies fs @*/ +{ if (reg >= fs->nactvar && reg < MAXSTACK) { fs->freereg--; lua_assert(reg == fs->freereg); @@ -200,13 +218,17 @@ static void freereg (FuncState *fs, int reg) { } -static void freeexp (FuncState *fs, expdesc *e) { +static void freeexp (FuncState *fs, expdesc *e) + /*@modifies fs @*/ +{ if (e->k == VNONRELOC) freereg(fs, e->info); } -static int addk (FuncState *fs, TObject *k, TObject *v) { +static int addk (FuncState *fs, TObject *k, TObject *v) + /*@modifies fs @*/ +{ const TObject *idx = luaH_get(fs->h, k); if (ttisnumber(idx)) { lua_assert(luaO_rawequalObj(&fs->f->k[cast(int, nvalue(idx))], v)); @@ -237,7 +259,9 @@ int luaK_numberK (FuncState *fs, lua_Number r) { } -static int nil_constant (FuncState *fs) { +static int nil_constant (FuncState *fs) + /*@modifies fs @*/ +{ TObject k, v; setnilvalue(&v); sethvalue(&k, fs->h); /* cannot use nil as key; instead use table itself */ @@ -288,13 +312,17 @@ void luaK_dischargevars (FuncState *fs, expdesc *e) { } -static int code_label (FuncState *fs, int A, int b, int jump) { +static int code_label (FuncState *fs, int A, int b, int jump) + /*@modifies fs @*/ +{ luaK_getlabel(fs); /* those instructions may be jump targets */ return luaK_codeABC(fs, OP_LOADBOOL, A, b, jump); } -static void discharge2reg (FuncState *fs, expdesc *e, int reg) { +static void discharge2reg (FuncState *fs, expdesc *e, int reg) + /*@modifies fs, e @*/ +{ luaK_dischargevars(fs, e); switch (e->k) { case VNIL: { @@ -329,7 +357,9 @@ static void discharge2reg (FuncState *fs, expdesc *e, int reg) { } -static void discharge2anyreg (FuncState *fs, expdesc *e) { +static void discharge2anyreg (FuncState *fs, expdesc *e) + /*@modifies fs, e @*/ +{ if (e->k != VNONRELOC) { luaK_reserveregs(fs, 1); discharge2reg(fs, e, fs->freereg-1); @@ -337,7 +367,9 @@ static void discharge2anyreg (FuncState *fs, expdesc *e) { } -static void luaK_exp2reg (FuncState *fs, expdesc *e, int reg) { +static void luaK_exp2reg (FuncState *fs, expdesc *e, int reg) + /*@modifies fs, e @*/ +{ discharge2reg(fs, e, reg); if (e->k == VJMP) luaK_concat(fs, &e->t, e->info); /* put this jump in `t' list */ @@ -460,7 +492,9 @@ void luaK_self (FuncState *fs, expdesc *e, expdesc *key) { } -static void invertjump (FuncState *fs, expdesc *e) { +static void invertjump (FuncState *fs, expdesc *e) + /*@*/ +{ Instruction *pc = getjumpcontrol(fs, e->info); lua_assert(testOpMode(GET_OPCODE(*pc), OpModeT) && GET_OPCODE(*pc) != OP_TEST); @@ -468,7 +502,9 @@ static void invertjump (FuncState *fs, expdesc *e) { } -static int jumponcond (FuncState *fs, expdesc *e, int cond) { +static int jumponcond (FuncState *fs, expdesc *e, int cond) + /*@modifies fs, e @*/ +{ if (e->k == VRELOCABLE) { Instruction ie = getcode(fs, e); if (GET_OPCODE(ie) == OP_NOT) { @@ -534,7 +570,9 @@ void luaK_goiffalse (FuncState *fs, expdesc *e) { } -static void codenot (FuncState *fs, expdesc *e) { +static void codenot (FuncState *fs, expdesc *e) + /*@modifies fs, e @*/ +{ luaK_dischargevars(fs, e); switch (e->k) { case VNIL: case VFALSE: { @@ -617,7 +655,9 @@ void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) { static void codebinop (FuncState *fs, expdesc *res, BinOpr op, - int o1, int o2) { + int o1, int o2) + /*@modifies fs, res @*/ +{ if (op <= OPR_POW) { /* arithmetic operator? */ OpCode opc = cast(OpCode, (op - OPR_ADD) + OP_ADD); /* ORDER OP */ res->info = luaK_codeABC(fs, opc, 0, o1, o2); |