| 2830 | } |
| 2831 | |
| 2832 | FunctionType::FunctionType(FunctionDefinition const& _function, Kind _kind): |
| 2833 | m_kind(_kind), |
| 2834 | m_stateMutability(_function.stateMutability()), |
| 2835 | m_declaration(&_function) |
| 2836 | { |
| 2837 | solAssert( |
| 2838 | _kind == Kind::Internal || _kind == Kind::External || _kind == Kind::Declaration, |
| 2839 | "Only internal or external function types or function declaration types can be created from function definitions." |
| 2840 | ); |
| 2841 | if (_kind == Kind::Internal && m_stateMutability == StateMutability::Payable) |
| 2842 | m_stateMutability = StateMutability::NonPayable; |
| 2843 | |
| 2844 | for (ASTPointer<VariableDeclaration> const& var: _function.parameters()) |
| 2845 | { |
| 2846 | solAssert(var->annotation().type, "Parameter type is not yet available in the AST."); |
| 2847 | m_parameterNames.push_back(var->name()); |
| 2848 | m_parameterTypes.push_back(var->annotation().type); |
| 2849 | } |
| 2850 | for (ASTPointer<VariableDeclaration> const& var: _function.returnParameters()) |
| 2851 | { |
| 2852 | solAssert(var->annotation().type, "Return parameter type is not yet available in the AST."); |
| 2853 | m_returnParameterNames.push_back(var->name()); |
| 2854 | m_returnParameterTypes.push_back(var->annotation().type); |
| 2855 | } |
| 2856 | |
| 2857 | solAssert( |
| 2858 | m_parameterNames.size() == m_parameterTypes.size(), |
| 2859 | "Parameter names list must match parameter types list!" |
| 2860 | ); |
| 2861 | |
| 2862 | solAssert( |
| 2863 | m_returnParameterNames.size() == m_returnParameterTypes.size(), |
| 2864 | "Return parameter names list must match return parameter types list!" |
| 2865 | ); |
| 2866 | } |
| 2867 | |
| 2868 | FunctionType::FunctionType(VariableDeclaration const& _varDecl): |
| 2869 | m_kind(Kind::External), |
nothing calls this directly
no test coverage detected