Skip to content

Commit e7d7d06

Browse files
authored
Merge pull request #59 from NiceAndPeter/claude/plan-next-phases-018745gk6jh49vs9yoxYQvuP
Plan next project phases
2 parents 346bf5b + 254bca3 commit e7d7d06

File tree

8 files changed

+34
-18
lines changed

8 files changed

+34
-18
lines changed

src/compiler/lopcodes.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "lprefix.h"
1111

1212

13+
#include <array>
1314
#include "lopcodes.h"
1415

1516

@@ -19,7 +20,7 @@
1920

2021
/* ORDER OP */
2122

22-
LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = {
23+
LUAI_DDEF const OpModesArray luaP_opmodes = {
2324
/* MM OT IT T A mode opcode */
2425
opmode(0, 0, 0, 0, 1, OpMode::iABC) /* OP_MOVE */
2526
,opmode(0, 0, 0, 0, 1, OpMode::iAsBx) /* OP_LOADI */

src/compiler/lopcodes.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#ifndef lopcodes_h
88
#define lopcodes_h
99

10+
#include <array>
1011
#include "llimits.h"
1112
#include "lobject.h"
1213

@@ -548,7 +549,8 @@ inline constexpr int NUM_OPCODES = ((int)(OP_EXTRAARG) + 1);
548549
** bit 7: instruction is an MM instruction (call a metamethod)
549550
*/
550551

551-
LUAI_DDEC(const lu_byte luaP_opmodes[NUM_OPCODES];)
552+
using OpModesArray = std::array<lu_byte, NUM_OPCODES>;
553+
LUAI_DDEC(const OpModesArray luaP_opmodes;)
552554

553555
inline OpMode getOpMode(int m) noexcept {
554556
return static_cast<OpMode>(luaP_opmodes[m] & 7);

src/compiler/lparser.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#ifndef lparser_h
88
#define lparser_h
99

10+
#include <span>
1011
#include "llimits.h"
1112
#include "lobject.h"
1213
#include "lopcodes.h"
@@ -277,6 +278,14 @@ class Dyndata {
277278
return &actvar_vec.back();
278279
}
279280

281+
/* Phase 116: std::span accessors for actvar array */
282+
inline std::span<Vardesc> actvarGetSpan() noexcept {
283+
return std::span(actvar_vec.data(), actvar_vec.size());
284+
}
285+
inline std::span<const Vardesc> actvarGetSpan() const noexcept {
286+
return std::span(actvar_vec.data(), actvar_vec.size());
287+
}
288+
280289
/* Legacy accessor interface for backward compatibility */
281290
class ActvarAccessor {
282291
private:

src/core/ltm.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "lprefix.h"
1111

1212

13+
#include <array>
1314
#include <cstring>
1415

1516
#include "lua.h"
@@ -27,7 +28,7 @@
2728

2829
static const char udatatypename[] = "userdata";
2930

30-
LUAI_DDEF const char *const luaT_typenames_[LUA_TOTALTYPES] = {
31+
LUAI_DDEF const TypeNamesArray luaT_typenames_ = {
3132
"no value",
3233
"nil", "boolean", udatatypename, "number",
3334
"string", "table", "function", udatatypename, "thread",
@@ -36,7 +37,7 @@ LUAI_DDEF const char *const luaT_typenames_[LUA_TOTALTYPES] = {
3637

3738

3839
void luaT_init (lua_State *L) {
39-
static const char *const luaT_eventname[] = { /* ORDER TM */
40+
static constexpr std::array<const char*, 25> luaT_eventname = { /* ORDER TM */
4041
"__index", "__newindex",
4142
"__gc", "__mode", "__len", "__eq",
4243
"__add", "__sub", "__mul", "__mod", "__pow",

src/core/ltm.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#define ltm_h
99

1010

11+
#include <array>
1112
#include "lobject.h"
1213

1314

@@ -78,7 +79,8 @@ struct lua_State;
7879
inline const TValue* gfasttm(global_State* g, const Table* mt, TMS e) noexcept;
7980
inline const TValue* fasttm(lua_State* l, const Table* mt, TMS e) noexcept;
8081

81-
LUAI_DDEC(const char *const luaT_typenames_[LUA_TOTALTYPES];)
82+
using TypeNamesArray = std::array<const char*, LUA_TOTALTYPES>;
83+
LUAI_DDEC(const TypeNamesArray luaT_typenames_;)
8284

8385
inline const char* ttypename(int x) noexcept {
8486
return luaT_typenames_[x + 1];

src/libraries/lstrlib.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,8 @@ static const char *classend (MatchState *ms, const char *p) {
420420
}
421421

422422

423-
static int match_class (int c, int cl) {
424-
int res;
423+
static bool match_class (int c, int cl) {
424+
bool res;
425425
switch (tolower(cl)) {
426426
case 'a' : res = isalpha(c); break;
427427
case 'c' : res = iscntrl(c); break;
@@ -440,10 +440,10 @@ static int match_class (int c, int cl) {
440440
}
441441

442442

443-
static int matchbracketclass (int c, const char *p, const char *ec) {
444-
int sig = 1;
443+
static bool matchbracketclass (int c, const char *p, const char *ec) {
444+
bool sig = true;
445445
if (*(p+1) == '^') {
446-
sig = 0;
446+
sig = false;
447447
p++; /* skip the '^' */
448448
}
449449
while (++p < ec) {
@@ -463,14 +463,14 @@ static int matchbracketclass (int c, const char *p, const char *ec) {
463463
}
464464

465465

466-
static int singlematch (MatchState *ms, const char *s, const char *p,
466+
static bool singlematch (MatchState *ms, const char *s, const char *p,
467467
const char *ep) {
468468
if (s >= ms->src_end)
469-
return 0;
469+
return false;
470470
else {
471471
int c = cast_uchar(*s);
472472
switch (*p) {
473-
case '.': return 1; /* matches any char */
473+
case '.': return true; /* matches any char */
474474
case L_ESC: return match_class(c, cast_uchar(*(p+1)));
475475
case '[': return matchbracketclass(c, p, ep-1);
476476
default: return (cast_uchar(*p) == c);

src/objects/ltable.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ static inline Node *mainpositionfromnode (const Table *t, Node *nd) {
371371
** anything. (In particular, 'next' will return some other valid item
372372
** on the table or nil.)
373373
*/
374-
static int equalkey (const TValue *k1, const Node *n2, int deadok) {
374+
static bool equalkey (const TValue *k1, const Node *n2, int deadok) {
375375
if (rawtt(k1) != n2->getKeyType()) { /* not the same variants? */
376376
if (n2->isKeyShrStr() && ttislngstring(k1)) {
377377
/* an external string can be equal to a short-string key */
@@ -382,12 +382,12 @@ static int equalkey (const TValue *k1, const Node *n2, int deadok) {
382382
return gcvalue(k1) == gcvalueraw(n2->getKeyValue());
383383
}
384384
else
385-
return 0; /* otherwise, different variants cannot be equal */
385+
return false; /* otherwise, different variants cannot be equal */
386386
}
387387
else { /* equal variants */
388388
switch (n2->getKeyType()) {
389389
case LUA_VNIL: case LUA_VFALSE: case LUA_VTRUE:
390-
return 1;
390+
return true;
391391
case LUA_VNUMINT:
392392
return (ivalue(k1) == n2->getKeyIntValue());
393393
case LUA_VNUMFLT:
@@ -1132,7 +1132,7 @@ static TValue *getintfromhash (Table *t, lua_Integer key) {
11321132
}
11331133

11341134

1135-
static int hashkeyisempty (Table *t, lua_Unsigned key) {
1135+
static bool hashkeyisempty (Table *t, lua_Unsigned key) {
11361136
const TValue *val = getintfromhash(t, l_castU2S(key));
11371137
return isempty(val);
11381138
}

src/vm/lopnames.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
#if !defined(lopnames_h)
88
#define lopnames_h
99

10+
#include <array>
1011
#include <cstddef>
1112

1213

1314
/* ORDER OP */
1415

15-
static const char *const opnames[] = {
16+
static constexpr std::array<const char*, 84> opnames = {
1617
"MOVE",
1718
"LOADI",
1819
"LOADF",

0 commit comments

Comments
 (0)