Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.object/src/com/oracle/truffle/object/PropertyImpl.java @ 21733:27943aac2e3c
Merge
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Thu, 04 Jun 2015 11:08:12 -0700 |
parents | 5f3dda39d205 |
children |
comparison
equal
deleted
inserted
replaced
21732:bc2ec35a7189 | 21733:27943aac2e3c |
---|---|
40 | 40 |
41 /** | 41 /** |
42 * Generic, usual-case constructor for properties storing at least a name. | 42 * Generic, usual-case constructor for properties storing at least a name. |
43 * | 43 * |
44 * @param key the name of the property | 44 * @param key the name of the property |
45 * @param location the storage location used to access the property | |
46 * @param flags property flags (optional) | |
45 */ | 47 */ |
46 protected PropertyImpl(Object key, Location location, int flags, boolean shadow, boolean relocatable) { | 48 protected PropertyImpl(Object key, Location location, int flags, boolean shadow, boolean relocatable) { |
47 this.key = Objects.requireNonNull(key); | 49 this.key = Objects.requireNonNull(key); |
48 this.location = Objects.requireNonNull(location); | 50 this.location = Objects.requireNonNull(location); |
49 this.flags = flags; | 51 this.flags = flags; |
65 return flags; | 67 return flags; |
66 } | 68 } |
67 | 69 |
68 @Override | 70 @Override |
69 public Property relocate(Location newLocation) { | 71 public Property relocate(Location newLocation) { |
70 if ((getLocation() == null || !getLocation().equals(newLocation)) && relocatable) { | 72 if (!getLocation().equals(newLocation) && relocatable) { |
71 return construct(getKey(), newLocation, getFlags()); | 73 return construct(key, newLocation, flags); |
72 } | 74 } |
73 return this; | 75 return this; |
74 } | 76 } |
75 | 77 |
76 @Override | 78 @Override |
161 if (getClass() != obj.getClass()) { | 163 if (getClass() != obj.getClass()) { |
162 return false; | 164 return false; |
163 } | 165 } |
164 | 166 |
165 PropertyImpl other = (PropertyImpl) obj; | 167 PropertyImpl other = (PropertyImpl) obj; |
166 return key.equals(other.key) && ((location == null && other.location == null) || (location != null && location.equals(other.location))) && flags == other.flags && shadow == other.shadow && | 168 return key.equals(other.key) && location.equals(other.location) && flags == other.flags && shadow == other.shadow && relocatable == other.relocatable; |
167 relocatable == other.relocatable; | |
168 } | 169 } |
169 | 170 |
170 @Override | 171 @Override |
171 public boolean isSame(Property obj) { | 172 public boolean isSame(Property obj) { |
172 if (this == obj) { | 173 if (this == obj) { |
187 public int hashCode() { | 188 public int hashCode() { |
188 final int prime = 31; | 189 final int prime = 31; |
189 int result = 1; | 190 int result = 1; |
190 result = prime * result + getClass().hashCode(); | 191 result = prime * result + getClass().hashCode(); |
191 result = prime * result + key.hashCode(); | 192 result = prime * result + key.hashCode(); |
192 result = prime * result + (location != null ? location.hashCode() : 0); | 193 result = prime * result + location.hashCode(); |
193 result = prime * result + flags; | 194 result = prime * result + flags; |
194 return result; | 195 return result; |
195 } | 196 } |
196 | 197 |
197 @Override | 198 @Override |
238 return shadow; | 239 return shadow; |
239 } | 240 } |
240 | 241 |
241 private Property relocateShadow(Location newLocation) { | 242 private Property relocateShadow(Location newLocation) { |
242 assert !isShadow() && getLocation() instanceof DeclaredLocation && relocatable; | 243 assert !isShadow() && getLocation() instanceof DeclaredLocation && relocatable; |
243 return new PropertyImpl(getKey(), newLocation, flags, true, relocatable); | 244 return new PropertyImpl(key, newLocation, flags, true, relocatable); |
244 } | 245 } |
245 | 246 |
246 @SuppressWarnings("hiding") | 247 @SuppressWarnings("hiding") |
247 protected Property construct(Object name, Location location, int flags) { | 248 protected Property construct(Object name, Location location, int flags) { |
248 return new PropertyImpl(name, location, flags, shadow, relocatable); | 249 return new PropertyImpl(name, location, flags, shadow, relocatable); |