示例#1
0
 def test_load_mem(self) -> None:
     if IS_32_BIT_PLATFORM:
         self.assert_emit(LoadMem(bool_rprimitive, self.i32),
                          """cpy_r_r0 = *(char *)cpy_r_i32;""")
     else:
         self.assert_emit(LoadMem(bool_rprimitive, self.i64),
                          """cpy_r_r0 = *(char *)cpy_r_i64;""")
示例#2
0
 def builtin_len(self, val: Value, line: int) -> Value:
     typ = val.type
     if is_list_rprimitive(typ) or is_tuple_rprimitive(typ):
         elem_address = self.add(GetElementPtr(val, PyVarObject, 'ob_size'))
         size_value = self.add(LoadMem(c_pyssize_t_rprimitive, elem_address, val))
         offset = self.add(LoadInt(1, line, rtype=c_pyssize_t_rprimitive))
         return self.binary_int_op(short_int_rprimitive, size_value, offset,
                                   BinaryIntOp.LEFT_SHIFT, line)
     elif is_dict_rprimitive(typ):
         size_value = self.call_c(dict_size_op, [val], line)
         offset = self.add(LoadInt(1, line, rtype=c_pyssize_t_rprimitive))
         return self.binary_int_op(short_int_rprimitive, size_value, offset,
                                   BinaryIntOp.LEFT_SHIFT, line)
     elif is_set_rprimitive(typ):
         elem_address = self.add(GetElementPtr(val, PySetObject, 'used'))
         size_value = self.add(LoadMem(c_pyssize_t_rprimitive, elem_address, val))
         offset = self.add(LoadInt(1, line, rtype=c_pyssize_t_rprimitive))
         return self.binary_int_op(short_int_rprimitive, size_value, offset,
                                   BinaryIntOp.LEFT_SHIFT, line)
     # generic case
     else:
         return self.call_c(generic_len_op, [val], line)
示例#3
0
 def test_load_mem(self) -> None:
     self.assert_emit(LoadMem(bool_rprimitive, self.ptr, None),
                      """cpy_r_r0 = *(char *)cpy_r_ptr;""")
     self.assert_emit(LoadMem(bool_rprimitive, self.ptr, self.s1),
                      """cpy_r_r0 = *(char *)cpy_r_ptr;""")