module Carbon::Core::Integer

Manages all Integer definitions for the Core library. This includes all nine (9) types and all 1298 integer functions.

@api private

Public Class Methods

define_integer() click to toggle source

Defines all integer definitions on the Core library. This just calls {.define_integer_types} and {.define_integer_functions}.

@api private @see define_integer_types @see .define_integer_functions @return [self]

# File lib/carbon/core/integer.rb, line 37
def define_integer
  define_integer_types
  define_integer_functions
  self
end
define_integer_functions() click to toggle source

Defines all integer functions on the Core library.

@api private @see define_cast_function @see define_math_functions @see define_comp_functions @see define_ship_function @see define_next_function @see define_prev_function @see define_iabs_function @see define_size_function @see define_even_function @see define_odd_function @see define_positive_function @see define_negative_function @see define_sign_function @see define_zero_function @see define_nonzero_function @return [void]

# File lib/carbon/core/integer.rb, line 62
def define_integer_functions
  performed = Set.new
  Ints.product(Ints).each do |(first, second)|
    define_integer_functions_pair(first, second)
    define_integer_functions_one(first) unless performed.include?(first)
    performed << first
  end
end

Private Class Methods

define_integer_functions_one(first) click to toggle source

rubocop:disable Metrics/MethodLength

# File lib/carbon/core/integer.rb, line 83
def define_integer_functions_one(first)
  define_bool_function(first)
  return if first.size == 1

  # MISC
  define_next_function(first)
  define_prev_function(first)
  define_iabs_function(first)
  define_size_function(first)

  # POLE
  define_even_function(first)
  define_odd_function(first)
  define_positive_function(first)
  define_negative_function(first)

  # SIGN
  define_sign_functions(first)

  # ZERO
  define_zero_function(first)
  define_nonzero_function(first)
end
define_integer_functions_pair(first, second) click to toggle source
# File lib/carbon/core/integer.rb, line 73
def define_integer_functions_pair(first, second)
  define_cast_function(first, second) unless second.size == 1
  return if first.size == 1 || second.size == 1

  define_math_functions(first, second)
  define_comp_functions(first, second)
  define_ship_function(first, second)
end