Class: Chelsy::Type::Array

Inherits:
Derived show all
Defined in:
lib/chelsy/ast.rb

Overview

From: 6.7.5.3 Function declarators (including prototypes)

qualifier in parameter array declarator

A declaration of a parameter as ‘‘array of type’’ shall be adjusted to ‘‘qualified pointer to type’’, where the type qualifiers (if any) are those specified within the [ and ] of the array type derivation.

static in parameter array declarator

If the keyword static also appears within the [ and ] of the array type derivation, then for each call to the function, the value of the corresponding actual argument shall provide access to the first element of an array with at least as many elements as specified by the size expression.

Instance Attribute Summary collapse

Attributes inherited from Element

#fragments, #post_fragments

Instance Method Summary collapse

Methods inherited from Base

#const?, #qualified?, #volatile?

Constructor Details

#initialize(element_type, size = nil, static: false, **rest) ⇒ Array

Returns a new instance of Array.



416
417
418
419
420
421
422
# File 'lib/chelsy/ast.rb', line 416

def initialize(element_type, size = nil, static: false, **rest)
  @element_type = element_type
  @size = size && Syntax::ArraySize.ensure(size)
  @static = !!static

  super(**rest)
end

Instance Attribute Details

#element_typeObject (readonly)

Returns the value of attribute element_type.



414
415
416
# File 'lib/chelsy/ast.rb', line 414

def element_type
  @element_type
end

#sizeObject (readonly)

Returns the value of attribute size.



414
415
416
# File 'lib/chelsy/ast.rb', line 414

def size
  @size
end

Instance Method Details

#incomplete?Boolean

An array type of unknown size is an incomplete type.

Returns:

  • (Boolean)


425
# File 'lib/chelsy/ast.rb', line 425

def incomplete?; @size.nil? end

#static?Boolean

Returns:

  • (Boolean)


428
# File 'lib/chelsy/ast.rb', line 428

def static?; @static end

#variable?Boolean

Returns:

  • (Boolean)


426
# File 'lib/chelsy/ast.rb', line 426

def variable?; @size == :* end