Class: SFRP::Flat::Node

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



42
43
44
# File 'lib/sfrp/flat/elements.rb', line 42

def exp
  @exp
end

#init_expObject

Returns the value of attribute init_exp

Returns:

  • (Object)

    the current value of init_exp



42
43
44
# File 'lib/sfrp/flat/elements.rb', line 42

def init_exp
  @init_exp
end

#spObject

Returns the value of attribute sp

Returns:

  • (Object)

    the current value of sp



42
43
44
# File 'lib/sfrp/flat/elements.rb', line 42

def sp
  @sp
end

#strObject

Returns the value of attribute str

Returns:

  • (Object)

    the current value of str



42
43
44
# File 'lib/sfrp/flat/elements.rb', line 42

def str
  @str
end

#taObject

Returns the value of attribute ta

Returns:

  • (Object)

    the current value of ta



42
43
44
# File 'lib/sfrp/flat/elements.rb', line 42

def ta
  @ta
end

Instance Method Details

#initialized?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/sfrp/flat/elements.rb', line 43

def initialized?
  !init_exp.nil?
end

#to_poly(src_set, dest_set) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/sfrp/flat/elements.rb', line 47

def to_poly(src_set, dest_set)
  dest_set << P.node(str, ta && ta.to_poly) do |n|
    collected_node_refs = []
    poly_exp = exp.alpha_convert({}, (0..1000).to_a)
      .lift_node_ref(collected_node_refs).to_poly
    collected_node_refs.each do |nr|
      if nr.last && !src_set.node(nr.node_str).initialized?
        raise NodeInvalidLastReferrenceError.new(nr.node_str)
      end
      nr.last ? n.l(nr.node_str) : n.c(nr.node_str)
    end
    dest_set << n.eval_func(str, ta && ta.to_poly) do |f|
      f.exp { poly_exp }
      collected_node_refs.each_with_index.map do |_, i|
        f.param("__node_ref_#{i}")
      end
    end
    next if init_exp.nil?
    dest_set << n.init_func(str + '#init', ta && ta.to_poly) do |f|
      f.exp { init_exp.alpha_convert({}, (0..1000).to_a).to_poly }
    end
  end
end