This commit is contained in:
Marenz 2021-10-07 18:11:19 +02:00
parent 694c431d74
commit 207b4fbeec
3 changed files with 8 additions and 9 deletions

View File

@ -11,6 +11,7 @@ Compiler Features:
Bugfixes: Bugfixes:
* Code Generator: Fixes source mappings for immutables.
* Commandline Interface: Fix extra newline character being appended to sources passed through standard input, affecting their hashes. * Commandline Interface: Fix extra newline character being appended to sources passed through standard input, affecting their hashes.
* SMTChecker: Fix internal error in magic type access (``block``, ``msg``, ``tx``). * SMTChecker: Fix internal error in magic type access (``block``, ``msg``, ``tx``).
* TypeChecker: Fix internal error when using user defined value types in public library functions. * TypeChecker: Fix internal error when using user defined value types in public library functions.
@ -27,7 +28,6 @@ Important Bugfixes:
Bugfixes: Bugfixes:
* AST: Export ``canonicalName`` for ``UserDefinedValueTypeDefinition`` and ``ContractDefinition``. * AST: Export ``canonicalName`` for ``UserDefinedValueTypeDefinition`` and ``ContractDefinition``.
* Code Generator: Fixes source mappings for immutables.

View File

@ -87,9 +87,9 @@ size_t AssemblyItem::bytesRequired(size_t _addressLength) const
case PushImmutable: case PushImmutable:
return 1 + 32; return 1 + 32;
case AssignImmutable: case AssignImmutable:
if (!m_immutableOccurrences) solAssert(m_immutableOccurrences, "");
return 0;
else if (m_immutableOccurrences.value() != 0) if (m_immutableOccurrences.value() != 0)
// (DUP DUP PUSH <n> ADD MSTORE)* (PUSH <n> ADD MSTORE) // (DUP DUP PUSH <n> ADD MSTORE)* (PUSH <n> ADD MSTORE)
return (*m_immutableOccurrences - 1) * (5 + 32) + (3 + 32); return (*m_immutableOccurrences - 1) * (5 + 32) + (3 + 32);
else else
@ -335,10 +335,9 @@ size_t AssemblyItem::opcodeCount() const noexcept
// For n immutable occurrences the first (n - 1) occurrences will // For n immutable occurrences the first (n - 1) occurrences will
// generate 5 opcodes and the last will generate 3 opcodes, // generate 5 opcodes and the last will generate 3 opcodes,
// because it is reusing the 2 top-most elements on the stack. // because it is reusing the 2 top-most elements on the stack.
if (!m_immutableOccurrences) solAssert(m_immutableOccurrences, "");
// AssignImmutable without any uses does not need to be assigned to at all.
return 0; if (m_immutableOccurrences.value() != 0)
else if (m_immutableOccurrences.value() != 0)
return (*m_immutableOccurrences - 1) * 5 + 3; return (*m_immutableOccurrences - 1) * 5 + 3;
else else
return 2; // two POP's return 2; // two POP's

View File

@ -172,9 +172,9 @@ public:
void setImmutableOccurrences(size_t _n) const { m_immutableOccurrences = _n; } void setImmutableOccurrences(size_t _n) const { m_immutableOccurrences = _n; }
private:
size_t opcodeCount() const noexcept; size_t opcodeCount() const noexcept;
private:
AssemblyItemType m_type; AssemblyItemType m_type;
Instruction m_instruction; ///< Only valid if m_type == Operation Instruction m_instruction; ///< Only valid if m_type == Operation
std::shared_ptr<u256> m_data; ///< Only valid if m_type != Operation std::shared_ptr<u256> m_data; ///< Only valid if m_type != Operation