745 final Global global = Global.instanceFrom(self); |
744 final Global global = Global.instanceFrom(self); |
746 global.float64Array = value; |
745 global.float64Array = value; |
747 } |
746 } |
748 |
747 |
749 private volatile Object float64Array; |
748 private volatile Object float64Array; |
|
749 |
|
750 |
|
751 /** |
|
752 * Getter for the Symbol property. |
|
753 * |
|
754 * @param self self reference |
|
755 * @return the value of the Symbol property |
|
756 */ |
|
757 @Getter(name = "Symbol", attributes = Attribute.NOT_ENUMERABLE) |
|
758 public static Object getSymbol(final Object self) { |
|
759 final Global global = Global.instanceFrom(self); |
|
760 if (global.symbol == LAZY_SENTINEL) { |
|
761 global.symbol = global.getBuiltinSymbol(); |
|
762 } |
|
763 return global.symbol; |
|
764 } |
|
765 |
|
766 /** |
|
767 * Setter for the Symbol property. |
|
768 * |
|
769 * @param self self reference |
|
770 * @param value value of the Symbol property |
|
771 */ |
|
772 @Setter(name = "Symbol", attributes = Attribute.NOT_ENUMERABLE) |
|
773 public static void setSymbol(final Object self, final Object value) { |
|
774 Global.instanceFrom(self).symbol = value; |
|
775 } |
|
776 |
|
777 private volatile Object symbol; |
|
778 |
|
779 /** |
|
780 * Getter for the Map property. |
|
781 * |
|
782 * @param self self reference |
|
783 * @return the value of the Map property |
|
784 */ |
|
785 @Getter(name = "Map", attributes = Attribute.NOT_ENUMERABLE) |
|
786 public static Object getMap(final Object self) { |
|
787 final Global global = Global.instanceFrom(self); |
|
788 if (global.map == LAZY_SENTINEL) { |
|
789 global.map = global.getBuiltinMap(); |
|
790 } |
|
791 return global.map; |
|
792 } |
|
793 |
|
794 /** |
|
795 * Setter for the Map property. |
|
796 * |
|
797 * @param self self reference |
|
798 * @param value value of the Map property |
|
799 */ |
|
800 @Setter(name = "Map", attributes = Attribute.NOT_ENUMERABLE) |
|
801 public static void setMap(final Object self, final Object value) { |
|
802 Global.instanceFrom(self).map = value; |
|
803 } |
|
804 |
|
805 private volatile Object map; |
|
806 |
|
807 /** |
|
808 * Getter for the WeakMap property. |
|
809 * |
|
810 * @param self self reference |
|
811 * @return the value of the WeakMap property |
|
812 */ |
|
813 @Getter(name = "WeakMap", attributes = Attribute.NOT_ENUMERABLE) |
|
814 public static Object getWeakMap(final Object self) { |
|
815 final Global global = Global.instanceFrom(self); |
|
816 if (global.weakMap == LAZY_SENTINEL) { |
|
817 global.weakMap = global.getBuiltinWeakMap(); |
|
818 } |
|
819 return global.weakMap; |
|
820 } |
|
821 |
|
822 /** |
|
823 * Setter for the WeakMap property. |
|
824 * |
|
825 * @param self self reference |
|
826 * @param value value of the WeakMap property |
|
827 */ |
|
828 @Setter(name = "WeakMap", attributes = Attribute.NOT_ENUMERABLE) |
|
829 public static void setWeakMap(final Object self, final Object value) { |
|
830 Global.instanceFrom(self).weakMap = value; |
|
831 } |
|
832 |
|
833 private volatile Object weakMap; |
|
834 |
|
835 /** |
|
836 * Getter for the Set property. |
|
837 * |
|
838 * @param self self reference |
|
839 * @return the value of the Set property |
|
840 */ |
|
841 @Getter(name = "Set", attributes = Attribute.NOT_ENUMERABLE) |
|
842 public static Object getSet(final Object self) { |
|
843 final Global global = Global.instanceFrom(self); |
|
844 if (global.set == LAZY_SENTINEL) { |
|
845 global.set = global.getBuiltinSet(); |
|
846 } |
|
847 return global.set; |
|
848 } |
|
849 |
|
850 /** |
|
851 * Setter for the Set property. |
|
852 * |
|
853 * @param self self reference |
|
854 * @param value value of the Set property |
|
855 */ |
|
856 @Setter(name = "Set", attributes = Attribute.NOT_ENUMERABLE) |
|
857 public static void setSet(final Object self, final Object value) { |
|
858 Global.instanceFrom(self).set = value; |
|
859 } |
|
860 |
|
861 private volatile Object set; |
|
862 |
|
863 /** |
|
864 * Getter for the WeakSet property. |
|
865 * |
|
866 * @param self self reference |
|
867 * @return the value of the WeakSet property |
|
868 */ |
|
869 @Getter(name = "WeakSet", attributes = Attribute.NOT_ENUMERABLE) |
|
870 public static Object getWeakSet(final Object self) { |
|
871 final Global global = Global.instanceFrom(self); |
|
872 if (global.weakSet == LAZY_SENTINEL) { |
|
873 global.weakSet = global.getBuiltinWeakSet(); |
|
874 } |
|
875 return global.weakSet; |
|
876 } |
|
877 |
|
878 /** |
|
879 * Setter for the WeakSet property. |
|
880 * |
|
881 * @param self self reference |
|
882 * @param value value of the WeakSet property |
|
883 */ |
|
884 @Setter(name = "WeakSet", attributes = Attribute.NOT_ENUMERABLE) |
|
885 public static void setWeakSet(final Object self, final Object value) { |
|
886 Global.instanceFrom(self).weakSet = value; |
|
887 } |
|
888 |
|
889 private volatile Object weakSet; |
750 |
890 |
751 /** Nashorn extension: Java access - global.Packages */ |
891 /** Nashorn extension: Java access - global.Packages */ |
752 @Property(name = "Packages", attributes = Attribute.NOT_ENUMERABLE) |
892 @Property(name = "Packages", attributes = Attribute.NOT_ENUMERABLE) |
753 public volatile Object packages; |
893 public volatile Object packages; |
754 |
894 |
905 private ScriptFunction builtinInt32Array; |
1045 private ScriptFunction builtinInt32Array; |
906 private ScriptFunction builtinUint32Array; |
1046 private ScriptFunction builtinUint32Array; |
907 private ScriptFunction builtinFloat32Array; |
1047 private ScriptFunction builtinFloat32Array; |
908 private ScriptFunction builtinFloat64Array; |
1048 private ScriptFunction builtinFloat64Array; |
909 private ScriptFunction builtinSymbol; |
1049 private ScriptFunction builtinSymbol; |
|
1050 private ScriptFunction builtinMap; |
|
1051 private ScriptFunction builtinWeakMap; |
|
1052 private ScriptFunction builtinSet; |
|
1053 private ScriptFunction builtinWeakSet; |
|
1054 private ScriptObject builtinIteratorPrototype; |
|
1055 private ScriptObject builtinMapIteratorPrototype; |
|
1056 private ScriptObject builtinSetIteratorPrototype; |
|
1057 private ScriptObject builtinArrayIteratorPrototype; |
|
1058 private ScriptObject builtinStringIteratorPrototype; |
910 |
1059 |
911 /* |
1060 /* |
912 * ECMA section 13.2.3 The [[ThrowTypeError]] Function Object |
1061 * ECMA section 13.2.3 The [[ThrowTypeError]] Function Object |
913 */ |
1062 */ |
914 private ScriptFunction typeErrorThrower; |
1063 private ScriptFunction typeErrorThrower; |
1671 ScriptObject getJSAdapterPrototype() { |
1820 ScriptObject getJSAdapterPrototype() { |
1672 return ScriptFunction.getPrototype(getBuiltinJSAdapter()); |
1821 return ScriptFunction.getPrototype(getBuiltinJSAdapter()); |
1673 } |
1822 } |
1674 |
1823 |
1675 ScriptObject getSymbolPrototype() { |
1824 ScriptObject getSymbolPrototype() { |
1676 return ScriptFunction.getPrototype(builtinSymbol); |
1825 return ScriptFunction.getPrototype(getBuiltinSymbol()); |
|
1826 } |
|
1827 |
|
1828 ScriptObject getMapPrototype() { |
|
1829 return ScriptFunction.getPrototype(getBuiltinMap()); |
|
1830 } |
|
1831 |
|
1832 ScriptObject getWeakMapPrototype() { |
|
1833 return ScriptFunction.getPrototype(getBuiltinWeakMap()); |
|
1834 } |
|
1835 |
|
1836 ScriptObject getSetPrototype() { |
|
1837 return ScriptFunction.getPrototype(getBuiltinSet()); |
|
1838 } |
|
1839 |
|
1840 ScriptObject getWeakSetPrototype() { |
|
1841 return ScriptFunction.getPrototype(getBuiltinWeakSet()); |
|
1842 } |
|
1843 |
|
1844 ScriptObject getIteratorPrototype() { |
|
1845 if (builtinIteratorPrototype == null) { |
|
1846 builtinIteratorPrototype = initPrototype("AbstractIterator", getObjectPrototype()); |
|
1847 } |
|
1848 return builtinIteratorPrototype; |
|
1849 } |
|
1850 |
|
1851 ScriptObject getMapIteratorPrototype() { |
|
1852 if (builtinMapIteratorPrototype == null) { |
|
1853 builtinMapIteratorPrototype = initPrototype("MapIterator", getIteratorPrototype()); |
|
1854 } |
|
1855 return builtinMapIteratorPrototype; |
|
1856 } |
|
1857 |
|
1858 ScriptObject getSetIteratorPrototype() { |
|
1859 if (builtinSetIteratorPrototype == null) { |
|
1860 builtinSetIteratorPrototype = initPrototype("SetIterator", getIteratorPrototype()); |
|
1861 } |
|
1862 return builtinSetIteratorPrototype; |
|
1863 } |
|
1864 |
|
1865 ScriptObject getArrayIteratorPrototype() { |
|
1866 if (builtinArrayIteratorPrototype == null) { |
|
1867 builtinArrayIteratorPrototype = initPrototype("ArrayIterator", getIteratorPrototype()); |
|
1868 } |
|
1869 return builtinArrayIteratorPrototype; |
|
1870 } |
|
1871 |
|
1872 ScriptObject getStringIteratorPrototype() { |
|
1873 if (builtinStringIteratorPrototype == null) { |
|
1874 builtinStringIteratorPrototype = initPrototype("StringIterator", getIteratorPrototype()); |
|
1875 } |
|
1876 return builtinStringIteratorPrototype; |
1677 } |
1877 } |
1678 |
1878 |
1679 private synchronized ScriptFunction getBuiltinArrayBuffer() { |
1879 private synchronized ScriptFunction getBuiltinArrayBuffer() { |
1680 if (this.builtinArrayBuffer == null) { |
1880 if (this.builtinArrayBuffer == null) { |
1681 this.builtinArrayBuffer = initConstructorAndSwitchPoint("ArrayBuffer", ScriptFunction.class); |
1881 this.builtinArrayBuffer = initConstructorAndSwitchPoint("ArrayBuffer", ScriptFunction.class); |
1912 private synchronized ScriptFunction getBuiltinURIError() { |
2112 private synchronized ScriptFunction getBuiltinURIError() { |
1913 if (this.builtinURIError == null) { |
2113 if (this.builtinURIError == null) { |
1914 this.builtinURIError = initErrorSubtype("URIError", getErrorPrototype()); |
2114 this.builtinURIError = initErrorSubtype("URIError", getErrorPrototype()); |
1915 } |
2115 } |
1916 return this.builtinURIError; |
2116 return this.builtinURIError; |
|
2117 } |
|
2118 |
|
2119 private synchronized ScriptFunction getBuiltinSymbol() { |
|
2120 if (this.builtinSymbol == null) { |
|
2121 this.builtinSymbol = initConstructorAndSwitchPoint("Symbol", ScriptFunction.class); |
|
2122 } |
|
2123 return this.builtinSymbol; |
|
2124 } |
|
2125 |
|
2126 private synchronized ScriptFunction getBuiltinMap() { |
|
2127 if (this.builtinMap == null) { |
|
2128 this.builtinMap = initConstructorAndSwitchPoint("Map", ScriptFunction.class); |
|
2129 } |
|
2130 return this.builtinMap; |
|
2131 } |
|
2132 |
|
2133 private synchronized ScriptFunction getBuiltinWeakMap() { |
|
2134 if (this.builtinWeakMap == null) { |
|
2135 this.builtinWeakMap = initConstructorAndSwitchPoint("WeakMap", ScriptFunction.class); |
|
2136 } |
|
2137 return this.builtinWeakMap; |
|
2138 } |
|
2139 |
|
2140 private synchronized ScriptFunction getBuiltinSet() { |
|
2141 if (this.builtinSet == null) { |
|
2142 this.builtinSet = initConstructorAndSwitchPoint("Set", ScriptFunction.class); |
|
2143 } |
|
2144 return this.builtinSet; |
|
2145 } |
|
2146 |
|
2147 private synchronized ScriptFunction getBuiltinWeakSet() { |
|
2148 if (this.builtinWeakSet == null) { |
|
2149 this.builtinWeakSet = initConstructorAndSwitchPoint("WeakSet", ScriptFunction.class); |
|
2150 } |
|
2151 return this.builtinWeakSet; |
1917 } |
2152 } |
1918 |
2153 |
1919 @Override |
2154 @Override |
1920 public String getClassName() { |
2155 public String getClassName() { |
1921 return "global"; |
2156 return "global"; |
2309 this.builtinBoolean = initConstructorAndSwitchPoint("Boolean", ScriptFunction.class); |
2544 this.builtinBoolean = initConstructorAndSwitchPoint("Boolean", ScriptFunction.class); |
2310 this.builtinNumber = initConstructorAndSwitchPoint("Number", ScriptFunction.class); |
2545 this.builtinNumber = initConstructorAndSwitchPoint("Number", ScriptFunction.class); |
2311 this.builtinString = initConstructorAndSwitchPoint("String", ScriptFunction.class); |
2546 this.builtinString = initConstructorAndSwitchPoint("String", ScriptFunction.class); |
2312 this.builtinMath = initConstructorAndSwitchPoint("Math", ScriptObject.class); |
2547 this.builtinMath = initConstructorAndSwitchPoint("Math", ScriptObject.class); |
2313 |
2548 |
2314 if (env._es6) { |
|
2315 this.builtinSymbol = initConstructorAndSwitchPoint("Symbol", ScriptFunction.class); |
|
2316 } else { |
|
2317 // We need to manually delete nasgen-generated properties we don't want |
|
2318 this.delete("Symbol", false); |
|
2319 this.builtinObject.delete("getOwnPropertySymbols", false); |
|
2320 } |
|
2321 |
|
2322 // initialize String.prototype.length to 0 |
2549 // initialize String.prototype.length to 0 |
2323 // add String.prototype.length |
2550 // add String.prototype.length |
2324 final ScriptObject stringPrototype = getStringPrototype(); |
2551 final ScriptObject stringPrototype = getStringPrototype(); |
2325 stringPrototype.addOwnProperty("length", Attribute.NON_ENUMERABLE_CONSTANT, 0.0); |
2552 stringPrototype.addOwnProperty("length", Attribute.NON_ENUMERABLE_CONSTANT, 0.0); |
2326 |
2553 |
2327 // set isArray flag on Array.prototype |
2554 // set isArray flag on Array.prototype |
2328 final ScriptObject arrayPrototype = getArrayPrototype(); |
2555 final ScriptObject arrayPrototype = getArrayPrototype(); |
2329 arrayPrototype.setIsArray(); |
2556 arrayPrototype.setIsArray(); |
|
2557 |
|
2558 if (env._es6) { |
|
2559 this.symbol = LAZY_SENTINEL; |
|
2560 this.map = LAZY_SENTINEL; |
|
2561 this.weakMap = LAZY_SENTINEL; |
|
2562 this.set = LAZY_SENTINEL; |
|
2563 this.weakSet = LAZY_SENTINEL; |
|
2564 } else { |
|
2565 // We need to manually delete nasgen-generated properties we don't want |
|
2566 this.delete("Symbol", false); |
|
2567 this.delete("Map", false); |
|
2568 this.delete("WeakMap", false); |
|
2569 this.delete("Set", false); |
|
2570 this.delete("WeakSet", false); |
|
2571 builtinObject.delete("getOwnPropertySymbols", false); |
|
2572 arrayPrototype.delete("entries", false); |
|
2573 arrayPrototype.delete("keys", false); |
|
2574 arrayPrototype.delete("values", false); |
|
2575 } |
2330 |
2576 |
2331 // Error stuff |
2577 // Error stuff |
2332 initErrorObjects(); |
2578 initErrorObjects(); |
2333 |
2579 |
2334 // java access |
2580 // java access |