Pointer cast
All checks were successful
All checks were successful
This commit is contained in:
parent
1bbd783184
commit
6c244c1243
@ -529,7 +529,7 @@ pub const Value = struct {
|
||||
integer_max: *Type,
|
||||
int_from_enum,
|
||||
int_from_pointer,
|
||||
pointer_cast,
|
||||
pointer_cast: *Value,
|
||||
select,
|
||||
trap,
|
||||
truncate: *Value,
|
||||
@ -1852,6 +1852,20 @@ pub const Module = struct {
|
||||
},
|
||||
};
|
||||
},
|
||||
.pointer_cast => blk: {
|
||||
module.skip_space();
|
||||
module.expect_character(left_parenthesis);
|
||||
module.skip_space();
|
||||
const v = module.parse_value(.{});
|
||||
module.expect_character(right_parenthesis);
|
||||
break :blk .{
|
||||
.bb = .{
|
||||
.intrinsic = .{
|
||||
.pointer_cast = v,
|
||||
},
|
||||
},
|
||||
};
|
||||
},
|
||||
.truncate => blk: {
|
||||
module.skip_space();
|
||||
module.expect_character(left_parenthesis);
|
||||
@ -2934,6 +2948,10 @@ pub const Module = struct {
|
||||
const truncate = module.llvm.builder.create_truncate(llvm_value, value_type.llvm.handle.?);
|
||||
break :blk truncate;
|
||||
},
|
||||
.pointer_cast => |pointer_value| blk: {
|
||||
module.emit_value(function, pointer_value);
|
||||
break :blk pointer_value.llvm.?;
|
||||
},
|
||||
else => @trap(),
|
||||
},
|
||||
.dereference => |dereferenceable_value| blk: {
|
||||
@ -3412,6 +3430,21 @@ pub const Module = struct {
|
||||
module.report_error();
|
||||
}
|
||||
},
|
||||
.pointer_cast => |pointer_value| {
|
||||
if (expected_type.bb != .pointer) {
|
||||
module.report_error();
|
||||
}
|
||||
module.analyze_value_type(function, pointer_value, .{});
|
||||
const pointer_type = pointer_value.type orelse module.report_error();
|
||||
|
||||
if (pointer_type == expected_type) {
|
||||
module.report_error();
|
||||
}
|
||||
|
||||
if (pointer_type.bb != .pointer) {
|
||||
module.report_error();
|
||||
}
|
||||
},
|
||||
.truncate => |value_to_truncate| {
|
||||
module.analyze_value_type(function, value_to_truncate, .{});
|
||||
if (expected_type.get_bit_size() >= value_to_truncate.type.?.get_bit_size()) {
|
||||
|
@ -189,10 +189,12 @@ const names = &[_][]const u8{
|
||||
"extend",
|
||||
"stack_negation",
|
||||
"stack_add",
|
||||
"stack_sub",
|
||||
"integer_max",
|
||||
"integer_hex",
|
||||
"basic_pointer",
|
||||
"basic_call",
|
||||
"pointer",
|
||||
"pointer_cast",
|
||||
"u1_return",
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user