|
1 | 1 | #!/usr/bin/env node |
2 | 2 |
|
3 | | -// https://github.com/grain-lang/grain/issues/114 |
4 | | -const v8 = require("v8"); |
5 | | -/* From the Node.js docs: |
6 | | - * |
7 | | - * The v8.setFlagsFromString() method can be used to programmatically set V8 command-line flags. |
8 | | - * This method should be used with care. Changing settings after the VM has started may result |
9 | | - * in unpredictable behavior, including crashes and data loss; or it may simply do nothing. |
10 | | - * |
11 | | - * This seems to work for our needs with Node 18, but we should be cautious when updating. |
12 | | - */ |
13 | | -v8.setFlagsFromString("--experimental-wasm-return-call"); |
14 | | - |
15 | 3 | const commander = require("commander"); |
16 | 4 | const exec = require("./exec.js"); |
17 | | -const run = require("./run.js"); |
18 | 5 | const pkgJson = require("../package.json"); |
19 | 6 |
|
20 | 7 | const stdlibPath = require("@grain/stdlib"); |
@@ -159,7 +146,6 @@ class GrainCommand extends commander.Command { |
159 | 146 | "--use-start-section", |
160 | 147 | "replaces the _start export with a start section during linking" |
161 | 148 | ); |
162 | | - cmd.forwardOption("--no-link", "disable static linking"); |
163 | 149 | cmd.forwardOption( |
164 | 150 | "--no-pervasives", |
165 | 151 | "don't automatically import the Grain Pervasives module" |
@@ -189,28 +175,27 @@ program |
189 | 175 | .command("compile-and-run <file>", { isDefault: true, hidden: true }) |
190 | 176 | // `--version` should only be available on the default command |
191 | 177 | .version(pkgJson.version, "-v, --version", "output the current version") |
192 | | - .addOption(new commander.Option("-p, --print-output").hideHelp()) |
193 | 178 | .forwardOption("-o <filename>", "output filename") |
194 | 179 | .action(function (file, options, program) { |
195 | 180 | exec.grainc(file, options, program); |
196 | 181 | if (options.o) { |
197 | | - run(options.o, options); |
| 182 | + exec.grainrun(options.o, options, program); |
198 | 183 | } else { |
199 | | - run(file.replace(/\.gr$/, ".gr.wasm"), options); |
| 184 | + exec.grainrun(file.replace(/\.gr$/, ".gr.wasm"), options, program); |
200 | 185 | } |
201 | 186 | }); |
202 | 187 |
|
203 | 188 | program |
204 | 189 | .command("compile <file>") |
205 | 190 | .description("compile a grain program into wasm") |
206 | 191 | .forwardOption("-o <filename>", "output filename") |
| 192 | + .forwardOption("--no-link", "disable static linking") |
207 | 193 | .action(exec.grainc); |
208 | 194 |
|
209 | 195 | program |
210 | 196 | .command("run <file>") |
211 | | - .description("run a wasm file with grain's javascript runner") |
212 | | - .addOption(new commander.Option("-p, --print-output").hideHelp()) |
213 | | - .action(run); |
| 197 | + .description("run a wasm file via grain's WASI runner") |
| 198 | + .action(exec.grainrun); |
214 | 199 |
|
215 | 200 | program |
216 | 201 | .command("lsp") |
|
0 commit comments