Class: TypeProf::Core::AST::SigTyTupleNode

Inherits:
SigTyNode show all
Defined in:
lib/typeprof/core/ast/sig_type.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#changes, #lenv, #prev_node, #ret, #static_ret

Instance Method Summary collapse

Methods inherited from SigTyNode

#contravariant_vertex, #covariant_vertex

Methods inherited from Node

#attrs, #boxes, #code_range, #define, #define0, #define_copy, #diagnostics, #diff, #each_subnode, #get_vertexes, #install, #install0, #install_copy, #modified_vars, #pretty_print_instance_variables, #retrieve_at, #traverse, #undefine, #undefine0, #uninstall

Constructor Details

#initialize(raw_decl, lenv) ⇒ SigTyTupleNode

Returns a new instance of SigTyTupleNode.



452
453
454
455
# File 'lib/typeprof/core/ast/sig_type.rb', line 452

def initialize(raw_decl, lenv)
  super(raw_decl, lenv)
  @types = raw_decl.types.map {|type| AST.create_rbs_type(type, lenv) }
end

Instance Attribute Details

#typesObject (readonly)

Returns the value of attribute types.



457
458
459
# File 'lib/typeprof/core/ast/sig_type.rb', line 457

def types
  @types
end

Instance Method Details

#contravariant_vertex0(genv, changes, vtx, subst) ⇒ Object



470
471
472
473
474
475
476
477
478
# File 'lib/typeprof/core/ast/sig_type.rb', line 470

def contravariant_vertex0(genv, changes, vtx, subst)
  unified_elem = changes.new_contravariant_vertex(genv, [self, :Elem]) # TODO
  elems = @types.map do |type|
    nvtx = type.contravariant_vertex(genv, changes, subst)
    changes.add_edge(genv, nvtx, unified_elem)
    nvtx
  end
  changes.add_edge(genv, Source.new(Type::Array.new(genv, elems, genv.gen_ary_type(unified_elem))), vtx)
end

#covariant_vertex0(genv, changes, vtx, subst) ⇒ Object



460
461
462
463
464
465
466
467
468
# File 'lib/typeprof/core/ast/sig_type.rb', line 460

def covariant_vertex0(genv, changes, vtx, subst)
  unified_elem = changes.new_covariant_vertex(genv, [self, :Elem]) # TODO
  elems = @types.map do |type|
    nvtx = type.covariant_vertex(genv, changes, subst)
    changes.add_edge(genv, nvtx, unified_elem)
    nvtx
  end
  changes.add_edge(genv, Source.new(Type::Array.new(genv, elems, genv.gen_ary_type(unified_elem))), vtx)
end

#showObject



480
481
482
# File 'lib/typeprof/core/ast/sig_type.rb', line 480

def show
  "[#{ @types.map {|ty| ty.show }.join(", ") }]"
end

#subnodesObject



458
# File 'lib/typeprof/core/ast/sig_type.rb', line 458

def subnodes = { types: }