diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-05-05 09:20:41 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-05-05 09:20:41 -0700 |
commit | f85e310924535da09822f3d43aeee9265eb12760 (patch) | |
tree | b78e5f471fd284710032762927d719e98921e2fc /src/ast_utils.h | |
parent | 2811727a118e92e6b7ef293458f9bab1cf5dacdc (diff) | |
download | binaryen-f85e310924535da09822f3d43aeee9265eb12760.tar.gz binaryen-f85e310924535da09822f3d43aeee9265eb12760.tar.bz2 binaryen-f85e310924535da09822f3d43aeee9265eb12760.zip |
Import emscripten's relooper, port it to the binaryen AST, and provide a C API (#434)
also ignore libstdc++ bug in ubsan
Diffstat (limited to 'src/ast_utils.h')
-rw-r--r-- | src/ast_utils.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/ast_utils.h b/src/ast_utils.h index 8aacb62da..ebb6861da 100644 --- a/src/ast_utils.h +++ b/src/ast_utils.h @@ -119,6 +119,23 @@ struct EffectAnalyzer : public PostWalker<EffectAnalyzer, Visitor<EffectAnalyzer void visitUnreachable(Unreachable *curr) { branches = true; } }; +// Meausure the size of an AST +struct Measurer : public PostWalker<Measurer, UnifiedExpressionVisitor<Measurer>> { + size_t size = 0; + + void visitExpression(Expression* curr) { + size++; + } + + static bool measure(Expression* tree) { + Measurer measurer; + measurer.walk(tree); + return measurer.size; + } +}; + +// Manipulate expressions + struct ExpressionManipulator { // Re-use a node's memory. This helps avoid allocation when optimizing. template<typename InputType, typename OutputType> |