UNPKG

jsx

Version:

a faster, safer, easier JavaScript

1,426 lines (1,287 loc) 1.15 MB
#!/usr/bin/env node // generatedy by JSX compiler 0.9.28 (2013-05-05 17:21:27 +0900; 27a1644e9b3800f8387a38410af80d18da43ba0d) var JSX = {}; (function (JSX) { /** * extends the class */ function $__jsx_extend(derivations, base) { var ctor = function () {}; ctor.prototype = base.prototype; var proto = new ctor(); for (var i in derivations) { derivations[i].prototype = proto; } } /** * copies the implementations from source interface to target */ function $__jsx_merge_interface(target, source) { for (var k in source.prototype) if (source.prototype.hasOwnProperty(k)) target.prototype[k] = source.prototype[k]; } /** * defers the initialization of the property */ function $__jsx_lazy_init(obj, prop, func) { function reset(obj, prop, value) { delete obj[prop]; obj[prop] = value; return value; } Object.defineProperty(obj, prop, { get: function () { return reset(obj, prop, func()); }, set: function (v) { reset(obj, prop, v); }, enumerable: true, configurable: true }); } /** * sideeffect().a /= b */ function $__jsx_div_assign(obj, prop, divisor) { return obj[prop] = (obj[prop] / divisor) | 0; } /* * global functions, renamed to avoid conflict with local variable names */ var $__jsx_parseInt = parseInt; var $__jsx_parseFloat = parseFloat; var $__jsx_isNaN = isNaN; var $__jsx_isFinite = isFinite; var $__jsx_encodeURIComponent = encodeURIComponent; var $__jsx_decodeURIComponent = decodeURIComponent; var $__jsx_encodeURI = encodeURI; var $__jsx_decodeURI = decodeURI; var $__jsx_ObjectToString = Object.prototype.toString; var $__jsx_ObjectHasOwnProperty = Object.prototype.hasOwnProperty; /* * profiler object, initialized afterwards */ function $__jsx_profiler() { } /* * public interface to JSX code */ JSX.require = function (path) { var m = $__jsx_classMap[path]; return m !== undefined ? m : null; }; JSX.profilerIsRunning = function () { return $__jsx_profiler.getResults != null; }; JSX.getProfileResults = function () { return ($__jsx_profiler.getResults || function () { return {}; })(); }; JSX.postProfileResults = function (url, cb) { if ($__jsx_profiler.postResults == null) throw new Error("profiler has not been turned on"); return $__jsx_profiler.postResults(url, cb); }; JSX.resetProfileResults = function () { if ($__jsx_profiler.resetResults == null) throw new Error("profiler has not been turned on"); return $__jsx_profiler.resetResults(); }; JSX.DEBUG = true; function g_StopIteration() { Error.call(this); }; $__jsx_extend([g_StopIteration], Error); function CompilationServer(parentPlatform) { this._requestSequence = 0; this._pidFile = ""; this._portFile = ""; this._httpd = null; this._timer = null; this._platform = parentPlatform; this._home = (function (v) { if (! (v != null)) { debugger; throw new Error("[src/jsx-node-front.jsx:289:45] null access\n this._home = process.env[\"JSX_HOME\"] ?: (process.env[\"HOME\"] ?: process.env[\"USERPROFILE\"]) + \"/.jsx\";\n ^\n"); } return v; }(process.env.JSX_HOME || (function (v) { if (! (v != null)) { debugger; throw new Error("[src/jsx-node-front.jsx:289:69] null access\n this._home = process.env[\"JSX_HOME\"] ?: (process.env[\"HOME\"] ?: process.env[\"USERPROFILE\"]) + \"/.jsx\";\n ^\n"); } return v; }(process.env.HOME || process.env.USERPROFILE)) + "/.jsx")); if (! parentPlatform.fileExists$S(this._home)) { parentPlatform.mkpath$S(this._home); } this._pidFile = this._home + "/pid"; this._portFile = this._home + "/port"; }; $__jsx_extend([CompilationServer], Object); function CompilationServer$start$LPlatform$I(platform, port) { var server; server = new CompilationServer(platform); server._httpd = node.http.createServer((function (request, response) { server.handleRequest$LServerRequest$LServerResponse$(request, response); })); server._httpd.listen(port); platform.save$USS(server._pidFile, process.pid + ""); platform.save$USS(server._portFile, port + ""); console.info("%s [%s] listen http://localhost:%s/", new Date().toISOString(), process.pid, port); server._timer = Timer$setTimeout$F$V$N((function () { server.shutdown$S("timeout"); }), CompilationServer.LIFE); process.on("SIGTERM", (function () { server.shutdown$S("SIGTERM"); })); process.on("SIGINT", (function () { server.shutdown$S("SIGINT"); })); if (CompilationServer.AUTO_SHUTDOWN) { node.fs.watch(node.__filename, ({ persistent: false }), (function (event, filename) { server.shutdown$S(event); })); } return 0; }; CompilationServer.start$LPlatform$I = CompilationServer$start$LPlatform$I; CompilationServer.prototype.shutdown$S = function (reason) { try { node.fs.unlinkSync(this._portFile); } catch ($__jsx_catch_0) { if ($__jsx_catch_0 instanceof Error) { } else { throw $__jsx_catch_0; } } try { node.fs.unlinkSync(this._pidFile); } catch ($__jsx_catch_0) { if ($__jsx_catch_0 instanceof Error) { } else { throw $__jsx_catch_0; } } Timer$clearTimeout$LTimerHandle$(this._timer); this._httpd.close(); console.info("%s [%s] shutdown by %s, handled %s requests", new Date().toISOString(), process.pid, reason, this._requestSequence); }; CompilationServer.prototype.handleRequest$LServerRequest$LServerResponse$ = function (request, response) { var $this = this; var startTime; var id; var c; var matched; var query; var inputData; startTime = new Date(); id = ++ this._requestSequence; Timer$clearTimeout$LTimerHandle$(this._timer); this._timer = Timer$setTimeout$F$V$N((function () { $this.shutdown$S("timeout"); }), CompilationServer.LIFE); if (request.method === "GET") { console.info("%s #%s start %s", startTime.toISOString(), id, request.url); this.handleGET$NLDate$LServerRequest$LServerResponse$(id, startTime, request, response); return; } c = new CompilationServerPlatform(this._platform.getRoot$(), id, request, response); matched = request.url.match(/\?(.*)/); if (! (matched && matched[1])) { c.error$S("invalid request to compilation server"); this.finishRequest$NLDate$LServerResponse$NX(id, startTime, response, 400, c.getContents$()); return; } query = $__jsx_decodeURIComponent((function (v) { if (! (v != null)) { debugger; throw new Error("[src/jsx-node-front.jsx:360:53] null access\n var query = String.decodeURIComponent(matched[1]);\n ^\n"); } return v; }(matched[1]))); console.info("%s #%s start %s", startTime.toISOString(), id, query.replace(/\n/g, "\\n")); inputData = ""; request.on("data", (function (chunk) { inputData += chunk + ""; })); request.on("end", (function () { var args; if (inputData) { c.setFileContent$SS("-", inputData); } try { args = (function ($v) { if (! ($v == null || $v instanceof Array)) { debugger; throw new Error("[src/jsx-node-front.jsx:373:45] detected invalid cast, value is not an Array or null\n var args = JSON.parse(query) as string[];\n ^^\n"); } return $v; }(JSON.parse(query))); c.setStatusCode$N(JSXCommand$main$LPlatform$AS(c, args)); } catch ($__jsx_catch_0) { if ($__jsx_catch_0 instanceof Error) { console.error("%s #%s %s", startTime.toISOString(), id, $__jsx_catch_0.stack); c.error$S($__jsx_catch_0.stack); } else { throw $__jsx_catch_0; } } $this.finishRequest$NLDate$LServerResponse$NX(id, startTime, response, 200, c.getContents$()); })); request.on("close", (function () { c.error$S("the connecion is unexpectedly closed.\n"); $this.finishRequest$NLDate$LServerResponse$NX(id, startTime, response, 500, c.getContents$()); })); }; CompilationServer.prototype.handleGET$NLDate$LServerRequest$LServerResponse$ = function (id, startTime, request, response) { this.finishRequest$NLDate$LServerResponse$NX(id, startTime, response, 200, ({ version_string: Meta.VERSION_STRING, version_number: Meta.VERSION_NUMBER, last_commit_hash: Meta.LAST_COMMIT_HASH, last_commit_date: Meta.LAST_COMMIT_DATE, status: true })); }; CompilationServer.prototype.finishRequest$NLDate$LServerResponse$NX = function (id, startTime, response, statusCode, data) { var content; var headers; var now; var elapsed; content = JSON.stringify(data); headers = ({ "Content-Type": "application/json", "Content-Length": Buffer.byteLength(content, "utf-8") + "", "Cache-Control": "no-cache" }); response.writeHead(statusCode, headers); response.end(content, "utf-8"); now = new Date(); elapsed = now.getTime() - startTime.getTime(); console.info("%s #%s finish, elapsed %s [ms]", now.toISOString(), id, elapsed); }; function _Main() { }; $__jsx_extend([_Main], Object); function _Main$main$AS(args) { var exitCode; var stdoutIsFlushed; var stderrIsFlushed; var exitIfFlushed; exitCode = JSXCommand$main$LPlatform$AS(new NodePlatform(), NodePlatform$getEnvOpts$().concat(args)); if (exitCode === 0) { return; } stdoutIsFlushed = process.stdout.write(""); stderrIsFlushed = process.stderr.write(""); exitIfFlushed = (function (data) { if (stdoutIsFlushed && stderrIsFlushed) { process.exit(exitCode); } }); if (! stdoutIsFlushed) { process.stdout.on('drain', exitIfFlushed); } if (! stderrIsFlushed) { process.stderr.on('drain', exitIfFlushed); } exitIfFlushed(null); }; _Main.main = _Main$main$AS; _Main.main$AS = _Main$main$AS; function node() { }; $__jsx_extend([node], Object); function node$require$S(source) { var src; src = 'require(' + JSON.stringify(source) + ')'; return eval(src); }; node.require$S = node$require$S; function Timer() { }; $__jsx_extend([Timer], Object); function Timer$setTimeout$F$V$N(callback, intervalMS) { return (function ($v) { if (! ($v == null || typeof $v === "function")) { debugger; throw new Error("[/Users/gfx/repo/JSX/lib/js/timer.jsx:34:40] detected invalid cast, value is not a function or null\n return (js.global[\"setTimeout\"] as __noconvert__ function(:function():void,:int) : TimerHandle)(callback, intervalMS);\n ^^\n"); } return $v; }(js.global.setTimeout))(callback, intervalMS); }; Timer.setTimeout$F$V$N = Timer$setTimeout$F$V$N; function Timer$clearTimeout$LTimerHandle$(timer) { (function ($v) { if (! ($v == null || typeof $v === "function")) { debugger; throw new Error("[/Users/gfx/repo/JSX/lib/js/timer.jsx:38:35] detected invalid cast, value is not a function or null\n (js.global[\"clearTimeout\"] as __noconvert__ function(:TimerHandle) : void)(timer);\n ^^\n"); } return $v; }(js.global.clearTimeout))(timer); }; Timer.clearTimeout$LTimerHandle$ = Timer$clearTimeout$LTimerHandle$; function Timer$setInterval$F$V$N(callback, intervalMS) { return (function ($v) { if (! ($v == null || typeof $v === "function")) { debugger; throw new Error("[/Users/gfx/repo/JSX/lib/js/timer.jsx:42:41] detected invalid cast, value is not a function or null\n return (js.global[\"setInterval\"] as __noconvert__ function(:function():void,:int) : TimerHandle)(callback, intervalMS);\n ^^\n"); } return $v; }(js.global.setInterval))(callback, intervalMS); }; Timer.setInterval$F$V$N = Timer$setInterval$F$V$N; function Timer$clearInterval$LTimerHandle$(timer) { (function ($v) { if (! ($v == null || typeof $v === "function")) { debugger; throw new Error("[/Users/gfx/repo/JSX/lib/js/timer.jsx:46:36] detected invalid cast, value is not a function or null\n (js.global[\"clearInterval\"] as __noconvert__ function(:TimerHandle) : void)(timer);\n ^^\n"); } return $v; }(js.global.clearInterval))(timer); }; Timer.clearInterval$LTimerHandle$ = Timer$clearInterval$LTimerHandle$; function Timer$requestAnimationFrame$F$NV$(callback) { return Timer._requestAnimationFrame(callback); }; Timer.requestAnimationFrame$F$NV$ = Timer$requestAnimationFrame$F$NV$; function Timer$cancelAnimationFrame$LTimerHandle$(timer) { Timer._cancelAnimationFrame(timer); }; Timer.cancelAnimationFrame$LTimerHandle$ = Timer$cancelAnimationFrame$LTimerHandle$; function Timer$useNativeRAF$B(enable) { Timer._requestAnimationFrame = Timer$_getRequestAnimationFrameImpl$B(enable); Timer._cancelAnimationFrame = Timer$_getCancelAnimationFrameImpl$B(enable); }; Timer.useNativeRAF$B = Timer$useNativeRAF$B; function Timer$_getRequestAnimationFrameImpl$B(useNativeImpl) { var lastTime; if (useNativeImpl) { if (js.global.requestAnimationFrame) { return (function (callback) { return (function ($v) { if (! ($v == null || typeof $v === "function")) { debugger; throw new Error("[/Users/gfx/repo/JSX/lib/js/timer.jsx:72:63] detected invalid cast, value is not a function or null\n return (js.global[\"requestAnimationFrame\"] as __noconvert__\n ^^\n"); } return $v; }(js.global.requestAnimationFrame))(callback); }); } else { if (js.global.webkitRequestAnimationFrame) { return (function (callback) { return (function ($v) { if (! ($v == null || typeof $v === "function")) { debugger; throw new Error("[/Users/gfx/repo/JSX/lib/js/timer.jsx:78:69] detected invalid cast, value is not a function or null\n return (js.global[\"webkitRequestAnimationFrame\"] as __noconvert__\n ^^\n"); } return $v; }(js.global.webkitRequestAnimationFrame))(callback); }); } else { if (js.global.mozRequestAnimationFrame) { return (function (callback) { return (function ($v) { if (! ($v == null || typeof $v === "function")) { debugger; throw new Error("[/Users/gfx/repo/JSX/lib/js/timer.jsx:84:66] detected invalid cast, value is not a function or null\n return (js.global[\"mozRequestAnimationFrame\"] as __noconvert__\n ^^\n"); } return $v; }(js.global.mozRequestAnimationFrame))(callback); }); } else { if (js.global.oRequestAnimationFrame) { return (function (callback) { return (function ($v) { if (! ($v == null || typeof $v === "function")) { debugger; throw new Error("[/Users/gfx/repo/JSX/lib/js/timer.jsx:90:64] detected invalid cast, value is not a function or null\n return (js.global[\"oRequestAnimationFrame\"] as __noconvert__\n ^^\n"); } return $v; }(js.global.oRequestAnimationFrame))(callback); }); } else { if (js.global.msRequestAnimationFrame) { return (function (callback) { return (function ($v) { if (! ($v == null || typeof $v === "function")) { debugger; throw new Error("[/Users/gfx/repo/JSX/lib/js/timer.jsx:96:65] detected invalid cast, value is not a function or null\n return (js.global[\"msRequestAnimationFrame\"] as __noconvert__\n ^^\n"); } return $v; }(js.global.msRequestAnimationFrame))(callback); }); } } } } } } lastTime = 0; return (function (callback) { var now; var timeToCall; now = Date.now(); timeToCall = Math.max(0, 16 - (now - lastTime)); lastTime = now + timeToCall; return Timer$setTimeout$F$V$N((function () { callback(now + timeToCall); }), timeToCall); }); }; Timer._getRequestAnimationFrameImpl$B = Timer$_getRequestAnimationFrameImpl$B; function Timer$_getCancelAnimationFrameImpl$B(useNativeImpl) { if (useNativeImpl) { if (js.global.cancelAnimationFrame) { return (function (timer) { (function ($v) { if (! ($v == null || typeof $v === "function")) { debugger; throw new Error("[/Users/gfx/repo/JSX/lib/js/timer.jsx:119:55] detected invalid cast, value is not a function or null\n (js.global[\"cancelAnimationFrame\"] as __noconvert__\n ^^\n"); } return $v; }(js.global.cancelAnimationFrame))(timer); }); } else { if (js.global.webkitCancelAnimationFrame) { return (function (timer) { (function ($v) { if (! ($v == null || typeof $v === "function")) { debugger; throw new Error("[/Users/gfx/repo/JSX/lib/js/timer.jsx:125:61] detected invalid cast, value is not a function or null\n (js.global[\"webkitCancelAnimationFrame\"] as __noconvert__\n ^^\n"); } return $v; }(js.global.webkitCancelAnimationFrame))(timer); }); } else { if (js.global.mozCancelAnimationFrame) { return (function (timer) { (function ($v) { if (! ($v == null || typeof $v === "function")) { debugger; throw new Error("[/Users/gfx/repo/JSX/lib/js/timer.jsx:131:58] detected invalid cast, value is not a function or null\n (js.global[\"mozCancelAnimationFrame\"] as __noconvert__\n ^^\n"); } return $v; }(js.global.mozCancelAnimationFrame))(timer); }); } else { if (js.global.oCancelAnimationFrame) { return (function (timer) { (function ($v) { if (! ($v == null || typeof $v === "function")) { debugger; throw new Error("[/Users/gfx/repo/JSX/lib/js/timer.jsx:137:56] detected invalid cast, value is not a function or null\n (js.global[\"oCancelAnimationFrame\"] as __noconvert__\n ^^\n"); } return $v; }(js.global.oCancelAnimationFrame))(timer); }); } else { if (js.global.msCancelAnimationFrame) { return (function (timer) { (function ($v) { if (! ($v == null || typeof $v === "function")) { debugger; throw new Error("[/Users/gfx/repo/JSX/lib/js/timer.jsx:143:57] detected invalid cast, value is not a function or null\n (js.global[\"msCancelAnimationFrame\"] as __noconvert__\n ^^\n"); } return $v; }(js.global.msCancelAnimationFrame))(timer); }); } } } } } } return Timer$clearTimeout$LTimerHandle$; }; Timer._getCancelAnimationFrameImpl$B = Timer$_getCancelAnimationFrameImpl$B; function TimerHandle() { }; $__jsx_extend([TimerHandle], Object); function Util() { }; $__jsx_extend([Util], Object); function Util$repeat$SN(c, n) { var s; var i; s = ""; for (i = 0; i < n; ++ i) { s += c; } return s; }; Util.repeat$SN = Util$repeat$SN; function Util$format$SAS(fmt, args) { var i; if (! (args != null)) { debugger; throw new Error("[src/util.jsx:81:20] assertion failure\n assert args != null;\n ^^\n"); } i = 0; return fmt.replace(/%(\d+|%)/g, (function (m) { var arg; if (m === "%%") { return "%"; } else { arg = args[(m.substring(1) | 0) - 1]; return (function (v) { if (! (v != null)) { debugger; throw new Error("[src/util.jsx:89:35] null access\n return arg == null ? \"null\" : arg;\n ^\n"); } return v; }(arg == null ? "null" : arg)); } })); }; Util.format$SAS = Util$format$SAS; function Util$instantiateTemplate$LAnalysisContext$LToken$SALType$(context, token, className, typeArguments) { return context.parser.lookupTemplate$ALCompileError$LTemplateInstantiationRequest$F$LParser$LClassDefinition$LClassDefinition$$(context.errors, new TemplateInstantiationRequest(token, className, typeArguments), context.postInstantiationCallback); }; Util.instantiateTemplate$LAnalysisContext$LToken$SALType$ = Util$instantiateTemplate$LAnalysisContext$LToken$SALType$; function Util$analyzeArgs$LAnalysisContext$ALExpression$LExpression$AALType$(context, args, parentExpr, expectedTypes) { var argTypes; var i; var funcDef; var expectedCallbackType; var j; var arrayExpr; var expectedArrayType; var mapExpr; var expectedMapType; argTypes = [ ]; for (i = 0; i < args.length; ++ i) { if (args[i] instanceof FunctionExpression && ! (function ($v) { if (! ($v == null || $v instanceof FunctionExpression)) { debugger; throw new Error("[src/util.jsx:101:68] detected invalid cast, value is not an instance of the designated type or null\n if (args[i] instanceof FunctionExpression && ! (args[i] as FunctionExpression).argumentTypesAreIdentified()) {\n ^^\n"); } return $v; }(args[i])).argumentTypesAreIdentified$()) { funcDef = (function ($v) { if (! ($v == null || $v instanceof FunctionExpression)) { debugger; throw new Error("[src/util.jsx:103:39] detected invalid cast, value is not an instance of the designated type or null\n var funcDef = (args[i] as FunctionExpression).getFuncDef();\n ^^\n"); } return $v; }(args[i])).getFuncDef$(); expectedCallbackType = null; for (j = 0; j < expectedTypes.length; ++ j) { if (expectedTypes[j][i] != null && expectedTypes[j][i] instanceof FunctionType && (function ($v) { if (! ($v == null || $v instanceof ResolvedFunctionType)) { debugger; throw new Error("[src/util.jsx:106:123] detected invalid cast, value is not an instance of the designated type or null\n if (expectedTypes[j][i] != null && expectedTypes[j][i] instanceof FunctionType && (expectedTypes[j][i] as ResolvedFunctionType).getArgumentTypes().length == funcDef.getArguments().length) {\n ^^\n"); } return $v; }(expectedTypes[j][i])).getArgumentTypes$().length === funcDef.getArguments$().length) { if (expectedCallbackType == null) { expectedCallbackType = expectedTypes[j][i]; } else { if (Util$typesAreEqual$ALType$ALType$((function ($v) { if (! ($v == null || $v instanceof ResolvedFunctionType)) { debugger; throw new Error("[src/util.jsx:109:76] detected invalid cast, value is not an instance of the designated type or null\n } else if (Util.typesAreEqual((expectedCallbackType as ResolvedFunctionType).getArgumentTypes(), (expectedTypes[j][i] as ResolvedFunctionType).getArgumentTypes())\n ^^\n"); } return $v; }(expectedCallbackType)).getArgumentTypes$(), (function ($v) { if (! ($v == null || $v instanceof ResolvedFunctionType)) { debugger; throw new Error("[src/util.jsx:109:142] detected invalid cast, value is not an instance of the designated type or null\n } else if (Util.typesAreEqual((expectedCallbackType as ResolvedFunctionType).getArgumentTypes(), (expectedTypes[j][i] as ResolvedFunctionType).getArgumentTypes())\n ^^\n"); } return $v; }(expectedTypes[j][i])).getArgumentTypes$()) && (function ($v) { if (! ($v == null || $v instanceof ResolvedFunctionType)) { debugger; throw new Error("[src/util.jsx:110:53] detected invalid cast, value is not an instance of the designated type or null\n && (expectedCallbackType as ResolvedFunctionType).getReturnType().equals((expectedTypes[j][i] as ResolvedFunctionType).getReturnType())) {\n ^^\n"); } return $v; }(expectedCallbackType)).getReturnType$().equals$LType$((function ($v) { if (! ($v == null || $v instanceof ResolvedFunctionType)) { debugger; throw new Error("[src/util.jsx:110:122] detected invalid cast, value is not an instance of the designated type or null\n && (expectedCallbackType as ResolvedFunctionType).getReturnType().equals((expectedTypes[j][i] as ResolvedFunctionType).getReturnType())) {\n ^^\n"); } return $v; }(expectedTypes[j][i])).getReturnType$())) { } else { break; } } } } if (j !== expectedTypes.length) { } else { if (expectedCallbackType != null) { if (! (function ($v) { if (! ($v == null || $v instanceof FunctionExpression)) { debugger; throw new Error("[src/util.jsx:120:35] detected invalid cast, value is not an instance of the designated type or null\n if (! (args[i] as FunctionExpression).deductTypeIfUnknown(context, expectedCallbackType as ResolvedFunctionType))\n ^^\n"); } return $v; }(args[i])).deductTypeIfUnknown$LAnalysisContext$LResolvedFunctionType$(context, (function ($v) { if (! ($v == null || $v instanceof ResolvedFunctionType)) { debugger; throw new Error("[src/util.jsx:120:108] detected invalid cast, value is not an instance of the designated type or null\n if (! (args[i] as FunctionExpression).deductTypeIfUnknown(context, expectedCallbackType as ResolvedFunctionType))\n ^^\n"); } return $v; }(expectedCallbackType)))) { return null; } } } } else { if (args[i] instanceof ArrayLiteralExpression && (function ($v) { if (! ($v == null || $v instanceof ArrayLiteralExpression)) { debugger; throw new Error("[src/util.jsx:123:77] detected invalid cast, value is not an instance of the designated type or null\n } else if (args[i] instanceof ArrayLiteralExpression && (args[i] as ArrayLiteralExpression).getExprs().length == 0 && (args[i] as ArrayLiteralExpression).getType() == null) {\n ^^\n"); } return $v; }(args[i])).getExprs$().length === 0 && (function ($v) { if (! ($v == null || $v instanceof ArrayLiteralExpression)) { debugger; throw new Error("[src/util.jsx:123:139] detected invalid cast, value is not an instance of the designated type or null\n } else if (args[i] instanceof ArrayLiteralExpression && (args[i] as ArrayLiteralExpression).getExprs().length == 0 && (args[i] as ArrayLiteralExpression).getType() == null) {\n ^^\n"); } return $v; }(args[i])).getType$() == null) { arrayExpr = (function ($v) { if (! ($v == null || $v instanceof ArrayLiteralExpression)) { debugger; throw new Error("[src/util.jsx:124:40] detected invalid cast, value is not an instance of the designated type or null\n var arrayExpr = args[i] as ArrayLiteralExpression;\n ^^\n"); } return $v; }(args[i])); expectedArrayType = null; for (j = 0; j < expectedTypes.length; ++ j) { if (expectedTypes[j][i] != null && expectedTypes[j][i] instanceof ObjectType && expectedTypes[j][i].getClassDef$() instanceof InstantiatedClassDefinition && (function ($v) { if (! ($v == null || $v instanceof InstantiatedClassDefinition)) { debugger; throw new Error("[src/util.jsx:130:62] detected invalid cast, value is not an instance of the designated type or null\n && (expectedTypes[j][i].getClassDef() as InstantiatedClassDefinition).getTemplateClassName() == \'Array\') {\n ^^\n"); } return $v; }(expectedTypes[j][i].getClassDef$())).getTemplateClassName$() === 'Array') { if (expectedArrayType == null) { expectedArrayType = expectedTypes[j][i]; } else { if (expectedArrayType.equals$LType$(expectedTypes[j][i])) { } else { break; } } } } if (j !== expectedTypes.length) { } else { if (expectedArrayType != null) { arrayExpr.setType$LType$(expectedArrayType); } } } else { if (args[i] instanceof MapLiteralExpression && (function ($v) { if (! ($v == null || $v instanceof MapLiteralExpression)) { debugger; throw new Error("[src/util.jsx:145:75] detected invalid cast, value is not an instance of the designated type or null\n } else if (args[i] instanceof MapLiteralExpression && (args[i] as MapLiteralExpression).getElements().length == 0 && (args[i] as MapLiteralExpression).getType() == null) {\n ^^\n"); } return $v; }(args[i])).getElements$().length === 0 && (function ($v) { if (! ($v == null || $v instanceof MapLiteralExpression)) { debugger; throw new Error("[src/util.jsx:145:138] detected invalid cast, value is not an instance of the designated type or null\n } else if (args[i] instanceof MapLiteralExpression && (args[i] as MapLiteralExpression).getElements().length == 0 && (args[i] as MapLiteralExpression).getType() == null) {\n ^^\n"); } return $v; }(args[i])).getType$() == null) { mapExpr = (function ($v) { if (! ($v == null || $v instanceof MapLiteralExpression)) { debugger; throw new Error("[src/util.jsx:146:38] detected invalid cast, value is not an instance of the designated type or null\n var mapExpr = args[i] as MapLiteralExpression;\n ^^\n"); } return $v; }(args[i])); expectedMapType = null; for (j = 0; j < expectedTypes.length; ++ j) { if (expectedTypes[j][i] != null && expectedTypes[j][i] instanceof ObjectType && expectedTypes[j][i].getClassDef$() instanceof InstantiatedClassDefinition && (function ($v) { if (! ($v == null || $v instanceof InstantiatedClassDefinition)) { debugger; throw new Error("[src/util.jsx:152:62] detected invalid cast, value is not an instance of the designated type or null\n && (expectedTypes[j][i].getClassDef() as InstantiatedClassDefinition).getTemplateClassName() == \'Map\') {\n ^^\n"); } return $v; }(expectedTypes[j][i].getClassDef$())).getTemplateClassName$() === 'Map') { if (expectedMapType == null) { expectedMapType = expectedTypes[j][i]; } else { if (expectedMapType.equals$LType$(expectedTypes[j][i])) { } else { break; } } } } if (j !== expectedTypes.length) { } else { if (expectedMapType != null) { mapExpr.setType$LType$(expectedMapType); } } } } } if (! args[i].analyze$LAnalysisContext$LExpression$(context, parentExpr)) { return null; } argTypes[i] = args[i].getType$(); } return argTypes; }; Util.analyzeArgs$LAnalysisContext$ALExpression$LExpression$AALType$ = Util$analyzeArgs$LAnalysisContext$ALExpression$LExpression$AALType$; function Util$typesAreEqual$ALType$ALType$(x, y) { var i; if (x.length !== y.length) { return false; } for (i = 0; i < x.length; ++ i) { if (! x[i].equals$LType$(y[i])) { return false; } } return true; }; Util.typesAreEqual$ALType$ALType$ = Util$typesAreEqual$ALType$ALType$; function Util$forEachStatement$F$LStatement$B$ALStatement$(cb, statements) { var i; if (statements != null) { for (i = 0; i < statements.length; ++ i) { if (! cb(statements[i])) { return false; } } } return true; }; Util.forEachStatement$F$LStatement$B$ALStatement$ = Util$forEachStatement$F$LStatement$B$ALStatement$; function Util$forEachExpression$F$LExpression$B$ALExpression$(cb, exprs) { return Util$forEachExpression$F$LExpression$F$LExpression$V$B$ALExpression$((function (expr, _) { return cb(expr); }), exprs); }; Util.forEachExpression$F$LExpression$B$ALExpression$ = Util$forEachExpression$F$LExpression$B$ALExpression$; function Util$forEachExpression$F$LExpression$F$LExpression$V$B$ALExpression$(cb, exprs) { var i; if (exprs != null) { for (i = 0; i < exprs.length; ++ i) { if (! cb(exprs[i], (function (exprs, index) { return (function (expr) { exprs[index] = expr; }); })(exprs, i))) { return false; } } } return true; }; Util.forEachExpression$F$LExpression$F$LExpression$V$B$ALExpression$ = Util$forEachExpression$F$LExpression$F$LExpression$V$B$ALExpression$; function Util$findFunctionInClass$LClassDefinition$SALType$B(classDef, funcName, argTypes, isStatic) { var found; found = null; classDef.forEachMemberFunction$F$LMemberFunctionDefinition$B$((function (funcDef) { if (isStatic === ((funcDef.flags$() & ClassDefinition.IS_STATIC) !== 0) && funcDef.name$() === funcName && Util$typesAreEqual$ALType$ALType$(funcDef.getArgumentTypes$(), argTypes)) { found = funcDef; return false; } return true; })); return found; }; Util.findFunctionInClass$LClassDefinition$SALType$B = Util$findFunctionInClass$LClassDefinition$SALType$B; function Util$findVariableInClass$LClassDefinition$SB(classDef, name, isStatic) { var found; found = null; classDef.forEachMemberVariable$F$LMemberVariableDefinition$B$((function (def) { if (isStatic === ((def.flags$() & ClassDefinition.IS_STATIC) !== 0) && def.name$() === name) { found = def; return false; } return true; })); return found; }; Util.findVariableInClass$LClassDefinition$SB = Util$findVariableInClass$LClassDefinition$SB; function Util$findMemberInClass$LClassDefinition$SALType$B(classDef, name, argTypes, isStatic) { if (argTypes != null) { return Util$findFunctionInClass$LClassDefinition$SALType$B(classDef, name, argTypes, isStatic); } else { return Util$findVariableInClass$LClassDefinition$SB(classDef, name, isStatic); } }; Util.findMemberInClass$LClassDefinition$SALType$B = Util$findMemberInClass$LClassDefinition$SALType$B; function Util$memberRootIsNative$LClassDefinition$SALType$B(classDef, name, argTypes, isStatic) { var rootIsNativeNonStatic; if (isStatic) { return (classDef.flags$() & (ClassDefinition.IS_NATIVE | ClassDefinition.IS_FAKE)) !== 0; } function rootIsNativeNonStatic(classDef, name, argTypes) { var found; found = Util$findMemberInClass$LClassDefinition$SALType$B(classDef, name, argTypes, false); if (found != null && (found.flags$() & ClassDefinition.IS_OVERRIDE) === 0) { return (classDef.flags$() & (ClassDefinition.IS_NATIVE | ClassDefinition.IS_FAKE)) !== 0; } if (classDef.extendType$() == null) { return false; } return rootIsNativeNonStatic(classDef.extendType$().getClassDef$(), name, argTypes); } return rootIsNativeNonStatic(classDef, name, argTypes); }; Util.memberRootIsNative$LClassDefinition$SALType$B = Util$memberRootIsNative$LClassDefinition$SALType$B; function Util$propertyRootIsNative$LPropertyExpression$(expr) { var baseExpr; baseExpr = expr.getExpr$(); return Util$memberRootIsNative$LClassDefinition$SALType$B(baseExpr.getType$().getClassDef$(), expr.getIdentifierToken$().getValue$(), Util$isReferringToFunctionDefinition$LPropertyExpression$(expr) ? (function ($v) { if (! ($v == null || $v instanceof ResolvedFunctionType)) { debugger; throw new Error("[src/util.jsx:270:73] detected invalid cast, value is not an instance of the designated type or null\n Util.isReferringToFunctionDefinition(expr) ? (expr.getType() as ResolvedFunctionType).getArgumentTypes() : null,\n ^^\n"); } return $v; }(expr.getType$())).getArgumentTypes$() : null, baseExpr instanceof ClassExpression); }; Util.propertyRootIsNative$LPropertyExpression$ = Util$propertyRootIsNative$LPropertyExpression$; function Util$memberIsExported$LClassDefinition$SALType$B(classDef, name, argTypes, isStatic) { var found; var check; if (isStatic) { found = Util$findMemberInClass$LClassDefinition$SALType$B(classDef, name, argTypes, true); return (found.flags$() & ClassDefinition.IS_EXPORT) !== 0; } function check(classDef) { var found; var isExportedInImpl; if ((classDef.flags$() & ClassDefinition.IS_NATIVE) !== 0) { return false; } found = Util$findMemberInClass$LClassDefinition$SALType$B(classDef, name, argTypes, false); if (found != null && (found.flags$() & ClassDefinition.IS_EXPORT) !== 0) { return true; } if (classDef.extendType$() != null) { if (check(classDef.extendType$().getClassDef$())) { return true; } } isExportedInImpl = false; classDef.implementTypes$().forEach((function (implType) { if (check(implType.getClassDef$())) { isExportedInImpl = true; } })); return isExportedInImpl; } return check(classDef); }; Util.memberIsExported$LClassDefinition$SALType$B = Util$memberIsExported$LClassDefinition$SALType$B; function Util$isReferringToFunctionDefinition$LPropertyExpression$(expr) { var exprType; exprType = expr.getType$(); if (! (exprType instanceof FunctionType)) { return false; } if (exprType.isAssignable$()) { return false; } return true; }; Util.isReferringToFunctionDefinition$LPropertyExpression$ = Util$isReferringToFunctionDefinition$LPropertyExpression$; function Util$encodeStringLiteral$S(str) { var escaped; escaped = str.replace(/[\0-\x19\\'"\u007f-\uffff]/g, (function (ch) { var t; if (ch in Util._stringLiteralEncodingMap) { return (function (v) { if (! (v != null)) { debugger; throw new Error("[src/util.jsx:330:53] null access\n return Util._stringLiteralEncodingMap[ch];\n ^\n"); } return v; }(Util._stringLiteralEncodingMap[ch])); } else { t = "000" + ch.charCodeAt(0).toString(16); t = t.substring(t.length - 4); return "\\u" + t; } })); return "\"" + escaped + "\""; }; Util.encodeStringLiteral$S = Util$encodeStringLiteral$S; function Util$decodeStringLiteral$S(literal) { var matched; var src; var decoded; var pos; var backslashAt; var escapeChar; matched = literal.match(/^([\'\"]).*([\'\"])$/); if (matched == null || matched[1] != matched[2]) { throw new Error("input string is not quoted properly: " + literal); } src = literal.substring(1, literal.length - 1); decoded = ""; pos = 0; while ((backslashAt = src.indexOf("\\", pos)) !== - 1) { decoded += src.substring(pos, backslashAt); pos = backslashAt + 1; if (pos === src.length) { throw new Error("last character within a string literal cannot be a backslash: " + literal); } escapeChar = src.charAt(pos++); switch (escapeChar) { case "'": case "\"": case "\\": decoded += escapeChar; break; case "b": decoded += "\b"; break; case "f": decoded += "\f"; break; case "n": decoded += "\n"; break; case "r": decoded += "\r"; break; case "t": decoded += "\t"; break; case "v": decoded += "\v"; break; case "u": matched = src.substring(pos).match(/^([0-9A-Fa-f]{4})/); if (matched == null) { throw new Error("expected four hexdigits after \\u: " + literal); } decoded += String.fromCharCode($__jsx_parseInt((function (v) { if (! (v != null)) { debugger; throw new Error("[src/util.jsx:371:70] null access\n decoded += String.fromCharCode(Number.parseInt(matched[1], 16));\n ^\n"); } return v; }(matched[1])), 16)); pos += 4; break; case "0": if (pos === src.length || src.charAt(pos).match(/[0-9]/) == null) { decoded += "\0"; } else { throw new Error("found a digit after '\\0': " + literal); } break; } } decoded += src.substring(pos); return decoded; }; Util.decodeStringLiteral$S = Util$decodeStringLiteral$S; function Util$_resolvedPathParts$S(path) { var tokens; var i; tokens = path.split(/[\\\/]+/); if (tokens.length === 1) { return tokens; } for (i = 0; i < tokens.length; ) { if (tokens[i] == ".") { tokens.splice(i, 1); } else { if (tokens[i] == ".." && i !== 0 && tokens[i - 1] != "..") { tokens.splice(i - 1, 2); i -= 1; } else { i++; } } } return tokens; }; Util._resolvedPathParts$S = Util$_resolvedPathParts$S; function Util$resolvePath$S(path) { return Util$_resolvedPathParts$S(path).join("/"); }; Util.resolvePath$S = Util$resolvePath$S; function Util$relativePath$SSB(fromPath, toPath, isFile) { var f; var t; var minLen; var samePartsIndex; var i; var pathParts; f = Util$_resolvedPathParts$S(fromPath); t = Util$_resolvedPathParts$S(toPath); if (isFile) { f.pop(); } if (f[0] == "") { f.shift(); } if (t[0] == "") { t.shift(); } minLen = Math.min(f.length, t.length); samePartsIndex = minLen; for (i = 0; i < minLen; ++ i) { if (f[i] != t[i]) { samePartsIndex = i; break; } } pathParts = []; for (i = samePartsIndex; i < f.length; ++ i) { pathParts.push(".."); } return pathParts.concat(t.slice(samePartsIndex)).join("/"); }; Util.relativePath$SSB = Util$relativePath$SSB; function Util$basename$S(path) { var parts; parts = Util$_resolvedPathParts$S(path); return (function (v) { if (! (v != null)) { debugger; throw new Error("[src/util.jsx:449:24] null access\n return parts.pop();\n ^\n"); } return v; }(parts.pop())); }; Util.basename$S = Util$basename$S; function Util$dirname$S(path) { var parts; parts = Util$_resolvedPathParts$S(path); parts.pop(); return (parts.length !== 0 ? parts.join("/") : "."); }; Util.dirname$S = Util$dirname$S; function Util$toOrdinal$N(n) { if (10 < n && n < 14) { return (n + "") + 'th'; } switch (n % 10) { case 1: return (n + "") + 'st'; case 2: return (n + "") + 'nd'; case 3: return (n + "") + 'rd'; default: return (n + "") + 'th'; } }; Util.toOrdinal$N = Util$toOrdinal$N; function Util$makeErrorMessage$LPlatform$SUSNNN(platform, message, filename, lineNumber, columnNumber, size) { var content; var sourceLine; var TAB_WIDTH; var tabs; if (filename == null) { return message + "\n"; } content = platform.load$S((function (v) { if (! (v != null)) { debugger; throw new Error("[src/util.jsx:475:36] null access\n var content = platform.load(filename);\n ^^^^^^^^\n"); } return v; }(filename))); sourceLine = (function (v) { if (! (v != null)) { debugger; throw new Error("[src/util.jsx:476:44] null access\n var sourceLine = content.split(/\\n/)[ lineNumber - 1 ] + \"\\n\";\n ^\n"); } return v; }(content.split(/\n/)[lineNumber - 1])) + "\n"; TAB_WIDTH = 4; tabs = sourceLine.slice(0, columnNumber).match(/\t/g); if (tabs != null) { columnNumber += (TAB_WIDTH - 1) * tabs.length; } sourceLine = sourceLine.replace(/\t/g, Util$repeat$SN(" ", TAB_WIDTH)); sourceLine += Util$repeat$SN(" ", columnNumber); sourceLine += Util$repeat$SN("^", size); return Util$format$SAS("[%1:%2:%3] %4\n%5\n", [ filename, lineNumber + "", columnNumber + "", message, sourceLine ]); }; Util.makeErrorMessage$LPlatform$SUSNNN = Util$makeErrorMessage$LPlatform$SUSNNN; function Util$isArrayOf$LClassDefinition$LType$(classDef, expectedElementType) { var instantiatedClassDef; if (! (classDef instanceof InstantiatedClassDefinition)) { return false; } instantiatedClassDef = (function ($v) { if (! ($v == null || $v instanceof InstantiatedClassDefinition)) { debugger; throw new Error("[src/util.jsx:496:44] detected invalid cast, value is not an instance of the designated type or null\n var instantiatedClassDef = classDef as InstantiatedClassDefinition;\n ^^\n"); } return $v; }(classDef)); if (instantiatedClassDef.getTemplateClassName$() !== "Array") { return false; } if (! instantiatedClassDef.getTypeArguments$()[0].equals$LType$(expectedElementType)) { return false; } return true; }; Util.isArrayOf$LClassDefinition$LType$ = Util$isArrayOf$LClassDefinition$LType$; function Cloner$Expression$E() { }; $__jsx_extend([Cloner$Expression$E], Object); function Cloner$Expression$E$cloneArray$ALExpression$(a) { var r; var i; r = [ ]; for (i = 0; i < a.length; ++ i) { r[i] = a[i].clone$(); } return r; }; Cloner$Expression$E.cloneArray$ALExpression$ = Cloner$Expression$E$cloneArray$ALExpression$; function Cloner$Expression$E$cloneNullable$LExpression$(o) { return (o == null ? null : o.clone$()); }; Cloner$Expression$E.cloneNullable$LExpression$ = Cloner$Expression$E$cloneNullable$LExpression$; function Serializer$Expression$E() { }; $__jsx_extend([Serializer$Expression$E], Object); function Serializer$Expression$E$serializeArray$ALExpression$(a) { var ret; var i; if (a == null) { return null; } ret = [ ]; for (i = 0; i < a.length; ++ i) { ret[i] = a[i].serialize$(); } return ret; }; Serializer$Expression$E.serializeArray$ALExpression$ = Serializer$Expression$E$serializeArray$ALExpression$; function Serializer$Expression$E$serializeNullable$LExpression$(v) { if (v == null) { return null; } return v.serialize$(); }; Serializer$Expression$E.serializeNullable$LExpression$ = Serializer$Expression$E$serializeNullable$LExpression$; function Serializer$Type$E() { }; $__jsx_extend([Serializer$Type$E], Object); function Serializer$Type$E$serializeArray$ALType$(a) { var ret; var i; if (a == null) { return null; } ret = [ ]; for (i = 0; i < a.length; ++ i) { ret[i] = a[i].serialize$(); } return ret; }; Serializer$Type$E.serializeArray$ALType$ = Serializer$Type$E$serializeArray$ALType$; function Serializer$Type$E$serializeNullable$LType$(v) { if (v == null) { return null; } return v.serialize$(); }; Serializer$Type$E.serializeNullable$LType$ = Serializer$Type$E$serializeNullable$LType$; function Serializer$MapLiteralElement$E() { }; $__jsx_extend([Serializer$MapLiteralElement$E], Object); function Serializer$MapLiteralElement$E$serializeArray$ALMapLiteralElement$(a) { var ret; var i; if (a == null) { return null; } ret = [ ]; for (i = 0; i < a.length; ++ i) { ret[i] = a[i].serialize$(); } return ret; }; Serializer$MapLiteralElement$E.serializeArray$ALMapLiteralElement$ = Serializer$MapLiteralElement$E$serializeArray$ALMapLiteralElement$; function Serializer$MapLiteralElement$E$serializeNullable$LMapLiteralElement$(v) { if (v == null) { return null; } return v.serialize$(); }; Serializer$MapLiteralElement$E.serializeNullable$LMapLiteralElement$ = Serializer$MapLiteralElement$E$serializeNullable$LMapLiteralElement$; function Serializer$ClassDefinition$E() { }; $__jsx_extend([Serializer$ClassDefinition$E], Object); function Serializer$ClassDefinition$E$serializeArray$ALClassDefinition$(a) { var ret; var i; if (a == null) { return null; } ret = [ ]; for (i = 0; i < a.length; ++ i) { ret[i] = a[i].serialize$(); } return ret; }; Serializer$ClassDefinition$E.serializeArray$ALClassDefinition$ = Serializer$ClassDefinition$E$serializeArray$ALClassDefinition$; function Serializer$ClassDefinition$E$serializeNullable$LClassDefinition$(v) { if (v == null) { return null; } return v.serialize$(); }; Serializer$ClassDefinition$E.serializeNullable$LClassDefinition$ = Serializer$ClassDefinition$E$serializeNullable$LClassDefinition$; function Serializer$Token$E() { }; $__jsx_extend([Serializer$Token$E], Object); function Serializer$Token$E$serializeArray$ALToken$(a) { var ret; var i; if (a == null) { return null; } ret = [ ]; for (i = 0; i < a.length; ++ i) { ret[i] = a[i].serialize$(); } return ret; }; Serializer$Token$E.serializeArray$ALToken$ = Serializer$Token$E$serializeArray$ALToken$; function Serializer$Token$E$serializeNullable$LToken$(v) { if (v == null) { return null; } return v.serialize$(); }; Serializer$Token$E.serializeNullable$LToken$ = Serializer$Token$E$serializeNullable$LToken$; function Cloner$Statement$E() { }; $__jsx_extend([Cloner$Statement$E], Object); function Cloner$Statement$E$cloneArray$ALStatement$(a) { var r; var i; r = [ ]; for (i = 0; i < a.length; ++ i) { r[i] = a[i].clone$(); } return r; }; Cloner$Statement$E.cloneArray$ALStatement$ = Cloner$Statement$E$cloneArray$ALStatement$; function Cloner$Statement$E$cloneNullable$LStatement$(o) { return (o == null ? null : o.clone$()); }; Cloner$Statement$E.cloneNullable$LStatement$ = Cloner$Statement$E$cloneNullable$LStatement$; function Serializer$Statement$E() { }; $__jsx_extend([Serializer$Statement$E], Object); function Serializer$Statement$E$serializeArray$ALStatement$(a) { var ret; var i; if (a == null) { return null; } ret = [ ]; for (i = 0; i < a.length; ++ i) { ret[i] = a[i].serialize$(); } return ret; }; Serializer$Statement$E.serializeArra