Class: SFRP::Raw::IfExp

Inherits:
Struct
  • Object
show all
Includes:
SugarExp
Defined in:
lib/sfrp/raw/expression.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SugarExp

#blame_side_effect, #to_flat, #vconst_refs

Instance Attribute Details

#cond_expObject

Returns the value of attribute cond_exp

Returns:

  • (Object)

    the current value of cond_exp



139
140
141
# File 'lib/sfrp/raw/expression.rb', line 139

def cond_exp
  @cond_exp
end

#else_expObject

Returns the value of attribute else_exp

Returns:

  • (Object)

    the current value of else_exp



139
140
141
# File 'lib/sfrp/raw/expression.rb', line 139

def else_exp
  @else_exp
end

#spObject

Returns the value of attribute sp

Returns:

  • (Object)

    the current value of sp



139
140
141
# File 'lib/sfrp/raw/expression.rb', line 139

def sp
  @sp
end

#then_expObject

Returns the value of attribute then_exp

Returns:

  • (Object)

    the current value of then_exp



139
140
141
# File 'lib/sfrp/raw/expression.rb', line 139

def then_exp
  @then_exp
end

Instance Method Details

#convertObject



142
143
144
145
146
147
148
149
150
151
152
# File 'lib/sfrp/raw/expression.rb', line 142

def convert
  cases = [
    MatchExp::Case.new(
      MatchExp::Pattern.new(Ref.new('True'), nil, [], sp), then_exp
    ),
    MatchExp::Case.new(
      MatchExp::Pattern.new(Ref.new('False'), nil, [], sp), else_exp
    )
  ]
  MatchExp.new(cond_exp, cases, sp)
end