File: abstract-syntax/core/expression/unary/atom/number.rb

Overview
Module Structure
Class Hierarchy
Code

Overview

Module Structure

  module: <Toplevel Module>
  module: Umu#6
  module: AbstractSyntax#8
  module: Core#10
  module: Expression#12
has properties
function: make_integer / 2 #74
function: make_float / 2 #82
  module: Unary#14
  module: Atom#16
  module: Number#18
  class: Abstract#20
inherits from
  Abstract ( Umu::AbstractSyntax::Core::Expression::Unary::Atom )
has properties
method: initialize / 2 #21
method: to_s #28
  class: Int#34
inherits from
  Abstract ( Umu::AbstractSyntax::Core::Expression::Unary::Atom::Number )
has properties
method: initialize / 2 #35
method: __evaluate__ / 2 #44
  class: Float#50
inherits from
  Abstract ( Umu::AbstractSyntax::Core::Expression::Unary::Atom::Number )
has properties
method: initialize / 2 #51
method: __evaluate__ / 2 #60

Code

   1  # coding: utf-8
   2  # frozen_string_literal: true
   3 
   4 
   5 
   6  module Umu
   7 
   8  module AbstractSyntax
   9 
  10  module Core
  11 
  12  module Expression
  13 
  14  module Unary
  15 
  16  module Atom
  17 
  18  module Number
  19 
  20  class Abstract < Atom::Abstract
  21      def initialize(loc, obj)
  22          ASSERT.kind_of obj, ::Numeric
  23 
  24          super
  25      end
  26 
  27 
  28      def to_s
  29          self.obj.to_s
  30      end
  31  end
  32 
  33 
  34  class Int < Abstract
  35      def initialize(loc, obj)
  36          ASSERT.kind_of obj, ::Integer
  37 
  38          super
  39      end
  40 
  41 
  42  private
  43 
  44      def __evaluate__(_env, _event)
  45          VC.make_integer self.obj
  46      end
  47  end
  48 
  49 
  50  class Float < Abstract
  51      def initialize(loc, obj)
  52          ASSERT.kind_of obj, ::Float
  53 
  54          super
  55      end
  56 
  57 
  58  private
  59 
  60      def __evaluate__(_env, _event)
  61          VC.make_float self.obj
  62      end
  63  end
  64 
  65  end # Umu::AbstractSyntax::Core::Expression::Unary::Atom::Number
  66 
  67  end # Umu::AbstractSyntax::Core::Expression::Unary::Atom
  68 
  69  end # Umu::AbstractSyntax::Core::Expression::Unary
  70 
  71 
  72  module_function
  73 
  74      def make_integer(loc, obj)
  75          ASSERT.kind_of loc, LOC::Entry
  76          ASSERT.kind_of obj, ::Integer
  77 
  78          Unary::Atom::Number::Int.new(loc, obj).freeze
  79      end
  80 
  81 
  82      def make_float(loc, obj)
  83          ASSERT.kind_of loc, LOC::Entry
  84          ASSERT.kind_of obj, ::Float
  85 
  86          Unary::Atom::Number::Float.new(loc, obj).freeze
  87      end
  88 
  89  end # Umu::AbstractSyntax::Core::Expression
  90 
  91  end # Umu::AbstractSyntax::Core
  92 
  93  end # Umu::AbstractSyntax
  94 
  95  end # Umu