Class: MilkTea::Types::Span

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) ⇒ Span

Returns a new instance of Span.



515
516
517
518
519
520
521
522
523
# File 'lib/milk_tea/core/types/types.rb', line 515

def initialize(element_type)
  @element_type = element_type
  @fields = {
    "data" => GenericInstance.new("ptr", [element_type]),
    "len" => Primitive.new("ptr_uint"),
  }.freeze
  @hash = [self.class, element_type].hash
  freeze
end

Instance Attribute Details

#element_typeObject (readonly)

Returns the value of attribute element_type.



513
514
515
# File 'lib/milk_tea/core/types/types.rb', line 513

def element_type
  @element_type
end

#hashObject (readonly)

Returns the value of attribute hash.



531
532
533
# File 'lib/milk_tea/core/types/types.rb', line 531

def hash
  @hash
end

Instance Method Details

#childrenObject



549
550
551
# File 'lib/milk_tea/core/types/types.rb', line 549

def children
  [element_type]
end

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

Returns:

  • (Boolean)


525
526
527
# File 'lib/milk_tea/core/types/types.rb', line 525

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

#field(name) ⇒ Object



541
542
543
# File 'lib/milk_tea/core/types/types.rb', line 541

def field(name)
  @fields[name]
end

#fieldsObject



537
538
539
# File 'lib/milk_tea/core/types/types.rb', line 537

def fields
  @fields
end

#nameObject



533
534
535
# File 'lib/milk_tea/core/types/types.rb', line 533

def name
  to_s
end

#to_sObject



545
546
547
# File 'lib/milk_tea/core/types/types.rb', line 545

def to_s
  "span[#{element_type}]"
end