mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	Fix module member access.
This commit is contained in:
		
							parent
							
								
									346fe1c6c5
								
							
						
					
					
						commit
						b2be8e1c0f
					
				| @ -1753,18 +1753,24 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess) | ||||
| 	{ | ||||
| 		Type::Category category = _memberAccess.annotation().type->category(); | ||||
| 		solAssert( | ||||
| 			dynamic_cast<VariableDeclaration const*>(_memberAccess.annotation().referencedDeclaration) || | ||||
| 			dynamic_cast<FunctionDefinition const*>(_memberAccess.annotation().referencedDeclaration) || | ||||
| 			category == Type::Category::TypeType || | ||||
| 			category == Type::Category::Module || | ||||
| 			category == Type::Category::Function, | ||||
| 			category == Type::Category::Module, | ||||
| 			"" | ||||
| 		); | ||||
| 		if (auto funType = dynamic_cast<FunctionType const*>(_memberAccess.annotation().type)) | ||||
| 		if (auto variable = dynamic_cast<VariableDeclaration const*>(_memberAccess.annotation().referencedDeclaration)) | ||||
| 		{ | ||||
| 			auto const* funDef = dynamic_cast<FunctionDefinition const*>(_memberAccess.annotation().referencedDeclaration); | ||||
| 			solAssert(funDef && funDef->isFree(), ""); | ||||
| 			solAssert(variable->isConstant(), ""); | ||||
| 			appendVariable(*variable, static_cast<Expression const&>(_memberAccess)); | ||||
| 		} | ||||
| 		else if (auto const* function = dynamic_cast<FunctionDefinition const*>(_memberAccess.annotation().referencedDeclaration)) | ||||
| 		{ | ||||
| 			auto funType = dynamic_cast<FunctionType const*>(_memberAccess.annotation().type); | ||||
| 			solAssert(function && function->isFree(), ""); | ||||
| 			solAssert(funType->kind() == FunctionType::Kind::Internal, ""); | ||||
| 			solAssert(*_memberAccess.annotation().requiredLookup == VirtualLookup::Static, ""); | ||||
| 			utils().pushCombinedFunctionEntryLabel(*funDef); | ||||
| 			utils().pushCombinedFunctionEntryLabel(*function); | ||||
| 		} | ||||
| 		break; | ||||
| 	} | ||||
|  | ||||
| @ -1871,6 +1871,35 @@ void IRGeneratorForStatements::endVisit(MemberAccess const& _memberAccess) | ||||
| 			solAssert(false, ""); | ||||
| 		break; | ||||
| 	} | ||||
| 	case Type::Category::Module: | ||||
| 	{ | ||||
| 		Type::Category category = _memberAccess.annotation().type->category(); | ||||
| 		solAssert( | ||||
| 			dynamic_cast<VariableDeclaration const*>(_memberAccess.annotation().referencedDeclaration) || | ||||
| 			dynamic_cast<FunctionDefinition const*>(_memberAccess.annotation().referencedDeclaration) || | ||||
| 			category == Type::Category::TypeType || | ||||
| 			category == Type::Category::Module, | ||||
| 			"" | ||||
| 		); | ||||
| 		if (auto variable = dynamic_cast<VariableDeclaration const*>(_memberAccess.annotation().referencedDeclaration)) | ||||
| 		{ | ||||
| 			solAssert(variable->isConstant(), ""); | ||||
| 			handleVariableReference(*variable, static_cast<Expression const&>(_memberAccess)); | ||||
| 		} | ||||
| 		else if (auto const* function = dynamic_cast<FunctionDefinition const*>(_memberAccess.annotation().referencedDeclaration)) | ||||
| 		{ | ||||
| 			auto funType = dynamic_cast<FunctionType const*>(_memberAccess.annotation().type); | ||||
| 			solAssert(function && function->isFree(), ""); | ||||
| 			solAssert(function->functionType(true), ""); | ||||
| 			solAssert(function->functionType(true)->kind() == FunctionType::Kind::Internal, ""); | ||||
| 			solAssert(funType->kind() == FunctionType::Kind::Internal, ""); | ||||
| 			solAssert(*_memberAccess.annotation().requiredLookup == VirtualLookup::Static, ""); | ||||
| 
 | ||||
| 			define(_memberAccess) << to_string(function->id()) << "\n"; | ||||
| 			m_context.internalFunctionAccessed(_memberAccess, *function); | ||||
| 		} | ||||
| 		break; | ||||
| 	} | ||||
| 	default: | ||||
| 		solAssert(false, "Member access to unknown type."); | ||||
| 	} | ||||
| @ -2130,6 +2159,10 @@ void IRGeneratorForStatements::endVisit(Identifier const& _identifier) | ||||
| 	{ | ||||
| 		// no-op
 | ||||
| 	} | ||||
| 	else if (dynamic_cast<ImportDirective const*>(declaration)) | ||||
| 	{ | ||||
| 		// no-op
 | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		solAssert(false, "Identifier type not expected in expression context."); | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user