<commit_before>
from .base import SimSootExpr


class SimSootExpr_Phi(SimSootExpr):
    def __init__(self, expr, state):
        super(SimSootExpr_Phi, self).__init__(expr, state)

    def _execute(self):

        if len(self.expr.values) != 2:
            import ipdb; ipdb.set_trace();

        v1, v2 = [self._translate_value(v) for v in self.expr.values]
        v = self.expr = self.state.memory.load(v1, none_if_missing=True)
        if v is None:
            v = self.expr = self.state.memory.load(v2, none_if_missing=True)
        if v is None:
            import ipdb; ipdb.set_trace();

        self.expr = v<commit_msg>Extend Phi expression to work with more than 2 values<commit_after>
from .base import SimSootExpr

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

class SimSootExpr_Phi(SimSootExpr):
    def __init__(self, expr, state):
        super(SimSootExpr_Phi, self).__init__(expr, state)

    def _execute(self):
        locals_option = [self._translate_value(v) for v in self.expr.values]
        values = []
        for local in locals_option:
            value = self.state.memory.load(local, none_if_missing=True)
            if value is not None:
                values.append(value)
        
        if len(values) == 0:
            l.warning("Couldn't find a value of Phi expression in memory.")
            return

        if len(values) > 2:
            l.warning("Found multiple values of Phi expression in memory.")
        
        self.expr = values[-1]
{'fraction_non_alphanumeric': 0.1023778071334214, 'fraction_numerical': 0.0059445178335535, 'mean_word_length': 2.404494382022472, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3087280', 'n_tokens_mistral': 484, 'n_tokens_neox': 471, 'n_words': 124}