Class: CastOff::Compiler::SimpleIR::ReturnIR

Inherits:
IR
  • Object
show all
Defined in:
lib/cast_off/compile/ir/return_ir.rb

Defined Under Namespace

Classes: ThrowObj

Instance Attribute Summary collapse

Attributes inherited from IR

#alias, #insn

Instance Method Summary collapse

Methods inherited from IR

#add_sampling_variable, #alive, #alive?, #dispatch_method?, #generate_guard, #get_definition, #get_definition_str, #get_usage, #get_variable, #inlining_target?, #propergate_guard_usage, #reset, #sampling_variable, #set_info, #standard_guard_target, #vanish, #vanish?

Methods included from Util

#bug, #dlog, #todo, #vlog

Constructor Details

#initialize(retval, throwobj, insn, cfg) ⇒ ReturnIR

Returns a new instance of ReturnIR.



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/cast_off/compile/ir/return_ir.rb', line 18

def initialize(retval, throwobj, insn, cfg)
  super(insn, cfg)
  @throwobj = throwobj
  @return_value = retval
  @values = [@return_value]
  @variables = []
  @variables_without_result = []
  if @return_value.is_a?(Variable)
    @variables << @return_value
    @variables_without_result << @return_value
  end
  @result_variable = nil
end

Instance Attribute Details

#result_variableObject (readonly)

Returns the value of attribute result_variable.



6
7
8
# File 'lib/cast_off/compile/ir/return_ir.rb', line 6

def result_variable
  @result_variable
end

#return_valueObject (readonly)

Returns the value of attribute return_value.



6
7
8
# File 'lib/cast_off/compile/ir/return_ir.rb', line 6

def return_value
  @return_value
end

#valuesObject (readonly)

Returns the value of attribute values.



6
7
8
# File 'lib/cast_off/compile/ir/return_ir.rb', line 6

def values
  @values
end

#variablesObject (readonly)

Returns the value of attribute variables.



6
7
8
# File 'lib/cast_off/compile/ir/return_ir.rb', line 6

def variables
  @variables
end

#variables_without_resultObject (readonly)

Returns the value of attribute variables_without_result.



6
7
8
# File 'lib/cast_off/compile/ir/return_ir.rb', line 6

def variables_without_result
  @variables_without_result
end

Instance Method Details

#mark(defs) ⇒ Object



70
71
72
73
74
75
76
77
78
# File 'lib/cast_off/compile/ir/return_ir.rb', line 70

def mark(defs)
  if !alive?
    alive()
    defs.mark(@return_value)
    true
  else
    false
  end
end

#propergate_boxed_value(defs) ⇒ Object



37
38
39
40
# File 'lib/cast_off/compile/ir/return_ir.rb', line 37

def propergate_boxed_value(defs)
  bug() unless @return_value.boxed?
  defs.propergate_boxed_value_backward(@return_value)
end

#propergate_exact_class(defs) ⇒ Object

unboxing end ###



43
44
45
# File 'lib/cast_off/compile/ir/return_ir.rb', line 43

def propergate_exact_class(defs)
  false
end

#to_cObject



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/cast_off/compile/ir/return_ir.rb', line 47

def to_c()
  if @insn.iseq.catch_exception?
    prereturn = "  TH_POP_TAG2();\n"
  else
    prereturn = ''
  end
  case @throwobj
  when ThrowObj 
    if @translator.inline_block?
      return prereturn + "  return_from_execute(#{@throwobj.raw_state}, #{@return_value});"
    else
      return prereturn + "  return return_block(#{@throwobj.raw_state}, #{@return_value}, lambda_p);"
    end
  when NilClass
    return prereturn + "  return #{@return_value};"
  end
  bug()
end

#type_propergation(defs) ⇒ Object



66
67
68
# File 'lib/cast_off/compile/ir/return_ir.rb', line 66

def type_propergation(defs)
  defs.type_resolve(@return_value)
end

#unboxing_preludeObject

unboxing begin ###



33
34
35
# File 'lib/cast_off/compile/ir/return_ir.rb', line 33

def unboxing_prelude()
  @return_value.box()
end