angr/simos/javavm.py
def cast_primitive(state, value, to_type):
        """
        Cast the value of primtive types.

        :param value:       Bitvector storing the primitive value.
        :param to_type:     Name of the targeted type.
        :return:            Resized value.
        """
        if to_type in ['float', 'double']:
            if value.symbolic:
                # TODO extend support for floating point types
                l.warning('No support for symbolic floating-point arguments.'
                          'Value gets concretized.')
            value = float(state.solver.eval(value))
            sort = FSORT_FLOAT if to_type == 'float' else FSORT_DOUBLE
            return FPV(value, sort)

        elif to_type == 'int' and isinstance(value, FP):
            # TODO fix fpToIEEEBV in claripty
            l.warning('Converting FP to BV might provide incorrect results.')
            return fpToIEEEBV(value)[63:32]

        elif to_type == 'long' and isinstance(value, FP):
            # TODO fix fpToIEEEBV in claripty
            l.warning('Converting FP to BV might provide incorrect results.')
            return fpToIEEEBV(value)

        else:
            # lookup the type size and extract value
            value_size = ArchSoot.sizeof[to_type]
            value_extracted = value.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 to_type in ['char', 'boolean']:
                # unsigned extend
                return value_extracted.zero_extend(value_soot_size-value_extracted.size())
            # signed extend
            return value_extracted.sign_extend(value_soot_size-value_extracted.size())

        Cast the value of primtive types.

        :param value:       Bitvector storing the primitive value.
        :param to_type:     Name of the targeted type.
        :return:            Resized value.
        
Cast the value of primtive types.
Cast the value of primtive types .
def cast_primitive(state, value, to_type):
        if to_type in ['float', 'double']:
            if value.symbolic:
                l.warning('No support for symbolic floating-point arguments.'
                          'Value gets concretized.')
            value = float(state.solver.eval(value))
            sort = FSORT_FLOAT if to_type == 'float' else FSORT_DOUBLE
            return FPV(value, sort)
        elif to_type == 'int' and isinstance(value, FP):
            l.warning('Converting FP to BV might provide incorrect results.')
            return fpToIEEEBV(value)[63:32]
        elif to_type == 'long' and isinstance(value, FP):
            l.warning('Converting FP to BV might provide incorrect results.')
            return fpToIEEEBV(value)
        else:
            value_size = ArchSoot.sizeof[to_type]
            value_extracted = value.reversed.get_bytes(index=0, size=value_size//8).reversed
            value_soot_size = value_size if value_size >= 32 else 32
            if to_type in ['char', 'boolean']:
                return value_extracted.zero_extend(value_soot_size-value_extracted.size())
            return value_extracted.sign_extend(value_soot_size-value_extracted.size())
def cast_primitive ( state , value , to_type ) : if to_type in [ 'float' , 'double' ] : if value . symbolic : l . warning ( 'No support for symbolic floating-point arguments.' 'Value gets concretized.' ) value = float ( state . solver . eval ( value ) ) sort = FSORT_FLOAT if to_type == 'float' else FSORT_DOUBLE return FPV ( value , sort ) elif to_type == 'int' and isinstance ( value , FP ) : l . warning ( 'Converting FP to BV might provide incorrect results.' ) return fpToIEEEBV ( value ) [ 63 : 32 ] elif to_type == 'long' and isinstance ( value , FP ) : l . warning ( 'Converting FP to BV might provide incorrect results.' ) return fpToIEEEBV ( value ) else : value_size = ArchSoot . sizeof [ to_type ] value_extracted = value . reversed . get_bytes ( index = 0 , size = value_size // 8 ) . reversed value_soot_size = value_size if value_size >= 32 else 32 if to_type in [ 'char' , 'boolean' ] : return value_extracted . zero_extend ( value_soot_size - value_extracted . size ( ) ) return value_extracted . sign_extend ( value_soot_size - value_extracted . size ( ) )
Cast the value of primtive types.
Cast the value of primtive types .
"""
        Cast the value of primtive types.

        :param value:       Bitvector storing the primitive value.
        :param to_type:     Name of the targeted type.
        :return:            Resized value.
        """ # TODO extend support for floating point types # TODO fix fpToIEEEBV in claripty # TODO fix fpToIEEEBV in claripty # lookup the type size and extract value # determine size of Soot bitvector and resize bitvector # Note: smaller types than int's are stored in a 32-bit BV # unsigned extend # signed extend
None
state
value
Bitvector storing the primitive value.
Bitvector storing the primitive value .
to_type
Name of the targeted type.
Name of the targeted type .