# encoding: utf-8 # frozen_string_literal: true require "carbon/core/integer/cast" require "carbon/core/integer/math" require "carbon/core/integer/misc" require "carbon/core/integer/pole" require "carbon/core/integer/ship" require "carbon/core/integer/sign" require "carbon/core/integer/type" require "carbon/core/integer/zero" module Carbon module Core # Manages all Integer definitions for the Core library. This includes # all nine (9) types and all 1298 integer functions. # # @api private module Integer extend Integer::Cast extend Integer::Math extend Integer::Misc extend Integer::Pole extend Integer::Ship extend Integer::Sign extend Integer::Type extend Integer::Zero class << self # 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] def define_integer define_integer_types define_integer_functions self end # 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] 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 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 # rubocop:disable Metrics/MethodLength 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 end end end end