Skip to content

Commit

Permalink
Merge pull request #127 from OptionalAssistant/master
Browse files Browse the repository at this point in the history
Remove duplicating code
  • Loading branch information
ZehMatt authored May 15, 2024
2 parents bbf0ae5 + 7d8c133 commit e0001ae
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions zasm/src/zasm/src/core/error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ namespace zasm
ErrorCode code;
std::string message;
};
static bool isExtError(std::uint64_t data) noexcept
{
return (data & kErrorExtBit) != 0;
}

// TODO: This is not fully portable so we should check for systems where
// we have to use a different approach.
static ErrorExt* toErrorExt(std::uint64_t data) noexcept
{
assert((data & kErrorExtBit) != 0);
assert(isExtError(data));

auto* ext = reinterpret_cast<ErrorExt*>(data & ~kErrorExtBit);
return ext;
Expand All @@ -27,11 +31,6 @@ namespace zasm
return static_cast<std::uint64_t>(reinterpret_cast<std::uintptr_t>(ext)) | kErrorExtBit;
}

static bool isExtError(std::uint64_t data) noexcept
{
return (data & kErrorExtBit) != 0;
}

Error::Error(const Error& other)
{
if (isExtError(other._data))
Expand Down

0 comments on commit e0001ae

Please sign in to comment.