Class: SFRP::Poly::Monofier
- Inherits:
-
Object
- Object
- SFRP::Poly::Monofier
- Defined in:
- lib/sfrp/poly/monofier.rb
Instance Method Summary collapse
-
#initialize(src_set, dest_set, &block) ⇒ Monofier
constructor
A new instance of Monofier.
- #use_func(func_str, ftyping) ⇒ Object
- #use_node(node_str) ⇒ Object
- #use_type(typing) ⇒ Object
- #use_vconst(vconst_str, typing) ⇒ Object
Constructor Details
#initialize(src_set, dest_set, &block) ⇒ Monofier
Returns a new instance of Monofier.
4 5 6 7 8 9 10 11 12 |
# File 'lib/sfrp/poly/monofier.rb', line 4 def initialize(src_set, dest_set, &block) @src_set = src_set @dest_set = dest_set @type_str = {} @func_str = {} @vconst_str = {} @node_str = {} block.call(self) if block end |
Instance Method Details
#use_func(func_str, ftyping) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/sfrp/poly/monofier.rb', line 27 def use_func(func_str, ftyping) unique_func_str = func_str + '/FUNC/' + ftyping.unique_str if @func_str.key?(unique_func_str) @func_str[unique_func_str] else new_func = @src_set.func(func_str).clone mono_func_str = 'F' + md5(unique_func_str) new_func.ftyping(@src_set).unify(ftyping) @dest_set << new_func.to_mono(self, mono_func_str) @func_str[unique_func_str] = mono_func_str end end |
#use_node(node_str) ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/sfrp/poly/monofier.rb', line 53 def use_node(node_str) unique_node_str = node_str + '/NODE/' if @node_str.key?(unique_node_str) @node_str[unique_node_str] else @node_str[unique_node_str] = 'N' + md5(unique_node_str) end end |
#use_type(typing) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/sfrp/poly/monofier.rb', line 14 def use_type(typing) unique_type_str = typing.tconst_str + '/TYPE/' + typing.unique_str if @type_str.key?(unique_type_str) @type_str[unique_type_str] else @type_str[unique_type_str] = 'T' + md5(unique_type_str) new_tconst = @src_set.tconst(typing.tconst_str).clone new_tconst.typing.unify(typing) @dest_set << new_tconst.to_mono(self) @type_str[unique_type_str] end end |
#use_vconst(vconst_str, typing) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/sfrp/poly/monofier.rb', line 40 def use_vconst(vconst_str, typing) unique_vconst_str = vconst_str + '/VCONST/' + typing.unique_str if @vconst_str.key?(unique_vconst_str) @vconst_str[unique_vconst_str] else @vconst_str[unique_vconst_str] = 'V' + md5(unique_vconst_str) new_vconst = @src_set.vconst(vconst_str).clone new_vconst.ftyping.body.unify(typing) @dest_set << new_vconst.to_mono(self) @vconst_str[unique_vconst_str] end end |