1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package gov.nasa.pds.tools.label;
17
18 /***
19 * This class is the object representation of a pointer statement in a label.
20 *
21 * @author pramirez
22 * @version $Revision: 2606 $
23 *
24 */
25 public class PointerStatement extends Statement implements PointerType {
26 protected Value value;
27 private CommentStatement comment;
28 private int pointerType;
29
30 /***
31 * Constructs essentially a null pointer
32 * @param lineNumber at which the statement occurs
33 * @param identifier of the statement
34 */
35 protected PointerStatement(int pointerType, int lineNumber, String identifier) {
36 this(pointerType, lineNumber, identifier, null);
37 }
38
39 /***
40 * Constructs a pointer with a value on the right hand side
41 * @param lineNumber at which the statement occurs
42 * @param identifier of the statement
43 * @param value of the assignment
44 */
45 protected PointerStatement(int pointerType, int lineNumber, String identifier, Value value) {
46 super(lineNumber, identifier);
47 this.value = value;
48 this.pointerType = pointerType;
49 comment = null;
50 }
51
52 /***
53 * Constructs a pointer with an unknown line number.
54 * @param identifier of the statement
55 * @param value of the assignment
56 */
57 protected PointerStatement(String identifier, Value value) {
58 this(UNDEFINED, -1, identifier, value);
59 }
60
61 /***
62 * Returns the value portion (right hand side) of the statement.
63 * @return value
64 */
65 public Value getValue() {
66 return value;
67 }
68
69 /***
70 * Attaches a comment to this pointer
71 * @param comment that occurs on same line as this pointer statement
72 */
73 public void attachComment(CommentStatement comment) {
74 this.comment = comment;
75 }
76
77 /***
78 * Returns the comment that occurs on the same line as this pointer assigment
79 * @return comment
80 */
81 public CommentStatement getComment() {
82 return comment;
83 }
84
85 /***
86 * Indicates the type of pointer that this pointer statement represents. See {@link PointerType}
87 * @return type of pointer
88 */
89 public int getPointerType() {
90 return pointerType;
91 }
92
93 }