aboutsummaryrefslogtreecommitdiffstats
path: root/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kris7topher@gmail.com>2019-02-16 16:59:35 +0100
committerLibravatar Kristóf Marussy <kris7topher@gmail.com>2019-02-19 19:18:25 +0100
commitd3ff0e28b79ea270171f5e29510f1d2d8d23b5fd (patch)
tree2661a544fb604a4a3428f3cfe159a6eb48a87b3d /Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src
parentTwo-valued fault tree analyzer WIP (diff)
downloadVIATRA-Generator-d3ff0e28b79ea270171f5e29510f1d2d8d23b5fd.tar.gz
VIATRA-Generator-d3ff0e28b79ea270171f5e29510f1d2d8d23b5fd.tar.zst
VIATRA-Generator-d3ff0e28b79ea270171f5e29510f1d2d8d23b5fd.zip
Fix recursive use of computeIfAbsent
Diffstat (limited to 'Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src')
-rw-r--r--Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/EventMaterializer.xtend16
1 files changed, 14 insertions, 2 deletions
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/EventMaterializer.xtend b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/EventMaterializer.xtend
index 85396e4d..c9aefe51 100644
--- a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/EventMaterializer.xtend
+++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.transformation/src/hu/bme/mit/inf/dslreasoner/faulttree/transformation/cft2ft/EventMaterializer.xtend
@@ -43,7 +43,13 @@ class EventMaterializer {
43 val eventKey = new EventKey(component, eventDeclaration) 43 val eventKey = new EventKey(component, eventDeclaration)
44 pushEventKey(eventKey) 44 pushEventKey(eventKey)
45 try { 45 try {
46 materializationCache.computeIfAbsent(eventKey)[materialize(it.component, it.event)] 46 // computeIfAbsent cannot be used recursively, so we must manually cache the event.
47 var event = materializationCache.get(eventKey)
48 if (event === null) {
49 event = materialize(component, eventDeclaration)
50 materializationCache.put(eventKey, event)
51 }
52 event
47 } finally { 53 } finally {
48 popEventKey(eventKey) 54 popEventKey(eventKey)
49 } 55 }
@@ -147,7 +153,13 @@ class EventMaterializer {
147 val inputKey = new EventKey(component, inputEvent) 153 val inputKey = new EventKey(component, inputEvent)
148 pushEventKey(inputKey) 154 pushEventKey(inputKey)
149 try { 155 try {
150 multipleInputCache.computeIfAbsent(inputKey)[materializeConnectedEvents(it.component, it.event)] 156 // computeIfAbsent cannot be used recursively, so we must manually cache the event.
157 var eventCollection = multipleInputCache.get(inputKey)
158 if (eventCollection === null) {
159 eventCollection = materializeConnectedEvents(component, inputEvent)
160 multipleInputCache.put(inputKey, eventCollection)
161 }
162 eventCollection
151 } finally { 163 } finally {
152 popEventKey(inputKey) 164 popEventKey(inputKey)
153 } 165 }