def _cast_to_bit(self, value_ref): ty = llvm_rffi.LLVMTypeOf(value_ref) if ty == self.cpu.ty_bit: return value_ref else: return llvm_rffi.LLVMBuildTrunc(self.builder, value_ref, self.cpu.ty_bit, "")
def _cast_to_unichar(self, value_ref): ty = llvm_rffi.LLVMTypeOf(value_ref) if ty == self.cpu.ty_unichar: return value_ref elif ty == self.cpu.ty_int: return llvm_rffi.LLVMBuildTrunc(self.builder, value_ref, self.cpu.ty_char, "") elif ty == self.cpu.ty_bit or ty == self.cpu.ty_char: return llvm_rffi.LLVMBuildZExt(self.builder, value_ref, self.cpu.ty_char, "") else: raise AssertionError("type is not an int nor a bit")