1 /* 2 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package jdk.nashorn.internal.runtime; 27 28 /** 29 * Interface for getting and setting properties from script objects 30 * This can be a plugin point for e.g. tagged values or alternative 31 * array property getters. 32 * 33 * The interface is engineered with the combinatorially exhaustive 34 * combination of types by purpose, for speed, as currently HotSpot is not 35 * good enough at removing boxing. 36 */ 37 public interface PropertyAccess { 38 /** 39 * Get the value for a given key and return it as an int 40 * @param key the key 41 * @param programPoint or INVALID_PROGRAM_POINT if pessimistic 42 * @return the value 43 */ 44 public int getInt(Object key, int programPoint); 45 46 /** 47 * Get the value for a given key and return it as an int 48 * @param key the key 49 * @param programPoint or INVALID_PROGRAM_POINT if pessimistic 50 * @return the value 51 */ 52 public int getInt(double key, int programPoint); 53 54 /** 55 * Get the value for a given key and return it as an int 56 * @param key the key 57 * @param programPoint or INVALID_PROGRAM_POINT if pessimistic 58 * @return the value 59 */ 60 public int getInt(long key, int programPoint); 61 62 /** 63 * Get the value for a given key and return it as an int 64 * @param key the key 65 * @param programPoint or INVALID_PROGRAM_POINT if pessimistic 66 * @return the value 67 */ 68 public int getInt(int key, int programPoint); 69 70 /** 71 * Get the value for a given key and return it as a long 72 * @param key the key 73 * @param programPoint or INVALID_PROGRAM_POINT if pessimistic 74 * @return the value 75 */ 76 public long getLong(Object key, int programPoint); 77 78 /** 79 * Get the value for a given key and return it as a long 80 * @param key the key 81 * @param programPoint or INVALID_PROGRAM_POINT if pessimistic 82 * @return the value 83 */ 84 public long getLong(double key, int programPoint); 85 86 /** 87 * Get the value for a given key and return it as a long 88 * @param key the key 89 * @param programPoint or INVALID_PROGRAM_POINT if pessimistic 90 * @return the value 91 */ 92 public long getLong(long key, int programPoint); 93 94 /** 95 * Get the value for a given key and return it as a long 96 * @param key the key 97 * @param programPoint or INVALID_PROGRAM_POINT if pessimistic 98 * @return the value 99 */ 100 public long getLong(int key, int programPoint); 101 102 /** 103 * Get the value for a given key and return it as a double 104 * @param key the key 105 * @param programPoint or INVALID_PROGRAM_POINT if pessimistic 106 * @return the value 107 */ 108 public double getDouble(Object key, int programPoint); 109 110 /** 111 * Get the value for a given key and return it as a double 112 * @param key the key 113 * @param programPoint or INVALID_PROGRAM_POINT if pessimistic 114 * @return the value 115 */ 116 public double getDouble(double key, int programPoint); 117 118 /** 119 * Get the value for a given key and return it as a double 120 * @param key the key 121 * @param programPoint or INVALID_PROGRAM_POINT if pessimistic 122 * @return the value 123 */ 124 public double getDouble(long key, int programPoint); 125 126 /** 127 * Get the value for a given key and return it as a double 128 * @param key the key 129 * @param programPoint or INVALID_PROGRAM_POINT if pessimistic 130 * @return the value 131 */ 132 public double getDouble(int key, int programPoint); 133 134 /** 135 * Get the value for a given key and return it as an Object 136 * @param key the key 137 * @return the value 138 */ 139 public Object get(Object key); 140 141 /** 142 * Get the value for a given key and return it as an Object 143 * @param key the key 144 * @return the value 145 */ 146 public Object get(double key); 147 148 /** 149 * Get the value for a given key and return it as an Object 150 * @param key the key 151 * @return the value 152 */ 153 public Object get(long key); 154 155 /** 156 * Get the value for a given key and return it as an Object 157 * @param key the key 158 * @return the value 159 */ 160 public Object get(int key); 161 162 /** 163 * Set the value of a given key 164 * @param key the key 165 * @param value the value 166 * @param flags call site flags 167 */ 168 public void set(Object key, int value, int flags); 169 170 /** 171 * Set the value of a given key 172 * @param key the key 173 * @param value the value 174 * @param flags call site flags 175 */ 176 public void set(Object key, long value, int flags); 177 178 /** 179 * Set the value of a given key 180 * @param key the key 181 * @param value the value 182 * @param flags call site flags 183 */ 184 public void set(Object key, double value, int flags); 185 186 /** 187 * Set the value of a given key 188 * @param key the key 189 * @param value the value 190 * @param flags call site flags 191 */ 192 public void set(Object key, Object value, int flags); 193 194 /** 195 * Set the value of a given key 196 * @param key the key 197 * @param value the value 198 * @param flags call site flags 199 */ 200 public void set(double key, int value, int flags); 201 202 /** 203 * Set the value of a given key 204 * @param key the key 205 * @param value the value 206 * @param flags call site flags 207 */ 208 public void set(double key, long value, int flags); 209 210 /** 211 * Set the value of a given key 212 * @param key the key 213 * @param value the value 214 * @param flags call site flags 215 */ 216 public void set(double key, double value, int flags); 217 218 /** 219 * Set the value of a given key 220 * @param key the key 221 * @param value the value 222 * @param flags call site flags 223 */ 224 public void set(double key, Object value, int flags); 225 226 /** 227 * Set the value of a given key 228 * @param key the key 229 * @param value the value 230 * @param flags call site flags 231 */ 232 public void set(long key, int value, int flags); 233 234 /** 235 * Set the value of a given key 236 * @param key the key 237 * @param value the value 238 * @param flags call site flags 239 */ 240 public void set(long key, long value, int flags); 241 242 /** 243 * Set the value of a given key 244 * @param key the key 245 * @param value the value 246 * @param flags call site flags 247 */ 248 public void set(long key, double value, int flags); 249 250 /** 251 * Set the value of a given key 252 * @param key the key 253 * @param value the value 254 * @param flags call site flags 255 */ 256 public void set(long key, Object value, int flags); 257 258 /** 259 * Set the value of a given key 260 * @param key the key 261 * @param value the value 262 * @param flags call site flags 263 */ 264 public void set(int key, int value, int flags); 265 266 /** 267 * Set the value of a given key 268 * @param key the key 269 * @param value the value 270 * @param flags call site flags 271 */ 272 public void set(int key, long value, int flags); 273 274 /** 275 * Set the value of a given key 276 * @param key the key 277 * @param value the value 278 * @param flags call site flags 279 */ 280 public void set(int key, double value, int flags); 281 282 /** 283 * Set the value of a given key 284 * @param key the key 285 * @param value the value 286 * @param flags call site flags 287 */ 288 public void set(int key, Object value, int flags); 289 290 /** 291 * Check if the given key exists anywhere in the proto chain 292 * @param key the key 293 * @return true if key exists 294 */ 295 public boolean has(Object key); 296 297 /** 298 * Check if the given key exists anywhere in the proto chain 299 * @param key the key 300 * @return true if key exists 301 */ 302 public boolean has(int key); 303 304 /** 305 * Check if the given key exists anywhere in the proto chain 306 * @param key the key 307 * @return true if key exists 308 */ 309 public boolean has(long key); 310 311 /** 312 * Check if the given key exists anywhere in the proto chain 313 * @param key the key 314 * @return true if key exists 315 */ 316 public boolean has(double key); 317 318 /** 319 * Check if the given key exists directly in the implementor 320 * @param key the key 321 * @return true if key exists 322 */ 323 public boolean hasOwnProperty(Object key); 324 325 /** 326 * Check if the given key exists directly in the implementor 327 * @param key the key 328 * @return true if key exists 329 */ 330 public boolean hasOwnProperty(int key); 331 332 /** 333 * Check if the given key exists directly in the implementor 334 * @param key the key 335 * @return true if key exists 336 */ 337 public boolean hasOwnProperty(long key); 338 339 /** 340 * Check if the given key exists directly in the implementor 341 * @param key the key 342 * @return true if key exists 343 */ 344 public boolean hasOwnProperty(double key); 345 346 /** 347 * Delete a property with the given key from the implementor 348 * @param key the key 349 * @param strict are we in strict mode 350 * @return true if deletion succeeded, false otherwise 351 */ 352 public boolean delete(int key, boolean strict); 353 354 /** 355 * Delete a property with the given key from the implementor 356 * @param key the key 357 * @param strict are we in strict mode 358 * @return true if deletion succeeded, false otherwise 359 */ 360 public boolean delete(long key, boolean strict); 361 362 /** 363 * Delete a property with the given key from the implementor 364 * @param key the key 365 * @param strict are we in strict mode 366 * @return true if deletion succeeded, false otherwise 367 */ 368 public boolean delete(double key, boolean strict); 369 370 /** 371 * Delete a property with the given key from the implementor 372 * @param key the key 373 * @param strict are we in strict mode 374 * @return true if deletion succeeded, false otherwise 375 */ 376 public boolean delete(Object key, boolean strict); 377 }