Class: MilkTea::Types::SoA

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(element_type, count:) ⇒ SoA

Returns a new instance of SoA.



1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
# File 'lib/milk_tea/core/types/types.rb', line 1522

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.



1520
1521
1522
# File 'lib/milk_tea/core/types/types.rb', line 1520

def count
  @count
end

#element_typeObject (readonly)

Returns the value of attribute element_type.



1520
1521
1522
# File 'lib/milk_tea/core/types/types.rb', line 1520

def element_type
  @element_type
end

#hashObject (readonly)

Returns the value of attribute hash.



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

def hash
  @hash
end

#module_nameObject (readonly)

Returns the value of attribute module_name.



1520
1521
1522
# File 'lib/milk_tea/core/types/types.rb', line 1520

def module_name
  @module_name
end

#nameObject (readonly)

Returns the value of attribute name.



1520
1521
1522
# File 'lib/milk_tea/core/types/types.rb', line 1520

def name
  @name
end

Instance Method Details

#childrenObject



1558
1559
1560
# File 'lib/milk_tea/core/types/types.rb', line 1558

def children
  [element_type]
end

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

Returns:

  • (Boolean)


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

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

#field(name) ⇒ Object



1550
1551
1552
# File 'lib/milk_tea/core/types/types.rb', line 1550

def field(name)
  @fields[name]
end

#fieldsObject



1546
1547
1548
# File 'lib/milk_tea/core/types/types.rb', line 1546

def fields
  @fields
end

#to_sObject



1554
1555
1556
# File 'lib/milk_tea/core/types/types.rb', line 1554

def to_s
  @name
end