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.



1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
# File 'lib/milk_tea/core/types.rb', line 1511

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.



1509
1510
1511
# File 'lib/milk_tea/core/types.rb', line 1509

def count
  @count
end

#element_typeObject (readonly)

Returns the value of attribute element_type.



1509
1510
1511
# File 'lib/milk_tea/core/types.rb', line 1509

def element_type
  @element_type
end

#hashObject (readonly)

Returns the value of attribute hash.



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

def hash
  @hash
end

#module_nameObject (readonly)

Returns the value of attribute module_name.



1509
1510
1511
# File 'lib/milk_tea/core/types.rb', line 1509

def module_name
  @module_name
end

#nameObject (readonly)

Returns the value of attribute name.



1509
1510
1511
# File 'lib/milk_tea/core/types.rb', line 1509

def name
  @name
end

Instance Method Details

#childrenObject



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

def children
  [element_type]
end

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

Returns:

  • (Boolean)


1527
1528
1529
# File 'lib/milk_tea/core/types.rb', line 1527

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

#field(name) ⇒ Object



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

def field(name)
  @fields[name]
end

#fieldsObject



1535
1536
1537
# File 'lib/milk_tea/core/types.rb', line 1535

def fields
  @fields
end

#to_sObject



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

def to_s
  @name
end