forked from jensnicolay/jipda
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstore.js
More file actions
151 lines (136 loc) · 2.84 KB
/
Copy pathstore.js
File metadata and controls
151 lines (136 loc) · 2.84 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
"use strict";
"use strong";
function Store(map)
{
this.map = map;
}
Store.empty =
function ()
{
return new Store(HashMap.empty());
}
Store.prototype.equals =
function (x)
{
if (!(x instanceof Store))
{
return false;
}
return this.map.equals(x.map);
}
Store.prototype.hashCode =
function ()
{
return this.map.hashCode();
}
//Store.prototype.compareTo =
// function (x)
// {
// return Lattice.subsumeComparison(this, x);
// }
Store.prototype.subsumes =
function (x)
{
if (!(x instanceof Store))
{
return false;
}
return this.map.subsumes(x.map);
}
Store.prototype.diff = // debug
function (x)
{
const diff = [];
const entries = this.map.entries();
for (let i = 0; i < entries.length; i++)
{
const entry = entries[i];
const address = entry[0];
const value = entry[1];
const xvalue = x.map.get(address);
if (xvalue)
{
if (!value.equals(xvalue))
{
// else
// {
diff.push(address + ":\n\t" + value + "\n\t" + xvalue);
// }
if (value.aval.isBenv && xvalue.aval.isBenv)
{
diff.push(value.aval.diff(xvalue.aval))
}
}
}
else
{
diff.push(address + ":\n\t" + value + "\n\t<undefined>");
}
}
const xentries = x.map.entries();
for (i = 0; i < xentries.length; i++)
{
const xentry = xentries[i];
const address = xentry[0];
const xvalue = xentry[1];
const value = this.map.get(address);
if (!value)
{
diff.push(address + ":\n\t<undefined>\n\t" + xvalue);
}
}
return diff.join("\n");
}
Store.prototype.toString =
function ()
{
return this.map.toString();
}
Store.prototype.nice =
function ()
{
return this.map.nice();
}
Store.prototype.lookupAval =
function (address)
{
const value = this.map.get(address);
if (value)
{
return value;
}
throw new Error("no value at address " + address + "\n" + this.nice());
}
Store.prototype.allocAval =
function (address, aval)
{
const map = this.map;
const newValue = (map.get(address) || BOT).join(aval);
return new Store(map.put(address, newValue));
}
Store.prototype.updateAval =
function (address, aval)
{
const map = this.map;
const value = map.get(address);
if (value === undefined)
{
throw new Error("no value at address " + address);
}
return new Store(map.put(address, value.join(aval)));
}
//Store.prototype.join =
// function (store)
// {
// return new Store(this.map.join(result.map));
// }
Store.prototype.narrow =
function (addresses)
{
return new Store(this.map.narrow(addresses));
}
Store.prototype.keys =
function ()
{
return this.map.keys();
}