-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathww-stub.js
51 lines (42 loc) · 1.41 KB
/
ww-stub.js
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
var msg = function(obj) {
self.postMessage(obj);
}
self.addEventListener('message', function(e) {
var code = e.data;
var church_to_js = require("./church_to_js").church_to_js;
var format_result = require("./format_result").format_result;
var transform = require("./probabilistic/transform");
var church_builtins = require("./church_builtins");
try
{
var js_code = church_to_js(code);
js_code = transform.probTransform(js_code);
// msg({status: 'compiled', data: js_code});
msg({status: 'done', data: format_result(eval(js_code)) });
}
catch (e)
{
msg({status: 'error', data: e.message });
}
}, false);
_hist = function() {
var args = Array.prototype.slice.call(arguments, 0);
msg({status: 'running', action: "hist", data: args});
};
_density = function() {
var args = Array.prototype.slice.call(arguments, 0);
msg({status: 'running', action: "density", data: args});
};
_scatter = function() {
var args = Array.prototype.slice.call(arguments, 0);
msg({status: 'running', action: "scatter", data: args});
};
_display = function() {
var args = Array.prototype.slice.call(arguments, 0);
msg({status: 'running', action: "display", data: args});
}
// shim. this doesn't work properly for strings or, e.g.,
// lists of strings
_multiviz = function() {
msg({status: 'running', action: "multiviz", data: args});
}