From d67322a1861d60a88151f7c25d6c3478a9a39acf Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Wed, 14 Nov 2018 17:11:55 +0100 Subject: Introduce namespace `langutil` in liblangutil directory. Also: - Use {}-style list initialisation for SourceLocation construction - Introduce new system includes - Changes the API of the Scanner to take source as value (with move) as opposed to as a reference --- libsolidity/codegen/ExpressionCompiler.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'libsolidity/codegen/ExpressionCompiler.cpp') diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index bdf91fbf..57b513d2 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -36,6 +36,7 @@ #include using namespace std; +using namespace langutil; namespace dev { -- cgit v1.2.3 From 06189ae57f2f556f21499938fca8f9c0db82779e Mon Sep 17 00:00:00 2001 From: Leonardo Alt Date: Mon, 19 Nov 2018 15:17:39 +0100 Subject: Add assert and tests for bound functions --- libsolidity/codegen/ExpressionCompiler.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'libsolidity/codegen/ExpressionCompiler.cpp') diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index 57b513d2..b0d17286 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -529,6 +529,8 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall) { bool shortcutTaken = false; if (auto identifier = dynamic_cast(&_functionCall.expression())) + { + solAssert(!function.bound(), ""); if (auto functionDef = dynamic_cast(identifier->annotation().referencedDeclaration)) { // Do not directly visit the identifier, because this way, we can avoid @@ -537,6 +539,7 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall) utils().pushCombinedFunctionEntryLabel(m_context.resolveVirtualFunction(*functionDef), false); shortcutTaken = true; } + } if (!shortcutTaken) _functionCall.expression().accept(*this); -- cgit v1.2.3 From 30e6f8d3fb9a16dc1e07367c9010aabe3577e2f1 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Thu, 8 Nov 2018 11:22:57 +0100 Subject: Allow mapping arguments for public and external library functions. --- libsolidity/codegen/ExpressionCompiler.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'libsolidity/codegen/ExpressionCompiler.cpp') diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index b0d17286..c9a1e076 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -1873,6 +1873,8 @@ void ExpressionCompiler::appendExternalFunctionCall( retSize = 0; break; } + else if (retType->decodingType()) + retSize += retType->decodingType()->calldataEncodedSize(); else retSize += retType->calldataEncodedSize(); } -- cgit v1.2.3 From 9326adc3db513353da51d9732d1c92b33ecd4d16 Mon Sep 17 00:00:00 2001 From: hydai Date: Thu, 29 Nov 2018 16:34:17 +0800 Subject: Replace IntegerType(256) with static function IntegerType::uint256() --- libsolidity/codegen/ExpressionCompiler.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'libsolidity/codegen/ExpressionCompiler.cpp') 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: [] 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: // check out-of-bounds access m_context << u256(fixedBytesType.numBytes()); -- cgit v1.2.3 From 73a64da041efb2b64b1c89ed6012161cb278e24e Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 29 Nov 2018 19:30:27 +0100 Subject: Fix bug related to state variables of function type accessed via base contract. --- libsolidity/codegen/ExpressionCompiler.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'libsolidity/codegen/ExpressionCompiler.cpp') diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index 87eecd2e..121585d9 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -1153,7 +1153,9 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess) if (dynamic_cast(type->actualType().get())) { solAssert(_memberAccess.annotation().type, "_memberAccess has no type"); - if (auto funType = dynamic_cast(_memberAccess.annotation().type.get())) + if (auto variable = dynamic_cast(_memberAccess.annotation().referencedDeclaration)) + appendVariable(*variable, static_cast(_memberAccess)); + else if (auto funType = dynamic_cast(_memberAccess.annotation().type.get())) { switch (funType->kind()) { @@ -1199,8 +1201,6 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess) { // no-op } - else if (auto variable = dynamic_cast(_memberAccess.annotation().referencedDeclaration)) - appendVariable(*variable, static_cast(_memberAccess)); else _memberAccess.expression().accept(*this); } -- cgit v1.2.3