Sha256: a0f471b2cfdfab6998af2d608007923464c46867b066bfccb00d8dc8f0921b23

Contents?: true

Size: 1.31 KB

Versions: 4

Compression:

Stored size: 1.31 KB

Contents

# encoding: utf-8
# frozen_string_literal: true

module Carbon
  module Core
    module Integer
      # Defines the integer types.  This uses the {Core::Ints} list to
      # determine the integer types that will be defined, and defines them with
      # the `:internal` type.  This defines the following integer types:
      #
      # - `Carbon::Int8`, `Carbon::UInt8`
      # - `Carbon::Int16`, `Carbon::UInt16`
      # - `Carbon::Int32`, `Carbon::UInt32`
      # - `Carbon::Int64`, `Carbon::UInt64`
      #
      # @api private
      module Type
        # Defines all of the integer types.
        #
        # @return [void]
        def define_integer_types
          Ints.each { |int| define_integer_type(int) }
        end

        # Defines the integer type for the given integer information.  All
        # integers implement both the `Carbon::Sized` and `Carbon::Numeric`
        # traits.
        #
        # @param int [Core::Int] The integer type.
        # @return [void]
        def define_integer_type(int)
          Core.define(internal: int.name) do |internal|
            internal[:kind] = :integer
            internal[:size] = int.size
            internal[:implements] << Carbon::Type("Carbon::Sized")
            internal[:implements] << Carbon::Type("Carbon::Numeric")
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
carbon-core-0.2.1 lib/carbon/core/integer/type.rb
carbon-core-0.2.0 lib/carbon/core/integer/type.rb
carbon-core-0.1.1 lib/carbon/core/integer/type.rb
carbon-core-0.1.0 lib/carbon/core/integer/type.rb