| 68 | } |
| 69 | |
| 70 | TestCase::TestResult ObjectCompilerTest::run(std::ostream& _stream, std::string const& _linePrefix, bool const _formatted) |
| 71 | { |
| 72 | YulStack yulStack = parseYul(m_source, "source", OptimiserSettings::preset(m_optimisationPreset)); |
| 73 | MachineAssemblyObject obj; |
| 74 | if (!yulStack.hasErrors()) |
| 75 | { |
| 76 | yulStack.optimize(); |
| 77 | obj = yulStack.assemble(YulStack::Machine::EVM); |
| 78 | } |
| 79 | if (yulStack.hasErrors()) |
| 80 | { |
| 81 | printYulErrors(yulStack, _stream, _linePrefix, _formatted); |
| 82 | return TestResult::FatalError; |
| 83 | } |
| 84 | |
| 85 | solAssert(obj.bytecode); |
| 86 | solAssert(obj.sourceMappings); |
| 87 | |
| 88 | if (std::find(m_outputSetting.begin(), m_outputSetting.end(), "Assembly") != m_outputSetting.end()) |
| 89 | m_obtainedResult = "Assembly:\n" + obj.assembly->assemblyString(yulStack.debugInfoSelection()); |
| 90 | if (obj.bytecode->bytecode.empty()) |
| 91 | m_obtainedResult += "-- empty bytecode --\n"; |
| 92 | else |
| 93 | { |
| 94 | if (std::find(m_outputSetting.begin(), m_outputSetting.end(), "Bytecode") != m_outputSetting.end()) |
| 95 | m_obtainedResult += "Bytecode: " + util::toHex(obj.bytecode->bytecode); |
| 96 | if (std::find(m_outputSetting.begin(), m_outputSetting.end(), "Opcodes") != m_outputSetting.end()) |
| 97 | { |
| 98 | m_obtainedResult += (!m_obtainedResult.empty() && m_obtainedResult.back() != '\n') ? "\n" : ""; |
| 99 | m_obtainedResult += "Opcodes: " + |
| 100 | boost::trim_copy(evmasm::disassemble(obj.bytecode->bytecode, solidity::test::CommonOptions::get().evmVersion())); |
| 101 | } |
| 102 | if (std::find(m_outputSetting.begin(), m_outputSetting.end(), "SourceMappings") != m_outputSetting.end()) |
| 103 | { |
| 104 | m_obtainedResult += (!m_obtainedResult.empty() && m_obtainedResult.back() != '\n') ? "\n" : ""; |
| 105 | m_obtainedResult += "SourceMappings:" + (obj.sourceMappings->empty() ? "" : " " + *obj.sourceMappings) + "\n"; |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | return checkResult(_stream, _linePrefix, _formatted); |
| 110 | } |
nothing calls this directly
no test coverage detected