-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(swingset): Finish vat tool RESM to NESM conversion
- Loading branch information
Showing
4 changed files
with
65 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../tools/rekernelize.js |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../tools/vat.js |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/usr/bin/env node | ||
|
||
// TODO Remove babel-standalone preinitialization | ||
// https://github.com/endojs/endo/issues/768 | ||
import '@agoric/babel-standalone'; | ||
import '@agoric/install-ses'; | ||
import process from 'process'; | ||
import repl from 'repl'; | ||
import util from 'util'; | ||
import { loadBasedir, buildVatController } from '../src/index.js'; | ||
import { buildLoopbox } from '../src/devices/loopbox.js'; | ||
|
||
function deepLog(item) { | ||
console.log(util.inspect(item, false, null, true)); | ||
} | ||
|
||
async function main() { | ||
const argv = process.argv.splice(2); | ||
let withSES = true; | ||
if (argv[0] === '--no-ses') { | ||
withSES = false; | ||
argv.shift(); | ||
} | ||
const command = argv.shift(); | ||
if (command !== 'run' && command !== 'shell') { | ||
throw new Error(`use 'vat run' or 'vat shell', not 'vat ${command}'`); | ||
} | ||
const basedir = | ||
argv[0] === '--' || argv[0] === undefined ? '.' : argv.shift(); | ||
const vatArgv = argv[0] === '--' ? argv.slice(1) : argv; | ||
|
||
const config = await loadBasedir(basedir); | ||
const { loopboxSrcPath, loopboxEndowments } = buildLoopbox('immediate'); | ||
config.devices = [['loopbox', loopboxSrcPath, loopboxEndowments]]; | ||
|
||
const controller = await buildVatController(config, withSES, vatArgv); | ||
if (command === 'run') { | ||
await controller.run(); | ||
console.log('= vat finished'); | ||
} else if (command === 'shell') { | ||
const r = repl.start({ prompt: 'vat> ', replMode: repl.REPL_MODE_STRICT }); | ||
r.context.dump = () => { | ||
const d = controller.dump(); | ||
console.log('Kernel Table:'); | ||
deepLog(d.kernelTable); | ||
console.log('Promises:'); | ||
deepLog(d.promises); | ||
console.log('Run Queue:'); | ||
deepLog(d.runQueue); | ||
}; | ||
r.context.dump2 = () => controller.dump(); | ||
r.context.run = () => { | ||
console.log('run!'); | ||
controller.run(); | ||
}; | ||
r.context.step = () => { | ||
console.log('step!'); | ||
controller.step(); | ||
}; | ||
} | ||
} | ||
|
||
main(); |