aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/ast
diff options
context:
space:
mode:
authorYoichi Hirai <i@yoichihirai.com>2017-03-09 00:49:14 +0800
committerGitHub <noreply@github.com>2017-03-09 00:49:14 +0800
commite364909e063cf95922b9611b3d25fb0a4199e43f (patch)
treeb235903bb5c2825f5b99e1534c59a922350c4859 /libsolidity/ast
parent3f9a7758348a30c4c65a99054e1e1055d1bb20c0 (diff)
parenta3cb69b14b13a64deda8a71387e480a0eec45698 (diff)
downloaddexon-solidity-e364909e063cf95922b9611b3d25fb0a4199e43f.tar.gz
dexon-solidity-e364909e063cf95922b9611b3d25fb0a4199e43f.tar.zst
dexon-solidity-e364909e063cf95922b9611b3d25fb0a4199e43f.zip
Merge pull request #1747 from ethereum/fixICEInternalConstructor
Move privateness of constructor into AST itself.
Diffstat (limited to 'libsolidity/ast')
-rw-r--r--libsolidity/ast/AST.cpp46
-rw-r--r--libsolidity/ast/AST.h2
-rw-r--r--libsolidity/ast/ASTAnnotations.h2
3 files changed, 28 insertions, 22 deletions
diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp
index 616de54e..03112d2d 100644
--- a/libsolidity/ast/AST.cpp
+++ b/libsolidity/ast/AST.cpp
@@ -83,7 +83,7 @@ SourceUnitAnnotation& SourceUnit::annotation() const
{
if (!m_annotation)
m_annotation = new SourceUnitAnnotation();
- return static_cast<SourceUnitAnnotation&>(*m_annotation);
+ return dynamic_cast<SourceUnitAnnotation&>(*m_annotation);
}
string Declaration::sourceUnitName() const
@@ -99,7 +99,7 @@ ImportAnnotation& ImportDirective::annotation() const
{
if (!m_annotation)
m_annotation = new ImportAnnotation();
- return static_cast<ImportAnnotation&>(*m_annotation);
+ return dynamic_cast<ImportAnnotation&>(*m_annotation);
}
TypePointer ImportDirective::type() const
@@ -132,6 +132,12 @@ FunctionDefinition const* ContractDefinition::constructor() const
return nullptr;
}
+bool ContractDefinition::constructorIsPublic() const
+{
+ FunctionDefinition const* f = constructor();
+ return !f || f->isPublic();
+}
+
FunctionDefinition const* ContractDefinition::fallbackFunction() const
{
for (ContractDefinition const* contract: annotation().linearizedBaseContracts)
@@ -255,14 +261,14 @@ ContractDefinitionAnnotation& ContractDefinition::annotation() const
{
if (!m_annotation)
m_annotation = new ContractDefinitionAnnotation();
- return static_cast<ContractDefinitionAnnotation&>(*m_annotation);
+ return dynamic_cast<ContractDefinitionAnnotation&>(*m_annotation);
}
TypeNameAnnotation& TypeName::annotation() const
{
if (!m_annotation)
m_annotation = new TypeNameAnnotation();
- return static_cast<TypeNameAnnotation&>(*m_annotation);
+ return dynamic_cast<TypeNameAnnotation&>(*m_annotation);
}
TypePointer StructDefinition::type() const
@@ -274,7 +280,7 @@ TypeDeclarationAnnotation& StructDefinition::annotation() const
{
if (!m_annotation)
m_annotation = new TypeDeclarationAnnotation();
- return static_cast<TypeDeclarationAnnotation&>(*m_annotation);
+ return dynamic_cast<TypeDeclarationAnnotation&>(*m_annotation);
}
TypePointer EnumValue::type() const
@@ -293,7 +299,7 @@ TypeDeclarationAnnotation& EnumDefinition::annotation() const
{
if (!m_annotation)
m_annotation = new TypeDeclarationAnnotation();
- return static_cast<TypeDeclarationAnnotation&>(*m_annotation);
+ return dynamic_cast<TypeDeclarationAnnotation&>(*m_annotation);
}
shared_ptr<FunctionType> FunctionDefinition::functionType(bool _internal) const
@@ -349,7 +355,7 @@ FunctionDefinitionAnnotation& FunctionDefinition::annotation() const
{
if (!m_annotation)
m_annotation = new FunctionDefinitionAnnotation();
- return static_cast<FunctionDefinitionAnnotation&>(*m_annotation);
+ return dynamic_cast<FunctionDefinitionAnnotation&>(*m_annotation);
}
TypePointer ModifierDefinition::type() const
@@ -361,7 +367,7 @@ ModifierDefinitionAnnotation& ModifierDefinition::annotation() const
{
if (!m_annotation)
m_annotation = new ModifierDefinitionAnnotation();
- return static_cast<ModifierDefinitionAnnotation&>(*m_annotation);
+ return dynamic_cast<ModifierDefinitionAnnotation&>(*m_annotation);
}
TypePointer EventDefinition::type() const
@@ -381,14 +387,14 @@ EventDefinitionAnnotation& EventDefinition::annotation() const
{
if (!m_annotation)
m_annotation = new EventDefinitionAnnotation();
- return static_cast<EventDefinitionAnnotation&>(*m_annotation);
+ return dynamic_cast<EventDefinitionAnnotation&>(*m_annotation);
}
UserDefinedTypeNameAnnotation& UserDefinedTypeName::annotation() const
{
if (!m_annotation)
m_annotation = new UserDefinedTypeNameAnnotation();
- return static_cast<UserDefinedTypeNameAnnotation&>(*m_annotation);
+ return dynamic_cast<UserDefinedTypeNameAnnotation&>(*m_annotation);
}
bool VariableDeclaration::isLValue() const
@@ -460,70 +466,70 @@ VariableDeclarationAnnotation& VariableDeclaration::annotation() const
{
if (!m_annotation)
m_annotation = new VariableDeclarationAnnotation();
- return static_cast<VariableDeclarationAnnotation&>(*m_annotation);
+ return dynamic_cast<VariableDeclarationAnnotation&>(*m_annotation);
}
StatementAnnotation& Statement::annotation() const
{
if (!m_annotation)
m_annotation = new StatementAnnotation();
- return static_cast<StatementAnnotation&>(*m_annotation);
+ return dynamic_cast<StatementAnnotation&>(*m_annotation);
}
InlineAssemblyAnnotation& InlineAssembly::annotation() const
{
if (!m_annotation)
m_annotation = new InlineAssemblyAnnotation();
- return static_cast<InlineAssemblyAnnotation&>(*m_annotation);
+ return dynamic_cast<InlineAssemblyAnnotation&>(*m_annotation);
}
ReturnAnnotation& Return::annotation() const
{
if (!m_annotation)
m_annotation = new ReturnAnnotation();
- return static_cast<ReturnAnnotation&>(*m_annotation);
+ return dynamic_cast<ReturnAnnotation&>(*m_annotation);
}
VariableDeclarationStatementAnnotation& VariableDeclarationStatement::annotation() const
{
if (!m_annotation)
m_annotation = new VariableDeclarationStatementAnnotation();
- return static_cast<VariableDeclarationStatementAnnotation&>(*m_annotation);
+ return dynamic_cast<VariableDeclarationStatementAnnotation&>(*m_annotation);
}
ExpressionAnnotation& Expression::annotation() const
{
if (!m_annotation)
m_annotation = new ExpressionAnnotation();
- return static_cast<ExpressionAnnotation&>(*m_annotation);
+ return dynamic_cast<ExpressionAnnotation&>(*m_annotation);
}
MemberAccessAnnotation& MemberAccess::annotation() const
{
if (!m_annotation)
m_annotation = new MemberAccessAnnotation();
- return static_cast<MemberAccessAnnotation&>(*m_annotation);
+ return dynamic_cast<MemberAccessAnnotation&>(*m_annotation);
}
BinaryOperationAnnotation& BinaryOperation::annotation() const
{
if (!m_annotation)
m_annotation = new BinaryOperationAnnotation();
- return static_cast<BinaryOperationAnnotation&>(*m_annotation);
+ return dynamic_cast<BinaryOperationAnnotation&>(*m_annotation);
}
FunctionCallAnnotation& FunctionCall::annotation() const
{
if (!m_annotation)
m_annotation = new FunctionCallAnnotation();
- return static_cast<FunctionCallAnnotation&>(*m_annotation);
+ return dynamic_cast<FunctionCallAnnotation&>(*m_annotation);
}
IdentifierAnnotation& Identifier::annotation() const
{
if (!m_annotation)
m_annotation = new IdentifierAnnotation();
- return static_cast<IdentifierAnnotation&>(*m_annotation);
+ return dynamic_cast<IdentifierAnnotation&>(*m_annotation);
}
bool Literal::looksLikeAddress() const
diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h
index 743fdaa1..8031760d 100644
--- a/libsolidity/ast/AST.h
+++ b/libsolidity/ast/AST.h
@@ -356,6 +356,8 @@ public:
/// Returns the constructor or nullptr if no constructor was specified.
FunctionDefinition const* constructor() const;
+ /// @returns true iff the constructor of this contract is public (or non-existing).
+ bool constructorIsPublic() const;
/// Returns the fallback function or nullptr if no fallback function was specified.
FunctionDefinition const* fallbackFunction() const;
diff --git a/libsolidity/ast/ASTAnnotations.h b/libsolidity/ast/ASTAnnotations.h
index 61e97a55..9c4c3ae8 100644
--- a/libsolidity/ast/ASTAnnotations.h
+++ b/libsolidity/ast/ASTAnnotations.h
@@ -80,8 +80,6 @@ struct ContractDefinitionAnnotation: TypeDeclarationAnnotation, DocumentedAnnota
{
/// Whether all functions are implemented.
bool isFullyImplemented = true;
- /// Whether a public constructor (even the default one) is available.
- bool hasPublicConstructor = true;
/// List of all (direct and indirect) base contracts in order from derived to
/// base, including the contract itself.
std::vector<ContractDefinition const*> linearizedBaseContracts;