mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
WIP: error type
This commit is contained in:
parent
d808302c62
commit
f70ffa4f4b
@ -594,6 +594,47 @@ private:
|
||||
ASTPointer<TypeName> m_typeName;
|
||||
};
|
||||
|
||||
template <typename AnnotationT>
|
||||
class CompositeType: public Declaration
|
||||
{
|
||||
public:
|
||||
CompositeType(
|
||||
int64_t _id,
|
||||
SourceLocation const& _location,
|
||||
ASTPointer<ASTString> const& _name,
|
||||
std::vector<ASTPointer<VariableDeclaration>> _members
|
||||
):
|
||||
Declaration(_id, _location, _name), m_members(std::move(_members)) {}
|
||||
|
||||
void accept(ASTVisitor& _visitor) override;
|
||||
void accept(ASTConstVisitor& _visitor) const override;
|
||||
|
||||
std::vector<ASTPointer<VariableDeclaration>> const& members() const { return m_members; }
|
||||
|
||||
TypePointer type() const override
|
||||
{
|
||||
return TypeProvider::typeType(TypeProvider::errorType(*this, DataLocation::Storage));
|
||||
}
|
||||
|
||||
bool isVisibleInDerivedContracts() const override { return true; }
|
||||
bool isVisibleViaContractTypeAccess() const override { return true; }
|
||||
|
||||
AnnotationT& annotation() const override;
|
||||
|
||||
private:
|
||||
std::vector<ASTPointer<VariableDeclaration>> m_members;
|
||||
};
|
||||
using ErrorDefinition = CompositeType<ErrorDeclarationAnnotation>;
|
||||
TypePointer ErrorDefinition::type() const
|
||||
{
|
||||
}
|
||||
|
||||
ErrorDeclarationAnnotation& ErrorDefinition::annotation() const
|
||||
{
|
||||
return initAnnotation<ErrorDeclarationAnnotation>();
|
||||
}
|
||||
|
||||
|
||||
class StructDefinition: public Declaration
|
||||
{
|
||||
public:
|
||||
|
@ -138,6 +138,11 @@ struct StructDeclarationAnnotation: TypeDeclarationAnnotation
|
||||
std::optional<bool> recursive;
|
||||
};
|
||||
|
||||
struct ErrorDeclarationAnnotation: TypeDeclarationAnnotation
|
||||
{
|
||||
// currently no annotations
|
||||
};
|
||||
|
||||
struct ContractDefinitionAnnotation: TypeDeclarationAnnotation, StructurallyDocumentedAnnotation
|
||||
{
|
||||
/// List of functions and modifiers without a body. Can also contain functions from base classes.
|
||||
|
@ -47,6 +47,7 @@ class ContractDefinition;
|
||||
class InheritanceSpecifier;
|
||||
class UsingForDirective;
|
||||
class StructDefinition;
|
||||
class ErrorDefinition;
|
||||
class EnumDefinition;
|
||||
class EnumValue;
|
||||
class ParameterList;
|
||||
|
@ -171,11 +171,12 @@ public:
|
||||
enum class Category
|
||||
{
|
||||
Address, Integer, RationalNumber, StringLiteral, Bool, FixedPoint, Array, ArraySlice,
|
||||
FixedBytes, Contract, Struct, Function, Enum, Tuple,
|
||||
FixedBytes, Contract, Struct, Error, Function, Enum, Tuple,
|
||||
Mapping, TypeType, Modifier, Magic, Module,
|
||||
InaccessibleDynamic
|
||||
};
|
||||
|
||||
|
||||
/// @returns a pointer to _a or _b if the other is implicitly convertible to it or nullptr otherwise
|
||||
static TypePointer commonType(Type const* _a, Type const* _b);
|
||||
|
||||
@ -1002,6 +1003,14 @@ private:
|
||||
mutable std::optional<TypeResult> m_interfaceType_library;
|
||||
};
|
||||
|
||||
class ErrorType: public StructType
|
||||
{
|
||||
public:
|
||||
explicit ErrorType(ErrorDefinition const& _def):
|
||||
StructType{_def, DataLocation::Memory}
|
||||
{}
|
||||
};
|
||||
|
||||
/**
|
||||
* The type of an enum instance, there is one distinct type per enum definition.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user