not really known
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

383 lines
1.0 MiB

  1. // vim:fileencoding=utf-8
  2. (function(external_namespace) {
  3. "use strict;"
  4. var rs_version = "0.7.16";
  5. var rs_commit_sha = "ac12d7e202b2816c5596d6e0ad9774cd41017d3c";
  6. // Embedded modules {{{
  7. var data = {"compiler.js":"(function(){\n \"use strict\";\n var ρσ_iterator_symbol = (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") ? Symbol.iterator : \"iterator-Symbol-5d0927e5554349048cf0e3762a228256\";\n var ρσ_kwargs_symbol = (typeof Symbol === \"function\") ? Symbol(\"kwargs-object\") : \"kwargs-object-Symbol-5d0927e5554349048cf0e3762a228256\";\n var ρσ_cond_temp, ρσ_expr_temp, ρσ_last_exception;\n var ρσ_object_counter = 0;\nvar ρσ_len;\nfunction ρσ_bool(val) {\n return !!val;\n};\nif (!ρσ_bool.__argnames__) Object.defineProperties(ρσ_bool, {\n __argnames__ : {value: [\"val\"]}\n});\n\nfunction ρσ_print() {\n var parts;\n if (typeof console === \"object\") {\n parts = [];\n for (var i = 0; i < arguments.length; i++) {\n parts.push(ρσ_str(arguments[(typeof i === \"number\" && i < 0) ? arguments.length + i : i]));\n }\n console.log(parts.join(\" \"));\n }\n};\n\nfunction ρσ_int(val, base) {\n var ans;\n ans = parseInt(val, base || 10);\n if (isNaN(ans)) {\n throw new ValueError(\"Invalid literal for int with base \" + (base || 10) + \": \" + val);\n }\n return ans;\n};\nif (!ρσ_int.__argnames__) Object.defineProperties(ρσ_int, {\n __argnames__ : {value: [\"val\", \"base\"]}\n});\n\nfunction ρσ_float() {\n var ans;\n ans = parseFloat.apply(null, arguments);\n if (isNaN(ans)) {\n throw new ValueError(\"Could not convert string to float: \" + arguments[0]);\n }\n return ans;\n};\n\nfunction ρσ_arraylike_creator() {\n var names;\n names = \"Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array\".split(\" \");\n if (typeof HTMLCollection === \"function\") {\n names = names.concat(\"HTMLCollection NodeList NamedNodeMap TouchList\".split(\" \"));\n }\n return (function() {\n var ρσ_anonfunc = function (x) {\n if (Array.isArray(x) || typeof x === \"string\" || names.indexOf(Object.prototype.toString.call(x).slice(8, -1)) > -1) {\n return true;\n }\n return false;\n };\n if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, {\n __argnames__ : {value: [\"x\"]}\n });\n return ρσ_anonfunc;\n })();\n};\n\nfunction options_object(f) {\n return function () {\n if (typeof arguments[arguments.length - 1] === \"object\") {\n arguments[ρσ_bound_index(arguments.length - 1, arguments)][ρσ_kwargs_symbol] = true;\n }\n return f.apply(this, arguments);\n };\n};\nif (!options_object.__argnames__) Object.defineProperties(options_object, {\n __argnames__ : {value: [\"f\"]}\n});\n\nfunction ρσ_id(x) {\n return x.ρσ_object_id;\n};\nif (!ρσ_id.__argnames__) Object.defineProperties(ρσ_id, {\n __argnames__ : {value: [\"x\"]}\n});\n\nfunction ρσ_dir(item) {\n var arr;\n arr = ρσ_list_decorate([]);\n for (var i in item) {\n arr.push(i);\n }\n return arr;\n};\nif (!ρσ_dir.__argnames__) Object.defineProperties(ρσ_dir, {\n __argnames__ : {value: [\"item\"]}\n});\n\nfunction ρσ_ord(x) {\n var ans, second;\n ans = x.charCodeAt(0);\n if (55296 <= ans && ans <= 56319) {\n second = x.charCodeAt(1);\n if (56320 <= second && second <= 57343) {\n return (ans - 55296) * 1024 + second - 56320 + 65536;\n }\n throw new TypeError(\"string is missing the low surrogate char\");\n }\n return ans;\n};\nif (!ρσ_ord.__argnames__) Object.defineProperties(ρσ_ord, {\n __argnames__ : {value: [\"x\"]}\n});\n\nfunction ρσ_chr(code) {\n if (code <= 65535) {\n return String.fromCharCode(code);\n }\n code -= 65536;\n return String.fromCharCode(55296 + (code >> 10), 56320 + (code & 1023));\n};\nif (!ρσ_chr.__argnames__) Object.defineProperties(ρσ_chr, {\n __argnames__ : {value: [\"code\"]}\n});\n\nfunction ρσ_callable(x) {\n re
  8. // End embedded modules }}}
  9. /* vim:fileencoding=utf-8
  10. *
  11. * Copyright (C) 2016 Kovid Goyal <kovid at kovidgoyal.net>
  12. *
  13. * Distributed under terms of the BSD license
  14. */
  15. var namespace = {}, jsSHA = {};
  16. var write_cache = {};
  17. var builtin_modules = {
  18. 'crypto' : {
  19. 'createHash': function create_hash() {
  20. var ans = new jsSHA.jsSHA('SHA-1', 'TEXT');
  21. ans.digest = function hex_digest() { return ans.getHash('HEX'); };
  22. return ans;
  23. },
  24. },
  25. 'vm': {
  26. 'createContext': function create_context(ctx) {
  27. var iframe = document.createElement('iframe');
  28. iframe.style.display = 'none';
  29. document.body.appendChild(iframe);
  30. var win = iframe.contentWindow;
  31. if(!ctx) ctx = {};
  32. if (!ctx.sha1sum) ctx.sha1sum = sha1sum;
  33. if (!ctx.require) ctx.require = require;
  34. Object.keys(ctx).forEach(function(k) { win[k] = ctx[k]; });
  35. return win;
  36. },
  37. 'runInContext': function run_in_context(code, ctx) {
  38. return ctx.eval(code);
  39. },
  40. 'runInThisContext': eval,
  41. },
  42. 'path': {
  43. 'join': function path_join() { return Array.prototype.slice.call(arguments).join('/'); },
  44. 'dirname': function path_dirname(path) {
  45. return path.split('/').slice(0, -1).join('/');
  46. },
  47. },
  48. 'inspect': function inspect(x) { return x.toString(); },
  49. 'fs': {
  50. 'readFileSync': function readfile(name) {
  51. var data = namespace.file_data[name];
  52. if (data) return data;
  53. data = write_cache[name];
  54. if (data) return data;
  55. var err = Error();
  56. err.code = 'ENOENT';
  57. throw err;
  58. },
  59. 'writeFileSync': function writefile(name, data) {
  60. write_cache[name] = data;
  61. },
  62. },
  63. };
  64. function require(name) {
  65. return builtin_modules[name] || {};
  66. }
  67. // Embedded sha1 implementation {{{
  68. (function() {
  69. /*
  70. A JavaScript implementation of the SHA family of hashes, as
  71. defined in FIPS PUB 180-2 as well as the corresponding HMAC implementation
  72. as defined in FIPS PUB 198a
  73. Copyright Brian Turek 2008-2015
  74. Distributed under the BSD License
  75. See http://caligatio.github.io/jsSHA/ for more information
  76. Several functions taken from Paul Johnston
  77. */
  78. 'use strict';(function(E){function t(e,a,c){var g=0,b=[],d=0,f,k,l,h,m,w,n,q=!1,r=!1,p=[],t=[],v,u=!1;c=c||{};f=c.encoding||"UTF8";v=c.numRounds||1;l=y(a,f);if(v!==parseInt(v,10)||1>v)throw Error("numRounds must a integer >= 1");if("SHA-1"===e)m=512,w=z,n=F,h=160;else throw Error("Chosen SHA variant is not supported");k=x(e);this.setHMACKey=function(a,b,d){var c;if(!0===r)throw Error("HMAC key already set");if(!0===q)throw Error("Cannot set HMAC key after finalizing hash");if(!0===u)throw Error("Cannot set HMAC key after calling update");
  79. f=(d||{}).encoding||"UTF8";b=y(b,f)(a);a=b.binLen;b=b.value;c=m>>>3;d=c/4-1;if(c<a/8){for(b=n(b,a,0,x(e));b.length<=d;)b.push(0);b[d]&=4294967040}else if(c>a/8){for(;b.length<=d;)b.push(0);b[d]&=4294967040}for(a=0;a<=d;a+=1)p[a]=b[a]^909522486,t[a]=b[a]^1549556828;k=w(p,k);g=m;r=!0};this.update=function(a){var e,c,f,h=0,n=m>>>5;e=l(a,b,d);a=e.binLen;c=e.value;e=a>>>5;for(f=0;f<e;f+=n)h+m<=a&&(k=w(c.slice(f,f+n),k),h+=m);g+=h;b=c.slice(h>>>5);d=a%m;u=!0};this.getHash=function(a,c){var f,l,m;if(!0===
  80. r)throw Error("Cannot call getHash after setting HMAC key");m=A(c);switch(a){case "HEX":f=function(a){return B(a,m)};break;case "B64":f=function(a){return C(a,m)};break;case "BYTES":f=D;break;default:throw Error("format must be HEX, B64, or BYTES");}if(!1===q)for(k=n(b,d,g,k),l=1;l<v;l+=1)k=n(k,h,0,x(e));q=!0;return f(k)};this.getHMAC=function(a,c){var f,l,p;if(!1===r)throw Error("Cannot call getHMAC without first setting HMAC key");p=A(c);switch(a){case "HEX":f=function(a){return B(a,p)};break;case "B64":f=
  81. function(a){return C(a,p)};break;case "BYTES":f=D;break;default:throw Error("outputFormat must be HEX, B64, or BYTES");}!1===q&&(l=n(b,d,g,k),k=w(t,x(e)),k=n(l,h,m,k));q=!0;return f(k)}}function G(e,a,c){var g=e.length,b,d,f,k,l;a=a||[0];c=c||0;l=c>>>3;if(0!==g%2)throw Error("String of HEX type must be in byte increments");for(b=0;b<g;b+=2){d=parseInt(e.substr(b,2),16);if(isNaN(d))throw Error("String of HEX type contains invalid characters");k=(b>>>1)+l;for(f=k>>>2;a.length<=f;)a.push(0);a[f]|=d<<
  82. 8*(3-k%4)}return{value:a,binLen:4*g+c}}function H(e,a,c){var g=[],b,d,f,k,g=a||[0];c=c||0;d=c>>>3;for(b=0;b<e.length;b+=1)a=e.charCodeAt(b),k=b+d,f=k>>>2,g.length<=f&&g.push(0),g[f]|=a<<8*(3-k%4);return{value:g,binLen:8*e.length+c}}function I(e,a,c){var g=[],b=0,d,f,k,l,h,m,g=a||[0];c=c||0;a=c>>>3;if(-1===e.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");f=e.indexOf("=");e=e.replace(/\=/g,"");if(-1!==f&&f<e.length)throw Error("Invalid '=' found in base-64 string");
  83. for(f=0;f<e.length;f+=4){h=e.substr(f,4);for(k=l=0;k<h.length;k+=1)d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(h[k]),l|=d<<18-6*k;for(k=0;k<h.length-1;k+=1){m=b+a;for(d=m>>>2;g.length<=d;)g.push(0);g[d]|=(l>>>16-8*k&255)<<8*(3-m%4);b+=1}}return{value:g,binLen:8*b+c}}function B(e,a){var c="",g=4*e.length,b,d;for(b=0;b<g;b+=1)d=e[b>>>2]>>>8*(3-b%4),c+="0123456789abcdef".charAt(d>>>4&15)+"0123456789abcdef".charAt(d&15);return a.outputUpper?c.toUpperCase():c}function C(e,
  84. a){var c="",g=4*e.length,b,d,f;for(b=0;b<g;b+=3)for(f=b+1>>>2,d=e.length<=f?0:e[f],f=b+2>>>2,f=e.length<=f?0:e[f],f=(e[b>>>2]>>>8*(3-b%4)&255)<<16|(d>>>8*(3-(b+1)%4)&255)<<8|f>>>8*(3-(b+2)%4)&255,d=0;4>d;d+=1)8*b+6*d<=32*e.length?c+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(f>>>6*(3-d)&63):c+=a.b64Pad;return c}function D(e){var a="",c=4*e.length,g,b;for(g=0;g<c;g+=1)b=e[g>>>2]>>>8*(3-g%4)&255,a+=String.fromCharCode(b);return a}function A(e){var a={outputUpper:!1,b64Pad:"="};
  85. e=e||{};a.outputUpper=e.outputUpper||!1;!0===e.hasOwnProperty("b64Pad")&&(a.b64Pad=e.b64Pad);if("boolean"!==typeof a.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!==typeof a.b64Pad)throw Error("Invalid b64Pad formatting option");return a}function y(e,a){var c;switch(a){case "UTF8":case "UTF16BE":case "UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE");}switch(e){case "HEX":c=G;break;case "TEXT":c=function(e,b,d){var f=[],c=[],l=0,h,m,p,
  86. n,q,f=b||[0];b=d||0;p=b>>>3;if("UTF8"===a)for(h=0;h<e.length;h+=1)for(d=e.charCodeAt(h),c=[],128>d?c.push(d):2048>d?(c.push(192|d>>>6),c.push(128|d&63)):55296>d||57344<=d?c.push(224|d>>>12,128|d>>>6&63,128|d&63):(h+=1,d=65536+((d&1023)<<10|e.charCodeAt(h)&1023),c.push(240|d>>>18,128|d>>>12&63,128|d>>>6&63,128|d&63)),m=0;m<c.length;m+=1){q=l+p;for(n=q>>>2;f.length<=n;)f.push(0);f[n]|=c[m]<<8*(3-q%4);l+=1}else if("UTF16BE"===a||"UTF16LE"===a)for(h=0;h<e.length;h+=1){d=e.charCodeAt(h);"UTF16LE"===a&&
  87. (m=d&255,d=m<<8|d>>>8);q=l+p;for(n=q>>>2;f.length<=n;)f.push(0);f[n]|=d<<8*(2-q%4);l+=2}return{value:f,binLen:8*l+b}};break;case "B64":c=I;break;case "BYTES":c=H;break;default:throw Error("format must be HEX, TEXT, B64, or BYTES");}return c}function r(e,a){return e<<a|e>>>32-a}function p(e,a){var c=(e&65535)+(a&65535);return((e>>>16)+(a>>>16)+(c>>>16)&65535)<<16|c&65535}function u(e,a,c,g,b){var d=(e&65535)+(a&65535)+(c&65535)+(g&65535)+(b&65535);return((e>>>16)+(a>>>16)+(c>>>16)+(g>>>16)+(b>>>16)+
  88. (d>>>16)&65535)<<16|d&65535}function x(e){if("SHA-1"===e)e=[1732584193,4023233417,2562383102,271733878,3285377520];else throw Error("No SHA variants supported");return e}function z(e,a){var c=[],g,b,d,f,k,l,h;g=a[0];b=a[1];d=a[2];f=a[3];k=a[4];for(h=0;80>h;h+=1)c[h]=16>h?e[h]:r(c[h-3]^c[h-8]^c[h-14]^c[h-16],1),l=20>h?u(r(g,5),b&d^~b&f,k,1518500249,c[h]):40>h?u(r(g,5),b^d^f,k,1859775393,c[h]):60>h?u(r(g,5),b&d^b&f^d&f,k,2400959708,c[h]):u(r(g,5),b^d^f,k,3395469782,c[h]),k=f,f=d,d=r(b,30),b=g,g=l;a[0]=
  89. p(g,a[0]);a[1]=p(b,a[1]);a[2]=p(d,a[2]);a[3]=p(f,a[3]);a[4]=p(k,a[4]);return a}function F(e,a,c,g){var b;for(b=(a+65>>>9<<4)+15;e.length<=b;)e.push(0);e[a>>>5]|=128<<24-a%32;e[b]=a+c;c=e.length;for(a=0;a<c;a+=16)g=z(e.slice(a,a+16),g);return g}"function"===typeof define&&define.amd?define(function(){return t}):"undefined"!==typeof exports?"undefined"!==typeof module&&module.exports?module.exports=exports=t:exports=t:E.jsSHA=t})(this);
  90. }).call(jsSHA);
  91. // End embedded sha1 implementation }}}
  92. var exports = namespace;
  93. /*
  94. * Copyright (C) 2015 Kovid Goyal <kovid at kovidgoyal.net>
  95. *
  96. * Distributed under terms of the BSD license
  97. */
  98. var vm = require('vm');
  99. var native_require = require;
  100. function normalize_array(parts, allowAboveRoot) {
  101. var res = [];
  102. for (var i = 0; i < parts.length; i++) {
  103. var p = parts[i];
  104. // ignore empty parts
  105. if (!p || p === '.')
  106. continue;
  107. if (p === '..') {
  108. if (res.length && res[res.length - 1] !== '..') {
  109. res.pop();
  110. } else if (allowAboveRoot) {
  111. res.push('..');
  112. }
  113. } else {
  114. res.push(p);
  115. }
  116. }
  117. return res;
  118. }
  119. function normalize(path) {
  120. var is_abs = path && path[0] === '/';
  121. var trailing_slash = path && path[path.length - 1] === '/';
  122. path = normalize_array(path.split('/'), !is_abs).join('/');
  123. if (!path && !is_abs) {
  124. path = '.';
  125. }
  126. if (path && trailing_slash) {
  127. path += '/';
  128. }
  129. return (is_abs ? '/' : '') + path;
  130. }
  131. function dirname(path) {
  132. var idx = path.lastIndexOf('/');
  133. if (idx != -1) path = path.slice(0, idx);
  134. else path = '';
  135. return path;
  136. }
  137. function basename(path) {
  138. var idx = path.lastIndexOf('/');
  139. if (idx != -1) path = path.slice(idx + 1);
  140. return path;
  141. }
  142. var cache = {};
  143. function load(filepath) {
  144. var cached = cache[filepath];
  145. if (cached) return cached.exports;
  146. var module = {'id':filepath, 'exports':{}};
  147. cache[filepath] = module;
  148. var content = data[filepath];
  149. if (Array.isArray(content)) content = data[content[0]];
  150. if (!content) throw 'Failed to load: ' + JSON.stringify(filepath);
  151. if (filepath.slice(-5) == '.json') { module.exports = JSON.parse(content); return module.exports; }
  152. var base = dirname(filepath);
  153. function mrequire(x) {
  154. return vrequire(x, base);
  155. }
  156. content = content.replace(/^\#\!.*/, '');
  157. var wrapped = '(function(exports, require, module, __filename, __dirname, create_rapydscript_compiler) { ';
  158. wrapped += content + '\n;})';
  159. try {
  160. vm.runInThisContext(wrapped, {'filename': filepath})(module.exports, mrequire, module, filepath, dirname(filepath), create_compiler);
  161. } catch (e) {
  162. console.error(e);
  163. delete cache[filepath];
  164. throw e;
  165. }
  166. return module.exports;
  167. }
  168. function has(x, y) { return Object.prototype.hasOwnProperty.call(x, y); }
  169. function try_files(candidate) {
  170. if (has(data, candidate)) return candidate;
  171. if (has(data, candidate + '.js')) return candidate + '.js';
  172. if (has(data, candidate + '.json')) return candidate + '.json';
  173. return null;
  174. }
  175. function find_in_modules_dir(name, base) {
  176. var candidate = normalize(base + (base ? '/':'') + 'node_modules/' + name);
  177. var q = try_files(candidate);
  178. if (q) return q;
  179. var pj = candidate + '/package.json';
  180. if (has(data, pj)) {
  181. var ans = normalize(candidate + '/' + JSON.parse(data[pj]).main);
  182. if (has(data, ans)) return ans;
  183. }
  184. var index = candidate + '/index.js';
  185. if (has(data, index)) return index;
  186. var p = dirname(base);
  187. if (p) return find_in_modules_dir(name, p);
  188. return null;
  189. }
  190. function find_module(name, base) {
  191. if (name[0] == '/') throw 'Cannot find absolute module: ' + name;
  192. if (name.slice(0, 2) == './' || name.slice(0, 3) == '../') {
  193. var candidate = normalize((base ? base + '/' : base) + name);
  194. return try_files(candidate);
  195. }
  196. var q = try_files(name);
  197. if (q) return q;
  198. return find_in_modules_dir(name, base);
  199. }
  200. function vrequire(name, base) {
  201. var exports = {};
  202. var modpath = '';
  203. base = base || '';
  204. // console.log('vrequire', name, base);
  205. if (!name) throw new Error('Cannot load a module from an empty name');
  206. modpath = find_module(name, base);
  207. if (!modpath && name && './'.indexOf(name[0]) === -1) {
  208. try {
  209. return native_require(name);
  210. } catch (e) {}
  211. }
  212. if (!modpath) throw new Error("Failed to find module: " + JSON.stringify(name) + " with base: " + JSON.stringify(base));
  213. return load(modpath);
  214. }
  215. var UglifyJS = null, regenerator = null;
  216. var crypto = null, fs = require('fs');
  217. function uglify(x) {
  218. if (!UglifyJS) UglifyJS = vrequire("uglify-js");
  219. ans = UglifyJS.minify(x);
  220. if (ans.error) throw ans.error;
  221. return ans.code;
  222. }
  223. function regenerate(code, beautify) {
  224. var orig = fs.readFileSync;
  225. fs.readFileSync = function(name) {
  226. if (!has(data, name)) {
  227. throw {message: "Failed to readfile from data: " + name};
  228. }
  229. return data[name];
  230. };
  231. if (!regenerator) regenerator = vrequire('regenerator');
  232. var ans;
  233. if (code) {
  234. try {
  235. ans = regenerator.compile(code).code;
  236. } catch (e) {
  237. console.error('regenerator failed for code: ' + code + 'with error stack:\n' + e.stack);
  238. throw e;
  239. }
  240. if (!beautify) ans = uglify(ans);
  241. } else {
  242. // Return the runtime
  243. ans = regenerator.compile('', {includeRuntime:true}).code;
  244. ans = ans.slice(ans.indexOf('!'), ans.lastIndexOf(')(')) + ')';
  245. if (!beautify) ans = uglify(ans+'();').slice(0, -3);
  246. }
  247. fs.readFileSync = orig;
  248. return ans;
  249. }
  250. if (typeof this != 'object' || typeof this.sha1sum !== 'function') {
  251. var sha1sum = function (data) {
  252. if (!crypto) crypto = require('crypto');
  253. var h = crypto.createHash('sha1');
  254. h.update(data);
  255. return h.digest('hex');
  256. };
  257. } else var sha1sum = this.sha1sum;
  258. function create_compiler() {
  259. var compilerjs = data['compiler.js'];
  260. var module = {'id':'compiler', 'exports':{}};
  261. var wrapped = '(function(module, exports, readfile, writefile, sha1sum, regenerate) {' + data['compiler.js'] + ';\n})';
  262. vm.runInThisContext(wrapped, {'filename': 'compiler.js'})(module, module.exports, fs.readFileSync, fs.writeFileSync, sha1sum, regenerate);
  263. return module.exports;
  264. }
  265. var RapydScript = null;
  266. function compile(code, filename, options) {
  267. if (!RapydScript) RapydScript = create_compiler();
  268. options = options || {};
  269. var ast = RapydScript.parse(code, {
  270. filename: filename || '<eval>',
  271. basedir: options.basedir || dirname(filename || ''),
  272. libdir: options.libdir,
  273. });
  274. var out_ops = {
  275. beautify: (options.beautify === undefined ? true : options.beautify),
  276. private_scope: !options.bare,
  277. omit_baselib: !!options.omit_baselib,
  278. js_version: options.js_version || 5,
  279. };
  280. if (!out_ops.omit_baselib) out_ops.baselib_plain = data['baselib-plain-' + (out_ops.beautify ? 'pretty' : 'ugly') + '.js'];
  281. var out = new RapydScript.OutputStream(out_ops);
  282. ast.print(out);
  283. return out.get();
  284. }
  285. function create_embedded_compiler(runjs) {
  286. var c = vrequire('tools/embedded_compiler.js');
  287. return c(create_compiler(), data['baselib-plain-pretty.js'], runjs);
  288. }
  289. function web_repl() {
  290. var repl = vrequire('tools/web_repl.js');
  291. return repl(create_compiler(), data['baselib-plain-pretty.js']);
  292. }
  293. function init_repl(options) {
  294. var repl = vrequire('tools/repl.js');
  295. options.baselib = data['baselib-plain-pretty.js'];
  296. return repl(options);
  297. }
  298. function gettext_parse(catalog, code, filename) {
  299. g = vrequire('tools/gettext.js');
  300. g.gettext(catalog, code, filename);
  301. }
  302. function gettext_output(catalog, options, write) {
  303. g = vrequire('tools/gettext.js');
  304. g.write_output(catalog, options, write);
  305. }
  306. function msgfmt(data, options) {
  307. m = vrequire('tools/msgfmt.js');
  308. return m.build(data, options);
  309. }
  310. function completer(compiler, options) {
  311. m = vrequire('tools/completer.js');
  312. return m(compiler, options);
  313. }
  314. if (typeof exports === 'object') {
  315. exports.compile = compile;
  316. exports.create_embedded_compiler = create_embedded_compiler;
  317. exports.web_repl = web_repl;
  318. exports.init_repl = init_repl;
  319. exports.gettext_parse = gettext_parse;
  320. exports.gettext_output = gettext_output;
  321. exports.msgfmt = msgfmt;
  322. exports.rs_version = rs_version;
  323. exports.file_data = data;
  324. exports.completer = completer;
  325. if (typeof rs_commit_sha === 'string') exports.rs_commit_sha = rs_commit_sha;
  326. }
  327. external_namespace.RapydScript = namespace;
  328. })(this)