Method: BOAST::TypeTransition#transition

Defined in:
lib/BOAST/Language/Transitions.rb

#transition(var1, var2, operator) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/BOAST/Language/Transitions.rb', line 22

def transition(var1, var2, operator)
  signed = false
  size = nil
  vector_length = 1
  t1 = var1.type.class
  t2 = var2.type.class
  t1 = var1.type.name if t1 == CustomType
  t2 = var2.type.name if t2 == CustomType
  return_type, operator = get_transition(t1, t2, operator)
  #STDERR.puts "#{return_type} : #{var1.type.class} #{operator} #{var2.type.class}"
  if t1 == return_type and t2 == return_type then
    signed = (signed or var1.type.signed)
    signed = (signed or var2.type.signed)
    size = [var1.type.size, var2.type.size].max
    vector_length = [var1.type.vector_length, var2.type.vector_length].max
    return [Variable::new("dummy", return_type, :size => size, :signed => signed, :vector_length => vector_length), operator]
  elsif var1.type.class == return_type then
    return [var1, operator]
  else # var2.type.class == return_type then
    return [var2, operator]
  end
end