Class: Object

Inherits:
BasicObject
Defined in:
lib/tecsgen/core/unjoin_plugin.rb

Constant Summary collapse

@@visited =
{}
@@n_visited =
0
@@n_found =
0
@@n_plugin_proxy =
0

Instance Method Summary collapse

Instance Method Details

#find_plugin(level, object_list) ⇒ Object

do nothing now. this function is used to find remained Proxy object.



58
59
60
61
62
# File 'lib/tecsgen/core/unjoin_plugin.rb', line 58

def find_plugin level, object_list

  # find_plugin_1 level, object_list
  # print "find_plugin: n_visted=", @@n_visited, " (len=", @@visited.length, ")  found=", @@n_found, "  proxy=", @@n_plugin_proxy, "\n"
end

#find_plugin_1(level, object_list) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/tecsgen/core/unjoin_plugin.rb', line 64

def find_plugin_1 level, object_list
  if @@visited[ self ] then
    return
  end
  @@visited[ self ] = true
  @@n_visited += 1

  if kind_of? Expression then
    # print   # Expression では print が別に定義されている
    get_elements.each{|ele|
      ele.find_plugin_1 level+1, object_list
    }
    return
  end

  if level > 100 then    # 100 is enough now, 50 is too small
    print "reached max level: "
    if respond_to? :get_name then
      print "#{get_name}(#{self.class.name})\n"
    else
      print "(#{self.class.name})\n"
    end
    return
  end

  object_list.push self                 ##### ここから return 不可

  if (kind_of? Plugin) || (kind_of? HRPSVCPlugin) then
    @@n_found += 1
    print "Plugin found: #{self.class.name}\n"
    object_list.each{ |obj|
      if obj.respond_to? :get_name then
        print "#{obj.get_name}(#{obj.class.name}), "
      else
        print "(#{obj.class.name}), "
      end
    }
    print "\n"
  elsif kind_of? Join::ThroughPluginProxy then
    @@n_plugin_proxy += 1
  end

  level += 1
  if kind_of? Array then
    each{ |val|
      val.find_plugin_1 level, object_list
    }
  elsif kind_of? Hash then
    each{ |key, val|
      key.find_plugin_1 level, object_list
      val.find_plugin_1 level, object_list
    }
  else
    instance_variables.each{|iv|
      iv_val = instance_variable_get iv
      iv_val.find_plugin_1 level, object_list
    }
  end
  object_list.pop                       ##### ここまで return 不可
end