Revert "Deno.bundle supports targets < ES2017. (#6328)" (#6342)

This reverts commit 75bb9dbdfc.
This commit is contained in:
Bartek Iwańczuk 2020-06-17 19:44:40 +02:00 committed by GitHub
parent 75bb9dbdfc
commit e60922981b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 169 additions and 414 deletions

View file

@ -307,10 +307,6 @@ class Host implements ts.CompilerHost {
} }
} }
get options(): ts.CompilerOptions {
return this.#options;
}
configure( configure(
cwd: string, cwd: string,
path: string, path: string,
@ -532,7 +528,6 @@ const _TS_SNAPSHOT_PROGRAM = ts.createProgram({
// This function is called only during snapshotting process // This function is called only during snapshotting process
const SYSTEM_LOADER = getAsset("system_loader.js"); const SYSTEM_LOADER = getAsset("system_loader.js");
const SYSTEM_LOADER_ES5 = getAsset("system_loader_es5.js");
function buildLocalSourceFileCache( function buildLocalSourceFileCache(
sourceFileMap: Record<string, SourceFileMapEntry> sourceFileMap: Record<string, SourceFileMapEntry>
@ -688,12 +683,7 @@ function createBundleWriteFile(state: WriteFileState): WriteFileCallback {
assert(state.bundle); assert(state.bundle);
// we only support single root names for bundles // we only support single root names for bundles
assert(state.rootNames.length === 1); assert(state.rootNames.length === 1);
state.bundleOutput = buildBundle( state.bundleOutput = buildBundle(state.rootNames[0], data, sourceFiles);
state.rootNames[0],
data,
sourceFiles,
state.host.options.target ?? ts.ScriptTarget.ESNext
);
}; };
} }
@ -959,8 +949,7 @@ function normalizeUrl(rootName: string): string {
function buildBundle( function buildBundle(
rootName: string, rootName: string,
data: string, data: string,
sourceFiles: readonly ts.SourceFile[], sourceFiles: readonly ts.SourceFile[]
target: ts.ScriptTarget
): string { ): string {
// when outputting to AMD and a single outfile, TypeScript makes up the module // when outputting to AMD and a single outfile, TypeScript makes up the module
// specifiers which are used to define the modules, and doesn't expose them // specifiers which are used to define the modules, and doesn't expose them
@ -978,8 +967,8 @@ function buildBundle(
let instantiate: string; let instantiate: string;
if (rootExports && rootExports.length) { if (rootExports && rootExports.length) {
instantiate = hasTla instantiate = hasTla
? `const __exp = await __instantiate("${rootName}", true);\n` ? `const __exp = await __instantiateAsync("${rootName}");\n`
: `const __exp = __instantiate("${rootName}", false);\n`; : `const __exp = __instantiate("${rootName}");\n`;
for (const rootExport of rootExports) { for (const rootExport of rootExports) {
if (rootExport === "default") { if (rootExport === "default") {
instantiate += `export default __exp["${rootExport}"];\n`; instantiate += `export default __exp["${rootExport}"];\n`;
@ -989,19 +978,10 @@ function buildBundle(
} }
} else { } else {
instantiate = hasTla instantiate = hasTla
? `await __instantiate("${rootName}", true);\n` ? `await __instantiateAsync("${rootName}");\n`
: `__instantiate("${rootName}", false);\n`; : `__instantiate("${rootName}");\n`;
} }
const es5Bundle = return `${SYSTEM_LOADER}\n${data}\n${instantiate}`;
target === ts.ScriptTarget.ES3 ||
target === ts.ScriptTarget.ES5 ||
target === ts.ScriptTarget.ES2015 ||
target === ts.ScriptTarget.ES2016
? true
: false;
return `${
es5Bundle ? SYSTEM_LOADER_ES5 : SYSTEM_LOADER
}\n${data}\n${instantiate}`;
} }
function setRootExports(program: ts.Program, rootModule: string): void { function setRootExports(program: ts.Program, rootModule: string): void {

View file

@ -1,5 +1,6 @@
[WILDCARD] [WILDCARD]
let System, __instantiate; let System, __instantiateAsync, __instantiate;
[WILDCARD]
(() => { (() => {
[WILDCARD] [WILDCARD]
})(); })();
@ -14,7 +15,7 @@ System.register("mod1", ["subdir2/mod2"], function (exports_3, context_3) {
[WILDCARD] [WILDCARD]
}); });
const __exp = __instantiate("mod1", false); const __exp = __instantiate("mod1");
export const returnsHi = __exp["returnsHi"]; export const returnsHi = __exp["returnsHi"];
export const returnsFoo2 = __exp["returnsFoo2"]; export const returnsFoo2 = __exp["returnsFoo2"];
export const printHello3 = __exp["printHello3"]; export const printHello3 = __exp["printHello3"];

View file

@ -1,201 +1,150 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { assert, assertEquals } from "../../std/testing/asserts.ts"; import { assert, assertEquals } from "../../std/testing/asserts.ts";
Deno.test({ Deno.test("compilerApiCompileSources", async function () {
name: "Deno.compile() - sources provided", const [diagnostics, actual] = await Deno.compile("/foo.ts", {
async fn() { "/foo.ts": `import * as bar from "./bar.ts";\n\nconsole.log(bar);\n`,
const [diagnostics, actual] = await Deno.compile("/foo.ts", { "/bar.ts": `export const bar = "bar";\n`,
"/foo.ts": `import * as bar from "./bar.ts";\n\nconsole.log(bar);\n`, });
"/bar.ts": `export const bar = "bar";\n`, assert(diagnostics == null);
}); assert(actual);
assert(diagnostics == null); assertEquals(Object.keys(actual), [
assert(actual); "/bar.js.map",
assertEquals(Object.keys(actual), [ "/bar.js",
"/bar.js.map", "/foo.js.map",
"/bar.js", "/foo.js",
"/foo.js.map", ]);
"/foo.js",
]);
},
}); });
Deno.test({ Deno.test("compilerApiCompileNoSources", async function () {
name: "Deno.compile() - no sources provided", const [diagnostics, actual] = await Deno.compile("./subdir/mod1.ts");
async fn() { assert(diagnostics == null);
const [diagnostics, actual] = await Deno.compile("./subdir/mod1.ts"); assert(actual);
assert(diagnostics == null); const keys = Object.keys(actual);
assert(actual); assertEquals(keys.length, 6);
const keys = Object.keys(actual); assert(keys[0].endsWith("print_hello.js.map"));
assertEquals(keys.length, 6); assert(keys[1].endsWith("print_hello.js"));
assert(keys[0].endsWith("print_hello.js.map"));
assert(keys[1].endsWith("print_hello.js"));
},
}); });
Deno.test({ Deno.test("compilerApiCompileOptions", async function () {
name: "Deno.compile() - compiler options effects imit", const [diagnostics, actual] = await Deno.compile(
async fn() { "/foo.ts",
const [diagnostics, actual] = await Deno.compile( {
"/foo.ts", "/foo.ts": `export const foo = "foo";`,
{ },
"/foo.ts": `export const foo = "foo";`, {
}, module: "amd",
{ sourceMap: false,
module: "amd", }
sourceMap: false, );
} assert(diagnostics == null);
); assert(actual);
assert(diagnostics == null); assertEquals(Object.keys(actual), ["/foo.js"]);
assert(actual); assert(actual["/foo.js"].startsWith("define("));
assertEquals(Object.keys(actual), ["/foo.js"]);
assert(actual["/foo.js"].startsWith("define("));
},
}); });
Deno.test({ Deno.test("compilerApiCompileLib", async function () {
name: "Deno.compile() - pass lib in compiler options", const [diagnostics, actual] = await Deno.compile(
async fn() { "/foo.ts",
const [diagnostics, actual] = await Deno.compile( {
"/foo.ts", "/foo.ts": `console.log(document.getElementById("foo"));
{
"/foo.ts": `console.log(document.getElementById("foo"));
console.log(Deno.args);`, console.log(Deno.args);`,
}, },
{ {
lib: ["dom", "es2018", "deno.ns"], lib: ["dom", "es2018", "deno.ns"],
} }
); );
assert(diagnostics == null); assert(diagnostics == null);
assert(actual); assert(actual);
assertEquals(Object.keys(actual), ["/foo.js.map", "/foo.js"]); assertEquals(Object.keys(actual), ["/foo.js.map", "/foo.js"]);
},
}); });
Deno.test({ Deno.test("compilerApiCompileTypes", async function () {
name: "Deno.compile() - properly handles .d.ts files", const [diagnostics, actual] = await Deno.compile(
async fn() { "/foo.ts",
const [diagnostics, actual] = await Deno.compile( {
"/foo.ts", "/foo.ts": `console.log(Foo.bar);`,
{ },
"/foo.ts": `console.log(Foo.bar);`, {
}, types: ["./subdir/foo_types.d.ts"],
{ }
types: ["./subdir/foo_types.d.ts"], );
} assert(diagnostics == null);
); assert(actual);
assert(diagnostics == null); assertEquals(Object.keys(actual), ["/foo.js.map", "/foo.js"]);
assert(actual);
assertEquals(Object.keys(actual), ["/foo.js.map", "/foo.js"]);
},
}); });
Deno.test({ Deno.test("transpileOnlyApi", async function () {
name: "Deno.transpileOnly()", const actual = await Deno.transpileOnly({
async fn() { "foo.ts": `export enum Foo { Foo, Bar, Baz };\n`,
const actual = await Deno.transpileOnly({ });
assert(actual);
assertEquals(Object.keys(actual), ["foo.ts"]);
assert(actual["foo.ts"].source.startsWith("export var Foo;"));
assert(actual["foo.ts"].map);
});
Deno.test("transpileOnlyApiConfig", async function () {
const actual = await Deno.transpileOnly(
{
"foo.ts": `export enum Foo { Foo, Bar, Baz };\n`, "foo.ts": `export enum Foo { Foo, Bar, Baz };\n`,
}); },
assert(actual); {
assertEquals(Object.keys(actual), ["foo.ts"]); sourceMap: false,
assert(actual["foo.ts"].source.startsWith("export var Foo;")); module: "amd",
assert(actual["foo.ts"].map); }
}, );
assert(actual);
assertEquals(Object.keys(actual), ["foo.ts"]);
assert(actual["foo.ts"].source.startsWith("define("));
assert(actual["foo.ts"].map == null);
}); });
Deno.test({ Deno.test("bundleApiSources", async function () {
name: "Deno.transpileOnly() - config effects commit", const [diagnostics, actual] = await Deno.bundle("/foo.ts", {
async fn() { "/foo.ts": `export * from "./bar.ts";\n`,
const actual = await Deno.transpileOnly( "/bar.ts": `export const bar = "bar";\n`,
{ });
"foo.ts": `export enum Foo { Foo, Bar, Baz };\n`, assert(diagnostics == null);
}, assert(actual.includes(`__instantiate("foo")`));
{ assert(actual.includes(`__exp["bar"]`));
sourceMap: false,
module: "amd",
}
);
assert(actual);
assertEquals(Object.keys(actual), ["foo.ts"]);
assert(actual["foo.ts"].source.startsWith("define("));
assert(actual["foo.ts"].map == null);
},
}); });
Deno.test({ Deno.test("bundleApiNoSources", async function () {
name: "Deno.bundle() - sources passed", const [diagnostics, actual] = await Deno.bundle("./subdir/mod1.ts");
async fn() { assert(diagnostics == null);
const [diagnostics, actual] = await Deno.bundle("/foo.ts", { assert(actual.includes(`__instantiate("mod1")`));
"/foo.ts": `export * from "./bar.ts";\n`, assert(actual.includes(`__exp["printHello3"]`));
});
Deno.test("bundleApiConfig", async function () {
const [diagnostics, actual] = await Deno.bundle(
"/foo.ts",
{
"/foo.ts": `// random comment\nexport * from "./bar.ts";\n`,
"/bar.ts": `export const bar = "bar";\n`, "/bar.ts": `export const bar = "bar";\n`,
}); },
assert(diagnostics == null); {
assert(actual.includes(`__instantiate("foo", false)`)); removeComments: true,
assert(actual.includes(`__exp["bar"]`)); }
}, );
assert(diagnostics == null);
assert(!actual.includes(`random`));
}); });
Deno.test({ Deno.test("bundleApiJsModules", async function () {
name: "Deno.bundle() - no sources passed", const [diagnostics, actual] = await Deno.bundle("/foo.js", {
async fn() { "/foo.js": `export * from "./bar.js";\n`,
const [diagnostics, actual] = await Deno.bundle("./subdir/mod1.ts"); "/bar.js": `export const bar = "bar";\n`,
assert(diagnostics == null); });
assert(actual.includes(`__instantiate("mod1", false)`)); assert(diagnostics == null);
assert(actual.includes(`__exp["printHello3"]`)); assert(actual.includes(`System.register("bar",`));
},
}); });
Deno.test({ Deno.test("diagnosticsTest", async function () {
name: "Deno.bundle() - compiler config effects emit", const [diagnostics] = await Deno.compile("/foo.ts", {
async fn() { "/foo.ts": `document.getElementById("foo");`,
const [diagnostics, actual] = await Deno.bundle( });
"/foo.ts", assert(Array.isArray(diagnostics));
{ assert(diagnostics.length === 1);
"/foo.ts": `// random comment\nexport * from "./bar.ts";\n`,
"/bar.ts": `export const bar = "bar";\n`,
},
{
removeComments: true,
}
);
assert(diagnostics == null);
assert(!actual.includes(`random`));
},
});
Deno.test({
name: "Deno.bundle() - JS Modules included",
async fn() {
const [diagnostics, actual] = await Deno.bundle("/foo.js", {
"/foo.js": `export * from "./bar.js";\n`,
"/bar.js": `export const bar = "bar";\n`,
});
assert(diagnostics == null);
assert(actual.includes(`System.register("bar",`));
},
});
Deno.test({
name: "Deno.bundle - pre ES2017 uses ES5 loader",
async fn() {
const [diagnostics, actual] = await Deno.bundle(
"/foo.ts",
{
"/foo.ts": `console.log("hello world!")\n`,
},
{ target: "es2015" }
);
assert(diagnostics == null);
assert(actual.includes(`var __awaiter = `));
},
});
Deno.test({
name: "runtime compiler APIs diagnostics",
async fn() {
const [diagnostics] = await Deno.compile("/foo.ts", {
"/foo.ts": `document.getElementById("foo");`,
});
assert(Array.isArray(diagnostics));
assert(diagnostics.length === 1);
},
}); });

View file

@ -69,14 +69,9 @@ At the time of this writing, while V8 and other JavaScript engines have
implemented top-level-await, no browsers have it implemented, meaning that most implemented top-level-await, no browsers have it implemented, meaning that most
browsers could not consume modules that require top-level-await. browsers could not consume modules that require top-level-await.
In order to allow more browsers to consume bundles, there is an argument that is In order to facilitate this, there are two functions that are in the scope of
passed to the `__instantiate()` function which determines if the code is the module in addition to the `System.register()` method. `__instantiate(main)`
bootstrapped asynchronously or not. When emitting a bundle that contains a will bootstrap everything synchronously and `__instantiateAsync(main)` will do
module that requires top-level-await, Deno will detect this and utilise so asynchronously. When emitting a bundle that contains a module that requires
`await __instantiate(main, true)`. top-level-await, Deno will detect this and utilise
`await __instantiateAsync(main)` instead.
The `system_loader_es5.js` is a transpiled version of `system_loader.js` that is
designed to work with ES5 or later, and will be used when the bundle target is <
ES2017. While ES3 is still a potential target which can be passed in a
`tsconfig.json` to Deno, any resulting bundle will not be compatible, as there
is a need to utilise items like `Object.defineProperty()`.

View file

@ -208,7 +208,7 @@ pub fn mksnapshot_bundle(
js_check( js_check(
isolate.execute(&bundle_filename.to_string_lossy(), bundle_source_code), isolate.execute(&bundle_filename.to_string_lossy(), bundle_source_code),
); );
let script = &format!("__instantiate(\"{}\", false);", main_module_name); let script = &format!("__instantiate(\"{}\");", main_module_name);
js_check(isolate.execute("anon", script)); js_check(isolate.execute("anon", script));
write_snapshot(isolate, snapshot_filename)?; write_snapshot(isolate, snapshot_filename)?;
Ok(()) Ok(())
@ -252,7 +252,6 @@ pub fn get_asset(name: &str) -> Option<&'static str> {
} }
match name { match name {
"system_loader.js" => Some(include_str!("system_loader.js")), "system_loader.js" => Some(include_str!("system_loader.js")),
"system_loader_es5.js" => Some(include_str!("system_loader_es5.js")),
"bootstrap.ts" => Some("console.log(\"hello deno\");"), "bootstrap.ts" => Some("console.log(\"hello deno\");"),
"typescript.d.ts" => inc!("typescript.d.ts"), "typescript.d.ts" => inc!("typescript.d.ts"),
"lib.dom.d.ts" => inc!("lib.dom.d.ts"), "lib.dom.d.ts" => inc!("lib.dom.d.ts"),

View file

@ -6,14 +6,17 @@
// @ts-nocheck // @ts-nocheck
/* eslint-disable */ /* eslint-disable */
let System, __instantiate; let System, __instantiateAsync, __instantiate;
(() => { (() => {
const r = Object.create(null); const r = new Map();
System = { System = {
register(id, d, f) { register(id, d, f) {
r[id] = { d, f, exp: {} }; r.set(id, { d, f, exp: {} });
}, },
}; };
async function dI(mid, src) { async function dI(mid, src) {
let id = mid.replace(/\.\w+$/i, ""); let id = mid.replace(/\.\w+$/i, "");
if (id.includes("./")) { if (id.includes("./")) {
@ -30,8 +33,9 @@ let System, __instantiate;
if (s < sa.length) oa.push(...sa.slice(s)); if (s < sa.length) oa.push(...sa.slice(s));
id = oa.reverse().join("/"); id = oa.reverse().join("/");
} }
return id in r ? gExpA(id) : import(mid); return r.has(id) ? gExpA(id) : import(mid);
} }
function gC(id, main) { function gC(id, main) {
return { return {
id, id,
@ -39,6 +43,7 @@ let System, __instantiate;
meta: { url: id, main }, meta: { url: id, main },
}; };
} }
function gE(exp) { function gE(exp) {
return (id, v) => { return (id, v) => {
v = typeof id === "string" ? { [id]: v } : id; v = typeof id === "string" ? { [id]: v } : id;
@ -51,10 +56,9 @@ let System, __instantiate;
} }
}; };
} }
function rF(main) { function rF(main) {
let m; for (const [id, m] of r.entries()) {
for (const id in r) {
m = r[id];
const { f, exp } = m; const { f, exp } = m;
const { execute: e, setters: s } = f(gE(exp), gC(id, id === main)); const { execute: e, setters: s } = f(gE(exp), gC(id, id === main));
delete m.f; delete m.f;
@ -62,9 +66,10 @@ let System, __instantiate;
m.s = s; m.s = s;
} }
} }
async function gExpA(id) { async function gExpA(id) {
if (!(id in r)) return; if (!r.has(id)) return;
const m = r[id]; const m = r.get(id);
if (m.s) { if (m.s) {
const { d, e, s } = m; const { d, e, s } = m;
delete m.s; delete m.s;
@ -75,9 +80,10 @@ let System, __instantiate;
} }
return m.exp; return m.exp;
} }
function gExp(id) { function gExp(id) {
if (!(id in r)) return; if (!r.has(id)) return;
const m = r[id]; const m = r.get(id);
if (m.s) { if (m.s) {
const { d, e, s } = m; const { d, e, s } = m;
delete m.s; delete m.s;
@ -87,9 +93,16 @@ let System, __instantiate;
} }
return m.exp; return m.exp;
} }
__instantiate = (m, a) => {
System = __instantiate = undefined; __instantiateAsync = async (m) => {
System = __instantiateAsync = __instantiate = undefined;
rF(m); rF(m);
return a ? gExpA(m) : gExp(m); return gExpA(m);
};
__instantiate = (m) => {
System = __instantiateAsync = __instantiate = undefined;
rF(m);
return gExp(m);
}; };
})(); })();

View file

@ -1,182 +0,0 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
// This is a specialised implementation of a System module loader.
"use strict";
// @ts-nocheck
/* eslint-disable */
var System, __instantiate;
(function () {
// prettier-ignore
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
// prettier-ignore
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var r = Object.create(null);
System = {
register: function (id, d, f) {
r[id] = { d: d, f: f, exp: {} };
},
};
function dI(mid, src) {
return __awaiter(this, void 0, void 0, function () {
var id, _a, o, ia, _b, sa, oa, s, i;
return __generator(this, function (_c) {
id = mid.replace(/\.\w+$/i, "");
if (id.includes("./")) {
(_a = id.split("/").reverse()),
(o = _a[0]),
(ia = _a.slice(1)),
(_b = src.split("/").reverse()),
(sa = _b.slice(1)),
(oa = [o]);
(s = 0), (i = void 0);
while ((i = ia.shift())) {
if (i === "..") s++;
else if (i === ".") break;
else oa.push(i);
}
if (s < sa.length) oa.push.apply(oa, sa.slice(s));
id = oa.reverse().join("/");
}
return [
2,
id in r
? gExpA(id)
: Promise.resolve().then(function () {
return require(mid);
}),
];
});
});
}
function gC(id, main) {
return {
id: id,
import: function (m) {
return dI(m, id);
},
meta: { url: id, main: main },
};
}
function gE(exp) {
return function (id, v) {
var _a;
v = typeof id === "string" ? ((_a = {}), (_a[id] = v), _a) : id;
for (var _i = 0, _b = Object.entries(v); _i < _b.length; _i++) {
var _c = _b[_i],
id_1 = _c[0],
value = _c[1];
Object.defineProperty(exp, id_1, {
value: value,
writable: true,
enumerable: true,
});
}
};
}
function rF(main) {
var m;
for (var id in r) {
m = r[id];
var f = m.f,
exp = m.exp;
var _a = f(gE(exp), gC(id, id === main)),
e = _a.execute,
s = _a.setters;
delete m.f;
m.e = e;
m.s = s;
}
}
function gExpA(id) {
return __awaiter(this, void 0, void 0, function () {
var m, d, e, s, i, _a, _b, r_1;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
if (!(id in r)) return [2];
m = r[id];
if (!m.s) return [3, 6];
(d = m.d), (e = m.e), (s = m.s);
delete m.s;
delete m.e;
i = 0;
_c.label = 1;
case 1:
if (!(i < s.length)) return [3, 4];
_b = (_a = s)[i];
return [4, gExpA(d[i])];
case 2:
_b.apply(_a, [_c.sent()]);
_c.label = 3;
case 3:
i++;
return [3, 1];
case 4:
r_1 = e();
if (!r_1) return [3, 6];
return [4, r_1];
case 5:
_c.sent();
_c.label = 6;
case 6:
return [2, m.exp];
}
});
});
}
function gExp(id) {
if (!(id in r)) return;
var m = r[id];
if (m.s) {
var d = m.d,
e = m.e,
s = m.s;
delete m.s;
delete m.e;
for (var i = 0; i < s.length; i++) s[i](gExp(d[i]));
e();
}
return m.exp;
}
__instantiate = function (m, a) {
System = __instantiate = undefined;
rF(m);
return a ? gExpA(m) : gExp(m);
};
})();