public boolean isScoped(ABlockStmIR block) { return !(block.parent() instanceof AMethodDeclIR) && !(block.parent() instanceof AElseIfStmIR) && !(block.parent() instanceof AIfStmIR) && !(block.parent() instanceof AForAllStmIR) && !(block.parent() instanceof AForIndexStmIR) && !(block.parent() instanceof AForLoopStmIR); }
@Override public void caseABlockStmIR(ABlockStmIR node) throws org.overture.codegen.ir.analysis.AnalysisException { for (SStmIR s : new LinkedList<>(node.getStatements())) { s.apply(this); } if (node.parent() instanceof ABlockStmIR && isEmpty(node)) { /** * Only remove empty blocks from blocks, otherwise we can get into a situation where we destroy the tree. * For example, 'if exp then () else ()' */ node.parent().removeChild(node); return; } if (singleBlockWrapsBlock(node)) { SStmIR enclosedStm = node.getStatements().get(0); if (node.parent() != null) { node.parent().replaceChild(node, enclosedStm); } } }