File: environment/context/value/target.rb

Overview
Module Structure
Class Hierarchy
Code

Overview

Module Structure

  module: <Toplevel Module>
  module: Umu#6
  module: Environment#8
  module: Context#10
  module: Value#12
has properties
function: make_value_target / 1 #80
function: make_recursive_target / 1 #87
  module: Target#14
  class: Abstract#16
inherits from
  Object ( Builtin-Module )
has properties
attribute: obj [R] #17
method: initialize / 1 #20
method: pretty_print / 1 #27
method: get_value / 1 #32
  class: Value#39
inherits from
  Abstract ( Umu::Environment::Context::Value::Target )
has properties
alias: value obj #40
method: initialize / 1 #43
method: get_value / 1 #50
  class: Recursive#57
inherits from
  Abstract ( Umu::Environment::Context::Value::Target )
has properties
alias: lam_expr obj #58
method: initialize / 1 #61
method: get_value / 1 #68

Class Hierarchy

Object ( Builtin-Module )
Abstract ( Umu::Environment::Context::Value::Target ) — #16
  Value    #39
  Recursive    #57

Code

   1  # coding: utf-8
   2  # frozen_string_literal: true
   3 
   4 
   5 
   6  module Umu
   7 
   8  module Environment
   9 
  10  module Context
  11 
  12  module Value
  13 
  14  module Target
  15 
  16  class Abstract
  17      attr_reader :obj
  18 
  19 
  20      def initialize(obj)
  21          ASSERT.kind_of obj, ::Object    # Polymophism
  22 
  23          @obj = obj
  24      end
  25 
  26 
  27      def pretty_print(q)
  28          q.pp self.obj
  29      end
  30 
  31 
  32      def get_value(_context)
  33          raise X::InternalSubclassResponsibility
  34      end
  35  end
  36 
  37 
  38 
  39  class Value < Abstract
  40      alias value obj
  41 
  42 
  43      def initialize(value)
  44          ASSERT.kind_of value, VC::Top
  45 
  46          super(value)
  47      end
  48 
  49 
  50      def get_value(_context)
  51          self.value
  52      end
  53  end
  54 
  55 
  56 
  57  class Recursive < Abstract
  58      alias lam_expr obj
  59 
  60 
  61      def initialize(lam_expr)
  62          ASSERT.kind_of lam_expr, ASCEN::Lambda::Entry
  63 
  64          super(lam_expr)
  65      end
  66 
  67 
  68      def get_value(context)
  69          ASSERT.kind_of context, ECV::Abstract
  70 
  71          VC.make_function self.lam_expr, context
  72      end
  73  end
  74 
  75  end # Umu::Environment::Context::Value::Target
  76 
  77 
  78  module_function
  79 
  80      def make_value_target(value)
  81          ASSERT.kind_of value, VC::Top
  82 
  83          Target::Value.new(value).freeze
  84      end
  85 
  86 
  87      def make_recursive_target(lam_expr)
  88          ASSERT.kind_of lam_expr, ASCEN::Lambda::Entry
  89 
  90          Target::Recursive.new(lam_expr).freeze
  91      end
  92 
  93  end # Umu::Environment::Context::Value
  94 
  95  end # Umu::Environment::Context
  96 
  97  end # Umu::Environment
  98 
  99  end # Umu