class Carbon::Core::Int
An integer type in Carbon
. The integer types are kept in here in order to keep track of the properties of each integer type.
@api private
Attributes
The name of the function that casts another integer to this one.
@api public @example
int.cast # => "to-bool"
@return [::String] The cast function name.
The name of the integer type.
@api public @example
int.name # => #<Carbon::Concrete::Type Carbon::Boolean>
@return [Carbon::Concrete::Type] The name.
The signage of the integer type. This is either `:signed` or `:unsigned`. `:signed` implies two's compliment.
@api public @example
int.sign # => :unsigned
@return [::Symbol] How the integer is signed.
The number of bits in the integer. This is normally a power of two.
@api public @example
int.size # => 1
@return [::Integer] The size of the integer.
Public Class Methods
Finds a specific integer with the given size and signage. Uses {Ints} as the base.
@param size [::Integer] The size of the integer. @param sign [::Symbol] How the integer should be signed. @return [Int] If an integer with the given size and signage is found. @return [nil] Otherwise.
# File lib/carbon/core/int.rb, line 51 def self.find(size:, sign:) Ints.find { |i| i.size == size && i.sign == sign } end
Initialize the int.
@param name [Carbon::Concrete::Type] The type of the integer. @param cast [::String] The cast function name. @param sign [::Symbol] How the integer is signed. @param size [::Integer] The size of the integer, in bits.
# File lib/carbon/core/int.rb, line 61 def initialize(name, cast, sign, size) @name = name @cast = cast @sign = sign @size = size deep_freeze! end