/** * Creates a new tree field only constructor {@code ABlockStmIR TAG=block} node with the given nodes as children. * @deprecated This method should not be used, use AstFactory instead. * The basic child nodes are removed from their previous parents. * @param scoped_ the {@link Boolean} node for the {@code scoped} child of this {@link ABlockStmIR} node * @param localDefs_ the {@link NodeList} node for the {@code localDefs} child of this {@link ABlockStmIR} node * @param statements_ the {@link NodeList} node for the {@code statements} child of this {@link ABlockStmIR} node */ public ABlockStmIR(Boolean scoped_, List<? extends AVarDeclIR> localDefs_, List<? extends SStmIR> statements_) { super(null,null,null); this.setScoped(scoped_); this.setLocalDefs(localDefs_); this.setStatements(statements_); }
/** * Creates a new complete constructor {@code ABlockStmIR} node with the given nodes as children. * @deprecated This method should not be used, use AstFactory instead. * The basic child nodes are removed from their previous parents. * @param scoped_ the {@link Boolean} node for the {@code scoped} child of this {@link ABlockStmIR} node * @param localDefs_ the {@link NodeList} node for the {@code localDefs} child of this {@link ABlockStmIR} node * @param statements_ the {@link NodeList} node for the {@code statements} child of this {@link ABlockStmIR} node */ public ABlockStmIR(SourceNode sourceNode_, Object tag_, List<? extends ClonableString> metaData_, Boolean scoped_, List<? extends AVarDeclIR> localDefs_, List<? extends SStmIR> statements_) { super(sourceNode_,tag_,metaData_); this.setScoped(scoped_); this.setLocalDefs(localDefs_); this.setStatements(statements_); }
@Override public void caseANonDeterministicBlockStmIR(ANonDeterministicBlockStmIR node) throws AnalysisException { super.caseANonDeterministicBlockStmIR(node); ABlockStmIR block = new ABlockStmIR(); block.setScoped(false); block.setTag(node.getTag()); block.setSourceNode(node.getSourceNode()); if(!node.getStatements().isEmpty()) { // Just use the first statement block.getStatements().add(node.getStatements().getFirst().clone()); } else { log.error("nondeterministic statement block did not contain any statements: " + node); } assist.replaceNodeWith(node, block); } }
@Override public SStmIR caseALetStm(ALetStm node, IRInfo question) throws AnalysisException { ABlockStmIR block = new ABlockStmIR(); block.setScoped(question.getStmAssistant().isScoped(node)); question.getDeclAssistant().setFinalLocalDefs(node.getLocalDefs(), block.getLocalDefs(), question); SStmIR stm = node.getStatement().apply(question.getStmVisitor(), question); if (stm != null) { block.getStatements().add(stm); } return block; }
liftedBlock.setScoped(block.getScoped()); liftedBlock.setLocalDefs(defsToLift); liftedBlock.setStatements(statementsToLift);
public void caseALetDefExpIR(ALetDefExpIR node) throws AnalysisException { SStmIR enclosingStm = transAssistant.getEnclosingStm(node, "let def expression"); SExpIR exp = node.getExp(); transAssistant.replaceNodeWith(node, exp); ABlockStmIR topBlock = new ABlockStmIR(); ABlockStmIR current = topBlock; for (AVarDeclIR local : node.getLocalDefs()) { ABlockStmIR tmp = new ABlockStmIR(); tmp.getLocalDefs().add(local.clone()); current.getStatements().add(tmp); current = tmp; } transAssistant.replaceNodeWith(enclosingStm, topBlock); topBlock.getStatements().add(enclosingStm); exp.apply(this); topBlock.apply(this); topBlock.setScoped(transAssistant.getInfo().getStmAssistant().isScoped(topBlock)); }
regBlock.setScoped(true);
outer.setScoped(true);
blockStm.setScoped(question.getStmAssistant().isScoped(node));
outerBlock.setScoped(transAssistant.getInfo().getStmAssistant().isScoped(outerBlock));
outerBlock.apply(this); outerBlock.setScoped(transAssistant.getInfo().getStmAssistant().isScoped(outerBlock));
declStmBlock.setScoped(false); declStmBlock.getLocalDefs().add(decl);