@@ -105,7 +105,6 @@ class AssemblyItem
105
105
106
106
explicit AssemblyItem (bytes _verbatimData, size_t _arguments, size_t _returnVariables):
107
107
m_type(VerbatimBytecode),
108
- m_instruction{},
109
108
m_verbatimBytecode{{_arguments, _returnVariables, std::move (_verbatimData)}},
110
109
m_debugData{langutil::DebugData::create ()}
111
110
{}
@@ -195,7 +194,7 @@ class AssemblyItem
195
194
// / @returns true if the item has m_instruction properly set.
196
195
bool hasInstruction () const
197
196
{
198
- return
197
+ bool const shouldHaveInstruction =
199
198
m_type == Operation ||
200
199
m_type == EOFCreate ||
201
200
m_type == ReturnContract ||
@@ -206,12 +205,14 @@ class AssemblyItem
206
205
m_type == RetF ||
207
206
m_type == SwapN ||
208
207
m_type == DupN;
208
+ solAssert (shouldHaveInstruction == m_instruction.has_value ());
209
+ return shouldHaveInstruction;
209
210
}
210
211
// / @returns the instruction of this item (only valid if hasInstruction returns true)
211
212
Instruction instruction () const
212
213
{
213
214
solAssert (hasInstruction ());
214
- return m_instruction;
215
+ return * m_instruction;
215
216
}
216
217
217
218
// / @returns true if the type and data of the items are equal.
@@ -323,7 +324,7 @@ class AssemblyItem
323
324
size_t opcodeCount () const noexcept ;
324
325
325
326
AssemblyItemType m_type;
326
- Instruction m_instruction; // /< Only valid if m_type == Operation
327
+ std::optional< Instruction> m_instruction; // /< Only valid for item types that represent a specific opcode
327
328
std::shared_ptr<u256> m_data; // /< Only valid if m_type != Operation
328
329
std::optional<FunctionSignature> m_functionSignature; // /< Only valid if m_type == CallF or JumpF
329
330
// / If m_type == VerbatimBytecode, this holds number of arguments, number of
0 commit comments