class TypeProf::Core::AST::BranchNode::LoopNode::BreakNode::NextNode::WhenNode
Attributes
Public Class Methods
Source
# File bundled-src/typeprof-0.31.1/lib/typeprof/core/ast/control.rb, line 255 def initialize(raw_when_node, lenv, pivot_var = nil) super(raw_when_node, lenv) @conditions = raw_when_node.conditions.map {|cond| AST.create_node(cond, lenv) } @body = raw_when_node.statements ? AST.create_node(raw_when_node.statements, lenv) : DummyNilNode.new(code_range, lenv) @pivot_var = pivot_var end
Calls superclass method
TypeProf::Core::AST::Node::new
Public Instance Methods
Source
# File bundled-src/typeprof-0.31.1/lib/typeprof/core/ast/control.rb, line 299 def get_exclusion_conditions @conditions.select {|condition| condition.is_a?(ConstantReadNode) && condition.static_ret } .map {|condition| condition.static_ret } end
else節での型除外に使用する条件を取得
Source
# File bundled-src/typeprof-0.31.1/lib/typeprof/core/ast/control.rb, line 266 def install0(genv) @conditions.each {|condition| condition.install(genv) } # 型絞り込みが必要な場合(pivot_varが設定されている場合) if @pivot_var && @lenv.locals.key?(:"*pivot") original_vtx = @lenv.locals[:"*pivot"] # 複数条件のOR(union)処理 filtered_vtxs = [] @conditions.each do |condition| if condition.is_a?(ConstantReadNode) && condition.static_ret # 各条件に対して独立して型絞り込みを適用 condition_vtx = original_vtx.new_vertex(genv, self) condition_vtx = IsAFilter.new(genv, self, condition_vtx, false, condition.static_ret).next_vtx filtered_vtxs << condition_vtx end end # 複数の絞り込み結果をマージして使用 if !filtered_vtxs.empty? merged_vtx = Vertex.new(self) filtered_vtxs.each do |vtx| @changes.add_edge(genv, vtx, merged_vtx) end @lenv.set_var(@pivot_var, merged_vtx) end end @body.install(genv) end
Source
# File bundled-src/typeprof-0.31.1/lib/typeprof/core/ast/control.rb, line 264 def subnodes = { conditions:, body: } def install0(genv) @conditions.each {|condition| condition.install(genv) } # 型絞り込みが必要な場合(pivot_varが設定されている場合) if @pivot_var && @lenv.locals.key?(:"*pivot") original_vtx = @lenv.locals[:"*pivot"] # 複数条件のOR(union)処理 filtered_vtxs = [] @conditions.each do |condition| if condition.is_a?(ConstantReadNode) && condition.static_ret # 各条件に対して独立して型絞り込みを適用 condition_vtx = original_vtx.new_vertex(genv, self) condition_vtx = IsAFilter.new(genv, self, condition_vtx, false, condition.static_ret).next_vtx filtered_vtxs << condition_vtx end end # 複数の絞り込み結果をマージして使用 if !filtered_vtxs.empty? merged_vtx = Vertex.new(self) filtered_vtxs.each do |vtx| @changes.add_edge(genv, vtx, merged_vtx) end @lenv.set_var(@pivot_var, merged_vtx) end end @body.install(genv) end # else節での型除外に使用する条件を取得 def get_exclusion_conditions @conditions.select {|condition| condition.is_a?(ConstantReadNode) && condition.static_ret } .map {|condition| condition.static_ret } end end