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

Method importAssemblyItemsFromJSON

libevmasm/Assembly.cpp:136–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134}
135
136void Assembly::importAssemblyItemsFromJSON(Json const& _code, std::vector<std::string> const& _sourceList)
137{
138 // Assembly constructor creates first code section with proper type and empty `items`
139 solAssert(m_codeSections.size() == 1);
140 solAssert(m_codeSections[0].items.empty());
141 // TODO: Add support for EOF and more than one code sections.
142 solUnimplementedAssert(!m_eofVersion.has_value(), "Assembly import for EOF is not yet implemented.");
143 solRequire(_code.is_array(), AssemblyImportException, "Supplied JSON is not an array.");
144 for (auto jsonItemIter = std::begin(_code); jsonItemIter != std::end(_code); ++jsonItemIter)
145 {
146 AssemblyItem const& newItem = m_codeSections[0].items.emplace_back(createAssemblyItemFromJSON(*jsonItemIter, _sourceList));
147 if (newItem == Instruction::JUMPDEST)
148 solThrow(AssemblyImportException, "JUMPDEST instruction without a tag");
149 else if (newItem.type() == AssemblyItemType::Tag)
150 {
151 ++jsonItemIter;
152 if (jsonItemIter != std::end(_code) && createAssemblyItemFromJSON(*jsonItemIter, _sourceList) != Instruction::JUMPDEST)
153 solThrow(AssemblyImportException, "JUMPDEST expected after tag.");
154 }
155 }
156}
157
158AssemblyItem Assembly::createAssemblyItemFromJSON(Json const& _json, std::vector<std::string> const& _sourceList)
159{

Callers 1

fromJSONMethod · 0.80

Calls 3

sizeMethod · 0.45
emptyMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected