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

Class Monitor

src/main/java/pascal/taie/ir/stmt/Monitor.java:33–88  ·  view source on GitHub ↗

Representation of monitorenter/monitorexit instruction.

Source from the content-addressed store, hash-verified

31 * Representation of monitorenter/monitorexit instruction.
32 */
33public class Monitor extends AbstractStmt {
34
35 public enum Op {
36 ENTER("enter"), EXIT("exit");
37
38 private final String name;
39
40 Op(String name) {
41 this.name = name;
42 }
43
44 @Override
45 public String toString() {
46 return name;
47 }
48 }
49
50 private final Op op;
51
52 /**
53 * Reference of the object to be locked/unlocked.
54 */
55 private final Var objectRef;
56
57 public Monitor(Op op, Var objectRef) {
58 this.op = op;
59 this.objectRef = objectRef;
60 }
61
62 public boolean isEnter() {
63 return op == Op.ENTER;
64 }
65
66 public boolean isExit() {
67 return op == Op.EXIT;
68 }
69
70 public Var getObjectRef() {
71 return objectRef;
72 }
73
74 @Override
75 public Set<RValue> getUses() {
76 return Set.of(objectRef);
77 }
78
79 @Override
80 public <T> T accept(StmtVisitor<T> visitor) {
81 return visitor.visit(this);
82 }
83
84 @Override
85 public String toString() {
86 return "monitor" + op + " " + objectRef;
87 }
88}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected