Class: MilkTea::Types::SoA

Inherits:
Base
  • Object
show all
Defined in:
lib/milk_tea/core/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(element_type, count:) ⇒ SoA

Returns a new instance of SoA.



1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
# File 'lib/milk_tea/core/types.rb', line 1516

def initialize(element_type, count:)
  @name = "SoA[#{element_type}, #{count}]"
  @element_type = element_type
  @count = count
  @module_name = nil
  @fields = if element_type.respond_to?(:fields) && element_type.fields
               element_type.fields.each_with_object({}) do |(fname, ftype), h|
                 h[fname] = GenericInstance.new("array", [ftype, LiteralTypeArg.new(count)])
               end
             else
               {}.freeze
             end.freeze
  @hash = [self.class, element_type, count].hash
  freeze
end

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.



1514
1515
1516
# File 'lib/milk_tea/core/types.rb', line 1514

def count
  @count
end

#element_typeObject (readonly)

Returns the value of attribute element_type.



1514
1515
1516
# File 'lib/milk_tea/core/types.rb', line 1514

def element_type
  @element_type
end

#hashObject (readonly)

Returns the value of attribute hash.



1538
1539
1540
# File 'lib/milk_tea/core/types.rb', line 1538

def hash
  @hash
end

#module_nameObject (readonly)

Returns the value of attribute module_name.



1514
1515
1516
# File 'lib/milk_tea/core/types.rb', line 1514

def module_name
  @module_name
end

#nameObject (readonly)

Returns the value of attribute name.



1514
1515
1516
# File 'lib/milk_tea/core/types.rb', line 1514

def name
  @name
end

Instance Method Details

#childrenObject



1552
1553
1554
# File 'lib/milk_tea/core/types.rb', line 1552

def children
  [element_type]
end

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

Returns:

  • (Boolean)


1532
1533
1534
# File 'lib/milk_tea/core/types.rb', line 1532

def eql?(other)
  other.is_a?(SoA) && other.element_type == element_type && other.count == count
end

#field(name) ⇒ Object



1544
1545
1546
# File 'lib/milk_tea/core/types.rb', line 1544

def field(name)
  @fields[name]
end

#fieldsObject



1540
1541
1542
# File 'lib/milk_tea/core/types.rb', line 1540

def fields
  @fields
end

#to_sObject



1548
1549
1550
# File 'lib/milk_tea/core/types.rb', line 1548

def to_s
  @name
end