aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Kirchner <daniel@ekpyron.org>2019-01-17 19:59:11 +0800
committerDaniel Kirchner <daniel@ekpyron.org>2019-01-18 19:11:35 +0800
commita766efc79fbcdf0aa2fc9210b20caf36f4258714 (patch)
treefe22298e25c992aad7cb1c224c8e30f060f71371
parent7c07e9498664c9b9dec6f332490d51c7a920de8b (diff)
downloaddexon-solidity-a766efc79fbcdf0aa2fc9210b20caf36f4258714.tar.gz
dexon-solidity-a766efc79fbcdf0aa2fc9210b20caf36f4258714.tar.zst
dexon-solidity-a766efc79fbcdf0aa2fc9210b20caf36f4258714.zip
Add ContractDefinition::isInterface.
-rw-r--r--libsolidity/analysis/SyntaxChecker.cpp2
-rw-r--r--libsolidity/analysis/TypeChecker.cpp11
-rw-r--r--libsolidity/ast/AST.h1
-rw-r--r--libsolidity/ast/Types.cpp2
4 files changed, 8 insertions, 8 deletions
diff --git a/libsolidity/analysis/SyntaxChecker.cpp b/libsolidity/analysis/SyntaxChecker.cpp
index 066b5004..7b8aa0f2 100644
--- a/libsolidity/analysis/SyntaxChecker.cpp
+++ b/libsolidity/analysis/SyntaxChecker.cpp
@@ -262,7 +262,7 @@ bool SyntaxChecker::visit(PlaceholderStatement const&)
bool SyntaxChecker::visit(ContractDefinition const& _contract)
{
- m_isInterface = _contract.contractKind() == ContractDefinition::ContractKind::Interface;
+ m_isInterface = _contract.isInterface();
ASTString const& contractName = _contract.name();
for (FunctionDefinition const* function: _contract.definedFunctions())
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index 507a2c94..32cafb55 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -204,7 +204,7 @@ void TypeChecker::endVisit(InheritanceSpecifier const& _inheritance)
auto base = dynamic_cast<ContractDefinition const*>(&dereference(_inheritance.name()));
solAssert(base, "Base contract not available.");
- if (m_scope->contractKind() == ContractDefinition::ContractKind::Interface)
+ if (m_scope->isInterface())
m_errorReporter.typeError(_inheritance.location(), "Interfaces cannot inherit.");
if (base->isLibrary())
@@ -212,7 +212,7 @@ void TypeChecker::endVisit(InheritanceSpecifier const& _inheritance)
auto const& arguments = _inheritance.arguments();
TypePointers parameterTypes;
- if (base->contractKind() != ContractDefinition::ContractKind::Interface)
+ if (!base->isInterface())
// Interfaces do not have constructors, so there are zero parameters.
parameterTypes = ContractType(*base).newExpressionType()->parameterTypes();
@@ -325,7 +325,6 @@ bool TypeChecker::visit(FunctionDefinition const& _function)
"This type is only supported in the new experimental ABI encoder. "
"Use \"pragma experimental ABIEncoderV2;\" to enable the feature."
);
-
var->accept(*this);
}
set<Declaration const*> modifiers;
@@ -346,7 +345,7 @@ bool TypeChecker::visit(FunctionDefinition const& _function)
else
modifiers.insert(decl);
}
- if (m_scope->contractKind() == ContractDefinition::ContractKind::Interface)
+ if (m_scope->isInterface())
{
if (_function.isImplemented())
m_errorReporter.typeError(_function.location(), "Functions in interfaces cannot have an implementation.");
@@ -375,7 +374,7 @@ bool TypeChecker::visit(VariableDeclaration const& _variable)
// * a function's input/output parameters,
// * or inside of a struct definition.
if (
- m_scope->contractKind() == ContractDefinition::ContractKind::Interface
+ m_scope->isInterface()
&& !_variable.isCallableParameter()
&& !m_insideStruct
)
@@ -1862,7 +1861,7 @@ void TypeChecker::endVisit(NewExpression const& _newExpression)
if (!contract)
m_errorReporter.fatalTypeError(_newExpression.location(), "Identifier is not a contract.");
- if (contract->contractKind() == ContractDefinition::ContractKind::Interface)
+ if (contract->isInterface())
m_errorReporter.fatalTypeError(_newExpression.location(), "Cannot instantiate an interface.");
if (!contract->annotation().unimplementedFunctions.empty())
{
diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h
index 9ac065ea..3a64a34a 100644
--- a/libsolidity/ast/AST.h
+++ b/libsolidity/ast/AST.h
@@ -394,6 +394,7 @@ public:
std::vector<FunctionDefinition const*> definedFunctions() const { return filteredNodes<FunctionDefinition>(m_subNodes); }
std::vector<EventDefinition const*> events() const { return filteredNodes<EventDefinition>(m_subNodes); }
std::vector<EventDefinition const*> const& interfaceEvents() const;
+ bool isInterface() const { return m_contractKind == ContractKind::Interface; }
bool isLibrary() const { return m_contractKind == ContractKind::Library; }
/// @returns a map of canonical function signatures to FunctionDefinitions
diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp
index cc978b4a..c8280d0f 100644
--- a/libsolidity/ast/Types.cpp
+++ b/libsolidity/ast/Types.cpp
@@ -2525,7 +2525,7 @@ FunctionTypePointer FunctionType::newExpressionType(ContractDefinition const& _c
strings parameterNames;
StateMutability stateMutability = StateMutability::NonPayable;
- solAssert(_contract.contractKind() != ContractDefinition::ContractKind::Interface, "");
+ solAssert(!_contract.isInterface(), "");
if (constructor)
{