Class: Carbon::Core::Int Private
- Inherits:
-
Object
- Object
- Carbon::Core::Int
- Defined in:
- lib/carbon/core/int.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
An integer type in Carbon. The integer types are kept in here in order to keep track of the properties of each integer type.
Instance Attribute Summary collapse
-
#cast ⇒ ::String
readonly
The name of the function that casts another integer to this one.
-
#name ⇒ Carbon::Concrete::Type
readonly
The name of the integer type.
-
#sign ⇒ ::Symbol
readonly
The signage of the integer type.
-
#size ⇒ ::Integer
readonly
The number of bits in the integer.
Class Method Summary collapse
-
.find(size:, sign:) ⇒ Int?
private
Finds a specific integer with the given size and signage.
Instance Method Summary collapse
-
#initialize(name, cast, sign, size) ⇒ Int
constructor
private
Initialize the int.
Constructor Details
#initialize(name, cast, sign, size) ⇒ Int
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize the int.
61 62 63 64 65 66 67 68 |
# 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 |
Instance Attribute Details
#cast ⇒ ::String (readonly)
The name of the function that casts another integer to this one.
25 26 27 |
# File 'lib/carbon/core/int.rb', line 25 def cast @cast end |
#name ⇒ Carbon::Concrete::Type (readonly)
The name of the integer type.
17 18 19 |
# File 'lib/carbon/core/int.rb', line 17 def name @name end |
#sign ⇒ ::Symbol (readonly)
The signage of the integer type. This is either :signed
or
:unsigned
. :signed
implies two's compliment.
34 35 36 |
# File 'lib/carbon/core/int.rb', line 34 def sign @sign end |
#size ⇒ ::Integer (readonly)
The number of bits in the integer. This is normally a power of two.
42 43 44 |
# File 'lib/carbon/core/int.rb', line 42 def size @size end |
Class Method Details
.find(size:, sign:) ⇒ Int?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Finds a specific integer with the given size and signage. Uses Carbon::Core::Ints as the base.
51 52 53 |
# File 'lib/carbon/core/int.rb', line 51 def self.find(size:, sign:) Ints.find { |i| i.size == size && i.sign == sign } end |