aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/codegen/ExpressionCompiler.cpp
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-09-27 05:10:30 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-09-27 18:32:19 +0800
commit204214f0700179e3d8fa97c77d4f92acd349f015 (patch)
tree26838663fe5b2a890eceee50434db778c802ca13 /libsolidity/codegen/ExpressionCompiler.cpp
parenta657d3b1a165d9ec14f9875db2380954f9ca37cf (diff)
downloaddexon-solidity-204214f0700179e3d8fa97c77d4f92acd349f015.tar.gz
dexon-solidity-204214f0700179e3d8fa97c77d4f92acd349f015.tar.zst
dexon-solidity-204214f0700179e3d8fa97c77d4f92acd349f015.zip
Split encodeToMemory to packedEncode and abiEncode
Diffstat (limited to 'libsolidity/codegen/ExpressionCompiler.cpp')
-rw-r--r--libsolidity/codegen/ExpressionCompiler.cpp26
1 files changed, 11 insertions, 15 deletions
diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp
index 5de24136..c2bf0f5c 100644
--- a/libsolidity/codegen/ExpressionCompiler.cpp
+++ b/libsolidity/codegen/ExpressionCompiler.cpp
@@ -581,7 +581,7 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall)
_context << Instruction::ADD;
}
);
- utils().encodeToMemory(argumentTypes, function.parameterTypes(), true, false);
+ utils().abiEncode(argumentTypes, function.parameterTypes());
// now on stack: memory_end_ptr
// need: size, offset, endowment
utils().toSizeAfterFreeMemoryPointer();
@@ -675,7 +675,8 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall)
argumentTypes.push_back(arg->annotation().type);
}
utils().fetchFreeMemoryPointer();
- utils().encodeToMemory(argumentTypes, TypePointers(), function.padArguments(), true);
+ solAssert(!function.padArguments(), "");
+ utils().packedEncode(argumentTypes, TypePointers());
utils().toSizeAfterFreeMemoryPointer();
m_context << Instruction::KECCAK256;
break;
@@ -694,11 +695,10 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall)
}
arguments.front()->accept(*this);
utils().fetchFreeMemoryPointer();
- utils().encodeToMemory(
+ utils().packedEncode(
{arguments.front()->annotation().type},
- {function.parameterTypes().front()},
- false,
- true);
+ {function.parameterTypes().front()}
+ );
utils().toSizeAfterFreeMemoryPointer();
m_context << logInstruction(logNumber);
break;
@@ -717,11 +717,9 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall)
if (auto const& arrayType = dynamic_pointer_cast<ArrayType const>(function.parameterTypes()[arg - 1]))
{
utils().fetchFreeMemoryPointer();
- utils().encodeToMemory(
+ utils().packedEncode(
{arguments[arg - 1]->annotation().type},
- {arrayType},
- false,
- true
+ {arrayType}
);
utils().toSizeAfterFreeMemoryPointer();
m_context << Instruction::KECCAK256;
@@ -751,7 +749,7 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall)
nonIndexedParamTypes.push_back(function.parameterTypes()[arg]);
}
utils().fetchFreeMemoryPointer();
- utils().encodeToMemory(nonIndexedArgTypes, nonIndexedParamTypes, true, false);
+ utils().abiEncode(nonIndexedArgTypes, nonIndexedParamTypes);
// need: topic1 ... topicn memsize memstart
utils().toSizeAfterFreeMemoryPointer();
m_context << logInstruction(numIndexed);
@@ -1212,11 +1210,9 @@ bool ExpressionCompiler::visit(IndexAccess const& _indexAccess)
utils().fetchFreeMemoryPointer();
// stack: base index mem
// note: the following operations must not allocate memory!
- utils().encodeToMemory(
+ utils().packedEncode(
TypePointers{_indexAccess.indexExpression()->annotation().type},
- TypePointers{keyType},
- false,
- true
+ TypePointers{keyType}
);
m_context << Instruction::SWAP1;
utils().storeInMemoryDynamic(IntegerType(256));