< prev index next >

src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Property.java

Print this page




 433     }
 434 
 435     /**
 436      * get the Object value of this property from {@code owner}. This allows to bypass creation of the
 437      * getter MethodHandle for spill and user accessor properties.
 438      *
 439      * @param self the this object
 440      * @param owner the owner of the property
 441      * @return  the property value
 442      */
 443     public abstract int getIntValue(final ScriptObject self, final ScriptObject owner);
 444 
 445     /**
 446      * get the Object value of this property from {@code owner}. This allows to bypass creation of the
 447      * getter MethodHandle for spill and user accessor properties.
 448      *
 449      * @param self the this object
 450      * @param owner the owner of the property
 451      * @return  the property value
 452      */
 453     public abstract long getLongValue(final ScriptObject self, final ScriptObject owner);
 454 
 455     /**
 456      * get the Object value of this property from {@code owner}. This allows to bypass creation of the
 457      * getter MethodHandle for spill and user accessor properties.
 458      *
 459      * @param self the this object
 460      * @param owner the owner of the property
 461      * @return  the property value
 462      */
 463     public abstract double getDoubleValue(final ScriptObject self, final ScriptObject owner);
 464 
 465     /**
 466      * get the Object value of this property from {@code owner}. This allows to bypass creation of the
 467      * getter MethodHandle for spill and user accessor properties.
 468      *
 469      * @param self the this object
 470      * @param owner the owner of the property
 471      * @return  the property value
 472      */
 473     public abstract Object getObjectValue(final ScriptObject self, final ScriptObject owner);
 474 
 475     /**
 476      * Set the value of this property in {@code owner}. This allows to bypass creation of the
 477      * setter MethodHandle for spill and user accessor properties.
 478      *
 479      * @param self the this object
 480      * @param owner the owner object
 481      * @param value the new property value
 482      * @param strict is this a strict setter?
 483      */
 484     public abstract void setValue(final ScriptObject self, final ScriptObject owner, final int value, final boolean strict);
 485 
 486     /**
 487      * Set the value of this property in {@code owner}. This allows to bypass creation of the
 488      * setter MethodHandle for spill and user accessor properties.
 489      *
 490      * @param self the this object
 491      * @param owner the owner object
 492      * @param value the new property value
 493      * @param strict is this a strict setter?
 494      */
 495     public abstract void setValue(final ScriptObject self, final ScriptObject owner, final long value, final boolean strict);
 496 
 497     /**
 498      * Set the value of this property in {@code owner}. This allows to bypass creation of the
 499      * setter MethodHandle for spill and user accessor properties.
 500      *
 501      * @param self the this object
 502      * @param owner the owner object
 503      * @param value the new property value
 504      * @param strict is this a strict setter?
 505      */
 506     public abstract void setValue(final ScriptObject self, final ScriptObject owner, final double value, final boolean strict);
 507 
 508     /**
 509      * Set the value of this property in {@code owner}. This allows to bypass creation of the
 510      * setter MethodHandle for spill and user accessor properties.
 511      *
 512      * @param self the this object
 513      * @param owner the owner object
 514      * @param value the new property value
 515      * @param strict is this a strict setter?
 516      */
 517     public abstract void setValue(final ScriptObject self, final ScriptObject owner, final Object value, final boolean strict);
 518 
 519     /**
 520      * Abstract method for retrieving the setter for the property. We do not know
 521      * anything about the internal representation when we request the setter, we only
 522      * know that the setter will take the property as a parameter of the given type.
 523      * <p>
 524      * Note that we have to pass the current property map from which we retrieved
 525      * the property here. This is necessary for map guards if, e.g. the internal


 576             return false;
 577         }
 578 
 579         final Property otherProperty = (Property)other;
 580 
 581         return equalsWithoutType(otherProperty) &&
 582                 getLocalType() == otherProperty.getLocalType();
 583     }
 584 
 585     boolean equalsWithoutType(final Property otherProperty) {
 586         return getFlags() == otherProperty.getFlags() &&
 587                 getSlot() == otherProperty.getSlot() &&
 588                 getKey().equals(otherProperty.getKey());
 589     }
 590 
 591     private static String type(final Class<?> type) {
 592         if (type == null) {
 593             return "undef";
 594         } else if (type == int.class) {
 595             return "i";
 596         } else if (type == long.class) {
 597             return "j";
 598         } else if (type == double.class) {
 599             return "d";
 600         } else {
 601             return "o";
 602         }
 603     }
 604 
 605     /**
 606      * Short toString version
 607      * @return short toString
 608      */
 609     public final String toStringShort() {
 610         final StringBuilder sb   = new StringBuilder();
 611         final Class<?>      t = getLocalType();
 612         sb.append(getKey()).append(" (").append(type(t)).append(')');
 613         return sb.toString();
 614     }
 615 
 616     private static String indent(final String str, final int indent) {
 617         final StringBuilder sb = new StringBuilder();




 433     }
 434 
 435     /**
 436      * get the Object value of this property from {@code owner}. This allows to bypass creation of the
 437      * getter MethodHandle for spill and user accessor properties.
 438      *
 439      * @param self the this object
 440      * @param owner the owner of the property
 441      * @return  the property value
 442      */
 443     public abstract int getIntValue(final ScriptObject self, final ScriptObject owner);
 444 
 445     /**
 446      * get the Object value of this property from {@code owner}. This allows to bypass creation of the
 447      * getter MethodHandle for spill and user accessor properties.
 448      *
 449      * @param self the this object
 450      * @param owner the owner of the property
 451      * @return  the property value
 452      */










 453     public abstract double getDoubleValue(final ScriptObject self, final ScriptObject owner);
 454 
 455     /**
 456      * get the Object value of this property from {@code owner}. This allows to bypass creation of the
 457      * getter MethodHandle for spill and user accessor properties.
 458      *
 459      * @param self the this object
 460      * @param owner the owner of the property
 461      * @return  the property value
 462      */
 463     public abstract Object getObjectValue(final ScriptObject self, final ScriptObject owner);
 464 
 465     /**
 466      * Set the value of this property in {@code owner}. This allows to bypass creation of the
 467      * setter MethodHandle for spill and user accessor properties.
 468      *
 469      * @param self the this object
 470      * @param owner the owner object
 471      * @param value the new property value
 472      * @param strict is this a strict setter?
 473      */
 474     public abstract void setValue(final ScriptObject self, final ScriptObject owner, final int value, final boolean strict);
 475 
 476     /**
 477      * Set the value of this property in {@code owner}. This allows to bypass creation of the
 478      * setter MethodHandle for spill and user accessor properties.
 479      *
 480      * @param self the this object
 481      * @param owner the owner object
 482      * @param value the new property value
 483      * @param strict is this a strict setter?
 484      */











 485     public abstract void setValue(final ScriptObject self, final ScriptObject owner, final double value, final boolean strict);
 486 
 487     /**
 488      * Set the value of this property in {@code owner}. This allows to bypass creation of the
 489      * setter MethodHandle for spill and user accessor properties.
 490      *
 491      * @param self the this object
 492      * @param owner the owner object
 493      * @param value the new property value
 494      * @param strict is this a strict setter?
 495      */
 496     public abstract void setValue(final ScriptObject self, final ScriptObject owner, final Object value, final boolean strict);
 497 
 498     /**
 499      * Abstract method for retrieving the setter for the property. We do not know
 500      * anything about the internal representation when we request the setter, we only
 501      * know that the setter will take the property as a parameter of the given type.
 502      * <p>
 503      * Note that we have to pass the current property map from which we retrieved
 504      * the property here. This is necessary for map guards if, e.g. the internal


 555             return false;
 556         }
 557 
 558         final Property otherProperty = (Property)other;
 559 
 560         return equalsWithoutType(otherProperty) &&
 561                 getLocalType() == otherProperty.getLocalType();
 562     }
 563 
 564     boolean equalsWithoutType(final Property otherProperty) {
 565         return getFlags() == otherProperty.getFlags() &&
 566                 getSlot() == otherProperty.getSlot() &&
 567                 getKey().equals(otherProperty.getKey());
 568     }
 569 
 570     private static String type(final Class<?> type) {
 571         if (type == null) {
 572             return "undef";
 573         } else if (type == int.class) {
 574             return "i";


 575         } else if (type == double.class) {
 576             return "d";
 577         } else {
 578             return "o";
 579         }
 580     }
 581 
 582     /**
 583      * Short toString version
 584      * @return short toString
 585      */
 586     public final String toStringShort() {
 587         final StringBuilder sb   = new StringBuilder();
 588         final Class<?>      t = getLocalType();
 589         sb.append(getKey()).append(" (").append(type(t)).append(')');
 590         return sb.toString();
 591     }
 592 
 593     private static String indent(final String str, final int indent) {
 594         final StringBuilder sb = new StringBuilder();


< prev index next >