src/jdk/nashorn/internal/objects/NativeBoolean.java

Print this page




  42 import jdk.nashorn.internal.runtime.ScriptObject;
  43 import jdk.nashorn.internal.runtime.ScriptRuntime;
  44 import jdk.nashorn.internal.runtime.linker.PrimitiveLookup;
  45 
  46 /**
  47  * ECMA 15.6 Boolean Objects.
  48  */
  49 
  50 @ScriptClass("Boolean")
  51 public final class NativeBoolean extends ScriptObject {
  52     private final boolean value;
  53 
  54     // Method handle to create an object wrapper for a primitive boolean
  55     private static final MethodHandle WRAPFILTER = findOwnMH("wrapFilter", MH.type(NativeBoolean.class, Object.class));
  56     // Method handle to retrieve the Boolean prototype object
  57     private static final MethodHandle PROTOFILTER = findOwnMH("protoFilter", MH.type(Object.class, Object.class));
  58 
  59     // initialized by nasgen
  60     private static PropertyMap $nasgenmap$;
  61 
  62     static PropertyMap getInitialMap() {
  63         return $nasgenmap$;
  64     }
  65 
  66     private NativeBoolean(final boolean value, final ScriptObject proto, final PropertyMap map) {
  67         super(proto, map);
  68         this.value = value;
  69     }
  70 
  71     NativeBoolean(final boolean flag, final Global global) {
  72         this(flag, global.getBooleanPrototype(), getInitialMap());
  73     }
  74 
  75     NativeBoolean(final boolean flag) {
  76         this(flag, Global.instance());
  77     }
  78 
  79     @Override
  80     public String safeToString() {
  81         return "[Boolean " + toString() + "]";
  82     }
  83 
  84     @Override
  85     public String toString() {
  86         return Boolean.toString(getValue());
  87     }
  88 
  89     /**
  90      * Get the value for this NativeBoolean
  91      * @return true or false
  92      */




  42 import jdk.nashorn.internal.runtime.ScriptObject;
  43 import jdk.nashorn.internal.runtime.ScriptRuntime;
  44 import jdk.nashorn.internal.runtime.linker.PrimitiveLookup;
  45 
  46 /**
  47  * ECMA 15.6 Boolean Objects.
  48  */
  49 
  50 @ScriptClass("Boolean")
  51 public final class NativeBoolean extends ScriptObject {
  52     private final boolean value;
  53 
  54     // Method handle to create an object wrapper for a primitive boolean
  55     private static final MethodHandle WRAPFILTER = findOwnMH("wrapFilter", MH.type(NativeBoolean.class, Object.class));
  56     // Method handle to retrieve the Boolean prototype object
  57     private static final MethodHandle PROTOFILTER = findOwnMH("protoFilter", MH.type(Object.class, Object.class));
  58 
  59     // initialized by nasgen
  60     private static PropertyMap $nasgenmap$;
  61 




  62     private NativeBoolean(final boolean value, final ScriptObject proto, final PropertyMap map) {
  63         super(proto, map);
  64         this.value = value;
  65     }
  66 
  67     NativeBoolean(final boolean flag, final Global global) {
  68         this(flag, global.getBooleanPrototype(), $nasgenmap$);
  69     }
  70 
  71     NativeBoolean(final boolean flag) {
  72         this(flag, Global.instance());
  73     }
  74 
  75     @Override
  76     public String safeToString() {
  77         return "[Boolean " + toString() + "]";
  78     }
  79 
  80     @Override
  81     public String toString() {
  82         return Boolean.toString(getValue());
  83     }
  84 
  85     /**
  86      * Get the value for this NativeBoolean
  87      * @return true or false
  88      */