mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Rename scope to currentContract.
This commit is contained in:
parent
e5c19d8a2c
commit
062159214c
@ -82,7 +82,7 @@ TypePointer const& TypeChecker::type(VariableDeclaration const& _variable) const
|
|||||||
|
|
||||||
bool TypeChecker::visit(ContractDefinition const& _contract)
|
bool TypeChecker::visit(ContractDefinition const& _contract)
|
||||||
{
|
{
|
||||||
m_scope = &_contract;
|
m_currentContract = &_contract;
|
||||||
|
|
||||||
ASTNode::listAccept(_contract.baseContracts(), *this);
|
ASTNode::listAccept(_contract.baseContracts(), *this);
|
||||||
|
|
||||||
@ -266,7 +266,7 @@ void TypeChecker::endVisit(InheritanceSpecifier const& _inheritance)
|
|||||||
auto base = dynamic_cast<ContractDefinition const*>(&dereference(_inheritance.name()));
|
auto base = dynamic_cast<ContractDefinition const*>(&dereference(_inheritance.name()));
|
||||||
solAssert(base, "Base contract not available.");
|
solAssert(base, "Base contract not available.");
|
||||||
|
|
||||||
if (m_scope->isInterface() && !base->isInterface())
|
if (m_currentContract->isInterface() && !base->isInterface())
|
||||||
m_errorReporter.typeError(6536_error, _inheritance.location(), "Interfaces can only inherit from other interfaces.");
|
m_errorReporter.typeError(6536_error, _inheritance.location(), "Interfaces can only inherit from other interfaces.");
|
||||||
|
|
||||||
if (base->isLibrary())
|
if (base->isLibrary())
|
||||||
@ -413,7 +413,7 @@ bool TypeChecker::visit(FunctionDefinition const& _function)
|
|||||||
else
|
else
|
||||||
modifiers.insert(decl);
|
modifiers.insert(decl);
|
||||||
}
|
}
|
||||||
if (m_scope->isInterface())
|
if (m_currentContract->isInterface())
|
||||||
{
|
{
|
||||||
if (_function.isImplemented())
|
if (_function.isImplemented())
|
||||||
m_errorReporter.typeError(4726_error, _function.location(), "Functions in interfaces cannot have an implementation.");
|
m_errorReporter.typeError(4726_error, _function.location(), "Functions in interfaces cannot have an implementation.");
|
||||||
@ -424,7 +424,7 @@ bool TypeChecker::visit(FunctionDefinition const& _function)
|
|||||||
if (_function.isConstructor())
|
if (_function.isConstructor())
|
||||||
m_errorReporter.typeError(6482_error, _function.location(), "Constructor cannot be defined in interfaces.");
|
m_errorReporter.typeError(6482_error, _function.location(), "Constructor cannot be defined in interfaces.");
|
||||||
}
|
}
|
||||||
else if (m_scope->contractKind() == ContractKind::Library)
|
else if (m_currentContract->contractKind() == ContractKind::Library)
|
||||||
if (_function.isConstructor())
|
if (_function.isConstructor())
|
||||||
m_errorReporter.typeError(7634_error, _function.location(), "Constructor cannot be defined in libraries.");
|
m_errorReporter.typeError(7634_error, _function.location(), "Constructor cannot be defined in libraries.");
|
||||||
if (_function.isImplemented())
|
if (_function.isImplemented())
|
||||||
@ -1790,7 +1790,7 @@ void TypeChecker::typeCheckFunctionCall(
|
|||||||
if (_functionType->kind() == FunctionType::Kind::Declaration)
|
if (_functionType->kind() == FunctionType::Kind::Declaration)
|
||||||
{
|
{
|
||||||
if (
|
if (
|
||||||
m_scope->derivesFrom(*_functionType->declaration().annotation().contract) &&
|
m_currentContract->derivesFrom(*_functionType->declaration().annotation().contract) &&
|
||||||
!dynamic_cast<FunctionDefinition const&>(_functionType->declaration()).isImplemented()
|
!dynamic_cast<FunctionDefinition const&>(_functionType->declaration()).isImplemented()
|
||||||
)
|
)
|
||||||
m_errorReporter.typeError(
|
m_errorReporter.typeError(
|
||||||
@ -1912,7 +1912,7 @@ void TypeChecker::typeCheckABIEncodeFunctions(
|
|||||||
bool const isPacked = _functionType->kind() == FunctionType::Kind::ABIEncodePacked;
|
bool const isPacked = _functionType->kind() == FunctionType::Kind::ABIEncodePacked;
|
||||||
solAssert(_functionType->padArguments() != isPacked, "ABI function with unexpected padding");
|
solAssert(_functionType->padArguments() != isPacked, "ABI function with unexpected padding");
|
||||||
|
|
||||||
bool const abiEncoderV2 = m_scope->sourceUnit().annotation().experimentalFeatures.count(
|
bool const abiEncoderV2 = m_currentContract->sourceUnit().annotation().experimentalFeatures.count(
|
||||||
ExperimentalFeature::ABIEncoderV2
|
ExperimentalFeature::ABIEncoderV2
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -2312,7 +2312,7 @@ bool TypeChecker::visit(FunctionCall const& _functionCall)
|
|||||||
case FunctionType::Kind::ABIDecode:
|
case FunctionType::Kind::ABIDecode:
|
||||||
{
|
{
|
||||||
bool const abiEncoderV2 =
|
bool const abiEncoderV2 =
|
||||||
m_scope->sourceUnit().annotation().experimentalFeatures.count(
|
m_currentContract->sourceUnit().annotation().experimentalFeatures.count(
|
||||||
ExperimentalFeature::ABIEncoderV2
|
ExperimentalFeature::ABIEncoderV2
|
||||||
);
|
);
|
||||||
returnTypes = typeCheckABIDecodeAndRetrieveReturnType(_functionCall, abiEncoderV2);
|
returnTypes = typeCheckABIDecodeAndRetrieveReturnType(_functionCall, abiEncoderV2);
|
||||||
@ -2508,13 +2508,13 @@ void TypeChecker::endVisit(NewExpression const& _newExpression)
|
|||||||
if (contract->abstract())
|
if (contract->abstract())
|
||||||
m_errorReporter.typeError(4614_error, _newExpression.location(), "Cannot instantiate an abstract contract.");
|
m_errorReporter.typeError(4614_error, _newExpression.location(), "Cannot instantiate an abstract contract.");
|
||||||
|
|
||||||
solAssert(!!m_scope, "");
|
solAssert(!!m_currentContract, "");
|
||||||
m_scope->annotation().contractDependencies.insert(contract);
|
m_currentContract->annotation().contractDependencies.insert(contract);
|
||||||
solAssert(
|
solAssert(
|
||||||
!contract->annotation().linearizedBaseContracts.empty(),
|
!contract->annotation().linearizedBaseContracts.empty(),
|
||||||
"Linearized base contracts not yet available."
|
"Linearized base contracts not yet available."
|
||||||
);
|
);
|
||||||
if (contractDependenciesAreCyclic(*m_scope))
|
if (contractDependenciesAreCyclic(*m_currentContract))
|
||||||
m_errorReporter.typeError(
|
m_errorReporter.typeError(
|
||||||
4579_error,
|
4579_error,
|
||||||
_newExpression.location(),
|
_newExpression.location(),
|
||||||
@ -2561,7 +2561,7 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess)
|
|||||||
|
|
||||||
// Retrieve the types of the arguments if this is used to call a function.
|
// Retrieve the types of the arguments if this is used to call a function.
|
||||||
auto const& arguments = _memberAccess.annotation().arguments;
|
auto const& arguments = _memberAccess.annotation().arguments;
|
||||||
MemberList::MemberMap possibleMembers = exprType->members(m_scope).membersByName(memberName);
|
MemberList::MemberMap possibleMembers = exprType->members(m_currentContract).membersByName(memberName);
|
||||||
size_t const initialMemberCount = possibleMembers.size();
|
size_t const initialMemberCount = possibleMembers.size();
|
||||||
if (initialMemberCount > 1 && arguments)
|
if (initialMemberCount > 1 && arguments)
|
||||||
{
|
{
|
||||||
@ -2587,7 +2587,7 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess)
|
|||||||
DataLocation::Storage,
|
DataLocation::Storage,
|
||||||
exprType
|
exprType
|
||||||
);
|
);
|
||||||
if (!storageType->members(m_scope).membersByName(memberName).empty())
|
if (!storageType->members(m_currentContract).membersByName(memberName).empty())
|
||||||
m_errorReporter.fatalTypeError(
|
m_errorReporter.fatalTypeError(
|
||||||
4994_error,
|
4994_error,
|
||||||
_memberAccess.location(),
|
_memberAccess.location(),
|
||||||
@ -2743,7 +2743,7 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess)
|
|||||||
{
|
{
|
||||||
annotation.isPure = true;
|
annotation.isPure = true;
|
||||||
ContractType const& accessedContractType = dynamic_cast<ContractType const&>(*magicType->typeArgument());
|
ContractType const& accessedContractType = dynamic_cast<ContractType const&>(*magicType->typeArgument());
|
||||||
m_scope->annotation().contractDependencies.insert(&accessedContractType.contractDefinition());
|
m_currentContract->annotation().contractDependencies.insert(&accessedContractType.contractDefinition());
|
||||||
|
|
||||||
if (
|
if (
|
||||||
memberName == "runtimeCode" &&
|
memberName == "runtimeCode" &&
|
||||||
@ -2755,7 +2755,7 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess)
|
|||||||
"\"runtimeCode\" is not available for contracts containing immutable variables."
|
"\"runtimeCode\" is not available for contracts containing immutable variables."
|
||||||
);
|
);
|
||||||
|
|
||||||
if (contractDependenciesAreCyclic(*m_scope))
|
if (contractDependenciesAreCyclic(*m_currentContract))
|
||||||
m_errorReporter.typeError(
|
m_errorReporter.typeError(
|
||||||
4224_error,
|
4224_error,
|
||||||
_memberAccess.location(),
|
_memberAccess.location(),
|
||||||
|
@ -165,7 +165,7 @@ private:
|
|||||||
/// Runs type checks on @a _expression to infer its type and then checks that it is an LValue.
|
/// Runs type checks on @a _expression to infer its type and then checks that it is an LValue.
|
||||||
void requireLValue(Expression const& _expression, bool _ordinaryAssignment);
|
void requireLValue(Expression const& _expression, bool _ordinaryAssignment);
|
||||||
|
|
||||||
ContractDefinition const* m_scope = nullptr;
|
ContractDefinition const* m_currentContract = nullptr;
|
||||||
|
|
||||||
langutil::EVMVersion m_evmVersion;
|
langutil::EVMVersion m_evmVersion;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user