MCPcopy Create free account
hub / github.com/LFYSec/MScan / If

Class If

src/main/java/pascal/taie/ir/stmt/If.java:35–92  ·  view source on GitHub ↗

Representation of if statement, e.g., if a == b goto S;

Source from the content-addressed store, hash-verified

33 * Representation of if statement, e.g., if a == b goto S;
34 */
35public class If extends JumpStmt {
36
37 /**
38 * The condition expression.
39 */
40 private final ConditionExp condition;
41
42 /**
43 * Jump target when the condition expression is evaluated to true.
44 */
45 private Stmt target;
46
47 public If(ConditionExp condition) {
48 this.condition = condition;
49 }
50
51 /**
52 * @return the condition expression of the if-statement.
53 */
54 public ConditionExp getCondition() {
55 return condition;
56 }
57
58 /**
59 * @return the jump target (when the condition expression is evaluated
60 * to true) of the if-statement.
61 */
62 public Stmt getTarget() {
63 return target;
64 }
65
66 public void setTarget(Stmt target) {
67 this.target = target;
68 }
69
70 @Override
71 public Set<RValue> getUses() {
72 Set<RValue> uses = new ArraySet<>(condition.getUses());
73 uses.add(condition);
74 return uses;
75 }
76
77 @Override
78 public List<Stmt> getTargets() {
79 return List.of(target);
80 }
81
82 @Override
83 public <T> T accept(StmtVisitor<T> visitor) {
84 return visitor.visit(this);
85 }
86
87 @Override
88 public String toString() {
89 return String.format(
90 "if (%s) goto %s", condition, toString(target));
91 }
92}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected