mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Minor refactoring
This commit is contained in:
@@ -4,7 +4,7 @@ using namespace std;
|
||||
using namespace dev;
|
||||
using namespace dev::test::abiv2fuzzer;
|
||||
|
||||
string ProtoConverter::appendVarDeclToOutput(
|
||||
string ProtoConverter::getVarDecl(
|
||||
string const& _type,
|
||||
string const& _varName,
|
||||
string const& _qualifier
|
||||
@@ -114,9 +114,7 @@ template <typename T>
|
||||
pair<string, string> ProtoConverter::processType(T const& _type, bool _isValueType)
|
||||
{
|
||||
ostringstream local, global;
|
||||
auto varNames = newVarNames(getNextVarCounter());
|
||||
string varName = varNames.first;
|
||||
string paramName = varNames.second;
|
||||
auto [varName, paramName] = newVarNames(getNextVarCounter());
|
||||
string location{};
|
||||
if (!m_isStateVar && !_isValueType)
|
||||
location = "memory";
|
||||
@@ -160,9 +158,9 @@ pair<string, string> ProtoConverter::varDecl(
|
||||
|
||||
// variable declaration
|
||||
if (m_isStateVar)
|
||||
global << appendVarDeclToOutput(typeStr, _varName, _location);
|
||||
global << getVarDecl(typeStr, _varName, _location);
|
||||
else
|
||||
local << appendVarDeclToOutput(typeStr, _varName, _location);
|
||||
local << getVarDecl(typeStr, _varName, _location);
|
||||
|
||||
// Add typed params for calling public and external functions with said type
|
||||
appendTypedParams(
|
||||
@@ -312,7 +310,7 @@ std::string ProtoConverter::typedParametersAsString(CalleeType _calleeType)
|
||||
}
|
||||
}
|
||||
|
||||
/// Test function to be called externally.
|
||||
// Test function to be called externally.
|
||||
string ProtoConverter::visit(TestFunction const& _x, string const& _storageVarDefs)
|
||||
{
|
||||
// TODO: Support more than one but less than N local variables
|
||||
@@ -491,10 +489,10 @@ pragma experimental ABIEncoderV2;)";
|
||||
string testFunction = visit(_x.testfunction(), storageVarDefs);
|
||||
/* Structure of contract body
|
||||
* - Storage variable declarations
|
||||
* - Struct type declarations
|
||||
* - Struct definitions
|
||||
* - Test function
|
||||
* - Storage variable definitions
|
||||
* - Local variable definitions
|
||||
* - Storage variable assignments
|
||||
* - Local variable definitions and assignments
|
||||
* - Test code proper (calls public and external functions)
|
||||
* - Helper functions
|
||||
*/
|
||||
@@ -557,8 +555,13 @@ string TypeVisitor::visit(ArrayType const& _type)
|
||||
string("]") :
|
||||
string("[]");
|
||||
m_baseType += arrayBraces;
|
||||
if (!_type.is_static())
|
||||
m_isLastDynParamRightPadded = true;
|
||||
|
||||
// If we don't know yet if the array will be dynamically encoded,
|
||||
// check again. If we already know that it will be, there's no
|
||||
// need to do anything.
|
||||
if (!m_isLastDynParamRightPadded)
|
||||
m_isLastDynParamRightPadded = DynParamVisitor().visit(_type);
|
||||
|
||||
return baseType + arrayBraces;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user