johnson 2.0.0.pre1 → 2.0.0.pre2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (311) hide show
  1. data/CHANGELOG.rdoc +12 -0
  2. data/Manifest.txt +4 -285
  3. data/Rakefile +13 -20
  4. data/ext/tracemonkey/global.cc +4 -1
  5. data/ext/tracemonkey/js.cc +30 -33
  6. data/ext/tracemonkey/runtime.cc +96 -6
  7. data/ext/tracemonkey/split_global.cc +0 -5
  8. data/ext/tracemonkey/tracemonkey.h +2 -2
  9. data/lib/johnson.rb +2 -2
  10. data/lib/johnson/runtime.rb +25 -15
  11. data/lib/johnson/tracemonkey/runtime.rb +6 -3
  12. data/vendor/tracemonkey/config/system-headers +1 -3
  13. data/vendor/tracemonkey/jscntxt.h +5 -2
  14. data/vendor/tracemonkey/jsdbgapi.cpp +9 -1
  15. data/vendor/tracemonkey/jsdbgapi.h +4 -0
  16. data/vendor/tracemonkey/tests/ecma/NativeObjects/browser.js +0 -0
  17. data/vendor/tracemonkey/tests/ecma/NativeObjects/jstests.list +0 -0
  18. data/vendor/tracemonkey/tests/ecma_3_1/Object/jstests.list +1 -1
  19. data/vendor/tracemonkey/tests/js1_3/misc/browser.js +0 -0
  20. data/vendor/tracemonkey/tests/js1_3/misc/jstests.list +0 -0
  21. data/vendor/tracemonkey/tests/js1_5/Regress/jstests.list +4 -4
  22. data/vendor/tracemonkey/tests/js1_5/Scope/jstests.list +1 -1
  23. data/vendor/tracemonkey/tests/js1_5/decompilation/jstests.list +2 -2
  24. data/vendor/tracemonkey/tests/js1_7/decompilation/jstests.list +1 -1
  25. data/vendor/tracemonkey/tests/shell.js +2 -1
  26. metadata +51 -309
  27. data/ext/spidermonkey/context.c +0 -116
  28. data/ext/spidermonkey/context.h +0 -19
  29. data/ext/spidermonkey/conversions.c +0 -361
  30. data/ext/spidermonkey/conversions.h +0 -31
  31. data/ext/spidermonkey/debugger.c +0 -234
  32. data/ext/spidermonkey/debugger.h +0 -10
  33. data/ext/spidermonkey/extconf.rb +0 -32
  34. data/ext/spidermonkey/extensions.c +0 -37
  35. data/ext/spidermonkey/extensions.h +0 -12
  36. data/ext/spidermonkey/global.c +0 -40
  37. data/ext/spidermonkey/global.h +0 -11
  38. data/ext/spidermonkey/idhash.c +0 -16
  39. data/ext/spidermonkey/idhash.h +0 -8
  40. data/ext/spidermonkey/immutable_node.c +0 -1153
  41. data/ext/spidermonkey/immutable_node.c.erb +0 -523
  42. data/ext/spidermonkey/immutable_node.h +0 -22
  43. data/ext/spidermonkey/jroot.h +0 -197
  44. data/ext/spidermonkey/js_land_proxy.c +0 -620
  45. data/ext/spidermonkey/js_land_proxy.h +0 -20
  46. data/ext/spidermonkey/ruby_land_proxy.c +0 -618
  47. data/ext/spidermonkey/ruby_land_proxy.h +0 -38
  48. data/ext/spidermonkey/runtime.c +0 -396
  49. data/ext/spidermonkey/runtime.h +0 -27
  50. data/ext/spidermonkey/spidermonkey.c +0 -22
  51. data/ext/spidermonkey/spidermonkey.h +0 -29
  52. data/lib/johnson/spidermonkey.rb +0 -12
  53. data/lib/johnson/spidermonkey/context.rb +0 -10
  54. data/lib/johnson/spidermonkey/debugger.rb +0 -67
  55. data/lib/johnson/spidermonkey/immutable_node.rb +0 -282
  56. data/lib/johnson/spidermonkey/js_land_proxy.rb +0 -64
  57. data/lib/johnson/spidermonkey/mutable_tree_visitor.rb +0 -242
  58. data/lib/johnson/spidermonkey/ruby_land_proxy.rb +0 -17
  59. data/lib/johnson/spidermonkey/runtime.rb +0 -74
  60. data/test/johnson/spidermonkey/context_test.rb +0 -21
  61. data/test/johnson/spidermonkey/immutable_node_test.rb +0 -34
  62. data/test/johnson/spidermonkey/js_land_proxy_test.rb +0 -273
  63. data/test/johnson/spidermonkey/ruby_land_proxy_test.rb +0 -274
  64. data/test/johnson/spidermonkey/runtime_test.rb +0 -41
  65. data/vendor/spidermonkey/.cvsignore +0 -9
  66. data/vendor/spidermonkey/Makefile.in +0 -449
  67. data/vendor/spidermonkey/Makefile.ref +0 -365
  68. data/vendor/spidermonkey/README.html +0 -820
  69. data/vendor/spidermonkey/SpiderMonkey.rsp +0 -12
  70. data/vendor/spidermonkey/Y.js +0 -19
  71. data/vendor/spidermonkey/build.mk +0 -43
  72. data/vendor/spidermonkey/config.mk +0 -192
  73. data/vendor/spidermonkey/config/AIX4.1.mk +0 -65
  74. data/vendor/spidermonkey/config/AIX4.2.mk +0 -64
  75. data/vendor/spidermonkey/config/AIX4.3.mk +0 -65
  76. data/vendor/spidermonkey/config/Darwin.mk +0 -83
  77. data/vendor/spidermonkey/config/Darwin1.3.mk +0 -81
  78. data/vendor/spidermonkey/config/Darwin1.4.mk +0 -41
  79. data/vendor/spidermonkey/config/Darwin5.2.mk +0 -81
  80. data/vendor/spidermonkey/config/Darwin5.3.mk +0 -81
  81. data/vendor/spidermonkey/config/HP-UXB.10.10.mk +0 -77
  82. data/vendor/spidermonkey/config/HP-UXB.10.20.mk +0 -77
  83. data/vendor/spidermonkey/config/HP-UXB.11.00.mk +0 -80
  84. data/vendor/spidermonkey/config/IRIX.mk +0 -87
  85. data/vendor/spidermonkey/config/IRIX5.3.mk +0 -44
  86. data/vendor/spidermonkey/config/IRIX6.1.mk +0 -44
  87. data/vendor/spidermonkey/config/IRIX6.2.mk +0 -44
  88. data/vendor/spidermonkey/config/IRIX6.3.mk +0 -44
  89. data/vendor/spidermonkey/config/IRIX6.5.mk +0 -44
  90. data/vendor/spidermonkey/config/Linux_All.mk +0 -103
  91. data/vendor/spidermonkey/config/Mac_OS10.0.mk +0 -82
  92. data/vendor/spidermonkey/config/OSF1V4.0.mk +0 -72
  93. data/vendor/spidermonkey/config/OSF1V5.0.mk +0 -69
  94. data/vendor/spidermonkey/config/SunOS4.1.4.mk +0 -101
  95. data/vendor/spidermonkey/config/SunOS5.10.mk +0 -50
  96. data/vendor/spidermonkey/config/SunOS5.3.mk +0 -91
  97. data/vendor/spidermonkey/config/SunOS5.4.mk +0 -92
  98. data/vendor/spidermonkey/config/SunOS5.5.1.mk +0 -44
  99. data/vendor/spidermonkey/config/SunOS5.5.mk +0 -87
  100. data/vendor/spidermonkey/config/SunOS5.6.mk +0 -89
  101. data/vendor/spidermonkey/config/SunOS5.7.mk +0 -44
  102. data/vendor/spidermonkey/config/SunOS5.8.mk +0 -44
  103. data/vendor/spidermonkey/config/SunOS5.9.mk +0 -44
  104. data/vendor/spidermonkey/config/WINNT4.0.mk +0 -117
  105. data/vendor/spidermonkey/config/WINNT5.0.mk +0 -117
  106. data/vendor/spidermonkey/config/WINNT5.1.mk +0 -117
  107. data/vendor/spidermonkey/config/WINNT5.2.mk +0 -117
  108. data/vendor/spidermonkey/config/WINNT6.0.mk +0 -117
  109. data/vendor/spidermonkey/config/dgux.mk +0 -64
  110. data/vendor/spidermonkey/editline/Makefile.ref +0 -144
  111. data/vendor/spidermonkey/editline/README +0 -83
  112. data/vendor/spidermonkey/editline/editline.3 +0 -175
  113. data/vendor/spidermonkey/editline/editline.c +0 -1369
  114. data/vendor/spidermonkey/editline/editline.h +0 -135
  115. data/vendor/spidermonkey/editline/sysunix.c +0 -182
  116. data/vendor/spidermonkey/editline/unix.h +0 -82
  117. data/vendor/spidermonkey/fdlibm/.cvsignore +0 -7
  118. data/vendor/spidermonkey/fdlibm/Makefile.in +0 -127
  119. data/vendor/spidermonkey/fdlibm/Makefile.ref +0 -192
  120. data/vendor/spidermonkey/fdlibm/e_acos.c +0 -147
  121. data/vendor/spidermonkey/fdlibm/e_acosh.c +0 -105
  122. data/vendor/spidermonkey/fdlibm/e_asin.c +0 -156
  123. data/vendor/spidermonkey/fdlibm/e_atan2.c +0 -165
  124. data/vendor/spidermonkey/fdlibm/e_atanh.c +0 -110
  125. data/vendor/spidermonkey/fdlibm/e_cosh.c +0 -133
  126. data/vendor/spidermonkey/fdlibm/e_exp.c +0 -202
  127. data/vendor/spidermonkey/fdlibm/e_fmod.c +0 -184
  128. data/vendor/spidermonkey/fdlibm/e_gamma.c +0 -71
  129. data/vendor/spidermonkey/fdlibm/e_gamma_r.c +0 -70
  130. data/vendor/spidermonkey/fdlibm/e_hypot.c +0 -173
  131. data/vendor/spidermonkey/fdlibm/e_j0.c +0 -524
  132. data/vendor/spidermonkey/fdlibm/e_j1.c +0 -523
  133. data/vendor/spidermonkey/fdlibm/e_jn.c +0 -315
  134. data/vendor/spidermonkey/fdlibm/e_lgamma.c +0 -71
  135. data/vendor/spidermonkey/fdlibm/e_lgamma_r.c +0 -347
  136. data/vendor/spidermonkey/fdlibm/e_log.c +0 -184
  137. data/vendor/spidermonkey/fdlibm/e_log10.c +0 -134
  138. data/vendor/spidermonkey/fdlibm/e_pow.c +0 -386
  139. data/vendor/spidermonkey/fdlibm/e_rem_pio2.c +0 -222
  140. data/vendor/spidermonkey/fdlibm/e_remainder.c +0 -120
  141. data/vendor/spidermonkey/fdlibm/e_scalb.c +0 -89
  142. data/vendor/spidermonkey/fdlibm/e_sinh.c +0 -122
  143. data/vendor/spidermonkey/fdlibm/e_sqrt.c +0 -497
  144. data/vendor/spidermonkey/fdlibm/fdlibm.h +0 -273
  145. data/vendor/spidermonkey/fdlibm/fdlibm.mak +0 -1453
  146. data/vendor/spidermonkey/fdlibm/fdlibm.mdp +0 -0
  147. data/vendor/spidermonkey/fdlibm/k_cos.c +0 -135
  148. data/vendor/spidermonkey/fdlibm/k_rem_pio2.c +0 -354
  149. data/vendor/spidermonkey/fdlibm/k_sin.c +0 -114
  150. data/vendor/spidermonkey/fdlibm/k_standard.c +0 -785
  151. data/vendor/spidermonkey/fdlibm/k_tan.c +0 -170
  152. data/vendor/spidermonkey/fdlibm/s_asinh.c +0 -101
  153. data/vendor/spidermonkey/fdlibm/s_atan.c +0 -175
  154. data/vendor/spidermonkey/fdlibm/s_cbrt.c +0 -133
  155. data/vendor/spidermonkey/fdlibm/s_ceil.c +0 -120
  156. data/vendor/spidermonkey/fdlibm/s_copysign.c +0 -72
  157. data/vendor/spidermonkey/fdlibm/s_cos.c +0 -118
  158. data/vendor/spidermonkey/fdlibm/s_erf.c +0 -356
  159. data/vendor/spidermonkey/fdlibm/s_expm1.c +0 -267
  160. data/vendor/spidermonkey/fdlibm/s_fabs.c +0 -70
  161. data/vendor/spidermonkey/fdlibm/s_finite.c +0 -71
  162. data/vendor/spidermonkey/fdlibm/s_floor.c +0 -121
  163. data/vendor/spidermonkey/fdlibm/s_frexp.c +0 -99
  164. data/vendor/spidermonkey/fdlibm/s_ilogb.c +0 -85
  165. data/vendor/spidermonkey/fdlibm/s_isnan.c +0 -74
  166. data/vendor/spidermonkey/fdlibm/s_ldexp.c +0 -66
  167. data/vendor/spidermonkey/fdlibm/s_lib_version.c +0 -73
  168. data/vendor/spidermonkey/fdlibm/s_log1p.c +0 -211
  169. data/vendor/spidermonkey/fdlibm/s_logb.c +0 -79
  170. data/vendor/spidermonkey/fdlibm/s_matherr.c +0 -64
  171. data/vendor/spidermonkey/fdlibm/s_modf.c +0 -132
  172. data/vendor/spidermonkey/fdlibm/s_nextafter.c +0 -124
  173. data/vendor/spidermonkey/fdlibm/s_rint.c +0 -131
  174. data/vendor/spidermonkey/fdlibm/s_scalbn.c +0 -107
  175. data/vendor/spidermonkey/fdlibm/s_signgam.c +0 -40
  176. data/vendor/spidermonkey/fdlibm/s_significand.c +0 -68
  177. data/vendor/spidermonkey/fdlibm/s_sin.c +0 -118
  178. data/vendor/spidermonkey/fdlibm/s_tan.c +0 -112
  179. data/vendor/spidermonkey/fdlibm/s_tanh.c +0 -122
  180. data/vendor/spidermonkey/fdlibm/w_acos.c +0 -78
  181. data/vendor/spidermonkey/fdlibm/w_acosh.c +0 -78
  182. data/vendor/spidermonkey/fdlibm/w_asin.c +0 -80
  183. data/vendor/spidermonkey/fdlibm/w_atan2.c +0 -79
  184. data/vendor/spidermonkey/fdlibm/w_atanh.c +0 -81
  185. data/vendor/spidermonkey/fdlibm/w_cosh.c +0 -77
  186. data/vendor/spidermonkey/fdlibm/w_exp.c +0 -88
  187. data/vendor/spidermonkey/fdlibm/w_fmod.c +0 -78
  188. data/vendor/spidermonkey/fdlibm/w_gamma.c +0 -85
  189. data/vendor/spidermonkey/fdlibm/w_gamma_r.c +0 -81
  190. data/vendor/spidermonkey/fdlibm/w_hypot.c +0 -78
  191. data/vendor/spidermonkey/fdlibm/w_j0.c +0 -105
  192. data/vendor/spidermonkey/fdlibm/w_j1.c +0 -106
  193. data/vendor/spidermonkey/fdlibm/w_jn.c +0 -128
  194. data/vendor/spidermonkey/fdlibm/w_lgamma.c +0 -85
  195. data/vendor/spidermonkey/fdlibm/w_lgamma_r.c +0 -81
  196. data/vendor/spidermonkey/fdlibm/w_log.c +0 -78
  197. data/vendor/spidermonkey/fdlibm/w_log10.c +0 -81
  198. data/vendor/spidermonkey/fdlibm/w_pow.c +0 -99
  199. data/vendor/spidermonkey/fdlibm/w_remainder.c +0 -77
  200. data/vendor/spidermonkey/fdlibm/w_scalb.c +0 -95
  201. data/vendor/spidermonkey/fdlibm/w_sinh.c +0 -77
  202. data/vendor/spidermonkey/fdlibm/w_sqrt.c +0 -77
  203. data/vendor/spidermonkey/javascript-trace.d +0 -73
  204. data/vendor/spidermonkey/js.c +0 -3951
  205. data/vendor/spidermonkey/js.mdp +0 -0
  206. data/vendor/spidermonkey/js.msg +0 -308
  207. data/vendor/spidermonkey/js.pkg +0 -2
  208. data/vendor/spidermonkey/js3240.rc +0 -79
  209. data/vendor/spidermonkey/jsOS240.def +0 -654
  210. data/vendor/spidermonkey/jsapi.c +0 -5836
  211. data/vendor/spidermonkey/jsapi.h +0 -2624
  212. data/vendor/spidermonkey/jsarena.c +0 -450
  213. data/vendor/spidermonkey/jsarena.h +0 -318
  214. data/vendor/spidermonkey/jsarray.c +0 -2996
  215. data/vendor/spidermonkey/jsarray.h +0 -127
  216. data/vendor/spidermonkey/jsatom.c +0 -1045
  217. data/vendor/spidermonkey/jsatom.h +0 -442
  218. data/vendor/spidermonkey/jsbit.h +0 -253
  219. data/vendor/spidermonkey/jsbool.c +0 -176
  220. data/vendor/spidermonkey/jsbool.h +0 -73
  221. data/vendor/spidermonkey/jsclist.h +0 -139
  222. data/vendor/spidermonkey/jscntxt.c +0 -1348
  223. data/vendor/spidermonkey/jscntxt.h +0 -1120
  224. data/vendor/spidermonkey/jscompat.h +0 -57
  225. data/vendor/spidermonkey/jsconfig.h +0 -248
  226. data/vendor/spidermonkey/jsconfig.mk +0 -181
  227. data/vendor/spidermonkey/jscpucfg.c +0 -396
  228. data/vendor/spidermonkey/jscpucfg.h +0 -212
  229. data/vendor/spidermonkey/jsdate.c +0 -2390
  230. data/vendor/spidermonkey/jsdate.h +0 -124
  231. data/vendor/spidermonkey/jsdbgapi.c +0 -1802
  232. data/vendor/spidermonkey/jsdbgapi.h +0 -464
  233. data/vendor/spidermonkey/jsdhash.c +0 -868
  234. data/vendor/spidermonkey/jsdhash.h +0 -592
  235. data/vendor/spidermonkey/jsdtoa.c +0 -3167
  236. data/vendor/spidermonkey/jsdtoa.h +0 -130
  237. data/vendor/spidermonkey/jsdtracef.c +0 -317
  238. data/vendor/spidermonkey/jsdtracef.h +0 -77
  239. data/vendor/spidermonkey/jsemit.c +0 -6909
  240. data/vendor/spidermonkey/jsemit.h +0 -741
  241. data/vendor/spidermonkey/jsexn.c +0 -1371
  242. data/vendor/spidermonkey/jsexn.h +0 -96
  243. data/vendor/spidermonkey/jsfile.c +0 -2736
  244. data/vendor/spidermonkey/jsfile.h +0 -56
  245. data/vendor/spidermonkey/jsfile.msg +0 -90
  246. data/vendor/spidermonkey/jsfun.c +0 -2634
  247. data/vendor/spidermonkey/jsfun.h +0 -254
  248. data/vendor/spidermonkey/jsgc.c +0 -3562
  249. data/vendor/spidermonkey/jsgc.h +0 -403
  250. data/vendor/spidermonkey/jshash.c +0 -476
  251. data/vendor/spidermonkey/jshash.h +0 -151
  252. data/vendor/spidermonkey/jsify.pl +0 -485
  253. data/vendor/spidermonkey/jsinterp.c +0 -7007
  254. data/vendor/spidermonkey/jsinterp.h +0 -525
  255. data/vendor/spidermonkey/jsinvoke.c +0 -43
  256. data/vendor/spidermonkey/jsiter.c +0 -1067
  257. data/vendor/spidermonkey/jsiter.h +0 -122
  258. data/vendor/spidermonkey/jskeyword.tbl +0 -124
  259. data/vendor/spidermonkey/jskwgen.c +0 -460
  260. data/vendor/spidermonkey/jslibmath.h +0 -266
  261. data/vendor/spidermonkey/jslock.c +0 -1309
  262. data/vendor/spidermonkey/jslock.h +0 -313
  263. data/vendor/spidermonkey/jslocko.asm +0 -60
  264. data/vendor/spidermonkey/jslog2.c +0 -94
  265. data/vendor/spidermonkey/jslong.c +0 -264
  266. data/vendor/spidermonkey/jslong.h +0 -412
  267. data/vendor/spidermonkey/jsmath.c +0 -567
  268. data/vendor/spidermonkey/jsmath.h +0 -57
  269. data/vendor/spidermonkey/jsnum.c +0 -1239
  270. data/vendor/spidermonkey/jsnum.h +0 -283
  271. data/vendor/spidermonkey/jsobj.c +0 -5282
  272. data/vendor/spidermonkey/jsobj.h +0 -709
  273. data/vendor/spidermonkey/jsopcode.c +0 -5245
  274. data/vendor/spidermonkey/jsopcode.h +0 -394
  275. data/vendor/spidermonkey/jsopcode.tbl +0 -523
  276. data/vendor/spidermonkey/jsotypes.h +0 -202
  277. data/vendor/spidermonkey/jsparse.c +0 -6704
  278. data/vendor/spidermonkey/jsparse.h +0 -511
  279. data/vendor/spidermonkey/jsprf.c +0 -1264
  280. data/vendor/spidermonkey/jsprf.h +0 -150
  281. data/vendor/spidermonkey/jsproto.tbl +0 -128
  282. data/vendor/spidermonkey/jsprvtd.h +0 -267
  283. data/vendor/spidermonkey/jspubtd.h +0 -744
  284. data/vendor/spidermonkey/jsregexp.c +0 -4364
  285. data/vendor/spidermonkey/jsregexp.h +0 -183
  286. data/vendor/spidermonkey/jsreops.tbl +0 -145
  287. data/vendor/spidermonkey/jsscan.c +0 -2012
  288. data/vendor/spidermonkey/jsscan.h +0 -387
  289. data/vendor/spidermonkey/jsscope.c +0 -1957
  290. data/vendor/spidermonkey/jsscope.h +0 -418
  291. data/vendor/spidermonkey/jsscript.c +0 -1832
  292. data/vendor/spidermonkey/jsscript.h +0 -287
  293. data/vendor/spidermonkey/jsshell.msg +0 -50
  294. data/vendor/spidermonkey/jsstddef.h +0 -83
  295. data/vendor/spidermonkey/jsstr.c +0 -5005
  296. data/vendor/spidermonkey/jsstr.h +0 -641
  297. data/vendor/spidermonkey/jstypes.h +0 -475
  298. data/vendor/spidermonkey/jsutil.c +0 -345
  299. data/vendor/spidermonkey/jsutil.h +0 -157
  300. data/vendor/spidermonkey/jsxdrapi.c +0 -800
  301. data/vendor/spidermonkey/jsxdrapi.h +0 -218
  302. data/vendor/spidermonkey/jsxml.c +0 -8476
  303. data/vendor/spidermonkey/jsxml.h +0 -349
  304. data/vendor/spidermonkey/lock_SunOS.s +0 -119
  305. data/vendor/spidermonkey/perfect.js +0 -39
  306. data/vendor/spidermonkey/plify_jsdhash.sed +0 -36
  307. data/vendor/spidermonkey/prmjtime.c +0 -846
  308. data/vendor/spidermonkey/prmjtime.h +0 -103
  309. data/vendor/spidermonkey/resource.h +0 -15
  310. data/vendor/spidermonkey/rules.mk +0 -197
  311. data/vendor/spidermonkey/win32.order +0 -384
@@ -1,57 +0,0 @@
1
- /* ***** BEGIN LICENSE BLOCK *****
2
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3
- *
4
- * The contents of this file are subject to the Mozilla Public License Version
5
- * 1.1 (the "License"); you may not use this file except in compliance with
6
- * the License. You may obtain a copy of the License at
7
- * http://www.mozilla.org/MPL/
8
- *
9
- * Software distributed under the License is distributed on an "AS IS" basis,
10
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11
- * for the specific language governing rights and limitations under the
12
- * License.
13
- *
14
- * The Original Code is Mozilla Communicator client code, released
15
- * March 31, 1998.
16
- *
17
- * The Initial Developer of the Original Code is
18
- * Netscape Communications Corporation.
19
- * Portions created by the Initial Developer are Copyright (C) 1998-1999
20
- * the Initial Developer. All Rights Reserved.
21
- *
22
- * Contributor(s):
23
- *
24
- * Alternatively, the contents of this file may be used under the terms of
25
- * either of the GNU General Public License Version 2 or later (the "GPL"),
26
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27
- * in which case the provisions of the GPL or the LGPL are applicable instead
28
- * of those above. If you wish to allow use of your version of this file only
29
- * under the terms of either the GPL or the LGPL, and not to allow others to
30
- * use your version of this file under the terms of the MPL, indicate your
31
- * decision by deleting the provisions above and replace them with the notice
32
- * and other provisions required by the GPL or the LGPL. If you do not delete
33
- * the provisions above, a recipient may use your version of this file under
34
- * the terms of any one of the MPL, the GPL or the LGPL.
35
- *
36
- * ***** END LICENSE BLOCK ***** */
37
-
38
- /* -*- Mode: C; tab-width: 8 -*-
39
- * Copyright (C) 1998-1999 Netscape Communications Corporation, All Rights Reserved.
40
- */
41
-
42
- #ifndef jsmath_h___
43
- #define jsmath_h___
44
- /*
45
- * JS math functions.
46
- */
47
-
48
- JS_BEGIN_EXTERN_C
49
-
50
- extern JSClass js_MathClass;
51
-
52
- extern JSObject *
53
- js_InitMathClass(JSContext *cx, JSObject *obj);
54
-
55
- JS_END_EXTERN_C
56
-
57
- #endif /* jsmath_h___ */
@@ -1,1239 +0,0 @@
1
- /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2
- *
3
- * ***** BEGIN LICENSE BLOCK *****
4
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5
- *
6
- * The contents of this file are subject to the Mozilla Public License Version
7
- * 1.1 (the "License"); you may not use this file except in compliance with
8
- * the License. You may obtain a copy of the License at
9
- * http://www.mozilla.org/MPL/
10
- *
11
- * Software distributed under the License is distributed on an "AS IS" basis,
12
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13
- * for the specific language governing rights and limitations under the
14
- * License.
15
- *
16
- * The Original Code is Mozilla Communicator client code, released
17
- * March 31, 1998.
18
- *
19
- * The Initial Developer of the Original Code is
20
- * Netscape Communications Corporation.
21
- * Portions created by the Initial Developer are Copyright (C) 1998
22
- * the Initial Developer. All Rights Reserved.
23
- *
24
- * Contributor(s):
25
- * IBM Corp.
26
- *
27
- * Alternatively, the contents of this file may be used under the terms of
28
- * either of the GNU General Public License Version 2 or later (the "GPL"),
29
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30
- * in which case the provisions of the GPL or the LGPL are applicable instead
31
- * of those above. If you wish to allow use of your version of this file only
32
- * under the terms of either the GPL or the LGPL, and not to allow others to
33
- * use your version of this file under the terms of the MPL, indicate your
34
- * decision by deleting the provisions above and replace them with the notice
35
- * and other provisions required by the GPL or the LGPL. If you do not delete
36
- * the provisions above, a recipient may use your version of this file under
37
- * the terms of any one of the MPL, the GPL or the LGPL.
38
- *
39
- * ***** END LICENSE BLOCK ***** */
40
-
41
- /*
42
- * JS number type and wrapper class.
43
- */
44
- #include "jsstddef.h"
45
- #if defined(XP_WIN) || defined(XP_OS2)
46
- #include <float.h>
47
- #endif
48
- #include <locale.h>
49
- #include <limits.h>
50
- #include <math.h>
51
- #include <stdlib.h>
52
- #include <string.h>
53
- #include "jstypes.h"
54
- #include "jsutil.h" /* Added by JSIFY */
55
- #include "jsapi.h"
56
- #include "jsatom.h"
57
- #include "jscntxt.h"
58
- #include "jsconfig.h"
59
- #include "jsdtoa.h"
60
- #include "jsgc.h"
61
- #include "jsinterp.h"
62
- #include "jsnum.h"
63
- #include "jsobj.h"
64
- #include "jsopcode.h"
65
- #include "jsprf.h"
66
- #include "jsscope.h"
67
- #include "jsstr.h"
68
-
69
- static JSBool
70
- num_isNaN(JSContext *cx, uintN argc, jsval *vp)
71
- {
72
- jsdouble x;
73
-
74
- x = js_ValueToNumber(cx, &vp[2]);
75
- if (JSVAL_IS_NULL(vp[2]))
76
- return JS_FALSE;
77
- *vp = BOOLEAN_TO_JSVAL(JSDOUBLE_IS_NaN(x));
78
- return JS_TRUE;
79
- }
80
-
81
- static JSBool
82
- num_isFinite(JSContext *cx, uintN argc, jsval *vp)
83
- {
84
- jsdouble x;
85
-
86
- x = js_ValueToNumber(cx, &vp[2]);
87
- if (JSVAL_IS_NULL(vp[2]))
88
- return JS_FALSE;
89
- *vp = BOOLEAN_TO_JSVAL(JSDOUBLE_IS_FINITE(x));
90
- return JS_TRUE;
91
- }
92
-
93
- static JSBool
94
- num_parseFloat(JSContext *cx, uintN argc, jsval *vp)
95
- {
96
- JSString *str;
97
- jsdouble d;
98
- const jschar *bp, *end, *ep;
99
-
100
- str = js_ValueToString(cx, vp[2]);
101
- if (!str)
102
- return JS_FALSE;
103
- JSSTRING_CHARS_AND_END(str, bp, end);
104
- if (!js_strtod(cx, bp, end, &ep, &d))
105
- return JS_FALSE;
106
- if (ep == bp) {
107
- *vp = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
108
- return JS_TRUE;
109
- }
110
- return js_NewNumberInRootedValue(cx, d, vp);
111
- }
112
-
113
- /* See ECMA 15.1.2.2. */
114
- static JSBool
115
- num_parseInt(JSContext *cx, uintN argc, jsval *vp)
116
- {
117
- jsint radix;
118
- JSString *str;
119
- jsdouble d;
120
- const jschar *bp, *end, *ep;
121
-
122
- if (argc > 1) {
123
- radix = js_ValueToECMAInt32(cx, &vp[3]);
124
- if (JSVAL_IS_NULL(vp[3]))
125
- return JS_FALSE;
126
- } else {
127
- radix = 0;
128
- }
129
- if (radix != 0 && (radix < 2 || radix > 36)) {
130
- *vp = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
131
- return JS_TRUE;
132
- }
133
-
134
- if (JSVAL_IS_INT(vp[2]) && (radix == 0 || radix == 10)) {
135
- *vp = vp[2];
136
- return JS_TRUE;
137
- }
138
-
139
- str = js_ValueToString(cx, vp[2]);
140
- if (!str)
141
- return JS_FALSE;
142
- JSSTRING_CHARS_AND_END(str, bp, end);
143
- if (!js_strtointeger(cx, bp, end, &ep, radix, &d))
144
- return JS_FALSE;
145
- if (ep == bp) {
146
- *vp = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
147
- return JS_TRUE;
148
- }
149
- return js_NewNumberInRootedValue(cx, d, vp);
150
- }
151
-
152
- const char js_Infinity_str[] = "Infinity";
153
- const char js_NaN_str[] = "NaN";
154
- const char js_isNaN_str[] = "isNaN";
155
- const char js_isFinite_str[] = "isFinite";
156
- const char js_parseFloat_str[] = "parseFloat";
157
- const char js_parseInt_str[] = "parseInt";
158
-
159
- static JSFunctionSpec number_functions[] = {
160
- JS_FN(js_isNaN_str, num_isNaN, 1,1,0),
161
- JS_FN(js_isFinite_str, num_isFinite, 1,1,0),
162
- JS_FN(js_parseFloat_str, num_parseFloat, 1,1,0),
163
- JS_FN(js_parseInt_str, num_parseInt, 1,2,0),
164
- JS_FS_END
165
- };
166
-
167
- JSClass js_NumberClass = {
168
- js_Number_str,
169
- JSCLASS_HAS_PRIVATE | JSCLASS_HAS_CACHED_PROTO(JSProto_Number),
170
- JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
171
- JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
172
- JSCLASS_NO_OPTIONAL_MEMBERS
173
- };
174
-
175
- static JSBool
176
- Number(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
177
- {
178
- jsval v;
179
- jsdouble d;
180
-
181
- if (argc != 0) {
182
- d = js_ValueToNumber(cx, &argv[0]);
183
- v = argv[0];
184
- if (JSVAL_IS_NULL(v))
185
- return JS_FALSE;
186
- if (v != JSVAL_TRUE) {
187
- JS_ASSERT(JSVAL_IS_INT(v) || JSVAL_IS_DOUBLE(v));
188
- } else {
189
- if (!js_NewNumberInRootedValue(cx, d, &argv[0]))
190
- return JS_FALSE;
191
- v = argv[0];
192
- }
193
- } else {
194
- v = JSVAL_ZERO;
195
- }
196
- if (!(cx->fp->flags & JSFRAME_CONSTRUCTING)) {
197
- *rval = v;
198
- return JS_TRUE;
199
- }
200
- STOBJ_SET_SLOT(obj, JSSLOT_PRIVATE, v);
201
- return JS_TRUE;
202
- }
203
-
204
- #if JS_HAS_TOSOURCE
205
- static JSBool
206
- num_toSource(JSContext *cx, uintN argc, jsval *vp)
207
- {
208
- jsval v;
209
- jsdouble d;
210
- char numBuf[DTOSTR_STANDARD_BUFFER_SIZE], *numStr;
211
- char buf[64];
212
- JSString *str;
213
-
214
- if (!js_GetPrimitiveThis(cx, vp, &js_NumberClass, &v))
215
- return JS_FALSE;
216
- JS_ASSERT(JSVAL_IS_NUMBER(v));
217
- d = JSVAL_IS_INT(v) ? (jsdouble)JSVAL_TO_INT(v) : *JSVAL_TO_DOUBLE(v);
218
- numStr = JS_dtostr(numBuf, sizeof numBuf, DTOSTR_STANDARD, 0, d);
219
- if (!numStr) {
220
- JS_ReportOutOfMemory(cx);
221
- return JS_FALSE;
222
- }
223
- JS_snprintf(buf, sizeof buf, "(new %s(%s))", js_NumberClass.name, numStr);
224
- str = JS_NewStringCopyZ(cx, buf);
225
- if (!str)
226
- return JS_FALSE;
227
- *vp = STRING_TO_JSVAL(str);
228
- return JS_TRUE;
229
- }
230
- #endif
231
-
232
- /* The buf must be big enough for MIN_INT to fit including '-' and '\0'. */
233
- char *
234
- js_IntToCString(jsint i, char *buf, size_t bufSize)
235
- {
236
- char *cp;
237
- jsuint u;
238
-
239
- u = (i < 0) ? -i : i;
240
-
241
- cp = buf + bufSize; /* one past last buffer cell */
242
- *--cp = '\0'; /* null terminate the string to be */
243
-
244
- /*
245
- * Build the string from behind. We use multiply and subtraction
246
- * instead of modulus because that's much faster.
247
- */
248
- do {
249
- jsuint newu = u / 10;
250
- *--cp = (char)(u - newu * 10) + '0';
251
- u = newu;
252
- } while (u != 0);
253
-
254
- if (i < 0)
255
- *--cp = '-';
256
-
257
- JS_ASSERT(cp >= buf);
258
- return cp;
259
- }
260
-
261
- static JSBool
262
- num_toString(JSContext *cx, uintN argc, jsval *vp)
263
- {
264
- jsval v;
265
- jsdouble d;
266
- jsint base;
267
- JSString *str;
268
-
269
- if (!js_GetPrimitiveThis(cx, vp, &js_NumberClass, &v))
270
- return JS_FALSE;
271
- JS_ASSERT(JSVAL_IS_NUMBER(v));
272
- d = JSVAL_IS_INT(v) ? (jsdouble)JSVAL_TO_INT(v) : *JSVAL_TO_DOUBLE(v);
273
- base = 10;
274
- if (argc != 0 && !JSVAL_IS_VOID(vp[2])) {
275
- base = js_ValueToECMAInt32(cx, &vp[2]);
276
- if (JSVAL_IS_NULL(vp[2]))
277
- return JS_FALSE;
278
- if (base < 2 || base > 36) {
279
- char numBuf[12];
280
- char *numStr = js_IntToCString(base, numBuf, sizeof numBuf);
281
- JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_BAD_RADIX,
282
- numStr);
283
- return JS_FALSE;
284
- }
285
- }
286
- if (base == 10) {
287
- str = js_NumberToString(cx, d);
288
- } else {
289
- char *dStr = JS_dtobasestr(base, d);
290
- if (!dStr) {
291
- JS_ReportOutOfMemory(cx);
292
- return JS_FALSE;
293
- }
294
- str = JS_NewStringCopyZ(cx, dStr);
295
- free(dStr);
296
- }
297
- if (!str)
298
- return JS_FALSE;
299
- *vp = STRING_TO_JSVAL(str);
300
- return JS_TRUE;
301
- }
302
-
303
- static JSBool
304
- num_toLocaleString(JSContext *cx, uintN argc, jsval *vp)
305
- {
306
- char thousandsLength, decimalLength;
307
- const char *numGrouping, *tmpGroup;
308
- JSRuntime *rt;
309
- JSString *numStr, *str;
310
- const char *num, *end, *tmpSrc;
311
- char *buf, *tmpDest;
312
- const char *nint;
313
- int digits, size, remainder, nrepeat;
314
-
315
- /*
316
- * Create the string, move back to bytes to make string twiddling
317
- * a bit easier and so we can insert platform charset seperators.
318
- */
319
- if (!num_toString(cx, 0, vp))
320
- return JS_FALSE;
321
- JS_ASSERT(JSVAL_IS_STRING(*vp));
322
- numStr = JSVAL_TO_STRING(*vp);
323
- num = js_GetStringBytes(cx, numStr);
324
- if (!num)
325
- return JS_FALSE;
326
-
327
- /*
328
- * Find the first non-integer value, whether it be a letter as in
329
- * 'Infinite', a decimal point, or an 'e' from exponential notation.
330
- */
331
- nint = num;
332
- if (*nint == '-')
333
- nint++;
334
- while (*nint >= '0' && *nint <= '9')
335
- nint++;
336
- digits = nint - num;
337
- end = num + digits;
338
- if (!digits)
339
- return JS_TRUE;
340
-
341
- rt = cx->runtime;
342
- thousandsLength = strlen(rt->thousandsSeparator);
343
- decimalLength = strlen(rt->decimalSeparator);
344
-
345
- /* Figure out how long resulting string will be. */
346
- size = digits + (*nint ? strlen(nint + 1) + 1 : 0);
347
- if (*nint == '.')
348
- size += decimalLength;
349
-
350
- numGrouping = tmpGroup = rt->numGrouping;
351
- remainder = digits;
352
- if (*num == '-')
353
- remainder--;
354
-
355
- while (*tmpGroup != CHAR_MAX && *tmpGroup != '\0') {
356
- if (*tmpGroup >= remainder)
357
- break;
358
- size += thousandsLength;
359
- remainder -= *tmpGroup;
360
- tmpGroup++;
361
- }
362
- if (*tmpGroup == '\0' && *numGrouping != '\0') {
363
- nrepeat = (remainder - 1) / tmpGroup[-1];
364
- size += thousandsLength * nrepeat;
365
- remainder -= nrepeat * tmpGroup[-1];
366
- } else {
367
- nrepeat = 0;
368
- }
369
- tmpGroup--;
370
-
371
- buf = (char *)JS_malloc(cx, size + 1);
372
- if (!buf)
373
- return JS_FALSE;
374
-
375
- tmpDest = buf;
376
- tmpSrc = num;
377
-
378
- while (*tmpSrc == '-' || remainder--)
379
- *tmpDest++ = *tmpSrc++;
380
- while (tmpSrc < end) {
381
- strcpy(tmpDest, rt->thousandsSeparator);
382
- tmpDest += thousandsLength;
383
- memcpy(tmpDest, tmpSrc, *tmpGroup);
384
- tmpDest += *tmpGroup;
385
- tmpSrc += *tmpGroup;
386
- if (--nrepeat < 0)
387
- tmpGroup--;
388
- }
389
-
390
- if (*nint == '.') {
391
- strcpy(tmpDest, rt->decimalSeparator);
392
- tmpDest += decimalLength;
393
- strcpy(tmpDest, nint + 1);
394
- } else {
395
- strcpy(tmpDest, nint);
396
- }
397
-
398
- if (cx->localeCallbacks && cx->localeCallbacks->localeToUnicode)
399
- return cx->localeCallbacks->localeToUnicode(cx, buf, vp);
400
-
401
- str = JS_NewString(cx, buf, size);
402
- if (!str) {
403
- JS_free(cx, buf);
404
- return JS_FALSE;
405
- }
406
-
407
- *vp = STRING_TO_JSVAL(str);
408
- return JS_TRUE;
409
- }
410
-
411
- static JSBool
412
- num_valueOf(JSContext *cx, uintN argc, jsval *vp)
413
- {
414
- jsval v;
415
- JSObject *obj;
416
-
417
- v = vp[1];
418
- if (JSVAL_IS_NUMBER(v)) {
419
- *vp = v;
420
- return JS_TRUE;
421
- }
422
- obj = JS_THIS_OBJECT(cx, vp);
423
- if (!JS_InstanceOf(cx, obj, &js_NumberClass, vp + 2))
424
- return JS_FALSE;
425
- *vp = OBJ_GET_SLOT(cx, obj, JSSLOT_PRIVATE);
426
- return JS_TRUE;
427
- }
428
-
429
-
430
- #define MAX_PRECISION 100
431
-
432
- static JSBool
433
- num_to(JSContext *cx, JSDToStrMode zeroArgMode, JSDToStrMode oneArgMode,
434
- jsint precisionMin, jsint precisionMax, jsint precisionOffset,
435
- uintN argc, jsval *vp)
436
- {
437
- jsval v;
438
- jsdouble d, precision;
439
- JSString *str;
440
-
441
- /* Use MAX_PRECISION+1 because precisionOffset can be 1. */
442
- char buf[DTOSTR_VARIABLE_BUFFER_SIZE(MAX_PRECISION+1)];
443
- char *numStr;
444
-
445
- if (!js_GetPrimitiveThis(cx, vp, &js_NumberClass, &v))
446
- return JS_FALSE;
447
- JS_ASSERT(JSVAL_IS_NUMBER(v));
448
- d = JSVAL_IS_INT(v) ? (jsdouble)JSVAL_TO_INT(v) : *JSVAL_TO_DOUBLE(v);
449
-
450
- if (argc == 0) {
451
- precision = 0.0;
452
- oneArgMode = zeroArgMode;
453
- } else {
454
- precision = js_ValueToNumber(cx, &vp[2]);
455
- if (JSVAL_IS_NULL(vp[2]))
456
- return JS_FALSE;
457
- precision = js_DoubleToInteger(precision);
458
- if (precision < precisionMin || precision > precisionMax) {
459
- numStr = JS_dtostr(buf, sizeof buf, DTOSTR_STANDARD, 0, precision);
460
- if (!numStr)
461
- JS_ReportOutOfMemory(cx);
462
- else
463
- JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_PRECISION_RANGE, numStr);
464
- return JS_FALSE;
465
- }
466
- }
467
-
468
- numStr = JS_dtostr(buf, sizeof buf, oneArgMode, (jsint)precision + precisionOffset, d);
469
- if (!numStr) {
470
- JS_ReportOutOfMemory(cx);
471
- return JS_FALSE;
472
- }
473
- str = JS_NewStringCopyZ(cx, numStr);
474
- if (!str)
475
- return JS_FALSE;
476
- *vp = STRING_TO_JSVAL(str);
477
- return JS_TRUE;
478
- }
479
-
480
- /*
481
- * In the following three implementations, we allow a larger range of precision
482
- * than ECMA requires; this is permitted by ECMA-262.
483
- */
484
- static JSBool
485
- num_toFixed(JSContext *cx, uintN argc, jsval *vp)
486
- {
487
- return num_to(cx, DTOSTR_FIXED, DTOSTR_FIXED, -20, MAX_PRECISION, 0,
488
- argc, vp);
489
- }
490
-
491
- static JSBool
492
- num_toExponential(JSContext *cx, uintN argc, jsval *vp)
493
- {
494
- return num_to(cx, DTOSTR_STANDARD_EXPONENTIAL, DTOSTR_EXPONENTIAL, 0,
495
- MAX_PRECISION, 1, argc, vp);
496
- }
497
-
498
- static JSBool
499
- num_toPrecision(JSContext *cx, uintN argc, jsval *vp)
500
- {
501
- if (JSVAL_IS_VOID(vp[2]))
502
- return num_toString(cx, 0, vp);
503
- return num_to(cx, DTOSTR_STANDARD, DTOSTR_PRECISION, 1, MAX_PRECISION, 0,
504
- argc, vp);
505
- }
506
-
507
- static JSFunctionSpec number_methods[] = {
508
- #if JS_HAS_TOSOURCE
509
- JS_FN(js_toSource_str, num_toSource, 0,0,JSFUN_THISP_NUMBER),
510
- #endif
511
- JS_FN(js_toString_str, num_toString, 0,1,JSFUN_THISP_NUMBER),
512
- JS_FN(js_toLocaleString_str, num_toLocaleString, 0,0,JSFUN_THISP_NUMBER),
513
- JS_FN(js_valueOf_str, num_valueOf, 0,0,JSFUN_THISP_NUMBER),
514
- JS_FN("toFixed", num_toFixed, 1,1,JSFUN_THISP_NUMBER),
515
- JS_FN("toExponential", num_toExponential, 1,1,JSFUN_THISP_NUMBER),
516
- JS_FN("toPrecision", num_toPrecision, 1,1,JSFUN_THISP_NUMBER),
517
- JS_FS_END
518
- };
519
-
520
- /* NB: Keep this in synch with number_constants[]. */
521
- enum nc_slot {
522
- NC_NaN,
523
- NC_POSITIVE_INFINITY,
524
- NC_NEGATIVE_INFINITY,
525
- NC_MAX_VALUE,
526
- NC_MIN_VALUE,
527
- NC_LIMIT
528
- };
529
-
530
- /*
531
- * Some to most C compilers forbid spelling these at compile time, or barf
532
- * if you try, so all but MAX_VALUE are set up by js_InitRuntimeNumberState
533
- * using union jsdpun.
534
- */
535
- static JSConstDoubleSpec number_constants[] = {
536
- {0, js_NaN_str, 0,{0,0,0}},
537
- {0, "POSITIVE_INFINITY", 0,{0,0,0}},
538
- {0, "NEGATIVE_INFINITY", 0,{0,0,0}},
539
- {1.7976931348623157E+308, "MAX_VALUE", 0,{0,0,0}},
540
- {0, "MIN_VALUE", 0,{0,0,0}},
541
- {0,0,0,{0,0,0}}
542
- };
543
-
544
- static jsdouble NaN;
545
-
546
- #if (defined XP_WIN || defined XP_OS2) && \
547
- !defined WINCE && \
548
- !defined __MWERKS__ && \
549
- (defined _M_IX86 || \
550
- (defined __GNUC__ && !defined __MINGW32__))
551
-
552
- /*
553
- * Set the exception mask to mask all exceptions and set the FPU precision
554
- * to 53 bit mantissa.
555
- * On Alpha platform this is handled via Compiler option.
556
- */
557
- #define FIX_FPU() _control87(MCW_EM | PC_53, MCW_EM | MCW_PC)
558
-
559
- #else
560
-
561
- #define FIX_FPU() ((void)0)
562
-
563
- #endif
564
-
565
- JSBool
566
- js_InitRuntimeNumberState(JSContext *cx)
567
- {
568
- JSRuntime *rt;
569
- jsdpun u;
570
- struct lconv *locale;
571
-
572
- rt = cx->runtime;
573
- JS_ASSERT(!rt->jsNaN);
574
-
575
- FIX_FPU();
576
-
577
- u.s.hi = JSDOUBLE_HI32_EXPMASK | JSDOUBLE_HI32_MANTMASK;
578
- u.s.lo = 0xffffffff;
579
- number_constants[NC_NaN].dval = NaN = u.d;
580
- rt->jsNaN = js_NewWeaklyRootedDouble(cx, NaN);
581
- if (!rt->jsNaN)
582
- return JS_FALSE;
583
-
584
- u.s.hi = JSDOUBLE_HI32_EXPMASK;
585
- u.s.lo = 0x00000000;
586
- number_constants[NC_POSITIVE_INFINITY].dval = u.d;
587
- rt->jsPositiveInfinity = js_NewWeaklyRootedDouble(cx, u.d);
588
- if (!rt->jsPositiveInfinity)
589
- return JS_FALSE;
590
-
591
- u.s.hi = JSDOUBLE_HI32_SIGNBIT | JSDOUBLE_HI32_EXPMASK;
592
- u.s.lo = 0x00000000;
593
- number_constants[NC_NEGATIVE_INFINITY].dval = u.d;
594
- rt->jsNegativeInfinity = js_NewWeaklyRootedDouble(cx, u.d);
595
- if (!rt->jsNegativeInfinity)
596
- return JS_FALSE;
597
-
598
- u.s.hi = 0;
599
- u.s.lo = 1;
600
- number_constants[NC_MIN_VALUE].dval = u.d;
601
-
602
- locale = localeconv();
603
- rt->thousandsSeparator =
604
- JS_strdup(cx, locale->thousands_sep ? locale->thousands_sep : "'");
605
- rt->decimalSeparator =
606
- JS_strdup(cx, locale->decimal_point ? locale->decimal_point : ".");
607
- rt->numGrouping =
608
- JS_strdup(cx, locale->grouping ? locale->grouping : "\3\0");
609
-
610
- return rt->thousandsSeparator && rt->decimalSeparator && rt->numGrouping;
611
- }
612
-
613
- void
614
- js_TraceRuntimeNumberState(JSTracer *trc)
615
- {
616
- JSRuntime *rt;
617
-
618
- rt = trc->context->runtime;
619
- if (rt->jsNaN)
620
- JS_CALL_DOUBLE_TRACER(trc, rt->jsNaN, "NaN");
621
- if (rt->jsPositiveInfinity)
622
- JS_CALL_DOUBLE_TRACER(trc, rt->jsPositiveInfinity, "+Infinity");
623
- if (rt->jsNegativeInfinity)
624
- JS_CALL_DOUBLE_TRACER(trc, rt->jsNegativeInfinity, "-Infinity");
625
- }
626
-
627
- void
628
- js_FinishRuntimeNumberState(JSContext *cx)
629
- {
630
- JSRuntime *rt = cx->runtime;
631
-
632
- js_UnlockGCThingRT(rt, rt->jsNaN);
633
- js_UnlockGCThingRT(rt, rt->jsNegativeInfinity);
634
- js_UnlockGCThingRT(rt, rt->jsPositiveInfinity);
635
-
636
- rt->jsNaN = NULL;
637
- rt->jsNegativeInfinity = NULL;
638
- rt->jsPositiveInfinity = NULL;
639
-
640
- JS_free(cx, (void *)rt->thousandsSeparator);
641
- JS_free(cx, (void *)rt->decimalSeparator);
642
- JS_free(cx, (void *)rt->numGrouping);
643
- rt->thousandsSeparator = rt->decimalSeparator = rt->numGrouping = NULL;
644
- }
645
-
646
- JSObject *
647
- js_InitNumberClass(JSContext *cx, JSObject *obj)
648
- {
649
- JSObject *proto, *ctor;
650
- JSRuntime *rt;
651
-
652
- /* XXX must do at least once per new thread, so do it per JSContext... */
653
- FIX_FPU();
654
-
655
- if (!JS_DefineFunctions(cx, obj, number_functions))
656
- return NULL;
657
-
658
- proto = JS_InitClass(cx, obj, NULL, &js_NumberClass, Number, 1,
659
- NULL, number_methods, NULL, NULL);
660
- if (!proto || !(ctor = JS_GetConstructor(cx, proto)))
661
- return NULL;
662
- STOBJ_SET_SLOT(proto, JSSLOT_PRIVATE, JSVAL_ZERO);
663
- if (!JS_DefineConstDoubles(cx, ctor, number_constants))
664
- return NULL;
665
-
666
- /* ECMA 15.1.1.1 */
667
- rt = cx->runtime;
668
- if (!JS_DefineProperty(cx, obj, js_NaN_str, DOUBLE_TO_JSVAL(rt->jsNaN),
669
- NULL, NULL, JSPROP_PERMANENT)) {
670
- return NULL;
671
- }
672
-
673
- /* ECMA 15.1.1.2 */
674
- if (!JS_DefineProperty(cx, obj, js_Infinity_str,
675
- DOUBLE_TO_JSVAL(rt->jsPositiveInfinity),
676
- NULL, NULL, JSPROP_PERMANENT)) {
677
- return NULL;
678
- }
679
- return proto;
680
- }
681
-
682
- JSBool
683
- js_NewNumberInRootedValue(JSContext *cx, jsdouble d, jsval *vp)
684
- {
685
- jsint i;
686
-
687
- if (JSDOUBLE_IS_INT(d, i) && INT_FITS_IN_JSVAL(i)) {
688
- *vp = INT_TO_JSVAL(i);
689
- return JS_TRUE;
690
- }
691
- return js_NewDoubleInRootedValue(cx, d, vp);
692
- }
693
-
694
- char *
695
- js_NumberToCString(JSContext *cx, jsdouble d, char *buf, size_t bufSize)
696
- {
697
- jsint i;
698
- char *numStr;
699
-
700
- JS_ASSERT(bufSize >= DTOSTR_STANDARD_BUFFER_SIZE);
701
- if (JSDOUBLE_IS_INT(d, i)) {
702
- numStr = js_IntToCString(i, buf, bufSize);
703
- } else {
704
- numStr = JS_dtostr(buf, bufSize, DTOSTR_STANDARD, 0, d);
705
- if (!numStr) {
706
- JS_ReportOutOfMemory(cx);
707
- return NULL;
708
- }
709
- }
710
- return numStr;
711
- }
712
-
713
- JSString *
714
- js_NumberToString(JSContext *cx, jsdouble d)
715
- {
716
- char buf[DTOSTR_STANDARD_BUFFER_SIZE];
717
- char *numStr;
718
-
719
- numStr = js_NumberToCString(cx, d, buf, sizeof buf);
720
- if (!numStr)
721
- return NULL;
722
- return JS_NewStringCopyZ(cx, numStr);
723
- }
724
-
725
- jsdouble
726
- js_ValueToNumber(JSContext *cx, jsval *vp)
727
- {
728
- jsval v;
729
- JSString *str;
730
- const jschar *bp, *end, *ep;
731
- jsdouble d, *dp;
732
- JSObject *obj;
733
- JSTempValueRooter tvr;
734
-
735
- v = *vp;
736
- for (;;) {
737
- if (JSVAL_IS_INT(v))
738
- return (jsdouble) JSVAL_TO_INT(v);
739
- if (JSVAL_IS_DOUBLE(v))
740
- return *JSVAL_TO_DOUBLE(v);
741
- if (JSVAL_IS_STRING(v)) {
742
- str = JSVAL_TO_STRING(v);
743
-
744
- /*
745
- * Note that ECMA doesn't treat a string beginning with a '0' as
746
- * an octal number here. This works because all such numbers will
747
- * be interpreted as decimal by js_strtod and will never get
748
- * passed to js_strtointeger (which would interpret them as
749
- * octal).
750
- */
751
- JSSTRING_CHARS_AND_END(str, bp, end);
752
- if ((!js_strtod(cx, bp, end, &ep, &d) ||
753
- js_SkipWhiteSpace(ep, end) != end) &&
754
- (!js_strtointeger(cx, bp, end, &ep, 0, &d) ||
755
- js_SkipWhiteSpace(ep, end) != end)) {
756
- break;
757
- }
758
-
759
- /*
760
- * JSVAL_TRUE indicates that double jsval was never constructed
761
- * for the result.
762
- */
763
- *vp = JSVAL_TRUE;
764
- return d;
765
- }
766
- if (JSVAL_IS_BOOLEAN(v)) {
767
- if (JSVAL_TO_BOOLEAN(v)) {
768
- *vp = JSVAL_ONE;
769
- return 1.0;
770
- } else {
771
- *vp = JSVAL_ZERO;
772
- return 0.0;
773
- }
774
- }
775
- if (JSVAL_IS_NULL(v)) {
776
- *vp = JSVAL_ZERO;
777
- return 0.0;
778
- }
779
- if (JSVAL_IS_VOID(v))
780
- break;
781
-
782
- JS_ASSERT(!JSVAL_IS_PRIMITIVE(v));
783
- obj = JSVAL_TO_OBJECT(v);
784
-
785
- /*
786
- * vp roots obj so we cannot use it as an extra root for
787
- * OBJ_DEFAULT_VALUE result when calling the hook.
788
- */
789
- JS_PUSH_SINGLE_TEMP_ROOT(cx, v, &tvr);
790
- if (!OBJ_DEFAULT_VALUE(cx, obj, JSTYPE_NUMBER, &tvr.u.value))
791
- obj = NULL;
792
- else
793
- v = *vp = tvr.u.value;
794
- JS_POP_TEMP_ROOT(cx, &tvr);
795
- if (!obj) {
796
- *vp = JSVAL_NULL;
797
- return 0.0;
798
- }
799
- if (!JSVAL_IS_PRIMITIVE(v))
800
- break;
801
- }
802
-
803
- dp = cx->runtime->jsNaN;
804
- *vp = DOUBLE_TO_JSVAL(dp);
805
- return *dp;
806
- }
807
-
808
- int32
809
- js_ValueToECMAInt32(JSContext *cx, jsval *vp)
810
- {
811
- jsval v;
812
- jsdouble d;
813
-
814
- v = *vp;
815
- if (JSVAL_IS_INT(v))
816
- return JSVAL_TO_INT(v);
817
- if (JSVAL_IS_DOUBLE(v)) {
818
- d = *JSVAL_TO_DOUBLE(v);
819
- *vp = JSVAL_TRUE;
820
- } else {
821
- d = js_ValueToNumber(cx, vp);
822
- if (JSVAL_IS_NULL(*vp))
823
- return 0;
824
- *vp = JSVAL_TRUE;
825
- }
826
- return js_DoubleToECMAInt32(d);
827
- }
828
-
829
- int32
830
- js_DoubleToECMAInt32(jsdouble d)
831
- {
832
- int32 i;
833
- jsdouble two32, two31;
834
-
835
- if (!JSDOUBLE_IS_FINITE(d))
836
- return 0;
837
-
838
- i = (int32) d;
839
- if ((jsdouble) i == d)
840
- return i;
841
-
842
- two32 = 4294967296.0;
843
- two31 = 2147483648.0;
844
- d = fmod(d, two32);
845
- d = (d >= 0) ? floor(d) : ceil(d) + two32;
846
- return (int32) (d >= two31 ? d - two32 : d);
847
- }
848
-
849
- uint32
850
- js_ValueToECMAUint32(JSContext *cx, jsval *vp)
851
- {
852
- jsval v;
853
- jsint i;
854
- jsdouble d;
855
-
856
- v = *vp;
857
- if (JSVAL_IS_INT(v)) {
858
- i = JSVAL_TO_INT(v);
859
- if (i < 0)
860
- *vp = JSVAL_TRUE;
861
- return (uint32) i;
862
- }
863
- if (JSVAL_IS_DOUBLE(v)) {
864
- d = *JSVAL_TO_DOUBLE(v);
865
- *vp = JSVAL_TRUE;
866
- } else {
867
- d = js_ValueToNumber(cx, vp);
868
- if (JSVAL_IS_NULL(*vp))
869
- return 0;
870
- *vp = JSVAL_TRUE;
871
- }
872
- return js_DoubleToECMAUint32(d);
873
- }
874
-
875
- uint32
876
- js_DoubleToECMAUint32(jsdouble d)
877
- {
878
- int32 i;
879
- JSBool neg;
880
- jsdouble two32;
881
-
882
- if (!JSDOUBLE_IS_FINITE(d))
883
- return 0;
884
-
885
- /*
886
- * We check whether d fits int32, not uint32, as all but the ">>>" bit
887
- * manipulation bytecode stores the result as int, not uint. When the
888
- * result does not fit int jsval, it will be stored as a negative double.
889
- */
890
- i = (int32) d;
891
- if ((jsdouble) i == d)
892
- return (int32)i;
893
-
894
- neg = (d < 0);
895
- d = floor(neg ? -d : d);
896
- d = neg ? -d : d;
897
-
898
- two32 = 4294967296.0;
899
- d = fmod(d, two32);
900
-
901
- return (uint32) (d >= 0 ? d : d + two32);
902
- }
903
-
904
- int32
905
- js_ValueToInt32(JSContext *cx, jsval *vp)
906
- {
907
- jsval v;
908
- jsdouble d;
909
-
910
- v = *vp;
911
- if (JSVAL_IS_INT(v))
912
- return JSVAL_TO_INT(v);
913
- d = js_ValueToNumber(cx, vp);
914
- if (JSVAL_IS_NULL(*vp))
915
- return 0;
916
- if (JSVAL_IS_INT(*vp))
917
- return JSVAL_TO_INT(*vp);
918
-
919
- *vp = JSVAL_TRUE;
920
- if (JSDOUBLE_IS_NaN(d) || d <= -2147483649.0 || 2147483648.0 <= d) {
921
- js_ReportValueError(cx, JSMSG_CANT_CONVERT,
922
- JSDVG_SEARCH_STACK, v, NULL);
923
- *vp = JSVAL_NULL;
924
- return 0;
925
- }
926
- return (int32) floor(d + 0.5); /* Round to nearest */
927
- }
928
-
929
- uint16
930
- js_ValueToUint16(JSContext *cx, jsval *vp)
931
- {
932
- jsdouble d;
933
- uint16 u;
934
- jsuint m;
935
- JSBool neg;
936
-
937
- d = js_ValueToNumber(cx, vp);
938
- if (JSVAL_IS_NULL(*vp))
939
- return 0;
940
-
941
- if (JSVAL_IS_INT(*vp)) {
942
- u = (uint16) JSVAL_TO_INT(*vp);
943
- } else if (d == 0 || !JSDOUBLE_IS_FINITE(d)) {
944
- u = (uint16) 0;
945
- } else {
946
- u = (uint16) d;
947
- if ((jsdouble) u != d) {
948
- neg = (d < 0);
949
- d = floor(neg ? -d : d);
950
- d = neg ? -d : d;
951
- m = JS_BIT(16);
952
- d = fmod(d, (double) m);
953
- if (d < 0)
954
- d += m;
955
- u = (uint16) d;
956
- }
957
- }
958
- *vp = INT_TO_JSVAL(u);
959
- return u;
960
- }
961
-
962
- jsdouble
963
- js_DoubleToInteger(jsdouble d)
964
- {
965
- JSBool neg;
966
-
967
- if (d == 0)
968
- return d;
969
- if (!JSDOUBLE_IS_FINITE(d)) {
970
- if (JSDOUBLE_IS_NaN(d))
971
- return 0;
972
- return d;
973
- }
974
- neg = (d < 0);
975
- d = floor(neg ? -d : d);
976
- return neg ? -d : d;
977
- }
978
-
979
- JSBool
980
- js_strtod(JSContext *cx, const jschar *s, const jschar *send,
981
- const jschar **ep, jsdouble *dp)
982
- {
983
- const jschar *s1;
984
- size_t length, i;
985
- char cbuf[32];
986
- char *cstr, *istr, *estr;
987
- JSBool negative;
988
- jsdouble d;
989
-
990
- s1 = js_SkipWhiteSpace(s, send);
991
- length = send - s1;
992
-
993
- /* Use cbuf to avoid malloc */
994
- if (length >= sizeof cbuf) {
995
- cstr = (char *) JS_malloc(cx, length + 1);
996
- if (!cstr)
997
- return JS_FALSE;
998
- } else {
999
- cstr = cbuf;
1000
- }
1001
-
1002
- for (i = 0; i != length; i++) {
1003
- if (s1[i] >> 8)
1004
- break;
1005
- cstr[i] = (char)s1[i];
1006
- }
1007
- cstr[i] = 0;
1008
-
1009
- istr = cstr;
1010
- if ((negative = (*istr == '-')) != 0 || *istr == '+')
1011
- istr++;
1012
- if (!strncmp(istr, js_Infinity_str, sizeof js_Infinity_str - 1)) {
1013
- d = *(negative ? cx->runtime->jsNegativeInfinity : cx->runtime->jsPositiveInfinity);
1014
- estr = istr + 8;
1015
- } else {
1016
- int err;
1017
- d = JS_strtod(cstr, &estr, &err);
1018
- if (err == JS_DTOA_ENOMEM) {
1019
- JS_ReportOutOfMemory(cx);
1020
- if (cstr != cbuf)
1021
- JS_free(cx, cstr);
1022
- return JS_FALSE;
1023
- }
1024
- if (err == JS_DTOA_ERANGE) {
1025
- if (d == HUGE_VAL)
1026
- d = *cx->runtime->jsPositiveInfinity;
1027
- else if (d == -HUGE_VAL)
1028
- d = *cx->runtime->jsNegativeInfinity;
1029
- }
1030
- #ifdef HPUX
1031
- if (d == 0.0 && negative) {
1032
- /*
1033
- * "-0", "-1e-2000" come out as positive zero
1034
- * here on HPUX. Force a negative zero instead.
1035
- */
1036
- JSDOUBLE_HI32(d) = JSDOUBLE_HI32_SIGNBIT;
1037
- JSDOUBLE_LO32(d) = 0;
1038
- }
1039
- #endif
1040
- }
1041
-
1042
- i = estr - cstr;
1043
- if (cstr != cbuf)
1044
- JS_free(cx, cstr);
1045
- *ep = i ? s1 + i : s;
1046
- *dp = d;
1047
- return JS_TRUE;
1048
- }
1049
-
1050
- struct BinaryDigitReader
1051
- {
1052
- uintN base; /* Base of number; must be a power of 2 */
1053
- uintN digit; /* Current digit value in radix given by base */
1054
- uintN digitMask; /* Mask to extract the next bit from digit */
1055
- const jschar *digits; /* Pointer to the remaining digits */
1056
- const jschar *end; /* Pointer to first non-digit */
1057
- };
1058
-
1059
- /* Return the next binary digit from the number or -1 if done */
1060
- static intN GetNextBinaryDigit(struct BinaryDigitReader *bdr)
1061
- {
1062
- intN bit;
1063
-
1064
- if (bdr->digitMask == 0) {
1065
- uintN c;
1066
-
1067
- if (bdr->digits == bdr->end)
1068
- return -1;
1069
-
1070
- c = *bdr->digits++;
1071
- if ('0' <= c && c <= '9')
1072
- bdr->digit = c - '0';
1073
- else if ('a' <= c && c <= 'z')
1074
- bdr->digit = c - 'a' + 10;
1075
- else bdr->digit = c - 'A' + 10;
1076
- bdr->digitMask = bdr->base >> 1;
1077
- }
1078
- bit = (bdr->digit & bdr->digitMask) != 0;
1079
- bdr->digitMask >>= 1;
1080
- return bit;
1081
- }
1082
-
1083
- JSBool
1084
- js_strtointeger(JSContext *cx, const jschar *s, const jschar *send,
1085
- const jschar **ep, jsint base, jsdouble *dp)
1086
- {
1087
- const jschar *s1, *start;
1088
- JSBool negative;
1089
- jsdouble value;
1090
-
1091
- s1 = js_SkipWhiteSpace(s, send);
1092
- if (s1 == send)
1093
- goto no_digits;
1094
- if ((negative = (*s1 == '-')) != 0 || *s1 == '+') {
1095
- s1++;
1096
- if (s1 == send)
1097
- goto no_digits;
1098
- }
1099
-
1100
- if (base == 0) {
1101
- /* No base supplied, or some base that evaluated to 0. */
1102
- if (*s1 == '0') {
1103
- /* It's either hex or octal; only increment char if str isn't '0' */
1104
- if (s1 + 1 != send && (s1[1] == 'X' || s1[1] == 'x')) {
1105
- base = 16;
1106
- s1 += 2;
1107
- if (s1 == send)
1108
- goto no_digits;
1109
- } else {
1110
- base = 8;
1111
- }
1112
- } else {
1113
- base = 10; /* Default to decimal. */
1114
- }
1115
- } else if (base == 16) {
1116
- /* If base is 16, ignore hex prefix. */
1117
- if (*s1 == '0' && s1 + 1 != send && (s1[1] == 'X' || s1[1] == 'x')) {
1118
- s1 += 2;
1119
- if (s1 == send)
1120
- goto no_digits;
1121
- }
1122
- }
1123
-
1124
- /*
1125
- * Done with the preliminaries; find some prefix of the string that's
1126
- * a number in the given base.
1127
- */
1128
- JS_ASSERT(s1 < send);
1129
- start = s1;
1130
- value = 0.0;
1131
- do {
1132
- uintN digit;
1133
- jschar c = *s1;
1134
- if ('0' <= c && c <= '9')
1135
- digit = c - '0';
1136
- else if ('a' <= c && c <= 'z')
1137
- digit = c - 'a' + 10;
1138
- else if ('A' <= c && c <= 'Z')
1139
- digit = c - 'A' + 10;
1140
- else
1141
- break;
1142
- if (digit >= (uintN)base)
1143
- break;
1144
- value = value * base + digit;
1145
- } while (++s1 != send);
1146
-
1147
- if (value >= 9007199254740992.0) {
1148
- if (base == 10) {
1149
- /*
1150
- * If we're accumulating a decimal number and the number is >=
1151
- * 2^53, then the result from the repeated multiply-add above may
1152
- * be inaccurate. Call JS_strtod to get the correct answer.
1153
- */
1154
- size_t i;
1155
- size_t length = s1 - start;
1156
- char *cstr = (char *) JS_malloc(cx, length + 1);
1157
- char *estr;
1158
- int err=0;
1159
-
1160
- if (!cstr)
1161
- return JS_FALSE;
1162
- for (i = 0; i != length; i++)
1163
- cstr[i] = (char)start[i];
1164
- cstr[length] = 0;
1165
-
1166
- value = JS_strtod(cstr, &estr, &err);
1167
- if (err == JS_DTOA_ENOMEM) {
1168
- JS_ReportOutOfMemory(cx);
1169
- JS_free(cx, cstr);
1170
- return JS_FALSE;
1171
- }
1172
- if (err == JS_DTOA_ERANGE && value == HUGE_VAL)
1173
- value = *cx->runtime->jsPositiveInfinity;
1174
- JS_free(cx, cstr);
1175
- } else if ((base & (base - 1)) == 0) {
1176
- /*
1177
- * The number may also be inaccurate for power-of-two bases. This
1178
- * happens if the addition in value * base + digit causes a round-
1179
- * down to an even least significant mantissa bit when the first
1180
- * dropped bit is a one. If any of the following digits in the
1181
- * number (which haven't been added in yet) are nonzero, then the
1182
- * correct action would have been to round up instead of down. An
1183
- * example occurs when reading the number 0x1000000000000081, which
1184
- * rounds to 0x1000000000000000 instead of 0x1000000000000100.
1185
- */
1186
- struct BinaryDigitReader bdr;
1187
- intN bit, bit2;
1188
- intN j;
1189
-
1190
- bdr.base = base;
1191
- bdr.digitMask = 0;
1192
- bdr.digits = start;
1193
- bdr.end = s1;
1194
- value = 0.0;
1195
-
1196
- /* Skip leading zeros. */
1197
- do {
1198
- bit = GetNextBinaryDigit(&bdr);
1199
- } while (bit == 0);
1200
-
1201
- if (bit == 1) {
1202
- /* Gather the 53 significant bits (including the leading 1) */
1203
- value = 1.0;
1204
- for (j = 52; j; j--) {
1205
- bit = GetNextBinaryDigit(&bdr);
1206
- if (bit < 0)
1207
- goto done;
1208
- value = value*2 + bit;
1209
- }
1210
- /* bit2 is the 54th bit (the first dropped from the mantissa) */
1211
- bit2 = GetNextBinaryDigit(&bdr);
1212
- if (bit2 >= 0) {
1213
- jsdouble factor = 2.0;
1214
- intN sticky = 0; /* sticky is 1 if any bit beyond the 54th is 1 */
1215
- intN bit3;
1216
-
1217
- while ((bit3 = GetNextBinaryDigit(&bdr)) >= 0) {
1218
- sticky |= bit3;
1219
- factor *= 2;
1220
- }
1221
- value += bit2 & (bit | sticky);
1222
- value *= factor;
1223
- }
1224
- done:;
1225
- }
1226
- }
1227
- }
1228
- /* We don't worry about inaccurate numbers for any other base. */
1229
-
1230
- if (s1 == start) {
1231
- no_digits:
1232
- *dp = 0.0;
1233
- *ep = s;
1234
- } else {
1235
- *dp = negative ? -value : value;
1236
- *ep = s1;
1237
- }
1238
- return JS_TRUE;
1239
- }