Method: Crokus::CFGBuilder#visitIf

Defined in:
lib/crokus/cfg_builder.rb

#visitIf(if_, args = nil) ⇒ Object



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/crokus/cfg_builder.rb', line 91

def visitIf if_,args=nil
  cond=if_.cond.accept(self,:as_expr)
  @cfg << trueBranch =BasicBlock.new
  @cfg << falseBranch=BasicBlock.new
  @cfg << mergeBranch=BasicBlock.new
  @current << ITE.new(cond,trueBranch,falseBranch)

  @current.to trueBranch
  @current.to falseBranch
  #-----------
  @current=trueBranch
  if_.body.accept(self) #may change @current !
  @current.to mergeBranch
  #
  @current=falseBranch
  if_.else.accept(self) if if_.else #may change @current !
  @current.to mergeBranch
  @current=mergeBranch
end