diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-05-22 14:47:54 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-05-22 14:47:54 -0300 |
commit | 9be74ccc214eb6f4d9d0b9496fd973542c7377d9 (patch) | |
tree | e62aacce2266814e8c09a490e02ac6ad9cf13be0 | |
parent | 09f3c2372f5dbeaec9f50614a26c1b5761726a88 (diff) | |
download | lua-9be74ccc214eb6f4d9d0b9496fd973542c7377d9.tar.gz lua-9be74ccc214eb6f4d9d0b9496fd973542c7377d9.tar.bz2 lua-9be74ccc214eb6f4d9d0b9496fd973542c7377d9.zip |
Several functions turned 'static'
Several functions that were already being used only inside their
own file have been declared as 'static'.
-rw-r--r-- | lcode.c | 22 | ||||
-rw-r--r-- | lcode.h | 3 | ||||
-rw-r--r-- | ldo.c | 6 | ||||
-rw-r--r-- | ldo.h | 1 | ||||
-rw-r--r-- | lgc.c | 4 | ||||
-rw-r--r-- | lstate.c | 4 | ||||
-rw-r--r-- | lstate.h | 1 |
7 files changed, 18 insertions, 23 deletions
@@ -415,7 +415,7 @@ int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) { | |||
415 | /* | 415 | /* |
416 | ** Format and emit an 'iAsBx' instruction. | 416 | ** Format and emit an 'iAsBx' instruction. |
417 | */ | 417 | */ |
418 | int luaK_codeAsBx (FuncState *fs, OpCode o, int a, int bc) { | 418 | static int codeAsBx (FuncState *fs, OpCode o, int a, int bc) { |
419 | unsigned int b = bc + OFFSET_sBx; | 419 | unsigned int b = bc + OFFSET_sBx; |
420 | lua_assert(getOpMode(o) == iAsBx); | 420 | lua_assert(getOpMode(o) == iAsBx); |
421 | lua_assert(a <= MAXARG_A && b <= MAXARG_Bx); | 421 | lua_assert(a <= MAXARG_A && b <= MAXARG_Bx); |
@@ -671,7 +671,7 @@ static int fitsBx (lua_Integer i) { | |||
671 | 671 | ||
672 | void luaK_int (FuncState *fs, int reg, lua_Integer i) { | 672 | void luaK_int (FuncState *fs, int reg, lua_Integer i) { |
673 | if (fitsBx(i)) | 673 | if (fitsBx(i)) |
674 | luaK_codeAsBx(fs, OP_LOADI, reg, cast_int(i)); | 674 | codeAsBx(fs, OP_LOADI, reg, cast_int(i)); |
675 | else | 675 | else |
676 | luaK_codek(fs, reg, luaK_intK(fs, i)); | 676 | luaK_codek(fs, reg, luaK_intK(fs, i)); |
677 | } | 677 | } |
@@ -680,7 +680,7 @@ void luaK_int (FuncState *fs, int reg, lua_Integer i) { | |||
680 | static void luaK_float (FuncState *fs, int reg, lua_Number f) { | 680 | static void luaK_float (FuncState *fs, int reg, lua_Number f) { |
681 | lua_Integer fi; | 681 | lua_Integer fi; |
682 | if (luaV_flttointeger(f, &fi, F2Ieq) && fitsBx(fi)) | 682 | if (luaV_flttointeger(f, &fi, F2Ieq) && fitsBx(fi)) |
683 | luaK_codeAsBx(fs, OP_LOADF, reg, cast_int(fi)); | 683 | codeAsBx(fs, OP_LOADF, reg, cast_int(fi)); |
684 | else | 684 | else |
685 | luaK_codek(fs, reg, luaK_numberK(fs, f)); | 685 | luaK_codek(fs, reg, luaK_numberK(fs, f)); |
686 | } | 686 | } |
@@ -1025,7 +1025,7 @@ static int luaK_exp2K (FuncState *fs, expdesc *e) { | |||
1025 | ** in the range of R/K indices). | 1025 | ** in the range of R/K indices). |
1026 | ** Returns 1 iff expression is K. | 1026 | ** Returns 1 iff expression is K. |
1027 | */ | 1027 | */ |
1028 | int luaK_exp2RK (FuncState *fs, expdesc *e) { | 1028 | static int exp2RK (FuncState *fs, expdesc *e) { |
1029 | if (luaK_exp2K(fs, e)) | 1029 | if (luaK_exp2K(fs, e)) |
1030 | return 1; | 1030 | return 1; |
1031 | else { /* not a constant in the right range: put it in a register */ | 1031 | else { /* not a constant in the right range: put it in a register */ |
@@ -1037,7 +1037,7 @@ int luaK_exp2RK (FuncState *fs, expdesc *e) { | |||
1037 | 1037 | ||
1038 | static void codeABRK (FuncState *fs, OpCode o, int a, int b, | 1038 | static void codeABRK (FuncState *fs, OpCode o, int a, int b, |
1039 | expdesc *ec) { | 1039 | expdesc *ec) { |
1040 | int k = luaK_exp2RK(fs, ec); | 1040 | int k = exp2RK(fs, ec); |
1041 | luaK_codeABCk(fs, o, a, b, ec->u.info, k); | 1041 | luaK_codeABCk(fs, o, a, b, ec->u.info, k); |
1042 | } | 1042 | } |
1043 | 1043 | ||
@@ -1225,7 +1225,7 @@ static int isKstr (FuncState *fs, expdesc *e) { | |||
1225 | /* | 1225 | /* |
1226 | ** Check whether expression 'e' is a literal integer. | 1226 | ** Check whether expression 'e' is a literal integer. |
1227 | */ | 1227 | */ |
1228 | int luaK_isKint (expdesc *e) { | 1228 | static int isKint (expdesc *e) { |
1229 | return (e->k == VKINT && !hasjumps(e)); | 1229 | return (e->k == VKINT && !hasjumps(e)); |
1230 | } | 1230 | } |
1231 | 1231 | ||
@@ -1235,7 +1235,7 @@ int luaK_isKint (expdesc *e) { | |||
1235 | ** proper range to fit in register C | 1235 | ** proper range to fit in register C |
1236 | */ | 1236 | */ |
1237 | static int isCint (expdesc *e) { | 1237 | static int isCint (expdesc *e) { |
1238 | return luaK_isKint(e) && (l_castS2U(e->u.ival) <= l_castS2U(MAXARG_C)); | 1238 | return isKint(e) && (l_castS2U(e->u.ival) <= l_castS2U(MAXARG_C)); |
1239 | } | 1239 | } |
1240 | 1240 | ||
1241 | 1241 | ||
@@ -1244,7 +1244,7 @@ static int isCint (expdesc *e) { | |||
1244 | ** proper range to fit in register sC | 1244 | ** proper range to fit in register sC |
1245 | */ | 1245 | */ |
1246 | static int isSCint (expdesc *e) { | 1246 | static int isSCint (expdesc *e) { |
1247 | return luaK_isKint(e) && fitsC(e->u.ival); | 1247 | return isKint(e) && fitsC(e->u.ival); |
1248 | } | 1248 | } |
1249 | 1249 | ||
1250 | 1250 | ||
@@ -1460,7 +1460,7 @@ static void codebinK (FuncState *fs, BinOpr opr, | |||
1460 | */ | 1460 | */ |
1461 | static int finishbinexpneg (FuncState *fs, expdesc *e1, expdesc *e2, | 1461 | static int finishbinexpneg (FuncState *fs, expdesc *e1, expdesc *e2, |
1462 | OpCode op, int line, TMS event) { | 1462 | OpCode op, int line, TMS event) { |
1463 | if (!luaK_isKint(e2)) | 1463 | if (!isKint(e2)) |
1464 | return 0; /* not an integer constant */ | 1464 | return 0; /* not an integer constant */ |
1465 | else { | 1465 | else { |
1466 | lua_Integer i2 = e2->u.ival; | 1466 | lua_Integer i2 = e2->u.ival; |
@@ -1593,7 +1593,7 @@ static void codeeq (FuncState *fs, BinOpr opr, expdesc *e1, expdesc *e2) { | |||
1593 | op = OP_EQI; | 1593 | op = OP_EQI; |
1594 | r2 = im; /* immediate operand */ | 1594 | r2 = im; /* immediate operand */ |
1595 | } | 1595 | } |
1596 | else if (luaK_exp2RK(fs, e2)) { /* 2nd expression is constant? */ | 1596 | else if (exp2RK(fs, e2)) { /* 2nd expression is constant? */ |
1597 | op = OP_EQK; | 1597 | op = OP_EQK; |
1598 | r2 = e2->u.info; /* constant index */ | 1598 | r2 = e2->u.info; /* constant index */ |
1599 | } | 1599 | } |
@@ -1659,7 +1659,7 @@ void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) { | |||
1659 | } | 1659 | } |
1660 | case OPR_EQ: case OPR_NE: { | 1660 | case OPR_EQ: case OPR_NE: { |
1661 | if (!tonumeral(v, NULL)) | 1661 | if (!tonumeral(v, NULL)) |
1662 | luaK_exp2RK(fs, v); | 1662 | exp2RK(fs, v); |
1663 | /* else keep numeral, which may be an immediate operand */ | 1663 | /* else keep numeral, which may be an immediate operand */ |
1664 | break; | 1664 | break; |
1665 | } | 1665 | } |
@@ -61,10 +61,8 @@ typedef enum UnOpr { OPR_MINUS, OPR_BNOT, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr; | |||
61 | 61 | ||
62 | LUAI_FUNC int luaK_code (FuncState *fs, Instruction i); | 62 | LUAI_FUNC int luaK_code (FuncState *fs, Instruction i); |
63 | LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx); | 63 | LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx); |
64 | LUAI_FUNC int luaK_codeAsBx (FuncState *fs, OpCode o, int A, int Bx); | ||
65 | LUAI_FUNC int luaK_codeABCk (FuncState *fs, OpCode o, int A, | 64 | LUAI_FUNC int luaK_codeABCk (FuncState *fs, OpCode o, int A, |
66 | int B, int C, int k); | 65 | int B, int C, int k); |
67 | LUAI_FUNC int luaK_isKint (expdesc *e); | ||
68 | LUAI_FUNC int luaK_exp2const (FuncState *fs, const expdesc *e, TValue *v); | 66 | LUAI_FUNC int luaK_exp2const (FuncState *fs, const expdesc *e, TValue *v); |
69 | LUAI_FUNC void luaK_fixline (FuncState *fs, int line); | 67 | LUAI_FUNC void luaK_fixline (FuncState *fs, int line); |
70 | LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n); | 68 | LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n); |
@@ -76,7 +74,6 @@ LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e); | |||
76 | LUAI_FUNC void luaK_exp2anyregup (FuncState *fs, expdesc *e); | 74 | LUAI_FUNC void luaK_exp2anyregup (FuncState *fs, expdesc *e); |
77 | LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e); | 75 | LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e); |
78 | LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e); | 76 | LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e); |
79 | LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e); | ||
80 | LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key); | 77 | LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key); |
81 | LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k); | 78 | LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k); |
82 | LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e); | 79 | LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e); |
@@ -409,7 +409,7 @@ static void rethook (lua_State *L, CallInfo *ci, int nres) { | |||
409 | ** stack, below original 'func', so that 'luaD_precall' can call it. Raise | 409 | ** stack, below original 'func', so that 'luaD_precall' can call it. Raise |
410 | ** an error if there is no '__call' metafield. | 410 | ** an error if there is no '__call' metafield. |
411 | */ | 411 | */ |
412 | StkId luaD_tryfuncTM (lua_State *L, StkId func) { | 412 | static StkId tryfuncTM (lua_State *L, StkId func) { |
413 | const TValue *tm; | 413 | const TValue *tm; |
414 | StkId p; | 414 | StkId p; |
415 | checkstackGCp(L, 1, func); /* space for metamethod */ | 415 | checkstackGCp(L, 1, func); /* space for metamethod */ |
@@ -568,7 +568,7 @@ int luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func, | |||
568 | return -1; | 568 | return -1; |
569 | } | 569 | } |
570 | default: { /* not a function */ | 570 | default: { /* not a function */ |
571 | func = luaD_tryfuncTM(L, func); /* try to get '__call' metamethod */ | 571 | func = tryfuncTM(L, func); /* try to get '__call' metamethod */ |
572 | /* return luaD_pretailcall(L, ci, func, narg1 + 1, delta); */ | 572 | /* return luaD_pretailcall(L, ci, func, narg1 + 1, delta); */ |
573 | narg1++; | 573 | narg1++; |
574 | goto retry; /* try again */ | 574 | goto retry; /* try again */ |
@@ -609,7 +609,7 @@ CallInfo *luaD_precall (lua_State *L, StkId func, int nresults) { | |||
609 | return ci; | 609 | return ci; |
610 | } | 610 | } |
611 | default: { /* not a function */ | 611 | default: { /* not a function */ |
612 | func = luaD_tryfuncTM(L, func); /* try to get '__call' metamethod */ | 612 | func = tryfuncTM(L, func); /* try to get '__call' metamethod */ |
613 | /* return luaD_precall(L, func, nresults); */ | 613 | /* return luaD_precall(L, func, nresults); */ |
614 | goto retry; /* try again with metamethod */ | 614 | goto retry; /* try again with metamethod */ |
615 | } | 615 | } |
@@ -71,7 +71,6 @@ LUAI_FUNC int luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func, | |||
71 | LUAI_FUNC CallInfo *luaD_precall (lua_State *L, StkId func, int nResults); | 71 | LUAI_FUNC CallInfo *luaD_precall (lua_State *L, StkId func, int nResults); |
72 | LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults); | 72 | LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults); |
73 | LUAI_FUNC void luaD_callnoyield (lua_State *L, StkId func, int nResults); | 73 | LUAI_FUNC void luaD_callnoyield (lua_State *L, StkId func, int nResults); |
74 | LUAI_FUNC StkId luaD_tryfuncTM (lua_State *L, StkId func); | ||
75 | LUAI_FUNC int luaD_closeprotected (lua_State *L, ptrdiff_t level, int status); | 74 | LUAI_FUNC int luaD_closeprotected (lua_State *L, ptrdiff_t level, int status); |
76 | LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, | 75 | LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, |
77 | ptrdiff_t oldtop, ptrdiff_t ef); | 76 | ptrdiff_t oldtop, ptrdiff_t ef); |
@@ -1409,7 +1409,7 @@ static void stepgenfull (lua_State *L, global_State *g) { | |||
1409 | setminordebt(g); | 1409 | setminordebt(g); |
1410 | } | 1410 | } |
1411 | else { /* another bad collection; stay in incremental mode */ | 1411 | else { /* another bad collection; stay in incremental mode */ |
1412 | g->GCestimate = gettotalbytes(g); /* first estimate */; | 1412 | g->GCestimate = gettotalbytes(g); /* first estimate */ |
1413 | entersweep(L); | 1413 | entersweep(L); |
1414 | luaC_runtilstate(L, bitmask(GCSpause)); /* finish collection */ | 1414 | luaC_runtilstate(L, bitmask(GCSpause)); /* finish collection */ |
1415 | setpause(g); | 1415 | setpause(g); |
@@ -1604,7 +1604,7 @@ static lu_mem singlestep (lua_State *L) { | |||
1604 | case GCSenteratomic: { | 1604 | case GCSenteratomic: { |
1605 | work = atomic(L); /* work is what was traversed by 'atomic' */ | 1605 | work = atomic(L); /* work is what was traversed by 'atomic' */ |
1606 | entersweep(L); | 1606 | entersweep(L); |
1607 | g->GCestimate = gettotalbytes(g); /* first estimate */; | 1607 | g->GCestimate = gettotalbytes(g); /* first estimate */ |
1608 | break; | 1608 | break; |
1609 | } | 1609 | } |
1610 | case GCSswpallgc: { /* sweep "regular" objects */ | 1610 | case GCSswpallgc: { /* sweep "regular" objects */ |
@@ -119,7 +119,7 @@ CallInfo *luaE_extendCI (lua_State *L) { | |||
119 | /* | 119 | /* |
120 | ** free all CallInfo structures not in use by a thread | 120 | ** free all CallInfo structures not in use by a thread |
121 | */ | 121 | */ |
122 | void luaE_freeCI (lua_State *L) { | 122 | static void freeCI (lua_State *L) { |
123 | CallInfo *ci = L->ci; | 123 | CallInfo *ci = L->ci; |
124 | CallInfo *next = ci->next; | 124 | CallInfo *next = ci->next; |
125 | ci->next = NULL; | 125 | ci->next = NULL; |
@@ -204,7 +204,7 @@ static void freestack (lua_State *L) { | |||
204 | if (L->stack.p == NULL) | 204 | if (L->stack.p == NULL) |
205 | return; /* stack not completely built yet */ | 205 | return; /* stack not completely built yet */ |
206 | L->ci = &L->base_ci; /* free the entire 'ci' list */ | 206 | L->ci = &L->base_ci; /* free the entire 'ci' list */ |
207 | luaE_freeCI(L); | 207 | freeCI(L); |
208 | lua_assert(L->nci == 0); | 208 | lua_assert(L->nci == 0); |
209 | luaM_freearray(L, L->stack.p, stacksize(L) + EXTRA_STACK); /* free stack */ | 209 | luaM_freearray(L, L->stack.p, stacksize(L) + EXTRA_STACK); /* free stack */ |
210 | } | 210 | } |
@@ -396,7 +396,6 @@ union GCUnion { | |||
396 | LUAI_FUNC void luaE_setdebt (global_State *g, l_mem debt); | 396 | LUAI_FUNC void luaE_setdebt (global_State *g, l_mem debt); |
397 | LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1); | 397 | LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1); |
398 | LUAI_FUNC CallInfo *luaE_extendCI (lua_State *L); | 398 | LUAI_FUNC CallInfo *luaE_extendCI (lua_State *L); |
399 | LUAI_FUNC void luaE_freeCI (lua_State *L); | ||
400 | LUAI_FUNC void luaE_shrinkCI (lua_State *L); | 399 | LUAI_FUNC void luaE_shrinkCI (lua_State *L); |
401 | LUAI_FUNC void luaE_checkcstack (lua_State *L); | 400 | LUAI_FUNC void luaE_checkcstack (lua_State *L); |
402 | LUAI_FUNC void luaE_incCstack (lua_State *L); | 401 | LUAI_FUNC void luaE_incCstack (lua_State *L); |