mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add util::capitalized() and Type::categoryName()
This commit is contained in:
@@ -294,6 +294,35 @@ Type const* Type::commonType(Type const* _a, Type const* _b)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
char const* Type::categoryName(Type::Category _category)
|
||||
{
|
||||
switch (_category)
|
||||
{
|
||||
case Category::Address: return "address";
|
||||
case Category::Integer: return "integer";
|
||||
case Category::RationalNumber: return "rational number literal";
|
||||
case Category::StringLiteral: return "string literal";
|
||||
case Category::Bool: return "boolean";
|
||||
case Category::FixedPoint: return "fixed-point number";
|
||||
case Category::Array: return "array";
|
||||
case Category::ArraySlice: return "array slice";
|
||||
case Category::FixedBytes: return "fixed-size byte array";
|
||||
case Category::Contract: return "contract";
|
||||
case Category::Struct: return "struct";
|
||||
case Category::Function: return "function";
|
||||
case Category::Enum: return "enum";
|
||||
case Category::UserDefinedValueType: return "user-defined value type";
|
||||
case Category::Tuple: return "tuple";
|
||||
case Category::Mapping: return "mapping";
|
||||
case Category::TypeType: return "type of a type";
|
||||
case Category::Modifier: return "modifier";
|
||||
case Category::Magic: return "magic variable";
|
||||
case Category::Module: return "module";
|
||||
case Category::InaccessibleDynamic: return "inaccessible dynamic value";
|
||||
}
|
||||
util::unreachable();
|
||||
}
|
||||
|
||||
MemberList const& Type::members(ASTNode const* _currentScope) const
|
||||
{
|
||||
if (!m_members[_currentScope])
|
||||
|
||||
+22
-3
@@ -174,9 +174,26 @@ public:
|
||||
|
||||
enum class Category
|
||||
{
|
||||
Address, Integer, RationalNumber, StringLiteral, Bool, FixedPoint, Array, ArraySlice,
|
||||
FixedBytes, Contract, Struct, Function, Enum, UserDefinedValueType, Tuple,
|
||||
Mapping, TypeType, Modifier, Magic, Module,
|
||||
Address,
|
||||
Integer,
|
||||
RationalNumber,
|
||||
StringLiteral,
|
||||
Bool,
|
||||
FixedPoint,
|
||||
Array,
|
||||
ArraySlice,
|
||||
FixedBytes,
|
||||
Contract,
|
||||
Struct,
|
||||
Function,
|
||||
Enum,
|
||||
UserDefinedValueType,
|
||||
Tuple,
|
||||
Mapping,
|
||||
TypeType,
|
||||
Modifier,
|
||||
Magic,
|
||||
Module,
|
||||
InaccessibleDynamic
|
||||
};
|
||||
|
||||
@@ -184,6 +201,8 @@ public:
|
||||
static Type const* commonType(Type const* _a, Type const* _b);
|
||||
|
||||
virtual Category category() const = 0;
|
||||
static char const* categoryName(Type::Category _category);
|
||||
|
||||
/// @returns a valid solidity identifier such that two types should compare equal if and
|
||||
/// only if they have the same identifier.
|
||||
/// The identifier should start with "t_".
|
||||
|
||||
Reference in New Issue
Block a user