From 525f021add458da8034a0790b07eb2b20573f73e Mon Sep 17 00:00:00 2001 From: ChUrl Date: Fri, 29 Jan 2021 21:53:38 +0100 Subject: [PATCH] renaming and FlowGraph Update --- .../java/codegen/sourcegraph/SourceBlock.java | 109 ------------------ 1 file changed, 109 deletions(-) delete mode 100644 src/main/java/codegen/sourcegraph/SourceBlock.java diff --git a/src/main/java/codegen/sourcegraph/SourceBlock.java b/src/main/java/codegen/sourcegraph/SourceBlock.java deleted file mode 100644 index 9cfaae3..0000000 --- a/src/main/java/codegen/sourcegraph/SourceBlock.java +++ /dev/null @@ -1,109 +0,0 @@ -package codegen.sourcegraph; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Objects; -import java.util.Set; -import java.util.stream.Collectors; - -public class SourceBlock { - - private final String id; - private final String label; - private final List instructions; - private final Set pred; - private final Set succ; - - public SourceBlock(String label) { - this.label = label; - this.id = String.valueOf(System.nanoTime()); - this.instructions = new ArrayList<>(); - this.pred = new HashSet<>(); - this.succ = new HashSet<>(); - } - - public SourceBlock() { - this(""); - } - - public boolean isEmpty() { - return this.label.isBlank() && this.instructions.isEmpty(); - } - - public void addLine(String instruction, String... args) { - this.instructions.add(new SourceInst(instruction, args)); - } - - public List getInstructions() { - return this.instructions; - } - - public String getLabel() { - return this.label; - } - - public void addSuccessor(SourceBlock block) { - this.succ.add(block); - } - - public void addPredecessor(SourceBlock block) { - this.pred.add(block); - } - - public Set getSuccessors() { - return this.succ; - } - - public Set getPredecessors() { - return this.pred; - } - - public String getId() { - return this.id; - } - - public String printInst() { - return this.instructions.stream() - .map(inst -> inst.toString().trim() + "\\n") - .map(inst -> inst.replace("\"", "\\\"")) - .collect(Collectors.joining()); - } - - public void addSuccessors(Set successors) { - this.succ.addAll(successors); - } - - public void addPredecessors(Set predecessors) { - this.pred.addAll(predecessors); - } - - @Override - public int hashCode() { - return Objects.hash(this.id); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof SourceBlock) { - return this.id.equals(((SourceBlock) obj).id); - } - - return false; - } - - @Override - public String toString() { - final String linesString = this.instructions.stream() - .map(SourceInst::toString) - .map(line -> line + "\n") - .collect(Collectors.joining()); - - if (this.label.isBlank()) { - return linesString; - } - - return this.label + ":\n" - + linesString; - } -}