Skip to content

Commit

Permalink
style: pre-commit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Nov 4, 2022
1 parent 62f58a6 commit 52d6532
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 19 deletions.
5 changes: 3 additions & 2 deletions include/slang/numeric/ConstantValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,9 @@ class SLANG_EXPORT ConstantValue {
Variant& getVariant() { return value; }
const Variant& getVariant() const { return value; }

std::string toString(bitwidth_t abbreviateThresholdBits = SVInt::DefaultStringAbbreviationThresholdBits,
bool exactUnknowns = false, bool useAssignmentPatterns = false) const;
std::string toString(
bitwidth_t abbreviateThresholdBits = SVInt::DefaultStringAbbreviationThresholdBits,
bool exactUnknowns = false, bool useAssignmentPatterns = false) const;
size_t hash() const;

[[nodiscard]] bool empty() const;
Expand Down
11 changes: 6 additions & 5 deletions include/slang/numeric/SVInt.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,14 +296,15 @@ class SLANG_EXPORT SVInt : SVIntStorage {
static SVInt createFillZ(bitwidth_t bitWidth, bool isSigned);

[[nodiscard]] size_t hash() const;
void writeTo(SmallVectorBase<char>& buffer, LiteralBase base, bitwidth_t
abbreviateThresholdBits = DefaultStringAbbreviationThresholdBits) const;
void writeTo(SmallVectorBase<char>& buffer, LiteralBase base,
bitwidth_t abbreviateThresholdBits = DefaultStringAbbreviationThresholdBits) const;
void writeTo(SmallVectorBase<char>& buffer, LiteralBase base, bool includeBase,
bitwidth_t abbreviateThresholdBits = MAX_BITS) const;
std::string toString(bitwidth_t abbreviateThresholdBits =
DefaultStringAbbreviationThresholdBits, bool exactUnknowns = false) const;
std::string toString(
bitwidth_t abbreviateThresholdBits = DefaultStringAbbreviationThresholdBits,
bool exactUnknowns = false) const;
std::string toString(LiteralBase base, bitwidth_t abbreviateThresholdBits =
DefaultStringAbbreviationThresholdBits) const;
DefaultStringAbbreviationThresholdBits) const;
std::string toString(LiteralBase base, bool includeBase,
bitwidth_t abbreviateThresholdBits = MAX_BITS) const;

Expand Down
15 changes: 10 additions & 5 deletions source/ast/types/TypePrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ void TypePrinter::visit(const EnumType& type, string_view overrideName) {
}
buffer->append("}");

if (options.skipScopedTypeNames);
if (options.skipScopedTypeNames)
;
else if (!overrideName.empty())
buffer->append(overrideName);
else {
Expand Down Expand Up @@ -147,7 +148,8 @@ void TypePrinter::visit(const PackedStructType& type, string_view overrideName)

appendMembers(type);

if (options.skipScopedTypeNames);
if (options.skipScopedTypeNames)
;
else if (!overrideName.empty())
buffer->append(overrideName);
else {
Expand All @@ -173,7 +175,8 @@ void TypePrinter::visit(const PackedUnionType& type, string_view overrideName) {

appendMembers(type);

if (options.skipScopedTypeNames);
if (options.skipScopedTypeNames)
;
else if (!overrideName.empty())
buffer->append(overrideName);
else {
Expand Down Expand Up @@ -248,7 +251,8 @@ void TypePrinter::visit(const UnpackedStructType& type, string_view overrideName
buffer->append("struct");
appendMembers(type);

if (options.skipScopedTypeNames);
if (options.skipScopedTypeNames)
;
else if (!overrideName.empty())
buffer->append(overrideName);
else {
Expand All @@ -271,7 +275,8 @@ void TypePrinter::visit(const UnpackedUnionType& type, string_view overrideName)
buffer->append("union");
appendMembers(type);

if (options.skipScopedTypeNames);
if (options.skipScopedTypeNames)
;
else if (!overrideName.empty())
buffer->append(overrideName);
else {
Expand Down
21 changes: 14 additions & 7 deletions source/numeric/ConstantValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ std::string ConstantValue::toString(bitwidth_t abbreviateThresholdBits, bool exa
FormatBuffer buffer;
buffer.append(useAssignmentPatterns ? "'{"sv : "["sv);
for (auto& element : arg) {
buffer.append(element.toString(abbreviateThresholdBits, exactUnknowns, useAssignmentPatterns));
buffer.append(element.toString(abbreviateThresholdBits, exactUnknowns,
useAssignmentPatterns));
buffer.append(",");
}

Expand All @@ -55,12 +56,16 @@ std::string ConstantValue::toString(bitwidth_t abbreviateThresholdBits, bool exa
FormatBuffer buffer;
buffer.append(useAssignmentPatterns ? "'{"sv : "["sv);
for (auto& [key, val] : *arg)
buffer.format("{}:{},", key.toString(abbreviateThresholdBits, exactUnknowns, useAssignmentPatterns),
val.toString(abbreviateThresholdBits, exactUnknowns, useAssignmentPatterns));
buffer.format("{}:{},",
key.toString(abbreviateThresholdBits, exactUnknowns,
useAssignmentPatterns),
val.toString(abbreviateThresholdBits, exactUnknowns,
useAssignmentPatterns));

if (arg->defaultValue)
buffer.format("default:{}", arg->defaultValue.toString(abbreviateThresholdBits,
exactUnknowns, useAssignmentPatterns));
buffer.format("default:{}",
arg->defaultValue.toString(abbreviateThresholdBits, exactUnknowns,
useAssignmentPatterns));
else if (!arg->empty())
buffer.pop_back();

Expand All @@ -71,7 +76,8 @@ std::string ConstantValue::toString(bitwidth_t abbreviateThresholdBits, bool exa
FormatBuffer buffer;
buffer.append(useAssignmentPatterns ? "'{"sv : "["sv);
for (auto& element : *arg) {
buffer.append(element.toString(abbreviateThresholdBits, exactUnknowns, useAssignmentPatterns));
buffer.append(element.toString(abbreviateThresholdBits, exactUnknowns,
useAssignmentPatterns));
buffer.append(",");
}

Expand All @@ -85,7 +91,8 @@ std::string ConstantValue::toString(bitwidth_t abbreviateThresholdBits, bool exa
return "(unset)"s;

return fmt::format("({}) {}", *arg->activeMember,
arg->value.toString(abbreviateThresholdBits, exactUnknowns, useAssignmentPatterns));
arg->value.toString(abbreviateThresholdBits, exactUnknowns,
useAssignmentPatterns));
}
else {
static_assert(always_false<T>::value, "Missing case");
Expand Down

0 comments on commit 52d6532

Please sign in to comment.