Class: SFRP::Poly::Set
- Inherits:
-
Object
- Object
- SFRP::Poly::Set
- Defined in:
- lib/sfrp/poly/set.rb
Instance Method Summary collapse
- #<<(element) ⇒ Object
- #append_init_func_str(init_func_str) ⇒ Object
- #append_output_node_str(node_str) ⇒ Object
- #func(func_str) ⇒ Object
-
#initialize(&block) ⇒ Set
constructor
A new instance of Set.
- #node(node_str) ⇒ Object
- #tconst(tconst_str) ⇒ Object
- #to_mono ⇒ Object
- #vconst(vconst_str) ⇒ Object
Constructor Details
#initialize(&block) ⇒ Set
Returns a new instance of Set.
11 12 13 14 15 16 17 18 19 |
# File 'lib/sfrp/poly/set.rb', line 11 def initialize(&block) @func_h = {} @node_h = {} @tconst_h = {} @vconst_h = {} @output_node_strs = [] @init_func_strs = [] block.call(self) if block end |
Instance Method Details
#<<(element) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/sfrp/poly/set.rb', line 46 def <<(element) case element when Function @func_h[element.str] = element when Node @node_h[element.str] = element when TConst @tconst_h[element.str] = element when VConst @vconst_h[element.str] = element else raise end end |
#append_init_func_str(init_func_str) ⇒ Object
65 66 67 |
# File 'lib/sfrp/poly/set.rb', line 65 def append_init_func_str(init_func_str) @init_func_strs << init_func_str end |
#append_output_node_str(node_str) ⇒ Object
61 62 63 |
# File 'lib/sfrp/poly/set.rb', line 61 def append_output_node_str(node_str) @output_node_strs << node_str end |
#func(func_str) ⇒ Object
69 70 71 72 |
# File 'lib/sfrp/poly/set.rb', line 69 def func(func_str) raise func_str unless @func_h.key?(func_str) @func_h[func_str] end |
#node(node_str) ⇒ Object
74 75 76 77 |
# File 'lib/sfrp/poly/set.rb', line 74 def node(node_str) raise node_str unless @node_h.key?(node_str) @node_h[node_str] end |
#tconst(tconst_str) ⇒ Object
79 80 81 82 |
# File 'lib/sfrp/poly/set.rb', line 79 def tconst(tconst_str) raise tconst_str unless @tconst_h.key?(tconst_str ) @tconst_h[tconst_str ] end |
#to_mono ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/sfrp/poly/set.rb', line 21 def to_mono Mono::Set.new do |dest_set| @func_h.values.each do |f| f.check_recursion(self) f.ftyping(self) end @node_h.values.each do |n| n.check_recursion(self) n.typing(self) end Monofier.new(self, dest_set) do |m| @init_func_strs.each do |func_str| mono_func_str = m.use_func(func_str, func(func_str).ftyping(self)) dest_set.append_init_func_str(mono_func_str) end @node_h.values.each do |node| dest_set << node.to_mono(m) end @output_node_strs.each do |node_str| dest_set.append_output_node_str(m.use_node(node_str)) end end end end |
#vconst(vconst_str) ⇒ Object
84 85 86 87 |
# File 'lib/sfrp/poly/set.rb', line 84 def vconst(vconst_str) raise vconst_str unless @vconst_h.key?(vconst_str) @vconst_h[vconst_str] end |