aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-08-29 23:07:32 +0800
committerchriseth <chris@ethereum.org>2017-09-06 19:50:49 +0800
commit342367d5dcb897d1ef3bbc00853538859773ed37 (patch)
treea8201102ef9e0176e33b1cc35783a4dd7c7abfca
parenteacee5b25c1edbcf3e32128bd28bce5e58fc2a74 (diff)
downloaddexon-solidity-342367d5dcb897d1ef3bbc00853538859773ed37.tar.gz
dexon-solidity-342367d5dcb897d1ef3bbc00853538859773ed37.tar.zst
dexon-solidity-342367d5dcb897d1ef3bbc00853538859773ed37.zip
Store super function.
-rw-r--r--libsolidity/analysis/TypeChecker.cpp3
-rw-r--r--libsolidity/analysis/TypeChecker.h1
-rw-r--r--libsolidity/ast/ASTAnnotations.h3
-rw-r--r--libsolidity/ast/ASTJsonConverter.cpp1
4 files changed, 8 insertions, 0 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index c46485d8..966ca560 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -315,6 +315,9 @@ void TypeChecker::checkFunctionOverride(FunctionDefinition const& function, Func
if (!functionType.hasEqualArgumentTypes(superType))
return;
+ if (!function.annotation().superFunction)
+ function.annotation().superFunction = &super;
+
if (function.visibility() != super.visibility())
overrideError(function, super, "Overriding function visibility differs.");
diff --git a/libsolidity/analysis/TypeChecker.h b/libsolidity/analysis/TypeChecker.h
index f2e13765..0c6f54d3 100644
--- a/libsolidity/analysis/TypeChecker.h
+++ b/libsolidity/analysis/TypeChecker.h
@@ -63,6 +63,7 @@ private:
void checkContractDuplicateFunctions(ContractDefinition const& _contract);
void checkContractIllegalOverrides(ContractDefinition const& _contract);
/// Reports a type error with an appropiate message if overriden function signature differs.
+ /// Also stores the direct super function in the AST annotations.
void checkFunctionOverride(FunctionDefinition const& function, FunctionDefinition const& super);
void overrideError(FunctionDefinition const& function, FunctionDefinition const& super, std::string message);
void checkContractAbstractFunctions(ContractDefinition const& _contract);
diff --git a/libsolidity/ast/ASTAnnotations.h b/libsolidity/ast/ASTAnnotations.h
index fd9efb4d..3d4236cc 100644
--- a/libsolidity/ast/ASTAnnotations.h
+++ b/libsolidity/ast/ASTAnnotations.h
@@ -94,6 +94,9 @@ struct ContractDefinitionAnnotation: TypeDeclarationAnnotation, DocumentedAnnota
struct FunctionDefinitionAnnotation: ASTAnnotation, DocumentedAnnotation
{
+ /// The function this function overrides, if any. This is always the closest
+ /// in the linearized inheritance hierarchy.
+ FunctionDefinition const* superFunction = nullptr;
};
struct EventDefinitionAnnotation: ASTAnnotation, DocumentedAnnotation
diff --git a/libsolidity/ast/ASTJsonConverter.cpp b/libsolidity/ast/ASTJsonConverter.cpp
index afc53bfe..6811d3e4 100644
--- a/libsolidity/ast/ASTJsonConverter.cpp
+++ b/libsolidity/ast/ASTJsonConverter.cpp
@@ -328,6 +328,7 @@ bool ASTJsonConverter::visit(FunctionDefinition const& _node)
make_pair(m_legacy ? "constant" : "isDeclaredConst", _node.stateMutability() <= StateMutability::View),
make_pair("payable", _node.isPayable()),
make_pair("stateMutability", stateMutabilityToString(_node.stateMutability())),
+ make_pair("superFunction", idOrNull(_node.annotation().superFunction)),
make_pair("visibility", Declaration::visibilityToString(_node.visibility())),
make_pair("parameters", toJson(_node.parameterList())),
make_pair("isConstructor", _node.isConstructor()),