<commit_before>
from .base import SimSootExpr

from archinfo import ArchSoot

import logging
l = logging.getLogger("angr.engines.soot.expressions.cast")

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

    def _execute(self):

        if self.expr.cast_type in ['double', 'float']:
            l.error('Casting of double and float types not supported.')
            return
        
        # get value
        local = self._translate_value(self.expr.value)
        value_uncasted = self.state.memory.load(local)

        # lookup the type size and extract value
        value_size = ArchSoot.primitive_types[self.expr.cast_type] 
        value_extracted = value_uncasted.reversed.get_bytes(index=0, size=value_size/8).reversed

        # determine size of Soot bitvector and resize bitvector
        # Note: smaller types than int's are stored in a 32-bit BV 
        value_soot_size = value_size if value_size >= 32 else 32
        if self.expr.cast_type in ['char', 'boolean']:
            # unsigned extend
            value_casted = value_extracted.zero_extend(value_soot_size-value_size)
        else:
            # signed extend
            value_casted = value_extracted.sign_extend(value_soot_size-value_size)

        self.expr = value_casted<commit_msg>Use correct dict for the type sizes<commit_after>
from .base import SimSootExpr

from archinfo import ArchSoot

import logging
l = logging.getLogger("angr.engines.soot.expressions.cast")

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

    def _execute(self):

        if self.expr.cast_type in ['double', 'float']:
            l.error('Casting of double and float types not supported.')
            return
        
        # get value
        local = self._translate_value(self.expr.value)
        value_uncasted = self.state.memory.load(local)

        # lookup the type size and extract value
        value_size = ArchSoot.sizeof[self.expr.cast_type] 
        value_extracted = value_uncasted.reversed.get_bytes(index=0, size=value_size/8).reversed

        # determine size of Soot bitvector and resize bitvector
        # Note: smaller types than int's are stored in a 32-bit BV 
        value_soot_size = value_size if value_size >= 32 else 32
        if self.expr.cast_type in ['char', 'boolean']:
            # unsigned extend
            value_casted = value_extracted.zero_extend(value_soot_size-value_size)
        else:
            # signed extend
            value_casted = value_extracted.sign_extend(value_soot_size-value_size)

        self.expr = value_casted
{'fraction_non_alphanumeric': 0.08182823442683376, 'fraction_numerical': 0.005897530409141172, 'mean_word_length': 2.7746870653685676, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4025007', 'n_tokens_mistral': 842, 'n_tokens_neox': 805, 'n_words': 201}