Class: MilkTea::Types::Dyn

Inherits:
Base
  • Object
show all
Defined in:
lib/milk_tea/core/types/types.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#accept, #bitwise?, #boolean?, #field_c_name, #float?, #integer?, #numeric?, #sendable?, #void?

Constructor Details

#initialize(interface_binding, type_arguments = []) ⇒ Dyn

Returns a new instance of Dyn.



1609
1610
1611
1612
1613
1614
# File 'lib/milk_tea/core/types/types.rb', line 1609

def initialize(interface_binding, type_arguments = [])
  @interface_binding = interface_binding
  @type_arguments = type_arguments
  @hash = [self.class, interface_binding, type_arguments].hash
  freeze
end

Instance Attribute Details

#hashObject (readonly)

Returns the value of attribute hash.



1622
1623
1624
# File 'lib/milk_tea/core/types/types.rb', line 1622

def hash
  @hash
end

#interface_bindingObject (readonly)

Returns the value of attribute interface_binding.



1607
1608
1609
# File 'lib/milk_tea/core/types/types.rb', line 1607

def interface_binding
  @interface_binding
end

#type_argumentsObject (readonly)

Returns the value of attribute type_arguments.



1607
1608
1609
# File 'lib/milk_tea/core/types/types.rb', line 1607

def type_arguments
  @type_arguments
end

Instance Method Details

#childrenObject



1637
1638
1639
# File 'lib/milk_tea/core/types/types.rb', line 1637

def children
  type_arguments
end

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


1616
1617
1618
# File 'lib/milk_tea/core/types/types.rb', line 1616

def eql?(other)
  other.is_a?(Dyn) && other.interface_binding == interface_binding && other.type_arguments == type_arguments
end

#field(name) ⇒ Object



1632
1633
1634
1635
# File 'lib/milk_tea/core/types/types.rb', line 1632

def field(name)
  void_ptr = GenericInstance.new("ptr", [Primitive.new("void")])
  { "data" => void_ptr, "vtable" => void_ptr }[name]
end

#to_sObject



1624
1625
1626
1627
1628
1629
1630
# File 'lib/milk_tea/core/types/types.rb', line 1624

def to_s
  if type_arguments.any?
    "dyn[#{interface_binding.name}[#{type_arguments.map(&:to_s).join(', ')}]]"
  else
    "dyn[#{interface_binding.name}]"
  end
end