Zilliqa / scilla

Scilla - A Smart Contract Intermediate Level Language
https://scilla-lang.org
GNU General Public License v3.0
240 stars 79 forks source link

Design functions to fold through statements and expressions #1148

Open jubnzv opened 2 years ago

jubnzv commented 2 years ago

Folding through nested statements and expressions is a common pattern used almost in every static analysis.

However, this pattern is too verbose and error-prone, because a developer could forget to handle nested statements or expressions for some nodes.

We should create generic functions fold_over_stmts and fold_over_exprs in the ContractUtil.ml in the same way as fold_over_messages is implemented. These function should look into nested statements and expressions and accumulate the information as it is implemented in the argument function ~f.

anton-trunov commented 2 years ago

Related issue: #438

anton-trunov commented 1 year ago

Related: we now have an annotation mapper in https://github.com/Zilliqa/scilla/blob/master/src/base/SyntaxAnnotMapper.ml.