Mercurial > hg > truffle
comparison truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameSlot.java @ 22522:cda3eebfa777
Documenting FrameSlot methods. Deprecating FrameSlot constructor in favor of FrameDescriptor.addFrameSlot.
author | Jaroslav Tulach <jaroslav.tulach@oracle.com> |
---|---|
date | Mon, 21 Dec 2015 11:11:45 +0100 |
parents | dc83cc1f94f2 |
children |
comparison
equal
deleted
inserted
replaced
22521:69e80ff8d725 | 22522:cda3eebfa777 |
---|---|
26 | 26 |
27 import com.oracle.truffle.api.CompilerDirectives; | 27 import com.oracle.truffle.api.CompilerDirectives; |
28 import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; | 28 import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; |
29 | 29 |
30 /** | 30 /** |
31 * A slot in a frame that can store a value of a given type. | 31 * A slot in a {@link Frame} and {@link FrameDescriptor} that can store a value of a given type. |
32 */ | 32 */ |
33 public final class FrameSlot implements Cloneable { | 33 public final class FrameSlot implements Cloneable { |
34 | 34 |
35 private final FrameDescriptor descriptor; | 35 private final FrameDescriptor descriptor; |
36 private final Object identifier; | 36 private final Object identifier; |
37 private final Object info; | 37 private final Object info; |
38 private final int index; | 38 private final int index; |
39 @CompilationFinal private FrameSlotKind kind; | 39 @CompilationFinal private FrameSlotKind kind; |
40 | 40 |
41 /** | |
42 * @deprecated use | |
43 * {@link FrameDescriptor#addFrameSlot(java.lang.Object, java.lang.Object, com.oracle.truffle.api.frame.FrameSlotKind)} | |
44 * to create new instance of the slot. This method will be made package private in | |
45 * the future. | |
46 */ | |
47 @Deprecated | |
41 public FrameSlot(FrameDescriptor descriptor, Object identifier, Object info, int index, FrameSlotKind kind) { | 48 public FrameSlot(FrameDescriptor descriptor, Object identifier, Object info, int index, FrameSlotKind kind) { |
49 this(descriptor, identifier, info, kind, index); | |
50 } | |
51 | |
52 FrameSlot(FrameDescriptor descriptor, Object identifier, Object info, FrameSlotKind kind, int index) { | |
42 this.descriptor = descriptor; | 53 this.descriptor = descriptor; |
43 this.identifier = identifier; | 54 this.identifier = identifier; |
44 this.info = info; | 55 this.info = info; |
45 this.index = index; | 56 this.index = index; |
46 this.kind = kind; | 57 this.kind = kind; |
47 } | 58 } |
48 | 59 |
60 /** | |
61 * Identifier of the slot. | |
62 * | |
63 * @return value as specified in {@link FrameDescriptor#addFrameSlot(java.lang.Object)} | |
64 * parameter | |
65 */ | |
49 public Object getIdentifier() { | 66 public Object getIdentifier() { |
50 return identifier; | 67 return identifier; |
51 } | 68 } |
52 | 69 |
70 /** | |
71 * Information about the slot. | |
72 * | |
73 * @return value as specified as second parameter of | |
74 * {@link FrameDescriptor#addFrameSlot(java.lang.Object, java.lang.Object, com.oracle.truffle.api.frame.FrameSlotKind)} | |
75 */ | |
53 public Object getInfo() { | 76 public Object getInfo() { |
54 return info; | 77 return info; |
55 } | 78 } |
56 | 79 |
80 /** | |
81 * Index of the slot in the {@link FrameDescriptor}. | |
82 * | |
83 * @return position of the slot computed after | |
84 * {@link FrameDescriptor#addFrameSlot(java.lang.Object, java.lang.Object, com.oracle.truffle.api.frame.FrameSlotKind) | |
85 * adding} it. | |
86 */ | |
57 public int getIndex() { | 87 public int getIndex() { |
58 return index; | 88 return index; |
59 } | 89 } |
60 | 90 |
91 /** | |
92 * Kind of the slot. Specified either at | |
93 * {@link FrameDescriptor#addFrameSlot(java.lang.Object, com.oracle.truffle.api.frame.FrameSlotKind) | |
94 * creation time} or updated via {@link #setKind(com.oracle.truffle.api.frame.FrameSlotKind)} | |
95 * method. | |
96 * | |
97 * @return current kind of this slot | |
98 */ | |
61 public FrameSlotKind getKind() { | 99 public FrameSlotKind getKind() { |
62 return kind; | 100 return kind; |
63 } | 101 } |
64 | 102 |
103 /** | |
104 * Changes the kind of this slot. Change of the slot kind is done on <em>slow path</em> and | |
105 * invalidates assumptions about {@link FrameDescriptor#createVersion() version} of | |
106 * {@link #getFrameDescriptor() associated descriptor}. | |
107 * | |
108 * @param kind new kind of the slot | |
109 */ | |
65 public void setKind(final FrameSlotKind kind) { | 110 public void setKind(final FrameSlotKind kind) { |
66 if (this.kind != kind) { | 111 if (this.kind != kind) { |
67 CompilerDirectives.transferToInterpreter(); | 112 CompilerDirectives.transferToInterpreter(); |
68 this.kind = kind; | 113 this.kind = kind; |
69 this.descriptor.updateVersion(); | 114 this.descriptor.updateVersion(); |
73 @Override | 118 @Override |
74 public String toString() { | 119 public String toString() { |
75 return "[" + index + "," + identifier + "," + kind + "]"; | 120 return "[" + index + "," + identifier + "," + kind + "]"; |
76 } | 121 } |
77 | 122 |
123 /** | |
124 * Frame descriptor this slot is associated with. | |
125 * | |
126 * @return instance of descriptor that {@link FrameDescriptor#addFrameSlot(java.lang.Object) | |
127 * created} the slot | |
128 */ | |
78 public FrameDescriptor getFrameDescriptor() { | 129 public FrameDescriptor getFrameDescriptor() { |
79 return this.descriptor; | 130 return this.descriptor; |
80 } | 131 } |
81 } | 132 } |