Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
out/**/*
build/**/*
build-*/**/*
**/node_modules/**/*
.cache/**/*
*.code-workspace
Expand Down
11 changes: 11 additions & 0 deletions debugger/src/internal/utils/lua_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ class Number {
}
};

class Integer {
public:
static constexpr lua_Type type = LUA_TINTEGER;
static std::string typeName() { return lua_typename(nullptr, type); }
static std::string toString(lua_State* L, int index) {
int64_t value = lua_tointeger64(L, index, nullptr);
return std::format("{}", value);
}
};

class String {
public:
static constexpr lua_Type type = LUA_TSTRING;
Expand Down Expand Up @@ -125,6 +135,7 @@ using RegisteredTypes = TypeList<Nil,
Boolean,
Vector,
Number,
Integer,
String,
LightUserData,
Table,
Expand Down
10 changes: 7 additions & 3 deletions debugger/src/internal/variable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,17 @@ bool Variable::hasGetters(lua_State* L, int value_idx) {
Variable Variable::addField(lua_State* L,
VariableRegistry* registry,
const Scope& scope) {
bool number_index = lua_type(L, -2) == LUA_TNUMBER;
int key_type = lua_type(L, -2);
std::string field_name = lua_utils::type::toString(L, -2);
if (number_index)
if (key_type == LUA_TNUMBER)
field_name = std::format("[{}]", lua_tointeger(L, -2));
else if (key_type == LUA_TINTEGER)
field_name = std::format("[{}]", lua_tointeger64(L, -2, nullptr));
auto variable = registry->createVariable(L, field_name, scope.getLevel());
if (number_index)
if (key_type == LUA_TNUMBER)
variable.index_ = lua_tointeger(L, -2);
else if (key_type == LUA_TINTEGER)
variable.index_ = static_cast<int>(lua_tointeger64(L, -2, nullptr));
return variable;
}

Expand Down
Loading