[isoltest] Reworks (default) ABI Type construction.

This commit is contained in:
Erik Kundt 2019-07-21 16:04:04 +02:00
parent d9b98bf7af
commit 07051f41d2
2 changed files with 24 additions and 3 deletions

View File

@ -14,6 +14,7 @@
#pragma once #pragma once
#include <libdevcore/AnsiColorized.h>
#include <libdevcore/CommonData.h> #include <libdevcore/CommonData.h>
#include <libsolidity/ast/Types.h> #include <libsolidity/ast/Types.h>
@ -111,9 +112,23 @@ struct ABIType
AlignRight, AlignRight,
AlignNone, AlignNone,
}; };
explicit ABIType(
Type _type,
Align _align = ABIType::AlignRight,
size_t _size = 32
): type(_type), align(_align), size(_size) {}
ABIType(ABIType const& _other):
type(_other.type),
align(_other.align),
size(_other.size),
alignDeclared(_other.alignDeclared)
{}
Type type = ABIType::None; Type type = ABIType::None;
Align align = ABIType::AlignRight; Align align = ABIType::AlignRight;
size_t size = 0; size_t size = 32;
bool alignDeclared = false; bool alignDeclared = false;
}; };
@ -130,7 +145,7 @@ struct FormatInfo
* Parameter abstraction used for the encoding and decoding of * Parameter abstraction used for the encoding and decoding of
* function parameter and expectation / return value lists. * function parameter and expectation / return value lists.
* A parameter list is usually a comma-separated list of literals. * A parameter list is usually a comma-separated list of literals.
* It should not be possible to call create a parameter holding * It should not be possible to create a parameter holding
* an identifier, but if so, the ABI type would be invalid. * an identifier, but if so, the ABI type would be invalid.
*/ */
struct Parameter struct Parameter
@ -154,12 +169,17 @@ struct Parameter
/// Types that were used to encode `rawBytes`. Expectations /// Types that were used to encode `rawBytes`. Expectations
/// are usually comma separated literals. Their type is auto- /// are usually comma separated literals. Their type is auto-
/// detected and retained in order to format them later on. /// detected and retained in order to format them later on.
ABIType abiType; ABIType abiType = ABIType{ABIType::UnsignedDec, ABIType::AlignRight, 32};
/// Format info attached to the parameter. It handles newlines given /// Format info attached to the parameter. It handles newlines given
/// in the declaration of it. /// in the declaration of it.
FormatInfo format; FormatInfo format;
/// Stores the parsed alignment, which can be either left(...) or right(...). /// Stores the parsed alignment, which can be either left(...) or right(...).
Alignment alignment = Alignment::None; Alignment alignment = Alignment::None;
/// Compares _bytes to the bytes stored in this object.
bool matchesBytes(bytes const& _bytes) const
{
return rawBytes == _bytes;
}
}; };
using ParameterList = std::vector<Parameter>; using ParameterList = std::vector<Parameter>;

View File

@ -234,6 +234,7 @@ Parameter TestFileParser::parseParameter()
parameter.format.newline = true; parameter.format.newline = true;
m_lineNumber++; m_lineNumber++;
} }
parameter.abiType = ABIType{ABIType::None, ABIType::AlignNone, 0};
bool isSigned = false; bool isSigned = false;
if (accept(Token::Left, true)) if (accept(Token::Left, true))