-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path0cfa-flow.dl
39 lines (33 loc) · 1.28 KB
/
0cfa-flow.dl
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
.decl sourceLambda(exprId:number, varName:number, bodyId:number)
.decl sourceVarRef(exprId:number, varName:number)
.decl sourceApplication(exprId:number, fnId:number, argId:number)
// ((lambda (x^10) x^2)^3 (lambda (y^11) y^5)^6)^7
// Assume that variable x is named 10 and y is named 11
sourceLambda(6,7,8).
sourceLambda(1,2,3).
sourceVarRef(5,2).
sourceVarRef(4,2).
sourceVarRef(10,7).
sourceVarRef(9,7).
sourceApplication(8,9,10).
sourceApplication(0,1,6).
sourceApplication(3,4,5).
// sourceLambda(3,10,2).
// sourceLambda(6,11,5).
// sourceVarRef(2,10).
// sourceVarRef(5,11).
// sourceApplication(7,3,6).
// The flowsTo relation
.decl valueFlowsTo(value:number, expr:number)
.output valueFlowsTo
valueFlowsTo(lambdaId,lambdaId) :- sourceLambda(lambdaId,_,_).
valueFlowsTo(argVal,x) :- sourceApplication(_,fnId,argId),
valueFlowsTo(_,argId),
sourceLambda(fnId,x,_),
valueFlowsTo(argVal,argId).
valueFlowsTo(v,exprId) :- sourceVarRef(exprId,var),
valueFlowsTo(v,var).
valueFlowsTo(v,exprId) :- sourceApplication(exprId,fnId,_),
valueFlowsTo(lambdaId,fnId),
sourceLambda(lambdaId,_,bodyId),
valueFlowsTo(v,bodyId).