70 public static final int IS_SPILL = 1 << 3; 71 72 /** Is this a function parameter? */ 73 public static final int IS_PARAMETER = 1 << 4; 74 75 /** Is parameter accessed thru arguments? */ 76 public static final int HAS_ARGUMENTS = 1 << 5; 77 78 /** Is this property always represented as an Object? See {@link ObjectClassGenerator} and dual fields flag. */ 79 public static final int IS_ALWAYS_OBJECT = 1 << 6; 80 81 /** Can this property be primitive? */ 82 public static final int CAN_BE_PRIMITIVE = 1 << 7; 83 84 /** Can this property be undefined? */ 85 public static final int CAN_BE_UNDEFINED = 1 << 8; 86 87 /* Is this a function declaration property ? */ 88 public static final int IS_FUNCTION_DECLARATION = 1 << 9; 89 90 /** Property key. */ 91 private final String key; 92 93 /** Property flags. */ 94 protected int flags; 95 96 /** Property field number or spill slot. */ 97 private final int slot; 98 99 /** 100 * Constructor 101 * 102 * @param key property key 103 * @param flags property flags 104 * @param slot property field number or spill slot 105 */ 106 Property(final String key, final int flags, final int slot) { 107 assert key != null; 108 this.key = key; 109 this.flags = flags; 232 } 233 234 /** 235 * Check whether this property is in an object with arguments field 236 * @return true if has arguments 237 */ 238 public boolean hasArguments() { 239 return (flags & HAS_ARGUMENTS) == HAS_ARGUMENTS; 240 } 241 242 /** 243 * Check whether this is a spill property, i.e. one that will not 244 * be stored in a specially generated field in the property class. 245 * The spill pool is maintained separately, as a growing Object array 246 * in the {@link ScriptObject}. 247 * 248 * @return true if spill property 249 */ 250 public boolean isSpill() { 251 return (flags & IS_SPILL) == IS_SPILL; 252 } 253 254 /** 255 * Does this property use any slots in the spill array described in 256 * {@link Property#isSpill}? In that case how many. Currently a property 257 * only uses max one spill slot, but this may change in future representations 258 * Only {@link AccessorProperty} instances use spill slots 259 * 260 * @return number of spill slots a property is using 261 */ 262 public int getSpillCount() { 263 return isSpill() ? 1 : 0; 264 } 265 266 /** 267 * Add more property flags to the property. Properties are immutable here, 268 * so any property change that results in a larger flag set results in the 269 * property being cloned. Use only the return value 270 * 271 * @param propertyFlags flags to be OR:ed to the existing property flags | 70 public static final int IS_SPILL = 1 << 3; 71 72 /** Is this a function parameter? */ 73 public static final int IS_PARAMETER = 1 << 4; 74 75 /** Is parameter accessed thru arguments? */ 76 public static final int HAS_ARGUMENTS = 1 << 5; 77 78 /** Is this property always represented as an Object? See {@link ObjectClassGenerator} and dual fields flag. */ 79 public static final int IS_ALWAYS_OBJECT = 1 << 6; 80 81 /** Can this property be primitive? */ 82 public static final int CAN_BE_PRIMITIVE = 1 << 7; 83 84 /** Can this property be undefined? */ 85 public static final int CAN_BE_UNDEFINED = 1 << 8; 86 87 /* Is this a function declaration property ? */ 88 public static final int IS_FUNCTION_DECLARATION = 1 << 9; 89 90 /* Is this property bound bound to a receiver? */ 91 public static final int IS_BOUND = 1 << 10; 92 93 /** Property key. */ 94 private final String key; 95 96 /** Property flags. */ 97 protected int flags; 98 99 /** Property field number or spill slot. */ 100 private final int slot; 101 102 /** 103 * Constructor 104 * 105 * @param key property key 106 * @param flags property flags 107 * @param slot property field number or spill slot 108 */ 109 Property(final String key, final int flags, final int slot) { 110 assert key != null; 111 this.key = key; 112 this.flags = flags; 235 } 236 237 /** 238 * Check whether this property is in an object with arguments field 239 * @return true if has arguments 240 */ 241 public boolean hasArguments() { 242 return (flags & HAS_ARGUMENTS) == HAS_ARGUMENTS; 243 } 244 245 /** 246 * Check whether this is a spill property, i.e. one that will not 247 * be stored in a specially generated field in the property class. 248 * The spill pool is maintained separately, as a growing Object array 249 * in the {@link ScriptObject}. 250 * 251 * @return true if spill property 252 */ 253 public boolean isSpill() { 254 return (flags & IS_SPILL) == IS_SPILL; 255 } 256 257 /** 258 * Is this property bound to a receiver? 259 * 260 * @return true if this is a bound property 261 */ 262 public boolean isBound() { 263 return (flags & IS_BOUND) == IS_BOUND; 264 } 265 266 /** 267 * Does this property use any slots in the spill array described in 268 * {@link Property#isSpill}? In that case how many. Currently a property 269 * only uses max one spill slot, but this may change in future representations 270 * Only {@link AccessorProperty} instances use spill slots 271 * 272 * @return number of spill slots a property is using 273 */ 274 public int getSpillCount() { 275 return isSpill() ? 1 : 0; 276 } 277 278 /** 279 * Add more property flags to the property. Properties are immutable here, 280 * so any property change that results in a larger flag set results in the 281 * property being cloned. Use only the return value 282 * 283 * @param propertyFlags flags to be OR:ed to the existing property flags |