diff options
Diffstat (limited to 'src/ast_utils.h')
-rw-r--r-- | src/ast_utils.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/ast_utils.h b/src/ast_utils.h index 9dfacb972..f10fb40eb 100644 --- a/src/ast_utils.h +++ b/src/ast_utils.h @@ -102,6 +102,11 @@ struct DirectCallGraphAnalyzer : public PostWalker<DirectCallGraphAnalyzer, Visi struct EffectAnalyzer : public PostWalker<EffectAnalyzer, Visitor<EffectAnalyzer>> { EffectAnalyzer() {} EffectAnalyzer(Expression *ast) { + analyze(ast); + } + + void analyze(Expression *ast) { + breakNames.clear(); walk(ast); // if we are left with breaks, they are external if (breakNames.size() > 0) branches = true; @@ -151,6 +156,17 @@ struct EffectAnalyzer : public PostWalker<EffectAnalyzer, Visitor<EffectAnalyzer return false; } + void mergeIn(EffectAnalyzer& other) { + branches = branches || other.branches; + calls = calls || other.calls; + readsMemory = readsMemory || other.readsMemory; + writesMemory = writesMemory || other.writesMemory; + for (auto i : other.localsRead) localsRead.insert(i); + for (auto i : other.localsWritten) localsWritten.insert(i); + for (auto i : other.globalsRead) globalsRead.insert(i); + for (auto i : other.globalsWritten) globalsWritten.insert(i); + } + // the checks above happen after the node's children were processed, in the order of execution // we must also check for control flow that happens before the children, i.e., loops bool checkPre(Expression* curr) { |