forked from mozart/mozart2-compiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAbstractions.oz
57 lines (55 loc) · 1.33 KB
/
Abstractions.oz
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
52
53
54
55
56
57
%%%
%%% Author:
%%% Leif Kornstaedt <[email protected]>
%%%
%%% Copyright:
%%% Leif Kornstaedt, 1998
%%%
%%% Last change:
%%% $Date$ by $Author$
%%% $Revision$
%%%
%%% This file is part of Mozart, an implementation of Oz 3:
%%% http://www.mozart-oz.org
%%%
%%% See the file "LICENSE" or
%%% http://www.mozart-oz.org/LICENSE.html
%%% for information on usage and redistribution
%%% of this file, and for a DISCLAIMER OF ALL
%%% WARRANTIES.
%%%
proc {EvalExpression VS Env ?Kill ?Result} E I S in
E = {New Engine init()}
I = {New Interface init(E)}
{E enqueue(mergeEnv(Env))}
{E enqueue(setSwitch(expression true))}
{E enqueue(setSwitch(threadedqueries false))}
{E enqueue(feedVirtualString(VS return(result: ?Result)))}
thread T in
T = {Thread.this}
proc {Kill}
{E clearQueue()}
{E interrupt()}
try
{Thread.terminate T}
S = killed
catch _ then skip % already dead
end
end
{I sync()}
if {I hasErrors($)} then Ms in
{I getMessages(?Ms)}
S = error(compiler(evalExpression VS Ms))
else
S = success
end
end
case S of error(M) then
{Exception.raiseError M}
[] success then skip
[] killed then skip
end
end
fun {VirtualStringToValue VS}
{EvalExpression VS env() _}
end