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

Method run

test/libyul/ObjectCompilerTest.cpp:70–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68}
69
70TestCase::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}

Callers

nothing calls this directly

Calls 11

toHexFunction · 0.85
getFunction · 0.85
hasErrorsMethod · 0.45
optimizeMethod · 0.45
assembleMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
assemblyStringMethod · 0.45
debugInfoSelectionMethod · 0.45
emptyMethod · 0.45
evmVersionMethod · 0.45

Tested by

no test coverage detected