diff options
| -rw-r--r-- | README.md | 4 | ||||
| -rw-r--r-- | libevmasm/GasMeter.cpp | 3 | ||||
| -rw-r--r-- | libevmasm/Instruction.h | 12 | ||||
| -rw-r--r-- | libsolidity/ast/Types.cpp | 4 |
4 files changed, 18 insertions, 5 deletions
@@ -29,8 +29,10 @@ Instructions about how to build and install the Solidity compiler can be found i A "Hello World" program in Solidity is of even less use than in other languages, but still: ``` +pragma solidity ^0.4.16; + contract HelloWorld { - function f() pure returns (string memory) { + function helloWorld() external pure returns (string memory) { return "Hello, World!"; } } diff --git a/libevmasm/GasMeter.cpp b/libevmasm/GasMeter.cpp index 3554f809..b525c301 100644 --- a/libevmasm/GasMeter.cpp +++ b/libevmasm/GasMeter.cpp @@ -125,8 +125,7 @@ GasMeter::GasConsumption GasMeter::estimateMax(AssemblyItem const& _item, bool _ case Instruction::LOG3: case Instruction::LOG4: { - unsigned n = unsigned(_item.instruction()) - unsigned(Instruction::LOG0); - gas = GasCosts::logGas + GasCosts::logTopicGas * n; + gas = GasCosts::logGas + GasCosts::logTopicGas * getLogNumber(_item.instruction()); gas += memoryGas(0, -1); if (u256 const* value = classes.knownConstant(m_state->relativeStackElement(-1))) gas += GasCosts::logDataGas * (*value); diff --git a/libevmasm/Instruction.h b/libevmasm/Instruction.h index e2e2b63e..50c1f47d 100644 --- a/libevmasm/Instruction.h +++ b/libevmasm/Instruction.h @@ -218,6 +218,12 @@ inline bool isSwapInstruction(Instruction _inst) return Instruction::SWAP1 <= _inst && _inst <= Instruction::SWAP16; } +/// @returns true if the instruction is a LOG +inline bool isLogInstruction(Instruction _inst) +{ + return Instruction::LOG0 <= _inst && _inst <= Instruction::LOG4; +} + /// @returns the number of PUSH Instruction _inst inline unsigned getPushNumber(Instruction _inst) { @@ -236,6 +242,12 @@ inline unsigned getSwapNumber(Instruction _inst) return (byte)_inst - unsigned(Instruction::SWAP1) + 1; } +/// @returns the number of LOG Instruction _inst +inline unsigned getLogNumber(Instruction _inst) +{ + return (byte)_inst - unsigned(Instruction::LOG0); +} + /// @returns the PUSH<_number> instruction inline Instruction pushInstruction(unsigned _number) { diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index c97ee657..fd72bf41 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -1276,13 +1276,13 @@ u256 RationalNumberType::literalValue(Literal const*) const else { auto fixed = fixedPointType(); - solAssert(fixed, ""); + solAssert(fixed, "Rational number cannot be represented as fixed point type."); int fractionalDigits = fixed->fractionalDigits(); shiftedValue = m_value.numerator() * boost::multiprecision::pow(bigint(10), fractionalDigits) / m_value.denominator(); } // we ignore the literal and hope that the type was correctly determined - solAssert(shiftedValue <= u256(-1), "Integer constant too large."); + solAssert(shiftedValue <= u256(-1), "Number constant too large."); solAssert(shiftedValue >= -(bigint(1) << 255), "Number constant too small."); if (m_value >= rational(0)) |
