MCPcopy Create free account
hub / github.com/argotorg/solidity / codeSectionInstructions

Function codeSectionInstructions

libevmasm/Ethdebug.cpp:84–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82}
83
84std::vector<schema::program::Instruction> codeSectionInstructions(Assembly const& _assembly, LinkerObject const& _linkerObject, unsigned const _sourceID, size_t const _codeSectionIndex)
85{
86 solAssert(_codeSectionIndex < _linkerObject.codeSectionLocations.size());
87 solAssert(_codeSectionIndex < _assembly.codeSections().size());
88 auto const& locations = _linkerObject.codeSectionLocations[_codeSectionIndex];
89 auto const& codeSection = _assembly.codeSections().at(_codeSectionIndex);
90
91 std::vector<schema::program::Instruction> instructions;
92 instructions.reserve(codeSection.items.size());
93
94 bool const codeSectionContainsVerbatim = ranges::any_of(
95 codeSection.items,
96 [](auto const& _instruction) { return _instruction.type() == VerbatimBytecode; }
97 );
98 solUnimplementedAssert(!codeSectionContainsVerbatim, "Verbatim bytecode is currently not supported by ethdebug.");
99
100 for (auto const& currentInstruction: locations.instructionLocations)
101 {
102 size_t const start = currentInstruction.start;
103 size_t const end = currentInstruction.end;
104
105 // some instructions do not contribute to the bytecode
106 if (start == end)
107 continue;
108
109 instructions.emplace_back(schema::program::Instruction{
110 .offset = schema::data::Unsigned{start},
111 .operation = instructionOperation(_assembly, _linkerObject, start, end),
112 .context = instructionContext(codeSection, currentInstruction.assemblyItemIndex, _sourceID)
113 });
114 }
115
116 return instructions;
117}
118
119std::vector<schema::program::Instruction> programInstructions(Assembly const& _assembly, LinkerObject const& _linkerObject, unsigned const _sourceID)
120{

Callers 1

programInstructionsFunction · 0.85

Calls 6

instructionOperationFunction · 0.85
instructionContextFunction · 0.85
atMethod · 0.80
reserveMethod · 0.80
sizeMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected