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

Print this page




  71 
  72     /** Is parameter accessed thru arguments? */
  73     public static final int HAS_ARGUMENTS    = 1 << 4;
  74 
  75     /** Is this a function declaration property ? */
  76     public static final int IS_FUNCTION_DECLARATION = 1 << 5;
  77 
  78     /**
  79      * Is this is a primitive field given to us by Nasgen, i.e.
  80      * something we can be sure remains a constant whose type
  81      * is narrower than object, e.g. Math.PI which is declared
  82      * as a double
  83      */
  84     public static final int IS_NASGEN_PRIMITIVE     = 1 << 6;
  85 
  86     /** Is this a builtin property, e.g. Function.prototype.apply */
  87     public static final int IS_BUILTIN = 1 << 7;
  88 
  89     /** Is this property bound to a receiver? This means get/set operations will be delegated to
  90      *  a statically defined object instead of the object passed as callsite parameter. */
  91     public static final int IS_BOUND                = 1 << 7;
  92 
  93     /** Is this a lexically scoped LET or CONST variable that is dead until it is declared. */
  94     public static final int NEEDS_DECLARATION       = 1 << 8;



  95 
  96     /** Property key. */
  97     private final String key;
  98 
  99     /** Property flags. */
 100     private int flags;
 101 
 102     /** Property field number or spill slot. */
 103     private final int slot;
 104 
 105     /**
 106      * Current type of this object, in object only mode, this is an Object.class. In dual-fields mode
 107      * null means undefined, and primitive types are allowed. The reason a special type is used for
 108      * undefined, is that are no bits left to represent it in primitive types
 109      */
 110     private Class<?> type;
 111 
 112     /** SwitchPoint that is invalidated when property is changed, optional */
 113     protected transient SwitchPoint builtinSwitchPoint;
 114 


 696      */
 697     protected Class<?> getLocalType() {
 698         return getType();
 699     }
 700 
 701     /**
 702      * Check whether this Property can ever change its type. The default is false, and if
 703      * you are not running with dual fields, the type is always object and can never change
 704      * @return true if this property can change types
 705      */
 706     public boolean canChangeType() {
 707         return false;
 708     }
 709 
 710     /**
 711      * Check whether this property represents a function declaration.
 712      * @return whether this property is a function declaration or not.
 713      */
 714     public boolean isFunctionDeclaration() {
 715         return (flags & IS_FUNCTION_DECLARATION) == IS_FUNCTION_DECLARATION;








 716     }
 717 }


  71 
  72     /** Is parameter accessed thru arguments? */
  73     public static final int HAS_ARGUMENTS    = 1 << 4;
  74 
  75     /** Is this a function declaration property ? */
  76     public static final int IS_FUNCTION_DECLARATION = 1 << 5;
  77 
  78     /**
  79      * Is this is a primitive field given to us by Nasgen, i.e.
  80      * something we can be sure remains a constant whose type
  81      * is narrower than object, e.g. Math.PI which is declared
  82      * as a double
  83      */
  84     public static final int IS_NASGEN_PRIMITIVE     = 1 << 6;
  85 
  86     /** Is this a builtin property, e.g. Function.prototype.apply */
  87     public static final int IS_BUILTIN              = 1 << 7;
  88 
  89     /** Is this property bound to a receiver? This means get/set operations will be delegated to
  90      *  a statically defined object instead of the object passed as callsite parameter. */
  91     public static final int IS_BOUND                = 1 << 8;
  92 
  93     /** Is this a lexically scoped LET or CONST variable that is dead until it is declared. */
  94     public static final int NEEDS_DECLARATION       = 1 << 9;
  95 
  96     /** Is this property an ES6 lexical binding? */
  97     public static final int IS_LEXICAL_BINDING      = 1 << 10;
  98 
  99     /** Property key. */
 100     private final String key;
 101 
 102     /** Property flags. */
 103     private int flags;
 104 
 105     /** Property field number or spill slot. */
 106     private final int slot;
 107 
 108     /**
 109      * Current type of this object, in object only mode, this is an Object.class. In dual-fields mode
 110      * null means undefined, and primitive types are allowed. The reason a special type is used for
 111      * undefined, is that are no bits left to represent it in primitive types
 112      */
 113     private Class<?> type;
 114 
 115     /** SwitchPoint that is invalidated when property is changed, optional */
 116     protected transient SwitchPoint builtinSwitchPoint;
 117 


 699      */
 700     protected Class<?> getLocalType() {
 701         return getType();
 702     }
 703 
 704     /**
 705      * Check whether this Property can ever change its type. The default is false, and if
 706      * you are not running with dual fields, the type is always object and can never change
 707      * @return true if this property can change types
 708      */
 709     public boolean canChangeType() {
 710         return false;
 711     }
 712 
 713     /**
 714      * Check whether this property represents a function declaration.
 715      * @return whether this property is a function declaration or not.
 716      */
 717     public boolean isFunctionDeclaration() {
 718         return (flags & IS_FUNCTION_DECLARATION) == IS_FUNCTION_DECLARATION;
 719     }
 720 
 721     /**
 722      * Is this a property defined by ES6 let or const?
 723      * @return true if this property represents a lexical binding.
 724      */
 725     public boolean isLexicalBinding() {
 726         return (flags & IS_LEXICAL_BINDING) == IS_LEXICAL_BINDING;
 727     }
 728 }