1 |
|
2 | cached_runs = new LRUCache(100, 60000 * 60 * 24 * 265)
|
3 | cached_findDependenciesInScript = new LRUCache(100, 60000 * 60 * 24 * 265)
|
4 |
|
5 | freeze = ->
|
6 |
|
7 | frozenSymbols = []
|
8 | frozenContents = []
|
9 | frozenPatterns = []
|
10 | frozenHash = ""
|
11 |
|
12 | for i in [0...symtab.length]
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | if isSymbolReclaimable[i] == false
|
19 | frozenSymbols.push symtab[i]
|
20 | frozenContents.push binding[i]
|
21 |
|
22 |
|
23 | frozenPatterns= userSimplificationsInListForm.slice(0)
|
24 |
|
25 | return [frozenSymbols, frozenContents, frozenPatterns, zero, one, imaginaryunit, getStateHash()]
|
26 |
|
27 | unfreeze = (frozen) ->
|
28 | [frozenSymbols, frozenContents, frozenPatterns, zero, one, imaginaryunit ] = frozen
|
29 |
|
30 |
|
31 |
|
32 | for i in [0...frozenSymbols.length]
|
33 | symtab[i] = frozenSymbols[i]
|
34 | binding[i] = frozenContents[i]
|
35 |
|
36 | userSimplificationsInListForm = frozenPatterns.slice(0)
|
37 |
|
38 |
|
39 | compareState = (previousHash) ->
|
40 |
|
41 | frozenHash = getStateHash()
|
42 |
|
43 | if frozenHash == previousHash
|
44 | return true
|
45 | else
|
46 | return false
|
47 |
|
48 | resetCache = ->
|
49 | if cached_runs?
|
50 | cached_runs.reset()
|
51 | if DEBUG then console.log "resetting cached_runs"
|
52 |
|
53 | if cached_findDependenciesInScript?
|
54 | cached_findDependenciesInScript.reset()
|
55 | if DEBUG then console.log "resetting cached_findDependenciesInScript"
|
56 |
|
57 | resetCacheHitMissCounts = ->
|
58 | if cached_runs?
|
59 | cached_runs.resetHitMissCount()
|
60 |
|
61 | if cached_findDependenciesInScript?
|
62 | cached_findDependenciesInScript.resetHitMissCount()
|
63 |
|
64 | totalAllCachesHits = ->
|
65 | cached_runs.hitCount + cached_findDependenciesInScript.hitCount
|
66 |
|
67 | totalAllCachesMisses = ->
|
68 | cached_runs.missCount + cached_findDependenciesInScript.missCount
|
69 |
|
70 | getStateHash = ->
|
71 | frozenHash = ""
|
72 |
|
73 | for i in [NIL+1...symtab.length]
|
74 | if symtab[i].printname == ""
|
75 | if isSymbolReclaimable[i] == false
|
76 | break
|
77 | else
|
78 | continue
|
79 |
|
80 | symtabi = print_list(symtab[i])
|
81 | bindingi = print_list(binding[i])
|
82 |
|
83 | frozenHash += " //" + symtabi + " : " + bindingi
|
84 |
|
85 | for i in userSimplificationsInListForm
|
86 | frozenHash += " pattern: " + i
|
87 |
|
88 |
|
89 | if DEBUG then console.log "frozenHash: " + frozenHash
|
90 | return frozenHash
|