Class: SFRP::Flat::Function

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#expObject

Returns the value of attribute exp

Returns:

  • (Object)

    the current value of exp



3
4
5
# File 'lib/sfrp/flat/elements.rb', line 3

def exp
  @exp
end

#ffi_strObject

Returns the value of attribute ffi_str

Returns:

  • (Object)

    the current value of ffi_str



3
4
5
# File 'lib/sfrp/flat/elements.rb', line 3

def ffi_str
  @ffi_str
end

#pstrsObject

Returns the value of attribute pstrs

Returns:

  • (Object)

    the current value of pstrs



3
4
5
# File 'lib/sfrp/flat/elements.rb', line 3

def pstrs
  @pstrs
end

#ptasObject

Returns the value of attribute ptas

Returns:

  • (Object)

    the current value of ptas



3
4
5
# File 'lib/sfrp/flat/elements.rb', line 3

def ptas
  @ptas
end

#ret_taObject

Returns the value of attribute ret_ta

Returns:

  • (Object)

    the current value of ret_ta



3
4
5
# File 'lib/sfrp/flat/elements.rb', line 3

def ret_ta
  @ret_ta
end

#spObject

Returns the value of attribute sp

Returns:

  • (Object)

    the current value of sp



3
4
5
# File 'lib/sfrp/flat/elements.rb', line 3

def sp
  @sp
end

#strObject

Returns the value of attribute str

Returns:

  • (Object)

    the current value of str



3
4
5
# File 'lib/sfrp/flat/elements.rb', line 3

def str
  @str
end

Instance Method Details

#to_poly(_src_set, dest_set) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/sfrp/flat/elements.rb', line 4

def to_poly(_src_set, dest_set)
  pstrs.reject(&:nil?).each do |s|
    raise DuplicatedVariableError.new(s) if pstrs.count(s) > 1
  end
  dest_set << P.func(str, ret_ta && ret_ta.to_poly) do |f|
    pstrs.zip(ptas) do |s, ta|
      f.param(s, ta && ta.to_poly)
    end
    if exp
      f.exp do
        table = Hash[pstrs.map { |s| [s, s] }]
        exp.alpha_convert(table, (0..1000).to_a).to_poly
      end
    end
    f.ffi_str(ffi_str) if ffi_str
  end
end