-
Notifications
You must be signed in to change notification settings - Fork 5
/
jipda-conc-eval.mjs
32 lines (27 loc) · 1.08 KB
/
jipda-conc-eval.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import fs from 'fs';
import Ast from './ast';
import concLattice from './conc-lattice';
import concAlloc from './conc-alloc';
import concKalloc from './conc-kalloc';
import createSemantics from './js-semantics';
import {createMachine, run, computeResultValue, computeInitialCeskState} from './abstract-machine';
import {} from './jipda';
const read = name => fs.readFileSync(name).toString();
const ast0src = read("prelude.js");
const jsSemantics = createSemantics(concLattice, concAlloc, concKalloc, {errors: true});
const initialCeskState = computeInitialCeskState(jsSemantics, ast0src);
const args = process.argv.slice(2);
const src = read(args[0]);
console.log(run2(src));
function run2(src)
{
const ast = Ast.createAst(src);
const s0 = createMachine(jsSemantics, {hardAsserts:true, initialState: initialCeskState});
const s1 = s0.enqueueScriptEvaluation(src);
const resultStates = new Set();
const system = run([s1], s => resultStates.add(s));
const result = computeResultValue(resultStates, concLattice.bot());
result.msgs.join("\n");
const actual = result.value;
return actual;
}