class TypeProf::Core::AST::LiteralNode::NilNode::TrueNode::FalseNode::IntegerNode::FloatNode::RationalNode::ComplexNode::SymbolNode::InterpolatedSymbolNode::StringNode::InterpolatedStringNode::RegexpNode::InterpolatedRegexpNode::MatchLastLineNode::InterpolatedMatchLastLineNode::RangeNode::ArrayNode::HashNode
Attributes
keys[R]
keywords[R]
splat[R]
vals[R]
Public Class Methods
new(raw_node, lenv, keywords)
click to toggle source
Calls superclass method
TypeProf::Core::AST::Node::new
# File typeprof-0.30.1/lib/typeprof/core/ast/value.rb, line 260 def initialize(raw_node, lenv, keywords) super(raw_node, lenv) @keys = [] @vals = [] @keywords = keywords @splat = false raw_node.elements.each do |raw_elem| # TODO: Support :assoc_splat_node case raw_elem.type when :assoc_node @keys << AST.create_node(raw_elem.key, lenv) @vals << AST.create_node(raw_elem.value, lenv) when :assoc_splat_node @keys << nil @vals << AST.create_node(raw_elem.value, lenv) @splat = true else raise "unknown hash elem: #{ raw_elem.type }" end end end
Public Instance Methods
attrs(= { splat:, keywords: })
click to toggle source
# File typeprof-0.30.1/lib/typeprof/core/ast/value.rb, line 286 def attrs = { splat:, keywords: } def install0(genv) unified_key = Vertex.new(self) unified_val = Vertex.new(self) literal_pairs = {} @keys.zip(@vals) do |key, val| if key k = key.install(genv).new_vertex(genv, self) v = val.install(genv).new_vertex(genv, self) @changes.add_edge(genv, k, unified_key) @changes.add_edge(genv, v, unified_val) literal_pairs[key.lit] = v if key.is_a?(SymbolNode) else h = val.install(genv) # TODO: do we want to call to_hash on h? @changes.add_hash_splat_box(genv, h, unified_key, unified_val) end end if @splat Source.new(genv.gen_hash_type(unified_key, unified_val)) else Source.new(Type::Hash.new(genv, literal_pairs, genv.gen_hash_type(unified_key, unified_val))) end end end
install0(genv)
click to toggle source
# File typeprof-0.30.1/lib/typeprof/core/ast/value.rb, line 288 def install0(genv) unified_key = Vertex.new(self) unified_val = Vertex.new(self) literal_pairs = {} @keys.zip(@vals) do |key, val| if key k = key.install(genv).new_vertex(genv, self) v = val.install(genv).new_vertex(genv, self) @changes.add_edge(genv, k, unified_key) @changes.add_edge(genv, v, unified_val) literal_pairs[key.lit] = v if key.is_a?(SymbolNode) else h = val.install(genv) # TODO: do we want to call to_hash on h? @changes.add_hash_splat_box(genv, h, unified_key, unified_val) end end if @splat Source.new(genv.gen_hash_type(unified_key, unified_val)) else Source.new(Type::Hash.new(genv, literal_pairs, genv.gen_hash_type(unified_key, unified_val))) end end
subnodes(= { keys:, vals: })
click to toggle source
# File typeprof-0.30.1/lib/typeprof/core/ast/value.rb, line 285 def subnodes = { keys:, vals: } def attrs = { splat:, keywords: } def install0(genv) unified_key = Vertex.new(self) unified_val = Vertex.new(self) literal_pairs = {} @keys.zip(@vals) do |key, val| if key k = key.install(genv).new_vertex(genv, self) v = val.install(genv).new_vertex(genv, self) @changes.add_edge(genv, k, unified_key) @changes.add_edge(genv, v, unified_val) literal_pairs[key.lit] = v if key.is_a?(SymbolNode) else h = val.install(genv) # TODO: do we want to call to_hash on h? @changes.add_hash_splat_box(genv, h, unified_key, unified_val) end end if @splat Source.new(genv.gen_hash_type(unified_key, unified_val)) else Source.new(Type::Hash.new(genv, literal_pairs, genv.gen_hash_type(unified_key, unified_val))) end end end class LambdaNode < Node def install0(genv) Source.new(genv.proc_type) end end end