@@ -90,6 +90,10 @@ std::pair<std::string, std::string> AssemblyItem::nameAndData(langutil::EVMVersi
9090 case JumpF:
9191 case RetF:
9292 return {instructionInfo (instruction (), _evmVersion).name , " " };
93+ case SwapN:
94+ return {instructionInfo (instruction (), _evmVersion).name , util::toString (static_cast <size_t >(data ())) };
95+ case DupN:
96+ return {instructionInfo (instruction (), _evmVersion).name , util::toString (static_cast <size_t >(data ())) };
9397 case Push:
9498 return {" PUSH" , toStringInHex (data ())};
9599 case PushTag:
@@ -192,6 +196,10 @@ size_t AssemblyItem::bytesRequired(size_t _addressLength, langutil::EVMVersion _
192196 return 2 ;
193197 case ReturnContract:
194198 return 2 ;
199+ case SwapN:
200+ return 2 ;
201+ case DupN:
202+ return 2 ;
195203 case UndefinedItem:
196204 solAssert (false );
197205 }
@@ -203,6 +211,10 @@ size_t AssemblyItem::arguments() const
203211{
204212 if (type () == CallF || type () == JumpF)
205213 return functionSignature ().argsNum ;
214+ else if (type () == SwapN)
215+ return static_cast <size_t >(data ()) + 2 ;
216+ else if (type () == DupN)
217+ return static_cast <size_t >(data ()) + 1 ;
206218 else if (hasInstruction ())
207219 {
208220 solAssert (instruction () != Instruction::CALLF && instruction () != Instruction::JUMPF);
@@ -231,6 +243,9 @@ size_t AssemblyItem::returnValues() const
231243 // The latest EVMVersion is used here, since the InstructionInfo is assumed to be
232244 // the same across all EVM versions except for the instruction name.
233245 return static_cast <size_t >(instructionInfo (instruction (), EVMVersion ()).ret );
246+ case SwapN:
247+ case DupN:
248+ return static_cast <size_t >(data ()) + 2 ;
234249 case Push:
235250 case PushTag:
236251 case PushData:
@@ -283,6 +298,8 @@ bool AssemblyItem::canBeFunctional() const
283298 case PushImmutable:
284299 case AuxDataLoadN:
285300 return true ;
301+ case SwapN:
302+ case DupN:
286303 case Tag:
287304 return false ;
288305 case AssignImmutable:
@@ -410,6 +427,12 @@ std::string AssemblyItem::toAssemblyText(Assembly const& _assembly) const
410427 case RetF:
411428 text = " retf" ;
412429 break ;
430+ case SwapN:
431+ text = " swapn{" + std::to_string (static_cast <size_t >(data ())) + " }" ;
432+ break ;
433+ case DupN:
434+ text = " dupn{" + std::to_string (static_cast <size_t >(data ())) + " }" ;
435+ break ;
413436 }
414437 if (m_jumpType == JumpType::IntoFunction || m_jumpType == JumpType::OutOfFunction)
415438 {
@@ -435,6 +458,8 @@ std::ostream& solidity::evmasm::operator<<(std::ostream& _out, AssemblyItem cons
435458 case CallF:
436459 case JumpF:
437460 case RetF:
461+ case SwapN:
462+ case DupN:
438463 _out << " " << instructionInfo (_item.instruction (), EVMVersion ()).name ;
439464 if (_item.instruction () == Instruction::JUMP || _item.instruction () == Instruction::JUMPI)
440465 _out << " \t " << _item.getJumpTypeAsString ();
0 commit comments