Skip to content

Commit 8bb4fae

Browse files
authored
Remove local sharing logic (#2540)
1 parent 78b2d1a commit 8bb4fae

File tree

344 files changed

+83325
-76520
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

344 files changed

+83325
-76520
lines changed

cli/index.js

+21-21
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import binaryen from "../lib/binaryen.js";
3737
import * as assemblyscriptJS from "assemblyscript";
3838

3939
// Use the TS->JS variant by default
40-
var assemblyscript = assemblyscriptJS;
40+
let assemblyscript = assemblyscriptJS;
4141

4242
// Use the AS->Wasm variant as an option (experimental)
4343
const wasmPos = process.argv.indexOf("--wasm");
@@ -115,7 +115,7 @@ export function configToArguments(options, argv = []) {
115115
/** Convenience function that parses and compiles source strings directly. */
116116
export async function compileString(sources, config = {}) {
117117
if (typeof sources === "string") sources = { [`input${extension}`]: sources };
118-
var argv = [
118+
let argv = [
119119
"--outFile", "binary",
120120
"--textFile", "text",
121121
];
@@ -182,11 +182,11 @@ export async function main(argv, options) {
182182
);
183183
}
184184

185-
var module = null;
186-
var binaryenModule = null;
185+
let module = null;
186+
let binaryenModule = null;
187187

188188
// Prepares the result object
189-
var prepareResult = (error, result = {}) => {
189+
let prepareResult = (error, result = {}) => {
190190
if (error) {
191191
stderr.write(`${stderrColors.red("FAILURE ")}${error.stack.replace(/^ERROR: /i, "")}${EOL}`);
192192
}
@@ -213,8 +213,8 @@ export async function main(argv, options) {
213213

214214
// Print the help message if requested or no source files are provided
215215
if (opts.help || (!argv.length && !configHasEntries)) {
216-
var out = opts.help ? stdout : stderr;
217-
var colors = opts.help ? stdoutColors : stderrColors;
216+
let out = opts.help ? stdout : stderr;
217+
let colors = opts.help ? stdoutColors : stderrColors;
218218
out.write([
219219
colors.white("SYNTAX"),
220220
" " + colors.cyan("asc") + " [entryFile ...] [options]",
@@ -295,7 +295,7 @@ export async function main(argv, options) {
295295
}
296296

297297
// Set up options
298-
var program, runtime;
298+
let program, runtime;
299299
const compilerOptions = assemblyscript.newOptions();
300300
switch (opts.runtime) {
301301
case "stub": runtime = 0; break;
@@ -358,7 +358,7 @@ export async function main(argv, options) {
358358
}
359359

360360
// Disable default features if specified
361-
var features;
361+
let features;
362362
if ((features = opts.disable) != null) {
363363
if (typeof features === "string") features = features.split(",");
364364
for (let i = 0, k = features.length; i < k; ++i) {
@@ -381,8 +381,8 @@ export async function main(argv, options) {
381381
}
382382

383383
// Set up optimization levels
384-
var optimizeLevel = 0;
385-
var shrinkLevel = 0;
384+
let optimizeLevel = 0;
385+
let shrinkLevel = 0;
386386
if (opts.optimize) {
387387
optimizeLevel = defaultOptimizeLevel;
388388
shrinkLevel = defaultShrinkLevel;
@@ -518,8 +518,8 @@ export async function main(argv, options) {
518518

519519
// Gets the file matching the specified source path, imported at the given dependee path
520520
async function getFile(internalPath, dependeePath) {
521-
var sourceText = null; // text reported back to the compiler
522-
var sourcePath = null; // path reported back to the compiler
521+
let sourceText = null; // text reported back to the compiler
522+
let sourcePath = null; // path reported back to the compiler
523523

524524
// Try file.ext, file/index.ext, file.d.ext
525525
if (!internalPath.startsWith(libraryPrefix)) {
@@ -602,7 +602,7 @@ export async function main(argv, options) {
602602

603603
// Parses the backlog of imported files after including entry files
604604
async function parseBacklog() {
605-
var backlog;
605+
let backlog;
606606
while ((backlog = getBacklog()).length) {
607607
let files = [];
608608
for (let internalPath of backlog) {
@@ -733,7 +733,7 @@ export async function main(argv, options) {
733733
? assemblyscript.getBinaryenModuleRef(module)
734734
: module.ref
735735
);
736-
var numErrors = checkDiagnostics(program, stderr, opts.disableWarning, options.reportDiagnostic, stderrColors.enabled);
736+
let numErrors = checkDiagnostics(program, stderr, opts.disableWarning, options.reportDiagnostic, stderrColors.enabled);
737737
if (numErrors) {
738738
const err = Error(`${numErrors} compile error(s)`);
739739
err.stack = err.message; // omit stack
@@ -1132,7 +1132,7 @@ async function getConfig(file, baseDir, readFile) {
11321132
/** Checks diagnostics emitted so far for errors. */
11331133
export function checkDiagnostics(program, stderr, disableWarning, reportDiagnostic, useColors) {
11341134
if (typeof useColors === "undefined" && stderr) useColors = stderr.isTTY;
1135-
var numErrors = 0;
1135+
let numErrors = 0;
11361136
do {
11371137
let diagnostic = assemblyscript.nextDiagnostic(program);
11381138
if (!diagnostic) break;
@@ -1224,13 +1224,13 @@ export class Stats {
12241224
}
12251225
}
12261226

1227-
var allocBuffer = typeof global !== "undefined" && global.Buffer
1227+
let allocBuffer = typeof global !== "undefined" && global.Buffer
12281228
? global.Buffer.allocUnsafe || (len => new global.Buffer(len))
12291229
: len => new Uint8Array(len);
12301230

12311231
/** Creates a memory stream that can be used in place of stdout/stderr. */
12321232
export function createMemoryStream(fn) {
1233-
var stream = [];
1233+
let stream = [];
12341234
stream.write = function(chunk) {
12351235
if (fn) fn(chunk);
12361236
if (typeof chunk === "string") {
@@ -1244,9 +1244,9 @@ export function createMemoryStream(fn) {
12441244
stream.length = 0;
12451245
};
12461246
stream.toBuffer = function() {
1247-
var offset = 0, i = 0, k = this.length;
1247+
let offset = 0, i = 0, k = this.length;
12481248
while (i < k) offset += this[i++].length;
1249-
var buffer = allocBuffer(offset);
1249+
let buffer = allocBuffer(offset);
12501250
offset = i = 0;
12511251
while (i < k) {
12521252
buffer.set(this[i], offset);
@@ -1256,7 +1256,7 @@ export function createMemoryStream(fn) {
12561256
return buffer;
12571257
};
12581258
stream.toString = function() {
1259-
var buffer = this.toBuffer();
1259+
let buffer = this.toBuffer();
12601260
return utf8.read(buffer, 0, buffer.length);
12611261
};
12621262
return stream;

cli/options.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@
190190
"description": [
191191
"Overrides the stack size. Only relevant for incremental GC",
192192
"or when using a custom runtime that requires stack space.",
193-
"Defaults to 0 without and to 16384 with incremental GC."
193+
"Defaults to 0 without and to 32768 with incremental GC."
194194
],
195195
"default": 0,
196196
"type": "i"

lib/loader/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ function postInstantiate(extendedExports, instance) {
146146
const length = str.length;
147147
const ptr = __new(length << 1, STRING_ID);
148148
const U16 = new Uint16Array(memory.buffer);
149-
for (var i = 0, p = ptr >>> 1; i < length; ++i) U16[p + i] = str.charCodeAt(i);
149+
for (let i = 0, p = ptr >>> 1; i < length; ++i) U16[p + i] = str.charCodeAt(i);
150150
return ptr;
151151
}
152152

lib/loader/tests/assembly/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ export class Car {
4040
}
4141

4242
export function sum(arr: Int32Array): i32 {
43-
var v = 0;
43+
let v = 0;
4444
for (let i = 0, k = arr.length; i < k; ++i) v += arr[i];
4545
return v;
4646
}
4747

4848
export function sumStatic(arr: StaticArray<i32>): i32 {
49-
var v = 0;
49+
let v = 0;
5050
for (let i = 0, k = arr.length; i < k; ++i) v += arr[i];
5151
return v;
5252
}

lib/loader/tests/index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
if (!c) throw Error("assertion failed");
66
}
77
(async () => {
8-
var module;
8+
let module;
99

1010
module = await exports.instantiate(fetch("./build/debug.wasm"));
1111
assert(module.memory);
@@ -25,7 +25,7 @@
2525
module = await exports.instantiateStreaming(await fetch("./build/debug.wasm"));
2626
assert(module.memory);
2727

28-
var instantiateStreaming = WebAssembly.instantiateStreaming;
28+
let instantiateStreaming = WebAssembly.instantiateStreaming;
2929
delete WebAssembly.instantiateStreaming;
3030

3131
module = await exports.instantiate(fetch("./build/debug.wasm"));

lib/loader/tests/index.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ async function wrapToResponse(source) {
2222
}
2323

2424
function test(file) {
25-
var buffer = fs.readFileSync(__dirname + "/build/" + file);
26-
var result = loader.instantiateSync(buffer, {});
25+
let buffer = fs.readFileSync(__dirname + "/build/" + file);
26+
let result = loader.instantiateSync(buffer, {});
2727
const exports = result.exports;
2828

2929
console.log(inspect(exports, true, 100, true));
@@ -251,7 +251,7 @@ function test(file) {
251251
// TBD: table is no more exported by default to allow more optimizations
252252

253253
// should be able to get a function from the table and just call it with variable arguments
254-
// var fn = module.getFunction(module.varadd_ref);
254+
// let fn = module.getFunction(module.varadd_ref);
255255
// assert.strictEqual(fn(), 3);
256256
// assert.strictEqual(fn(2, 3), 5);
257257
// assert.strictEqual(fn(2), 4);
@@ -262,7 +262,7 @@ function test(file) {
262262

263263
// NOTE: Class exports have been removed in 0.20
264264
// should be able to use a class
265-
// var car = new exports.Car(5);
265+
// let car = new exports.Car(5);
266266
// assert.strictEqual(car.numDoors, 5);
267267
// assert.strictEqual(car.isDoorsOpen, 0);
268268
// car.openDoors();

lib/loader/umd/index.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ var loader = (function(exports) {
55
Object.defineProperty(exports, "__esModule", {
66
value: true
77
});
8-
exports.default = void 0;
9-
exports.demangle = demangle;
108
exports.instantiate = instantiate;
11-
exports.instantiateStreaming = instantiateStreaming;
129
exports.instantiateSync = instantiateSync;
10+
exports.instantiateStreaming = instantiateStreaming;
11+
exports.demangle = demangle;
12+
exports.default = void 0;
1313
// Runtime header offsets
1414
const ID_OFFSET = -8;
1515
const SIZE_OFFSET = -4; // Runtime ids
@@ -182,7 +182,7 @@ var loader = (function(exports) {
182182

183183
const U16 = new Uint16Array(memory.buffer);
184184

185-
for (var i = 0, p = ptr >>> 1; i < length; ++i) U16[p + i] = str.charCodeAt(i);
185+
for (let i = 0, p = ptr >>> 1; i < length; ++i) U16[p + i] = str.charCodeAt(i);
186186

187187
return ptr;
188188
}

lib/rtrace/index.js

+15-15
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export class Rtrace {
9393
initial: ((this.memory.buffer.byteLength + PAGE_MASK) & ~PAGE_MASK) >>> PAGE_SIZE_BITS
9494
});
9595
} else {
96-
var diff = this.memory.buffer.byteLength - this.shadow.buffer.byteLength;
96+
let diff = this.memory.buffer.byteLength - this.shadow.buffer.byteLength;
9797
if (diff > 0) this.shadow.grow(diff >>> 16);
9898
}
9999
}
@@ -105,10 +105,10 @@ export class Rtrace {
105105
if (info.ptr < this.shadowStart) {
106106
this.shadowStart = info.ptr;
107107
}
108-
var len = info.size >>> PTR_SIZE_BITS;
109-
var view = new PTR_VIEW(this.shadow.buffer, info.ptr, len);
110-
var errored = false;
111-
var start = oldSize >>> PTR_SIZE_BITS;
108+
let len = info.size >>> PTR_SIZE_BITS;
109+
let view = new PTR_VIEW(this.shadow.buffer, info.ptr, len);
110+
let errored = false;
111+
let start = oldSize >>> PTR_SIZE_BITS;
112112
for (let i = 0; i < start; ++i) {
113113
if (view[i] != info.ptr && !errored) {
114114
this.onerror(Error("shadow region mismatch: " + view[i] + " != " + info.ptr), info);
@@ -128,10 +128,10 @@ export class Rtrace {
128128
/** Unmarks a block's presence in shadow memory. */
129129
unmarkShadow(info, oldSize = info.size) {
130130
assert(this.shadow && this.shadow.byteLength == this.memory.byteLength);
131-
var len = oldSize >>> PTR_SIZE_BITS;
132-
var view = new PTR_VIEW(this.shadow.buffer, info.ptr, len);
133-
var errored = false;
134-
var start = 0;
131+
let len = oldSize >>> PTR_SIZE_BITS;
132+
let view = new PTR_VIEW(this.shadow.buffer, info.ptr, len);
133+
let errored = false;
134+
let start = 0;
135135
if (oldSize != info.size) {
136136
assert(oldSize > info.size);
137137
start = info.size >>> PTR_SIZE_BITS;
@@ -149,7 +149,7 @@ export class Rtrace {
149149
accessShadow(ptr, size, isLoad, isRT) {
150150
this.syncShadow();
151151
if (ptr < this.shadowStart) return;
152-
var value = new Uint32Array(this.shadow.buffer, ptr & ~PTR_MASK, 1)[0];
152+
let value = new Uint32Array(this.shadow.buffer, ptr & ~PTR_MASK, 1)[0];
153153
if (value != 0) return;
154154
if (!isRT) {
155155
let stack = trimStacktrace(new Error().stack, 2);
@@ -211,7 +211,7 @@ export class Rtrace {
211211
onalloc(ptr) {
212212
this.syncShadow();
213213
++this.allocCount;
214-
var info = this.getBlockInfo(ptr);
214+
let info = this.getBlockInfo(ptr);
215215
if (this.blocks.has(ptr)) {
216216
this.onerror(Error("duplicate alloc: " + ptr), info);
217217
} else {
@@ -247,8 +247,8 @@ export class Rtrace {
247247
onmove(oldPtr, newPtr) {
248248
this.syncShadow();
249249
++this.moveCount;
250-
var oldInfo = this.getBlockInfo(oldPtr);
251-
var newInfo = this.getBlockInfo(newPtr);
250+
let oldInfo = this.getBlockInfo(oldPtr);
251+
let newInfo = this.getBlockInfo(newPtr);
252252
if (!this.blocks.has(oldPtr)) {
253253
this.onerror(Error("orphaned move (old): " + oldPtr), oldInfo);
254254
} else {
@@ -285,7 +285,7 @@ export class Rtrace {
285285
onfree(ptr) {
286286
this.syncShadow();
287287
++this.freeCount;
288-
var info = this.getBlockInfo(ptr);
288+
let info = this.getBlockInfo(ptr);
289289
if (!this.blocks.has(ptr)) {
290290
this.onerror(Error("orphaned free: " + ptr), info);
291291
} else {
@@ -323,7 +323,7 @@ export class Rtrace {
323323
}
324324

325325
onyield(total) {
326-
var pause = hrtime() - this.interruptStart;
326+
let pause = hrtime() - this.interruptStart;
327327
if (pause >= 1) console.log("interrupted for " + pause.toFixed(1) + "ms");
328328
this.plot(total, pause);
329329
}

scripts/build-dts.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,9 @@ OutputStream.prototype.toString = function () {
426426
};
427427

428428
function transformTypes(sourceFile) {
429-
var numReplaced = 0;
429+
let numReplaced = 0;
430430
console.log("transforming:");
431-
var result = ts.transform(sourceFile, [
431+
let result = ts.transform(sourceFile, [
432432
function (context) {
433433
const visit = node => {
434434
node = ts.visitEachChild(node, visit, context);

scripts/build.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,10 @@ const diagnosticsPlugin = {
134134
out.push("/** Enum of available diagnostic codes. */\n");
135135
out.push("export enum DiagnosticCode {\n");
136136

137-
var first = true;
137+
let first = true;
138138
const messages = JSON.parse(fs.readFileSync(path.join(dirname, "..", "src", "diagnosticMessages.json")));
139139
Object.keys(messages).forEach(text => {
140-
var key = makeKey(text);
140+
let key = makeKey(text);
141141
if (first)
142142
first = false;
143143
else {
@@ -233,7 +233,7 @@ const cliBuild = esbuild.build({
233233

234234
// Optionally build definitions (takes a while)
235235

236-
var buildingDefinitions = false;
236+
let buildingDefinitions = false;
237237

238238
function buildDefinitions() {
239239
const startTime = Date.now();

scripts/hexfloat.html

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ <h1>Hexadecimal float to decimal float converter</h1>
2121
<script src="hexfloat.js"></script>
2222
<script>
2323
function convert(form) {
24-
var isF64 = document.getElementById("f64").checked;
25-
var pre = document.getElementById("pre").value;
26-
var post = document.getElementById("post").value;
27-
var input = document.getElementById("input").value;
24+
let isF64 = document.getElementById("f64").checked;
25+
let pre = document.getElementById("pre").value;
26+
let post = document.getElementById("post").value;
27+
let input = document.getElementById("input").value;
2828
document.getElementById("output").value = input
2929
.replace(/\b(\-?0x[0-9a-fA-F]*(?:\.[0-9a-fA-F]+)?[pP][+-]?[0-9]+\b)/g, ($0, $1) => {
30-
var val = parse($1);
30+
let val = parse($1);
3131
return val.toPrecision(isF64 ? 18 : 10);
3232
})
3333
.replace(/(\d\.[0-9])0+\b/g, "$1")

0 commit comments

Comments
 (0)