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

Method overwriteWithOptimizedObject

libyul/ObjectOptimizer.cpp:101–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99}
100
101void ObjectOptimizer::overwriteWithOptimizedObject(util::h256 _cacheKey, Object& _object) const
102{
103 yulAssert(m_cachedObjects.count(_cacheKey) != 0);
104 CachedObject const& cachedObject = m_cachedObjects.at(_cacheKey);
105
106 yulAssert(cachedObject.optimizedAST);
107 yulAssert(cachedObject.dialect);
108 _object.setCode(std::make_shared<AST>(*cachedObject.dialect, ASTCopier{}.translate(*cachedObject.optimizedAST)));
109 yulAssert(_object.code());
110 yulAssert(_object.dialect());
111
112 // There's no point in caching AnalysisInfo because it references AST nodes. It can't be shared
113 // by multiple ASTs and it's easier to recalculate it than properly clone it.
114 _object.analysisInfo = std::make_shared<AsmAnalysisInfo>(
115 AsmAnalyzer::analyzeStrictAssertCorrect(
116 _object
117 )
118 );
119
120 // NOTE: Source name index is included in the key so it must be identical. No need to store and restore it.
121}
122
123std::optional<h256> ObjectOptimizer::calculateCacheKey(
124 Block const& _ast,

Callers

nothing calls this directly

Calls 6

atMethod · 0.80
setCodeMethod · 0.80
dialectMethod · 0.80
countMethod · 0.45
translateMethod · 0.45
codeMethod · 0.45

Tested by

no test coverage detected