asIntegral
Function parameters
Parameters
Expressions can be evaluated in different contexts, each requiring its own set of inputs.
Types
A stack machine that can decode and run DWARF expressions.
Functions
- StackMachine
- A stack machine that can decode and run DWARF expressions.
Error sets in this namespace
Error Sets
Source
Implementation
pub fn asIntegral(self: Value) !addr_type {
return switch (self) {
.generic => |v| v,
// TODO: For these two prongs, look up the type and assert it's integral?
.regval_type => |regval_type| regval_type.value,
.const_type => |const_type| {
const value: u64 = switch (const_type.value_bytes.len) {
1 => mem.readInt(u8, const_type.value_bytes[0..1], native_endian),
2 => mem.readInt(u16, const_type.value_bytes[0..2], native_endian),
4 => mem.readInt(u32, const_type.value_bytes[0..4], native_endian),
8 => mem.readInt(u64, const_type.value_bytes[0..8], native_endian),
else => return error.InvalidIntegralTypeSize,
};
return std.math.cast(addr_type, value) orelse error.TruncatedIntegralType;
},
};
}