sys: (s8, s16, s32, s64, s128) -> (i8, i16, i32, i64, i128)
This commit is contained in:
parent
6806f8e5ba
commit
48aacc0c2e
@ -320,8 +320,8 @@ struct MemoryEditor
|
||||
else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_DownArrow)) && DataEditingAddr < mem_size - Cols) { data_editing_addr_next = DataEditingAddr + Cols; DataEditingTakeFocus = true; }
|
||||
else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_LeftArrow)) && DataEditingAddr > 0) { data_editing_addr_next = DataEditingAddr - 1; DataEditingTakeFocus = true; }
|
||||
else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_RightArrow)) && DataEditingAddr < mem_size - 1) { data_editing_addr_next = DataEditingAddr + 1; DataEditingTakeFocus = true; }
|
||||
else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_PageUp)) && DataEditingAddr > 0) { data_editing_addr_next = std::max(s64(0), s64(DataEditingAddr) - s64(visible_count)); DataEditingTakeFocus = true; }
|
||||
else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_PageDown)) && DataEditingAddr < mem_size - 1) { data_editing_addr_next = std::min(s64(mem_size - 1), s64(DataEditingAddr) + s64(visible_count)); DataEditingTakeFocus = true; }
|
||||
else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_PageUp)) && DataEditingAddr > 0) { data_editing_addr_next = std::max<i64>(0, DataEditingAddr - visible_count); DataEditingTakeFocus = true; }
|
||||
else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_PageDown)) && DataEditingAddr < mem_size - 1) { data_editing_addr_next = std::min<i64>(mem_size - 1, DataEditingAddr + visible_count); DataEditingTakeFocus = true; }
|
||||
else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Home)) && DataEditingAddr > 0) { data_editing_addr_next = 0; DataEditingTakeFocus = true; }
|
||||
else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_End)) && DataEditingAddr < mem_size - 1) { data_editing_addr_next = mem_size - 1; DataEditingTakeFocus = true; }
|
||||
} else if (DataPreviewAddr != -1) {
|
||||
@ -329,8 +329,8 @@ struct MemoryEditor
|
||||
else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_DownArrow)) && DataPreviewAddr < mem_size - Cols) { DataPreviewAddr = data_preview_addr_next = DataPreviewAddr + Cols; if (!ImGui::GetIO().KeyShift) DataPreviewAddrEnd = DataPreviewAddr; }
|
||||
else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_LeftArrow)) && DataPreviewAddr > 0) { DataPreviewAddr = data_preview_addr_next = DataPreviewAddr - 1; if (!ImGui::GetIO().KeyShift) DataPreviewAddrEnd = DataPreviewAddr; }
|
||||
else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_RightArrow)) && DataPreviewAddr < mem_size - 1) { DataPreviewAddr = data_preview_addr_next = DataPreviewAddr + 1; if (!ImGui::GetIO().KeyShift) DataPreviewAddrEnd = DataPreviewAddr; }
|
||||
else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_PageUp)) && DataPreviewAddr > 0) { DataPreviewAddr = data_preview_addr_next = std::max(s64(0), s64(DataPreviewAddr) - s64(visible_count)); if (!ImGui::GetIO().KeyShift) DataPreviewAddrEnd = DataPreviewAddr; }
|
||||
else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_PageDown)) && DataPreviewAddr < mem_size - 1) { DataPreviewAddr = data_preview_addr_next = std::min(s64(mem_size - 1), s64(DataPreviewAddr) + s64(visible_count)); if (!ImGui::GetIO().KeyShift) DataPreviewAddrEnd = DataPreviewAddr; }
|
||||
else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_PageUp)) && DataPreviewAddr > 0) { DataPreviewAddr = data_preview_addr_next = std::max<i64>(0, DataPreviewAddr - visible_count); if (!ImGui::GetIO().KeyShift) DataPreviewAddrEnd = DataPreviewAddr; }
|
||||
else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_PageDown)) && DataPreviewAddr < mem_size - 1) { DataPreviewAddr = data_preview_addr_next = std::min<i64>(mem_size - 1, DataPreviewAddr + visible_count); if (!ImGui::GetIO().KeyShift) DataPreviewAddrEnd = DataPreviewAddr; }
|
||||
else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Home)) && DataPreviewAddr > 0) { DataPreviewAddr = data_preview_addr_next = 0; if (!ImGui::GetIO().KeyShift) DataPreviewAddrEnd = DataPreviewAddr; }
|
||||
else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_End)) && DataPreviewAddr < mem_size - 1) { DataPreviewAddr = data_preview_addr_next = mem_size - 1; if (!ImGui::GetIO().KeyShift) DataPreviewAddrEnd = DataPreviewAddr; }
|
||||
}
|
||||
|
@ -12,11 +12,11 @@ using u32 = std::uint32_t;
|
||||
using u64 = std::uint64_t;
|
||||
using u128 = __uint128_t;
|
||||
|
||||
using s8 = std::int8_t;
|
||||
using s16 = std::int16_t;
|
||||
using s32 = std::int32_t;
|
||||
using s64 = std::int64_t;
|
||||
using s128 = __int128_t;
|
||||
using i8 = std::int8_t;
|
||||
using i16 = std::int16_t;
|
||||
using i32 = std::int32_t;
|
||||
using i64 = std::int64_t;
|
||||
using i128 = __int128_t;
|
||||
|
||||
namespace hex {
|
||||
|
||||
|
@ -43,14 +43,14 @@ namespace hex {
|
||||
void load();
|
||||
void store();
|
||||
|
||||
void add(const std::string &unlocalizedCategory, const std::string &unlocalizedName, s64 defaultValue, const Callback &callback);
|
||||
void add(const std::string &unlocalizedCategory, const std::string &unlocalizedName, i64 defaultValue, const Callback &callback);
|
||||
void add(const std::string &unlocalizedCategory, const std::string &unlocalizedName, const std::string &defaultValue, const Callback &callback);
|
||||
|
||||
void write(const std::string &unlocalizedCategory, const std::string &unlocalizedName, s64 value);
|
||||
void write(const std::string &unlocalizedCategory, const std::string &unlocalizedName, i64 value);
|
||||
void write(const std::string &unlocalizedCategory, const std::string &unlocalizedName, const std::string &value);
|
||||
void write(const std::string &unlocalizedCategory, const std::string &unlocalizedName, const std::vector<std::string>& value);
|
||||
|
||||
s64 read(const std::string &unlocalizedCategory, const std::string &unlocalizedName, s64 defaultValue);
|
||||
i64 read(const std::string &unlocalizedCategory, const std::string &unlocalizedName, i64 defaultValue);
|
||||
std::string read(const std::string &unlocalizedCategory, const std::string &unlocalizedName, const std::string &defaultValue);
|
||||
std::vector<std::string> read(const std::string &unlocalizedCategory, const std::string &unlocalizedName, const std::vector<std::string>& defaultValue = { });
|
||||
|
||||
|
@ -13,31 +13,31 @@ namespace hex {
|
||||
struct is_integral_helper<u8> : public std::true_type { };
|
||||
|
||||
template<>
|
||||
struct is_integral_helper<s8> : public std::true_type { };
|
||||
struct is_integral_helper<i8> : public std::true_type { };
|
||||
|
||||
template<>
|
||||
struct is_integral_helper<u16> : public std::true_type { };
|
||||
|
||||
template<>
|
||||
struct is_integral_helper<s16> : public std::true_type { };
|
||||
struct is_integral_helper<i16> : public std::true_type { };
|
||||
|
||||
template<>
|
||||
struct is_integral_helper<u32> : public std::true_type { };
|
||||
|
||||
template<>
|
||||
struct is_integral_helper<s32> : public std::true_type { };
|
||||
struct is_integral_helper<i32> : public std::true_type { };
|
||||
|
||||
template<>
|
||||
struct is_integral_helper<u64> : public std::true_type { };
|
||||
|
||||
template<>
|
||||
struct is_integral_helper<s64> : public std::true_type { };
|
||||
struct is_integral_helper<i64> : public std::true_type { };
|
||||
|
||||
template<>
|
||||
struct is_integral_helper<u128> : public std::true_type { };
|
||||
|
||||
template<>
|
||||
struct is_integral_helper<s128> : public std::true_type { };
|
||||
struct is_integral_helper<i128> : public std::true_type { };
|
||||
|
||||
template<>
|
||||
struct is_integral_helper<bool> : public std::true_type { };
|
||||
@ -65,19 +65,19 @@ namespace hex {
|
||||
struct is_signed_helper : public std::false_type { };
|
||||
|
||||
template<>
|
||||
struct is_signed_helper<s8> : public std::true_type { };
|
||||
struct is_signed_helper<i8> : public std::true_type { };
|
||||
|
||||
template<>
|
||||
struct is_signed_helper<s16> : public std::true_type { };
|
||||
struct is_signed_helper<i16> : public std::true_type { };
|
||||
|
||||
template<>
|
||||
struct is_signed_helper<s32> : public std::true_type { };
|
||||
struct is_signed_helper<i32> : public std::true_type { };
|
||||
|
||||
template<>
|
||||
struct is_signed_helper<s64> : public std::true_type { };
|
||||
struct is_signed_helper<i64> : public std::true_type { };
|
||||
|
||||
template<>
|
||||
struct is_signed_helper<s128> : public std::true_type { };
|
||||
struct is_signed_helper<i128> : public std::true_type { };
|
||||
|
||||
template<>
|
||||
struct is_signed_helper<char> : public std::true_type { };
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
namespace hex {
|
||||
|
||||
enum class Architecture : s32 {
|
||||
enum class Architecture : i32 {
|
||||
ARM,
|
||||
ARM64,
|
||||
MIPS,
|
||||
@ -43,14 +43,14 @@ namespace hex {
|
||||
|
||||
constexpr static const char * const ArchitectureNames[] = { "ARM32", "ARM64", "MIPS", "x86", "PowerPC", "Sparc", "SystemZ", "XCore", "68K", "TMS320C64x", "680X", "Ethereum", "MOS65XX", "WebAssembly", "Berkeley Packet Filter", "RISC-V" };
|
||||
|
||||
static inline s32 getArchitectureSupportedCount() {
|
||||
static s32 supportedCount = -1;
|
||||
static inline i32 getArchitectureSupportedCount() {
|
||||
static i32 supportedCount = -1;
|
||||
|
||||
if (supportedCount != -1) {
|
||||
return supportedCount;
|
||||
}
|
||||
|
||||
for (supportedCount = static_cast<s32>(Architecture::MIN); supportedCount < static_cast<s32>(Architecture::MAX); supportedCount++) {
|
||||
for (supportedCount = static_cast<i32>(Architecture::MIN); supportedCount < static_cast<i32>(Architecture::MAX); supportedCount++) {
|
||||
if (!cs_support(supportedCount)) {
|
||||
break;
|
||||
}
|
||||
|
@ -21,13 +21,13 @@ namespace hex {
|
||||
|
||||
template<typename T>
|
||||
struct Response {
|
||||
s32 code;
|
||||
i32 code;
|
||||
T body;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct Response<void> {
|
||||
s32 code;
|
||||
i32 code;
|
||||
};
|
||||
|
||||
class Net {
|
||||
@ -51,7 +51,7 @@ namespace hex {
|
||||
|
||||
private:
|
||||
void setCommonSettings(std::string &response, const std::string &url, u32 timeout = 2000, const std::map<std::string, std::string> &extraHeaders = { }, const std::string &body = { });
|
||||
std::optional<s32> execute();
|
||||
std::optional<i32> execute();
|
||||
|
||||
friend int progressCallback(void *contents, curl_off_t dlTotal, curl_off_t dlNow, curl_off_t ulTotal, curl_off_t ulNow);
|
||||
private:
|
||||
|
@ -33,7 +33,7 @@ namespace hex {
|
||||
ImVec2 scaled(const ImVec2 &vector);
|
||||
|
||||
std::string to_string(u128 value);
|
||||
std::string to_string(s128 value);
|
||||
std::string to_string(i128 value);
|
||||
|
||||
std::string toByteString(u64 bytes);
|
||||
std::string makePrintable(u8 c);
|
||||
@ -66,8 +66,8 @@ namespace hex {
|
||||
return (value & mask) >> to;
|
||||
}
|
||||
|
||||
constexpr inline s128 signExtend(size_t numBits, s128 value) {
|
||||
s128 mask = 1U << (numBits - 1);
|
||||
constexpr inline i128 signExtend(size_t numBits, i128 value) {
|
||||
i128 mask = 1U << (numBits - 1);
|
||||
return (value ^ mask) - mask;
|
||||
}
|
||||
|
||||
@ -193,7 +193,7 @@ namespace hex {
|
||||
if (number == 0) return "0";
|
||||
|
||||
std::string result;
|
||||
for (s16 bit = hex::bit_width(number) - 1; bit >= 0; bit--)
|
||||
for (i16 bit = hex::bit_width(number) - 1; bit >= 0; bit--)
|
||||
result += (number & (0b1 << bit)) == 0 ? '0' : '1';
|
||||
|
||||
return result;
|
||||
|
@ -189,13 +189,13 @@ namespace hex::pl {
|
||||
return std::visit(overloaded {
|
||||
// TODO: :notlikethis:
|
||||
[this](u128 left, PatternData * const &right) -> ASTNode* { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
[this](s128 left, PatternData * const &right) -> ASTNode* { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
[this](i128 left, PatternData * const &right) -> ASTNode* { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
[this](double left, PatternData * const &right) -> ASTNode* { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
[this](char left, PatternData * const &right) -> ASTNode* { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
[this](bool left, PatternData * const &right) -> ASTNode* { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
[this](std::string left, PatternData * const &right) -> ASTNode* { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
[this](PatternData * const &left, u128 right) -> ASTNode* { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
[this](PatternData * const &left, s128 right) -> ASTNode* { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
[this](PatternData * const &left, i128 right) -> ASTNode* { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
[this](PatternData * const &left, double right) -> ASTNode* { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
[this](PatternData * const &left, char right) -> ASTNode* { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
[this](PatternData * const &left, bool right) -> ASTNode* { LogConsole::abortEvaluation("invalid operand used in mathematical expression", this); },
|
||||
@ -512,15 +512,15 @@ namespace hex::pl {
|
||||
case Token::ValueType::Unsigned128Bit:
|
||||
return new ASTNodeLiteral(u128(endianAdjustedValue));
|
||||
case Token::ValueType::Signed8Bit:
|
||||
return new ASTNodeLiteral(s128(s8(endianAdjustedValue)));
|
||||
return new ASTNodeLiteral(i128(i8(endianAdjustedValue)));
|
||||
case Token::ValueType::Signed16Bit:
|
||||
return new ASTNodeLiteral(s128(s16(endianAdjustedValue)));
|
||||
return new ASTNodeLiteral(i128(i16(endianAdjustedValue)));
|
||||
case Token::ValueType::Signed32Bit:
|
||||
return new ASTNodeLiteral(s128(s32(endianAdjustedValue)));
|
||||
return new ASTNodeLiteral(i128(i32(endianAdjustedValue)));
|
||||
case Token::ValueType::Signed64Bit:
|
||||
return new ASTNodeLiteral(s128(s64(endianAdjustedValue)));
|
||||
return new ASTNodeLiteral(i128(i64(endianAdjustedValue)));
|
||||
case Token::ValueType::Signed128Bit:
|
||||
return new ASTNodeLiteral(s128(endianAdjustedValue));
|
||||
return new ASTNodeLiteral(i128(endianAdjustedValue));
|
||||
case Token::ValueType::Float:
|
||||
return new ASTNodeLiteral(double(float(endianAdjustedValue)));
|
||||
case Token::ValueType::Double:
|
||||
@ -601,7 +601,7 @@ namespace hex::pl {
|
||||
auto variables = *evaluator->getScope(0).scope;
|
||||
u32 startVariableCount = variables.size();
|
||||
ON_SCOPE_EXIT {
|
||||
s64 stackSize = evaluator->getStack().size();
|
||||
i64 stackSize = evaluator->getStack().size();
|
||||
for (u32 i = startVariableCount; i < variables.size(); i++) {
|
||||
stackSize--;
|
||||
delete variables[i];
|
||||
@ -1540,7 +1540,7 @@ namespace hex::pl {
|
||||
readVariable(evaluator, value, pattern);
|
||||
literal = value;
|
||||
} else if (dynamic_cast<PatternDataSigned*>(pattern)) {
|
||||
s128 value = 0;
|
||||
i128 value = 0;
|
||||
readVariable(evaluator, value, pattern);
|
||||
value = hex::signExtend(pattern->getSize() * 8, value);
|
||||
literal = value;
|
||||
@ -1613,7 +1613,7 @@ namespace hex::pl {
|
||||
[[nodiscard]] std::vector<PatternData*> createPatterns(Evaluator *evaluator) const override {
|
||||
std::vector<PatternData*> searchScope;
|
||||
PatternData *currPattern = nullptr;
|
||||
s32 scopeIndex = 0;
|
||||
i32 scopeIndex = 0;
|
||||
|
||||
if (!evaluator->isGlobalScope()){
|
||||
auto globalScope = evaluator->getGlobalScope().scope;
|
||||
@ -1873,7 +1873,7 @@ namespace hex::pl {
|
||||
auto variables = *evaluator->getScope(0).scope;
|
||||
u32 startVariableCount = variables.size();
|
||||
ON_SCOPE_EXIT {
|
||||
s64 stackSize = evaluator->getStack().size();
|
||||
i64 stackSize = evaluator->getStack().size();
|
||||
for (u32 i = startVariableCount; i < variables.size(); i++) {
|
||||
stackSize--;
|
||||
delete variables[i];
|
||||
@ -2325,7 +2325,7 @@ namespace hex::pl {
|
||||
}
|
||||
|
||||
if (this->m_newScope) {
|
||||
s64 stackSize = evaluator->getStack().size();
|
||||
i64 stackSize = evaluator->getStack().size();
|
||||
for (u32 i = startVariableCount; i < variables.size(); i++) {
|
||||
stackSize--;
|
||||
delete variables[i];
|
||||
|
@ -59,7 +59,7 @@ namespace hex::pl {
|
||||
this->m_scopes.pop_back();
|
||||
}
|
||||
|
||||
const Scope& getScope(s32 index) {
|
||||
const Scope& getScope(i32 index) {
|
||||
return this->m_scopes[this->m_scopes.size() - 1 + index];
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ namespace hex::pl {
|
||||
std::vector<TokenIter> m_matchedOptionals;
|
||||
std::vector<std::vector<std::string>> m_currNamespace;
|
||||
|
||||
u32 getLineNumber(s32 index) const {
|
||||
u32 getLineNumber(i32 index) const {
|
||||
return this->m_curr[index].lineNumber;
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ namespace hex::pl {
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
const T& getValue(s32 index) const {
|
||||
const T& getValue(i32 index) const {
|
||||
auto value = std::get_if<T>(&this->m_curr[index].value);
|
||||
|
||||
if (value == nullptr)
|
||||
@ -52,7 +52,7 @@ namespace hex::pl {
|
||||
return *value;
|
||||
}
|
||||
|
||||
Token::Type getType(s32 index) const {
|
||||
Token::Type getType(i32 index) const {
|
||||
return this->m_curr[index].type;
|
||||
}
|
||||
|
||||
@ -141,7 +141,7 @@ namespace hex::pl {
|
||||
return program;
|
||||
}
|
||||
|
||||
[[noreturn]] void throwParseError(const std::string &error, s32 token = -1) const {
|
||||
[[noreturn]] void throwParseError(const std::string &error, i32 token = -1) const {
|
||||
throw ParseError(this->m_curr[token].lineNumber, "Parser: " + error);
|
||||
}
|
||||
|
||||
@ -245,7 +245,7 @@ namespace hex::pl {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool peek(Token::Type type, auto value, s32 index = 0) {
|
||||
bool peek(Token::Type type, auto value, i32 index = 0) {
|
||||
return this->m_curr[index].type == type && this->m_curr[index] == value;
|
||||
}
|
||||
|
||||
|
@ -500,7 +500,7 @@ namespace hex::pl {
|
||||
}
|
||||
|
||||
void createEntry(prv::Provider* &provider) override {
|
||||
s128 data = 0;
|
||||
i128 data = 0;
|
||||
provider->read(this->getOffset(), &data, this->getSize());
|
||||
data = hex::changeEndianess(data, this->getSize(), this->getEndian());
|
||||
|
||||
|
@ -133,7 +133,7 @@ namespace hex::pl {
|
||||
std::string m_identifier;
|
||||
};
|
||||
|
||||
using Literal = std::variant<char, bool, u128, s128, double, std::string, PatternData*>;
|
||||
using Literal = std::variant<char, bool, u128, i128, double, std::string, PatternData*>;
|
||||
using ValueTypes = std::variant<Keyword, Identifier, Operator, Literal, ValueType, Separator>;
|
||||
|
||||
Token(Type type, auto value, u32 lineNumber) : type(type), value(value), lineNumber(lineNumber) {
|
||||
@ -165,11 +165,11 @@ namespace hex::pl {
|
||||
literal);
|
||||
}
|
||||
|
||||
static s128 literalToSigned(const pl::Token::Literal &literal) {
|
||||
static i128 literalToSigned(const pl::Token::Literal &literal) {
|
||||
return std::visit(overloaded {
|
||||
[](std::string) -> s128 { throw std::string("expected integral type, got string"); },
|
||||
[](PatternData*) -> s128 { throw std::string("expected integral type, got custom type"); },
|
||||
[](auto &&value) -> s128 { return value; }
|
||||
[](std::string) -> i128 { throw std::string("expected integral type, got string"); },
|
||||
[](PatternData*) -> i128 { throw std::string("expected integral type, got custom type"); },
|
||||
[](auto &&value) -> i128 { return value; }
|
||||
},
|
||||
literal);
|
||||
}
|
||||
@ -199,7 +199,7 @@ namespace hex::pl {
|
||||
return std::visit(overloaded {
|
||||
[](std::string value) -> std::string { return value; },
|
||||
[](u128 value) -> std::string { return std::to_string(u64(value)); },
|
||||
[](s128 value) -> std::string { return std::to_string(s64(value)); },
|
||||
[](i128 value) -> std::string { return std::to_string(i64(value)); },
|
||||
[](bool value) -> std::string { return value ? "true" : "false"; },
|
||||
[](char value) -> std::string { return std::string() + value; },
|
||||
[](PatternData*) -> std::string { throw std::string("expected integral type, got custom type"); },
|
||||
|
@ -40,7 +40,7 @@ namespace hex {
|
||||
}
|
||||
}
|
||||
|
||||
void ContentRegistry::Settings::add(const std::string &unlocalizedCategory, const std::string &unlocalizedName, s64 defaultValue, const ContentRegistry::Settings::Callback &callback) {
|
||||
void ContentRegistry::Settings::add(const std::string &unlocalizedCategory, const std::string &unlocalizedName, i64 defaultValue, const ContentRegistry::Settings::Callback &callback) {
|
||||
log::info("Registered new integer setting: [{}]: {}", unlocalizedCategory, unlocalizedName);
|
||||
|
||||
ContentRegistry::Settings::getEntries()[unlocalizedCategory.c_str()].emplace_back(Entry{ unlocalizedName.c_str(), callback });
|
||||
@ -66,7 +66,7 @@ namespace hex {
|
||||
json[unlocalizedCategory][unlocalizedName] = std::string(defaultValue);
|
||||
}
|
||||
|
||||
void ContentRegistry::Settings::write(const std::string &unlocalizedCategory, const std::string &unlocalizedName, s64 value) {
|
||||
void ContentRegistry::Settings::write(const std::string &unlocalizedCategory, const std::string &unlocalizedName, i64 value) {
|
||||
auto &json = getSettingsData();
|
||||
|
||||
if (!json.contains(unlocalizedCategory))
|
||||
@ -94,7 +94,7 @@ namespace hex {
|
||||
}
|
||||
|
||||
|
||||
s64 ContentRegistry::Settings::read(const std::string &unlocalizedCategory, const std::string &unlocalizedName, s64 defaultValue) {
|
||||
i64 ContentRegistry::Settings::read(const std::string &unlocalizedCategory, const std::string &unlocalizedName, i64 defaultValue) {
|
||||
auto &json = getSettingsData();
|
||||
|
||||
if (!json.contains(unlocalizedCategory))
|
||||
@ -105,7 +105,7 @@ namespace hex {
|
||||
if (!json[unlocalizedCategory][unlocalizedName].is_number())
|
||||
json[unlocalizedCategory][unlocalizedName] = defaultValue;
|
||||
|
||||
return json[unlocalizedCategory][unlocalizedName].get<s64>();
|
||||
return json[unlocalizedCategory][unlocalizedName].get<i64>();
|
||||
}
|
||||
|
||||
std::string ContentRegistry::Settings::read(const std::string &unlocalizedCategory, const std::string &unlocalizedName, const std::string &defaultValue) {
|
||||
|
@ -115,12 +115,12 @@ namespace hex {
|
||||
curl_easy_setopt(this->m_ctx, CURLOPT_NOPROGRESS, 0L);
|
||||
}
|
||||
|
||||
std::optional<s32> Net::execute() {
|
||||
std::optional<i32> Net::execute() {
|
||||
CURLcode result = curl_easy_perform(this->m_ctx);
|
||||
if (result != CURLE_OK)
|
||||
log::error("Net request failed with error {}!", curl_easy_strerror(result));
|
||||
|
||||
s32 responseCode = 0;
|
||||
i32 responseCode = 0;
|
||||
curl_easy_getinfo(this->m_ctx, CURLINFO_RESPONSE_CODE, &responseCode);
|
||||
|
||||
curl_slist_free_all(this->m_headers);
|
||||
|
@ -44,7 +44,7 @@ namespace hex {
|
||||
return std::string(data + index + 1);
|
||||
}
|
||||
|
||||
std::string to_string(s128 value) {
|
||||
std::string to_string(i128 value) {
|
||||
char data[45] = { 0 };
|
||||
|
||||
u128 unsignedValue = value < 0 ? -value : value;
|
||||
|
@ -22,8 +22,8 @@ namespace hex::pl {
|
||||
|
||||
if (std::get_if<u128>(&value.value()) != nullptr)
|
||||
pattern = new PatternDataUnsigned(0, sizeof(u128), this);
|
||||
else if (std::get_if<s128>(&value.value()) != nullptr)
|
||||
pattern = new PatternDataSigned(0, sizeof(s128), this);
|
||||
else if (std::get_if<i128>(&value.value()) != nullptr)
|
||||
pattern = new PatternDataSigned(0, sizeof(i128), this);
|
||||
else if (std::get_if<double>(&value.value()) != nullptr)
|
||||
pattern = new PatternDataFloat(0, sizeof(double), this);
|
||||
else if (std::get_if<bool>(&value.value()) != nullptr)
|
||||
@ -83,7 +83,7 @@ namespace hex::pl {
|
||||
if (dynamic_cast<PatternDataUnsigned*>(pattern))
|
||||
return u128(value) & bitmask(pattern->getSize() * 8);
|
||||
else if (dynamic_cast<PatternDataSigned*>(pattern))
|
||||
return s128(value) & bitmask(pattern->getSize() * 8);
|
||||
return i128(value) & bitmask(pattern->getSize() * 8);
|
||||
else if (dynamic_cast<PatternDataFloat*>(pattern))
|
||||
return pattern->getSize() == sizeof(float) ? double(float(value)) : value;
|
||||
else
|
||||
@ -105,7 +105,7 @@ namespace hex::pl {
|
||||
if (dynamic_cast<PatternDataUnsigned*>(pattern) || dynamic_cast<PatternDataEnum*>(pattern))
|
||||
return u128(value) & bitmask(pattern->getSize() * 8);
|
||||
else if (dynamic_cast<PatternDataSigned*>(pattern))
|
||||
return s128(value) & bitmask(pattern->getSize() * 8);
|
||||
return i128(value) & bitmask(pattern->getSize() * 8);
|
||||
else if (dynamic_cast<PatternDataCharacter*>(pattern))
|
||||
return char(value);
|
||||
else if (dynamic_cast<PatternDataBoolean*>(pattern))
|
||||
|
@ -108,7 +108,7 @@ namespace hex::pl {
|
||||
|
||||
switch (type) {
|
||||
case Token::ValueType::Unsigned128Bit: return { u128(integer) };
|
||||
case Token::ValueType::Signed128Bit: return { s128(integer) };
|
||||
case Token::ValueType::Signed128Bit: return { i128(integer) };
|
||||
default: return { };
|
||||
}
|
||||
} else if (Token::isFloatingPoint(type)) {
|
||||
|
@ -195,7 +195,7 @@ namespace hex::pl {
|
||||
});
|
||||
|
||||
for (const auto &[define, value, defineLine] : sortedDefines) {
|
||||
s32 index = 0;
|
||||
i32 index = 0;
|
||||
while((index = output.find(define, index)) != std::string::npos) {
|
||||
output.replace(index, define.length(), value);
|
||||
index += value.length();
|
||||
|
@ -57,10 +57,10 @@ namespace hex::prv {
|
||||
auto overlayOffset = overlay->getAddress();
|
||||
auto overlaySize = overlay->getSize();
|
||||
|
||||
s128 overlapMin = std::max(offset, overlayOffset);
|
||||
s128 overlapMax = std::min(offset + size, overlayOffset + overlaySize);
|
||||
i128 overlapMin = std::max(offset, overlayOffset);
|
||||
i128 overlapMax = std::min(offset + size, overlayOffset + overlaySize);
|
||||
if (overlapMax > overlapMin)
|
||||
std::memcpy(static_cast<u8*>(buffer) + std::max<s128>(0, overlapMin - offset), overlay->getData().data() + std::max<s128>(0, overlapMin - overlayOffset), overlapMax - overlapMin);
|
||||
std::memcpy(static_cast<u8*>(buffer) + std::max<i128>(0, overlapMin - offset), overlay->getData().data() + std::max<i128>(0, overlapMin - overlayOffset), overlapMax - overlapMin);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -381,7 +381,7 @@ namespace hex {
|
||||
{
|
||||
ImGui::SetCursorPos(sidebarPos);
|
||||
|
||||
static s32 openWindow = -1;
|
||||
static i32 openWindow = -1;
|
||||
u32 index = 0;
|
||||
ImGui::PushID("SideBarWindows");
|
||||
for (const auto &[icon, callback] : ContentRegistry::Interface::getSidebarItems()) {
|
||||
|
@ -35,11 +35,11 @@ namespace hex::plugin::builtin {
|
||||
SearchFunction m_searchFunction = nullptr;
|
||||
std::vector<std::pair<u64, u64>> *m_lastSearchBuffer;
|
||||
|
||||
s64 m_lastSearchIndex = 0;
|
||||
i64 m_lastSearchIndex = 0;
|
||||
std::vector<std::pair<u64, u64>> m_lastStringSearch;
|
||||
std::vector<std::pair<u64, u64>> m_lastHexSearch;
|
||||
|
||||
s64 m_gotoAddress = 0;
|
||||
i64 m_gotoAddress = 0;
|
||||
|
||||
char m_baseAddressBuffer[0x20] = { 0 };
|
||||
u64 m_resizeSize = 0;
|
||||
|
@ -19,8 +19,8 @@ namespace hex::plugin::builtin {
|
||||
struct YaraMatch {
|
||||
std::string identifier;
|
||||
std::string variable;
|
||||
s64 address;
|
||||
s32 size;
|
||||
i64 address;
|
||||
i32 size;
|
||||
bool wholeDataMatch;
|
||||
};
|
||||
|
||||
|
@ -45,10 +45,10 @@ namespace hex::plugin::builtin {
|
||||
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
||||
});
|
||||
|
||||
ContentRegistry::DataInspector::add("hex.builtin.inspector.s8", sizeof(s8), [](auto buffer, auto endian, auto style) {
|
||||
ContentRegistry::DataInspector::add("hex.builtin.inspector.i8", sizeof(i8), [](auto buffer, auto endian, auto style) {
|
||||
auto format = (style == Style::Decimal) ? "{0}{1:d}" : ((style == Style::Hexadecimal) ? "{0}0x{1:02X}" : "{0}0o{1:03o}");
|
||||
|
||||
auto number = hex::changeEndianess(*reinterpret_cast<s8*>(buffer.data()), endian);
|
||||
auto number = hex::changeEndianess(*reinterpret_cast<i8*>(buffer.data()), endian);
|
||||
bool negative = number < 0;
|
||||
auto value = hex::format(format, negative ? "-" : "", std::abs(number));
|
||||
|
||||
@ -63,10 +63,10 @@ namespace hex::plugin::builtin {
|
||||
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
||||
});
|
||||
|
||||
ContentRegistry::DataInspector::add("hex.builtin.inspector.s16", sizeof(s16), [](auto buffer, auto endian, auto style) {
|
||||
ContentRegistry::DataInspector::add("hex.builtin.inspector.i16", sizeof(i16), [](auto buffer, auto endian, auto style) {
|
||||
auto format = (style == Style::Decimal) ? "{0}{1:d}" : ((style == Style::Hexadecimal) ? "{0}0x{1:04X}" : "{0}0o{1:06o}");
|
||||
|
||||
auto number = hex::changeEndianess(*reinterpret_cast<s16*>(buffer.data()), endian);
|
||||
auto number = hex::changeEndianess(*reinterpret_cast<i16*>(buffer.data()), endian);
|
||||
bool negative = number < 0;
|
||||
auto value = hex::format(format, negative ? "-" : "", std::abs(number));
|
||||
|
||||
@ -81,10 +81,10 @@ namespace hex::plugin::builtin {
|
||||
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
||||
});
|
||||
|
||||
ContentRegistry::DataInspector::add("hex.builtin.inspector.s32", sizeof(s32), [](auto buffer, auto endian, auto style) {
|
||||
ContentRegistry::DataInspector::add("hex.builtin.inspector.i32", sizeof(i32), [](auto buffer, auto endian, auto style) {
|
||||
auto format = (style == Style::Decimal) ? "{0}{1:d}" : ((style == Style::Hexadecimal) ? "{0}0x{1:08X}" : "{0}0o{1:011o}");
|
||||
|
||||
auto number = hex::changeEndianess(*reinterpret_cast<s32*>(buffer.data()), endian);
|
||||
auto number = hex::changeEndianess(*reinterpret_cast<i32*>(buffer.data()), endian);
|
||||
bool negative = number < 0;
|
||||
auto value = hex::format(format, negative ? "-" : "", std::abs(number));
|
||||
|
||||
@ -99,10 +99,10 @@ namespace hex::plugin::builtin {
|
||||
return [value] { ImGui::TextUnformatted(value.c_str()); return value; };
|
||||
});
|
||||
|
||||
ContentRegistry::DataInspector::add("hex.builtin.inspector.s64", sizeof(s64), [](auto buffer, auto endian, auto style) {
|
||||
ContentRegistry::DataInspector::add("hex.builtin.inspector.i64", sizeof(i64), [](auto buffer, auto endian, auto style) {
|
||||
auto format = (style == Style::Decimal) ? "{0}{1:d}" : ((style == Style::Hexadecimal) ? "{0}0x{1:016X}" : "{0}0o{1:022o}");
|
||||
|
||||
auto number = hex::changeEndianess(*reinterpret_cast<s64*>(buffer.data()), endian);
|
||||
auto number = hex::changeEndianess(*reinterpret_cast<i64*>(buffer.data()), endian);
|
||||
bool negative = number < 0;
|
||||
auto value = hex::format(format, negative ? "-" : "", std::abs(number));
|
||||
|
||||
|
@ -173,7 +173,7 @@ namespace hex::plugin::builtin {
|
||||
if (size > 16)
|
||||
LogConsole::abortEvaluation("read size out of range");
|
||||
|
||||
s128 value;
|
||||
i128 value;
|
||||
ctx->getProvider()->read(address, &value, size);
|
||||
return hex::signExtend(size * 8, value);
|
||||
});
|
||||
@ -238,7 +238,7 @@ namespace hex::plugin::builtin {
|
||||
auto string = Token::literalToString(params[0], false);
|
||||
auto base = Token::literalToUnsigned(params[1]);
|
||||
|
||||
return s128(std::strtoll(string.c_str(), nullptr, base));
|
||||
return i128(std::strtoll(string.c_str(), nullptr, base));
|
||||
});
|
||||
|
||||
/* parse_float(string) */
|
||||
|
@ -543,7 +543,7 @@ namespace hex::plugin::builtin {
|
||||
clipper.Begin(links.size());
|
||||
|
||||
while (clipper.Step()) {
|
||||
for (s32 i = clipper.DisplayEnd - 1; i >= clipper.DisplayStart; i--) {
|
||||
for (i32 i = clipper.DisplayEnd - 1; i >= clipper.DisplayStart; i--) {
|
||||
auto &[fileName, link, size] = links[i];
|
||||
|
||||
ImGui::TableNextRow();
|
||||
@ -888,7 +888,7 @@ namespace hex::plugin::builtin {
|
||||
static bool combining = false;
|
||||
static std::vector<std::string> files;
|
||||
static auto outputPath = []{ std::string s; s.reserve(0x1000); return s; }();
|
||||
static s32 selectedIndex;
|
||||
static i32 selectedIndex;
|
||||
|
||||
if (ImGui::BeginTable("files_table", 2, ImGuiTableFlags_SizingStretchProp)) {
|
||||
ImGui::TableSetupColumn("file list", ImGuiTableColumnFlags_NoHeaderLabel, 10);
|
||||
@ -898,7 +898,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
if (ImGui::BeginListBox("##files", { -FLT_MIN, 10 * ImGui::GetTextLineHeightWithSpacing() })) {
|
||||
|
||||
s32 index = 0;
|
||||
i32 index = 0;
|
||||
for (auto &file : files) {
|
||||
if (ImGui::Selectable(fs::path(file).filename().string().c_str(), index == selectedIndex))
|
||||
selectedIndex = index;
|
||||
|
@ -68,7 +68,7 @@ namespace hex::plugin::builtin {
|
||||
enum class DiffResult { Same, Changed, Added, Removed };
|
||||
struct LineInfo {
|
||||
std::vector<u8> bytes;
|
||||
s64 validBytes = 0;
|
||||
i64 validBytes = 0;
|
||||
};
|
||||
|
||||
static DiffResult diffBytes(u8 index, const LineInfo &a, const LineInfo &b) {
|
||||
@ -97,7 +97,7 @@ namespace hex::plugin::builtin {
|
||||
// Read one line of each provider
|
||||
lineInfo[i].bytes.resize(this->m_columnCount);
|
||||
provider->read(row * this->m_columnCount, lineInfo[i].bytes.data(), lineInfo[i].bytes.size());
|
||||
lineInfo[i].validBytes = std::min<s64>(this->m_columnCount, provider->getSize() - row * this->m_columnCount);
|
||||
lineInfo[i].validBytes = std::min<i64>(this->m_columnCount, provider->getSize() - row * this->m_columnCount);
|
||||
|
||||
// Calculate address width
|
||||
u8 addressDigits = 0;
|
||||
@ -122,12 +122,12 @@ namespace hex::plugin::builtin {
|
||||
const ImColor colorDisabled = this->m_greyedOutZeros ? ImGui::GetColorU32(ImGuiCol_TextDisabled) : static_cast<u32>(colorText);
|
||||
|
||||
|
||||
for (s8 curr = 0; curr < 2; curr++) {
|
||||
for (i8 curr = 0; curr < 2; curr++) {
|
||||
auto other = !curr;
|
||||
|
||||
std::optional<ImVec2> lastHighlightEnd;
|
||||
|
||||
for (s64 col = 0; col < lineInfo[curr].validBytes; col++) {
|
||||
for (i64 col = 0; col < lineInfo[curr].validBytes; col++) {
|
||||
auto pos = ImGui::GetCursorScreenPos();
|
||||
|
||||
// Diff bytes
|
||||
|
@ -937,7 +937,7 @@ namespace hex::plugin::builtin {
|
||||
if (ImGui::BeginTabItem("hex.builtin.view.hexeditor.goto.offset.current"_lang)) {
|
||||
ImGui::InputScalar("dec", ImGuiDataType_S64, &this->m_gotoAddress, nullptr, nullptr, "%lld", ImGuiInputTextFlags_CharsDecimal);
|
||||
|
||||
s64 currSelectionOffset = std::min(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd);
|
||||
i64 currSelectionOffset = std::min(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd);
|
||||
|
||||
if (currSelectionOffset + this->m_gotoAddress < 0)
|
||||
this->m_gotoAddress = -currSelectionOffset;
|
||||
@ -1164,7 +1164,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
EventManager::subscribe<QuerySelection>(this, [this](auto ®ion) {
|
||||
u64 address = std::min(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd);
|
||||
size_t size = std::abs(s64(this->m_memoryEditor.DataPreviewAddrEnd) - s64(this->m_memoryEditor.DataPreviewAddr)) + 1;
|
||||
size_t size = std::abs(i64(this->m_memoryEditor.DataPreviewAddrEnd) - i64(this->m_memoryEditor.DataPreviewAddr)) + 1;
|
||||
|
||||
region = Region { address, size };
|
||||
});
|
||||
|
@ -419,9 +419,9 @@ namespace hex::plugin::builtin {
|
||||
ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth());
|
||||
switch (type) {
|
||||
case EnvVarType::Integer: {
|
||||
s64 displayValue = hex::get_or<s128>(value, 0);
|
||||
i64 displayValue = hex::get_or<i128>(value, 0);
|
||||
ImGui::InputScalar("###value", ImGuiDataType_S64, &displayValue);
|
||||
value = s128(displayValue);
|
||||
value = i128(displayValue);
|
||||
break;
|
||||
}
|
||||
case EnvVarType::Float: {
|
||||
@ -449,7 +449,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
if (ImGui::IconButton(ICON_VS_ADD, ImGui::GetStyleColorVec4(ImGuiCol_Text))) {
|
||||
iter++;
|
||||
this->m_envVarEntries.insert(iter, { this->m_envVarIdCounter++, "", s128(0), EnvVarType::Integer });
|
||||
this->m_envVarEntries.insert(iter, { this->m_envVarIdCounter++, "", i128(0), EnvVarType::Integer });
|
||||
iter--;
|
||||
}
|
||||
|
||||
@ -492,9 +492,9 @@ namespace hex::plugin::builtin {
|
||||
ImGui::TextUnformatted(pl::Token::literalToString(variable.value, true).c_str());
|
||||
} else if (variable.inVariable) {
|
||||
if (pl::Token::isSigned(variable.type)) {
|
||||
s64 value = hex::get_or<s128>(variable.value, 0);
|
||||
i64 value = hex::get_or<i128>(variable.value, 0);
|
||||
ImGui::InputScalar("", ImGuiDataType_S64, &value);
|
||||
variable.value = s128(value);
|
||||
variable.value = i128(value);
|
||||
} else if (pl::Token::isUnsigned(variable.type)) {
|
||||
u64 value = hex::get_or<u128>(variable.value, 0);
|
||||
ImGui::InputScalar("", ImGuiDataType_U64, &value);
|
||||
|
@ -360,13 +360,13 @@ namespace hex::plugin::builtin {
|
||||
|
||||
{ "hex.builtin.inspector.binary", "Binär (8 bit)" },
|
||||
{ "hex.builtin.inspector.u8", "uint8_t" },
|
||||
{ "hex.builtin.inspector.s8", "int8_t" },
|
||||
{ "hex.builtin.inspector.i8", "int8_t" },
|
||||
{ "hex.builtin.inspector.u16", "uint16_t" },
|
||||
{ "hex.builtin.inspector.s16", "int16_t" },
|
||||
{ "hex.builtin.inspector.i16", "int16_t" },
|
||||
{ "hex.builtin.inspector.u32", "uint32_t" },
|
||||
{ "hex.builtin.inspector.s32", "int32_t" },
|
||||
{ "hex.builtin.inspector.i32", "int32_t" },
|
||||
{ "hex.builtin.inspector.u64", "uint64_t" },
|
||||
{ "hex.builtin.inspector.s64", "int64_t" },
|
||||
{ "hex.builtin.inspector.i64", "int64_t" },
|
||||
{ "hex.builtin.inspector.float16", "half float (16 bit)" },
|
||||
{ "hex.builtin.inspector.float", "float (32 bit)" },
|
||||
{ "hex.builtin.inspector.double", "double (64 bit)" },
|
||||
|
@ -363,13 +363,13 @@ namespace hex::plugin::builtin {
|
||||
|
||||
{ "hex.builtin.inspector.binary", "Binary (8 bit)" },
|
||||
{ "hex.builtin.inspector.u8", "uint8_t" },
|
||||
{ "hex.builtin.inspector.s8", "int8_t" },
|
||||
{ "hex.builtin.inspector.i8", "int8_t" },
|
||||
{ "hex.builtin.inspector.u16", "uint16_t" },
|
||||
{ "hex.builtin.inspector.s16", "int16_t" },
|
||||
{ "hex.builtin.inspector.i16", "int16_t" },
|
||||
{ "hex.builtin.inspector.u32", "uint32_t" },
|
||||
{ "hex.builtin.inspector.s32", "int32_t" },
|
||||
{ "hex.builtin.inspector.i32", "int32_t" },
|
||||
{ "hex.builtin.inspector.u64", "uint64_t" },
|
||||
{ "hex.builtin.inspector.s64", "int64_t" },
|
||||
{ "hex.builtin.inspector.i64", "int64_t" },
|
||||
{ "hex.builtin.inspector.float16", "half float (16 bit)" },
|
||||
{ "hex.builtin.inspector.float", "float (32 bit)" },
|
||||
{ "hex.builtin.inspector.double", "double (64 bit)" },
|
||||
|
@ -357,13 +357,13 @@ namespace hex::plugin::builtin {
|
||||
|
||||
{ "hex.builtin.inspector.binary", "Binary (8 bit)" },
|
||||
{ "hex.builtin.inspector.u8", "uint8_t" },
|
||||
{ "hex.builtin.inspector.s8", "int8_t" },
|
||||
{ "hex.builtin.inspector.i8", "int8_t" },
|
||||
{ "hex.builtin.inspector.u16", "uint16_t" },
|
||||
{ "hex.builtin.inspector.s16", "int16_t" },
|
||||
{ "hex.builtin.inspector.i16", "int16_t" },
|
||||
{ "hex.builtin.inspector.u32", "uint32_t" },
|
||||
{ "hex.builtin.inspector.s32", "int32_t" },
|
||||
{ "hex.builtin.inspector.i32", "int32_t" },
|
||||
{ "hex.builtin.inspector.u64", "uint64_t" },
|
||||
{ "hex.builtin.inspector.s64", "int64_t" },
|
||||
{ "hex.builtin.inspector.i64", "int64_t" },
|
||||
{ "hex.builtin.inspector.float16", "half float (16 bit)" },
|
||||
{ "hex.builtin.inspector.float", "float (32 bit)" },
|
||||
{ "hex.builtin.inspector.double", "double (64 bit)" },
|
||||
|
@ -358,13 +358,13 @@ namespace hex::plugin::builtin {
|
||||
// Use half width symbols for inspector names because displayable space
|
||||
{ "hex.builtin.inspector.binary", "二进制(8位)" },
|
||||
{ "hex.builtin.inspector.u8", "uint8_t" },
|
||||
{ "hex.builtin.inspector.s8", "int8_t" },
|
||||
{ "hex.builtin.inspector.i8", "int8_t" },
|
||||
{ "hex.builtin.inspector.u16", "uint16_t" },
|
||||
{ "hex.builtin.inspector.s16", "int16_t" },
|
||||
{ "hex.builtin.inspector.i16", "int16_t" },
|
||||
{ "hex.builtin.inspector.u32", "uint32_t" },
|
||||
{ "hex.builtin.inspector.s32", "int32_t" },
|
||||
{ "hex.builtin.inspector.i32", "int32_t" },
|
||||
{ "hex.builtin.inspector.u64", "uint64_t" },
|
||||
{ "hex.builtin.inspector.s64", "int64_t" },
|
||||
{ "hex.builtin.inspector.i64", "int64_t" },
|
||||
{ "hex.builtin.inspector.float16", "半浮点(16位)" },
|
||||
{ "hex.builtin.inspector.float", "float(32位单精度浮点)" },
|
||||
{ "hex.builtin.inspector.double", "double(64位双精度浮点)" },
|
||||
|
@ -11,8 +11,8 @@
|
||||
|
||||
namespace hex {
|
||||
|
||||
s16 comparePrecedence(const Operator& a, const Operator& b) {
|
||||
return (static_cast<s8>(a) & 0x0F0) - (static_cast<s8>(b) & 0x0F0);
|
||||
i16 comparePrecedence(const Operator& a, const Operator& b) {
|
||||
return (static_cast<i8>(a) & 0x0F0) - (static_cast<i8>(b) & 0x0F0);
|
||||
}
|
||||
|
||||
bool isLeftAssociative(const Operator op) {
|
||||
@ -226,13 +226,13 @@ namespace hex {
|
||||
case Operator::Invalid:
|
||||
throw std::invalid_argument("Invalid operator!");
|
||||
case Operator::And:
|
||||
result = static_cast<s64>(leftOperand) && static_cast<s64>(rightOperand);
|
||||
result = static_cast<i64>(leftOperand) && static_cast<i64>(rightOperand);
|
||||
break;
|
||||
case Operator::Or:
|
||||
result = static_cast<s64>(leftOperand) && static_cast<s64>(rightOperand);
|
||||
result = static_cast<i64>(leftOperand) && static_cast<i64>(rightOperand);
|
||||
break;
|
||||
case Operator::Xor:
|
||||
result = (static_cast<s64>(leftOperand) ^ static_cast<s64>(rightOperand)) > 0;
|
||||
result = (static_cast<i64>(leftOperand) ^ static_cast<i64>(rightOperand)) > 0;
|
||||
break;
|
||||
case Operator::GreaterThan:
|
||||
result = leftOperand > rightOperand;
|
||||
@ -253,25 +253,25 @@ namespace hex {
|
||||
result = leftOperand != rightOperand;
|
||||
break;
|
||||
case Operator::Not:
|
||||
result = !static_cast<s64>(rightOperand);
|
||||
result = !static_cast<i64>(rightOperand);
|
||||
break;
|
||||
case Operator::BitwiseOr:
|
||||
result = static_cast<s64>(leftOperand) | static_cast<s64>(rightOperand);
|
||||
result = static_cast<i64>(leftOperand) | static_cast<i64>(rightOperand);
|
||||
break;
|
||||
case Operator::BitwiseXor:
|
||||
result = static_cast<s64>(leftOperand) ^ static_cast<s64>(rightOperand);
|
||||
result = static_cast<i64>(leftOperand) ^ static_cast<i64>(rightOperand);
|
||||
break;
|
||||
case Operator::BitwiseAnd:
|
||||
result = static_cast<s64>(leftOperand) & static_cast<s64>(rightOperand);
|
||||
result = static_cast<i64>(leftOperand) & static_cast<i64>(rightOperand);
|
||||
break;
|
||||
case Operator::BitwiseNot:
|
||||
result = ~static_cast<s64>(rightOperand);
|
||||
result = ~static_cast<i64>(rightOperand);
|
||||
break;
|
||||
case Operator::ShiftLeft:
|
||||
result = static_cast<s64>(leftOperand) << static_cast<s64>(rightOperand);
|
||||
result = static_cast<i64>(leftOperand) << static_cast<i64>(rightOperand);
|
||||
break;
|
||||
case Operator::ShiftRight:
|
||||
result = static_cast<s64>(leftOperand) >> static_cast<s64>(rightOperand);
|
||||
result = static_cast<i64>(leftOperand) >> static_cast<i64>(rightOperand);
|
||||
break;
|
||||
case Operator::Addition:
|
||||
result = leftOperand + rightOperand;
|
||||
|
@ -10,7 +10,7 @@ namespace hex::test {
|
||||
auto testEnum = create<PatternDataEnum>("TestEnum", "testEnum", 0x08, sizeof(u32), nullptr);
|
||||
testEnum->setEnumValues({
|
||||
{ u128(0x0000), "A" },
|
||||
{ s128(0x0C), "B" },
|
||||
{ i128(0x0C), "B" },
|
||||
{ u128(0x0D), "C" },
|
||||
{ u128(0x0E), "D" },
|
||||
});
|
||||
|
@ -7,12 +7,12 @@ namespace hex::test {
|
||||
class TestPatternPadding : public TestPattern {
|
||||
public:
|
||||
TestPatternPadding() : TestPattern("Padding") {
|
||||
auto testStruct = create<PatternDataStruct>("TestStruct", "testStruct", 0x100, sizeof(s32) + 20 + sizeof(u8[0x10]), nullptr);
|
||||
auto testStruct = create<PatternDataStruct>("TestStruct", "testStruct", 0x100, sizeof(i32) + 20 + sizeof(u8[0x10]), nullptr);
|
||||
|
||||
auto variable = create<PatternDataSigned>("s32", "variable", 0x100, sizeof(s32), nullptr);
|
||||
auto padding = create<PatternDataPadding>("padding", "", 0x100 + sizeof(s32), 20, nullptr);
|
||||
auto array = create<PatternDataStaticArray>("u8", "array", 0x100 + sizeof(s32) + 20, sizeof(u8[0x10]), nullptr);
|
||||
array->setEntries(create<PatternDataUnsigned>("u8", "", 0x100 + sizeof(s32) + 20, sizeof(u8), nullptr), 0x10);
|
||||
auto variable = create<PatternDataSigned>("s32", "variable", 0x100, sizeof(i32), nullptr);
|
||||
auto padding = create<PatternDataPadding>("padding", "", 0x100 + sizeof(i32), 20, nullptr);
|
||||
auto array = create<PatternDataStaticArray>("u8", "array", 0x100 + sizeof(i32) + 20, sizeof(u8[0x10]), nullptr);
|
||||
array->setEntries(create<PatternDataUnsigned>("u8", "", 0x100 + sizeof(i32) + 20, sizeof(u8), nullptr), 0x10);
|
||||
|
||||
testStruct->setMembers({ variable, padding, array });
|
||||
|
||||
|
@ -7,11 +7,11 @@ namespace hex::test {
|
||||
class TestPatternStructs : public TestPattern {
|
||||
public:
|
||||
TestPatternStructs() : TestPattern("Structs") {
|
||||
auto testStruct = create<PatternDataStruct>("TestStruct", "testStruct", 0x100, sizeof(s32) + sizeof(u8[0x10]), nullptr);
|
||||
auto testStruct = create<PatternDataStruct>("TestStruct", "testStruct", 0x100, sizeof(i32) + sizeof(u8[0x10]), nullptr);
|
||||
|
||||
auto variable = create<PatternDataSigned>("s32", "variable", 0x100, sizeof(s32), nullptr);
|
||||
auto array = create<PatternDataStaticArray>("u8", "array", 0x100 + sizeof(s32), sizeof(u8[0x10]), nullptr);
|
||||
array->setEntries(create<PatternDataUnsigned>("u8", "", 0x100 + sizeof(s32), sizeof(u8), nullptr), 0x10);
|
||||
auto variable = create<PatternDataSigned>("s32", "variable", 0x100, sizeof(i32), nullptr);
|
||||
auto array = create<PatternDataStaticArray>("u8", "array", 0x100 + sizeof(i32), sizeof(u8[0x10]), nullptr);
|
||||
array->setEntries(create<PatternDataUnsigned>("u8", "", 0x100 + sizeof(i32), sizeof(u8), nullptr), 0x10);
|
||||
|
||||
testStruct->setMembers({ variable, array });
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user