@@ -26,6 +26,9 @@ import { insistStorageAPI } from './storageAPI';
26
26
import { insistCapData } from './capdata' ;
27
27
import { parseVatSlot } from './parseVatSlots' ;
28
28
29
+ // FIXME: Put this somewhere better.
30
+ process . on ( 'unhandledRejection' , e => console . log ( 'unhandledRejection' , e ) ) ;
31
+
29
32
const ADMIN_DEVICE_PATH = require . resolve ( './kernel/vatAdmin/vatAdmin-src' ) ;
30
33
const ADMIN_VAT_PATH = require . resolve ( './kernel/vatAdmin/vatAdminWrapper' ) ;
31
34
@@ -197,32 +200,29 @@ function realmRegisterEndOfCrank(fn) {
197
200
{ registerEndOfCrank } ,
198
201
) ;
199
202
200
- return src => {
201
- // FIXME: Note that this replaceGlobalMeter endowment is not any
202
- // worse than before metering existed. However, it probably is
203
- // only necessary to be added to the kernel, rather than all
204
- // static vats once we add metering support to the dynamic vat
205
- // implementation.
206
- // FIXME: Same for registerEndOfCrank.
207
-
208
- // Cope with ESM problems.
209
- src = src . replace ( / ( _ [ a - z A - Z 0 - 9 ] { 3 } \u200d \. e ) / g, 'eval' ) ;
210
-
211
- // Support both getExport and nestedEvaluate module format.
203
+ return ( src , filePrefix = '/SwingSet-bundled-source' ) => {
212
204
const nestedEvaluate = source =>
213
205
s . evaluate ( source , {
206
+ // Support both getExport and nestedEvaluate module format.
214
207
require : r ,
208
+ nestedEvaluate,
209
+
210
+ // FIXME: Note that this replaceGlobalMeter endowment is not any
211
+ // worse than before metering existed. However, it probably is
212
+ // only necessary to be added to the kernel, rather than all
213
+ // static vats once we add metering support to the dynamic vat
214
+ // implementation.
215
+ // FIXME: Same for registerEndOfCrank.
215
216
registerEndOfCrank : realmRegisterEndOfCrank ,
216
217
replaceGlobalMeter,
217
- nestedEvaluate,
218
218
} ) ;
219
- return nestedEvaluate ( src ) ( ) . default ;
219
+ return nestedEvaluate ( src ) ( filePrefix ) . default ;
220
220
} ;
221
221
}
222
222
223
223
function buildSESKernel ( sesEvaluator , endowments ) {
224
224
const kernelSource = getKernelSource ( ) ;
225
- const buildKernel = sesEvaluator ( kernelSource ) ;
225
+ const buildKernel = sesEvaluator ( kernelSource , '/SwingSet-kernel' ) ;
226
226
return buildKernel ( endowments ) ;
227
227
}
228
228
@@ -266,7 +266,7 @@ export async function buildVatController(config, withSES = true, argv = []) {
266
266
// Evaluate source to produce a setup function. This binds withSES from the
267
267
// enclosing context and evaluates it either in a SES context, or without SES
268
268
// by directly calling require().
269
- async function evaluateToSetup ( sourceIndex ) {
269
+ async function evaluateToSetup ( sourceIndex , filePrefix = undefined ) {
270
270
if ( ! ( sourceIndex [ 0 ] === '.' || path . isAbsolute ( sourceIndex ) ) ) {
271
271
throw Error (
272
272
'sourceIndex must be relative (./foo) or absolute (/foo) not bare (foo)' ,
@@ -284,7 +284,7 @@ export async function buildVatController(config, withSES = true, argv = []) {
284
284
'nestedEvaluate' ,
285
285
) ;
286
286
const actualSource = `(${ source } )\n${ sourceMap } ` ;
287
- setup = sesEvaluator ( actualSource ) ;
287
+ setup = sesEvaluator ( actualSource , filePrefix ) ;
288
288
} else {
289
289
// eslint-disable-next-line global-require,import/no-dynamic-require
290
290
setup = require ( `${ sourceIndex } ` ) . default ;
@@ -298,8 +298,8 @@ export async function buildVatController(config, withSES = true, argv = []) {
298
298
setImmediate,
299
299
hostStorage,
300
300
runEndOfCrank,
301
- vatAdminDevSetup : await evaluateToSetup ( ADMIN_DEVICE_PATH ) ,
302
- vatAdminVatSetup : await evaluateToSetup ( ADMIN_VAT_PATH ) ,
301
+ vatAdminDevSetup : await evaluateToSetup ( ADMIN_DEVICE_PATH , '/SwingSet/src' ) ,
302
+ vatAdminVatSetup : await evaluateToSetup ( ADMIN_VAT_PATH , '/SwingSet/src' ) ,
303
303
} ;
304
304
305
305
const kernel = withSES
@@ -308,12 +308,12 @@ export async function buildVatController(config, withSES = true, argv = []) {
308
308
309
309
async function addGenesisVat ( name , sourceIndex , options = { } ) {
310
310
console . log ( `= adding vat '${ name } ' from ${ sourceIndex } ` ) ;
311
- const setup = await evaluateToSetup ( sourceIndex ) ;
311
+ const setup = await evaluateToSetup ( sourceIndex , `/SwingSet-vat- ${ name } ` ) ;
312
312
kernel . addGenesisVat ( name , setup , options ) ;
313
313
}
314
314
315
315
async function addGenesisDevice ( name , sourceIndex , endowments ) {
316
- const setup = await evaluateToSetup ( sourceIndex ) ;
316
+ const setup = await evaluateToSetup ( sourceIndex , `/SwingSet-dev- ${ name } ` ) ;
317
317
kernel . addGenesisDevice ( name , setup , endowments ) ;
318
318
}
319
319
0 commit comments