Class: SFRP::Flat::MatchExp::Pattern
- Inherits:
-
Struct
- Object
- Struct
- SFRP::Flat::MatchExp::Pattern
- Defined in:
- lib/sfrp/flat/expression.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
-
#ref_var_str ⇒ Object
Returns the value of attribute ref_var_str.
-
#sp ⇒ Object
Returns the value of attribute sp.
-
#vconst_str ⇒ Object
Returns the value of attribute vconst_str.
Instance Method Summary collapse
- #alpha_convert(table, serial) ⇒ Object
- #duplicated_var_check ⇒ Object
- #to_poly ⇒ Object
- #var_strs ⇒ Object
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args
58 59 60 |
# File 'lib/sfrp/flat/expression.rb', line 58 def args @args end |
#ref_var_str ⇒ Object
Returns the value of attribute ref_var_str
58 59 60 |
# File 'lib/sfrp/flat/expression.rb', line 58 def ref_var_str @ref_var_str end |
#sp ⇒ Object
Returns the value of attribute sp
58 59 60 |
# File 'lib/sfrp/flat/expression.rb', line 58 def sp @sp end |
#vconst_str ⇒ Object
Returns the value of attribute vconst_str
58 59 60 |
# File 'lib/sfrp/flat/expression.rb', line 58 def vconst_str @vconst_str end |
Instance Method Details
#alpha_convert(table, serial) ⇒ Object
59 60 61 62 63 64 |
# File 'lib/sfrp/flat/expression.rb', line 59 def alpha_convert(table, serial) new_ref_var_str = ref_var_str && (table[ref_var_str] = "_alpha#{serial.shift}") new_args = args.map { |a| a.alpha_convert(table, serial) } Pattern.new(vconst_str, new_ref_var_str, new_args) end |
#duplicated_var_check ⇒ Object
70 71 72 73 74 75 |
# File 'lib/sfrp/flat/expression.rb', line 70 def duplicated_var_check vstrs = var_strs vstrs.each do |s| raise DuplicatedVariableError.new(s) if vstrs.count(s) > 1 end end |
#to_poly ⇒ Object
77 78 79 |
# File 'lib/sfrp/flat/expression.rb', line 77 def to_poly Poly::Pattern.new(vconst_str, ref_var_str, args.map(&:to_poly)) end |
#var_strs ⇒ Object
66 67 68 |
# File 'lib/sfrp/flat/expression.rb', line 66 def var_strs [ref_var_str, *args.flat_map(&:var_strs)].reject(&:nil?) end |