class TypeProf::Core::AST::BranchNode::LoopNode::BreakNode::NextNode::WhenNode::CaseNode::CaseMatchNode::AndNode::OrNode
Attributes
Public Class Methods
Source
# File bundled-src/typeprof-0.31.1/lib/typeprof/core/ast/control.rb, line 441 def initialize(raw_node, e1 = nil, raw_e2 = raw_node.right, lenv) super(raw_node, lenv) @e1 = e1 || AST.create_node(raw_node.left, lenv) @e2 = AST.create_node(raw_e2 || raw_node.right, lenv) 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 452 def install0(genv) ret = Vertex.new(self) v1 = @e1.install(genv) v1 = NilFilter.new(genv, self, v1, false).next_vtx # For OR: if left side is falsy, apply negated narrowing to right side # Use legacy detect_narrowing for now to maintain compatibility _then_narrowing, else_narrowing = @e1.narrowings if else_narrowing # For OR: negated narrowing (negate: true) v2 = AST.with_narrowing(genv, self, @lenv, else_narrowing) do @e2.install(genv) end else v2 = @e2.install(genv) end @changes.add_edge(genv, v1, ret) @changes.add_edge(genv, v2, ret) ret end
Source
# File bundled-src/typeprof-0.31.1/lib/typeprof/core/ast/control.rb, line 476 def narrowings @narrowings ||= begin e1_then_narrowing, e1_else_narrowing = @e1.narrowings e2_then_narrowing, e2_else_narrowing = @e2.narrowings [e1_then_narrowing.or(e2_then_narrowing), e1_else_narrowing.and(e2_else_narrowing)] end end
Source
# File bundled-src/typeprof-0.31.1/lib/typeprof/core/ast/control.rb, line 450 def subnodes = { e1:, e2: } def install0(genv) ret = Vertex.new(self) v1 = @e1.install(genv) v1 = NilFilter.new(genv, self, v1, false).next_vtx # For OR: if left side is falsy, apply negated narrowing to right side # Use legacy detect_narrowing for now to maintain compatibility _then_narrowing, else_narrowing = @e1.narrowings if else_narrowing # For OR: negated narrowing (negate: true) v2 = AST.with_narrowing(genv, self, @lenv, else_narrowing) do @e2.install(genv) end else v2 = @e2.install(genv) end @changes.add_edge(genv, v1, ret) @changes.add_edge(genv, v2, ret) ret end def narrowings @narrowings ||= begin e1_then_narrowing, e1_else_narrowing = @e1.narrowings e2_then_narrowing, e2_else_narrowing = @e2.narrowings [e1_then_narrowing.or(e2_then_narrowing), e1_else_narrowing.and(e2_else_narrowing)] end end end