<commit_before>#!/usr/bin/env python

import logging
l = logging.getLogger("claripy.expression")

import operator
from .storable import Storable

class A(object):
    '''
    An A(ST) tracks a tree of operations on arguments.
    '''

    def __init__(self, op, args):
        self._op = op
        self._args = args

    def eval(self, backends, save, model=None):
        args = [ ]
        for a in self._args:
            if isinstance(a, E):
                args.append(a.eval(backends=backends, save=save, model=model))
            elif isinstance(a, A):
                args.append(a.eval(backends, save, model=model))
            else:
                args.append(a)

        for b in backends:
            l.debug("trying evaluation with %s", b)
            try:
                return b.call(self._op, args, model=model)
            except BackendError:
                l.debug("... failed")
                continue

        raise Exception("eval failed with available backends")

    def __repr__(self):
        if '__' in self._op:
            return "%s.%s%s" % (self._args[0], self._op, self._args[1:])
        else:
            return "%s%s" % (self._op, self._args)

class E(Storable):
    '''
    A class to wrap expressions.
    '''
    __slots__ = [ 'length', 'variables', 'symbolic', '_uuid', '_ast', '_stored', 'objects' ]

    def __init__(self, claripy, length=None, variables=None, symbolic=None, uuid=None, objects=None, ast=None, stored=False):
        Storable.__init__(self, claripy, uuid=uuid)
        have_uuid = uuid is not None
        have_data = not (variables is None or symbolic is None or ast is None or length is None)
        self.objects = { }

        if have_uuid and not have_data:
            self._load()
        elif have_data:
            self.variables = variables
            self.symbolic = symbolic
            self.length = length

            self._uuid = uuid<commit_msg>bug fix when deciding the value of have_data in E<commit_after>#!/usr/bin/env python

import logging
l = logging.getLogger("claripy.expression")

import operator
from .storable import Storable

class A(object):
    '''
    An A(ST) tracks a tree of operations on arguments.
    '''

    def __init__(self, op, args):
        self._op = op
        self._args = args

    def eval(self, backends, save, model=None):
        args = [ ]
        for a in self._args:
            if isinstance(a, E):
                args.append(a.eval(backends=backends, save=save, model=model))
            elif isinstance(a, A):
                args.append(a.eval(backends, save, model=model))
            else:
                args.append(a)

        for b in backends:
            l.debug("trying evaluation with %s", b)
            try:
                return b.call(self._op, args, model=model)
            except BackendError:
                l.debug("... failed")
                continue

        raise Exception("eval failed with available backends")

    def __repr__(self):
        if '__' in self._op:
            return "%s.%s%s" % (self._args[0], self._op, self._args[1:])
        else:
            return "%s%s" % (self._op, self._args)

class E(Storable):
    '''
    A class to wrap expressions.
    '''
    __slots__ = [ 'length', 'variables', 'symbolic', '_uuid', '_ast', '_stored', 'objects' ]

    def __init__(self, claripy, length=None, variables=None, symbolic=None, uuid=None, objects=None, ast=None, stored=False):
        Storable.__init__(self, claripy, uuid=uuid)
        have_uuid = uuid is not None
        have_data = not (variables is None and symbolic is None and ast is None and length is None)
        self.objects = { }

        if have_uuid and not have_data:
            self._load()
        elif have_data:
            self.variables = variables
            self.symbolic = symbolic
            self.length = length

            self._uuid = uuid
{'fraction_non_alphanumeric': 0.1156515034695451, 'fraction_numerical': 0.0010280133641737343, 'mean_word_length': 2.003086419753086, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7209216', 'n_tokens_mistral': 1166, 'n_tokens_neox': 1139, 'n_words': 332}