democracy 0.0.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of democracy might be problematic. Click here for more details.

Files changed (647) hide show
  1. checksums.yaml +7 -0
  2. data/LIBERTY +310 -0
  3. data/README +310 -0
  4. data/README2 +14 -0
  5. data/READ_THIS_TO_CHANGE_THINGS +310 -0
  6. data/Resume.pdf +0 -0
  7. data/Ruby Installer.exe +0 -0
  8. data/VERSION_NUMBER +1 -0
  9. data/WE_NEEDNT_BE_ENSLAVED +310 -0
  10. data/_.html +460 -0
  11. data/__index.html +11 -0
  12. data/a.html +21 -0
  13. data/ac +73 -0
  14. data/all_code.cpp +280 -0
  15. data/all_code.js +30 -0
  16. data/app_topics +93 -0
  17. data/background.jpg +0 -0
  18. data/better_string +26 -0
  19. data/bin/abs +0 -0
  20. data/bin/ac +34 -0
  21. data/bin/add +0 -0
  22. data/bin/append +14 -0
  23. data/bin/args +0 -0
  24. data/bin/autorequire +85 -0
  25. data/bin/big_num +155 -0
  26. data/bin/black +0 -0
  27. data/bin/blue +0 -0
  28. data/bin/bold +0 -0
  29. data/bin/c_repl +76 -0
  30. data/bin/close +3 -0
  31. data/bin/copy +0 -0
  32. data/bin/count +0 -0
  33. data/bin/cpy +0 -0
  34. data/bin/cyan +0 -0
  35. data/bin/democracyinstall.exe +0 -0
  36. data/bin/div +0 -0
  37. data/bin/down_all_links +50 -0
  38. data/bin/dump +0 -0
  39. data/bin/email +127 -0
  40. data/bin/emerald-browser +0 -0
  41. data/bin/emoji +176 -0
  42. data/bin/executable +1 -0
  43. data/bin/exp +0 -0
  44. data/bin/files +0 -0
  45. data/bin/floor +0 -0
  46. data/bin/foreach +49 -0
  47. data/bin/g+ +557 -0
  48. data/bin/get_all_links +11 -0
  49. data/bin/github +55 -0
  50. data/bin/green +0 -0
  51. data/bin/gsearch +159 -0
  52. data/bin/gsub +0 -0
  53. data/bin/gsub_in_place +0 -0
  54. data/bin/last_nth +0 -0
  55. data/bin/lines +0 -0
  56. data/bin/magenta +0 -0
  57. data/bin/mkfile +47 -0
  58. data/bin/mul +0 -0
  59. data/bin/nth +0 -0
  60. data/bin/open +0 -0
  61. data/bin/play +0 -0
  62. data/bin/prepend +14 -0
  63. data/bin/processes +3 -0
  64. data/bin/qt_download +21 -0
  65. data/bin/record +121 -0
  66. data/bin/red +0 -0
  67. data/bin/replace_in_place +0 -0
  68. data/bin/replace_not_in_place +0 -0
  69. data/bin/selectlines +0 -0
  70. data/bin/sort_in_place +0 -0
  71. data/bin/splitfiles +16 -0
  72. data/bin/squeeze +17 -0
  73. data/bin/string +161 -0
  74. data/bin/strip_extensions +13 -0
  75. data/bin/sub +0 -0
  76. data/bin/t +63 -0
  77. data/bin/tracefile +555 -0
  78. data/bin/underline +0 -0
  79. data/bin/undump +0 -0
  80. data/bin/viu +0 -0
  81. data/bin/white +0 -0
  82. data/bin/yellow +0 -0
  83. data/bin/youtube_video +45 -0
  84. data/bin/youtube_video2 +45 -0
  85. data/code.js +28490 -0
  86. data/crystal-gobject/.git/HEAD +1 -0
  87. data/crystal-gobject/.git/config +11 -0
  88. data/crystal-gobject/.git/description +1 -0
  89. data/crystal-gobject/.git/hooks/applypatch-msg.sample +15 -0
  90. data/crystal-gobject/.git/hooks/commit-msg.sample +24 -0
  91. data/crystal-gobject/.git/hooks/fsmonitor-watchman.sample +109 -0
  92. data/crystal-gobject/.git/hooks/post-update.sample +8 -0
  93. data/crystal-gobject/.git/hooks/pre-applypatch.sample +14 -0
  94. data/crystal-gobject/.git/hooks/pre-commit.sample +49 -0
  95. data/crystal-gobject/.git/hooks/pre-merge-commit.sample +13 -0
  96. data/crystal-gobject/.git/hooks/pre-push.sample +53 -0
  97. data/crystal-gobject/.git/hooks/pre-rebase.sample +169 -0
  98. data/crystal-gobject/.git/hooks/pre-receive.sample +24 -0
  99. data/crystal-gobject/.git/hooks/prepare-commit-msg.sample +42 -0
  100. data/crystal-gobject/.git/hooks/update.sample +128 -0
  101. data/crystal-gobject/.git/index +0 -0
  102. data/crystal-gobject/.git/info/exclude +6 -0
  103. data/crystal-gobject/.git/logs/HEAD +1 -0
  104. data/crystal-gobject/.git/logs/refs/heads/main +1 -0
  105. data/crystal-gobject/.git/logs/refs/remotes/origin/HEAD +1 -0
  106. data/crystal-gobject/.git/objects/pack/pack-c21cfd88c6eef3076f2c2aebb658b750e87e10b6.idx +0 -0
  107. data/crystal-gobject/.git/objects/pack/pack-c21cfd88c6eef3076f2c2aebb658b750e87e10b6.pack +0 -0
  108. data/crystal-gobject/.git/packed-refs +15 -0
  109. data/crystal-gobject/.git/refs/heads/main +1 -0
  110. data/crystal-gobject/.git/refs/remotes/origin/HEAD +1 -0
  111. data/crystal-gobject/.github/workflows/ci.yml +22 -0
  112. data/crystal-gobject/.gitignore +14 -0
  113. data/crystal-gobject/LICENSE +27 -0
  114. data/crystal-gobject/README.md +143 -0
  115. data/crystal-gobject/samples/base_class_container.cr +15 -0
  116. data/crystal-gobject/samples/connect_after.cr +35 -0
  117. data/crystal-gobject/samples/crout/crout.cr +59 -0
  118. data/crystal-gobject/samples/e +0 -0
  119. data/crystal-gobject/samples/gdk_window.cr +36 -0
  120. data/crystal-gobject/samples/glist.cr +16 -0
  121. data/crystal-gobject/samples/greeter.cr +34 -0
  122. data/crystal-gobject/samples/greeter.glade +91 -0
  123. data/crystal-gobject/samples/gtk_accel_group.cr +13 -0
  124. data/crystal-gobject/samples/gtk_application.cr +12 -0
  125. data/crystal-gobject/samples/gtk_boxes.cr +44 -0
  126. data/crystal-gobject/samples/gtk_css_styling/css_window.cr +37 -0
  127. data/crystal-gobject/samples/gtk_css_styling/css_window.css +3 -0
  128. data/crystal-gobject/samples/gtk_css_styling/css_window.glade +104 -0
  129. data/crystal-gobject/samples/gtk_editable.cr +14 -0
  130. data/crystal-gobject/samples/gtk_entry.cr +10 -0
  131. data/crystal-gobject/samples/gtk_hello_world.cr +13 -0
  132. data/crystal-gobject/samples/gtk_menu_and_actions.cr +69 -0
  133. data/crystal-gobject/samples/gtk_message_dialog.cr +9 -0
  134. data/crystal-gobject/samples/gtk_subclasses.cr +30 -0
  135. data/crystal-gobject/samples/gtk_tree_view.cr +30 -0
  136. data/crystal-gobject/samples/gtk_tree_view.glade +44 -0
  137. data/crystal-gobject/samples/hello +0 -0
  138. data/crystal-gobject/samples/libgdk-3.a +0 -0
  139. data/crystal-gobject/samples/libgdk_pixbuf-2.0.a +0 -0
  140. data/crystal-gobject/samples/libgtk-3.a +0 -0
  141. data/crystal-gobject/samples/timeout.cr +34 -0
  142. data/crystal-gobject/script/ci.sh +17 -0
  143. data/crystal-gobject/script/release.sh +31 -0
  144. data/crystal-gobject/script/run_with_timeout.cr +14 -0
  145. data/crystal-gobject/script/test +7 -0
  146. data/crystal-gobject/shard.yml +16 -0
  147. data/crystal-gobject/spec/basic_spec.cr +46 -0
  148. data/crystal-gobject/spec/libsample/Makefile +28 -0
  149. data/crystal-gobject/spec/libsample/test-subject.c +107 -0
  150. data/crystal-gobject/spec/libsample/test-subject.h +65 -0
  151. data/crystal-gobject/spec/spec_helper.cr +5 -0
  152. data/crystal-gobject/src/atk/atk.cr +2 -0
  153. data/crystal-gobject/src/closure_data_manager.cr +62 -0
  154. data/crystal-gobject/src/crout.cr +601 -0
  155. data/crystal-gobject/src/g_i_repository/dumper.cr +116 -0
  156. data/crystal-gobject/src/g_i_repository/g_i_repository.cr +46 -0
  157. data/crystal-gobject/src/g_i_repository/info/arg_info.cr +157 -0
  158. data/crystal-gobject/src/g_i_repository/info/base_info.cr +169 -0
  159. data/crystal-gobject/src/g_i_repository/info/callable_info.cr +266 -0
  160. data/crystal-gobject/src/g_i_repository/info/callback_info.cr +54 -0
  161. data/crystal-gobject/src/g_i_repository/info/constant_info.cr +115 -0
  162. data/crystal-gobject/src/g_i_repository/info/enum_info.cr +88 -0
  163. data/crystal-gobject/src/g_i_repository/info/field_info.cr +97 -0
  164. data/crystal-gobject/src/g_i_repository/info/function_info.cr +237 -0
  165. data/crystal-gobject/src/g_i_repository/info/interface_info.cr +97 -0
  166. data/crystal-gobject/src/g_i_repository/info/object_info.cr +170 -0
  167. data/crystal-gobject/src/g_i_repository/info/property_info.cr +93 -0
  168. data/crystal-gobject/src/g_i_repository/info/registered_type_info.cr +62 -0
  169. data/crystal-gobject/src/g_i_repository/info/signal_info.cr +119 -0
  170. data/crystal-gobject/src/g_i_repository/info/struct_info.cr +139 -0
  171. data/crystal-gobject/src/g_i_repository/info/type_info.cr +326 -0
  172. data/crystal-gobject/src/g_i_repository/info/union_info.cr +136 -0
  173. data/crystal-gobject/src/g_i_repository/info/v_func_info.cr +33 -0
  174. data/crystal-gobject/src/g_i_repository/info/value_info.cr +62 -0
  175. data/crystal-gobject/src/g_i_repository/repository.cr +68 -0
  176. data/crystal-gobject/src/g_i_repository/wrapper_generator.cr +103 -0
  177. data/crystal-gobject/src/g_lib/error.cr +34 -0
  178. data/crystal-gobject/src/g_lib/g_lib.cr +81 -0
  179. data/crystal-gobject/src/g_lib/list_iterator.cr +81 -0
  180. data/crystal-gobject/src/g_lib/s_list_iterator.cr +54 -0
  181. data/crystal-gobject/src/g_object/closure.cr +40 -0
  182. data/crystal-gobject/src/g_object/g_object.cr +7 -0
  183. data/crystal-gobject/src/g_object/module_functions.cr +38 -0
  184. data/crystal-gobject/src/g_object/object.cr +104 -0
  185. data/crystal-gobject/src/g_object/type.cr +68 -0
  186. data/crystal-gobject/src/g_object/value.cr +308 -0
  187. data/crystal-gobject/src/gdk/event.cr +34 -0
  188. data/crystal-gobject/src/gdk/gdk.cr +35 -0
  189. data/crystal-gobject/src/generated/g_i_repository/argument.cr +130 -0
  190. data/crystal-gobject/src/generated/g_i_repository/array_type.cr +34 -0
  191. data/crystal-gobject/src/generated/g_i_repository/attribute_iter.cr +65 -0
  192. data/crystal-gobject/src/generated/g_i_repository/base_info.cr +134 -0
  193. data/crystal-gobject/src/generated/g_i_repository/direction.cr +33 -0
  194. data/crystal-gobject/src/generated/g_i_repository/field_info_flags.cr +34 -0
  195. data/crystal-gobject/src/generated/g_i_repository/function_info_flags.cr +38 -0
  196. data/crystal-gobject/src/generated/g_i_repository/g_i_repository.cr +7 -0
  197. data/crystal-gobject/src/generated/g_i_repository/info_type.cr +50 -0
  198. data/crystal-gobject/src/generated/g_i_repository/module_functions.cr +816 -0
  199. data/crystal-gobject/src/generated/g_i_repository/repository.cr +214 -0
  200. data/crystal-gobject/src/generated/g_i_repository/repository_class.cr +55 -0
  201. data/crystal-gobject/src/generated/g_i_repository/repository_error.cr +34 -0
  202. data/crystal-gobject/src/generated/g_i_repository/repository_load_flags.cr +33 -0
  203. data/crystal-gobject/src/generated/g_i_repository/repository_private.cr +46 -0
  204. data/crystal-gobject/src/generated/g_i_repository/scope_type.cr +34 -0
  205. data/crystal-gobject/src/generated/g_i_repository/transfer.cr +33 -0
  206. data/crystal-gobject/src/generated/g_i_repository/type_tag.cr +52 -0
  207. data/crystal-gobject/src/generated/g_i_repository/typelib.cr +61 -0
  208. data/crystal-gobject/src/generated/g_i_repository/unresolved_info.cr +45 -0
  209. data/crystal-gobject/src/generated/g_i_repository/v_func_info_flags.cr +36 -0
  210. data/crystal-gobject/src/generated/g_object/param_flags.cr +44 -0
  211. data/crystal-gobject/src/generated/g_object/signal_flags.cr +42 -0
  212. data/crystal-gobject/src/generated/lib_g_i_repository.cr +302 -0
  213. data/crystal-gobject/src/generated/lib_g_lib.cr +2261 -0
  214. data/crystal-gobject/src/generated/lib_g_object.cr +874 -0
  215. data/crystal-gobject/src/generator/build_namespace.cr +22 -0
  216. data/crystal-gobject/src/generator/doc.cr +259 -0
  217. data/crystal-gobject/src/generator/dump.cr +55 -0
  218. data/crystal-gobject/src/generator/generator.cr +22 -0
  219. data/crystal-gobject/src/generator/namespace.cr +192 -0
  220. data/crystal-gobject/src/generator/stage2.cr +113 -0
  221. data/crystal-gobject/src/generator/stage3.cr +3 -0
  222. data/crystal-gobject/src/gio/gio.cr +4 -0
  223. data/crystal-gobject/src/gobject.cr +54 -0
  224. data/crystal-gobject/src/gtk/autorun.cr +16 -0
  225. data/crystal-gobject/src/gtk/gtk.cr +61 -0
  226. data/crystal-gobject/src/notify/notification.cr +158 -0
  227. data/crystal-gobject/src/notify/notify.cr +4 -0
  228. data/crystal-gobject/src/pointer_iterator.cr +49 -0
  229. data/crystal-gobject/src/wrapped_type.cr +53 -0
  230. data/democracy.gemspec +14 -0
  231. data/dictate +183 -0
  232. data/emerald-browser/.qmake.stash +23 -0
  233. data/emerald-browser/Makefile +469 -0
  234. data/emerald-browser/OUT +90 -0
  235. data/emerald-browser/a.out +0 -0
  236. data/emerald-browser/empty +0 -0
  237. data/emerald-browser/empty.c +1 -0
  238. data/emerald-browser/open +0 -0
  239. data/emerald-browser/open.c +57 -0
  240. data/emerald-browser/qmake.pro +23 -0
  241. data/emerald-browser/src/OUT +438 -0
  242. data/emerald-browser/src/a.cpp +303 -0
  243. data/emerald-browser/src/a.out +0 -0
  244. data/emerald-browser/src/ss.h +12 -0
  245. data/emerald-browser/src/t/fullscreennotification.cpp +98 -0
  246. data/emerald-browser/src/t/fullscreennotification.h +72 -0
  247. data/emerald-browser/src/t/fullscreenwindow.cpp +99 -0
  248. data/emerald-browser/src/t/fullscreenwindow.h +76 -0
  249. data/emerald-browser/src/t/main.cpp +64 -0
  250. data/emerald-browser/src/t/mainwindow.cpp +83 -0
  251. data/emerald-browser/src/t/mainwindow.h +75 -0
  252. data/emerald-browser/test/a.cpp +2 -0
  253. data/f +0 -0
  254. data/faster_googler +31 -0
  255. data/favicon.ico +0 -0
  256. data/foo +80 -0
  257. data/foo.c +39 -0
  258. data/foo.cpp +36 -0
  259. data/foo.js +25 -0
  260. data/free_icons/site/bulb +0 -0
  261. data/free_icons/site/chess +0 -0
  262. data/free_icons/site/compiz.svg +463 -0
  263. data/free_icons/site/cursor.svg +1 -0
  264. data/free_icons/site/dock +0 -0
  265. data/free_icons/site/gnu +0 -0
  266. data/free_icons/site/info.svg +200 -0
  267. data/free_icons/site/iphone.svg +222 -0
  268. data/free_icons/site/laptop +0 -0
  269. data/free_icons/site/magic.svg +856 -0
  270. data/free_icons/site/man +0 -0
  271. data/free_icons/site/mint +0 -0
  272. data/free_icons/site/mouse +0 -0
  273. data/free_icons/site/paint.svg +2640 -0
  274. data/free_icons/site/present +0 -0
  275. data/free_icons/site/python +0 -0
  276. data/free_icons/site/reality +0 -0
  277. data/free_icons/site/ruby +0 -0
  278. data/free_icons/site/skeptic +0 -0
  279. data/free_icons/site/terminal +0 -0
  280. data/free_icons/site/video.svg +358 -0
  281. data/free_icons/site/warning +0 -0
  282. data/free_icons/site/wikipedia.svg +553 -0
  283. data/free_icons/site/write.svg +287 -0
  284. data/g +0 -0
  285. data/graphical_help.c +6 -0
  286. data/gregory_coreutils/DOC +14 -0
  287. data/gregory_coreutils/build/Makefile +12 -0
  288. data/gregory_coreutils/build/code +1 -0
  289. data/gregory_coreutils/build/functions +465 -0
  290. data/gregory_coreutils/build/make +93 -0
  291. data/gregory_coreutils/build/mk +74 -0
  292. data/gregory_coreutils/build/regex +2 -0
  293. data/gregory_coreutils/build/ruby_functions +0 -0
  294. data/gregory_coreutils/utilities/abs +0 -0
  295. data/gregory_coreutils/utilities/add +0 -0
  296. data/gregory_coreutils/utilities/args +0 -0
  297. data/gregory_coreutils/utilities/black +0 -0
  298. data/gregory_coreutils/utilities/blue +0 -0
  299. data/gregory_coreutils/utilities/bold +0 -0
  300. data/gregory_coreutils/utilities/copy +0 -0
  301. data/gregory_coreutils/utilities/count +0 -0
  302. data/gregory_coreutils/utilities/cpy +0 -0
  303. data/gregory_coreutils/utilities/cyan +0 -0
  304. data/gregory_coreutils/utilities/div +0 -0
  305. data/gregory_coreutils/utilities/dump +0 -0
  306. data/gregory_coreutils/utilities/exp +0 -0
  307. data/gregory_coreutils/utilities/files +0 -0
  308. data/gregory_coreutils/utilities/floor +0 -0
  309. data/gregory_coreutils/utilities/green +0 -0
  310. data/gregory_coreutils/utilities/gsub +0 -0
  311. data/gregory_coreutils/utilities/gsub_in_place +0 -0
  312. data/gregory_coreutils/utilities/last_nth +0 -0
  313. data/gregory_coreutils/utilities/lines +0 -0
  314. data/gregory_coreutils/utilities/magenta +0 -0
  315. data/gregory_coreutils/utilities/mul +0 -0
  316. data/gregory_coreutils/utilities/nth +0 -0
  317. data/gregory_coreutils/utilities/red +0 -0
  318. data/gregory_coreutils/utilities/replace_in_place +0 -0
  319. data/gregory_coreutils/utilities/replace_not_in_place +0 -0
  320. data/gregory_coreutils/utilities/selectlines +0 -0
  321. data/gregory_coreutils/utilities/sort_in_place +0 -0
  322. data/gregory_coreutils/utilities/sub +0 -0
  323. data/gregory_coreutils/utilities/underline +0 -0
  324. data/gregory_coreutils/utilities/undump +0 -0
  325. data/gregory_coreutils/utilities/white +0 -0
  326. data/gregory_coreutils/utilities/yellow +0 -0
  327. data/gtk +3 -0
  328. data/html_file +0 -0
  329. data/html_file.html +92 -0
  330. data/i +181 -0
  331. data/index.html +38 -0
  332. data/index2.html +344 -0
  333. data/inspect.rb +209 -0
  334. data/lib/README +310 -0
  335. data/lib/__index.html +11 -0
  336. data/lib/because.rb +41 -0
  337. data/lib/code.js +28490 -0
  338. data/lib/compile +5 -0
  339. data/lib/conjunction.rb +49 -0
  340. data/lib/evidence.rb +45 -0
  341. data/lib/graphical_help +90 -0
  342. data/lib/however.rb +42 -0
  343. data/lib/index.html +49 -0
  344. data/lib/index2.html +344 -0
  345. data/lib/inputreceiver.rb +135 -0
  346. data/lib/item.rb +77 -0
  347. data/lib/itemlist.rb +50 -0
  348. data/lib/negative.rb +43 -0
  349. data/lib/neutral.rb +43 -0
  350. data/lib/outputter.rb +60 -0
  351. data/lib/p.rb +71 -0
  352. data/lib/positive.rb +41 -0
  353. data/lib/script.js +423 -0
  354. data/lib/string__.rb +110 -0
  355. data/lib/sub/file +5 -0
  356. data/man/foo.rb +6 -0
  357. data/man/gtk.html +1 -0
  358. data/man/out +7288 -0
  359. data/more/ac.desktop +12 -0
  360. data/more/res +1 -0
  361. data/more/web-speech-api/.git/HEAD +1 -0
  362. data/more/web-speech-api/.git/config +11 -0
  363. data/more/web-speech-api/.git/description +1 -0
  364. data/more/web-speech-api/.git/hooks/applypatch-msg.sample +15 -0
  365. data/more/web-speech-api/.git/hooks/commit-msg.sample +24 -0
  366. data/more/web-speech-api/.git/hooks/fsmonitor-watchman.sample +109 -0
  367. data/more/web-speech-api/.git/hooks/post-update.sample +8 -0
  368. data/more/web-speech-api/.git/hooks/pre-applypatch.sample +14 -0
  369. data/more/web-speech-api/.git/hooks/pre-commit.sample +49 -0
  370. data/more/web-speech-api/.git/hooks/pre-merge-commit.sample +13 -0
  371. data/more/web-speech-api/.git/hooks/pre-push.sample +53 -0
  372. data/more/web-speech-api/.git/hooks/pre-rebase.sample +169 -0
  373. data/more/web-speech-api/.git/hooks/pre-receive.sample +24 -0
  374. data/more/web-speech-api/.git/hooks/prepare-commit-msg.sample +42 -0
  375. data/more/web-speech-api/.git/hooks/update.sample +128 -0
  376. data/more/web-speech-api/.git/index +0 -0
  377. data/more/web-speech-api/.git/info/exclude +6 -0
  378. data/more/web-speech-api/.git/logs/HEAD +1 -0
  379. data/more/web-speech-api/.git/logs/refs/heads/master +1 -0
  380. data/more/web-speech-api/.git/logs/refs/remotes/origin/HEAD +1 -0
  381. data/more/web-speech-api/.git/objects/pack/pack-4d2adae000c513b287d53e24937e9e836954f901.idx +0 -0
  382. data/more/web-speech-api/.git/objects/pack/pack-4d2adae000c513b287d53e24937e9e836954f901.pack +0 -0
  383. data/more/web-speech-api/.git/packed-refs +2 -0
  384. data/more/web-speech-api/.git/refs/heads/master +1 -0
  385. data/more/web-speech-api/.git/refs/remotes/origin/HEAD +1 -0
  386. data/more/web-speech-api/CODE_OF_CONDUCT.md +15 -0
  387. data/more/web-speech-api/LICENSE +116 -0
  388. data/more/web-speech-api/README.md +23 -0
  389. data/more/web-speech-api/index.html +25 -0
  390. data/more/web-speech-api/phrase-matcher/index.html +30 -0
  391. data/more/web-speech-api/phrase-matcher/script.js +124 -0
  392. data/more/web-speech-api/phrase-matcher/style.css +54 -0
  393. data/more/web-speech-api/speak-easy-synthesis/img/ws128.png +0 -0
  394. data/more/web-speech-api/speak-easy-synthesis/img/ws512.png +0 -0
  395. data/more/web-speech-api/speak-easy-synthesis/index.html +43 -0
  396. data/more/web-speech-api/speak-easy-synthesis/manifest.webapp +14 -0
  397. data/more/web-speech-api/speak-easy-synthesis/script.js +87 -0
  398. data/more/web-speech-api/speak-easy-synthesis/style.css +74 -0
  399. data/more/web-speech-api/speech-color-changer/img/ws128.png +0 -0
  400. data/more/web-speech-api/speech-color-changer/img/ws512.png +0 -0
  401. data/more/web-speech-api/speech-color-changer/index.html +26 -0
  402. data/more/web-speech-api/speech-color-changer/manifest.webapp +23 -0
  403. data/more/web-speech-api/speech-color-changer/script.js +58 -0
  404. data/more/web-speech-api/speech-color-changer/style.css +38 -0
  405. data/opensrc +68 -0
  406. data/out +39 -0
  407. data/playsrc +14 -0
  408. data/program.c +11 -0
  409. data/program.prog +568 -0
  410. data/proj/a +0 -0
  411. data/proj/a.c +1 -0
  412. data/proj/a.o +0 -0
  413. data/proj/a.rs +18 -0
  414. data/proj/b.rs +22 -0
  415. data/proj/linker.sh +8 -0
  416. data/proj/save_last +4 -0
  417. data/push +16 -0
  418. data/q.cpp +175 -0
  419. data/qt/.qmake.stash +23 -0
  420. data/qt/Qt5Core.dll +0 -0
  421. data/qt/Qt5Gui.dll +0 -0
  422. data/qt/Qt5Multimedia.dll +0 -0
  423. data/qt/Qt5MultimediaWidgets.dll +0 -0
  424. data/qt/Qt5Network.dll +0 -0
  425. data/qt/Qt5PrintSupport.dll +0 -0
  426. data/qt/Qt5Qml.dll +0 -0
  427. data/qt/Qt5QmlModels.dll +0 -0
  428. data/qt/Qt5Quick.dll +0 -0
  429. data/qt/Qt5Sensors.dll +0 -0
  430. data/qt/Qt5WebChannel.dll +0 -0
  431. data/qt/Qt5WebKit.dll +0 -0
  432. data/qt/Qt5WebKitWidgets.dll +0 -0
  433. data/qt/Qt5Widgets.dll +0 -0
  434. data/qt/a.cpp +39 -0
  435. data/qt/a.out +0 -0
  436. data/qt/a.sh +7 -0
  437. data/qt/icudt66.dll +0 -0
  438. data/qt/icuin66.dll +0 -0
  439. data/qt/icuuc66.dll +0 -0
  440. data/qt/libbz2.dll +0 -0
  441. data/qt/libcrypto-1_1-x64.dll +0 -0
  442. data/qt/libfreetype-6.dll +0 -0
  443. data/qt/libgcc_s_seh-1.dll +0 -0
  444. data/qt/libglib-2.0-0.dll +0 -0
  445. data/qt/libharfbuzz-0.dll +0 -0
  446. data/qt/libiconv-2.dll +0 -0
  447. data/qt/libintl-8.dll +0 -0
  448. data/qt/libjpeg-9.dll +0 -0
  449. data/qt/liblzma-5.dll +0 -0
  450. data/qt/libpcre-1.dll +0 -0
  451. data/qt/libpcre2-16-0.dll +0 -0
  452. data/qt/libpng16-16.dll +0 -0
  453. data/qt/libsqlite3-0.dll +0 -0
  454. data/qt/libssl-1_1-x64.dll +0 -0
  455. data/qt/libstdc++-6.dll +0 -0
  456. data/qt/libwebp-7.dll +0 -0
  457. data/qt/libwinpthread-1.dll +0 -0
  458. data/qt/libxml2-2.dll +0 -0
  459. data/qt/libxslt-1.dll +0 -0
  460. data/qt/libzstd.dll +0 -0
  461. data/qt/prog +1 -0
  462. data/qt/qwindows.dll +0 -0
  463. data/qt/zlib1.dll +0 -0
  464. data/quickjs/.git/HEAD +1 -0
  465. data/quickjs/.git/config +11 -0
  466. data/quickjs/.git/description +1 -0
  467. data/quickjs/.git/hooks/applypatch-msg.sample +15 -0
  468. data/quickjs/.git/hooks/commit-msg.sample +24 -0
  469. data/quickjs/.git/hooks/fsmonitor-watchman.sample +109 -0
  470. data/quickjs/.git/hooks/post-update.sample +8 -0
  471. data/quickjs/.git/hooks/pre-applypatch.sample +14 -0
  472. data/quickjs/.git/hooks/pre-commit.sample +49 -0
  473. data/quickjs/.git/hooks/pre-merge-commit.sample +13 -0
  474. data/quickjs/.git/hooks/pre-push.sample +53 -0
  475. data/quickjs/.git/hooks/pre-rebase.sample +169 -0
  476. data/quickjs/.git/hooks/pre-receive.sample +24 -0
  477. data/quickjs/.git/hooks/prepare-commit-msg.sample +42 -0
  478. data/quickjs/.git/hooks/update.sample +128 -0
  479. data/quickjs/.git/index +0 -0
  480. data/quickjs/.git/info/exclude +6 -0
  481. data/quickjs/.git/logs/HEAD +1 -0
  482. data/quickjs/.git/logs/refs/heads/master +1 -0
  483. data/quickjs/.git/logs/refs/remotes/origin/HEAD +1 -0
  484. data/quickjs/.git/objects/pack/pack-744a13dba8773a756b22372ba65ded3aca50cdeb.idx +0 -0
  485. data/quickjs/.git/objects/pack/pack-744a13dba8773a756b22372ba65ded3aca50cdeb.pack +0 -0
  486. data/quickjs/.git/packed-refs +2 -0
  487. data/quickjs/.git/refs/heads/master +1 -0
  488. data/quickjs/.git/refs/remotes/origin/HEAD +1 -0
  489. data/quickjs/.obj/.d +1 -0
  490. data/quickjs/.obj/cutils.nolto.o +0 -0
  491. data/quickjs/.obj/cutils.o +0 -0
  492. data/quickjs/.obj/cutils.o.d +1 -0
  493. data/quickjs/.obj/hello.o +0 -0
  494. data/quickjs/.obj/hello.o.d +1 -0
  495. data/quickjs/.obj/libbf.nolto.o +0 -0
  496. data/quickjs/.obj/libbf.o +0 -0
  497. data/quickjs/.obj/libbf.o.d +1 -0
  498. data/quickjs/.obj/libregexp.nolto.o +0 -0
  499. data/quickjs/.obj/libregexp.o +0 -0
  500. data/quickjs/.obj/libregexp.o.d +2 -0
  501. data/quickjs/.obj/libunicode.nolto.o +0 -0
  502. data/quickjs/.obj/libunicode.o +0 -0
  503. data/quickjs/.obj/libunicode.o.d +1 -0
  504. data/quickjs/.obj/qjs.check.o +0 -0
  505. data/quickjs/.obj/qjs.check.o.d +1 -0
  506. data/quickjs/.obj/qjs.o +0 -0
  507. data/quickjs/.obj/qjs.o.d +1 -0
  508. data/quickjs/.obj/qjsc.o +0 -0
  509. data/quickjs/.obj/qjsc.o.d +1 -0
  510. data/quickjs/.obj/qjscalc.o +0 -0
  511. data/quickjs/.obj/qjscalc.o.d +1 -0
  512. data/quickjs/.obj/quickjs-libc.nolto.o +0 -0
  513. data/quickjs/.obj/quickjs-libc.o +0 -0
  514. data/quickjs/.obj/quickjs-libc.o.d +2 -0
  515. data/quickjs/.obj/quickjs.check.o +0 -0
  516. data/quickjs/.obj/quickjs.check.o.d +2 -0
  517. data/quickjs/.obj/quickjs.nolto.o +0 -0
  518. data/quickjs/.obj/quickjs.o +0 -0
  519. data/quickjs/.obj/quickjs.o.d +2 -0
  520. data/quickjs/.obj/repl.o +0 -0
  521. data/quickjs/.obj/repl.o.d +1 -0
  522. data/quickjs/.obj/run-test262.o +0 -0
  523. data/quickjs/.obj/run-test262.o.d +2 -0
  524. data/quickjs/COMPILE_WIN +1 -0
  525. data/quickjs/Changelog +148 -0
  526. data/quickjs/LICENSE +22 -0
  527. data/quickjs/Makefile +470 -0
  528. data/quickjs/TODO +70 -0
  529. data/quickjs/VERSION +1 -0
  530. data/quickjs/a.c +50038 -0
  531. data/quickjs/a.js +26075 -0
  532. data/quickjs/a.rb +3 -0
  533. data/quickjs/cutils.c +631 -0
  534. data/quickjs/cutils.h +297 -0
  535. data/quickjs/doc/jsbignum.texi +589 -0
  536. data/quickjs/doc/quickjs.texi +1097 -0
  537. data/quickjs/examples/fib.c +72 -0
  538. data/quickjs/examples/fib_module.js +10 -0
  539. data/quickjs/examples/hello +0 -0
  540. data/quickjs/examples/hello.js +1 -0
  541. data/quickjs/examples/hello_module.js +6 -0
  542. data/quickjs/examples/pi_bigdecimal.js +68 -0
  543. data/quickjs/examples/pi_bigfloat.js +66 -0
  544. data/quickjs/examples/pi_bigint.js +118 -0
  545. data/quickjs/examples/point.c +151 -0
  546. data/quickjs/examples/test_fib.js +6 -0
  547. data/quickjs/examples/test_point.js +40 -0
  548. data/quickjs/hello.c +44 -0
  549. data/quickjs/libbf.c +8466 -0
  550. data/quickjs/libbf.h +535 -0
  551. data/quickjs/libquickjs.a +0 -0
  552. data/quickjs/libquickjs.lto.a +0 -0
  553. data/quickjs/libregexp-opcode.h +58 -0
  554. data/quickjs/libregexp.c +2610 -0
  555. data/quickjs/libregexp.h +92 -0
  556. data/quickjs/libunicode-table.h +4368 -0
  557. data/quickjs/libunicode.c +1556 -0
  558. data/quickjs/libunicode.h +124 -0
  559. data/quickjs/libwinpthread-1.dll +0 -0
  560. data/quickjs/list.h +100 -0
  561. data/quickjs/out.c +24 -0
  562. data/quickjs/out55.c +59 -0
  563. data/quickjs/out56.c +79 -0
  564. data/quickjs/out57.c +24 -0
  565. data/quickjs/out58.c +4 -0
  566. data/quickjs/p.exe +0 -0
  567. data/quickjs/qjs +0 -0
  568. data/quickjs/qjs.c +570 -0
  569. data/quickjs/qjsc +0 -0
  570. data/quickjs/qjsc.c +762 -0
  571. data/quickjs/qjsc.exe +0 -0
  572. data/quickjs/qjscalc.c +4005 -0
  573. data/quickjs/qjscalc.js +2657 -0
  574. data/quickjs/quickjs-atom.h +273 -0
  575. data/quickjs/quickjs-libc.c +3927 -0
  576. data/quickjs/quickjs-libc.h +59 -0
  577. data/quickjs/quickjs-opcode.h +365 -0
  578. data/quickjs/quickjs.c +54036 -0
  579. data/quickjs/quickjs.h +1049 -0
  580. data/quickjs/readme.txt +1 -0
  581. data/quickjs/release.sh +158 -0
  582. data/quickjs/repl.c +2020 -0
  583. data/quickjs/repl.js +1566 -0
  584. data/quickjs/run-test262 +0 -0
  585. data/quickjs/run-test262.c +2107 -0
  586. data/quickjs/test262.conf +199 -0
  587. data/quickjs/test262_errors.txt +35 -0
  588. data/quickjs/test262o.conf +410 -0
  589. data/quickjs/test262o_errors.txt +0 -0
  590. data/quickjs/tests/bjson.c +96 -0
  591. data/quickjs/tests/microbench.js +1065 -0
  592. data/quickjs/tests/test262.patch +71 -0
  593. data/quickjs/tests/test_bignum.js +326 -0
  594. data/quickjs/tests/test_bjson.js +191 -0
  595. data/quickjs/tests/test_builtin.js +685 -0
  596. data/quickjs/tests/test_closure.js +221 -0
  597. data/quickjs/tests/test_language.js +547 -0
  598. data/quickjs/tests/test_loop.js +368 -0
  599. data/quickjs/tests/test_op_overloading.js +207 -0
  600. data/quickjs/tests/test_qjscalc.js +256 -0
  601. data/quickjs/tests/test_std.js +281 -0
  602. data/quickjs/tests/test_worker.js +62 -0
  603. data/quickjs/tests/test_worker_module.js +31 -0
  604. data/quickjs/unicode_download.sh +19 -0
  605. data/quickjs/unicode_gen.c +3057 -0
  606. data/quickjs/unicode_gen_def.h +284 -0
  607. data/readline +3 -0
  608. data/rm_com +1 -0
  609. data/run.sh +13 -0
  610. data/scaling +6 -0
  611. data/script.js +572 -0
  612. data/server_creator/__ +307 -0
  613. data/server_creator/a/a (1).tar.gz +0 -0
  614. data/server_creator/a/a.out +0 -0
  615. data/server_creator/a/hello_world +0 -0
  616. data/server_creator/a/help +57 -0
  617. data/server_creator/a/main_v1.cpp +83 -0
  618. data/server_creator/a/my_libs_gregory/.deps +0 -0
  619. data/server_creator/a/my_libs_gregory/.libs/mod_my_libs_gregory.lai +41 -0
  620. data/server_creator/a/my_libs_gregory/.libs/mod_my_libs_gregory.o +0 -0
  621. data/server_creator/a/my_libs_gregory/.libs/mod_my_libs_gregory.so +0 -0
  622. data/server_creator/a/my_libs_gregory/mod_my_libs_gregory.c +72 -0
  623. data/server_creator/a/my_libs_gregory/mod_my_libs_gregory.la +41 -0
  624. data/server_creator/a/my_libs_gregory/mod_my_libs_gregory.lo +12 -0
  625. data/server_creator/a/my_libs_gregory/mod_my_libs_gregory.slo +0 -0
  626. data/server_creator/a/nginx.conf +32 -0
  627. data/server_creator/a/six +1 -0
  628. data/server_creator/a.out +0 -0
  629. data/server_creator/all_code.cpp +448 -0
  630. data/server_creator/all_code.js +27 -0
  631. data/server_creator/code +510 -0
  632. data/server_creator/make_application +64 -0
  633. data/server_creator/prog.cpp +33 -0
  634. data/server_creator/prog.js +22 -0
  635. data/server_creator/program.js +745 -0
  636. data/server_creator/rm_com +1 -0
  637. data/server_creator/test.sh +82 -0
  638. data/speakcat.rb +9 -0
  639. data/string +48 -0
  640. data/super_trans +83 -0
  641. data/test.sh +21 -0
  642. data/todo +8 -0
  643. data/version_decrement +3 -0
  644. data/viu_license +21 -0
  645. data/windows/program.c +21 -0
  646. data/windows/program.exe +0 -0
  647. metadata +759 -0
@@ -0,0 +1,1097 @@
1
+ \input texinfo
2
+
3
+ @iftex
4
+ @afourpaper
5
+ @headings double
6
+ @end iftex
7
+
8
+ @titlepage
9
+ @afourpaper
10
+ @sp 7
11
+ @center @titlefont{QuickJS Javascript Engine}
12
+ @sp 3
13
+ @end titlepage
14
+
15
+ @setfilename spec.info
16
+ @settitle QuickJS Javascript Engine
17
+
18
+ @contents
19
+
20
+ @chapter Introduction
21
+
22
+ QuickJS is a small and embeddable Javascript engine. It supports the
23
+ ES2020 specification
24
+ @footnote{@url{https://tc39.es/ecma262/}}
25
+ including modules, asynchronous generators, proxies and BigInt.
26
+
27
+ It supports mathematical extensions such as big decimal float float
28
+ numbers (BigDecimal), big binary floating point numbers (BigFloat),
29
+ and operator overloading.
30
+
31
+ @section Main Features
32
+
33
+ @itemize
34
+
35
+ @item Small and easily embeddable: just a few C files, no external dependency, 210 KiB of x86 code for a simple ``hello world'' program.
36
+
37
+ @item Fast interpreter with very low startup time: runs the 69000 tests of the ECMAScript Test Suite@footnote{@url{https://github.com/tc39/test262}} in about 95 seconds on a single core of a desktop PC. The complete life cycle of a runtime instance completes in less than 300 microseconds.
38
+
39
+ @item Almost complete ES2020 support including modules, asynchronous
40
+ generators and full Annex B support (legacy web compatibility). Many
41
+ features from the upcoming ES2021 specification
42
+ @footnote{@url{https://tc39.github.io/ecma262/}} are also supported.
43
+
44
+ @item Passes nearly 100% of the ECMAScript Test Suite tests when selecting the ES2020 features.
45
+
46
+ @item Compile Javascript sources to executables with no external dependency.
47
+
48
+ @item Garbage collection using reference counting (to reduce memory usage and have deterministic behavior) with cycle removal.
49
+
50
+ @item Mathematical extensions: BigDecimal, BigFloat, operator overloading, bigint mode, math mode.
51
+
52
+ @item Command line interpreter with contextual colorization and completion implemented in Javascript.
53
+
54
+ @item Small built-in standard library with C library wrappers.
55
+
56
+ @end itemize
57
+
58
+ @chapter Usage
59
+
60
+ @section Installation
61
+
62
+ A Makefile is provided to compile the engine on Linux or MacOS/X. A
63
+ preliminary Windows support is available thru cross compilation on a
64
+ Linux host with the MingGW tools.
65
+
66
+ Edit the top of the @code{Makefile} if you wish to select specific
67
+ options then run @code{make}.
68
+
69
+ You can type @code{make install} as root if you wish to install the binaries and support files to
70
+ @code{/usr/local} (this is not necessary to use QuickJS).
71
+
72
+ @section Quick start
73
+
74
+ @code{qjs} is the command line interpreter (Read-Eval-Print Loop). You can pass
75
+ Javascript files and/or expressions as arguments to execute them:
76
+
77
+ @example
78
+ ./qjs examples/hello.js
79
+ @end example
80
+
81
+ @code{qjsc} is the command line compiler:
82
+
83
+ @example
84
+ ./qjsc -o hello examples/hello.js
85
+ ./hello
86
+ @end example
87
+
88
+ generates a @code{hello} executable with no external dependency.
89
+
90
+ @section Command line options
91
+
92
+ @subsection @code{qjs} interpreter
93
+
94
+ @verbatim
95
+ usage: qjs [options] [file [args]]
96
+ @end verbatim
97
+
98
+ Options are:
99
+ @table @code
100
+ @item -h
101
+ @item --help
102
+ List options.
103
+
104
+ @item -e @code{EXPR}
105
+ @item --eval @code{EXPR}
106
+ Evaluate EXPR.
107
+
108
+ @item -i
109
+ @item --interactive
110
+ Go to interactive mode (it is not the default when files are provided on the command line).
111
+
112
+ @item -m
113
+ @item --module
114
+ Load as ES6 module (default=autodetect). A module is autodetected if
115
+ the filename extension is @code{.mjs} or if the first keyword of the
116
+ source is @code{import}.
117
+
118
+ @item --script
119
+ Load as ES6 script (default=autodetect).
120
+
121
+ @item --bignum
122
+ Enable the bignum extensions: BigDecimal object, BigFloat object and
123
+ the @code{"use math"} directive.
124
+
125
+ @item -I file
126
+ @item --include file
127
+ Include an additional file.
128
+
129
+ @end table
130
+
131
+ Advanced options are:
132
+
133
+ @table @code
134
+ @item --std
135
+ Make the @code{std} and @code{os} modules available to the loaded
136
+ script even if it is not a module.
137
+
138
+ @item -d
139
+ @item --dump
140
+ Dump the memory usage stats.
141
+
142
+ @item -q
143
+ @item --quit
144
+ just instantiate the interpreter and quit.
145
+
146
+ @end table
147
+
148
+ @subsection @code{qjsc} compiler
149
+
150
+ @verbatim
151
+ usage: qjsc [options] [files]
152
+ @end verbatim
153
+
154
+ Options are:
155
+ @table @code
156
+ @item -c
157
+ Only output bytecode in a C file. The default is to output an executable file.
158
+ @item -e
159
+ Output @code{main()} and bytecode in a C file. The default is to output an
160
+ executable file.
161
+ @item -o output
162
+ Set the output filename (default = @file{out.c} or @file{a.out}).
163
+
164
+ @item -N cname
165
+ Set the C name of the generated data.
166
+
167
+ @item -m
168
+ Compile as Javascript module (default=autodetect).
169
+
170
+ @item -D module_name
171
+ Compile a dynamically loaded module and its dependencies. This option
172
+ is needed when your code uses the @code{import} keyword or the
173
+ @code{os.Worker} constructor because the compiler cannot statically
174
+ find the name of the dynamically loaded modules.
175
+
176
+ @item -M module_name[,cname]
177
+ Add initialization code for an external C module. See the
178
+ @code{c_module} example.
179
+
180
+ @item -x
181
+ Byte swapped output (only used for cross compilation).
182
+
183
+ @item -flto
184
+ Use link time optimization. The compilation is slower but the
185
+ executable is smaller and faster. This option is automatically set
186
+ when the @code{-fno-x} options are used.
187
+
188
+ @item -fno-[eval|string-normalize|regexp|json|proxy|map|typedarray|promise|bigint]
189
+ Disable selected language features to produce a smaller executable file.
190
+
191
+ @item -fbignum
192
+ Enable the bignum extensions: BigDecimal object, BigFloat object and
193
+ the @code{"use math"} directive.
194
+
195
+ @end table
196
+
197
+ @section @code{qjscalc} application
198
+
199
+ The @code{qjscalc} application is a superset of the @code{qjs}
200
+ command line interpreter implementing a Javascript calculator with
201
+ arbitrarily large integer and floating point numbers, fractions,
202
+ complex numbers, polynomials and matrices. The source code is in
203
+ @file{qjscalc.js}. More documentation and a web version are available at
204
+ @url{http://numcalc.com}.
205
+
206
+ @section Built-in tests
207
+
208
+ Run @code{make test} to run the few built-in tests included in the
209
+ QuickJS archive.
210
+
211
+ @section Test262 (ECMAScript Test Suite)
212
+
213
+ A test262 runner is included in the QuickJS archive. The test262 tests
214
+ can be installed in the QuickJS source directory with:
215
+
216
+ @example
217
+ git clone https://github.com/tc39/test262.git test262
218
+ cd test262
219
+ patch -p1 < ../tests/test262.patch
220
+ cd ..
221
+ @end example
222
+
223
+ The patch adds the implementation specific @code{harness} functions
224
+ and optimizes the inefficient RegExp character classes and Unicode
225
+ property escapes tests (the tests themselves are not modified, only a
226
+ slow string initialization function is optimized).
227
+
228
+ The tests can be run with
229
+ @example
230
+ make test2
231
+ @end example
232
+
233
+ The configuration files @code{test262.conf}
234
+ (resp. @code{test262o.conf} for the old ES5.1 tests@footnote{The old
235
+ ES5.1 tests can be extracted with @code{git clone --single-branch
236
+ --branch es5-tests https://github.com/tc39/test262.git test262o}}))
237
+ contain the options to run the various tests. Tests can be excluded
238
+ based on features or filename.
239
+
240
+ The file @code{test262_errors.txt} contains the current list of
241
+ errors. The runner displays a message when a new error appears or when
242
+ an existing error is corrected or modified. Use the @code{-u} option
243
+ to update the current list of errors (or @code{make test2-update}).
244
+
245
+ The file @code{test262_report.txt} contains the logs of all the
246
+ tests. It is useful to have a clearer analysis of a particular
247
+ error. In case of crash, the last line corresponds to the failing
248
+ test.
249
+
250
+ Use the syntax @code{./run-test262 -c test262.conf -f filename.js} to
251
+ run a single test. Use the syntax @code{./run-test262 -c test262.conf
252
+ N} to start testing at test number @code{N}.
253
+
254
+ For more information, run @code{./run-test262} to see the command line
255
+ options of the test262 runner.
256
+
257
+ @code{run-test262} accepts the @code{-N} option to be invoked from
258
+ @code{test262-harness}@footnote{@url{https://github.com/bterlson/test262-harness}}
259
+ thru @code{eshost}. Unless you want to compare QuickJS with other
260
+ engines under the same conditions, we do not recommend to run the
261
+ tests this way as it is much slower (typically half an hour instead of
262
+ about 100 seconds).
263
+
264
+ @chapter Specifications
265
+
266
+ @section Language support
267
+
268
+ @subsection ES2020 support
269
+
270
+ The ES2020 specification is almost fully supported including the Annex
271
+ B (legacy web compatibility) and the Unicode related features.
272
+
273
+ The following features are not supported yet:
274
+
275
+ @itemize
276
+
277
+ @item Tail calls@footnote{We believe the current specification of tails calls is too complicated and presents limited practical interests.}
278
+
279
+ @end itemize
280
+
281
+ @subsection ECMA402
282
+
283
+ ECMA402 (Internationalization API) is not supported.
284
+
285
+ @subsection Extensions
286
+
287
+ @itemize
288
+
289
+ @item The directive @code{"use strip"} indicates that the debug information (including the source code of the functions) should not be retained to save memory. As @code{"use strict"}, the directive can be global to a script or local to a function.
290
+
291
+ @item The first line of a script beginning with @code{#!} is ignored.
292
+
293
+ @end itemize
294
+
295
+ @subsection Mathematical extensions
296
+
297
+ The mathematical extensions are fully backward compatible with
298
+ standard Javascript. See @code{jsbignum.pdf} for more information.
299
+
300
+ @itemize
301
+
302
+ @item @code{BigDecimal} support: arbitrary large floating point numbers in base 10.
303
+
304
+ @item @code{BigFloat} support: arbitrary large floating point numbers in base 2.
305
+
306
+ @item Operator overloading.
307
+
308
+ @item The directive @code{"use bigint"} enables the bigint mode where integers are @code{BigInt} by default.
309
+
310
+ @item The directive @code{"use math"} enables the math mode where the division and power operators on integers produce fractions. Floating point literals are @code{BigFloat} by default and integers are @code{BigInt} by default.
311
+
312
+ @end itemize
313
+
314
+ @section Modules
315
+
316
+ ES6 modules are fully supported. The default name resolution is the
317
+ following:
318
+
319
+ @itemize
320
+
321
+ @item Module names with a leading @code{.} or @code{..} are relative
322
+ to the current module path.
323
+
324
+ @item Module names without a leading @code{.} or @code{..} are system
325
+ modules, such as @code{std} or @code{os}.
326
+
327
+ @item Module names ending with @code{.so} are native modules using the
328
+ QuickJS C API.
329
+
330
+ @end itemize
331
+
332
+ @section Standard library
333
+
334
+ The standard library is included by default in the command line
335
+ interpreter. It contains the two modules @code{std} and @code{os} and
336
+ a few global objects.
337
+
338
+ @subsection Global objects
339
+
340
+ @table @code
341
+ @item scriptArgs
342
+ Provides the command line arguments. The first argument is the script name.
343
+ @item print(...args)
344
+ Print the arguments separated by spaces and a trailing newline.
345
+ @item console.log(...args)
346
+ Same as print().
347
+
348
+ @end table
349
+
350
+ @subsection @code{std} module
351
+
352
+ The @code{std} module provides wrappers to the libc @file{stdlib.h}
353
+ and @file{stdio.h} and a few other utilities.
354
+
355
+ Available exports:
356
+
357
+ @table @code
358
+
359
+ @item exit(n)
360
+ Exit the process.
361
+
362
+ @item evalScript(str, options = undefined)
363
+ Evaluate the string @code{str} as a script (global
364
+ eval). @code{options} is an optional object containing the following
365
+ optional properties:
366
+
367
+ @table @code
368
+ @item backtrace_barrier
369
+ Boolean (default = false). If true, error backtraces do not list the
370
+ stack frames below the evalScript.
371
+ @end table
372
+
373
+ @item loadScript(filename)
374
+ Evaluate the file @code{filename} as a script (global eval).
375
+
376
+ @item loadFile(filename)
377
+ Load the file @code{filename} and return it as a string assuming UTF-8
378
+ encoding. Return @code{null} in case of I/O error.
379
+
380
+ @item open(filename, flags, errorObj = undefined)
381
+ Open a file (wrapper to the libc @code{fopen()}). Return the FILE
382
+ object or @code{null} in case of I/O error. If @code{errorObj} is not
383
+ undefined, set its @code{errno} property to the error code or to 0 if
384
+ no error occured.
385
+
386
+ @item popen(command, flags, errorObj = undefined)
387
+ Open a process by creating a pipe (wrapper to the libc
388
+ @code{popen()}). Return the FILE
389
+ object or @code{null} in case of I/O error. If @code{errorObj} is not
390
+ undefined, set its @code{errno} property to the error code or to 0 if
391
+ no error occured.
392
+
393
+ @item fdopen(fd, flags, errorObj = undefined)
394
+ Open a file from a file handle (wrapper to the libc
395
+ @code{fdopen()}). Return the FILE
396
+ object or @code{null} in case of I/O error. If @code{errorObj} is not
397
+ undefined, set its @code{errno} property to the error code or to 0 if
398
+ no error occured.
399
+
400
+ @item tmpfile(errorObj = undefined)
401
+ Open a temporary file. Return the FILE
402
+ object or @code{null} in case of I/O error. If @code{errorObj} is not
403
+ undefined, set its @code{errno} property to the error code or to 0 if
404
+ no error occured.
405
+
406
+ @item puts(str)
407
+ Equivalent to @code{std.out.puts(str)}.
408
+
409
+ @item printf(fmt, ...args)
410
+ Equivalent to @code{std.out.printf(fmt, ...args)}.
411
+
412
+ @item sprintf(fmt, ...args)
413
+ Equivalent to the libc sprintf().
414
+
415
+ @item in
416
+ @item out
417
+ @item err
418
+ Wrappers to the libc file @code{stdin}, @code{stdout}, @code{stderr}.
419
+
420
+ @item SEEK_SET
421
+ @item SEEK_CUR
422
+ @item SEEK_END
423
+ Constants for seek().
424
+
425
+ @item Error
426
+
427
+ Enumeration object containing the integer value of common errors
428
+ (additional error codes may be defined):
429
+
430
+ @table @code
431
+ @item EINVAL
432
+ @item EIO
433
+ @item EACCES
434
+ @item EEXIST
435
+ @item ENOSPC
436
+ @item ENOSYS
437
+ @item EBUSY
438
+ @item ENOENT
439
+ @item EPERM
440
+ @item EPIPE
441
+ @end table
442
+
443
+ @item strerror(errno)
444
+ Return a string that describes the error @code{errno}.
445
+
446
+ @item gc()
447
+ Manually invoke the cycle removal algorithm. The cycle removal
448
+ algorithm is automatically started when needed, so this function is
449
+ useful in case of specific memory constraints or for testing.
450
+
451
+ @item getenv(name)
452
+ Return the value of the environment variable @code{name} or
453
+ @code{undefined} if it is not defined.
454
+
455
+ @item setenv(name, value)
456
+ Set the value of the environment variable @code{name} to the string
457
+ @code{value}.
458
+
459
+ @item unsetenv(name)
460
+ Delete the environment variable @code{name}.
461
+
462
+ @item getenviron()
463
+ Return an object containing the environment variables as key-value pairs.
464
+
465
+ @item urlGet(url, options = undefined)
466
+
467
+ Download @code{url} using the @file{curl} command line
468
+ utility. @code{options} is an optional object containing the following
469
+ optional properties:
470
+
471
+ @table @code
472
+ @item binary
473
+ Boolean (default = false). If true, the response is an ArrayBuffer
474
+ instead of a string. When a string is returned, the data is assumed
475
+ to be UTF-8 encoded.
476
+
477
+ @item full
478
+
479
+ Boolean (default = false). If true, return the an object contains
480
+ the properties @code{response} (response content),
481
+ @code{responseHeaders} (headers separated by CRLF), @code{status}
482
+ (status code). @code{response} is @code{null} is case of protocol or
483
+ network error. If @code{full} is false, only the response is
484
+ returned if the status is between 200 and 299. Otherwise @code{null}
485
+ is returned.
486
+
487
+ @end table
488
+
489
+ @item parseExtJSON(str)
490
+
491
+ Parse @code{str} using a superset of @code{JSON.parse}. The
492
+ following extensions are accepted:
493
+
494
+ @itemize
495
+ @item Single line and multiline comments
496
+ @item unquoted properties (ASCII-only Javascript identifiers)
497
+ @item trailing comma in array and object definitions
498
+ @item single quoted strings
499
+ @item @code{\f} and @code{\v} are accepted as space characters
500
+ @item leading plus in numbers
501
+ @item octal (@code{0o} prefix) and hexadecimal (@code{0x} prefix) numbers
502
+ @end itemize
503
+ @end table
504
+
505
+ FILE prototype:
506
+
507
+ @table @code
508
+ @item close()
509
+ Close the file. Return 0 if OK or @code{-errno} in case of I/O error.
510
+ @item puts(str)
511
+ Outputs the string with the UTF-8 encoding.
512
+ @item printf(fmt, ...args)
513
+ Formatted printf.
514
+
515
+ The same formats as the standard C library @code{printf} are
516
+ supported. Integer format types (e.g. @code{%d}) truncate the Numbers
517
+ or BigInts to 32 bits. Use the @code{l} modifier (e.g. @code{%ld}) to
518
+ truncate to 64 bits.
519
+
520
+ @item flush()
521
+ Flush the buffered file.
522
+ @item seek(offset, whence)
523
+ Seek to a give file position (whence is
524
+ @code{std.SEEK_*}). @code{offset} can be a number or a bigint. Return
525
+ 0 if OK or @code{-errno} in case of I/O error.
526
+ @item tell()
527
+ Return the current file position.
528
+ @item tello()
529
+ Return the current file position as a bigint.
530
+ @item eof()
531
+ Return true if end of file.
532
+ @item fileno()
533
+ Return the associated OS handle.
534
+ @item error()
535
+ Return true if there was an error.
536
+ @item clearerr()
537
+ Clear the error indication.
538
+
539
+ @item read(buffer, position, length)
540
+ Read @code{length} bytes from the file to the ArrayBuffer @code{buffer} at byte
541
+ position @code{position} (wrapper to the libc @code{fread}).
542
+
543
+ @item write(buffer, position, length)
544
+ Write @code{length} bytes to the file from the ArrayBuffer @code{buffer} at byte
545
+ position @code{position} (wrapper to the libc @code{fwrite}).
546
+
547
+ @item getline()
548
+ Return the next line from the file, assuming UTF-8 encoding, excluding
549
+ the trailing line feed.
550
+
551
+ @item readAsString(max_size = undefined)
552
+ Read @code{max_size} bytes from the file and return them as a string
553
+ assuming UTF-8 encoding. If @code{max_size} is not present, the file
554
+ is read up its end.
555
+
556
+ @item getByte()
557
+ Return the next byte from the file. Return -1 if the end of file is reached.
558
+
559
+ @item putByte(c)
560
+ Write one byte to the file.
561
+ @end table
562
+
563
+ @subsection @code{os} module
564
+
565
+ The @code{os} module provides Operating System specific functions:
566
+
567
+ @itemize
568
+ @item low level file access
569
+ @item signals
570
+ @item timers
571
+ @item asynchronous I/O
572
+ @item workers (threads)
573
+ @end itemize
574
+
575
+ The OS functions usually return 0 if OK or an OS specific negative
576
+ error code.
577
+
578
+ Available exports:
579
+
580
+ @table @code
581
+ @item open(filename, flags, mode = 0o666)
582
+ Open a file. Return a handle or < 0 if error.
583
+
584
+ @item O_RDONLY
585
+ @item O_WRONLY
586
+ @item O_RDWR
587
+ @item O_APPEND
588
+ @item O_CREAT
589
+ @item O_EXCL
590
+ @item O_TRUNC
591
+ POSIX open flags.
592
+
593
+ @item O_TEXT
594
+ (Windows specific). Open the file in text mode. The default is binary mode.
595
+
596
+ @item close(fd)
597
+ Close the file handle @code{fd}.
598
+
599
+ @item seek(fd, offset, whence)
600
+ Seek in the file. Use @code{std.SEEK_*} for
601
+ @code{whence}. @code{offset} is either a number or a bigint. If
602
+ @code{offset} is a bigint, a bigint is returned too.
603
+
604
+ @item read(fd, buffer, offset, length)
605
+ Read @code{length} bytes from the file handle @code{fd} to the
606
+ ArrayBuffer @code{buffer} at byte position @code{offset}.
607
+ Return the number of read bytes or < 0 if error.
608
+
609
+ @item write(fd, buffer, offset, length)
610
+ Write @code{length} bytes to the file handle @code{fd} from the
611
+ ArrayBuffer @code{buffer} at byte position @code{offset}.
612
+ Return the number of written bytes or < 0 if error.
613
+
614
+ @item isatty(fd)
615
+ Return @code{true} is @code{fd} is a TTY (terminal) handle.
616
+
617
+ @item ttyGetWinSize(fd)
618
+ Return the TTY size as @code{[width, height]} or @code{null} if not available.
619
+
620
+ @item ttySetRaw(fd)
621
+ Set the TTY in raw mode.
622
+
623
+ @item remove(filename)
624
+ Remove a file. Return 0 if OK or @code{-errno}.
625
+
626
+ @item rename(oldname, newname)
627
+ Rename a file. Return 0 if OK or @code{-errno}.
628
+
629
+ @item realpath(path)
630
+ Return @code{[str, err]} where @code{str} is the canonicalized absolute
631
+ pathname of @code{path} and @code{err} the error code.
632
+
633
+ @item getcwd()
634
+ Return @code{[str, err]} where @code{str} is the current working directory
635
+ and @code{err} the error code.
636
+
637
+ @item chdir(path)
638
+ Change the current directory. Return 0 if OK or @code{-errno}.
639
+
640
+ @item mkdir(path, mode = 0o777)
641
+ Create a directory at @code{path}. Return 0 if OK or @code{-errno}.
642
+
643
+ @item stat(path)
644
+ @item lstat(path)
645
+
646
+ Return @code{[obj, err]} where @code{obj} is an object containing the
647
+ file status of @code{path}. @code{err} is the error code. The
648
+ following fields are defined in @code{obj}: dev, ino, mode, nlink,
649
+ uid, gid, rdev, size, blocks, atime, mtime, ctime. The times are
650
+ specified in milliseconds since 1970. @code{lstat()} is the same as
651
+ @code{stat()} excepts that it returns information about the link
652
+ itself.
653
+
654
+ @item S_IFMT
655
+ @item S_IFIFO
656
+ @item S_IFCHR
657
+ @item S_IFDIR
658
+ @item S_IFBLK
659
+ @item S_IFREG
660
+ @item S_IFSOCK
661
+ @item S_IFLNK
662
+ @item S_ISGID
663
+ @item S_ISUID
664
+ Constants to interpret the @code{mode} property returned by
665
+ @code{stat()}. They have the same value as in the C system header
666
+ @file{sys/stat.h}.
667
+
668
+ @item utimes(path, atime, mtime)
669
+ Change the access and modification times of the file @code{path}. The
670
+ times are specified in milliseconds since 1970. Return 0 if OK or @code{-errno}.
671
+
672
+ @item symlink(target, linkpath)
673
+ Create a link at @code{linkpath} containing the string @code{target}. Return 0 if OK or @code{-errno}.
674
+
675
+ @item readlink(path)
676
+ Return @code{[str, err]} where @code{str} is the link target and @code{err}
677
+ the error code.
678
+
679
+ @item readdir(path)
680
+ Return @code{[array, err]} where @code{array} is an array of strings
681
+ containing the filenames of the directory @code{path}. @code{err} is
682
+ the error code.
683
+
684
+ @item setReadHandler(fd, func)
685
+ Add a read handler to the file handle @code{fd}. @code{func} is called
686
+ each time there is data pending for @code{fd}. A single read handler
687
+ per file handle is supported. Use @code{func = null} to remove the
688
+ handler.
689
+
690
+ @item setWriteHandler(fd, func)
691
+ Add a write handler to the file handle @code{fd}. @code{func} is
692
+ called each time data can be written to @code{fd}. A single write
693
+ handler per file handle is supported. Use @code{func = null} to remove
694
+ the handler.
695
+
696
+ @item signal(signal, func)
697
+ Call the function @code{func} when the signal @code{signal}
698
+ happens. Only a single handler per signal number is supported. Use
699
+ @code{null} to set the default handler or @code{undefined} to ignore
700
+ the signal. Signal handlers can only be defined in the main thread.
701
+
702
+ @item SIGINT
703
+ @item SIGABRT
704
+ @item SIGFPE
705
+ @item SIGILL
706
+ @item SIGSEGV
707
+ @item SIGTERM
708
+ POSIX signal numbers.
709
+
710
+ @item kill(pid, sig)
711
+ Send the signal @code{sig} to the process @code{pid}.
712
+
713
+ @item exec(args[, options])
714
+ Execute a process with the arguments @code{args}. @code{options} is an
715
+ object containing optional parameters:
716
+
717
+ @table @code
718
+ @item block
719
+ Boolean (default = true). If true, wait until the process is
720
+ terminated. In this case, @code{exec} return the exit code if positive
721
+ or the negated signal number if the process was interrupted by a
722
+ signal. If false, do not block and return the process id of the child.
723
+
724
+ @item usePath
725
+ Boolean (default = true). If true, the file is searched in the
726
+ @code{PATH} environment variable.
727
+
728
+ @item file
729
+ String (default = @code{args[0]}). Set the file to be executed.
730
+
731
+ @item cwd
732
+ String. If present, set the working directory of the new process.
733
+
734
+ @item stdin
735
+ @item stdout
736
+ @item stderr
737
+ If present, set the handle in the child for stdin, stdout or stderr.
738
+
739
+ @item env
740
+ Object. If present, set the process environment from the object
741
+ key-value pairs. Otherwise use the same environment as the current
742
+ process.
743
+
744
+ @item uid
745
+ Integer. If present, the process uid with @code{setuid}.
746
+
747
+ @item gid
748
+ Integer. If present, the process gid with @code{setgid}.
749
+
750
+ @end table
751
+
752
+ @item waitpid(pid, options)
753
+ @code{waitpid} Unix system call. Return the array @code{[ret,
754
+ status]}. @code{ret} contains @code{-errno} in case of error.
755
+
756
+ @item WNOHANG
757
+ Constant for the @code{options} argument of @code{waitpid}.
758
+
759
+ @item dup(fd)
760
+ @code{dup} Unix system call.
761
+
762
+ @item dup2(oldfd, newfd)
763
+ @code{dup2} Unix system call.
764
+
765
+ @item pipe()
766
+ @code{pipe} Unix system call. Return two handles as @code{[read_fd,
767
+ write_fd]} or null in case of error.
768
+
769
+ @item sleep(delay_ms)
770
+ Sleep during @code{delay_ms} milliseconds.
771
+
772
+ @item setTimeout(func, delay)
773
+ Call the function @code{func} after @code{delay} ms. Return a handle
774
+ to the timer.
775
+
776
+ @item clearTimeout(handle)
777
+ Cancel a timer.
778
+
779
+ @item platform
780
+ Return a string representing the platform: @code{"linux"}, @code{"darwin"},
781
+ @code{"win32"} or @code{"js"}.
782
+
783
+ @item Worker(module_filename)
784
+ Constructor to create a new thread (worker) with an API close to the
785
+ @code{WebWorkers}. @code{module_filename} is a string specifying the
786
+ module filename which is executed in the newly created thread. As for
787
+ dynamically imported module, it is relative to the current script or
788
+ module path. Threads normally don't share any data and communicate
789
+ between each other with messages. Nested workers are not supported. An
790
+ example is available in @file{tests/test_worker.js}.
791
+
792
+ The worker class has the following static properties:
793
+
794
+ @table @code
795
+ @item parent
796
+ In the created worker, @code{Worker.parent} represents the parent
797
+ worker and is used to send or receive messages.
798
+ @end table
799
+
800
+ The worker instances have the following properties:
801
+
802
+ @table @code
803
+ @item postMessage(msg)
804
+
805
+ Send a message to the corresponding worker. @code{msg} is cloned in
806
+ the destination worker using an algorithm similar to the @code{HTML}
807
+ structured clone algorithm. @code{SharedArrayBuffer} are shared
808
+ between workers.
809
+
810
+ Current limitations: @code{Map} and @code{Set} are not supported
811
+ yet.
812
+
813
+ @item onmessage
814
+
815
+ Getter and setter. Set a function which is called each time a
816
+ message is received. The function is called with a single
817
+ argument. It is an object with a @code{data} property containing the
818
+ received message. The thread is not terminated if there is at least
819
+ one non @code{null} @code{onmessage} handler.
820
+
821
+ @end table
822
+
823
+ @end table
824
+
825
+ @section QuickJS C API
826
+
827
+ The C API was designed to be simple and efficient. The C API is
828
+ defined in the header @code{quickjs.h}.
829
+
830
+ @subsection Runtime and contexts
831
+
832
+ @code{JSRuntime} represents a Javascript runtime corresponding to an
833
+ object heap. Several runtimes can exist at the same time but they
834
+ cannot exchange objects. Inside a given runtime, no multi-threading is
835
+ supported.
836
+
837
+ @code{JSContext} represents a Javascript context (or Realm). Each
838
+ JSContext has its own global objects and system objects. There can be
839
+ several JSContexts per JSRuntime and they can share objects, similar
840
+ to frames of the same origin sharing Javascript objects in a
841
+ web browser.
842
+
843
+ @subsection JSValue
844
+
845
+ @code{JSValue} represents a Javascript value which can be a primitive
846
+ type or an object. Reference counting is used, so it is important to
847
+ explicitly duplicate (@code{JS_DupValue()}, increment the reference
848
+ count) or free (@code{JS_FreeValue()}, decrement the reference count)
849
+ JSValues.
850
+
851
+ @subsection C functions
852
+
853
+ C functions can be created with
854
+ @code{JS_NewCFunction()}. @code{JS_SetPropertyFunctionList()} is a
855
+ shortcut to easily add functions, setters and getters properties to a
856
+ given object.
857
+
858
+ Unlike other embedded Javascript engines, there is no implicit stack,
859
+ so C functions get their parameters as normal C parameters. As a
860
+ general rule, C functions take constant @code{JSValue}s as parameters
861
+ (so they don't need to free them) and return a newly allocated (=live)
862
+ @code{JSValue}.
863
+
864
+ @subsection Exceptions
865
+
866
+ Exceptions: most C functions can return a Javascript exception. It
867
+ must be explicitly tested and handled by the C code. The specific
868
+ @code{JSValue} @code{JS_EXCEPTION} indicates that an exception
869
+ occurred. The actual exception object is stored in the
870
+ @code{JSContext} and can be retrieved with @code{JS_GetException()}.
871
+
872
+ @subsection Script evaluation
873
+
874
+ Use @code{JS_Eval()} to evaluate a script or module source.
875
+
876
+ If the script or module was compiled to bytecode with @code{qjsc}, it
877
+ can be evaluated by calling @code{js_std_eval_binary()}. The advantage
878
+ is that no compilation is needed so it is faster and smaller because
879
+ the compiler can be removed from the executable if no @code{eval} is
880
+ required.
881
+
882
+ Note: the bytecode format is linked to a given QuickJS
883
+ version. Moreover, no security check is done before its
884
+ execution. Hence the bytecode should not be loaded from untrusted
885
+ sources. That's why there is no option to output the bytecode to a
886
+ binary file in @code{qjsc}.
887
+
888
+ @subsection JS Classes
889
+
890
+ C opaque data can be attached to a Javascript object. The type of the
891
+ C opaque data is determined with the class ID (@code{JSClassID}) of
892
+ the object. Hence the first step is to register a new class ID and JS
893
+ class (@code{JS_NewClassID()}, @code{JS_NewClass()}). Then you can
894
+ create objects of this class with @code{JS_NewObjectClass()} and get or
895
+ set the C opaque point with
896
+ @code{JS_GetOpaque()}/@code{JS_SetOpaque()}.
897
+
898
+ When defining a new JS class, it is possible to declare a finalizer
899
+ which is called when the object is destroyed. The finalizer should be
900
+ used to release C resources. It is invalid to execute JS code from
901
+ it. A @code{gc_mark} method can be provided so that the cycle removal
902
+ algorithm can find the other objects referenced by this object. Other
903
+ methods are available to define exotic object behaviors.
904
+
905
+ The Class ID are globally allocated (i.e. for all runtimes). The
906
+ JSClass are allocated per @code{JSRuntime}. @code{JS_SetClassProto()}
907
+ is used to define a prototype for a given class in a given
908
+ JSContext. @code{JS_NewObjectClass()} sets this prototype in the
909
+ created object.
910
+
911
+ Examples are available in @file{quickjs-libc.c}.
912
+
913
+ @subsection C Modules
914
+
915
+ Native ES6 modules are supported and can be dynamically or statically
916
+ linked. Look at the @file{test_bjson} and @file{bjson.so}
917
+ examples. The standard library @file{quickjs-libc.c} is also a good example
918
+ of a native module.
919
+
920
+ @subsection Memory handling
921
+
922
+ Use @code{JS_SetMemoryLimit()} to set a global memory allocation limit
923
+ to a given JSRuntime.
924
+
925
+ Custom memory allocation functions can be provided with
926
+ @code{JS_NewRuntime2()}.
927
+
928
+ The maximum system stack size can be set with @code{JS_SetMaxStackSize()}.
929
+
930
+ @subsection Execution timeout and interrupts
931
+
932
+ Use @code{JS_SetInterruptHandler()} to set a callback which is
933
+ regularly called by the engine when it is executing code. This
934
+ callback can be used to implement an execution timeout.
935
+
936
+ It is used by the command line interpreter to implement a
937
+ @code{Ctrl-C} handler.
938
+
939
+ @chapter Internals
940
+
941
+ @section Bytecode
942
+
943
+ The compiler generates bytecode directly with no intermediate
944
+ representation such as a parse tree, hence it is very fast. Several
945
+ optimizations passes are done over the generated bytecode.
946
+
947
+ A stack-based bytecode was chosen because it is simple and generates
948
+ compact code.
949
+
950
+ For each function, the maximum stack size is computed at compile time so that
951
+ no runtime stack overflow tests are needed.
952
+
953
+ A separate compressed line number table is maintained for the debug
954
+ information.
955
+
956
+ Access to closure variables is optimized and is almost as fast as local
957
+ variables.
958
+
959
+ Direct @code{eval} in strict mode is optimized.
960
+
961
+ @section Executable generation
962
+
963
+ @subsection @code{qjsc} compiler
964
+
965
+ The @code{qjsc} compiler generates C sources from Javascript files. By
966
+ default the C sources are compiled with the system compiler
967
+ (@code{gcc} or @code{clang}).
968
+
969
+ The generated C source contains the bytecode of the compiled functions
970
+ or modules. If a full complete executable is needed, it also
971
+ contains a @code{main()} function with the necessary C code to initialize the
972
+ Javascript engine and to load and execute the compiled functions and
973
+ modules.
974
+
975
+ Javascript code can be mixed with C modules.
976
+
977
+ In order to have smaller executables, specific Javascript features can
978
+ be disabled, in particular @code{eval} or the regular expressions. The
979
+ code removal relies on the Link Time Optimization of the system
980
+ compiler.
981
+
982
+ @subsection Binary JSON
983
+
984
+ @code{qjsc} works by compiling scripts or modules and then serializing
985
+ them to a binary format. A subset of this format (without functions or
986
+ modules) can be used as binary JSON. The example @file{test_bjson.js}
987
+ shows how to use it.
988
+
989
+ Warning: the binary JSON format may change without notice, so it
990
+ should not be used to store persistent data. The @file{test_bjson.js}
991
+ example is only used to test the binary object format functions.
992
+
993
+ @section Runtime
994
+
995
+ @subsection Strings
996
+
997
+ Strings are stored either as an 8 bit or a 16 bit array of
998
+ characters. Hence random access to characters is always fast.
999
+
1000
+ The C API provides functions to convert Javascript Strings to C UTF-8 encoded
1001
+ strings. The most common case where the Javascript string contains
1002
+ only ASCII characters involves no copying.
1003
+
1004
+ @subsection Objects
1005
+
1006
+ The object shapes (object prototype, property names and flags) are shared
1007
+ between objects to save memory.
1008
+
1009
+ Arrays with no holes (except at the end of the array) are optimized.
1010
+
1011
+ TypedArray accesses are optimized.
1012
+
1013
+ @subsection Atoms
1014
+
1015
+ Object property names and some strings are stored as Atoms (unique
1016
+ strings) to save memory and allow fast comparison. Atoms are
1017
+ represented as a 32 bit integer. Half of the atom range is reserved for
1018
+ immediate integer literals from @math{0} to @math{2^{31}-1}.
1019
+
1020
+ @subsection Numbers
1021
+
1022
+ Numbers are represented either as 32-bit signed integers or 64-bit IEEE-754
1023
+ floating point values. Most operations have fast paths for the 32-bit
1024
+ integer case.
1025
+
1026
+ @subsection Garbage collection
1027
+
1028
+ Reference counting is used to free objects automatically and
1029
+ deterministically. A separate cycle removal pass is done when the allocated
1030
+ memory becomes too large. The cycle removal algorithm only uses the
1031
+ reference counts and the object content, so no explicit garbage
1032
+ collection roots need to be manipulated in the C code.
1033
+
1034
+ @subsection JSValue
1035
+
1036
+ It is a Javascript value which can be a primitive type (such as
1037
+ Number, String, ...) or an Object. NaN boxing is used in the 32-bit version
1038
+ to store 64-bit floating point numbers. The representation is
1039
+ optimized so that 32-bit integers and reference counted values can be
1040
+ efficiently tested.
1041
+
1042
+ In 64-bit code, JSValue are 128-bit large and no NaN boxing is used. The
1043
+ rationale is that in 64-bit code memory usage is less critical.
1044
+
1045
+ In both cases (32 or 64 bits), JSValue exactly fits two CPU registers,
1046
+ so it can be efficiently returned by C functions.
1047
+
1048
+ @subsection Function call
1049
+
1050
+ The engine is optimized so that function calls are fast. The system
1051
+ stack holds the Javascript parameters and local variables.
1052
+
1053
+ @section RegExp
1054
+
1055
+ A specific regular expression engine was developed. It is both small
1056
+ and efficient and supports all the ES2020 features including the
1057
+ Unicode properties. As the Javascript compiler, it directly generates
1058
+ bytecode without a parse tree.
1059
+
1060
+ Backtracking with an explicit stack is used so that there is no
1061
+ recursion on the system stack. Simple quantifiers are specifically
1062
+ optimized to avoid recursions.
1063
+
1064
+ Infinite recursions coming from quantifiers with empty terms are
1065
+ avoided.
1066
+
1067
+ The full regexp library weights about 15 KiB (x86 code), excluding the
1068
+ Unicode library.
1069
+
1070
+ @section Unicode
1071
+
1072
+ A specific Unicode library was developed so that there is no
1073
+ dependency on an external large Unicode library such as ICU. All the
1074
+ Unicode tables are compressed while keeping a reasonable access
1075
+ speed.
1076
+
1077
+ The library supports case conversion, Unicode normalization, Unicode
1078
+ script queries, Unicode general category queries and all Unicode
1079
+ binary properties.
1080
+
1081
+ The full Unicode library weights about 45 KiB (x86 code).
1082
+
1083
+ @section BigInt, BigFloat, BigDecimal
1084
+
1085
+ BigInt, BigFloat and BigDecimal are implemented with the @code{libbf}
1086
+ library@footnote{@url{https://bellard.org/libbf}}. It weights about 90
1087
+ KiB (x86 code) and provides arbitrary precision IEEE 754 floating
1088
+ point operations and transcendental functions with exact rounding.
1089
+
1090
+ @chapter License
1091
+
1092
+ QuickJS is released under the MIT license.
1093
+
1094
+ Unless otherwise specified, the QuickJS sources are copyright Fabrice
1095
+ Bellard and Charlie Gordon.
1096
+
1097
+ @bye