aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/codegen
diff options
context:
space:
mode:
authorhydai <z54981220@gmail.com>2018-11-29 16:34:17 +0800
committerhydai <z54981220@gmail.com>2018-11-29 17:07:18 +0800
commit9326adc3db513353da51d9732d1c92b33ecd4d16 (patch)
treeacc49affdc911984d67a37fe7e61c8bc4bca94c6 /libsolidity/codegen
parentb4086ac87037813eb553e92839bbc40de6bbd9ac (diff)
downloaddexon-solidity-9326adc3db513353da51d9732d1c92b33ecd4d16.tar
dexon-solidity-9326adc3db513353da51d9732d1c92b33ecd4d16.tar.gz
dexon-solidity-9326adc3db513353da51d9732d1c92b33ecd4d16.tar.bz2
dexon-solidity-9326adc3db513353da51d9732d1c92b33ecd4d16.tar.lz
dexon-solidity-9326adc3db513353da51d9732d1c92b33ecd4d16.tar.xz
dexon-solidity-9326adc3db513353da51d9732d1c92b33ecd4d16.tar.zst
dexon-solidity-9326adc3db513353da51d9732d1c92b33ecd4d16.zip
Replace IntegerType(256) with static function IntegerType::uint256()
Diffstat (limited to 'libsolidity/codegen')
-rw-r--r--libsolidity/codegen/ABIFunctions.cpp2
-rw-r--r--libsolidity/codegen/CompilerUtils.cpp18
-rw-r--r--libsolidity/codegen/CompilerUtils.h2
-rw-r--r--libsolidity/codegen/ExpressionCompiler.cpp16
4 files changed, 19 insertions, 19 deletions
diff --git a/libsolidity/codegen/ABIFunctions.cpp b/libsolidity/codegen/ABIFunctions.cpp
index bd29b382..b02623de 100644
--- a/libsolidity/codegen/ABIFunctions.cpp
+++ b/libsolidity/codegen/ABIFunctions.cpp
@@ -558,7 +558,7 @@ string ABIFunctions::abiEncodingFunction(
// special case: convert storage reference type to value type - this is only
// possible for library calls where we just forward the storage reference
solAssert(_encodeAsLibraryTypes, "");
- solAssert(to == IntegerType(256), "");
+ solAssert(to == IntegerType::uint256(), "");
templ("cleanupConvert", "value");
}
else
diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp
index 93c8cc77..7d2ad9d2 100644
--- a/libsolidity/codegen/CompilerUtils.cpp
+++ b/libsolidity/codegen/CompilerUtils.cpp
@@ -136,7 +136,7 @@ void CompilerUtils::loadFromMemoryDynamic(
void CompilerUtils::storeInMemory(unsigned _offset)
{
- unsigned numBytes = prepareMemoryStore(IntegerType(256), true);
+ unsigned numBytes = prepareMemoryStore(IntegerType::uint256(), true);
if (numBytes > 0)
m_context << u256(_offset) << Instruction::MSTORE;
}
@@ -150,7 +150,7 @@ void CompilerUtils::storeInMemoryDynamic(Type const& _type, bool _padToWordBound
ref->location() == DataLocation::Memory,
"Only in-memory reference type can be stored."
);
- storeInMemoryDynamic(IntegerType(256), _padToWordBoundaries);
+ storeInMemoryDynamic(IntegerType::uint256(), _padToWordBoundaries);
}
else if (auto str = dynamic_cast<StringLiteralType const*>(&_type))
{
@@ -266,7 +266,7 @@ void CompilerUtils::abiDecode(TypePointers const& _typeParameters, bool _fromMem
if (calldataType->isDynamicallySized())
{
// put on stack: data_pointer length
- loadFromMemoryDynamic(IntegerType(256), !_fromMemory);
+ loadFromMemoryDynamic(IntegerType::uint256(), !_fromMemory);
m_context << Instruction::SWAP1;
// stack: input_end base_offset next_pointer data_offset
m_context.appendInlineAssembly("{ if gt(data_offset, 0x100000000) { revert(0, 0) } }", {"data_offset"});
@@ -277,7 +277,7 @@ void CompilerUtils::abiDecode(TypePointers const& _typeParameters, bool _fromMem
{"input_end", "base_offset", "next_ptr", "array_head_ptr"}
);
// retrieve length
- loadFromMemoryDynamic(IntegerType(256), !_fromMemory, true);
+ loadFromMemoryDynamic(IntegerType::uint256(), !_fromMemory, true);
// stack: input_end base_offset next_pointer array_length data_pointer
m_context << Instruction::SWAP2;
// stack: input_end base_offset data_pointer array_length next_pointer
@@ -430,7 +430,7 @@ void CompilerUtils::encodeToMemory(
{
auto const& strType = dynamic_cast<StringLiteralType const&>(*_givenTypes[i]);
m_context << u256(strType.value().size());
- storeInMemoryDynamic(IntegerType(256), true);
+ storeInMemoryDynamic(IntegerType::uint256(), true);
// stack: ... <end_of_mem'>
storeInMemoryDynamic(strType, _padToWordBoundaries);
}
@@ -445,7 +445,7 @@ void CompilerUtils::encodeToMemory(
m_context << dupInstruction(1 + arrayType.sizeOnStack());
ArrayUtils(m_context).retrieveLength(arrayType, 1);
// stack: ... <end_of_mem> <value...> <end_of_mem'> <length>
- storeInMemoryDynamic(IntegerType(256), true);
+ storeInMemoryDynamic(IntegerType::uint256(), true);
// stack: ... <end_of_mem> <value...> <end_of_mem''>
// copy the new memory pointer
m_context << swapInstruction(arrayType.sizeOnStack() + 1) << Instruction::POP;
@@ -807,7 +807,7 @@ void CompilerUtils::convertType(
allocateMemory();
// stack: mempos
m_context << Instruction::DUP1 << u256(data.size());
- storeInMemoryDynamic(IntegerType(256));
+ storeInMemoryDynamic(IntegerType::uint256());
// stack: mempos datapos
storeStringData(data);
}
@@ -856,7 +856,7 @@ void CompilerUtils::convertType(
if (targetType.isDynamicallySized())
{
m_context << Instruction::DUP2;
- storeInMemoryDynamic(IntegerType(256));
+ storeInMemoryDynamic(IntegerType::uint256());
}
// stack: <mem start> <source ref> (variably sized) <length> <mem data pos>
if (targetType.baseType()->isValueType())
@@ -1210,7 +1210,7 @@ void CompilerUtils::storeStringData(bytesConstRef _data)
for (unsigned i = 0; i < _data.size(); i += 32)
{
m_context << h256::Arith(h256(_data.cropped(i), h256::AlignLeft));
- storeInMemoryDynamic(IntegerType(256));
+ storeInMemoryDynamic(IntegerType::uint256());
}
m_context << Instruction::POP;
}
diff --git a/libsolidity/codegen/CompilerUtils.h b/libsolidity/codegen/CompilerUtils.h
index bd8170ad..5f7dce22 100644
--- a/libsolidity/codegen/CompilerUtils.h
+++ b/libsolidity/codegen/CompilerUtils.h
@@ -69,7 +69,7 @@ public:
/// @returns the number of bytes consumed in memory.
unsigned loadFromMemory(
unsigned _offset,
- Type const& _type = IntegerType(256),
+ Type const& _type = IntegerType::uint256(),
bool _fromCalldata = false,
bool _padToWords = false
);
diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp
index c9a1e076..87eecd2e 100644
--- a/libsolidity/codegen/ExpressionCompiler.cpp
+++ b/libsolidity/codegen/ExpressionCompiler.cpp
@@ -631,7 +631,7 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall)
_functionCall.expression().accept(*this);
arguments.front()->accept(*this);
- utils().convertType(*arguments.front()->annotation().type, IntegerType(256), true);
+ utils().convertType(*arguments.front()->annotation().type, IntegerType::uint256(), true);
// Note that function is not the original function, but the ".gas" function.
// Its values of gasSet and valueSet is equal to the original function's though.
unsigned stackDepth = (function.gasSet() ? 1 : 0) + (function.valueSet() ? 1 : 0);
@@ -814,13 +814,13 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall)
case FunctionType::Kind::MulMod:
{
arguments[2]->accept(*this);
- utils().convertType(*arguments[2]->annotation().type, IntegerType(256));
+ utils().convertType(*arguments[2]->annotation().type, IntegerType::uint256());
m_context << Instruction::DUP1 << Instruction::ISZERO;
m_context.appendConditionalInvalid();
for (unsigned i = 1; i < 3; i ++)
{
arguments[2 - i]->accept(*this);
- utils().convertType(*arguments[2 - i]->annotation().type, IntegerType(256));
+ utils().convertType(*arguments[2 - i]->annotation().type, IntegerType::uint256());
}
if (function.kind() == FunctionType::Kind::AddMod)
m_context << Instruction::ADDMOD;
@@ -904,7 +904,7 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall)
// Fetch requested length.
arguments[0]->accept(*this);
- utils().convertType(*arguments[0]->annotation().type, IntegerType(256));
+ utils().convertType(*arguments[0]->annotation().type, IntegerType::uint256());
// Stack: requested_length
utils().fetchFreeMemoryPointer();
@@ -1452,7 +1452,7 @@ bool ExpressionCompiler::visit(IndexAccess const& _indexAccess)
TypePointers{keyType}
);
m_context << Instruction::SWAP1;
- utils().storeInMemoryDynamic(IntegerType(256));
+ utils().storeInMemoryDynamic(IntegerType::uint256());
utils().toSizeAfterFreeMemoryPointer();
}
else
@@ -1461,7 +1461,7 @@ bool ExpressionCompiler::visit(IndexAccess const& _indexAccess)
appendExpressionCopyToMemory(*keyType, *_indexAccess.indexExpression());
m_context << Instruction::SWAP1;
solAssert(CompilerUtils::freeMemoryPointer >= 0x40, "");
- utils().storeInMemoryDynamic(IntegerType(256));
+ utils().storeInMemoryDynamic(IntegerType::uint256());
m_context << u256(0);
}
m_context << Instruction::KECCAK256;
@@ -1474,7 +1474,7 @@ bool ExpressionCompiler::visit(IndexAccess const& _indexAccess)
solAssert(_indexAccess.indexExpression(), "Index expression expected.");
_indexAccess.indexExpression()->accept(*this);
- utils().convertType(*_indexAccess.indexExpression()->annotation().type, IntegerType(256), true);
+ utils().convertType(*_indexAccess.indexExpression()->annotation().type, IntegerType::uint256(), true);
// stack layout: <base_ref> [<length>] <index>
ArrayUtils(m_context).accessIndex(arrayType);
switch (arrayType.location())
@@ -1510,7 +1510,7 @@ bool ExpressionCompiler::visit(IndexAccess const& _indexAccess)
solAssert(_indexAccess.indexExpression(), "Index expression expected.");
_indexAccess.indexExpression()->accept(*this);
- utils().convertType(*_indexAccess.indexExpression()->annotation().type, IntegerType(256), true);
+ utils().convertType(*_indexAccess.indexExpression()->annotation().type, IntegerType::uint256(), true);
// stack layout: <value> <index>
// check out-of-bounds access
m_context << u256(fixedBytesType.numBytes());