@ruby/wasm-wasi 2.4.1 → 2.5.0

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/dist/esm/index.js CHANGED
@@ -1,637 +1,2 @@
1
- import * as RbAbi from "./bindgen/rb-abi-guest.js";
2
- import { addRbJsAbiHostToImports, } from "./bindgen/rb-js-abi-host.js";
3
1
  export { consolePrinter } from "./console.js";
4
- /**
5
- * A Ruby VM instance
6
- *
7
- * @example
8
- *
9
- * const wasi = new WASI();
10
- * const vm = new RubyVM();
11
- * const imports = {
12
- * wasi_snapshot_preview1: wasi.wasiImport,
13
- * };
14
- *
15
- * vm.addToImports(imports);
16
- *
17
- * const instance = await WebAssembly.instantiate(rubyModule, imports);
18
- * await vm.setInstance(instance);
19
- * wasi.initialize(instance);
20
- * vm.initialize();
21
- *
22
- */
23
- export class RubyVM {
24
- constructor() {
25
- this.instance = null;
26
- this.interfaceState = {
27
- hasJSFrameAfterRbFrame: false,
28
- };
29
- // Wrap exported functions from Ruby VM to prohibit nested VM operation
30
- // if the call stack has sandwitched JS frames like JS -> Ruby -> JS -> Ruby.
31
- const proxyExports = (exports) => {
32
- const excludedMethods = [
33
- "addToImports",
34
- "instantiate",
35
- "rbSetShouldProhibitRewind",
36
- "rbGcDisable",
37
- "rbGcEnable",
38
- ];
39
- const excluded = ["constructor"].concat(excludedMethods);
40
- // wrap all methods in RbAbi.RbAbiGuest class
41
- for (const key of Object.getOwnPropertyNames(RbAbi.RbAbiGuest.prototype)) {
42
- if (excluded.includes(key)) {
43
- continue;
44
- }
45
- const value = exports[key];
46
- if (typeof value === "function") {
47
- exports[key] = (...args) => {
48
- const isNestedVMCall = this.interfaceState.hasJSFrameAfterRbFrame;
49
- if (isNestedVMCall) {
50
- const oldShouldProhibitRewind = this.guest.rbSetShouldProhibitRewind(true);
51
- const oldIsDisabledGc = this.guest.rbGcDisable();
52
- const result = Reflect.apply(value, exports, args);
53
- this.guest.rbSetShouldProhibitRewind(oldShouldProhibitRewind);
54
- if (!oldIsDisabledGc) {
55
- this.guest.rbGcEnable();
56
- }
57
- return result;
58
- }
59
- else {
60
- return Reflect.apply(value, exports, args);
61
- }
62
- };
63
- }
64
- }
65
- return exports;
66
- };
67
- this.guest = proxyExports(new RbAbi.RbAbiGuest());
68
- this.transport = new JsValueTransport();
69
- this.exceptionFormatter = new RbExceptionFormatter();
70
- }
71
- /**
72
- * Initialize the Ruby VM with the given command line arguments
73
- * @param args The command line arguments to pass to Ruby. Must be
74
- * an array of strings starting with the Ruby program name.
75
- */
76
- initialize(args = ["ruby.wasm", "--disable-gems", "-EUTF-8", "-e_=0"]) {
77
- const c_args = args.map((arg) => arg + "\0");
78
- this.guest.rubyInit();
79
- this.guest.rubySysinit(c_args);
80
- this.guest.rubyOptions(c_args);
81
- }
82
- /**
83
- * Set a given instance to interact JavaScript and Ruby's
84
- * WebAssembly instance. This method must be called before calling
85
- * Ruby API.
86
- *
87
- * @param instance The WebAssembly instance to interact with. Must
88
- * be instantiated from a Ruby built with JS extension, and built
89
- * with Reactor ABI instead of command line.
90
- */
91
- async setInstance(instance) {
92
- this.instance = instance;
93
- await this.guest.instantiate(instance);
94
- }
95
- /**
96
- * Add intrinsic import entries, which is necessary to interact JavaScript
97
- * and Ruby's WebAssembly instance.
98
- * @param imports The import object to add to the WebAssembly instance
99
- */
100
- addToImports(imports) {
101
- this.guest.addToImports(imports);
102
- function wrapTry(f) {
103
- return (...args) => {
104
- try {
105
- return { tag: "success", val: f(...args) };
106
- }
107
- catch (e) {
108
- if (e instanceof RbFatalError) {
109
- // RbFatalError should not be caught by Ruby because it Ruby VM
110
- // can be already in an inconsistent state.
111
- throw e;
112
- }
113
- return { tag: "failure", val: e };
114
- }
115
- };
116
- }
117
- imports["rb-js-abi-host"] = {
118
- rb_wasm_throw_prohibit_rewind_exception: (messagePtr, messageLen) => {
119
- const memory = this.instance.exports.memory;
120
- const str = new TextDecoder().decode(new Uint8Array(memory.buffer, messagePtr, messageLen));
121
- throw new RbFatalError("Ruby APIs that may rewind the VM stack are prohibited under nested VM operation " +
122
- `(${str})\n` +
123
- "Nested VM operation means that the call stack has sandwitched JS frames like JS -> Ruby -> JS -> Ruby " +
124
- "caused by something like `window.rubyVM.eval(\"JS.global[:rubyVM].eval('Fiber.yield')\")`\n" +
125
- "\n" +
126
- "Please check your call stack and make sure that you are **not** doing any of the following inside the nested Ruby frame:\n" +
127
- " 1. Switching fibers (e.g. Fiber#resume, Fiber.yield, and Fiber#transfer)\n" +
128
- " Note that `evalAsync` JS API switches fibers internally\n" +
129
- " 2. Raising uncaught exceptions\n" +
130
- " Please catch all exceptions inside the nested operation\n" +
131
- " 3. Calling Continuation APIs\n");
132
- },
133
- };
134
- // NOTE: The GC may collect objects that are still referenced by Wasm
135
- // locals because Asyncify cannot scan the Wasm stack above the JS frame.
136
- // So we need to keep track whether the JS frame is sandwitched by Ruby
137
- // frames or not, and prohibit nested VM operation if it is.
138
- const proxyImports = (imports) => {
139
- for (const [key, value] of Object.entries(imports)) {
140
- if (typeof value === "function") {
141
- imports[key] = (...args) => {
142
- const oldValue = this.interfaceState.hasJSFrameAfterRbFrame;
143
- this.interfaceState.hasJSFrameAfterRbFrame = true;
144
- const result = Reflect.apply(value, imports, args);
145
- this.interfaceState.hasJSFrameAfterRbFrame = oldValue;
146
- return result;
147
- };
148
- }
149
- }
150
- return imports;
151
- };
152
- addRbJsAbiHostToImports(imports, proxyImports({
153
- evalJs: wrapTry((code) => {
154
- return Function(code)();
155
- }),
156
- isJs: (value) => {
157
- // Just for compatibility with the old JS API
158
- return true;
159
- },
160
- globalThis: () => {
161
- if (typeof globalThis !== "undefined") {
162
- return globalThis;
163
- }
164
- else if (typeof global !== "undefined") {
165
- return global;
166
- }
167
- else if (typeof window !== "undefined") {
168
- return window;
169
- }
170
- throw new Error("unable to locate global object");
171
- },
172
- intToJsNumber: (value) => {
173
- return value;
174
- },
175
- floatToJsNumber: (value) => {
176
- return value;
177
- },
178
- stringToJsString: (value) => {
179
- return value;
180
- },
181
- boolToJsBool: (value) => {
182
- return value;
183
- },
184
- procToJsFunction: (rawRbAbiValue) => {
185
- const rbValue = this.rbValueOfPointer(rawRbAbiValue);
186
- return (...args) => {
187
- rbValue.call("call", ...args.map((arg) => this.wrap(arg)));
188
- };
189
- },
190
- rbObjectToJsRbValue: (rawRbAbiValue) => {
191
- return this.rbValueOfPointer(rawRbAbiValue);
192
- },
193
- jsValueToString: (value) => {
194
- // According to the [spec](https://tc39.es/ecma262/multipage/text-processing.html#sec-string-constructor-string-value)
195
- // `String(value)` always returns a string.
196
- return String(value);
197
- },
198
- jsValueToInteger(value) {
199
- if (typeof value === "number") {
200
- return { tag: "f64", val: value };
201
- }
202
- else if (typeof value === "bigint") {
203
- return { tag: "bignum", val: BigInt(value).toString(10) + "\0" };
204
- }
205
- else if (typeof value === "string") {
206
- return { tag: "bignum", val: value + "\0" };
207
- }
208
- else if (typeof value === "undefined") {
209
- return { tag: "f64", val: 0 };
210
- }
211
- else {
212
- return { tag: "f64", val: Number(value) };
213
- }
214
- },
215
- exportJsValueToHost: (value) => {
216
- // See `JsValueExporter` for the reason why we need to do this
217
- this.transport.takeJsValue(value);
218
- },
219
- importJsValueFromHost: () => {
220
- return this.transport.consumeJsValue();
221
- },
222
- instanceOf: (value, klass) => {
223
- if (typeof klass === "function") {
224
- return value instanceof klass;
225
- }
226
- else {
227
- return false;
228
- }
229
- },
230
- jsValueTypeof(value) {
231
- return typeof value;
232
- },
233
- jsValueEqual(lhs, rhs) {
234
- return lhs == rhs;
235
- },
236
- jsValueStrictlyEqual(lhs, rhs) {
237
- return lhs === rhs;
238
- },
239
- reflectApply: wrapTry((target, thisArgument, args) => {
240
- return Reflect.apply(target, thisArgument, args);
241
- }),
242
- reflectConstruct: function (target, args) {
243
- throw new Error("Function not implemented.");
244
- },
245
- reflectDeleteProperty: function (target, propertyKey) {
246
- throw new Error("Function not implemented.");
247
- },
248
- reflectGet: wrapTry((target, propertyKey) => {
249
- return target[propertyKey];
250
- }),
251
- reflectGetOwnPropertyDescriptor: function (target, propertyKey) {
252
- throw new Error("Function not implemented.");
253
- },
254
- reflectGetPrototypeOf: function (target) {
255
- throw new Error("Function not implemented.");
256
- },
257
- reflectHas: function (target, propertyKey) {
258
- throw new Error("Function not implemented.");
259
- },
260
- reflectIsExtensible: function (target) {
261
- throw new Error("Function not implemented.");
262
- },
263
- reflectOwnKeys: function (target) {
264
- throw new Error("Function not implemented.");
265
- },
266
- reflectPreventExtensions: function (target) {
267
- throw new Error("Function not implemented.");
268
- },
269
- reflectSet: wrapTry((target, propertyKey, value) => {
270
- return Reflect.set(target, propertyKey, value);
271
- }),
272
- reflectSetPrototypeOf: function (target, prototype) {
273
- throw new Error("Function not implemented.");
274
- },
275
- }), (name) => {
276
- return this.instance.exports[name];
277
- });
278
- }
279
- /**
280
- * Print the Ruby version to stdout
281
- */
282
- printVersion() {
283
- this.guest.rubyShowVersion();
284
- }
285
- /**
286
- * Runs a string of Ruby code from JavaScript
287
- * @param code The Ruby code to run
288
- * @returns the result of the last expression
289
- *
290
- * @example
291
- * vm.eval("puts 'hello world'");
292
- * const result = vm.eval("1 + 2");
293
- * console.log(result.toString()); // 3
294
- *
295
- */
296
- eval(code) {
297
- return evalRbCode(this, this.privateObject(), code);
298
- }
299
- /**
300
- * Runs a string of Ruby code with top-level `JS::Object#await`
301
- * Returns a promise that resolves when execution completes.
302
- * @param code The Ruby code to run
303
- * @returns a promise that resolves to the result of the last expression
304
- *
305
- * @example
306
- * const text = await vm.evalAsync(`
307
- * require 'js'
308
- * response = JS.global.fetch('https://example.com').await
309
- * response.text.await
310
- * `);
311
- * console.log(text.toString()); // <html>...</html>
312
- */
313
- evalAsync(code) {
314
- const JS = this.eval("require 'js'; JS");
315
- return new Promise((resolve, reject) => {
316
- JS.call("__eval_async_rb", this.wrap(code), this.wrap({
317
- resolve,
318
- reject: (error) => {
319
- reject(new RbError(this.exceptionFormatter.format(error, this, this.privateObject())));
320
- },
321
- }));
322
- });
323
- }
324
- /**
325
- * Wrap a JavaScript value into a Ruby JS::Object
326
- * @param value The value to convert to RbValue
327
- * @returns the RbValue object representing the given JS value
328
- *
329
- * @example
330
- * const hash = vm.eval(`Hash.new`)
331
- * hash.call("store", vm.eval(`"key1"`), vm.wrap(new Object()));
332
- */
333
- wrap(value) {
334
- return this.transport.importJsValue(value, this);
335
- }
336
- /** @private */
337
- privateObject() {
338
- return {
339
- transport: this.transport,
340
- exceptionFormatter: this.exceptionFormatter,
341
- };
342
- }
343
- /** @private */
344
- rbValueOfPointer(pointer) {
345
- const abiValue = new RbAbi.RbAbiValue(pointer, this.guest);
346
- return new RbValue(abiValue, this, this.privateObject());
347
- }
348
- }
349
- /**
350
- * Export a JS value held by the Ruby VM to the JS environment.
351
- * This is implemented in a dirty way since wit cannot reference resources
352
- * defined in other interfaces.
353
- * In our case, we can't express `function(v: rb-abi-value) -> js-abi-value`
354
- * because `rb-js-abi-host.wit`, that defines `js-abi-value`, is implemented
355
- * by embedder side (JS) but `rb-abi-guest.wit`, that defines `rb-abi-value`
356
- * is implemented by guest side (Wasm).
357
- *
358
- * This class is a helper to export by:
359
- * 1. Call `function __export_to_js(v: rb-abi-value)` defined in guest from embedder side.
360
- * 2. Call `function takeJsValue(v: js-abi-value)` defined in embedder from guest side with
361
- * underlying JS value of given `rb-abi-value`.
362
- * 3. Then `takeJsValue` implementation escapes the given JS value to the `_takenJsValues`
363
- * stored in embedder side.
364
- * 4. Finally, embedder side can take `_takenJsValues`.
365
- *
366
- * Note that `exportJsValue` is not reentrant.
367
- *
368
- * @private
369
- */
370
- class JsValueTransport {
371
- constructor() {
372
- this._takenJsValue = null;
373
- }
374
- takeJsValue(value) {
375
- this._takenJsValue = value;
376
- }
377
- consumeJsValue() {
378
- return this._takenJsValue;
379
- }
380
- exportJsValue(value) {
381
- value.call("__export_to_js");
382
- return this._takenJsValue;
383
- }
384
- importJsValue(value, vm) {
385
- this._takenJsValue = value;
386
- return vm.eval('require "js"; JS::Object').call("__import_from_js");
387
- }
388
- }
389
- /**
390
- * A RbValue is an object that represents a value in Ruby
391
- */
392
- export class RbValue {
393
- /**
394
- * @hideconstructor
395
- */
396
- constructor(inner, vm, privateObject) {
397
- this.inner = inner;
398
- this.vm = vm;
399
- this.privateObject = privateObject;
400
- }
401
- /**
402
- * Call a given method with given arguments
403
- *
404
- * @param callee name of the Ruby method to call
405
- * @param args arguments to pass to the method. Must be an array of RbValue
406
- *
407
- * @example
408
- * const ary = vm.eval("[1, 2, 3]");
409
- * ary.call("push", 4);
410
- * console.log(ary.call("sample").toString());
411
- *
412
- */
413
- call(callee, ...args) {
414
- const innerArgs = args.map((arg) => arg.inner);
415
- return new RbValue(callRbMethod(this.vm, this.privateObject, this.inner, callee, innerArgs), this.vm, this.privateObject);
416
- }
417
- /**
418
- * @see {@link https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toPrimitive}
419
- * @param hint Preferred type of the result primitive value. `"number"`, `"string"`, or `"default"`.
420
- */
421
- [Symbol.toPrimitive](hint) {
422
- if (hint === "string" || hint === "default") {
423
- return this.toString();
424
- }
425
- else if (hint === "number") {
426
- return null;
427
- }
428
- return null;
429
- }
430
- /**
431
- * Returns a string representation of the value by calling `to_s`
432
- */
433
- toString() {
434
- const rbString = callRbMethod(this.vm, this.privateObject, this.inner, "to_s", []);
435
- return this.vm.guest.rstringPtr(rbString);
436
- }
437
- /**
438
- * Returns a JavaScript object representation of the value
439
- * by calling `to_js`.
440
- *
441
- * Returns null if the value is not convertible to a JavaScript object.
442
- */
443
- toJS() {
444
- const JS = this.vm.eval("JS");
445
- const jsValue = JS.call("try_convert", this);
446
- if (jsValue.call("nil?").toString() === "true") {
447
- return null;
448
- }
449
- return this.privateObject.transport.exportJsValue(jsValue);
450
- }
451
- }
452
- var ruby_tag_type;
453
- (function (ruby_tag_type) {
454
- ruby_tag_type[ruby_tag_type["None"] = 0] = "None";
455
- ruby_tag_type[ruby_tag_type["Return"] = 1] = "Return";
456
- ruby_tag_type[ruby_tag_type["Break"] = 2] = "Break";
457
- ruby_tag_type[ruby_tag_type["Next"] = 3] = "Next";
458
- ruby_tag_type[ruby_tag_type["Retry"] = 4] = "Retry";
459
- ruby_tag_type[ruby_tag_type["Redo"] = 5] = "Redo";
460
- ruby_tag_type[ruby_tag_type["Raise"] = 6] = "Raise";
461
- ruby_tag_type[ruby_tag_type["Throw"] = 7] = "Throw";
462
- ruby_tag_type[ruby_tag_type["Fatal"] = 8] = "Fatal";
463
- ruby_tag_type[ruby_tag_type["Mask"] = 15] = "Mask";
464
- })(ruby_tag_type || (ruby_tag_type = {}));
465
- class RbExceptionFormatter {
466
- constructor() {
467
- this.literalsCache = null;
468
- this.isFormmatting = false;
469
- }
470
- format(error, vm, privateObject) {
471
- // All Ruby exceptions raised during formatting exception message should
472
- // be caught and return a fallback message.
473
- // Therefore, we don't need to worry about infinite recursion here ideally
474
- // but checking re-entrancy just in case.
475
- class RbExceptionFormatterError extends Error {
476
- }
477
- if (this.isFormmatting) {
478
- throw new RbExceptionFormatterError("Unexpected exception occurred during formatting exception message");
479
- }
480
- this.isFormmatting = true;
481
- try {
482
- return this._format(error, vm, privateObject);
483
- }
484
- finally {
485
- this.isFormmatting = false;
486
- }
487
- }
488
- _format(error, vm, privateObject) {
489
- const [zeroLiteral, oneLiteral, newLineLiteral] = (() => {
490
- if (this.literalsCache == null) {
491
- const zeroOneNewLine = [
492
- evalRbCode(vm, privateObject, "0"),
493
- evalRbCode(vm, privateObject, "1"),
494
- evalRbCode(vm, privateObject, `"\n"`),
495
- ];
496
- this.literalsCache = zeroOneNewLine;
497
- return zeroOneNewLine;
498
- }
499
- else {
500
- return this.literalsCache;
501
- }
502
- })();
503
- let className;
504
- let backtrace;
505
- let message;
506
- try {
507
- className = error.call("class").toString();
508
- }
509
- catch (e) {
510
- className = "unknown";
511
- }
512
- try {
513
- message = error.toString();
514
- }
515
- catch (e) {
516
- message = "unknown";
517
- }
518
- try {
519
- backtrace = error.call("backtrace");
520
- }
521
- catch (e) {
522
- return this.formatString(className, message);
523
- }
524
- if (backtrace.call("nil?").toString() === "true") {
525
- return this.formatString(className, message);
526
- }
527
- try {
528
- const firstLine = backtrace.call("at", zeroLiteral);
529
- const restLines = backtrace
530
- .call("drop", oneLiteral)
531
- .call("join", newLineLiteral);
532
- return this.formatString(className, message, [
533
- firstLine.toString(),
534
- restLines.toString(),
535
- ]);
536
- }
537
- catch (e) {
538
- return this.formatString(className, message);
539
- }
540
- }
541
- formatString(klass, message, backtrace) {
542
- if (backtrace) {
543
- return `${backtrace[0]}: ${message} (${klass})\n${backtrace[1]}`;
544
- }
545
- else {
546
- return `${klass}: ${message}`;
547
- }
548
- }
549
- }
550
- const checkStatusTag = (rawTag, vm, privateObject) => {
551
- switch (rawTag & ruby_tag_type.Mask) {
552
- case ruby_tag_type.None:
553
- break;
554
- case ruby_tag_type.Return:
555
- throw new RbError("unexpected return");
556
- case ruby_tag_type.Next:
557
- throw new RbError("unexpected next");
558
- case ruby_tag_type.Break:
559
- throw new RbError("unexpected break");
560
- case ruby_tag_type.Redo:
561
- throw new RbError("unexpected redo");
562
- case ruby_tag_type.Retry:
563
- throw new RbError("retry outside of rescue clause");
564
- case ruby_tag_type.Throw:
565
- throw new RbError("unexpected throw");
566
- case ruby_tag_type.Raise:
567
- case ruby_tag_type.Fatal:
568
- const error = new RbValue(vm.guest.rbErrinfo(), vm, privateObject);
569
- if (error.call("nil?").toString() === "true") {
570
- throw new RbError("no exception object");
571
- }
572
- // clear errinfo if got exception due to no rb_jump_tag
573
- vm.guest.rbClearErrinfo();
574
- throw new RbError(privateObject.exceptionFormatter.format(error, vm, privateObject));
575
- default:
576
- throw new RbError(`unknown error tag: ${rawTag}`);
577
- }
578
- };
579
- function wrapRbOperation(vm, body) {
580
- try {
581
- return body();
582
- }
583
- catch (e) {
584
- if (e instanceof RbError) {
585
- throw e;
586
- }
587
- // All JS exceptions triggered by Ruby code are translated to Ruby exceptions,
588
- // so non-RbError exceptions are unexpected.
589
- vm.guest.rbVmBugreport();
590
- if (e instanceof WebAssembly.RuntimeError && e.message === "unreachable") {
591
- const error = new RbError(`Something went wrong in Ruby VM: ${e}`);
592
- error.stack = e.stack;
593
- throw error;
594
- }
595
- else {
596
- throw e;
597
- }
598
- }
599
- }
600
- const callRbMethod = (vm, privateObject, recv, callee, args) => {
601
- const mid = vm.guest.rbIntern(callee + "\0");
602
- return wrapRbOperation(vm, () => {
603
- const [value, status] = vm.guest.rbFuncallvProtect(recv, mid, args);
604
- checkStatusTag(status, vm, privateObject);
605
- return value;
606
- });
607
- };
608
- const evalRbCode = (vm, privateObject, code) => {
609
- return wrapRbOperation(vm, () => {
610
- const [value, status] = vm.guest.rbEvalStringProtect(code + "\0");
611
- checkStatusTag(status, vm, privateObject);
612
- return new RbValue(value, vm, privateObject);
613
- });
614
- };
615
- /**
616
- * Error class thrown by Ruby execution
617
- */
618
- export class RbError extends Error {
619
- /**
620
- * @hideconstructor
621
- */
622
- constructor(message) {
623
- super(message);
624
- }
625
- }
626
- /**
627
- * Error class thrown by Ruby execution when it is not possible to recover.
628
- * This is usually caused when Ruby VM is in an inconsistent state.
629
- */
630
- export class RbFatalError extends RbError {
631
- /**
632
- * @hideconstructor
633
- */
634
- constructor(message) {
635
- super("Ruby Fatal Error: " + message);
636
- }
637
- }
2
+ export * from "./vm.js";
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import { WASI } from "wasi";
3
- import { RubyVM } from "./index.js";
3
+ import { RubyVM } from "./vm.js";
4
4
  export declare const DefaultRubyVM: (rubyModule: WebAssembly.Module, options?: {
5
5
  env?: Record<string, string> | undefined;
6
6
  }) => Promise<{
package/dist/esm/node.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { WASI } from "wasi";
2
- import { RubyVM } from "./index.js";
2
+ import { RubyVM } from "./vm.js";
3
3
  export const DefaultRubyVM = async (rubyModule, options = {}) => {
4
4
  const wasi = new WASI({ env: options.env, version: "preview1" });
5
5
  const vm = new RubyVM();