Class: SFRP::Flat::MatchExp::Pattern

Inherits:
Struct
  • Object
show all
Defined in:
lib/sfrp/flat/expression.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#argsObject

Returns the value of attribute args

Returns:

  • (Object)

    the current value of args



58
59
60
# File 'lib/sfrp/flat/expression.rb', line 58

def args
  @args
end

#ref_var_strObject

Returns the value of attribute ref_var_str

Returns:

  • (Object)

    the current value of ref_var_str



58
59
60
# File 'lib/sfrp/flat/expression.rb', line 58

def ref_var_str
  @ref_var_str
end

#spObject

Returns the value of attribute sp

Returns:

  • (Object)

    the current value of sp



58
59
60
# File 'lib/sfrp/flat/expression.rb', line 58

def sp
  @sp
end

#vconst_strObject

Returns the value of attribute vconst_str

Returns:

  • (Object)

    the current value of 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_checkObject



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_polyObject



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_strsObject



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