pub fn const_int_of_string(ty: &TypeRef, text: &str, radix: u8) -> ValueRef
Expand description
Obtain a constant value for an integer parsed from a string.
A similar API, const_int_of_string_and_size
is also available. If the
string’s length is available, it is preferred to call that function
instead.
§Details
Creates a constant integer value by parsing a string representation of the integer.
This function wraps the LLVMConstIntOfString
function from the LLVM core library. It generates a constant
integer value of the specified type (ty
) by parsing the provided string (text
) according to the specified
radix (radix
). This function is useful when you need to create constant integers from string literals in various bases
(e.g., binary, octal, decimal, hexadecimal).
§Parameters
ty
: A reference to the integer type (TypeRef
) for the constant value. This type specifies the bit width and signedness of the integer.text
: A string slice that represents the integer value to be parsed. The string should be a valid representation of an integer in the specified radix.radix
: The radix (or base) used to interpret the string. Common values include 2 (binary), 8 (octal), 10 (decimal), and 16 (hexadecimal).
§Returns
Returns an instance of ValueRef
, which encapsulates the constant integer value parsed from the string at compile time.