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

Method tryToSimplify

libevmasm/ExpressionClasses.cpp:205–234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

203}
204
205ExpressionClasses::Id ExpressionClasses::tryToSimplify(Expression const& _expr)
206{
207 static Rules rules;
208 assertThrow(rules.isInitialized(), OptimizerException, "Rule list not properly initialized.");
209
210 if (
211 !_expr.item ||
212 _expr.item->type() != Operation ||
213 !SemanticInformation::isDeterministic(*_expr.item)
214 )
215 return std::numeric_limits<unsigned>::max();
216
217 if (auto match = rules.findFirstMatch(_expr, *this))
218 {
219 // Debug info
220 if (false)
221 {
222 std::cout << "Simplifying " << *_expr.item << "(";
223 for (Id arg: _expr.arguments)
224 std::cout << fullDAGToString(arg) << ", ";
225 std::cout << ")" << std::endl;
226 std::cout << "with rule " << match->pattern.toString() << std::endl;
227 std::cout << "to " << match->action().toString() << std::endl;
228 }
229
230 return rebuildExpression(ExpressionTemplate(match->action(), _expr.item->debugData()));
231 }
232
233 return std::numeric_limits<unsigned>::max();
234}
235
236ExpressionClasses::Id ExpressionClasses::rebuildExpression(ExpressionTemplate const& _template)
237{

Callers

nothing calls this directly

Calls 6

debugDataMethod · 0.80
ExpressionTemplateClass · 0.70
isInitializedMethod · 0.45
typeMethod · 0.45
findFirstMatchMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected