libv8-sgonyea 3.3.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (500) hide show
  1. data/.gitignore +8 -0
  2. data/.gitmodules +3 -0
  3. data/Gemfile +4 -0
  4. data/README.md +76 -0
  5. data/Rakefile +113 -0
  6. data/ext/libv8/extconf.rb +28 -0
  7. data/lib/libv8.rb +15 -0
  8. data/lib/libv8/Makefile +30 -0
  9. data/lib/libv8/detect_cpu.rb +27 -0
  10. data/lib/libv8/fpic-on-linux-amd64.patch +13 -0
  11. data/lib/libv8/v8/.gitignore +35 -0
  12. data/lib/libv8/v8/AUTHORS +44 -0
  13. data/lib/libv8/v8/ChangeLog +2839 -0
  14. data/lib/libv8/v8/LICENSE +52 -0
  15. data/lib/libv8/v8/LICENSE.strongtalk +29 -0
  16. data/lib/libv8/v8/LICENSE.v8 +26 -0
  17. data/lib/libv8/v8/LICENSE.valgrind +45 -0
  18. data/lib/libv8/v8/SConstruct +1478 -0
  19. data/lib/libv8/v8/build/README.txt +49 -0
  20. data/lib/libv8/v8/build/all.gyp +18 -0
  21. data/lib/libv8/v8/build/armu.gypi +32 -0
  22. data/lib/libv8/v8/build/common.gypi +144 -0
  23. data/lib/libv8/v8/build/gyp_v8 +145 -0
  24. data/lib/libv8/v8/include/v8-debug.h +395 -0
  25. data/lib/libv8/v8/include/v8-preparser.h +117 -0
  26. data/lib/libv8/v8/include/v8-profiler.h +505 -0
  27. data/lib/libv8/v8/include/v8-testing.h +104 -0
  28. data/lib/libv8/v8/include/v8.h +4124 -0
  29. data/lib/libv8/v8/include/v8stdint.h +53 -0
  30. data/lib/libv8/v8/preparser/SConscript +38 -0
  31. data/lib/libv8/v8/preparser/preparser-process.cc +379 -0
  32. data/lib/libv8/v8/src/SConscript +368 -0
  33. data/lib/libv8/v8/src/accessors.cc +767 -0
  34. data/lib/libv8/v8/src/accessors.h +123 -0
  35. data/lib/libv8/v8/src/allocation-inl.h +49 -0
  36. data/lib/libv8/v8/src/allocation.cc +122 -0
  37. data/lib/libv8/v8/src/allocation.h +143 -0
  38. data/lib/libv8/v8/src/api.cc +5845 -0
  39. data/lib/libv8/v8/src/api.h +574 -0
  40. data/lib/libv8/v8/src/apinatives.js +110 -0
  41. data/lib/libv8/v8/src/apiutils.h +73 -0
  42. data/lib/libv8/v8/src/arguments.h +118 -0
  43. data/lib/libv8/v8/src/arm/assembler-arm-inl.h +353 -0
  44. data/lib/libv8/v8/src/arm/assembler-arm.cc +2661 -0
  45. data/lib/libv8/v8/src/arm/assembler-arm.h +1375 -0
  46. data/lib/libv8/v8/src/arm/builtins-arm.cc +1658 -0
  47. data/lib/libv8/v8/src/arm/code-stubs-arm.cc +6398 -0
  48. data/lib/libv8/v8/src/arm/code-stubs-arm.h +673 -0
  49. data/lib/libv8/v8/src/arm/codegen-arm.cc +52 -0
  50. data/lib/libv8/v8/src/arm/codegen-arm.h +91 -0
  51. data/lib/libv8/v8/src/arm/constants-arm.cc +152 -0
  52. data/lib/libv8/v8/src/arm/constants-arm.h +775 -0
  53. data/lib/libv8/v8/src/arm/cpu-arm.cc +120 -0
  54. data/lib/libv8/v8/src/arm/debug-arm.cc +317 -0
  55. data/lib/libv8/v8/src/arm/deoptimizer-arm.cc +754 -0
  56. data/lib/libv8/v8/src/arm/disasm-arm.cc +1506 -0
  57. data/lib/libv8/v8/src/arm/frames-arm.cc +45 -0
  58. data/lib/libv8/v8/src/arm/frames-arm.h +168 -0
  59. data/lib/libv8/v8/src/arm/full-codegen-arm.cc +4375 -0
  60. data/lib/libv8/v8/src/arm/ic-arm.cc +1562 -0
  61. data/lib/libv8/v8/src/arm/lithium-arm.cc +2206 -0
  62. data/lib/libv8/v8/src/arm/lithium-arm.h +2348 -0
  63. data/lib/libv8/v8/src/arm/lithium-codegen-arm.cc +4526 -0
  64. data/lib/libv8/v8/src/arm/lithium-codegen-arm.h +403 -0
  65. data/lib/libv8/v8/src/arm/lithium-gap-resolver-arm.cc +305 -0
  66. data/lib/libv8/v8/src/arm/lithium-gap-resolver-arm.h +84 -0
  67. data/lib/libv8/v8/src/arm/macro-assembler-arm.cc +3163 -0
  68. data/lib/libv8/v8/src/arm/macro-assembler-arm.h +1126 -0
  69. data/lib/libv8/v8/src/arm/regexp-macro-assembler-arm.cc +1287 -0
  70. data/lib/libv8/v8/src/arm/regexp-macro-assembler-arm.h +253 -0
  71. data/lib/libv8/v8/src/arm/simulator-arm.cc +3424 -0
  72. data/lib/libv8/v8/src/arm/simulator-arm.h +431 -0
  73. data/lib/libv8/v8/src/arm/stub-cache-arm.cc +4243 -0
  74. data/lib/libv8/v8/src/array.js +1366 -0
  75. data/lib/libv8/v8/src/assembler.cc +1207 -0
  76. data/lib/libv8/v8/src/assembler.h +858 -0
  77. data/lib/libv8/v8/src/ast-inl.h +112 -0
  78. data/lib/libv8/v8/src/ast.cc +1146 -0
  79. data/lib/libv8/v8/src/ast.h +2188 -0
  80. data/lib/libv8/v8/src/atomicops.h +167 -0
  81. data/lib/libv8/v8/src/atomicops_internals_arm_gcc.h +145 -0
  82. data/lib/libv8/v8/src/atomicops_internals_mips_gcc.h +169 -0
  83. data/lib/libv8/v8/src/atomicops_internals_x86_gcc.cc +133 -0
  84. data/lib/libv8/v8/src/atomicops_internals_x86_gcc.h +287 -0
  85. data/lib/libv8/v8/src/atomicops_internals_x86_macosx.h +301 -0
  86. data/lib/libv8/v8/src/atomicops_internals_x86_msvc.h +203 -0
  87. data/lib/libv8/v8/src/bignum-dtoa.cc +655 -0
  88. data/lib/libv8/v8/src/bignum-dtoa.h +81 -0
  89. data/lib/libv8/v8/src/bignum.cc +768 -0
  90. data/lib/libv8/v8/src/bignum.h +140 -0
  91. data/lib/libv8/v8/src/bootstrapper.cc +2184 -0
  92. data/lib/libv8/v8/src/bootstrapper.h +188 -0
  93. data/lib/libv8/v8/src/builtins.cc +1707 -0
  94. data/lib/libv8/v8/src/builtins.h +371 -0
  95. data/lib/libv8/v8/src/bytecodes-irregexp.h +105 -0
  96. data/lib/libv8/v8/src/cached-powers.cc +177 -0
  97. data/lib/libv8/v8/src/cached-powers.h +65 -0
  98. data/lib/libv8/v8/src/char-predicates-inl.h +94 -0
  99. data/lib/libv8/v8/src/char-predicates.h +67 -0
  100. data/lib/libv8/v8/src/checks.cc +110 -0
  101. data/lib/libv8/v8/src/checks.h +296 -0
  102. data/lib/libv8/v8/src/circular-queue-inl.h +53 -0
  103. data/lib/libv8/v8/src/circular-queue.cc +122 -0
  104. data/lib/libv8/v8/src/circular-queue.h +103 -0
  105. data/lib/libv8/v8/src/code-stubs.cc +267 -0
  106. data/lib/libv8/v8/src/code-stubs.h +1011 -0
  107. data/lib/libv8/v8/src/code.h +70 -0
  108. data/lib/libv8/v8/src/codegen.cc +231 -0
  109. data/lib/libv8/v8/src/codegen.h +84 -0
  110. data/lib/libv8/v8/src/compilation-cache.cc +540 -0
  111. data/lib/libv8/v8/src/compilation-cache.h +287 -0
  112. data/lib/libv8/v8/src/compiler.cc +786 -0
  113. data/lib/libv8/v8/src/compiler.h +312 -0
  114. data/lib/libv8/v8/src/contexts.cc +347 -0
  115. data/lib/libv8/v8/src/contexts.h +391 -0
  116. data/lib/libv8/v8/src/conversions-inl.h +106 -0
  117. data/lib/libv8/v8/src/conversions.cc +1131 -0
  118. data/lib/libv8/v8/src/conversions.h +135 -0
  119. data/lib/libv8/v8/src/counters.cc +93 -0
  120. data/lib/libv8/v8/src/counters.h +254 -0
  121. data/lib/libv8/v8/src/cpu-profiler-inl.h +101 -0
  122. data/lib/libv8/v8/src/cpu-profiler.cc +609 -0
  123. data/lib/libv8/v8/src/cpu-profiler.h +302 -0
  124. data/lib/libv8/v8/src/cpu.h +69 -0
  125. data/lib/libv8/v8/src/d8-debug.cc +367 -0
  126. data/lib/libv8/v8/src/d8-debug.h +158 -0
  127. data/lib/libv8/v8/src/d8-posix.cc +695 -0
  128. data/lib/libv8/v8/src/d8-readline.cc +130 -0
  129. data/lib/libv8/v8/src/d8-windows.cc +42 -0
  130. data/lib/libv8/v8/src/d8.cc +803 -0
  131. data/lib/libv8/v8/src/d8.gyp +91 -0
  132. data/lib/libv8/v8/src/d8.h +235 -0
  133. data/lib/libv8/v8/src/d8.js +2798 -0
  134. data/lib/libv8/v8/src/data-flow.cc +66 -0
  135. data/lib/libv8/v8/src/data-flow.h +205 -0
  136. data/lib/libv8/v8/src/date.js +1103 -0
  137. data/lib/libv8/v8/src/dateparser-inl.h +127 -0
  138. data/lib/libv8/v8/src/dateparser.cc +178 -0
  139. data/lib/libv8/v8/src/dateparser.h +266 -0
  140. data/lib/libv8/v8/src/debug-agent.cc +447 -0
  141. data/lib/libv8/v8/src/debug-agent.h +129 -0
  142. data/lib/libv8/v8/src/debug-debugger.js +2569 -0
  143. data/lib/libv8/v8/src/debug.cc +3165 -0
  144. data/lib/libv8/v8/src/debug.h +1057 -0
  145. data/lib/libv8/v8/src/deoptimizer.cc +1256 -0
  146. data/lib/libv8/v8/src/deoptimizer.h +602 -0
  147. data/lib/libv8/v8/src/disasm.h +80 -0
  148. data/lib/libv8/v8/src/disassembler.cc +343 -0
  149. data/lib/libv8/v8/src/disassembler.h +58 -0
  150. data/lib/libv8/v8/src/diy-fp.cc +58 -0
  151. data/lib/libv8/v8/src/diy-fp.h +117 -0
  152. data/lib/libv8/v8/src/double.h +238 -0
  153. data/lib/libv8/v8/src/dtoa.cc +103 -0
  154. data/lib/libv8/v8/src/dtoa.h +85 -0
  155. data/lib/libv8/v8/src/execution.cc +849 -0
  156. data/lib/libv8/v8/src/execution.h +297 -0
  157. data/lib/libv8/v8/src/extensions/experimental/break-iterator.cc +250 -0
  158. data/lib/libv8/v8/src/extensions/experimental/break-iterator.h +89 -0
  159. data/lib/libv8/v8/src/extensions/experimental/collator.cc +218 -0
  160. data/lib/libv8/v8/src/extensions/experimental/collator.h +69 -0
  161. data/lib/libv8/v8/src/extensions/experimental/experimental.gyp +94 -0
  162. data/lib/libv8/v8/src/extensions/experimental/i18n-extension.cc +78 -0
  163. data/lib/libv8/v8/src/extensions/experimental/i18n-extension.h +54 -0
  164. data/lib/libv8/v8/src/extensions/experimental/i18n-locale.cc +112 -0
  165. data/lib/libv8/v8/src/extensions/experimental/i18n-locale.h +60 -0
  166. data/lib/libv8/v8/src/extensions/experimental/i18n-utils.cc +43 -0
  167. data/lib/libv8/v8/src/extensions/experimental/i18n-utils.h +49 -0
  168. data/lib/libv8/v8/src/extensions/experimental/i18n.js +180 -0
  169. data/lib/libv8/v8/src/extensions/experimental/language-matcher.cc +251 -0
  170. data/lib/libv8/v8/src/extensions/experimental/language-matcher.h +95 -0
  171. data/lib/libv8/v8/src/extensions/externalize-string-extension.cc +141 -0
  172. data/lib/libv8/v8/src/extensions/externalize-string-extension.h +50 -0
  173. data/lib/libv8/v8/src/extensions/gc-extension.cc +58 -0
  174. data/lib/libv8/v8/src/extensions/gc-extension.h +49 -0
  175. data/lib/libv8/v8/src/factory.cc +1222 -0
  176. data/lib/libv8/v8/src/factory.h +442 -0
  177. data/lib/libv8/v8/src/fast-dtoa.cc +736 -0
  178. data/lib/libv8/v8/src/fast-dtoa.h +83 -0
  179. data/lib/libv8/v8/src/fixed-dtoa.cc +405 -0
  180. data/lib/libv8/v8/src/fixed-dtoa.h +55 -0
  181. data/lib/libv8/v8/src/flag-definitions.h +560 -0
  182. data/lib/libv8/v8/src/flags.cc +551 -0
  183. data/lib/libv8/v8/src/flags.h +79 -0
  184. data/lib/libv8/v8/src/frames-inl.h +247 -0
  185. data/lib/libv8/v8/src/frames.cc +1243 -0
  186. data/lib/libv8/v8/src/frames.h +870 -0
  187. data/lib/libv8/v8/src/full-codegen.cc +1374 -0
  188. data/lib/libv8/v8/src/full-codegen.h +771 -0
  189. data/lib/libv8/v8/src/func-name-inferrer.cc +92 -0
  190. data/lib/libv8/v8/src/func-name-inferrer.h +111 -0
  191. data/lib/libv8/v8/src/gdb-jit.cc +1555 -0
  192. data/lib/libv8/v8/src/gdb-jit.h +143 -0
  193. data/lib/libv8/v8/src/global-handles.cc +665 -0
  194. data/lib/libv8/v8/src/global-handles.h +284 -0
  195. data/lib/libv8/v8/src/globals.h +325 -0
  196. data/lib/libv8/v8/src/handles-inl.h +177 -0
  197. data/lib/libv8/v8/src/handles.cc +987 -0
  198. data/lib/libv8/v8/src/handles.h +382 -0
  199. data/lib/libv8/v8/src/hashmap.cc +230 -0
  200. data/lib/libv8/v8/src/hashmap.h +123 -0
  201. data/lib/libv8/v8/src/heap-inl.h +704 -0
  202. data/lib/libv8/v8/src/heap-profiler.cc +1173 -0
  203. data/lib/libv8/v8/src/heap-profiler.h +397 -0
  204. data/lib/libv8/v8/src/heap.cc +5930 -0
  205. data/lib/libv8/v8/src/heap.h +2268 -0
  206. data/lib/libv8/v8/src/hydrogen-instructions.cc +1769 -0
  207. data/lib/libv8/v8/src/hydrogen-instructions.h +3971 -0
  208. data/lib/libv8/v8/src/hydrogen.cc +6239 -0
  209. data/lib/libv8/v8/src/hydrogen.h +1202 -0
  210. data/lib/libv8/v8/src/ia32/assembler-ia32-inl.h +446 -0
  211. data/lib/libv8/v8/src/ia32/assembler-ia32.cc +2487 -0
  212. data/lib/libv8/v8/src/ia32/assembler-ia32.h +1144 -0
  213. data/lib/libv8/v8/src/ia32/builtins-ia32.cc +1621 -0
  214. data/lib/libv8/v8/src/ia32/code-stubs-ia32.cc +6198 -0
  215. data/lib/libv8/v8/src/ia32/code-stubs-ia32.h +517 -0
  216. data/lib/libv8/v8/src/ia32/codegen-ia32.cc +265 -0
  217. data/lib/libv8/v8/src/ia32/codegen-ia32.h +79 -0
  218. data/lib/libv8/v8/src/ia32/cpu-ia32.cc +88 -0
  219. data/lib/libv8/v8/src/ia32/debug-ia32.cc +312 -0
  220. data/lib/libv8/v8/src/ia32/deoptimizer-ia32.cc +774 -0
  221. data/lib/libv8/v8/src/ia32/disasm-ia32.cc +1628 -0
  222. data/lib/libv8/v8/src/ia32/frames-ia32.cc +45 -0
  223. data/lib/libv8/v8/src/ia32/frames-ia32.h +142 -0
  224. data/lib/libv8/v8/src/ia32/full-codegen-ia32.cc +4338 -0
  225. data/lib/libv8/v8/src/ia32/ic-ia32.cc +1597 -0
  226. data/lib/libv8/v8/src/ia32/lithium-codegen-ia32.cc +4461 -0
  227. data/lib/libv8/v8/src/ia32/lithium-codegen-ia32.h +375 -0
  228. data/lib/libv8/v8/src/ia32/lithium-gap-resolver-ia32.cc +475 -0
  229. data/lib/libv8/v8/src/ia32/lithium-gap-resolver-ia32.h +110 -0
  230. data/lib/libv8/v8/src/ia32/lithium-ia32.cc +2261 -0
  231. data/lib/libv8/v8/src/ia32/lithium-ia32.h +2396 -0
  232. data/lib/libv8/v8/src/ia32/macro-assembler-ia32.cc +2136 -0
  233. data/lib/libv8/v8/src/ia32/macro-assembler-ia32.h +775 -0
  234. data/lib/libv8/v8/src/ia32/regexp-macro-assembler-ia32.cc +1263 -0
  235. data/lib/libv8/v8/src/ia32/regexp-macro-assembler-ia32.h +216 -0
  236. data/lib/libv8/v8/src/ia32/simulator-ia32.cc +30 -0
  237. data/lib/libv8/v8/src/ia32/simulator-ia32.h +74 -0
  238. data/lib/libv8/v8/src/ia32/stub-cache-ia32.cc +3847 -0
  239. data/lib/libv8/v8/src/ic-inl.h +130 -0
  240. data/lib/libv8/v8/src/ic.cc +2577 -0
  241. data/lib/libv8/v8/src/ic.h +736 -0
  242. data/lib/libv8/v8/src/inspector.cc +63 -0
  243. data/lib/libv8/v8/src/inspector.h +62 -0
  244. data/lib/libv8/v8/src/interpreter-irregexp.cc +659 -0
  245. data/lib/libv8/v8/src/interpreter-irregexp.h +49 -0
  246. data/lib/libv8/v8/src/isolate-inl.h +50 -0
  247. data/lib/libv8/v8/src/isolate.cc +1869 -0
  248. data/lib/libv8/v8/src/isolate.h +1382 -0
  249. data/lib/libv8/v8/src/json-parser.cc +504 -0
  250. data/lib/libv8/v8/src/json-parser.h +161 -0
  251. data/lib/libv8/v8/src/json.js +342 -0
  252. data/lib/libv8/v8/src/jsregexp.cc +5385 -0
  253. data/lib/libv8/v8/src/jsregexp.h +1492 -0
  254. data/lib/libv8/v8/src/list-inl.h +212 -0
  255. data/lib/libv8/v8/src/list.h +174 -0
  256. data/lib/libv8/v8/src/lithium-allocator-inl.h +142 -0
  257. data/lib/libv8/v8/src/lithium-allocator.cc +2123 -0
  258. data/lib/libv8/v8/src/lithium-allocator.h +630 -0
  259. data/lib/libv8/v8/src/lithium.cc +190 -0
  260. data/lib/libv8/v8/src/lithium.h +597 -0
  261. data/lib/libv8/v8/src/liveedit-debugger.js +1082 -0
  262. data/lib/libv8/v8/src/liveedit.cc +1691 -0
  263. data/lib/libv8/v8/src/liveedit.h +180 -0
  264. data/lib/libv8/v8/src/liveobjectlist-inl.h +126 -0
  265. data/lib/libv8/v8/src/liveobjectlist.cc +2589 -0
  266. data/lib/libv8/v8/src/liveobjectlist.h +322 -0
  267. data/lib/libv8/v8/src/log-inl.h +59 -0
  268. data/lib/libv8/v8/src/log-utils.cc +428 -0
  269. data/lib/libv8/v8/src/log-utils.h +231 -0
  270. data/lib/libv8/v8/src/log.cc +1993 -0
  271. data/lib/libv8/v8/src/log.h +476 -0
  272. data/lib/libv8/v8/src/macro-assembler.h +120 -0
  273. data/lib/libv8/v8/src/macros.py +178 -0
  274. data/lib/libv8/v8/src/mark-compact.cc +3143 -0
  275. data/lib/libv8/v8/src/mark-compact.h +506 -0
  276. data/lib/libv8/v8/src/math.js +264 -0
  277. data/lib/libv8/v8/src/messages.cc +179 -0
  278. data/lib/libv8/v8/src/messages.h +113 -0
  279. data/lib/libv8/v8/src/messages.js +1096 -0
  280. data/lib/libv8/v8/src/mips/assembler-mips-inl.h +312 -0
  281. data/lib/libv8/v8/src/mips/assembler-mips.cc +1960 -0
  282. data/lib/libv8/v8/src/mips/assembler-mips.h +1138 -0
  283. data/lib/libv8/v8/src/mips/builtins-mips.cc +1628 -0
  284. data/lib/libv8/v8/src/mips/code-stubs-mips.cc +6656 -0
  285. data/lib/libv8/v8/src/mips/code-stubs-mips.h +682 -0
  286. data/lib/libv8/v8/src/mips/codegen-mips.cc +52 -0
  287. data/lib/libv8/v8/src/mips/codegen-mips.h +98 -0
  288. data/lib/libv8/v8/src/mips/constants-mips.cc +352 -0
  289. data/lib/libv8/v8/src/mips/constants-mips.h +739 -0
  290. data/lib/libv8/v8/src/mips/cpu-mips.cc +96 -0
  291. data/lib/libv8/v8/src/mips/debug-mips.cc +308 -0
  292. data/lib/libv8/v8/src/mips/deoptimizer-mips.cc +91 -0
  293. data/lib/libv8/v8/src/mips/disasm-mips.cc +1050 -0
  294. data/lib/libv8/v8/src/mips/frames-mips.cc +47 -0
  295. data/lib/libv8/v8/src/mips/frames-mips.h +219 -0
  296. data/lib/libv8/v8/src/mips/full-codegen-mips.cc +4388 -0
  297. data/lib/libv8/v8/src/mips/ic-mips.cc +1580 -0
  298. data/lib/libv8/v8/src/mips/lithium-codegen-mips.h +65 -0
  299. data/lib/libv8/v8/src/mips/lithium-mips.h +307 -0
  300. data/lib/libv8/v8/src/mips/macro-assembler-mips.cc +4056 -0
  301. data/lib/libv8/v8/src/mips/macro-assembler-mips.h +1214 -0
  302. data/lib/libv8/v8/src/mips/regexp-macro-assembler-mips.cc +1251 -0
  303. data/lib/libv8/v8/src/mips/regexp-macro-assembler-mips.h +252 -0
  304. data/lib/libv8/v8/src/mips/simulator-mips.cc +2621 -0
  305. data/lib/libv8/v8/src/mips/simulator-mips.h +401 -0
  306. data/lib/libv8/v8/src/mips/stub-cache-mips.cc +4285 -0
  307. data/lib/libv8/v8/src/mirror-debugger.js +2382 -0
  308. data/lib/libv8/v8/src/mksnapshot.cc +328 -0
  309. data/lib/libv8/v8/src/natives.h +64 -0
  310. data/lib/libv8/v8/src/objects-debug.cc +738 -0
  311. data/lib/libv8/v8/src/objects-inl.h +4323 -0
  312. data/lib/libv8/v8/src/objects-printer.cc +829 -0
  313. data/lib/libv8/v8/src/objects-visiting.cc +148 -0
  314. data/lib/libv8/v8/src/objects-visiting.h +424 -0
  315. data/lib/libv8/v8/src/objects.cc +10585 -0
  316. data/lib/libv8/v8/src/objects.h +6838 -0
  317. data/lib/libv8/v8/src/parser.cc +4997 -0
  318. data/lib/libv8/v8/src/parser.h +765 -0
  319. data/lib/libv8/v8/src/platform-cygwin.cc +779 -0
  320. data/lib/libv8/v8/src/platform-freebsd.cc +826 -0
  321. data/lib/libv8/v8/src/platform-linux.cc +1149 -0
  322. data/lib/libv8/v8/src/platform-macos.cc +830 -0
  323. data/lib/libv8/v8/src/platform-nullos.cc +479 -0
  324. data/lib/libv8/v8/src/platform-openbsd.cc +640 -0
  325. data/lib/libv8/v8/src/platform-posix.cc +424 -0
  326. data/lib/libv8/v8/src/platform-solaris.cc +762 -0
  327. data/lib/libv8/v8/src/platform-tls-mac.h +62 -0
  328. data/lib/libv8/v8/src/platform-tls-win32.h +62 -0
  329. data/lib/libv8/v8/src/platform-tls.h +50 -0
  330. data/lib/libv8/v8/src/platform-win32.cc +2021 -0
  331. data/lib/libv8/v8/src/platform.h +667 -0
  332. data/lib/libv8/v8/src/preparse-data-format.h +62 -0
  333. data/lib/libv8/v8/src/preparse-data.cc +183 -0
  334. data/lib/libv8/v8/src/preparse-data.h +225 -0
  335. data/lib/libv8/v8/src/preparser-api.cc +220 -0
  336. data/lib/libv8/v8/src/preparser.cc +1450 -0
  337. data/lib/libv8/v8/src/preparser.h +493 -0
  338. data/lib/libv8/v8/src/prettyprinter.cc +1493 -0
  339. data/lib/libv8/v8/src/prettyprinter.h +223 -0
  340. data/lib/libv8/v8/src/profile-generator-inl.h +128 -0
  341. data/lib/libv8/v8/src/profile-generator.cc +3098 -0
  342. data/lib/libv8/v8/src/profile-generator.h +1126 -0
  343. data/lib/libv8/v8/src/property.cc +105 -0
  344. data/lib/libv8/v8/src/property.h +365 -0
  345. data/lib/libv8/v8/src/proxy.js +83 -0
  346. data/lib/libv8/v8/src/regexp-macro-assembler-irregexp-inl.h +78 -0
  347. data/lib/libv8/v8/src/regexp-macro-assembler-irregexp.cc +471 -0
  348. data/lib/libv8/v8/src/regexp-macro-assembler-irregexp.h +142 -0
  349. data/lib/libv8/v8/src/regexp-macro-assembler-tracer.cc +373 -0
  350. data/lib/libv8/v8/src/regexp-macro-assembler-tracer.h +104 -0
  351. data/lib/libv8/v8/src/regexp-macro-assembler.cc +267 -0
  352. data/lib/libv8/v8/src/regexp-macro-assembler.h +243 -0
  353. data/lib/libv8/v8/src/regexp-stack.cc +111 -0
  354. data/lib/libv8/v8/src/regexp-stack.h +147 -0
  355. data/lib/libv8/v8/src/regexp.js +483 -0
  356. data/lib/libv8/v8/src/rewriter.cc +360 -0
  357. data/lib/libv8/v8/src/rewriter.h +50 -0
  358. data/lib/libv8/v8/src/runtime-profiler.cc +489 -0
  359. data/lib/libv8/v8/src/runtime-profiler.h +201 -0
  360. data/lib/libv8/v8/src/runtime.cc +12227 -0
  361. data/lib/libv8/v8/src/runtime.h +652 -0
  362. data/lib/libv8/v8/src/runtime.js +649 -0
  363. data/lib/libv8/v8/src/safepoint-table.cc +256 -0
  364. data/lib/libv8/v8/src/safepoint-table.h +270 -0
  365. data/lib/libv8/v8/src/scanner-base.cc +952 -0
  366. data/lib/libv8/v8/src/scanner-base.h +670 -0
  367. data/lib/libv8/v8/src/scanner.cc +345 -0
  368. data/lib/libv8/v8/src/scanner.h +146 -0
  369. data/lib/libv8/v8/src/scopeinfo.cc +646 -0
  370. data/lib/libv8/v8/src/scopeinfo.h +254 -0
  371. data/lib/libv8/v8/src/scopes.cc +1150 -0
  372. data/lib/libv8/v8/src/scopes.h +507 -0
  373. data/lib/libv8/v8/src/serialize.cc +1574 -0
  374. data/lib/libv8/v8/src/serialize.h +589 -0
  375. data/lib/libv8/v8/src/shell.h +55 -0
  376. data/lib/libv8/v8/src/simulator.h +43 -0
  377. data/lib/libv8/v8/src/small-pointer-list.h +163 -0
  378. data/lib/libv8/v8/src/smart-pointer.h +109 -0
  379. data/lib/libv8/v8/src/snapshot-common.cc +83 -0
  380. data/lib/libv8/v8/src/snapshot-empty.cc +54 -0
  381. data/lib/libv8/v8/src/snapshot.h +91 -0
  382. data/lib/libv8/v8/src/spaces-inl.h +529 -0
  383. data/lib/libv8/v8/src/spaces.cc +3145 -0
  384. data/lib/libv8/v8/src/spaces.h +2369 -0
  385. data/lib/libv8/v8/src/splay-tree-inl.h +310 -0
  386. data/lib/libv8/v8/src/splay-tree.h +205 -0
  387. data/lib/libv8/v8/src/string-search.cc +41 -0
  388. data/lib/libv8/v8/src/string-search.h +568 -0
  389. data/lib/libv8/v8/src/string-stream.cc +592 -0
  390. data/lib/libv8/v8/src/string-stream.h +191 -0
  391. data/lib/libv8/v8/src/string.js +994 -0
  392. data/lib/libv8/v8/src/strtod.cc +440 -0
  393. data/lib/libv8/v8/src/strtod.h +40 -0
  394. data/lib/libv8/v8/src/stub-cache.cc +1965 -0
  395. data/lib/libv8/v8/src/stub-cache.h +924 -0
  396. data/lib/libv8/v8/src/third_party/valgrind/valgrind.h +3925 -0
  397. data/lib/libv8/v8/src/token.cc +63 -0
  398. data/lib/libv8/v8/src/token.h +288 -0
  399. data/lib/libv8/v8/src/type-info.cc +507 -0
  400. data/lib/libv8/v8/src/type-info.h +272 -0
  401. data/lib/libv8/v8/src/unbound-queue-inl.h +95 -0
  402. data/lib/libv8/v8/src/unbound-queue.h +69 -0
  403. data/lib/libv8/v8/src/unicode-inl.h +238 -0
  404. data/lib/libv8/v8/src/unicode.cc +1624 -0
  405. data/lib/libv8/v8/src/unicode.h +280 -0
  406. data/lib/libv8/v8/src/uri.js +408 -0
  407. data/lib/libv8/v8/src/utils-inl.h +48 -0
  408. data/lib/libv8/v8/src/utils.cc +371 -0
  409. data/lib/libv8/v8/src/utils.h +800 -0
  410. data/lib/libv8/v8/src/v8-counters.cc +62 -0
  411. data/lib/libv8/v8/src/v8-counters.h +314 -0
  412. data/lib/libv8/v8/src/v8.cc +213 -0
  413. data/lib/libv8/v8/src/v8.h +131 -0
  414. data/lib/libv8/v8/src/v8checks.h +64 -0
  415. data/lib/libv8/v8/src/v8dll-main.cc +44 -0
  416. data/lib/libv8/v8/src/v8globals.h +512 -0
  417. data/lib/libv8/v8/src/v8memory.h +82 -0
  418. data/lib/libv8/v8/src/v8natives.js +1310 -0
  419. data/lib/libv8/v8/src/v8preparserdll-main.cc +39 -0
  420. data/lib/libv8/v8/src/v8threads.cc +464 -0
  421. data/lib/libv8/v8/src/v8threads.h +165 -0
  422. data/lib/libv8/v8/src/v8utils.h +319 -0
  423. data/lib/libv8/v8/src/variables.cc +114 -0
  424. data/lib/libv8/v8/src/variables.h +167 -0
  425. data/lib/libv8/v8/src/version.cc +116 -0
  426. data/lib/libv8/v8/src/version.h +68 -0
  427. data/lib/libv8/v8/src/vm-state-inl.h +138 -0
  428. data/lib/libv8/v8/src/vm-state.h +71 -0
  429. data/lib/libv8/v8/src/win32-headers.h +96 -0
  430. data/lib/libv8/v8/src/x64/assembler-x64-inl.h +462 -0
  431. data/lib/libv8/v8/src/x64/assembler-x64.cc +3027 -0
  432. data/lib/libv8/v8/src/x64/assembler-x64.h +1633 -0
  433. data/lib/libv8/v8/src/x64/builtins-x64.cc +1520 -0
  434. data/lib/libv8/v8/src/x64/code-stubs-x64.cc +5132 -0
  435. data/lib/libv8/v8/src/x64/code-stubs-x64.h +514 -0
  436. data/lib/libv8/v8/src/x64/codegen-x64.cc +146 -0
  437. data/lib/libv8/v8/src/x64/codegen-x64.h +76 -0
  438. data/lib/libv8/v8/src/x64/cpu-x64.cc +88 -0
  439. data/lib/libv8/v8/src/x64/debug-x64.cc +319 -0
  440. data/lib/libv8/v8/src/x64/deoptimizer-x64.cc +815 -0
  441. data/lib/libv8/v8/src/x64/disasm-x64.cc +1832 -0
  442. data/lib/libv8/v8/src/x64/frames-x64.cc +45 -0
  443. data/lib/libv8/v8/src/x64/frames-x64.h +130 -0
  444. data/lib/libv8/v8/src/x64/full-codegen-x64.cc +4318 -0
  445. data/lib/libv8/v8/src/x64/ic-x64.cc +1608 -0
  446. data/lib/libv8/v8/src/x64/lithium-codegen-x64.cc +4267 -0
  447. data/lib/libv8/v8/src/x64/lithium-codegen-x64.h +367 -0
  448. data/lib/libv8/v8/src/x64/lithium-gap-resolver-x64.cc +320 -0
  449. data/lib/libv8/v8/src/x64/lithium-gap-resolver-x64.h +74 -0
  450. data/lib/libv8/v8/src/x64/lithium-x64.cc +2202 -0
  451. data/lib/libv8/v8/src/x64/lithium-x64.h +2333 -0
  452. data/lib/libv8/v8/src/x64/macro-assembler-x64.cc +3745 -0
  453. data/lib/libv8/v8/src/x64/macro-assembler-x64.h +1290 -0
  454. data/lib/libv8/v8/src/x64/regexp-macro-assembler-x64.cc +1398 -0
  455. data/lib/libv8/v8/src/x64/regexp-macro-assembler-x64.h +282 -0
  456. data/lib/libv8/v8/src/x64/simulator-x64.cc +27 -0
  457. data/lib/libv8/v8/src/x64/simulator-x64.h +72 -0
  458. data/lib/libv8/v8/src/x64/stub-cache-x64.cc +3610 -0
  459. data/lib/libv8/v8/src/zone-inl.h +140 -0
  460. data/lib/libv8/v8/src/zone.cc +196 -0
  461. data/lib/libv8/v8/src/zone.h +240 -0
  462. data/lib/libv8/v8/tools/codemap.js +265 -0
  463. data/lib/libv8/v8/tools/consarray.js +93 -0
  464. data/lib/libv8/v8/tools/csvparser.js +78 -0
  465. data/lib/libv8/v8/tools/disasm.py +92 -0
  466. data/lib/libv8/v8/tools/freebsd-tick-processor +10 -0
  467. data/lib/libv8/v8/tools/gc-nvp-trace-processor.py +342 -0
  468. data/lib/libv8/v8/tools/gcmole/README +62 -0
  469. data/lib/libv8/v8/tools/gcmole/gccause.lua +60 -0
  470. data/lib/libv8/v8/tools/gcmole/gcmole.cc +1261 -0
  471. data/lib/libv8/v8/tools/gcmole/gcmole.lua +378 -0
  472. data/lib/libv8/v8/tools/generate-ten-powers.scm +286 -0
  473. data/lib/libv8/v8/tools/grokdump.py +841 -0
  474. data/lib/libv8/v8/tools/gyp/v8.gyp +995 -0
  475. data/lib/libv8/v8/tools/js2c.py +364 -0
  476. data/lib/libv8/v8/tools/jsmin.py +280 -0
  477. data/lib/libv8/v8/tools/linux-tick-processor +35 -0
  478. data/lib/libv8/v8/tools/ll_prof.py +942 -0
  479. data/lib/libv8/v8/tools/logreader.js +185 -0
  480. data/lib/libv8/v8/tools/mac-nm +18 -0
  481. data/lib/libv8/v8/tools/mac-tick-processor +6 -0
  482. data/lib/libv8/v8/tools/oom_dump/README +31 -0
  483. data/lib/libv8/v8/tools/oom_dump/SConstruct +42 -0
  484. data/lib/libv8/v8/tools/oom_dump/oom_dump.cc +288 -0
  485. data/lib/libv8/v8/tools/presubmit.py +305 -0
  486. data/lib/libv8/v8/tools/process-heap-prof.py +120 -0
  487. data/lib/libv8/v8/tools/profile.js +751 -0
  488. data/lib/libv8/v8/tools/profile_view.js +219 -0
  489. data/lib/libv8/v8/tools/run-valgrind.py +77 -0
  490. data/lib/libv8/v8/tools/splaytree.js +316 -0
  491. data/lib/libv8/v8/tools/stats-viewer.py +468 -0
  492. data/lib/libv8/v8/tools/test.py +1510 -0
  493. data/lib/libv8/v8/tools/tickprocessor-driver.js +59 -0
  494. data/lib/libv8/v8/tools/tickprocessor.js +877 -0
  495. data/lib/libv8/v8/tools/utils.py +96 -0
  496. data/lib/libv8/v8/tools/visual_studio/README.txt +12 -0
  497. data/lib/libv8/v8/tools/windows-tick-processor.bat +30 -0
  498. data/lib/libv8/version.rb +5 -0
  499. data/libv8.gemspec +36 -0
  500. metadata +578 -0
@@ -0,0 +1,1096 @@
1
+ // Copyright 2006-2008 the V8 project authors. All rights reserved.
2
+ // Redistribution and use in source and binary forms, with or without
3
+ // modification, are permitted provided that the following conditions are
4
+ // met:
5
+ //
6
+ // * Redistributions of source code must retain the above copyright
7
+ // notice, this list of conditions and the following disclaimer.
8
+ // * Redistributions in binary form must reproduce the above
9
+ // copyright notice, this list of conditions and the following
10
+ // disclaimer in the documentation and/or other materials provided
11
+ // with the distribution.
12
+ // * Neither the name of Google Inc. nor the names of its
13
+ // contributors may be used to endorse or promote products derived
14
+ // from this software without specific prior written permission.
15
+ //
16
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+
28
+
29
+ // -------------------------------------------------------------------
30
+ //
31
+ // Matches Script::Type from objects.h
32
+ var TYPE_NATIVE = 0;
33
+ var TYPE_EXTENSION = 1;
34
+ var TYPE_NORMAL = 2;
35
+
36
+ // Matches Script::CompilationType from objects.h
37
+ var COMPILATION_TYPE_HOST = 0;
38
+ var COMPILATION_TYPE_EVAL = 1;
39
+ var COMPILATION_TYPE_JSON = 2;
40
+
41
+ // Matches Messages::kNoLineNumberInfo from v8.h
42
+ var kNoLineNumberInfo = 0;
43
+
44
+ // If this object gets passed to an error constructor the error will
45
+ // get an accessor for .message that constructs a descriptive error
46
+ // message on access.
47
+ var kAddMessageAccessorsMarker = { };
48
+
49
+ var kMessages = 0;
50
+
51
+ var kReplacementMarkers = [ "%0", "%1", "%2", "%3" ];
52
+
53
+ function FormatString(format, message) {
54
+ var args = %MessageGetArguments(message);
55
+ var result = "";
56
+ var arg_num = 0;
57
+ for (var i = 0; i < format.length; i++) {
58
+ var str = format[i];
59
+ for (arg_num = 0; arg_num < kReplacementMarkers.length; arg_num++) {
60
+ if (format[i] !== kReplacementMarkers[arg_num]) continue;
61
+ try {
62
+ str = ToDetailString(args[arg_num]);
63
+ } catch (e) {
64
+ str = "#<error>";
65
+ }
66
+ }
67
+ result += str;
68
+ }
69
+ return result;
70
+ }
71
+
72
+
73
+ // To check if something is a native error we need to check the
74
+ // concrete native error types. It is not enough to check "obj
75
+ // instanceof $Error" because user code can replace
76
+ // NativeError.prototype.__proto__. User code cannot replace
77
+ // NativeError.prototype though and therefore this is a safe test.
78
+ function IsNativeErrorObject(obj) {
79
+ return (obj instanceof $Error) ||
80
+ (obj instanceof $EvalError) ||
81
+ (obj instanceof $RangeError) ||
82
+ (obj instanceof $ReferenceError) ||
83
+ (obj instanceof $SyntaxError) ||
84
+ (obj instanceof $TypeError) ||
85
+ (obj instanceof $URIError);
86
+ }
87
+
88
+
89
+ // When formatting internally created error messages, do not
90
+ // invoke overwritten error toString methods but explicitly use
91
+ // the error to string method. This is to avoid leaking error
92
+ // objects between script tags in a browser setting.
93
+ function ToStringCheckErrorObject(obj) {
94
+ if (IsNativeErrorObject(obj)) {
95
+ return %_CallFunction(obj, errorToString);
96
+ } else {
97
+ return ToString(obj);
98
+ }
99
+ }
100
+
101
+
102
+ function ToDetailString(obj) {
103
+ if (obj != null && IS_OBJECT(obj) && obj.toString === $Object.prototype.toString) {
104
+ var constructor = obj.constructor;
105
+ if (!constructor) return ToStringCheckErrorObject(obj);
106
+ var constructorName = constructor.name;
107
+ if (!constructorName || !IS_STRING(constructorName)) {
108
+ return ToStringCheckErrorObject(obj);
109
+ }
110
+ return "#<" + constructorName + ">";
111
+ } else {
112
+ return ToStringCheckErrorObject(obj);
113
+ }
114
+ }
115
+
116
+
117
+ function MakeGenericError(constructor, type, args) {
118
+ if (IS_UNDEFINED(args)) {
119
+ args = [];
120
+ }
121
+ var e = new constructor(kAddMessageAccessorsMarker);
122
+ e.type = type;
123
+ e.arguments = args;
124
+ return e;
125
+ }
126
+
127
+
128
+ /**
129
+ * Setup the Script function and constructor.
130
+ */
131
+ %FunctionSetInstanceClassName(Script, 'Script');
132
+ %SetProperty(Script.prototype, 'constructor', Script, DONT_ENUM);
133
+ %SetCode(Script, function(x) {
134
+ // Script objects can only be created by the VM.
135
+ throw new $Error("Not supported");
136
+ });
137
+
138
+
139
+ // Helper functions; called from the runtime system.
140
+ function FormatMessage(message) {
141
+ if (kMessages === 0) {
142
+ kMessages = {
143
+ // Error
144
+ cyclic_proto: ["Cyclic __proto__ value"],
145
+ code_gen_from_strings: ["Code generation from strings disallowed for this context"],
146
+ // TypeError
147
+ unexpected_token: ["Unexpected token ", "%0"],
148
+ unexpected_token_number: ["Unexpected number"],
149
+ unexpected_token_string: ["Unexpected string"],
150
+ unexpected_token_identifier: ["Unexpected identifier"],
151
+ unexpected_strict_reserved: ["Unexpected strict mode reserved word"],
152
+ unexpected_eos: ["Unexpected end of input"],
153
+ malformed_regexp: ["Invalid regular expression: /", "%0", "/: ", "%1"],
154
+ unterminated_regexp: ["Invalid regular expression: missing /"],
155
+ regexp_flags: ["Cannot supply flags when constructing one RegExp from another"],
156
+ incompatible_method_receiver: ["Method ", "%0", " called on incompatible receiver ", "%1"],
157
+ invalid_lhs_in_assignment: ["Invalid left-hand side in assignment"],
158
+ invalid_lhs_in_for_in: ["Invalid left-hand side in for-in"],
159
+ invalid_lhs_in_postfix_op: ["Invalid left-hand side expression in postfix operation"],
160
+ invalid_lhs_in_prefix_op: ["Invalid left-hand side expression in prefix operation"],
161
+ multiple_defaults_in_switch: ["More than one default clause in switch statement"],
162
+ newline_after_throw: ["Illegal newline after throw"],
163
+ redeclaration: ["%0", " '", "%1", "' has already been declared"],
164
+ no_catch_or_finally: ["Missing catch or finally after try"],
165
+ unknown_label: ["Undefined label '", "%0", "'"],
166
+ uncaught_exception: ["Uncaught ", "%0"],
167
+ stack_trace: ["Stack Trace:\n", "%0"],
168
+ called_non_callable: ["%0", " is not a function"],
169
+ undefined_method: ["Object ", "%1", " has no method '", "%0", "'"],
170
+ property_not_function: ["Property '", "%0", "' of object ", "%1", " is not a function"],
171
+ cannot_convert_to_primitive: ["Cannot convert object to primitive value"],
172
+ not_constructor: ["%0", " is not a constructor"],
173
+ not_defined: ["%0", " is not defined"],
174
+ non_object_property_load: ["Cannot read property '", "%0", "' of ", "%1"],
175
+ non_object_property_store: ["Cannot set property '", "%0", "' of ", "%1"],
176
+ non_object_property_call: ["Cannot call method '", "%0", "' of ", "%1"],
177
+ with_expression: ["%0", " has no properties"],
178
+ illegal_invocation: ["Illegal invocation"],
179
+ no_setter_in_callback: ["Cannot set property ", "%0", " of ", "%1", " which has only a getter"],
180
+ apply_non_function: ["Function.prototype.apply was called on ", "%0", ", which is a ", "%1", " and not a function"],
181
+ apply_wrong_args: ["Function.prototype.apply: Arguments list has wrong type"],
182
+ invalid_in_operator_use: ["Cannot use 'in' operator to search for '", "%0", "' in ", "%1"],
183
+ instanceof_function_expected: ["Expecting a function in instanceof check, but got ", "%0"],
184
+ instanceof_nonobject_proto: ["Function has non-object prototype '", "%0", "' in instanceof check"],
185
+ null_to_object: ["Cannot convert null to object"],
186
+ reduce_no_initial: ["Reduce of empty array with no initial value"],
187
+ getter_must_be_callable: ["Getter must be a function: ", "%0"],
188
+ setter_must_be_callable: ["Setter must be a function: ", "%0"],
189
+ value_and_accessor: ["Invalid property. A property cannot both have accessors and be writable or have a value: ", "%0"],
190
+ proto_object_or_null: ["Object prototype may only be an Object or null"],
191
+ property_desc_object: ["Property description must be an object: ", "%0"],
192
+ redefine_disallowed: ["Cannot redefine property: ", "%0"],
193
+ define_disallowed: ["Cannot define property, object is not extensible: ", "%0"],
194
+ non_extensible_proto: ["%0", " is not extensible"],
195
+ handler_trap_missing: ["Proxy handler ", "%0", " has no '", "%1", "' trap"],
196
+ // RangeError
197
+ invalid_array_length: ["Invalid array length"],
198
+ stack_overflow: ["Maximum call stack size exceeded"],
199
+ // SyntaxError
200
+ unable_to_parse: ["Parse error"],
201
+ duplicate_regexp_flag: ["Duplicate RegExp flag ", "%0"],
202
+ invalid_regexp: ["Invalid RegExp pattern /", "%0", "/"],
203
+ illegal_break: ["Illegal break statement"],
204
+ illegal_continue: ["Illegal continue statement"],
205
+ illegal_return: ["Illegal return statement"],
206
+ error_loading_debugger: ["Error loading debugger"],
207
+ no_input_to_regexp: ["No input to ", "%0"],
208
+ invalid_json: ["String '", "%0", "' is not valid JSON"],
209
+ circular_structure: ["Converting circular structure to JSON"],
210
+ obj_ctor_property_non_object: ["Object.", "%0", " called on non-object"],
211
+ called_on_null_or_undefined: ["%0", " called on null or undefined"],
212
+ array_indexof_not_defined: ["Array.getIndexOf: Argument undefined"],
213
+ object_not_extensible: ["Can't add property ", "%0", ", object is not extensible"],
214
+ illegal_access: ["Illegal access"],
215
+ invalid_preparser_data: ["Invalid preparser data for function ", "%0"],
216
+ strict_mode_with: ["Strict mode code may not include a with statement"],
217
+ strict_catch_variable: ["Catch variable may not be eval or arguments in strict mode"],
218
+ too_many_parameters: ["Too many parameters in function definition (only 32766 allowed)"],
219
+ too_many_variables: ["Too many variables declared (only 32767 allowed)"],
220
+ strict_param_name: ["Parameter name eval or arguments is not allowed in strict mode"],
221
+ strict_param_dupe: ["Strict mode function may not have duplicate parameter names"],
222
+ strict_var_name: ["Variable name may not be eval or arguments in strict mode"],
223
+ strict_function_name: ["Function name may not be eval or arguments in strict mode"],
224
+ strict_octal_literal: ["Octal literals are not allowed in strict mode."],
225
+ strict_duplicate_property: ["Duplicate data property in object literal not allowed in strict mode"],
226
+ accessor_data_property: ["Object literal may not have data and accessor property with the same name"],
227
+ accessor_get_set: ["Object literal may not have multiple get/set accessors with the same name"],
228
+ strict_lhs_assignment: ["Assignment to eval or arguments is not allowed in strict mode"],
229
+ strict_lhs_postfix: ["Postfix increment/decrement may not have eval or arguments operand in strict mode"],
230
+ strict_lhs_prefix: ["Prefix increment/decrement may not have eval or arguments operand in strict mode"],
231
+ strict_reserved_word: ["Use of future reserved word in strict mode"],
232
+ strict_delete: ["Delete of an unqualified identifier in strict mode."],
233
+ strict_delete_property: ["Cannot delete property '", "%0", "' of ", "%1"],
234
+ strict_const: ["Use of const in strict mode."],
235
+ strict_function: ["In strict mode code, functions can only be declared at top level or immediately within another function." ],
236
+ strict_read_only_property: ["Cannot assign to read only property '", "%0", "' of ", "%1"],
237
+ strict_cannot_assign: ["Cannot assign to read only '", "%0", "' in strict mode"],
238
+ strict_poison_pill: ["'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them"],
239
+ strict_caller: ["Illegal access to a strict mode caller function."],
240
+ };
241
+ }
242
+ var message_type = %MessageGetType(message);
243
+ var format = kMessages[message_type];
244
+ if (!format) return "<unknown message " + message_type + ">";
245
+ return FormatString(format, message);
246
+ }
247
+
248
+
249
+ function GetLineNumber(message) {
250
+ var start_position = %MessageGetStartPosition(message);
251
+ if (start_position == -1) return kNoLineNumberInfo;
252
+ var script = %MessageGetScript(message);
253
+ var location = script.locationFromPosition(start_position, true);
254
+ if (location == null) return kNoLineNumberInfo;
255
+ return location.line + 1;
256
+ }
257
+
258
+
259
+ // Returns the source code line containing the given source
260
+ // position, or the empty string if the position is invalid.
261
+ function GetSourceLine(message) {
262
+ var script = %MessageGetScript(message);
263
+ var start_position = %MessageGetStartPosition(message);
264
+ var location = script.locationFromPosition(start_position, true);
265
+ if (location == null) return "";
266
+ location.restrict();
267
+ return location.sourceText();
268
+ }
269
+
270
+
271
+ function MakeTypeError(type, args) {
272
+ return MakeGenericError($TypeError, type, args);
273
+ }
274
+
275
+
276
+ function MakeRangeError(type, args) {
277
+ return MakeGenericError($RangeError, type, args);
278
+ }
279
+
280
+
281
+ function MakeSyntaxError(type, args) {
282
+ return MakeGenericError($SyntaxError, type, args);
283
+ }
284
+
285
+
286
+ function MakeReferenceError(type, args) {
287
+ return MakeGenericError($ReferenceError, type, args);
288
+ }
289
+
290
+
291
+ function MakeEvalError(type, args) {
292
+ return MakeGenericError($EvalError, type, args);
293
+ }
294
+
295
+
296
+ function MakeError(type, args) {
297
+ return MakeGenericError($Error, type, args);
298
+ }
299
+
300
+ /**
301
+ * Find a line number given a specific source position.
302
+ * @param {number} position The source position.
303
+ * @return {number} 0 if input too small, -1 if input too large,
304
+ else the line number.
305
+ */
306
+ Script.prototype.lineFromPosition = function(position) {
307
+ var lower = 0;
308
+ var upper = this.lineCount() - 1;
309
+ var line_ends = this.line_ends;
310
+
311
+ // We'll never find invalid positions so bail right away.
312
+ if (position > line_ends[upper]) {
313
+ return -1;
314
+ }
315
+
316
+ // This means we don't have to safe-guard indexing line_ends[i - 1].
317
+ if (position <= line_ends[0]) {
318
+ return 0;
319
+ }
320
+
321
+ // Binary search to find line # from position range.
322
+ while (upper >= 1) {
323
+ var i = (lower + upper) >> 1;
324
+
325
+ if (position > line_ends[i]) {
326
+ lower = i + 1;
327
+ } else if (position <= line_ends[i - 1]) {
328
+ upper = i - 1;
329
+ } else {
330
+ return i;
331
+ }
332
+ }
333
+
334
+ return -1;
335
+ }
336
+
337
+ /**
338
+ * Get information on a specific source position.
339
+ * @param {number} position The source position
340
+ * @param {boolean} include_resource_offset Set to true to have the resource
341
+ * offset added to the location
342
+ * @return {SourceLocation}
343
+ * If line is negative or not in the source null is returned.
344
+ */
345
+ Script.prototype.locationFromPosition = function (position,
346
+ include_resource_offset) {
347
+ var line = this.lineFromPosition(position);
348
+ if (line == -1) return null;
349
+
350
+ // Determine start, end and column.
351
+ var line_ends = this.line_ends;
352
+ var start = line == 0 ? 0 : line_ends[line - 1] + 1;
353
+ var end = line_ends[line];
354
+ if (end > 0 && %_CallFunction(this.source, end - 1, StringCharAt) == '\r') end--;
355
+ var column = position - start;
356
+
357
+ // Adjust according to the offset within the resource.
358
+ if (include_resource_offset) {
359
+ line += this.line_offset;
360
+ if (line == this.line_offset) {
361
+ column += this.column_offset;
362
+ }
363
+ }
364
+
365
+ return new SourceLocation(this, position, line, column, start, end);
366
+ };
367
+
368
+
369
+ /**
370
+ * Get information on a specific source line and column possibly offset by a
371
+ * fixed source position. This function is used to find a source position from
372
+ * a line and column position. The fixed source position offset is typically
373
+ * used to find a source position in a function based on a line and column in
374
+ * the source for the function alone. The offset passed will then be the
375
+ * start position of the source for the function within the full script source.
376
+ * @param {number} opt_line The line within the source. Default value is 0
377
+ * @param {number} opt_column The column in within the line. Default value is 0
378
+ * @param {number} opt_offset_position The offset from the begining of the
379
+ * source from where the line and column calculation starts. Default value is 0
380
+ * @return {SourceLocation}
381
+ * If line is negative or not in the source null is returned.
382
+ */
383
+ Script.prototype.locationFromLine = function (opt_line, opt_column, opt_offset_position) {
384
+ // Default is the first line in the script. Lines in the script is relative
385
+ // to the offset within the resource.
386
+ var line = 0;
387
+ if (!IS_UNDEFINED(opt_line)) {
388
+ line = opt_line - this.line_offset;
389
+ }
390
+
391
+ // Default is first column. If on the first line add the offset within the
392
+ // resource.
393
+ var column = opt_column || 0;
394
+ if (line == 0) {
395
+ column -= this.column_offset
396
+ }
397
+
398
+ var offset_position = opt_offset_position || 0;
399
+ if (line < 0 || column < 0 || offset_position < 0) return null;
400
+ if (line == 0) {
401
+ return this.locationFromPosition(offset_position + column, false);
402
+ } else {
403
+ // Find the line where the offset position is located.
404
+ var offset_line = this.lineFromPosition(offset_position);
405
+
406
+ if (offset_line == -1 || offset_line + line >= this.lineCount()) {
407
+ return null;
408
+ }
409
+
410
+ return this.locationFromPosition(this.line_ends[offset_line + line - 1] + 1 + column); // line > 0 here.
411
+ }
412
+ }
413
+
414
+
415
+ /**
416
+ * Get a slice of source code from the script. The boundaries for the slice is
417
+ * specified in lines.
418
+ * @param {number} opt_from_line The first line (zero bound) in the slice.
419
+ * Default is 0
420
+ * @param {number} opt_to_column The last line (zero bound) in the slice (non
421
+ * inclusive). Default is the number of lines in the script
422
+ * @return {SourceSlice} The source slice or null of the parameters where
423
+ * invalid
424
+ */
425
+ Script.prototype.sourceSlice = function (opt_from_line, opt_to_line) {
426
+ var from_line = IS_UNDEFINED(opt_from_line) ? this.line_offset : opt_from_line;
427
+ var to_line = IS_UNDEFINED(opt_to_line) ? this.line_offset + this.lineCount() : opt_to_line
428
+
429
+ // Adjust according to the offset within the resource.
430
+ from_line -= this.line_offset;
431
+ to_line -= this.line_offset;
432
+ if (from_line < 0) from_line = 0;
433
+ if (to_line > this.lineCount()) to_line = this.lineCount();
434
+
435
+ // Check parameters.
436
+ if (from_line >= this.lineCount() ||
437
+ to_line < 0 ||
438
+ from_line > to_line) {
439
+ return null;
440
+ }
441
+
442
+ var line_ends = this.line_ends;
443
+ var from_position = from_line == 0 ? 0 : line_ends[from_line - 1] + 1;
444
+ var to_position = to_line == 0 ? 0 : line_ends[to_line - 1] + 1;
445
+
446
+ // Return a source slice with line numbers re-adjusted to the resource.
447
+ return new SourceSlice(this, from_line + this.line_offset, to_line + this.line_offset,
448
+ from_position, to_position);
449
+ }
450
+
451
+
452
+ Script.prototype.sourceLine = function (opt_line) {
453
+ // Default is the first line in the script. Lines in the script are relative
454
+ // to the offset within the resource.
455
+ var line = 0;
456
+ if (!IS_UNDEFINED(opt_line)) {
457
+ line = opt_line - this.line_offset;
458
+ }
459
+
460
+ // Check parameter.
461
+ if (line < 0 || this.lineCount() <= line) {
462
+ return null;
463
+ }
464
+
465
+ // Return the source line.
466
+ var line_ends = this.line_ends;
467
+ var start = line == 0 ? 0 : line_ends[line - 1] + 1;
468
+ var end = line_ends[line];
469
+ return %_CallFunction(this.source, start, end, StringSubstring);
470
+ }
471
+
472
+
473
+ /**
474
+ * Returns the number of source lines.
475
+ * @return {number}
476
+ * Number of source lines.
477
+ */
478
+ Script.prototype.lineCount = function() {
479
+ // Return number of source lines.
480
+ return this.line_ends.length;
481
+ };
482
+
483
+
484
+ /**
485
+ * Returns the name of script if available, contents of sourceURL comment
486
+ * otherwise. See
487
+ * http://fbug.googlecode.com/svn/branches/firebug1.1/docs/ReleaseNotes_1.1.txt
488
+ * for details on using //@ sourceURL comment to identify scritps that don't
489
+ * have name.
490
+ *
491
+ * @return {?string} script name if present, value for //@ sourceURL comment
492
+ * otherwise.
493
+ */
494
+ Script.prototype.nameOrSourceURL = function() {
495
+ if (this.name)
496
+ return this.name;
497
+ // TODO(608): the spaces in a regexp below had to be escaped as \040
498
+ // because this file is being processed by js2c whose handling of spaces
499
+ // in regexps is broken. Also, ['"] are excluded from allowed URLs to
500
+ // avoid matches against sources that invoke evals with sourceURL.
501
+ // A better solution would be to detect these special comments in
502
+ // the scanner/parser.
503
+ var source = ToString(this.source);
504
+ var sourceUrlPos = %StringIndexOf(source, "sourceURL=", 0);
505
+ if (sourceUrlPos > 4) {
506
+ var sourceUrlPattern =
507
+ /\/\/@[\040\t]sourceURL=[\040\t]*([^\s\'\"]*)[\040\t]*$/gm;
508
+ // Don't reuse lastMatchInfo here, so we create a new array with room
509
+ // for four captures (array with length one longer than the index
510
+ // of the fourth capture, where the numbering is zero-based).
511
+ var matchInfo = new InternalArray(CAPTURE(3) + 1);
512
+ var match =
513
+ %_RegExpExec(sourceUrlPattern, source, sourceUrlPos - 4, matchInfo);
514
+ if (match) {
515
+ return SubString(source, matchInfo[CAPTURE(2)], matchInfo[CAPTURE(3)]);
516
+ }
517
+ }
518
+ return this.name;
519
+ }
520
+
521
+
522
+ /**
523
+ * Class for source location. A source location is a position within some
524
+ * source with the following properties:
525
+ * script : script object for the source
526
+ * line : source line number
527
+ * column : source column within the line
528
+ * position : position within the source
529
+ * start : position of start of source context (inclusive)
530
+ * end : position of end of source context (not inclusive)
531
+ * Source text for the source context is the character interval [start, end[. In
532
+ * most cases end will point to a newline character. It might point just past
533
+ * the final position of the source if the last source line does not end with a
534
+ * newline character.
535
+ * @param {Script} script The Script object for which this is a location
536
+ * @param {number} position Source position for the location
537
+ * @param {number} line The line number for the location
538
+ * @param {number} column The column within the line for the location
539
+ * @param {number} start Source position for start of source context
540
+ * @param {number} end Source position for end of source context
541
+ * @constructor
542
+ */
543
+ function SourceLocation(script, position, line, column, start, end) {
544
+ this.script = script;
545
+ this.position = position;
546
+ this.line = line;
547
+ this.column = column;
548
+ this.start = start;
549
+ this.end = end;
550
+ }
551
+
552
+
553
+ const kLineLengthLimit = 78;
554
+
555
+ /**
556
+ * Restrict source location start and end positions to make the source slice
557
+ * no more that a certain number of characters wide.
558
+ * @param {number} opt_limit The with limit of the source text with a default
559
+ * of 78
560
+ * @param {number} opt_before The number of characters to prefer before the
561
+ * position with a default value of 10 less that the limit
562
+ */
563
+ SourceLocation.prototype.restrict = function (opt_limit, opt_before) {
564
+ // Find the actual limit to use.
565
+ var limit;
566
+ var before;
567
+ if (!IS_UNDEFINED(opt_limit)) {
568
+ limit = opt_limit;
569
+ } else {
570
+ limit = kLineLengthLimit;
571
+ }
572
+ if (!IS_UNDEFINED(opt_before)) {
573
+ before = opt_before;
574
+ } else {
575
+ // If no before is specified center for small limits and perfer more source
576
+ // before the the position that after for longer limits.
577
+ if (limit <= 20) {
578
+ before = $floor(limit / 2);
579
+ } else {
580
+ before = limit - 10;
581
+ }
582
+ }
583
+ if (before >= limit) {
584
+ before = limit - 1;
585
+ }
586
+
587
+ // If the [start, end[ interval is too big we restrict
588
+ // it in one or both ends. We make sure to always produce
589
+ // restricted intervals of maximum allowed size.
590
+ if (this.end - this.start > limit) {
591
+ var start_limit = this.position - before;
592
+ var end_limit = this.position + limit - before;
593
+ if (this.start < start_limit && end_limit < this.end) {
594
+ this.start = start_limit;
595
+ this.end = end_limit;
596
+ } else if (this.start < start_limit) {
597
+ this.start = this.end - limit;
598
+ } else {
599
+ this.end = this.start + limit;
600
+ }
601
+ }
602
+ };
603
+
604
+
605
+ /**
606
+ * Get the source text for a SourceLocation
607
+ * @return {String}
608
+ * Source text for this location.
609
+ */
610
+ SourceLocation.prototype.sourceText = function () {
611
+ return %_CallFunction(this.script.source, this.start, this.end, StringSubstring);
612
+ };
613
+
614
+
615
+ /**
616
+ * Class for a source slice. A source slice is a part of a script source with
617
+ * the following properties:
618
+ * script : script object for the source
619
+ * from_line : line number for the first line in the slice
620
+ * to_line : source line number for the last line in the slice
621
+ * from_position : position of the first character in the slice
622
+ * to_position : position of the last character in the slice
623
+ * The to_line and to_position are not included in the slice, that is the lines
624
+ * in the slice are [from_line, to_line[. Likewise the characters in the slice
625
+ * are [from_position, to_position[.
626
+ * @param {Script} script The Script object for the source slice
627
+ * @param {number} from_line
628
+ * @param {number} to_line
629
+ * @param {number} from_position
630
+ * @param {number} to_position
631
+ * @constructor
632
+ */
633
+ function SourceSlice(script, from_line, to_line, from_position, to_position) {
634
+ this.script = script;
635
+ this.from_line = from_line;
636
+ this.to_line = to_line;
637
+ this.from_position = from_position;
638
+ this.to_position = to_position;
639
+ }
640
+
641
+
642
+ /**
643
+ * Get the source text for a SourceSlice
644
+ * @return {String} Source text for this slice. The last line will include
645
+ * the line terminating characters (if any)
646
+ */
647
+ SourceSlice.prototype.sourceText = function () {
648
+ return %_CallFunction(this.script.source,
649
+ this.from_position,
650
+ this.to_position,
651
+ StringSubstring);
652
+ };
653
+
654
+
655
+ // Returns the offset of the given position within the containing
656
+ // line.
657
+ function GetPositionInLine(message) {
658
+ var script = %MessageGetScript(message);
659
+ var start_position = %MessageGetStartPosition(message);
660
+ var location = script.locationFromPosition(start_position, false);
661
+ if (location == null) return -1;
662
+ location.restrict();
663
+ return start_position - location.start;
664
+ }
665
+
666
+
667
+ function GetStackTraceLine(recv, fun, pos, isGlobal) {
668
+ return FormatSourcePosition(new CallSite(recv, fun, pos));
669
+ }
670
+
671
+ // ----------------------------------------------------------------------------
672
+ // Error implementation
673
+
674
+ // Defines accessors for a property that is calculated the first time
675
+ // the property is read.
676
+ function DefineOneShotAccessor(obj, name, fun) {
677
+ // Note that the accessors consistently operate on 'obj', not 'this'.
678
+ // Since the object may occur in someone else's prototype chain we
679
+ // can't rely on 'this' being the same as 'obj'.
680
+ var hasBeenSet = false;
681
+ var value;
682
+ obj.__defineGetter__(name, function () {
683
+ if (hasBeenSet) {
684
+ return value;
685
+ }
686
+ hasBeenSet = true;
687
+ value = fun(obj);
688
+ return value;
689
+ });
690
+ obj.__defineSetter__(name, function (v) {
691
+ hasBeenSet = true;
692
+ value = v;
693
+ });
694
+ }
695
+
696
+ function CallSite(receiver, fun, pos) {
697
+ this.receiver = receiver;
698
+ this.fun = fun;
699
+ this.pos = pos;
700
+ }
701
+
702
+ CallSite.prototype.getThis = function () {
703
+ return this.receiver;
704
+ };
705
+
706
+ CallSite.prototype.getTypeName = function () {
707
+ var constructor = this.receiver.constructor;
708
+ if (!constructor)
709
+ return %_CallFunction(this.receiver, ObjectToString);
710
+ var constructorName = constructor.name;
711
+ if (!constructorName)
712
+ return %_CallFunction(this.receiver, ObjectToString);
713
+ return constructorName;
714
+ };
715
+
716
+ CallSite.prototype.isToplevel = function () {
717
+ if (this.receiver == null)
718
+ return true;
719
+ return IS_GLOBAL(this.receiver);
720
+ };
721
+
722
+ CallSite.prototype.isEval = function () {
723
+ var script = %FunctionGetScript(this.fun);
724
+ return script && script.compilation_type == COMPILATION_TYPE_EVAL;
725
+ };
726
+
727
+ CallSite.prototype.getEvalOrigin = function () {
728
+ var script = %FunctionGetScript(this.fun);
729
+ return FormatEvalOrigin(script);
730
+ };
731
+
732
+ CallSite.prototype.getScriptNameOrSourceURL = function () {
733
+ var script = %FunctionGetScript(this.fun);
734
+ return script ? script.nameOrSourceURL() : null;
735
+ };
736
+
737
+ CallSite.prototype.getFunction = function () {
738
+ return this.fun;
739
+ };
740
+
741
+ CallSite.prototype.getFunctionName = function () {
742
+ // See if the function knows its own name
743
+ var name = this.fun.name;
744
+ if (name) {
745
+ return name;
746
+ } else {
747
+ return %FunctionGetInferredName(this.fun);
748
+ }
749
+ // Maybe this is an evaluation?
750
+ var script = %FunctionGetScript(this.fun);
751
+ if (script && script.compilation_type == COMPILATION_TYPE_EVAL)
752
+ return "eval";
753
+ return null;
754
+ };
755
+
756
+ CallSite.prototype.getMethodName = function () {
757
+ // See if we can find a unique property on the receiver that holds
758
+ // this function.
759
+ var ownName = this.fun.name;
760
+ if (ownName && this.receiver &&
761
+ (%_CallFunction(this.receiver, ownName, ObjectLookupGetter) === this.fun ||
762
+ %_CallFunction(this.receiver, ownName, ObjectLookupSetter) === this.fun ||
763
+ this.receiver[ownName] === this.fun)) {
764
+ // To handle DontEnum properties we guess that the method has
765
+ // the same name as the function.
766
+ return ownName;
767
+ }
768
+ var name = null;
769
+ for (var prop in this.receiver) {
770
+ if (this.receiver.__lookupGetter__(prop) === this.fun ||
771
+ this.receiver.__lookupSetter__(prop) === this.fun ||
772
+ (!this.receiver.__lookupGetter__(prop) && this.receiver[prop] === this.fun)) {
773
+ // If we find more than one match bail out to avoid confusion.
774
+ if (name)
775
+ return null;
776
+ name = prop;
777
+ }
778
+ }
779
+ if (name)
780
+ return name;
781
+ return null;
782
+ };
783
+
784
+ CallSite.prototype.getFileName = function () {
785
+ var script = %FunctionGetScript(this.fun);
786
+ return script ? script.name : null;
787
+ };
788
+
789
+ CallSite.prototype.getLineNumber = function () {
790
+ if (this.pos == -1)
791
+ return null;
792
+ var script = %FunctionGetScript(this.fun);
793
+ var location = null;
794
+ if (script) {
795
+ location = script.locationFromPosition(this.pos, true);
796
+ }
797
+ return location ? location.line + 1 : null;
798
+ };
799
+
800
+ CallSite.prototype.getColumnNumber = function () {
801
+ if (this.pos == -1)
802
+ return null;
803
+ var script = %FunctionGetScript(this.fun);
804
+ var location = null;
805
+ if (script) {
806
+ location = script.locationFromPosition(this.pos, true);
807
+ }
808
+ return location ? location.column + 1: null;
809
+ };
810
+
811
+ CallSite.prototype.isNative = function () {
812
+ var script = %FunctionGetScript(this.fun);
813
+ return script ? (script.type == TYPE_NATIVE) : false;
814
+ };
815
+
816
+ CallSite.prototype.getPosition = function () {
817
+ return this.pos;
818
+ };
819
+
820
+ CallSite.prototype.isConstructor = function () {
821
+ var constructor = this.receiver ? this.receiver.constructor : null;
822
+ if (!constructor)
823
+ return false;
824
+ return this.fun === constructor;
825
+ };
826
+
827
+ function FormatEvalOrigin(script) {
828
+ var sourceURL = script.nameOrSourceURL();
829
+ if (sourceURL)
830
+ return sourceURL;
831
+
832
+ var eval_origin = "eval at ";
833
+ if (script.eval_from_function_name) {
834
+ eval_origin += script.eval_from_function_name;
835
+ } else {
836
+ eval_origin += "<anonymous>";
837
+ }
838
+
839
+ var eval_from_script = script.eval_from_script;
840
+ if (eval_from_script) {
841
+ if (eval_from_script.compilation_type == COMPILATION_TYPE_EVAL) {
842
+ // eval script originated from another eval.
843
+ eval_origin += " (" + FormatEvalOrigin(eval_from_script) + ")";
844
+ } else {
845
+ // eval script originated from "real" source.
846
+ if (eval_from_script.name) {
847
+ eval_origin += " (" + eval_from_script.name;
848
+ var location = eval_from_script.locationFromPosition(script.eval_from_script_position, true);
849
+ if (location) {
850
+ eval_origin += ":" + (location.line + 1);
851
+ eval_origin += ":" + (location.column + 1);
852
+ }
853
+ eval_origin += ")"
854
+ } else {
855
+ eval_origin += " (unknown source)";
856
+ }
857
+ }
858
+ }
859
+
860
+ return eval_origin;
861
+ };
862
+
863
+ function FormatSourcePosition(frame) {
864
+ var fileName;
865
+ var fileLocation = "";
866
+ if (frame.isNative()) {
867
+ fileLocation = "native";
868
+ } else if (frame.isEval()) {
869
+ fileName = frame.getScriptNameOrSourceURL();
870
+ if (!fileName)
871
+ fileLocation = frame.getEvalOrigin();
872
+ } else {
873
+ fileName = frame.getFileName();
874
+ }
875
+
876
+ if (fileName) {
877
+ fileLocation += fileName;
878
+ var lineNumber = frame.getLineNumber();
879
+ if (lineNumber != null) {
880
+ fileLocation += ":" + lineNumber;
881
+ var columnNumber = frame.getColumnNumber();
882
+ if (columnNumber) {
883
+ fileLocation += ":" + columnNumber;
884
+ }
885
+ }
886
+ }
887
+
888
+ if (!fileLocation) {
889
+ fileLocation = "unknown source";
890
+ }
891
+ var line = "";
892
+ var functionName = frame.getFunction().name;
893
+ var addPrefix = true;
894
+ var isConstructor = frame.isConstructor();
895
+ var isMethodCall = !(frame.isToplevel() || isConstructor);
896
+ if (isMethodCall) {
897
+ var methodName = frame.getMethodName();
898
+ line += frame.getTypeName() + ".";
899
+ if (functionName) {
900
+ line += functionName;
901
+ if (methodName && (methodName != functionName)) {
902
+ line += " [as " + methodName + "]";
903
+ }
904
+ } else {
905
+ line += methodName || "<anonymous>";
906
+ }
907
+ } else if (isConstructor) {
908
+ line += "new " + (functionName || "<anonymous>");
909
+ } else if (functionName) {
910
+ line += functionName;
911
+ } else {
912
+ line += fileLocation;
913
+ addPrefix = false;
914
+ }
915
+ if (addPrefix) {
916
+ line += " (" + fileLocation + ")";
917
+ }
918
+ return line;
919
+ }
920
+
921
+ function FormatStackTrace(error, frames) {
922
+ var lines = [];
923
+ try {
924
+ lines.push(error.toString());
925
+ } catch (e) {
926
+ try {
927
+ lines.push("<error: " + e + ">");
928
+ } catch (ee) {
929
+ lines.push("<error>");
930
+ }
931
+ }
932
+ for (var i = 0; i < frames.length; i++) {
933
+ var frame = frames[i];
934
+ var line;
935
+ try {
936
+ line = FormatSourcePosition(frame);
937
+ } catch (e) {
938
+ try {
939
+ line = "<error: " + e + ">";
940
+ } catch (ee) {
941
+ // Any code that reaches this point is seriously nasty!
942
+ line = "<error>";
943
+ }
944
+ }
945
+ lines.push(" at " + line);
946
+ }
947
+ return lines.join("\n");
948
+ }
949
+
950
+ function FormatRawStackTrace(error, raw_stack) {
951
+ var frames = [ ];
952
+ for (var i = 0; i < raw_stack.length; i += 4) {
953
+ var recv = raw_stack[i];
954
+ var fun = raw_stack[i + 1];
955
+ var code = raw_stack[i + 2];
956
+ var pc = raw_stack[i + 3];
957
+ var pos = %FunctionGetPositionForOffset(code, pc);
958
+ frames.push(new CallSite(recv, fun, pos));
959
+ }
960
+ if (IS_FUNCTION($Error.prepareStackTrace)) {
961
+ return $Error.prepareStackTrace(error, frames);
962
+ } else {
963
+ return FormatStackTrace(error, frames);
964
+ }
965
+ }
966
+
967
+ function DefineError(f) {
968
+ // Store the error function in both the global object
969
+ // and the runtime object. The function is fetched
970
+ // from the runtime object when throwing errors from
971
+ // within the runtime system to avoid strange side
972
+ // effects when overwriting the error functions from
973
+ // user code.
974
+ var name = f.name;
975
+ %SetProperty(global, name, f, DONT_ENUM);
976
+ this['$' + name] = f;
977
+ // Configure the error function.
978
+ if (name == 'Error') {
979
+ // The prototype of the Error object must itself be an error.
980
+ // However, it can't be an instance of the Error object because
981
+ // it hasn't been properly configured yet. Instead we create a
982
+ // special not-a-true-error-but-close-enough object.
983
+ function ErrorPrototype() {}
984
+ %FunctionSetPrototype(ErrorPrototype, $Object.prototype);
985
+ %FunctionSetInstanceClassName(ErrorPrototype, 'Error');
986
+ %FunctionSetPrototype(f, new ErrorPrototype());
987
+ } else {
988
+ %FunctionSetPrototype(f, new $Error());
989
+ }
990
+ %FunctionSetInstanceClassName(f, 'Error');
991
+ %SetProperty(f.prototype, 'constructor', f, DONT_ENUM);
992
+ // The name property on the prototype of error objects is not
993
+ // specified as being read-one and dont-delete. However, allowing
994
+ // overwriting allows leaks of error objects between script blocks
995
+ // in the same context in a browser setting. Therefore we fix the
996
+ // name.
997
+ %SetProperty(f.prototype, "name", name, READ_ONLY | DONT_DELETE);
998
+ %SetCode(f, function(m) {
999
+ if (%_IsConstructCall()) {
1000
+ // Define all the expected properties directly on the error
1001
+ // object. This avoids going through getters and setters defined
1002
+ // on prototype objects.
1003
+ %IgnoreAttributesAndSetProperty(this, 'stack', void 0);
1004
+ %IgnoreAttributesAndSetProperty(this, 'arguments', void 0);
1005
+ %IgnoreAttributesAndSetProperty(this, 'type', void 0);
1006
+ if (m === kAddMessageAccessorsMarker) {
1007
+ // DefineOneShotAccessor always inserts a message property and
1008
+ // ignores setters.
1009
+ DefineOneShotAccessor(this, 'message', function (obj) {
1010
+ return FormatMessage(%NewMessageObject(obj.type, obj.arguments));
1011
+ });
1012
+ } else if (!IS_UNDEFINED(m)) {
1013
+ %IgnoreAttributesAndSetProperty(this, 'message', ToString(m));
1014
+ }
1015
+ captureStackTrace(this, f);
1016
+ } else {
1017
+ return new f(m);
1018
+ }
1019
+ });
1020
+ }
1021
+
1022
+ function captureStackTrace(obj, cons_opt) {
1023
+ var stackTraceLimit = $Error.stackTraceLimit;
1024
+ if (!stackTraceLimit || !IS_NUMBER(stackTraceLimit)) return;
1025
+ if (stackTraceLimit < 0 || stackTraceLimit > 10000)
1026
+ stackTraceLimit = 10000;
1027
+ var raw_stack = %CollectStackTrace(cons_opt
1028
+ ? cons_opt
1029
+ : captureStackTrace, stackTraceLimit);
1030
+ DefineOneShotAccessor(obj, 'stack', function (obj) {
1031
+ return FormatRawStackTrace(obj, raw_stack);
1032
+ });
1033
+ };
1034
+
1035
+ $Math.__proto__ = global.Object.prototype;
1036
+
1037
+ DefineError(function Error() { });
1038
+ DefineError(function TypeError() { });
1039
+ DefineError(function RangeError() { });
1040
+ DefineError(function SyntaxError() { });
1041
+ DefineError(function ReferenceError() { });
1042
+ DefineError(function EvalError() { });
1043
+ DefineError(function URIError() { });
1044
+
1045
+ $Error.captureStackTrace = captureStackTrace;
1046
+
1047
+ // Setup extra properties of the Error.prototype object.
1048
+ $Error.prototype.message = '';
1049
+
1050
+ // Global list of error objects visited during errorToString. This is
1051
+ // used to detect cycles in error toString formatting.
1052
+ var visited_errors = new $Array();
1053
+ var cyclic_error_marker = new $Object();
1054
+
1055
+ function errorToStringDetectCycle() {
1056
+ if (!%PushIfAbsent(visited_errors, this)) throw cyclic_error_marker;
1057
+ try {
1058
+ var type = this.type;
1059
+ if (type && !%_CallFunction(this, "message", ObjectHasOwnProperty)) {
1060
+ var formatted = FormatMessage(%NewMessageObject(type, this.arguments));
1061
+ return this.name + ": " + formatted;
1062
+ }
1063
+ var message = %_CallFunction(this, "message", ObjectHasOwnProperty)
1064
+ ? (": " + this.message)
1065
+ : "";
1066
+ return this.name + message;
1067
+ } finally {
1068
+ visited_errors.length = visited_errors.length - 1;
1069
+ }
1070
+ }
1071
+
1072
+ function errorToString() {
1073
+ if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
1074
+ throw MakeTypeError("called_on_null_or_undefined",
1075
+ ["Error.prototype.toString"]);
1076
+ }
1077
+ // This helper function is needed because access to properties on
1078
+ // the builtins object do not work inside of a catch clause.
1079
+ function isCyclicErrorMarker(o) { return o === cyclic_error_marker; }
1080
+
1081
+ try {
1082
+ return %_CallFunction(this, errorToStringDetectCycle);
1083
+ } catch(e) {
1084
+ // If this error message was encountered already return the empty
1085
+ // string for it instead of recursively formatting it.
1086
+ if (isCyclicErrorMarker(e)) return '';
1087
+ else throw e;
1088
+ }
1089
+ }
1090
+
1091
+
1092
+ InstallFunctions($Error.prototype, DONT_ENUM, ['toString', errorToString]);
1093
+
1094
+ // Boilerplate for exceptions for stack overflows. Used from
1095
+ // Isolate::StackOverflow().
1096
+ const kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []);