
import logging

from .base import SimSootExpr

l = logging.getLogger('angr.engines.soot.expressions.phi')


class SimSootExpr_Phi(SimSootExpr):
    def _execute(self):
        local = [self._translate_value(v) for v, idx in self.expr.values if idx == self.state.scratch.source.block_idx][0]
        value = self.state.memory.load(local, none_if_missing=True)
        self.expr = value

@@ -162,16 +162,33 @@
 (self):%0A
+        try:%0A    
         
@@ -310,16 +310,20 @@
         
+    
 value = 
@@ -382,16 +382,20 @@
         
+    
 self.exp
@@ -404,8 +404,400 @@
 = value%0A
+        except IndexError:%0A            # TODO is there a better way to do this?%0A            local_options = %5Bself._translate_value(v) for v, idx in self.expr.values%5B::-1%5D%5D%0A            for local in local_options:%0A                value = self.state.memory.load(local, none_if_missing=True)%0A                if value is not None:%0A                    self.expr = value%0A                    return%0A%0A

Add heuristic when Phi expr fails