@yowasp/yosys 0.38.52-dev.660 → 0.39.37-dev.676

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -17,7 +17,7 @@ API reference
17
17
 
18
18
  This package provides one function:
19
19
 
20
- - `runYosys` (alias `cmd:yosys`)
20
+ - `runYosys`
21
21
 
22
22
  For more detail, see the documentation for [the JavaScript YoWASP runtime](https://github.com/YoWASP/runtime-js#api-reference).
23
23
 
@@ -31,8 +31,8 @@ The version of this package is derived from the upstream Yosys package version i
31
31
  2. `Y`: Yosys minor version
32
32
  3. `Z`: Yosys patch version; ignored if present
33
33
  4. `N`: matches the `N` in the `X.Y+N` upstream version, if present
34
- 5. `M`: package build version; disambiguates different builds produced from the same Yosys source tree
35
- 6. `-dev`: present only for packages built from unreleased Yosys snapshots; marks these packages as pre-releases
34
+ 5. `-dev`: present only for packages built from unreleased Yosys snapshots; marks these packages as pre-releases
35
+ 6. `M`: package build version; disambiguates different builds produced from the same Yosys source tree
36
36
 
37
37
  With this scheme, there is a direct correspondence between upstream versions and [SemVer][semver] NPM package versions.
38
38
 
package/gen/bundle.js CHANGED
@@ -86,6 +86,20 @@ var OutputStream = class {
86
86
  this.blockingFlush();
87
87
  }
88
88
  };
89
+ var CallbackInputStream = class extends InputStream {
90
+ constructor(callback = null) {
91
+ super();
92
+ this.callback = callback;
93
+ }
94
+ read(len) {
95
+ if (this.callback === null)
96
+ throw { tag: "closed" };
97
+ let contents = this.callback(Number(len));
98
+ if (contents === null)
99
+ throw { tag: "closed" };
100
+ return contents;
101
+ }
102
+ };
89
103
  var CallbackOutputStream = class extends OutputStream {
90
104
  constructor(callback = null) {
91
105
  super();
@@ -326,7 +340,7 @@ var Environment = class {
326
340
  root = new Directory({});
327
341
  constructor() {
328
342
  this.prng = new Xoroshiro128StarStar(1n);
329
- this.standardInputStream = new InputStream();
343
+ this.standardInputStream = new CallbackInputStream();
330
344
  this.standardOutputStream = new CallbackOutputStream();
331
345
  this.standardErrorStream = new CallbackOutputStream();
332
346
  this.terminalInput = new TerminalInput();
@@ -393,6 +407,12 @@ var Environment = class {
393
407
  }
394
408
  };
395
409
  }
410
+ get stdin() {
411
+ return this.standardInputStream.callback;
412
+ }
413
+ set stdin(callback) {
414
+ this.standardInputStream.callback = callback;
415
+ }
396
416
  get stdout() {
397
417
  return this.standardOutputStream.callback;
398
418
  }
@@ -466,23 +486,26 @@ var Application = class {
466
486
  this.instantiate = instantiate2;
467
487
  this.argv0 = argv0;
468
488
  }
469
- // The `printLine` option is deprecated and not documented but still accepted for compatibility.
470
- async run(args = null, files = {}, { stdout, stderr, decodeASCII = true, printLine } = {}) {
489
+ async preload() {
471
490
  if (this.resourceData === null)
472
491
  this.resourceData = await this.resources().then(fetchResources);
473
- if (args === null)
474
- return;
492
+ }
493
+ // The `printLine` option is deprecated and not documented but still accepted for compatibility.
494
+ execute(args, files = {}, { stdin, stdout, stderr, decodeASCII = true, printLine } = {}) {
475
495
  const environment = new Environment();
476
496
  environment.args = [this.argv0].concat(args);
477
497
  environment.root = directoryFromTree(files);
478
498
  for (const [dirName, dirContents] of Object.entries(this.resourceData.filesystem))
479
499
  environment.root.files[dirName] = directoryFromTree(dirContents);
480
500
  const lineBufferedConsole = lineBuffered(printLine ?? console.log);
501
+ environment.stdin = stdin === void 0 ? null : stdin;
481
502
  environment.stdout = stdout === void 0 ? lineBufferedConsole : stdout;
482
503
  environment.stderr = stderr === void 0 ? lineBufferedConsole : stderr;
483
- const wasmCommand = await this.instantiate(
504
+ const wasmCommand = this.instantiate(
484
505
  (filename) => this.resourceData.modules[filename],
485
- { runtime: environment.exports }
506
+ { runtime: environment.exports },
507
+ // workaround for bytecodealliance/jco#374
508
+ (module, imports) => new WebAssembly.Instance(module, imports)
486
509
  );
487
510
  let error = null;
488
511
  try {
@@ -503,6 +526,13 @@ var Application = class {
503
526
  return files;
504
527
  }
505
528
  }
529
+ run(args = null, files = {}, options = {}) {
530
+ if (this.resourceData === null)
531
+ return this.preload().then((_) => this.run(args, files, options));
532
+ if (args === null)
533
+ return;
534
+ return this.execute(args, files, options);
535
+ }
506
536
  };
507
537
 
508
538
  // gen/yosys.js
@@ -552,7 +582,7 @@ function utf8Encode(s, realloc, memory) {
552
582
  utf8EncodedLen = writtenTotal;
553
583
  return ptr;
554
584
  }
555
- async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.instantiate) {
585
+ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.Instance) {
556
586
  const module0 = getCoreModule("yosys.core.wasm");
557
587
  const module1 = getCoreModule("yosys.core2.wasm");
558
588
  const module2 = getCoreModule("yosys.core3.wasm");
@@ -4426,10 +4456,8 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
4426
4456
  handleEntry.rep[symbolDispose]();
4427
4457
  }
4428
4458
  }
4429
- Promise.all([module0, module1, module2, module3]).catch(() => {
4430
- });
4431
- ({ exports: exports0 } = await instantiateCore(await module2));
4432
- ({ exports: exports1 } = await instantiateCore(await module0, {
4459
+ ({ exports: exports0 } = instantiateCore(module2));
4460
+ ({ exports: exports1 } = instantiateCore(module0, {
4433
4461
  wasi_snapshot_preview1: {
4434
4462
  args_get: exports0["29"],
4435
4463
  args_sizes_get: exports0["30"],
@@ -4454,54 +4482,54 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
4454
4482
  proc_exit: exports0["49"]
4455
4483
  }
4456
4484
  }));
4457
- ({ exports: exports2 } = await instantiateCore(await module1, {
4485
+ ({ exports: exports2 } = instantiateCore(module1, {
4458
4486
  __main_module__: {
4459
4487
  _start: exports1._start
4460
4488
  },
4461
4489
  env: {
4462
4490
  memory: exports1.memory
4463
4491
  },
4464
- "wasi:cli/environment@0.2.0-rc-2023-12-05": {
4492
+ "wasi:cli/environment@0.2.0": {
4465
4493
  "get-arguments": exports0["25"],
4466
4494
  "get-environment": exports0["24"]
4467
4495
  },
4468
- "wasi:cli/exit@0.2.0-rc-2023-12-05": {
4496
+ "wasi:cli/exit@0.2.0": {
4469
4497
  exit: trampoline9
4470
4498
  },
4471
- "wasi:cli/stderr@0.2.0-rc-2023-12-05": {
4499
+ "wasi:cli/stderr@0.2.0": {
4472
4500
  "get-stderr": trampoline8
4473
4501
  },
4474
- "wasi:cli/stdin@0.2.0-rc-2023-12-05": {
4502
+ "wasi:cli/stdin@0.2.0": {
4475
4503
  "get-stdin": trampoline10
4476
4504
  },
4477
- "wasi:cli/stdout@0.2.0-rc-2023-12-05": {
4505
+ "wasi:cli/stdout@0.2.0": {
4478
4506
  "get-stdout": trampoline11
4479
4507
  },
4480
- "wasi:cli/terminal-input@0.2.0-rc-2023-12-05": {
4508
+ "wasi:cli/terminal-input@0.2.0": {
4481
4509
  "[resource-drop]terminal-input": trampoline7
4482
4510
  },
4483
- "wasi:cli/terminal-output@0.2.0-rc-2023-12-05": {
4511
+ "wasi:cli/terminal-output@0.2.0": {
4484
4512
  "[resource-drop]terminal-output": trampoline6
4485
4513
  },
4486
- "wasi:cli/terminal-stderr@0.2.0-rc-2023-12-05": {
4514
+ "wasi:cli/terminal-stderr@0.2.0": {
4487
4515
  "get-terminal-stderr": exports0["28"]
4488
4516
  },
4489
- "wasi:cli/terminal-stdin@0.2.0-rc-2023-12-05": {
4517
+ "wasi:cli/terminal-stdin@0.2.0": {
4490
4518
  "get-terminal-stdin": exports0["26"]
4491
4519
  },
4492
- "wasi:cli/terminal-stdout@0.2.0-rc-2023-12-05": {
4520
+ "wasi:cli/terminal-stdout@0.2.0": {
4493
4521
  "get-terminal-stdout": exports0["27"]
4494
4522
  },
4495
- "wasi:clocks/monotonic-clock@0.2.0-rc-2023-11-10": {
4523
+ "wasi:clocks/monotonic-clock@0.2.0": {
4496
4524
  now: trampoline0
4497
4525
  },
4498
- "wasi:clocks/wall-clock@0.2.0-rc-2023-11-10": {
4526
+ "wasi:clocks/wall-clock@0.2.0": {
4499
4527
  now: exports0["1"]
4500
4528
  },
4501
- "wasi:filesystem/preopens@0.2.0-rc-2023-11-10": {
4529
+ "wasi:filesystem/preopens@0.2.0": {
4502
4530
  "get-directories": exports0["0"]
4503
4531
  },
4504
- "wasi:filesystem/types@0.2.0-rc-2023-11-10": {
4532
+ "wasi:filesystem/types@0.2.0": {
4505
4533
  "[method]descriptor.append-via-stream": exports0["4"],
4506
4534
  "[method]descriptor.create-directory-at": exports0["8"],
4507
4535
  "[method]descriptor.get-flags": exports0["5"],
@@ -4521,10 +4549,10 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
4521
4549
  "[resource-drop]directory-entry-stream": trampoline1,
4522
4550
  "filesystem-error-code": exports0["17"]
4523
4551
  },
4524
- "wasi:io/error@0.2.0-rc-2023-11-10": {
4552
+ "wasi:io/error@0.2.0": {
4525
4553
  "[resource-drop]error": trampoline2
4526
4554
  },
4527
- "wasi:io/streams@0.2.0-rc-2023-11-10": {
4555
+ "wasi:io/streams@0.2.0": {
4528
4556
  "[method]input-stream.blocking-read": exports0["19"],
4529
4557
  "[method]input-stream.read": exports0["18"],
4530
4558
  "[method]output-stream.blocking-flush": exports0["23"],
@@ -4537,7 +4565,7 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
4537
4565
  }));
4538
4566
  memory0 = exports1.memory;
4539
4567
  realloc0 = exports2.cabi_import_realloc;
4540
- ({ exports: exports3 } = await instantiateCore(await module3, {
4568
+ ({ exports: exports3 } = instantiateCore(module3, {
4541
4569
  "": {
4542
4570
  $imports: exports0.$imports,
4543
4571
  "0": trampoline12,
@@ -4593,7 +4621,7 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
4593
4621
  }
4594
4622
  }));
4595
4623
  function run() {
4596
- const ret = exports2["wasi:cli/run@0.2.0-rc-2023-12-05#run"]();
4624
+ const ret = exports2["wasi:cli/run@0.2.0#run"]();
4597
4625
  let variant0;
4598
4626
  switch (ret) {
4599
4627
  case 0: {
@@ -4633,10 +4661,10 @@ async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly
4633
4661
  let handleCnt5 = 0;
4634
4662
  const handleTable6 = /* @__PURE__ */ new Map();
4635
4663
  let handleCnt6 = 0;
4636
- const run0_2_0Rc20231205 = {
4664
+ const run0_2_0 = {
4637
4665
  run
4638
4666
  };
4639
- return { run: run0_2_0Rc20231205, "wasi:cli/run@0.2.0-rc-2023-12-05": run0_2_0Rc20231205 };
4667
+ return { run: run0_2_0, "wasi:cli/run@0.2.0": run0_2_0 };
4640
4668
  }
4641
4669
 
4642
4670
  // lib/api.js